Debian Codegraph @

freehep-graphicsio-latex/src/main/java/org/freehep/graphicsio/latex/LatexPathConstructor.java

raw symbols SCIP
1 // Copyright 2004, FreeHEP
2 package org.freehep.graphicsio.latex;
3
4 import java.io.IOException;
5 import java.io.PrintStream;
6
7 import org.freehep.graphicsio.QuadToCubicPathConstructor;
8
9 /**
10 * @author Andre Bach
11 * @author Mark Donszelmann
12 * @version $Id: freehep-graphicsio-latex/src/main/java/org/freehep/graphicsio/latex/LatexPathConstructor.java e3449d5a3c6c 2005/12/07 22:14:47 duns $
13 */
14 public class LatexPathConstructor extends QuadToCubicPathConstructor {
15
16 private PrintStream ps;
17
18 public LatexPathConstructor(PrintStream ps) {
19 super();
20 this.ps = ps;
21 }
22
23 public void move(double x, double y) throws IOException {
24 ps.println("\\moveto(" + fixedPrecision(x) + "," + fixedPrecision(y)
25 + ")");
26 }
27
28 public void line(double x, double y) throws IOException {
29 ps.println("\\lineto(" + fixedPrecision(x) + "," + fixedPrecision(y)
30 + ")");
31 // psline doesn't give proper corners at sharp angles
32 }
33
34 public void cubic(double x1, double y1, double x2, double y2, double x3,
35 double y3) throws IOException {
36 super.cubic(x1, y1, x2, y2, x3, y3);
37 ps.println("\\curveto(" + fixedPrecision(x1) + "," + fixedPrecision(y1)
38 + ")(" + fixedPrecision(x2) + "," + fixedPrecision(y2) + ")("
39 + fixedPrecision(x3) + "," + fixedPrecision(y3) + ")");
40 }
41
42 public void closePath(double x0, double y0) throws IOException {
43 ps.println("\\closepath");
44 }
45
46 protected String fixedPrecision(double d) {
47 return LatexGraphics2D.fixedPrecision(d);
48 }
49 }