You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by dv...@apache.org on 2006/12/20 13:50:39 UTC
svn commit: r489071 - in
/xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/geom:
Polygon2D.java Polyline2D.java
Author: dvholten
Date: Wed Dec 20 04:50:39 2006
New Revision: 489071
URL: http://svn.apache.org/viewvc?view=rev&rev=489071
Log:
some tuning
Modified:
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/geom/Polygon2D.java
xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/geom/Polyline2D.java
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/geom/Polygon2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/geom/Polygon2D.java?view=diff&rev=489071&r1=489070&r2=489071
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/geom/Polygon2D.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/geom/Polygon2D.java Wed Dec 20 04:50:39 2006
@@ -28,12 +28,14 @@
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
+import java.io.Serializable;
/**
* This class is a Polygon with float coordinates.
*
+ * @version $Id: DisplacementMapRed.java 478276 2006-11-22 18:33:37Z dvholten $
*/
-public class Polygon2D implements Shape, Cloneable, java.io.Serializable {
+public class Polygon2D implements Shape, Cloneable, Serializable {
/**
* The total number of points. The value of <code>npoints</code>
@@ -83,9 +85,9 @@
if (rec == null) {
throw new IndexOutOfBoundsException("null Rectangle");
}
- this.npoints = 4;
- this.xpoints = new float[4];
- this.ypoints = new float[4];
+ npoints = 4;
+ xpoints = new float[4];
+ ypoints = new float[4];
xpoints[0] = (float)rec.getMinX();
ypoints[0] = (float)rec.getMinY();
xpoints[1] = (float)rec.getMaxX();
@@ -222,11 +224,10 @@
/* get the associated {@link Polyline2D}.
*/
public Polyline2D getPolyline2D() {
- Polyline2D pol = new Polyline2D();
- for (int i = 0; i < npoints; i++) {
- pol.addPoint((float)xpoints[i], (float)ypoints[i]);
- }
- pol.addPoint((float)xpoints[0], (float)ypoints[0]);
+
+ Polyline2D pol = new Polyline2D( xpoints, ypoints, npoints );
+
+ pol.addPoint( xpoints[0], ypoints[0]);
return pol;
}
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/geom/Polyline2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/geom/Polyline2D.java?view=diff&rev=489071&r1=489070&r2=489071
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/geom/Polyline2D.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/ext/awt/geom/Polyline2D.java Wed Dec 20 04:50:39 2006
@@ -28,12 +28,16 @@
import java.awt.geom.PathIterator;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
+import java.io.Serializable;
/**
* This class has the same behavior than {@link Polygon2D}, except that
* the figure is not closed.
+ *
+ * @version $Id: DisplacementMapRed.java 478276 2006-11-22 18:33:37Z dvholten $
*/
-public class Polyline2D implements Shape, Cloneable, java.io.Serializable {
+public class Polyline2D implements Shape, Cloneable, Serializable {
+
private static final float ASSUME_ZERO = 0.001f;
/**
@@ -94,8 +98,8 @@
throw new IndexOutOfBoundsException("npoints > xpoints.length || npoints > ypoints.length");
}
this.npoints = npoints;
- this.xpoints = new float[npoints];
- this.ypoints = new float[npoints];
+ this.xpoints = new float[npoints+1]; // make space for one more to close the polyline
+ this.ypoints = new float[npoints+1]; // make space for one more to close the polyline
System.arraycopy(xpoints, 0, this.xpoints, 0, npoints);
System.arraycopy(ypoints, 0, this.ypoints, 0, npoints);
calculatePath();
@@ -130,9 +134,9 @@
}
public Polyline2D(Line2D line) {
- this.npoints = 2;
- this.xpoints = new float[2];
- this.ypoints = new float[2];
+ npoints = 2;
+ xpoints = new float[2];
+ ypoints = new float[2];
xpoints[0] = (float)line.getX1();
xpoints[1] = (float)line.getX2();
ypoints[0] = (float)line.getY1();