Try reducing the number of points in each polyline to a maximum of 200
or so. You would need to adjust the 'dash_phase' on each section to get
the pieces to join without artefacts (or you just ignore the artefacts).
Each polyline is converted to a huge polygon (or set of disconnected
polygons in this case) which is then filled. The polygon fill algorithm
is not linear in the number of points. Ideally, with a line width of 1
pixel, and provided anti-aliasing is /not/ being used, then a much
faster dashed line algorithm is possible, but I don't know if Java2D
detects this case. In any case the extra quality provided by
anti-aliasing is very nice, but it costs ...

I once encountered a similar problem when drawing Nordic coastlines
under Windows with C++. This lead to humorous references to the "Hitch
Hikers Guide to the Galaxy" ...

Regards,
Mark Thornton

-----Original Message-----
From: Vella, John [mailto:[EMAIL PROTECTED]]
Sent: 17 March 2001 04:00
To: Advanced Swing Mail List (E-mail)
Subject: Anyone got some tricks for making dashed strokes draw faster?


I have to draw 1-pixel wide polylines(~5000 pts visible at one time)
with a
variety of different dash patterns to help distinguish them. My problem
is
the incredibly poor performance of using BasicStroke to get the dashed
lines
drawn. I'm using the following constructor to build one of the line
styles:

   final int CAP  = BasicStroke.CAP_BUTT;
   final int JOIN = BasicStroke.JOIN_MITER;
   final float[] pattern = {20.0f, 20.0f};
   BasicStroke bs =
     new BasicStroke(1.0f, CAP, JOIN, 10.0f, pattern, 0.0f);

 
When my drawing application is zoomed in so there are only a few hundred
data points in the polyline arrays(I use g.drawPolyline(xpts, ypts,
npts))
then the performance is OK. But when I'm zoomed all the way out so there
are
several thousand data points in the polyline, then scrolling of my
graphical
drawing surface is pretty much unusable.

Are there any tricks I can try? I've tried using a TexturePaint with a
solid
stroke but this is only marginally better, and the quality of the pseudo
dash patterns is awful when compared to what you can get with
BasicStroke.

Short of trying to tell all my users to run on a dual processor 1.5GHz
PC,
what can I do?

Thanks,

John  (using 1.3)
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing

Reply via email to