MinchoRendererのへんこう瘢雹
import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; public class ShowSkeleton extends Frame implements KeyListener{ Skeleton skel; Renderer renderer; ShowSkeleton(){ super("skeleton"); addKeyListener(this); renderer=MinchoRenderer.chuuMincho; } public void keyPressed(KeyEvent e){} public void keyReleased(KeyEvent e){} public void keyTyped(KeyEvent e){} public void showOutline(Graphics g,Outline outline){ Vector ret=new Vector(10); OutlineComponent[] components=outline.getComponents(); int i,len=components.length; for(i=0;i<len;i++){ components[i].render(ret,3.0); } len=ret.size(); int[] xs=new int[len], ys=new int[len]; for(i=0;i<len;i++){ Point p=(Point)(ret.elementAt(i)); xs[i]=(int)p.x; ys[i]=(int)p.y; } g.drawPolyline(xs,ys,len); } public void paint(Graphics g){ g.setColor(Color.white); g.fillRect(0,0,400,400); g.setColor(Color.black); if(skel!=null){ Point[] points=skel.getPoints(); Element[] elements=skel.getElements(); int i,len=elements.length; for(i=0;i<len;i++){ int[] elementPoints=elements[i].getPoints(); int j,plen=elementPoints.length; Point p0,p1; for(j=0;j<plen-1;j++){ p0=points[elementPoints[j]]; p1=points[elementPoints[j+1]]; g.drawLine((int)p0.getX(),(int)p0.getY(),(int)p1.getX(),(int)p1.getY()); } } g.setColor(Color.red); Outline[] outlines=skel.makeOutline(renderer); for(i=0;i<outlines.length;i++){ showOutline(g,outlines[i]); } } } public static void main(String[] args) throws IOException,LispException{ ShowSkeleton window=new ShowSkeleton(); window.setSize(400,400); window.show(); LispInputStream lis; lis=new LispInputStream(new FileReader(args[0])); BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); LispObject lo=null; while((lo=lis.nextObject())!=null){ System.out.println(lo); if(lo.getType()==LispObject.CONS && lo.car().getName().equals("setq")){ window.skel=LispToSkeleton.lispToSkeleton(lo.cdr().cdr().car().cdr().car()); window.repaint(); br.readLine(); } } } }
ktanaka Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |