Hi All
I wonder if anyone can help me with an exception I’m getting using Path2D. I’m generating a line for a river like so:
float px=0;
float py = dimM/2;
Fbm fbm = new Fbm(2.0f, 1.5f, 8f);
float s = 0.0005f;
float offset = rnd.nextFloat() * 999f;
river = new Path2D.Double();
river.moveTo(px,py);
for(int i=0; i<dimM; i++){
px = (float)i;
py += fbm.fBm(offset + px*s, py*s) * 5;
river.lineTo(px,py);
}
and rendering with:
public void paint(Graphics g1){
Graphics2D g = (Graphics2D) g1;
g.setColor(Color.BLUE);
g.draw(river);
}
The exception I’m getting is:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 2280
at java.awt.geom.AffineTransform.transform(AffineTransform.java:3405)
at java.awt.geom.Path2D$Double$TxIterator.currentSegment(Path2D.java:1686)
at sun.dc.DuctusRenderingEngine.getAATileGenerator(DuctusRenderingEngine.java:442)
at sun.java2d.pipe.AAShapePipe.renderPath(AAShapePipe.java:152)
at sun.java2d.pipe.AAShapePipe.draw(AAShapePipe.java:64)
at sun.java2d.pipe.PixelToParallelogramConverter.draw(PixelToParallelogramConverter.java:148)
at sun.java2d.pipe.PixelToParallelogramConverter.draw(PixelToParallelogramConverter.java:148)
at sun.java2d.SunGraphics2D.draw(SunGraphics2D.java:2461)
at city.City$CityPanel.paint(City.java:163)
etc....