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

Triangle.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 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 }