Skip to main content

Stroke perfomance issue

1 reply [Last post]
Anonymous

I'm creating some sort of vector image editor in java
now, and I need to draw lines, points and curves in
different styles -- like dashed, dotted lines, points as
small square, rhomb (different sizes and line widths),
and so on. So, my first questions is:

1) I've seen great performance degrading than use pattern
line style (I actually use BasicStroke with pattern like
new float[]{5,5}) -- one or two such lines on canvas make
my Athlon1800+ down then I start to drag this lines. Is
where are a way to walk around this, or it's common
problem?

2) What is the convenient way to implement different
point's style (square, rhomb, etc) -- currently I'm
thinking about create set of custom Shapes implementation
for each style, and, holding one instance of each style's
Shape, move it to location of current drawing point, but
I'm not sure first that it is legal to change properties
of Shape than it's already drawn in Graphics2D, and
second, that it will not be much slower than simply
drawing by set of lines. And, (much more important) --
where are many methods in Shape to implement, I searching
for a better solution.

Thanks!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anonymous

...I've found the root of problem -- to create lines looking like infinitly I've use very large length (about 10000px). It seems, what Graphics [i]first[/i] calculates and creates all elementary shapes from, for example, dashed line, and only [i]then[/i] applying current clipping -- so, in my case this produce great overhead. And, so, my next question is: how I can workaround this? How I can set clipping, what will be applied before stroked curve will be break up on segments? Now I'm forced to make clipping by myself, but I feel, it is not a good idea...