// Last edited on 2000-03-19 05:08:54 by stolfi import Map; import java.applet.Applet; import java.awt.Graphics; import java.awt.Rectangle; import java.awt.Color; class DrawMap extends Applet { // A map-drawing program public void paint(Graphics g) { int N = 10; Map m = Map.Ring(N); Rectangle s = g.getClipBounds(); // System.out.println(s.width + " x " + s.height); double xc = s.x + s.width/2; double yc = s.y + s.height/2; double R = 0.4 * (s.width > s.height ? s.width : s.height); int i; // Arcs g.setColor(new Color(0.750f, 0.000f, 0.000f)); for(i = 0; i < m.arc.length; i++) { Map.Arc a = m.arc[i]; int x1 = (int)Math.round(xc + a.org.x*R); int y1 = (int)Math.round(yc + a.org.y*R); int x2 = (int)Math.round(xc + a.dst.x*R); int y2 = (int)Math.round(yc + a.dst.y*R); // double w = 4*a.w; g.drawLine(x1,y1,x2,y2); } // Nodes g.setColor(new Color(0.000f, 0.000f, 0.500f)); for(i = 0; i < m.node.length; i++) { Map.Node nd = m.node[i]; int r = (int)Math.ceil(4*nd.r); int x = (int)Math.round(xc + nd.x*R); int y = (int)Math.round(yc + nd.y*R); g.fillOval(x-r,y-r,2*r,2*r); } } }