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