public void paint(Graphics g) {
pw=this.getSize().width;
ph=this.getSize().height;
g2d=(Graphics2D)g;
g2d.clearRect(0,0,pw,ph);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,alias);
continuous=g2d.getStroke();
vertexAngle=gf.angle;
cs=Math.round(Math.min(pw,ph)/2-20);
cx=pw/2;
cy=ph/2;
if (displayGrid){
g2d.setColor(gridGray);
for (int i=0;i< pw;i+=30){
g2d.drawLine(0,i,pw,i);
g2d.drawLine(i,0,i,ph);
}
}
if (gf.orientable && displayIndicators){
g2d.setColor(Color.black);
xorientHandle=(int)Math.round(-Math.sin(gf.angle)*cs*1.1)+cx;
yorientHandle=-(int)Math.round(Math.cos(gf.angle)*cs*1.1)+cy;
g2d.drawLine(cx,cy,xorientHandle,yorientHandle);
if (selectedVertex==-2){g2d.setColor(Color.red);}
g2d.fillOval(xorientHandle-4,yorientHandle-4,8,8);
}
}
|