Generated on Fri Oct 6 16:26:43 2006 for Gecode/J by doxygen 1.4.7

Circle.java

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Guido Tack <tack@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Guido Tack, 2006
00007  *
00008  *  Last modified:
00009  *     $Date: 2006-02-09 16:32:56 +0100 (Thu, 09 Feb 2006) $ by $Author: tack $
00010  *     $Revision: 2943 $
00011  *
00012  *  This file is part of Gecode, the generic constraint
00013  *  development environment:
00014  *     http://www.gecode.org
00015  *
00016  *  See the file "LICENSE" for information on usage and
00017  *  redistribution of this file, and for a
00018  *     DISCLAIMER OF ALL WARRANTIES.
00019  *
00020  */
00021 
00022 package org.gecode.explorer.postscript;
00023 
00024 import java.io.Writer;
00025 import java.io.IOException;
00026 
00027 public class Circle extends Path {
00028     private int cx, cy, r;
00029     private PSColor outline;
00030     private PSColor fill;
00031 
00032     public Circle(int cx0, int cy0, int r0,
00033                   PSColor outline0, PSColor fill0) {
00034         cx = cx0;
00035         cy = cy0;
00036         r = r0;
00037         outline = outline0;
00038         fill = fill0;
00039     }
00040 
00041     void emit(Writer out) throws IOException {
00042         out.write("gsave\n");
00043         out.write("matrix currentmatrix\n");
00044         out.write(cx+".0 "+cy+".0 translate "+r+".0 "+r+
00045                 ".0 scale 1 0 moveto 0 0 1 0 360 arc\n");
00046         out.write("setmatrix\n");
00047         out.write(fill.r+" "+fill.g+" "+fill.b+" setrgbcolor\n");
00048         out.write("fill\n");
00049         out.write("matrix currentmatrix\n");
00050         out.write(cx+".0 "+cy+".0 translate "+r+".0 "+r+
00051                 ".0 scale 1 0 moveto 0 0 1 0 360 arc\n");
00052         out.write("setmatrix\n");
00053         out.write("0 setlinejoin 2 setlinecap\n");
00054         out.write("1 setlinewidth\n");
00055         out.write("[] 0 setdash\n");
00056         out.write(outline.r+" "+outline.g+" "+outline.b+" setrgbcolor\n");
00057         out.write("stroke\n");
00058         out.write("grestore\n");
00059     }
00060 
00061     BoundingBox bb() {
00062         return new BoundingBox(cx-r,cx+r,cy-r,cy+r);
00063     }
00064 }