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

Line.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 Line extends Path {
00028     private int ax, ay, bx, by;
00029     private PSColor color;
00030 
00031     public Line(int ax0, int ay0, int bx0, int by0, PSColor color0) {
00032         ax = ax0; ay = ay0;
00033         bx = bx0; by = by0;
00034         color = color0;
00035     }
00036 
00037     void emit(Writer out) throws IOException {
00038         out.write("gsave\n");
00039         out.write(ax+".0 "+ay+".0 moveto\n");
00040         out.write(bx+".0 "+by+".0 lineto\n");
00041         out.write("0 setlinecap\n");
00042         out.write("1 setlinejoin\n");
00043         out.write("1 setlinewidth\n");
00044         out.write("[] 0 setdash\n");
00045         out.write(color.r+" "+color.g+" "+color.b+" setrgbcolor\n");
00046         out.write("stroke\n");
00047         out.write("grestore\n");
00048     }
00049 
00050     BoundingBox bb() {
00051         return new BoundingBox(Math.min(ax,bx), Math.max(ax,bx),
00052                                Math.min(ay,by), Math.max(ay,by));
00053     }
00054 }