Improvement suggestion

A discussion forum for JFreeSVG (a fast, lightweight, SVG generator for the Java platform).
Post Reply
CommanderSirow
Posts: 1
Joined: Tue Aug 05, 2014 12:21 pm
antibot: No, of course not.

Improvement suggestion

Post by CommanderSirow » Tue Aug 05, 2014 12:55 pm

I'm currently working with JFreeSVG for a university project and I really like JFreeSVG's simplicity in comparison to batik.
(Had my svg-chart export drop from >250MB size to a few mega-bytes)

There were a few necessary addition I made to it, comming from version 1.9 I see you allready have implemented the rgba fix. :)
But here are two additional suggestions:


Adding support for stroke-linecap:
In SVGGraphics2D.java after

Code: Select all

private String strokeStyle() {
add

Code: Select all

		String strokeCap = "butt";
In SVGGraphics2D.java after

Code: Select all

dashArray = bs.getDashArray();
add

Code: Select all

            switch (bs.getEndCap()) {
			case BasicStroke.CAP_ROUND:
				strokeCap = "round";
				break;
			case BasicStroke.CAP_SQUARE:
				strokeCap = "square";
				break;
			default:
			case BasicStroke.CAP_BUTT:
            }
In SVGGraphics2D.java after

Code: Select all

        b.append("stroke-opacity: ").append(getColorAlpha() * getAlpha())
                .append(";");
add

Code: Select all

b.append("stroke-linecap: ").append(strokeCap).append(";");

Add support to export a compressed SVG (SVGZ), with something like:

Code: Select all

public static void saveCompressed(String path, String text) {
	BufferedWriter writer = null;
	
	try {
		final File file = new File(path);
		final GZIPOutputStream zip = new GZIPOutputStream(new FileOutputStream(file));
		writer = new BufferedWriter(new OutputStreamWriter(zip, "UTF-8"));
		writer.append(text);
		writer.flush();
		writer.close();
	} catch (final FileNotFoundException e) {} catch (final IOException e) {} finally {
		if (writer != null)
			try {
				writer.close();
			} catch (final IOException e) {}
	}
}
Best Regards and thanks for working on all those jFree* stuff :D


EDIT: Faulty explanation fixed ^^

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

Re: Improvement suggestion

Post by david.gilbert » Fri Aug 15, 2014 5:40 pm

These are good suggestions, I will incorporate the changes in the next release (2.2).
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited

Post Reply