Triangle.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 Triangle extends Path {
00028 private int c1x, c1y, c2x, c2y, c3x, c3y;
00029 private PSColor outline;
00030 private PSColor fill;
00031
00032 public Triangle(int c1x0, int c1y0, int c2x0, int c2y0, int c3x0, int c3y0,
00033 PSColor outline0, PSColor fill0) {
00034 c1x = c1x0;
00035 c1y = c1y0;
00036 c2x = c2x0;
00037 c2y = c2y0;
00038 c3x = c3x0;
00039 c3y = c3y0;
00040 outline = outline0;
00041 fill = fill0;
00042 }
00043
00044 void emit(Writer out) throws IOException {
00045 out.write("gsave\n");
00046 out.write(c1x+" "+c1y+" moveto "+c2x+" "+c2y+" lineto ");
00047 out.write(c3x+" "+c3y+" lineto "+c1x+" "+c1y+" lineto\n");
00048 out.write(fill.r+" "+fill.g+" "+fill.b+" setrgbcolor\n");
00049 out.write("eofill\n");
00050 out.write(c1x+" "+c1y+" moveto "+c2x+" "+c2y+" lineto ");
00051 out.write(c3x+" "+c3y+" lineto "+c1x+" "+c1y+" lineto\n");
00052 out.write("1 setlinejoin 1 setlinecap\n");
00053 out.write("1 setlinewidth\n");
00054 out.write("[] 0 setdash\n");
00055 out.write(outline.r+" "+outline.g+" "+outline.b+" setrgbcolor\n");
00056 out.write("stroke\n");
00057 out.write("grestore\n");
00058 }
00059
00060 BoundingBox bb() {
00061 return new BoundingBox(Math.min(Math.min(c1x,c2x),c3x),
00062 Math.max(Math.max(c1x,c2x),c3x),
00063 Math.min(Math.min(c1y,c2y),c3y),
00064 Math.max(Math.max(c1y,c2y),c3y));
00065 }
00066 }