Sorry Michaël, I didn't mean to mislead you, but I didn't include all of the code as I was still doing testing. There were a number of side effects to adding the SEG_CLOSE and changing from GeneralPath to Path2D.Double. I had to change PolygonShape, Java2DCovnerter, and StyleUtil. The difference between the Linestring and Polygon code is the explicit test for closed in Linestring.
The full method in Java2DConverter is: class LineStringPath extends LineString implements PathIterator { private int iterate; private int numPoints; private Coordinate[] points; private Java2DConverter j2D; private boolean closed; public LineStringPath(LineString linestring, Java2DConverter j2D){ super(null, new GeometryFactory()); //this.linestring = linestring; this.j2D = j2D; try { points = j2D.toViewCoordinates(linestring.getCoordinates()); } catch (NoninvertibleTransformException ex){ } this.numPoints = points.length; //linestring.getNumPoints(); iterate = 0; closed = (numPoints>1) && (points[0].equals2D(points[numPoints-1])); } private int getSegType(){ if (closed && (iterate == numPoints-1)) return PathIterator.SEG_CLOSE; return (iterate==0) ? PathIterator.SEG_MOVETO : PathIterator.SEG_LINETO; } public int currentSegment(double[] coords) { coords[0] = points[iterate].x; coords[1] = points[iterate].y; return getSegType(); } public int currentSegment(float[] coords) { coords[0] = (float) points[iterate].x; coords[1] = (float) points[iterate].y; return getSegType(); } public int getWindingRule() { return GeneralPath.WIND_NON_ZERO; } public boolean isDone() { return !(iterate < numPoints); } public void next() { iterate++; } } The full method in PolygonShape is: class PolygonPath implements PathIterator { private int iterate; private int numPoints; private Coordinate[] points; public PolygonPath(Coordinate[] coordinates){ points = coordinates; this.numPoints = points.length; iterate = 0; } private int getSegType(){ if (iterate == numPoints-1) return PathIterator.SEG_CLOSE; return (iterate==0) ? PathIterator.SEG_MOVETO : PathIterator.SEG_LINETO; } public int currentSegment(double[] coords) { coords[0] = points[iterate].x; coords[1] = points[iterate].y; return getSegType(); } public int currentSegment(float[] coords) { coords[0] = (float) points[iterate].x; coords[1] = (float) points[iterate].y; return getSegType(); } public int getWindingRule() { return GeneralPath.WIND_EVEN_ODD; } public boolean isDone() { return !(iterate < numPoints); } public void next() { iterate++; } } That should work as advertised. Then to complete the mod for double, just change all of the GeneralPath references (except for constants) to Path2D.Double in PolygonShape, Java2DCovnerter, and StyleUtil. In StyleUtil: if (!(shape instanceof Path2D.Double) && renderingFill) { regards, Larry On 7/13/07, Michaël Michaud <[EMAIL PROTECTED]> wrote: > Hi, > > I tested this one, but it did not change the result for me. > The JOIN_BEVEL appears and desappears depending on scale in both cases, > with old code and with your patch. > > I read that PathIterator.SEG_CLOSE add a segment back to the point > corresponding to the most recent SEG_MOVETO. > In our case, this segment already exists because the linestring is > closed. Will we have to trace one more segment (over the first one) ? > How your code is supposed to change the join type? > > Michaël > > > Larry Becker a écrit : > > >We recently implemented some modifications to Java2DConverter and > >PolygonShape to use PathIterator. The implementation was slightly > >flawed and resulted in paths that didn't use a SEG_CLOSE which causes > >closed paths to fail to connect start and end with a JOIN_BEVEL. You > >can see the problem very easily if you start OJ, drag out a rectangle, > >and then increase the line width to 10. > > > >The fix is: > > > > private int getSegType(){ > > if (closed && (iterate == numPoints-1)) > > return PathIterator.SEG_CLOSE; > > return (iterate==0) ? PathIterator.SEG_MOVETO : > > PathIterator.SEG_LINETO; > > } > > > >I would also like to increase the accuracy of the rendering system > >from float to double by replacing all references to GeneralPath with > >Path2D.Double. There is no speed or memory penalty for this change. > > > >regards, > >Larry Becker > > > > > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Jump-pilot-devel mailing list > Jump-pilot-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > -- http://amusingprogrammer.blogspot.com/ ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel