AwtNote.java from gzz at Krugle
Show AwtNote.java syntax highlighted
/* DO NOT EDIT THIS FILE. THIS FILE WAS GENERATED FROM ../Modules/awtool/AwtNote.zob,
* EDIT THAT FILE INSTEAD!
* All changes to this file will be lost.
*/
/*
Awtnote.java
*
* Copyright (c) 1999-2000, Ted Nelson and Tuomas Lukka
*
* This file is part of Gzz.
*
* Gzz is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Gzz is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
* Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with Gzz; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
*/
/*
* Written by Kimmo Wideroos
*/
package org.gzigzag.module;
import org.gzigzag.*;
import java.awt.*;
import java.util.*;
/** this is for awt content. change 'AwtNote' => 'AwtContent'
*/
public class AwtNote extends ZObCellRepr implements ZOb {
public static boolean dbg = false;
static final void p(String s) { if(dbg) System.out.println(s); }
static final void pa(String s) { System.out.println(s); }
/** UNDOCUMENTED.
* <p>Default value: <PRE> 0.1;</PRE>.
* @structparam 1
*/
public
double width
= 0.1;/** UNDOCUMENTED.
* <p>Default value: <PRE> 0.07;</PRE>.
* @structparam 1
*/
public double height
= 0.07;
/* AUTOGENERATED! */
static final private int fullmask = 3;
/* AUTOGENERATED! */
public String readParams(ZZCell start) {
int m = 0;
try {
if(start != null)
m = readParams(start, 0);
} catch(Throwable t) {
ZZLogger.exc(t);
} finally {
}
if((m & fullmask) != fullmask) {
// not all parameters present - no problem right now.
}
return "";
}
/* AUTOGENERATED! */
private int readParams(ZZCell start, int mask) {
ZZCell n = start;
while(n != null) {
String s = n.getText();
// Tests autogenerated from members.
if(s.equals("width")) {
mask |= 1;
try {
ZZCell c = n.s("d.1"); s = c.getText(); width = (Double.valueOf(s)).doubleValue();
} catch(Exception e) {
ZZLogger.exc(e);
}
} else
if(s.equals("height")) {
mask |= 2;
try {
ZZCell c = n.s("d.1"); s = c.getText(); height = (Double.valueOf(s)).doubleValue();
} catch(Exception e) {
ZZLogger.exc(e);
}
} else
{ } // grab that last "else"
ZZCell h = n.h("d.3");
if(h != null && h != n) {
// recurse
mask |= readParams(h, mask);
}
n = n.s("d.2");
}
return mask;
}
// category link
private AwtLink cLink = null;
double x = Double.NaN;
double y = Double.NaN;
public void setCell(ZZCell c) {
super.setCell(c);
ZZCell cc, nCategoryCell = AwtUtil.getNoteCellCategory(c);
if(nCategoryCell != null) {
cc = c.s(AwtUtil.d_from, -1);
if(cc.s("d.1") != null)
cLink = (AwtLink)AwtUtil.readZObClone(cc);
else
cLink = new AwtLink();
cLink.setCell(cc);
} else {
cLink = new AwtLink();
}
}
public double getWidth() { return width; }
public double getHeight() { return height; }
public double[] getDimension() { return new double[] { width, height }; }
public void setDimension(double w, double h) {
width = w;
height = h;
}
public AwtLink getCategoryLink() {
return cLink;
}
public void setCategoryLink(AwtLink cl) {
cLink = cl;
}
public void setCoord(double x, double y) {
cLink.setX(x);
cLink.setY(y);
}
public void setX(double x) {
cLink.setX(x);
}
public void setY(double y) {
cLink.setY(y);
}
public double[] getCoord() {
return new double[] { cLink.getX(), cLink.getY() };
}
public double getX() {
return cLink.getX();
}
public double getY() {
return cLink.getY();
}
public String getZObName() {
return "Note";
}
/** method for storing ZOb back to structure.
* @param start quess;)
* @param clone whether or not to make the new central cell a clone of
* this.cell (default is true).
*/
public String cellRepr(ZZCell start, boolean clone)
{
ZZCell c = start.getOrNewCell("d.1");
c.setText(getZObClassName());
c.setText("AwtNote");
c = c.getOrNewCell("d.1");
c.setText("width");
c.getOrNewCell("d.1").setText(""+getWidth());
c = c.getOrNewCell("d.2");
c.setText("height");
c.getOrNewCell("d.1").setText(""+getHeight());
if(clone && !start.equals(getCell())) {
getCell().connect(AwtUtil.d_clone, start);
}
if(cLink.getCell() != null) cLink.cellRepr();
return "";
}
}
// vim: set syntax=java :
See more files for this project here