Use of drawLine() vs drawPolyLine()

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
plusik
Posts: 28
Joined: Tue May 16, 2006 3:36 am
Location: Boston, MA, USA

Use of drawLine() vs drawPolyLine()

Post by plusik » Wed Feb 17, 2016 11:50 pm

Hi,

We noticed that if JFreeChart line chart is drawn into a vector device such as PDF, the plots are composed of many disconnected lines.

This is ok for screen viewing, but when a vector graphics file (e.g., PDF or SVG) is produced, it makes subsequent downstream editing more difficult, because it is impossible to adjust the parameters of the whole line that belongs to a series (such as color or line thickness).

For making scientific figures, we often need to adjust the exported charts, e.g. in Adobe Illustrator or Inkscape.

I suppose the cause of this problem is that the XYLineAndShapeRenderer class is using Graphics2D.drawLine() to draw each segment separately. If it used Graphics2D.drawPolyLine() to draw the entire series, it would produce a single "polyline" object in the resulting vector image.

Would it be too very difficult to change this?

Tomas

Ref: https://docs.oracle.com/javase/7/docs/a ... [],%20int)

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Use of drawLine() vs drawPolyLine()

Post by david.gilbert » Thu Feb 18, 2016 5:25 pm

In the XYLineAndShapeRenderer class, there is a flag drawSeriesLineAsPath. It defaults to false, but you can set it to true and then the line for a series will be drawn as a single path.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

plusik
Posts: 28
Joined: Tue May 16, 2006 3:36 am
Location: Boston, MA, USA

Re: Use of drawLine() vs drawPolyLine()

Post by plusik » Thu Feb 18, 2016 5:35 pm

Amazing!
JFreeChart never stops surprising me :)

Locked