| 1 |
// Copyright 2007, FreeHEP. |
| 2 |
package org.freehep.graphicsio.emf.gdi; |
| 3 |
|
| 4 |
import org.freehep.graphicsio.emf.EMFTag; |
| 5 |
import org.freehep.graphicsio.emf.EMFOutputStream; |
| 6 |
|
| 7 |
import java.awt.Rectangle; |
| 8 |
import java.awt.Point; |
| 9 |
import java.io.IOException; |
| 10 |
|
| 11 |
/** |
| 12 |
* @author Steffen Greiffenberg |
| 13 |
* @version $Id: freehep-graphicsio-emf/src/main/java/org/freehep/graphicsio/emf/gdi/AbstractPolygon.java 1f907e13cce8 2007/01/24 15:10:42 duns $ |
| 14 |
*/ |
| 15 |
public abstract class AbstractPolygon extends EMFTag { |
| 16 |
|
| 17 |
private Rectangle bounds; |
| 18 |
|
| 19 |
private int numberOfPoints; |
| 20 |
|
| 21 |
private Point[] points; |
| 22 |
|
| 23 |
protected AbstractPolygon(int id, int version) { |
| 24 |
super(id, version); |
| 25 |
} |
| 26 |
|
| 27 |
protected AbstractPolygon(int id, int version, Rectangle bounds, int numberOfPoints, Point[] points) { |
| 28 |
super(id, version); |
| 29 |
this.bounds = bounds; |
| 30 |
this.numberOfPoints = numberOfPoints; |
| 31 |
this.points = points; |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
public void write(int tagID, EMFOutputStream emf) throws IOException { |
| 36 |
emf.writeRECTL(bounds); |
| 37 |
emf.writeDWORD(numberOfPoints); |
| 38 |
emf.writePOINTL(numberOfPoints, points); |
| 39 |
} |
| 40 |
|
| 41 |
public String toString() { |
| 42 |
String result = super.toString() + |
| 43 |
"\n bounds: " + bounds + |
| 44 |
"\n #points: " + numberOfPoints; |
| 45 |
if (points != null) { |
| 46 |
result += "\n points: "; |
| 47 |
for (int i = 0; i < points.length; i++) { |
| 48 |
result += "[" + points[i].x + "," + points[i].y + "]"; |
| 49 |
if (i < points.length - 1) { |
| 50 |
result += ", "; |
| 51 |
} |
| 52 |
} |
| 53 |
} |
| 54 |
return result; |
| 55 |
} |
| 56 |
|
| 57 |
protected Rectangle getBounds() { |
| 58 |
return bounds; |
| 59 |
} |
| 60 |
|
| 61 |
protected int getNumberOfPoints() { |
| 62 |
return numberOfPoints; |
| 63 |
} |
| 64 |
|
| 65 |
protected Point[] getPoints() { |
| 66 |
return points; |
| 67 |
} |
| 68 |
} |