AMADEUS html plain
import java.util.*;
import java.awt.*;
class ViewBox
class ViewBox extends View
realiseerib kast-vaate
static final int hd = 15;
hor-intervall
static final int vd = 5;
vert-intervall
static Color color = Color.blue;
joonistamisva"rv
static Color colorBr = Default.branchHeadColor;
joonistamisva"rv
static final Color selectionColor = Color.gray;
valitu ymbrise va"rv
static int iconw = hd;
static int iconh = vd;
static int ikooninooleNihe = 0;
ViewBox(Scheme s)
super(s);
type = View.BOX;
plan
public void plan(int x0, int y0)
kast-vaate planeerimine
planeeritakse vaatega seotud skeem sk
if (sk.icon){
ikooni koht ja moo~tmed:
x = x0; y = y0;
width = iconw; height = iconh;
return;
}
? sk.icon
ikooni koht ja moo~tmed:
x = x0; y = y0;
iconw = sk.comment.height;
iconh = iconw;
width = iconw + 8;
height = iconh + 4;
<======
int yy= y0+vd;
jooksev vert. koordinaat
int ww = 0;
jooksev laius
kommentaar
yy -= vd; //
sk.comment.plan(x0+1, yy+1);
sk.comment.y = yy;
yy += sk.comment.height+vd;
? sk.comment.width > ww
ww = sk.comment.width;
? sk.head.size() != 0
planeerida paised
* Enumeration e = sk.head.elements(); e.hasMoreElements();
PrimitiveHead he = (PrimitiveHead)(e.nextElement());
he.text.plan(x0+hd, yy-vd);
yy += he.text.height;
? he.text.width > ww
ww = he.text.width;
yy += 2*vd;
vahekriipsu jaoks
yy += vd; // enne keha
* int i = 0; i < sk.body.size(); i++
alluvate planeerimine:
Object o = sk.member(i);
? o instanceof Scheme
Scheme ss = (Scheme)o;
ss.view.plan(x0+hd, yy);
yy += ss.view.height + vd;
? ss.type != Scheme.SIMPLE
yy += 3;
? ss.view.width > ww
ww = ss.view.width;
<------
o on lihtliige
PrimitiveMember ns = (PrimitiveMember)o;
ns.text.plan(x0+hd, yy);
yy += ns.text.height + vd;
//System.out.println("ViewBOx: ns.text.height="+ ns.text.height);
//System.out.println("yy=" + yy);
//System.out.println("y0=" + y0);
? ns.text.width > ww
ww = ns.text.width;
for
enda koht ja moo~tmed:
x = x0; y = y0;
width = ww+2*hd;
height = yy-y0+vd+1;
kommentaar paremale aa"rde
sk.comment.x = sk.view.x + sk.view.width - sk.comment.width - 2;
draw
public void draw(Graphics g)
kast-vaate joonistamine
joonistab selle vaatega seotud skeemi sk
if(sk.icon){
g.drawRect(x, y, width+1, height+1);
g.drawLine(x, y, x + width+1, y + height+1);
g.setColor(Default.commentColor);
g.drawString(sk.comment.toString(),
x+width+1+1, y+height);
return;
}
Scheme s = super.sk;
? s.icon
ikooni värv
? s instanceof Sketch
g.setColor(color);
<======
ikoon joonistatakse talle planeeritud ala sisse
//int luX = x + 6;
//int luY = y + 2;
//g.drawRect(luX, luY, iconw, iconh);
//g.drawLine(luX, luY,
//luX + iconw - 1, luY + iconh - 1);
ikoon joonistatakse talle planeeritud ala sisse
int luX = x + 2;
int luY = y + 2;
g.drawRect(luX, luY, iconw, iconh);
g.drawLine(luX, luY, luX + iconw - 1, luY + iconh - 1);
g.drawImage(Am.pictureBoard.iconImage, luX, luY, null);
? !s.comment.isTrivial()
g.setColor(Default.commentColor);
g.drawString(s.comment.toString(),
x + width + 2, y + iconh);
<======
? s.head.size() != 0
? s instanceof Sketch
g.setColor(color);
<======
g.drawString(s.primitiveHead(0).text.row(0).toString(),
x + width + 2, y + iconh);
ikooninooled
int X = x, Y = y + height/3;
ikooninooleNihe = 0;
et nooled ei XORiks üksteist
? s instanceof Sketch
drawArrowsForIcon(g, (Sketch)s, X, Y, s.level());
<======
haru ikoon
int m = s.body.size();
liikmed
* int j = 0; j < m; j++
Object o = ((Branch)s).member(j);
? o instanceof Sketch
drawArrowsForIcon(g, (Sketch)o, X, Y, s.level());
<------
? o instanceof Arrow
Scheme sc = ((Arrow)o).destination((Branch)s);
mitteväljaulatuvat ei tee (destination on ka planeerimata)
? sc.level() >= s.level()
<----------
int endX = sc.view.x;
seada endX
ViewSketchy.drawStrongArrow(g, X, Y+(ikooninooleNihe+=2), endX);
joonistada nool
<======
int yy = 0;
joonistamise jarg
kommentaar
sk.comment.draw(g);
yy += sk.comment.height;
int w = 0;
paised
* Enumeration e = sk.head.elements(); e.hasMoreElements();
PrimitiveHead he = (PrimitiveHead)(e.nextElement());
g.setColor(color);
he.text.draw(g);
? he.text.width > w
w = he.text.width;
g.setColor(color);
paise tunnus
?? he.type
? PrimitiveHead.LOOP:
g.setFont(Default.font);
p.o. selle vaate font !!!!!!!!!!!
(el-paise esimese rea ette)
g.drawString("*", x+1, y+yy + he.text.height*3/4);
<======
? PrimitiveHead.SWITCH:
g.setFont(Default.font);
p.o. selle vaate font !!!!!!!!!!!
g.drawString("??", x+1, y+yy + he.text.height*3/4);
<======
? PrimitiveHead.CASE:
? PrimitiveHead.DEFAULT:
g.setFont(Default.font);
p.o. selle vaate font !!!!!!!!!!!
g.drawString("?", x+1, y+yy + he.text.height*3/4);
<======
? PrimitiveHead.TRY:
g.setFont(Default.font);
p.o. selle vaate font !!!!!!!!!!!
g.drawString("!!", x+1, y+yy + he.text.height*3/4);
<======
? PrimitiveHead.CATCH:
? PrimitiveHead.FINALLY:
g.setFont(Default.font);
p.o. selle vaate font !!!!!!!!!!!
g.drawString("!", x+1, y+yy + he.text.height*3/4);
<======
yy += he.text.height;
vahekriips:
? sk.head.size() > 0
g.drawLine(x+1, y+yy+vd, x+1+w, y+yy+vd);
kast ymber
? sk instanceof Branch
g.setColor(Color.magenta);
p.o. selle vaate font !!!!!!!!!!!
<======
g.setColor(color);
p.o. selle vaate font !!!!!!!!!!!
//System.out.println("ViewBOx: height="+ height);
//System.out.println("yy=" + yy);
g.drawRect(x, y, width, height);
skeemi tyybist so~ltuvalt veel:
??sk.type
? Scheme.LOOP:
g.drawRect(x-2, y-2, width+4, height+4);
<======
? Scheme.MODULE:
g.drawRect(x-1, y-1, width+2, height+2);
<======
System.out.println("ViewBOx: liikmete arv:="+ sk.body.size());
joonistada alluvad:
* Enumeration e = sk.body.elements(); e.hasMoreElements();
Object o = e.nextElement();
? o instanceof Scheme
Scheme ss = (Scheme)o;
ss.view.draw(g);
yy += ss.view.height;
<------
? o instanceof Arrow
Arrow ns = (Arrow)o;
g.setFont(Default.font);
p.o. selle vaate font !!!!!!!!!!!
g.setColor(Default.conditionColor);
(esimese rea ette)
int leftX;
Scheme destination = ns.destination((Branch)sk);
? ns.level == Integer.MAX_VALUE
leftX = x+hd/2;
<======
leftX = destination.view.x;
int leftY = ns.text.y + ns.text.height/2;
? destination.view instanceof ViewBox
ViewSketchy.drawStrongArrow(g, x+hd, leftY,leftX);
<======
?? ns.type
? Arrow.STRONG:
ViewSketchy.drawStrongArrow(g, x+hd, leftY,leftX);
<======
? Arrow.WEAK:
ViewSketchy.drawWeakArrow(g, x+hd, leftY,leftX);
ns.text.draw(g);
yy += ns.text.height;
<------
PrimitiveMember ns = (PrimitiveMember)o;
?? ns.type
? Primitive.CONDITION:
g.setFont(Default.font);
p.o. selle vaate font !!!!!!!!!!!
g.setColor(Default.conditionColor);
(esimese rea ette)
g.drawString("?", x+1, ns.text.y + ns.text.height*3/4);
<======
ns.text.draw(g);
yy += ns.text.height;
for
public Rectangle getLineArea(Scheme s)
praegu vaid kasti vasakul äärel
<======new Rectangle(s.view.x, s.view.y, hd, s.view.height)
static void drawArrowsForIcon(Graphics g, Sketch s,
int X, int Y, int iconLevel)
X, Y - noole alguse koordinaadid (ikooni vasakul serval)
int endX;
int nihe = 0;
et nooled ei XORiks üksteist
int n = s.body.size();
harud
* int i = 0; i < n; i++
Branch br = s.branch(i);
int m = br.body.size();
liikmed
* int j = 0; j < m; j++
Object o = br.member(j);
? o instanceof Sketch
drawArrowsForIcon(g, (Sketch)o, X, Y, iconLevel);
<------
? o instanceof Arrow
//drawIconArrow(g, br, (Arrow)o, X, Y+(nihe+=2), iconLevel);
Scheme sc = ((Arrow)o).destination(br);
mitteva"ljaulatuvat ei tee (destination on ka planeerimata)
? sc.level() >= iconLevel
<----------
endX = sc.view.x;
seada endX
ViewSketchy.drawStrongArrow(g, X, Y+(ikooninooleNihe+=2), endX);
joonistada nool