Revision Log
Revision: 1.3 - (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 : | ktanaka | 1.3 | Outline[] outlines=skel.makeOutline(renderer); |
| 53 : | for(i=0;i<outlines.length;i++){ | ||
| 54 : | showOutline(g,outlines[i]); | ||
| 55 : | ktanaka | 1.2 | } |
| 56 : | ktanaka | 1.1 | } |
| 57 : | } | ||
| 58 : | public static void main(String[] args) throws IOException,LispException{ | ||
| 59 : | ShowSkeleton window=new ShowSkeleton(); | ||
| 60 : | window.setSize(400,400); | ||
| 61 : | window.show(); | ||
| 62 : | LispInputStream lis; | ||
| 63 : | lis=new LispInputStream(new FileReader(args[0])); | ||
| 64 : | BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); | ||
| 65 : | LispObject lo=null; | ||
| 66 : | while((lo=lis.nextObject())!=null){ | ||
| 67 : | ktanaka | 1.2 | System.out.println(lo); |
| 68 : | ktanaka | 1.1 | if(lo.getType()==LispObject.CONS && lo.car().getName().equals("setq")){ |
| 69 : | window.skel=LispToSkeleton.lispToSkeleton(lo.cdr().cdr().car().cdr().car()); | ||
| 70 : | window.repaint(); | ||
| 71 : | br.readLine(); | ||
| 72 : | } | ||
| 73 : | } | ||
| 74 : | } | ||
| 75 : | } |
|
ktanaka Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |