Rectangle.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
00023 package org.gecode.gist.postscript;
00024
00025 import java.io.Writer;
00026 import java.io.IOException;
00027
00028 public class Rectangle extends Path {
00029 private int c1x, c1y, c2x, c2y;
00030 private PSColor outline;
00031 private PSColor fill;
00032
00033 public Rectangle(int c1x0, int c1y0, int c2x0, int c2y0,
00034 PSColor outline0, PSColor fill0) {
00035 c1x = c1x0;
00036 c1y = c1y0;
00037 c2x = c2x0;
00038 c2y = c2y0;
00039 outline = outline0;
00040 fill = fill0;
00041 }
00042
00043 void emit(Writer out) throws IOException {
00044 out.write("gsave\n");
00045 out.write(c1x+".0 "+c1y+".0 moveto "+c1x+".0 "+c2y+".0 lineto ");
00046 out.write(c2x+".0 "+c2y+".0 lineto "+c2x+".0 "+c1y+
00047 ".0 lineto "+"closepath\n");
00048 out.write(fill.r+" "+fill.g+" "+fill.b+" setrgbcolor\n");
00049 out.write("fill\n");
00050 out.write(c1x+".0 "+c1y+".0 moveto "+c1x+".0 "+c2y+".0 lineto ");
00051 out.write(c2x+".0 "+c2y+".0 lineto "+c2x+".0 "+c1y+
00052 ".0 lineto "+"closepath\n");
00053 out.write("1 setlinejoin 1 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(Math.min(c1x,c2x), Math.max(c1x,c2x),
00063 Math.min(c1y,c2y), Math.max(c1y,c2y));
00064 }
00065 }