Generated on Thu Nov 2 14:49:35 2006 for Gecode/J by doxygen 1.5.0

Rectangle.java

Go to the documentation of this file.
00001 /* -*- indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Guido Tack <tack@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Guido Tack, 2006
00008  *
00009  *  Last modified:
00010  *     $Date: 2006-02-09 16:32:56 +0100 (Thu, 09 Feb 2006) $ by $Author: tack $
00011  *     $Revision: 2943 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  See the file "LICENSE" for information on usage and
00018  *  redistribution of this file, and for a
00019  *     DISCLAIMER OF ALL WARRANTIES.
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 }