Revision: 1.2 - (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 : | ktanaka | 1.2 | public void keyPressed(KeyEvent e){} |
15 : | public void keyReleased(KeyEvent e){} | ||
16 : | public void keyTyped(KeyEvent e){} | ||
17 : | ktanaka | 1.1 | 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 : | ktanaka | 1.2 | if(skel!=null){ |
38 : | Point[] points=skel.getPoints(); | ||
39 : | Element[] elements=skel.getElements(); | ||
40 : | int i,len=elements.length; | ||
41 : | for(i=0;i<len;i++){ | ||
42 : | int[] elementPoints=elements[i].getPoints(); | ||
43 : | int j,plen=elementPoints.length; | ||
44 : | Point p0,p1; | ||
45 : | for(j=0;j<plen-1;j++){ | ||
46 : | p0=points[elementPoints[j]]; | ||
47 : | p1=points[elementPoints[j+1]]; | ||
48 : | g.drawLine((int)p0.getX(),(int)p0.getY(),(int)p1.getX(),(int)p1.getY()); | ||
49 : | } | ||
50 : | } | ||
51 : | g.setColor(Color.red); | ||
52 : | for(i=0;i<len;i++){ | ||
53 : | Outline[] outlines=renderer.elementRenderer(points,elements[i]); | ||
54 : | showOutline(g,outlines[0]); | ||
55 : | showOutline(g,outlines[1]); | ||
56 : | } | ||
57 : | ktanaka | 1.1 | } |
58 : | } | ||
59 : | public static void main(String[] args) throws IOException,LispException{ | ||
60 : | ShowSkeleton window=new ShowSkeleton(); | ||
61 : | window.setSize(400,400); | ||
62 : | window.show(); | ||
63 : | LispInputStream lis; | ||
64 : | lis=new LispInputStream(new FileReader(args[0])); | ||
65 : | BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); | ||
66 : | LispObject lo=null; | ||
67 : | while((lo=lis.nextObject())!=null){ | ||
68 : | ktanaka | 1.2 | System.out.println(lo); |
69 : | ktanaka | 1.1 | if(lo.getType()==LispObject.CONS && lo.car().getName().equals("setq")){ |
70 : | window.skel=LispToSkeleton.lispToSkeleton(lo.cdr().cdr().car().cdr().car()); | ||
71 : | window.repaint(); | ||
72 : | br.readLine(); | ||
73 : | } | ||
74 : | } | ||
75 : | } | ||
76 : | } |
ktanaka Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |