| 1 |
|
| 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 |
|
| 11 |
|
| 12 |
|
| 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 |
|
| 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 |
} |