Revision: 1.1 - (view) (download) (as text)
1 : | ktanaka | 1.1 | import java.awt.*; |
2 : | import java.awt.event.*; | ||
3 : | import java.io.*; | ||
4 : | import java.util.*; | ||
5 : | |||
6 : | public class ShowSkeleton extends Frame implements KeyListener{ | ||
7 : | Skeleton skel; | ||
8 : | Renderer renderer; | ||
9 : | ShowSkeleton(){ | ||
10 : | super("skeleton"); | ||
11 : | addKeyListener(this); | ||
12 : | renderer=MinchoRenderer.chuuMincho; | ||
13 : | } | ||
14 : | public void keyPressed(KeyEvent e){ System.exit(1);} | ||
15 : | public void keyReleased(KeyEvent e){ System.exit(1);} | ||
16 : | public void keyTyped(KeyEvent e){ System.exit(1);} | ||
17 : | public void showOutline(Graphics g,Outline outline){ | ||
18 : | Vector ret=new Vector(10); | ||
19 : | OutlineComponent[] components=outline.getComponents(); | ||
20 : | int i,len=components.length; | ||
21 : | for(i=0;i<len;i++){ | ||
22 : | components[i].render(ret,3.0); | ||
23 : | } | ||
24 : | len=ret.size(); | ||
25 : | int[] xs=new int[len], ys=new int[len]; | ||
26 : | for(i=0;i<len;i++){ | ||
27 : | Point p=(Point)(ret.elementAt(i)); | ||
28 : | xs[i]=(int)p.x; | ||
29 : | ys[i]=(int)p.y; | ||
30 : | } | ||
31 : | g.drawPolyline(xs,ys,len); | ||
32 : | } | ||
33 : | public void paint(Graphics g){ | ||
34 : | g.setColor(Color.white); | ||
35 : | g.fillRect(0,0,400,400); | ||
36 : | g.setColor(Color.black); | ||
37 : | Point[] points=skel.getPoints(); | ||
38 : | Element[] elements=skel.getElements(); | ||
39 : | int i,len=elements.length; | ||
40 : | for(i=0;i<len;i++){ | ||
41 : | int[] elementPoints=elements[i].getPoints(); | ||
42 : | int j,plen=elementPoints.length; | ||
43 : | Point p0,p1; | ||
44 : | for(j=0;j<plen-1;j++){ | ||
45 : | p0=points[elementPoints[j]]; | ||
46 : | p1=points[elementPoints[j+1]]; | ||
47 : | g.drawLine((int)p0.getX(),(int)p0.getY(),(int)p1.getX(),(int)p1.getY()); | ||
48 : | } | ||
49 : | } | ||
50 : | g.setColor(Color.red); | ||
51 : | for(i=0;i<len;i++){ | ||
52 : | Outline[] outlines=renderer.elementRenderer(points,elements[i]); | ||
53 : | showOutline(g,outlines[0]); | ||
54 : | showOutline(g,outlines[1]); | ||
55 : | } | ||
56 : | } | ||
57 : | public static void main(String[] args) throws IOException,LispException{ | ||
58 : | ShowSkeleton window=new ShowSkeleton(); | ||
59 : | window.setSize(400,400); | ||
60 : | window.show(); | ||
61 : | LispInputStream lis; | ||
62 : | lis=new LispInputStream(new FileReader(args[0])); | ||
63 : | BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); | ||
64 : | LispObject lo=null; | ||
65 : | while((lo=lis.nextObject())!=null){ | ||
66 : | if(lo.getType()==LispObject.CONS && lo.car().getName().equals("setq")){ | ||
67 : | window.skel=LispToSkeleton.lispToSkeleton(lo.cdr().cdr().car().cdr().car()); | ||
68 : | window.repaint(); | ||
69 : | br.readLine(); | ||
70 : | } | ||
71 : | } | ||
72 : | } | ||
73 : | } |
ktanaka Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |