Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Java
 QCChart2D for Java
 Two simple rendering speed ups
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

PeterJ

26 Posts

Posted - 24 Aug 2010 :  12:37:53  Show Profile  Reply with Quote
We found two speed up which reduced plot line rendering time in our plots from the order of hundreds of milliseconds to a millisecond or two.

The first was to change the definition of a solid line in ChartAttrribute for [10,0,10,0] to just null. The original definition was the define a solid line as a number of dotted lines with no gap between the dots. Dotted lines are slow for Sun's drawPolyLine

private static float lineStyleData[][] =
{null,{8,4,8,4},{4,4,4,4},{4,2,4,2},{2,2,2,2},{1,1,1,1},{1,2,1,2},{1,4,1,4},{1,8,1,8},{8,4,1,4}};

The second was to turn off antialiasing in ChartView. It would be great to be able to set this option as we're using step plots and anti aliasing is of not benefit. We tried on no-step plots and the results are acceptable. It would be nice if the developer could choose between slight appearance improvement or significant run time.

quinncurtis

1586 Posts

Posted - 24 Aug 2010 :  15:24:01  Show Profile  Reply with Quote
Thanks for the stroke information. I can't find anywhere in the Java documentation that BasicStroke can take a null as the dash pattern, but it does seem to work, and speed things up. You can implement this change using the standard library by just creating your own BasicStroke object, and calling the ChartAttribute.setCustomStroke method.

ChartAttribute customattrib = new ChartAttribute(Color.Blue)
BasicStroke bs = new BasicStoke(1);
customattrib.setCustomStroke(bs);

It does look like a good change to make to the standard library.

You can set your own custom rendering hints with a call to the ChartView.setRenderingHints method.

RenderingHints defaultrendering;
RenderingHints renderingHints = new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

// defaultrendering = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// renderingHints.add(defaultrendering);
defaultrendering = new RenderingHints(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
renderingHints.add(defaultrendering);
defaultrendering = new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
renderingHints.add(defaultrendering);
defaultrendering = new RenderingHints(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
renderingHints.add(defaultrendering);
defaultrendering = new RenderingHints(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
renderingHints.add(defaultrendering);

// defaultrendering = new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
// renderingHints.add(defaultrendering);

gWG.setRenderingHints(renderingHints);


We have found that if antialiasing is off, a polygon, and a filled polygon will not match perfectly and leave unfilled pixels. Also, turning antialiasing for text makes the text look really, really, bad.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-2018 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07