AMADEUS html plain
This sketchy text is generated by AMADEUS
* import
java.awt.*;
java.awt.event.*;
javax.swing.*;
class AmCanvas
class AmCanvas extends JPanel
graafiline vaateala, lo~uend
static final int hd = 10;
planeerimise alguse nihe, vasak vaba aa"r
static final int vd = 10;
planeerimise alguse nihe, ylemine vaba aa"r
AmFrame frame;
raam, milles vaateala asub
AmCanvasScrollbar sbv, sbh;
raami kerimisribad
Point start;
joonistamise alguspunkt (skroll)
Selection selection;
valik vaatealas
boolean caretToScreen;
kas karetti hoida na"htaval
boolean mouseDragged;
boolean justActivated;
seab AmFrameListener, kui Activated
boolean own;
kui pole tundmatu (systeemi) repaint
int X; int Y; int W; int H;
repaint jaoks
AmCanvas(AmFrame fr)
konstruktor
frame = fr;
start = new Point(0, 0);
silumiseks
selection = null;
tehakse pa"rast loomist
caretToScreen = true;
setBackground(Default.backgroundColor);
setForeground(Default.foregroundColor);
addMouseListener(new AmMouseListener(this));
addMouseMotionListener(new AmMouseMovementListener(this));
addMouseWheelListener(new AmMouseWheelListener(this));
addKeyListener(new AmKeyListener(this));
justActivated = false;
own = false;
public void paint(Graphics g)
lo~uendile joonistamine
//Wmenu
? Am.isWindows && (frame.menuBar == null)
<==========
super.paintComponent(g);
int canvh = getSize().height;
int canvw = getSize().width;
AmView.sizeFactor = frame.sizeFactor;
JK 10.01.06
? (justActivated)
? true//Am.isWindows
requestFocusInWindow();
g.setClip(0, 0 , canvw, canvh);
g.setColor(Default.backgroundColor);
g.fillRect(0, 0 , canvw, canvh);
justActivated = false;
joon ymber louendi:
g.setColor(Color.green);
g.drawRect(0, 0 , canvw-1, canvh-1);
silumiseks: repaint area
g.setColor(Color.red); g.drawRect(X+1, Y+1 , W-2, H-2);
? (frame.contents != null)
väikese joonise kohendamine
nt kui olla all, siis muidu ikoniseerimisel läheb väikeseks,
aga ülemine osa jääks üles nähtamatuks
int yyy = frame.contents.main.view.height + vd;
? (canvh >= yyy)
joonis mahub lõuendile
//JK 24.05.06 pole vaja: start.x = 0;
start.y = 0;
joonise kohendamine, juhuks kui raami on suurendatud,
aga h-bar oli nihkes
int xxx = frame.contents.main.view.width + hd;
? (canvw >= xxx)
joonis mahub lõuendile
start.x = 0;
g.translate(start.x, start.y);
frame.contents.editor.caret.drawx(g);
frame.contents.draw(g);
frame.contents.affected = frame.contents.main;
valiku joonistamine p.o. pärast sisu joonistamist (värvid!)
? (selection.kind() != Selection.NONE)
selection.draw(g);
systeemse paint puhuks (kui sellelt teist akent nihutatud)
? (!own)
frame.contents.main.invalidate(-start.y, getSize().height-start.y);
kuna joonistamine toimub alati ka pearaami muutmisel,
siis on siin paras koht kerimisribade (ymber)seadmiseks
vertikaalne:
int vis_am = 100;
int value = 0;
int yy = frame.contents.main.view.height + vd;
? (canvh < yy)
kui joonis ei mahu lo~uendile
vis_am = (int)( ((float)canvh/(float)yy)*100);
value = (int)( ((float)(-start.y)/(float)yy)*100);
sbv.setVisibleAmount(vis_am);
sbv.setValue(value);
horisontaalne:
vis_am = 100;
value = 0;
int xx = frame.contents.main.view.width + hd;
? (canvw < xx)
kui joonis ei mahu lo~uendile
vis_am = (int)( ((float)canvw/(float)xx)*100);
value = (int)( ((float)(-start.x)/(float)xx)*100);
sbh.setVisibleAmount(vis_am);
sbh.setValue(value);
<======
kui skeemteksti pole, siis vaid tyhjendada lo~uend:
g.setColor(Default.backgroundColor);
g.fillRect(1, 1 , canvw-2, canvh-2);
own = false;
public boolean caretToScreen()
<======rectToScreen(frame.contents.editor.caret.row)
private boolean rectToScreen(Rectangle p)
boolean res = false;
kas muudeti start
int canvh = getSize().height;
int canvw = getSize().width;
? ((p.y + start.y) <= 0) ||
((p.y + p.height + start.y) >= canvh)
rida pole ekraanil
? (p.y + start.y) <= 0
on üleval pool
res = true;
start.y = canvh/2 - p.y;
? start.y > 0
start.y = 0;
<======
? (p.y + p.height + start.y) >= canvh
on allpool
res = true;
start.y = -p.y - p.height + canvh/2;
siia veel, kui symbol reas pole ekraanil, muuta start.x
<======res
public void selectionToScreen()
kasutab AmMouseListener, et ikon/deikon korral tuleks tulem ekraanile
? selection.kind() != Selection.NONE
Rectangle rk = selection.area();
rk. height = 20;
rectToScreen(rk);
void prepare(int yy)
antud: yy - esimese muudetud (rea) suhteline y
tulemus: aken X,Y,W,H - repaint jaoks
X = 0;
Y = yy + start.y;
W = getSize().width;
H = getSize().height - Y;
void prepare(int yy, Scheme s)
antud: yy - esimese muudetud (rea) suhteline y
tulemus: aken X,Y,W,H - repaint jaoks
invalideerib s selle osa
X = 0;
Y = yy + start.y;
W = getSize().width;
H = getSize().height - Y;
s.invalidate(yy, yy + H - Y);
s.invalidate(yy, yy + H);