Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #38

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ pom.xml.releaseBackup
release.properties
dependency-reduced-pom.xml
/freehep-graphics2d-headless-example/YourPanel.pdf

*.iml
*.idea
2 changes: 1 addition & 1 deletion freehep-graphics2d-export-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>freehep-vectorgraphics</artifactId>
<groupId>org.freehep</groupId>
<version>2.4</version>
<version>2.4.ninjoPatch3-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion freehep-graphics2d-headless-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>freehep-vectorgraphics</artifactId>
<groupId>org.freehep</groupId>
<version>2.4</version>
<version>2.4.ninjoPatch3-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion freehep-graphics2d/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>freehep-vectorgraphics</artifactId>
<groupId>org.freehep</groupId>
<version>2.4</version>
<version>2.4.ninjoPatch3-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion freehep-graphicsbase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<parent>
<artifactId>freehep-vectorgraphics</artifactId>
<groupId>org.freehep</groupId>
<version>2.4</version>
<version>2.4.ninjoPatch3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>freehep-graphicsbase</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion freehep-graphicsio-emf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>freehep-vectorgraphics</artifactId>
<groupId>org.freehep</groupId>
<version>2.4</version>
<version>2.4.ninjoPatch3-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion freehep-graphicsio-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>freehep-vectorgraphics</artifactId>
<groupId>org.freehep</groupId>
<version>2.4</version>
<version>2.4.ninjoPatch3-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion freehep-graphicsio-pdf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>freehep-vectorgraphics</artifactId>
<groupId>org.freehep</groupId>
<version>2.4</version>
<version>2.4.ninjoPatch3-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,16 +798,25 @@ protected void writeTransform(AffineTransform t) throws IOException {
* ================================================================================
*/
protected void writeSetClip(Shape s) throws IOException {

// clear old clip
// FIXME this code only clears the clip if the PDF graphics state stack has been
// kept so shallow that a single "pop" removes the clip. However, when using
// Graphics.create states are being pushed on the stack and this method doesn't
// successfully clear the clip any more. A solution requires clearing the whole
// stack, setting a new clip and reconstructing the stack when the state with the
// new clip gets popped some time later.
try {
AffineTransform at = getTransform();
Stroke stroke = getStroke();
Color color = getColor();

writeGraphicsRestore();
writeGraphicsSave();

writeStroke(stroke);
writeTransform(at);
writePaint(color);
} catch (IOException e) {
handleException(e);
}
Expand Down
2 changes: 1 addition & 1 deletion freehep-graphicsio-ps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>freehep-vectorgraphics</artifactId>
<groupId>org.freehep</groupId>
<version>2.4</version>
<version>2.4.ninjoPatch3-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion freehep-graphicsio-svg/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>freehep-vectorgraphics</artifactId>
<groupId>org.freehep</groupId>
<version>2.4</version>
<version>2.4.ninjoPatch3-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.DateFormat;
Expand Down Expand Up @@ -260,14 +261,14 @@ public void writeHeader() throws IOException {
ros = new GZIPOutputStream(ros);
}

os = new PrintWriter(ros, true);
os = new PrintWriter(new OutputStreamWriter(ros, "UTF-8"), true);
fontTable = new SVGFontTable();

// Do the bounding box calculation.
setBoundingBox();
imageNumber = 0;

os.println("<?xml version=\"1.0\" standalone=\"no\"?>");
os.println("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>");
if (getProperty(VERSION).equals(VERSION_1_1)) {
// no DTD anymore
} else {
Expand Down Expand Up @@ -318,7 +319,7 @@ public void writeHeader() throws IOException {
if (!isDeviceIndependent()) {
os.print(" Date: "
+ DateFormat.getDateTimeInstance(DateFormat.FULL,
DateFormat.FULL).format(new Date()));
DateFormat.FULL).format(new Date()));
}
os.println("</desc>");

Expand Down Expand Up @@ -446,7 +447,7 @@ public void draw(Shape shape) {
style.put("fill", "none");
style.putAll(getStrokeProperties(getStroke(), false));

writePathIterator(path, style);
writePathIterator(shape, style);
} else if (getStroke() != null) {
// fill the shape created by stroke
fill(getStroke().createStrokedShape(shape));
Expand Down Expand Up @@ -486,18 +487,18 @@ public void fill(Shape shape) {
// no border
style.put("stroke", "none");

writePathIterator(path, style);
writePathIterator(shape, style);
}
}

/**
* writes a path using {@link #getPath(java.awt.geom.PathIterator)}
* writes a shape's path using {@link #getPath(java.awt.geom.PathIterator)}
* and the given style
*
* @param pi PathIterator
* @param shape The shape to get a PathIterator from
* @param style Properties for <g> tag
*/
private void writePathIterator(PathIterator pi, Properties style) {
private void writePathIterator(Shape shape, Properties style) {
StringBuffer result = new StringBuffer();

// write style
Expand All @@ -506,6 +507,7 @@ private void writePathIterator(PathIterator pi, Properties style) {
result.append(">\n ");

// draw shape
PathIterator pi = shape.getPathIterator(null);
result.append(getPath(pi));

// close style
Expand All @@ -516,6 +518,8 @@ private void writePathIterator(PathIterator pi, Properties style) {
// test if clip intersects pi
if (getClip() != null) {
GeneralPath gp = new GeneralPath();

pi = shape.getPathIterator(null);
gp.append(pi, true);
// create the stroked shape
Stroke stroke = getStroke() == null? defaultStroke : getStroke();
Expand Down
2 changes: 1 addition & 1 deletion freehep-graphicsio-swf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>freehep-vectorgraphics</artifactId>
<groupId>org.freehep</groupId>
<version>2.4</version>
<version>2.4.ninjoPatch3-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion freehep-graphicsio-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>freehep-vectorgraphics</artifactId>
<groupId>org.freehep</groupId>
<version>2.4</version>
<version>2.4.ninjoPatch3-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void paintComponent(Graphics g) {
vg.fillRect(0, 0, dim.width, dim.height);

int nx = 6;
int ny = 6;
int ny = 7;

int dw = dim.width / (nx + 1);
int dh = dim.height / ny;
Expand Down Expand Up @@ -216,8 +216,27 @@ public void paintComponent(Graphics g) {
svg2.fill(clippedPath);
svg2.dispose();
}
svg.dispose();

// Java setClip and Draw
svg = (VectorGraphics) vg.create();
svg.drawString("JavaSetClip", 10, 10 + 10 + 6 * dh);
svg.scale(factor, factor);
svg.translate(10 / factor, 10 / factor + 6 * dh / factor);
for (int i = 0; i < nx; i++) {
svg.translate(dw / factor, 0);
VectorGraphics svg2 = (VectorGraphics) svg.create();
svg2.setColor(Color.red);
svg2.setLineWidth(1.0 / factor);
svg2.draw(clip[i]);
svg2.setColor(Color.blue); // color is set before setClip to check that it is taken over
svg2.setClip(clip[i]);
svg2.setLineWidth(3.0 / factor);
svg2.draw(path[i]);
svg2.dispose();
}
svg.dispose();

}

public static void main(String[] args) throws Exception {
Expand Down
2 changes: 1 addition & 1 deletion freehep-graphicsio/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>freehep-vectorgraphics</artifactId>
<groupId>org.freehep</groupId>
<version>2.4</version>
<version>2.4.ninjoPatch3-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.freehep</groupId>
<artifactId>freehep-vectorgraphics</artifactId>
<version>2.4</version>
<version>2.4.ninjoPatch3-SNAPSHOT</version>
<packaging>pom</packaging>

<name>FreeHEP Vector Graphics</name>
Expand Down