John, is it possible to use the flyweight pattern for your BasicStroke
objects? Have you got a profiling tool like OptimizeIt to actually see what
is slowing your program down?
I've radically improved performance in (admittedly not as low level) Swing
programs by using flyweights, and where is the majority of painting occuring
in your application?
If you are doing a lot of work in the paint method for your container
(canvas?) and it's constituents this could also be a bottleneck.
Try and make your paint methods as small and fast as possible. Do extra work
in setting up caches, and smarter objects so that you're not calling
on-the-fly calculating aglorithms in your paint methods.
regards,
Neil
-----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
**********************************************************************
This email is intended only for the addressee. This email
and any files transmitted with it may contain confidential
or privileged information. If you are not the named
addressee or the person responsible for delivering the
message to the named addressee, please contact
[EMAIL PROTECTED]
This email has been scanned by MAILsweeper.
**********************************************************************
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing