Circle.java
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 }