eseifert / vectorgraphics2d Goto Github PK
View Code? Open in Web Editor NEWGraphics2D implementations to export various vector file formats
License: GNU General Public License v3.0
Graphics2D implementations to export various vector file formats
License: GNU General Public License v3.0
The command handling methods should be extracted and moved to new Processor
classes.
What does "Some features are still missing, like [..] text encoding" really mean? I'm trying to print some non-ascii characters (swedish åäö) that comes out invalid. Can I somehow output these characters by changing encoding of the text myself before using drawString()? Thanks for your time!
EPS doesn't support rounded rectangle at the moment. Add support for rounded rectangles directly or by converting them to vector shapes.
Imported from trac ticket #6, created by eseifert on 11-07-2010 at 16:41, last modified: 11-09-2010 at 10:07
At the moment arcs in EPS aren't rendered correctly. The arc angles are wrong and the type of arc isn't taken into account.
Imported from trac ticket #7, created by eseifert on 11-07-2010 at 17:33, last modified: 11-07-2010 at 17:45
This method has two problems:
IOException
that should better be forwarded to the user of the APIVectorGraphics2D.writeTo(OutputStream)
exists. If the user wants to obtain a byte array, he can still write to a ByteArrayOutputStream
and obtain the byte representationUsing writeTo(OutputStream)
instead of getBytes()
also makes writing to files (i. e. the common case) easier.
After rewriting VectorGraphics2D to use objects Paint objects aren't exported correctly anymore. This should be (re-)implemented.
Quite a few public and protected members, methods or classes are missing javadoc comments and should be documented before the next release.
Currently, VectorGraphics2D does not specify a default stroke and uses white as a default color.
The EPS file format specification v3.0 specifies the default graphics state in section 2.6, which is different from the current state.
Add support for a CI tool to the project.
Later implementations of PageSize might require unit calculations, so it's better to have getter methods instead of fields.
Instead of creating file-format specific objects directly, such as new SVGGraphics2D(...)
, a builder should be used.
Example:
VectorGraphics2D vg2d = new VectorGraphics2D.Builder("svg", PageSize.A4)
.compressed(true).build();
VectorGraphics2D occasionally produces EPS files with a line length of more than 255 characters.
As stated in the EPS file format specification v3.0, EPS files must not contain lines that exceed 255 ASCII characters, excluding line termination characters.
The current build fails on Mac OS X because it assumes that a Sun/Oracle JDK is in use.
The attached patch alters the build in the following ways:
so to get a compressed/obfuscated build you would need to do
$ mvn -Pproguard package
and to get the same on a Mac OS X system
$ mvn -Pmacosx,proguard package
Imported from trac ticket #13, created by ianp on 05-30-2011 at 22:28, last modified: 05-31-2011 at 17:38
Replace Maven with gradle.
There should be an option to save vector data of text based vector formats (like EPS, PDF, and SVG) to more compact versions. This will produce much smaller files.
Several levels of compression could be implemented. Lossy compression of image data (e.g. as JPEG) could save even more space.
Possible compression formats:
.eps.gz
).pdf
).svgz
)As currently font embedding does not work, it is difficult to create PDFs that work across various devices.
Therefore I suggest adding support for the base 14 fonts that are specified by PDF.
The change would be small, but the benefit large.
(By way of background, I recently found this library when I was looking for alternatives to FreeHEP. I'm impressed so far!)
I've noticed some odd (to me) behavior regarding sizes and scaling, particularly when creating EPS graphics. Both the size of the page I created and the size of my graphics weren't what I thought they should be. After browsing the code, I discovered that this is because VectorGraphics2D treats all dimensions as millimeters, while I expected it to be pixels or maybe points — basically, the native unit of the format in question.
For SVG this is only a minor annoyance that I can easily correct if I care enough. It's more of a concern for EPS and PDF though — even if I convert the size canvas I want from points to millimeters (just to have VectorGraphics2D convert it back) I'm still forced to do all my drawing in millimeters. This leads to output with unintuitive arguments to the scale command and all of the drawing commands. What could be a simple "newpath 0 0 612 792 rect Z fill" becomes "2.834645669291339 -2.834645669291339 scale" followed by "newpath 0 0 215.9 279.4 rect Z fill".
Bottom line, could there be a way to create a Graphics object with a different base unit? Or at least to skip the built-in scaling and work in the format's native units? Thanks!
Ellipses in EPS output are painted at the wrong position. This is because ellipses are specified using top-left position and size but should be defined using center and size.
Imported from trac ticket #5, created by eseifert on 11-07-2010 at 16:11, last modified: 11-07-2010 at 16:14
Support for clipping should be implemented in all format classes.
Possible implementations:
clip
instruction in EPS
W
or W*
instruction in PDF
<clipPath>
tag and corresponding references in SVG
Imported from trac ticket #1, created by eseifert on 10-22-2010 at 14:43, last modified: 10-23-2010 at 00:03
The write
method usually writes something into the object (i. e. the Document
in this case). However, this method writes the contents of the Document
into the specified OutputStream
, so writeTo
seems to be more fitting.
The handle()
method should be generic and produce data objects that can be stored in Document
instances.
An implementation for the ShockWave Flash (SWF) format should be added
see http://en.wikipedia.org/wiki/SWF for more information.
Imported from trac ticket #4, created by eseifert on 10-23-2010 at 00:16, last modified: 10-23-2010 at 00:16
Clipping paths are referenced in SVG. This can cause problems when referencing a clipping path from a transformed group of objects.
See http://trac.erichseifert.de/gral/ticket/57 for a description of the effects and a test case.
Imported from trac ticket #14, created by eseifert on 04-13-2013 at 16:16, last modified: 05-31-2013 at 16:59
Hello vectorgraphics2d developers, thanks a lot for the great tool!
Recently I've tried to use version 0.10 to produce SVG graphics in headless enviroment and faced this exception:
Caused by: java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at sun.java2d.HeadlessGraphicsEnvironment.getDefaultScreenDevice(HeadlessGraphicsEnvironment.java:77)
at de.erichseifert.vectorgraphics2d.VectorGraphics2D.<init>(SourceFile:113)
at de.erichseifert.vectorgraphics2d.ProcessingPipeline.<init>(SourceFile:43)
at de.erichseifert.vectorgraphics2d.SVGGraphics2D.<init>(SourceFile:46)
...
As far as I can see, the issue is already fixed in master, when can we expect the fix version published?
Thanks in advance,
Oleg
Use objects to make construction of file formats like SVG and PDF less error prone, more object-oriented, and more testable.
Imported from trac ticket #12, created by eseifert on 12-03-2010 at 17:27, last modified: 12-22-2013 at 17:32
VectorGraphics2D should be available on a Maven repository to make integration easier for projects using a Maven build system.
Imported from trac ticket #15, created by eseifert on 05-31-2013 at 16:45, last modified: 05-31-2013 at 16:57
Sadly, the version Apache Batik 1.8 in Maven Central is unusable. The older Batik 1.6-1 comes with its own XML parser which doesn't support the setXmlStandalone()
method. As of commit a607d3b this is handled in SVGDocument by simply catching the exception:
try {
doc.setXmlStandalone(false);
} catch (AbstractMethodError e) {
System.err.println("Your XML parser does not support standalone XML documents.");
}
We should find a better solution for this problem, e.g. to find a working version of Apache Batik 1.8+.
Just letting you know, I love your library and would love to see it on MavenCentral. :)
PDF support "appears" to be broken. No image is being rendered in a PDF reader, and I suspect (due the tiny file size) that no data is actually being written.
http://trac.erichseifert.de/vectorgraphics2d/attachment/wiki/Usage/ellipse.pdf
The above seems to be an example?
Tested with Adobe Reader 10.
Imported from trac ticket #8, created by Detritus on 11-26-2010 at 18:31, last modified: 12-01-2010 at 20:13
SVG and PDF are working perfectly. Hower for EPS, all the text is just off the image to the upper left. Any ideas what I could do to fix this?
See: knowm/XChart#105
Add a README file that includes a short project description and usage instructions.
EPS appears to be fixed to a certain document size rather than using the measurements requested.
The result is cropping or huge whitespace.
Attached is an EPS and SVG, both generated with identical settings. Only difference being class used.
Imported from trac ticket #9, created by Detritus on 11-26-2010 at 18:49, last modified: 11-30-2010 at 17:33
The task of iterating over commands should be handled by the VectorGraphics2D
implementations.
It should be possible to define the dots per inch (dpi) for EPS, PDF, and SVG files.
Imported from trac ticket #10, created by eseifert on 11-30-2010 at 16:08, last modified: 11-30-2010 at 16:08
Currently writing image data isn't supported. Writing bitmap image data should be implemented by all VectorGraphics2D implementations.
Imported from trac ticket #2, created by eseifert on 10-23-2010 at 00:12, last modified: 12-03-2010 at 17:09
I am getting the following exception when I run: comp.paint(g).
And "g" is an SVGGraphics2D. Can something be done to fix this?
ERROR [ActionAdapter-AWT-EventQueue-2] <HTML>Error executing script for event: <code><b>actionPerformed</b></code><BR>on component: <code><b>Button 1</b></code>.
Traceback (most recent call last):
File "<event:actionPerformed>", line 4, in <module>
at com.incors.plaf.m.a(Unknown Source)
at com.incors.plaf.m.b(Unknown Source)
at com.incors.plaf.c.b(Unknown Source)
at com.incors.plaf.alloy.AlloyButtonUI.update(Unknown Source)
at javax.swing.JComponent.paintComponent(Unknown Source)
at com.inductiveautomation.vision.api.client.components.model.AbstractVisionButton.paintComponent(AbstractVisionButton.java:366)
at javax.swing.JComponent.paint(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
java.lang.NullPointerException: java.lang.NullPointerException
at org.python.core.Py.JavaError(Py.java:495)
at org.python.core.Py.JavaError(Py.java:488)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)
at org.python.core.PyObject.__call__(PyObject.java:404)
at org.python.core.PyObject.__call__(PyObject.java:408)
at org.python.core.PyMethod.__call__(PyMethod.java:124)
at org.python.pycode._pyx10.f$0(<event:actionPerformed>:5)
at org.python.pycode._pyx10.call_function(<event:actionPerformed>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1275)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:624)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:168)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:265)
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:55)
at com.sun.proxy.$Proxy29.actionPerformed(Unknown Source)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at com.incors.plaf.m.a(Unknown Source)
at com.incors.plaf.m.b(Unknown Source)
at com.incors.plaf.c.b(Unknown Source)
at com.incors.plaf.alloy.AlloyButtonUI.update(Unknown Source)
at javax.swing.JComponent.paintComponent(Unknown Source)
at com.inductiveautomation.vision.api.client.components.model.AbstractVisionButton.paintComponent(AbstractVisionButton.java:366)
at javax.swing.JComponent.paint(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186)
... 50 more
Move responsibilities of the implementors (= Documents) to the respective Processors.
Happened with 0.11 version released recently.
java.lang.NullPointerException
at java.util.LinkedList$ListItr.next(LinkedList.java:893)
at de.erichseifert.vectorgraphics2d.intermediate.filters.Filter.a(SourceFile:51)
at de.erichseifert.vectorgraphics2d.intermediate.filters.Filter.hasNext(SourceFile:45)
at de.erichseifert.vectorgraphics2d.intermediate.filters.Filter.a(SourceFile:50)
at de.erichseifert.vectorgraphics2d.intermediate.filters.Filter.hasNext(SourceFile:45)
at de.erichseifert.vectorgraphics2d.intermediate.filters.GroupingFilter.hasNext(SourceFile:40)
at de.erichseifert.vectorgraphics2d.svg.SVGProcessor.process(SourceFile:36)
at de.erichseifert.vectorgraphics2d.ProcessingPipeline.writeTo(SourceFile:54)
at de.erichseifert.vectorgraphics2d.ProcessingPipeline.getBytes(SourceFile:61)
EPS documents generated by VectorGraphics2D simply end without any indication at the moment.
However, the PostScript Language Structuring Conventions Specification v3.0 suggests that a document should end with a %%EOF
comment.
VectorGrahpics2D currently does not support multi-threaded drawing. Two causes have been identified so far (see issue #42):
Hi fellow charting lib developer!
I'm the main dev of XChart, and someone requested that I implement a vector graphics export function like Gral. (BTW, nice project!)
I was able to change a lot of my underlying code to get things compatible with vectorgraphics2d and the SVG export works great. The PDF and ESP are not so great though. I've attached some screenshots. Can you perhaps guess why the rendering isn't working properly?
Thanks, Tim
Imported from trac ticket #16, created by timmolter on 04-26-2014 at 17:16, last modified: 04-26-2014 at 17:16
VectorGraphics2D
contains the member _debug_validate_graphics
which should be removed together with its references.
Hi!
Is it possible to create multipage pdfs with vectorgraphics2d?
Opening empty generated .pdf on Windows 10 with Adobe Acrobat Reader DC (15.016.20045) results in a warning "The font 'Dialog.plain' contains bad /BBox."
Repro:
// Gradle dependency: testCompile 'de.erichseifert.vectorgraphics2d:VectorGraphics2D:0.10'
@Test
public void BBoxError() throws IOException
{
PDFGraphics2D pdf = new PDFGraphics2D(0.0, 0.0, 100.0, 100.0);
System.out.println(pdf.getFont());
// Prints out: java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12]
try (FileOutputStream file = new FileOutputStream("test1.pdf"))
{
file.write(pdf.getBytes());
}
// Open test1.pdf with Adobe Acrobat Reader DC (15.016.20045) on Windows 10
// See a dialog box: "The font 'Dialog.plain' contains bad /BBox."
pdf.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 14));
System.out.println(pdf.getFont());
// Prints out: java.awt.Font[family=SansSerif,name=SansSerif,style=bold,size=14]
try (FileOutputStream file = new FileOutputStream("test2.pdf"))
{
file.write(pdf.getBytes());
}
// Open test2.pdf with Adobe Acrobat Reader DC (15.016.20045) on Windows 10
// See a dialog box: "The font 'Dialog.plain' contains bad /BBox."
// I.e. the message is the same, even though the font was changed.
// Both test1.pdf and test2.pdf in "Document Propeties -> Fonts" show:
// Dialog.plain
// Type: TrueType
// Encoding: Ansi
// Actual font: Adobe Sans MM
// Actual Font Type: Type 1
}
An implementation for Enhanced Windows Metafile format should be added
see http://en.wikipedia.org/wiki/Windows_Metafile for more information.
Imported from trac ticket #3, created by eseifert on 10-23-2010 at 00:13, last modified: 11-30-2010 at 18:00
EPS already supports CMYK colors (see #38). We should add support to PDF and SVG as well.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.