AMADEUS html plain
This sketchy text is generated by AMADEUS
* import java.
class ViewSTree
class ViewSTree extends View
static final int hd = 10;
static final int vd = 5;
static final int vstep = 2*vd;
4*vd;
static Color color = Default.sketchLineColor;
static Color colorBr = Default.branchHeadColor;
static Color colorLine = Color.yellow;
static int iconw;
static int iconh;
static int laius;
ViewSTree(Scheme s)
super(s);
type = View.STREE;
public Rectangle getLineArea(Scheme s)
<======new Rectangle(s.view.x, s.view.y, hd, s.view.height)
private Rectangle getNodeArea(Scheme s)
tagastab ala, mis sisaldab skeemi s pa"ist (hd*hd, kui pa"ist pole)
kui s on planeerimata, siis saab ikka ko~rguse ja laiuse ka"tte
int x = (s.view.x + s.view.x + s.view.width)/2;
? s instanceof Sketch
int z = nodeX((Sketch)s);
? z >= 0
x = z;
int y = s.view.y + s.comment.height + vd;
? s.icon
<======new Rectangle(s.view.x, s.view.y, s.view.width, s.view.height)
int n = s.head.size();
el.pa"iste arv
? n == 0
<======new Rectangle(x, y, hd, hd)
int hh = 0;
int ww = 0;
* int i = 0; i < n; i++
PrimitiveHead he = s.primitiveHead(i);
? i == 0
x = he.text.x;
y = he.text.y;
hh += he.text.height + vd;
int w = he.text.width;
? w > ww
ww = w;
<======new Rectangle(x, y, ww, hh-vd)
private int nodeX(Sketch s)
s on planeeritud
(kui pole alluvaid skeeme vo~i on ikoniseeritud, siis tagastab -1)
? s.icon
<======-1
Branch br = s.branch(0);
Vector v = new Vector();
int ww = hd;
* int i = 0; i < s.head.size(); i++
PrimitiveHead he = s.primitiveHead(i);
? he.text.width > ww
ww = he.text.width;
int l = ww/2;
* int i = 0; i < br.body.size(); i++
Object o= br.member(i);
? o instanceof Sketch
Sketch ss = (Sketch)o;
Rectangle rec = getNodeArea(ss);
int x = (rec.x + rec.x + rec.width)/2;
v.addElement(new Integer(x));
int n = v.size();
int k = n/2;
? (n % 2) != 0
<======((Integer)(v.elementAt(k))).intValue() - l
<======-1
int x1 = ((Integer)(v.elementAt(k-1))).intValue() - l;
int x2 = ((Integer)(v.elementAt(k))).intValue() - l;
<======(x1 + x2)/2
private void drawSkLine(Graphics g, Scheme s)
Rectangle rk = getLineArea(s);
int xx= rk.x, yy=rk.y, korgus=rk.height;
laius=rk.width;
int xja = xx + 1;
int xjl = xja;
int dd = (s.comment.width == 0)? 0 : vd;
int yja = yy + (s.comment.height - dd) / 2;
int yjl = yy + korgus - 3;
Color keepColor = g.getColor();
g.setColor(colorLine);
//L0:
non-control
? s instanceof Branch
int vahe1 = laius/4;
? s.parent.type == Scheme.MODULE
vahe1 = 1;
? s.parent.type == Scheme.SIMPLE
vahe1 = 0;
int xsa = xja + vahe1;
? (!(((Sketch)(s.parent)).isMono())) ||
(((Sketch)(s.parent)).head.size() > 0) ||
(s.type != Scheme.SIMPLE)
..switch
??s.type
? Scheme.LOOP:
? Scheme.MODULE:
int vahe = laius/4;
? s.type == Scheme.MODULE
vahe = 1;
int xva, yva;
int ysa;
xva = xja; yva = yja-vahe;
ysa = yva + vahe;
g.drawLine(xsa, yva, xva + laius - 2, yva);
g.drawLine(xsa, ysa, xva + laius - 2, ysa);
<======;
? :
g.drawLine(xsa, yja, xja + laius - 2 - 1, yja);
<======;
<======
..switch
??s.type
? Scheme.LOOP:
? Scheme.MODULE:
int vahe = laius/4;
? s.type == Scheme.MODULE
vahe = 1;
int xva, yva, xvl, yvl;
int xsa, ysa, xsl, ysl;
xva = xja; yva = yja-vahe; xvl = xjl; yvl =yjl+vahe;
xsa = xva + vahe; ysa = yva + vahe; xsl = xsa; ysl = yvl - vahe;
g.drawLine(xva, yva, xvl, yvl);
g.drawLine(xva+1, yva, xva + laius - 2, yva);
g.drawLine(xvl+1, yvl, xvl + laius - 2, yvl);
g.drawLine(xsa, ysa, xsl, ysl);
g.drawLine(xsa+1, ysa, xva + laius - 2, ysa);
g.drawLine(xsl+1, ysl, xvl + laius - 2, ysl);
<======;
? :
g.drawLine(xja, yja, xjl, yjl);
g.drawLine(xja+1, yja, xja + laius - 2, yja);
g.drawLine(xjl+1, yjl, xjl + laius - 2, yjl);
<======;
g.setColor(keepColor);
public void plan(int x0, int y0)
PrimitiveHead h;
PrimitiveMember nsk;
Arrow ar;
? sk.icon
x = x0;
y = y0 + sk.comment.height +vd;
iconw = sk.comment.height;
iconh = iconw;
width = iconw + 8;
height = iconh + 4;
<======
Rectangle rc = getNodeArea(sk);
ainult ko~rgus ja laius
int hhe = rc.height;
hhe += sk.comment.height;
int ww = rc.width;
? sk.comment.width > ww
ww = sk.comment.width;
int xCurr = x0;
int yy= y0+hhe+vstep;
int hh = 0;
planeerida alluvad
* int i = 0; i < sk.body.size(); i++
Object o = sk.member(i);
? o instanceof Scheme
Scheme ss = (Scheme)o;
? ss instanceof Sketch
ss.view.plan(xCurr+hd, yy);
xCurr += ss.view.width + hd;
? ss.view.height > hh
hh = ss.view.height;
<======
ss.view.plan(xCurr+1, yy - vstep);
xCurr += ss.view.width+hd;
? ss.view.height > hh
hh = ss.view.height;
<------
PrimitiveMember ns = (PrimitiveMember)o;
ns.text.plan(xCurr+hd, yy);
sk.comment.plan(sk.comment.x, sk.comment.y);
width = xCurr - x0 + 1;
width = Math.max(Math.max(sk.comment.width, rc.width), width);
int xNode = (x0 + x0 + width)/2 - rc.width/2;
? sk instanceof Sketch
int z = nodeX((Sketch)sk);
? z >= 0
xNode = z;
xNode = Math.max(xNode, x0);
sk.comment.x = xNode;
sk.comment.y = y0;
- sk.comment.height/2;
yy = sk.comment.y + sk.comment.height +vd;
? sk.head.size() != 0
* Enumeration e = sk.head.elements(); e.hasMoreElements();
PrimitiveHead he = (PrimitiveHead)(e.nextElement());
he.text.plan(xNode, yy);
yy += he.text.height + vd;
x = x0;
y = y0;
? sk instanceof Sketch
height = hh + hhe + vstep;
haru kommentaar o~igesse kohta:
Branch bb = ((Sketch)sk).branch(0);
Rectangle re = getNodeArea(sk);
bb.comment.x = (re.x + re.x + re.width)/2 - hd;
?? -hd
bb.comment.y = re.y + re.height + vd;
? sk instanceof Branch
height = hh + hhe;
public void draw(Graphics g)
Scheme s = super.sk;
Scheme parent = s.parent;
? s.icon
va"rv (color vo~i colorBr)
? s instanceof Sketch
g.setColor(color);
<======
int luX = x + 6;
int luY = y + 2;
g.drawRect(luX, luY, iconw, iconh);
g.drawLine(luX, luY, luX + iconw - 1, luY + iconh - 1);
joon u"lemusele
? s instanceof Sketch
? parent != null
parent = parent.parent;
? parent.view.type == View.STREE
Rectangle r = getNodeArea(parent);
int xParent = r.x + r.width/2;
int yParent = r.y + r.height;
g.drawLine(luX + iconw/2, luY, xParent, yParent);
<======
skeemijoon
? s instanceof Sketch
//?((Sketch)s).containsSubsketch()
drawSkLine(g,s);
s.comment.draw(g);
int yy = s.comment.height + vd;
int x1 = x + hd/2;
Rectangle rk = getNodeArea(sk);
ovaal
? s instanceof Sketch
g.drawOval(rk.x, rk.y, rk.width, rk.height);
? s.type == Scheme.MODULE
g.drawOval(rk.x-1, rk.y-1, rk.width+2, rk.height+2);
<======
? s.type == Scheme.LOOP
g.drawOval(rk.x-2, rk.y-2, rk.width+4, rk.height+4);
joon u"lemusele
? s instanceof Sketch
? parent != null
parent = parent.parent;
? parent.view.type == View.STREE
Rectangle r = getNodeArea(parent);
int xParent = r.x + r.width/2;
int yParent = r.y + r.height;
g.drawLine(rk.x +rk.width/2, rk.y, xParent, yParent);
pa"ise tyyp
* Enumeration e = s.head.elements(); e.hasMoreElements();
PrimitiveHead he = (PrimitiveHead)(e.nextElement());
he.text.draw(g);
g.setColor(color);
..switch
??he.type
? PrimitiveHead.LOOP:
g.setFont(Default.font);
g.drawString("*", x1, y+yy + he.text.height*3/4);
<======;
? PrimitiveHead.SWITCH:
g.setFont(Default.font);
g.drawString("??", x1, y+yy + he.text.height*3/4);
<======;
? PrimitiveHead.CASE:
? PrimitiveHead.DEFAULT:
g.setFont(Default.font);
g.drawString("?", x1, y+yy + he.text.height*3/4);
<======;
? PrimitiveHead.TRY:
g.setFont(Default.font);
g.drawString("!!", x1, y+yy + he.text.height*3/4);
<======;
? PrimitiveHead.CATCH:
? PrimitiveHead.FINALLY:
g.setFont(Default.font);
g.drawString("!", x1, y+yy + he.text.height*3/4);
<======;
yy += he.text.height;
alamskeemid
* Enumeration e = s.body.elements(); e.hasMoreElements();
Object o = e.nextElement();
? o instanceof Scheme
Scheme sss = (Scheme)o;
sss.view.draw(g);
? (sss instanceof Sketch) && (sss.view.type != View.STREE)
joon u"lemusele:
Rectangle r = getNodeArea(s.parent);
int xParent = r.x + r.width/2;
int yParent = r.y + r.height;
g.drawLine(sss.view.x +sss.view.width/2, sss.view.y, xParent, yParent);
public void xxxpointLocation(Point p, Scheme s)
pyytakse leida va"him (alam)osa, kuhu punkt kuulub
erijuhul jaa"b kursor skeemijoone alale (!inScheme)
globaalne: Cursor result (eelnevalt == null)
? (result != null)
<======
<======
? (s.icon)
result = new Cursor(s);
<======
otsida skeemi liikmetes:
* int i = 0; i < s.body.size(); i++
Object o = s.member(i);
? (o instanceof Scheme)
liige on skeem
Scheme sk = (Scheme)o;
pointLocation(p, sk);
? (result != null)
leitud mingis alamskeemis
<==============
<------
//
on mitteskeem
result = new Cursor(s);
? (pointLocation(p, ((PrimitiveMember)o).text))
on liikmel
result.primitive = (PrimitiveMember)o;
viia kursor reas hiireni
result.noInRow = 1;
Row r = result.row;
int shift = (((Symbol)r.elements.elementAt(0))).width();
* i = 1; i < r.elements.size(); i++
<======;
result.noInRow++;
r.getElement(i);
? (r.sy != null)
shift += r.sy.width();
<------
<==============
alamskeemidel ei olnud
selle skeemi kommentaaril ?
result = new Cursor(s);
? (pointLocation(p, s.comment))
result.primitive = null;
viia kursor reas hiireni (kui mitte haru komm)
result.noInRow = 1;
? s instanceof Sketch
Row r = result.row;
int shift = (((Symbol)r.elements.elementAt(0))).width();
* int i = 1; i < r.elements.size(); i++
<======;
result.noInRow++;
r.getElement(i);
? (r.sy != null)
shift += r.sy.width();
<------
<======
selle skeemi pa"isel ?
? s instanceof Sketch
result = null;
result = new Cursor(s);
* Enumeration e = s.head.elements(); e.hasMoreElements();
PrimitiveHead h = (PrimitiveHead)(e.nextElement());
? (pointLocation(p, h.text))
result.primitive = h;
viia kursor reas hiireni
result.noInRow = 1;
Row r = result.row;
int shift = (((Symbol)r.elements.elementAt(0))).width();
* int i = 1; i < r.elements.size(); i++
<======
result.noInRow++;
r.getElement(i);
? (r.sy != null)
shift += r.sy.width();
<------
<==============
vo~ib olla veel skeemi s aa"rel ?
Rectangle rec = getLineArea(s);
rec.width -= hd/2;
? (s instanceof Sketch) && (rec.contains(p))
result = new Cursor(s);
<======