Results 1 to 8 of 8
Thread: paint in vector graphics
- 06-08-2010, 02:59 PM #1
Member
- Join Date
- Apr 2010
- Posts
- 20
- Rep Power
- 0
paint in vector graphics
Hi,
I want to make a vector graphics with Java.
I already make an GUI with some JPanel there and I have write a paint method for the Graphics using Graphics2D.
But since the Quality of the Graphics is not as expected, we want to change the paint method through vector graphics.
Since I´m still a newbie in Java, I´ve googled for this vector graphics possibilities with Java, and Batik is as far as I can find.
But as far as I concerned, with Batik I cannot draw on the JPanel, which I already have.
So.... Are there any other possibilities to draw vector graphics other than Batic?
Or have anyone use batik and can give me some example to paint with it on a JPanel?
thanks for any help.
-
But AFAIK, Batik can draw on a JSVGCanvas object which derives from JComponent, so this should be easily usable form within a Swing application.
The Batik api can be found here: Apache Batik Javadoc
- 06-09-2010, 04:05 PM #3
Member
- Join Date
- Apr 2010
- Posts
- 20
- Rep Power
- 0
So... I wanna try it, but when I read the data (since I need to read the xml-data first for the input), I got error message:
<code>
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/batik/svggen/SVGGraphics2D
<code>
But when I´m not using any batik api, the program run smoothly.
Does anyone know, what that error message mean? And how to fix it?
Thank you in advance.
-
Do you have the Batik jar file(s) in your class path, or if you're using an IDE, are they in the project's compile path?
- 06-09-2010, 09:05 PM #5
Member
- Join Date
- Apr 2010
- Posts
- 20
- Rep Power
- 0
yo... I´ve already downloaded the Batik jar files and compile it in the project library
- 06-11-2010, 07:40 AM #6
Member
- Join Date
- Apr 2010
- Posts
- 20
- Rep Power
- 0
I post the error code, which I get when I run the program.
The program running smoothly without BATIK. But when I insert BATIK for SVG Graphics, I got the error code like these.Java Code:Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/batik/svggen/SVGGraphics2D at EvaluateDataModel.<init>(EvaluateDataModel.java:27) at DataModel.createEvaluateDataModel(DataModel.java:52) at Controller$LoadXMLFileListener.actionPerformed(Controller.java:151) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) at javax.swing.plaf.basic.BasicButtonListener$Actions.actionPerformed(BasicButtonListener.java:287) at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1636) at javax.swing.JComponent.processKeyBinding(JComponent.java:2849) at javax.swing.JComponent.processKeyBindings(JComponent.java:2884) at javax.swing.JComponent.processKeyEvent(JComponent.java:2812) at java.awt.Component.processEvent(Component.java:5993) at java.awt.Container.processEvent(Container.java:2041) at java.awt.Component.dispatchEventImpl(Component.java:4583) at java.awt.Container.dispatchEventImpl(Container.java:2099) at java.awt.Component.dispatchEvent(Component.java:4413) at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1848) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:704) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:969) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:841) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:668) at java.awt.Component.dispatchEventImpl(Component.java:4455) at java.awt.Container.dispatchEventImpl(Container.java:2099) at java.awt.Window.dispatchEventImpl(Window.java:2475) at java.awt.Component.dispatchEvent(Component.java:4413) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) Caused by: java.lang.ClassNotFoundException: org.apache.batik.svggen.SVGGraphics2D at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) ... 33 more
What I cannot understand, I got the error when it still on the step of reading the XML-Data (since I need to read the Datas for the Graphics) and it hasn´t ever gone to class and method for the drawing graphics.
I try to re-download the BATIK and reinstall and recompile the BATIK files jar to the project, but it still got the same error.
Has anyone any idea?
Thank you very much.
- 06-15-2010, 10:52 AM #7
Member
- Join Date
- Apr 2010
- Posts
- 20
- Rep Power
- 0
well... the problem before is solved... but now I have another problem.
so.. the code I write on JSVGCanvas is:
but when I compile it, I got the error code like this:Java Code:DOMImplementation impl = SVGDOMImplementation.getDOMImplementation(); String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; Document doc = impl.createDocument(svgNS, "svg", null); SVGGraphics2D svgGraphics = new SVGGraphics2D(doc); EvaluateDrawing drawing = new EvaluateDrawing(dataModel.getGDSDataModel()); Element root = doc.getDocumentElement(); svgGraphics.getRoot(root); canvas1.setSVGDocument(doc);
Can anyone help me, what should I do?PHP Code:setSVGDocument(org.w3c.dom.svg.SVGDocument) in org.apache.batik.swing.svg.AbstractJSVGComponent cannot be applied to (org.w3c.dom.Document) canvas1.setSVGDocument(doc);
Thank you very much
- 06-16-2010, 08:30 AM #8
Member
- Join Date
- Apr 2010
- Posts
- 20
- Rep Power
- 0
Hallo,
since I still don´t know the answer of the problem before, I try to make it another way to paint in vector graphics.
I can now make the vector graphics in svg and I save the svg file first.
After that, I read the file again on my JSVGCanvas (canvas1), which is on the panel, to show the graphic.
Since I use Netbeans for the IDE, I must override the paint-methode to show the graphic.
Here is the code.
But when I compile the program, I get an endlose run of this paint method, so that the graphic won´t be displayed.Java Code:panel = new JPanel (){ public void paint(Graphics g) { super.paint(g); panel.setOpaque(true); panel.add(canvas1); canvas1.setURI(new File("ProfilRight.svg").toURI().toString()); canvas1.repaint(); } }
Can anyone help me, how I can correct the code?
Thank you very much in advance for any help...
Similar Threads
-
Two JPanels and paint(Graphics)
By ingfy in forum New To JavaReplies: 3Last Post: 04-27-2010, 08:51 PM -
Vector<vector> loop thru
By ocean in forum New To JavaReplies: 11Last Post: 11-21-2009, 02:17 PM -
Some confusions with paint()
By kendaop in forum Java AppletsReplies: 1Last Post: 01-24-2009, 12:23 AM -
finished paint!
By diggitydoggz in forum New To JavaReplies: 3Last Post: 01-04-2009, 10:33 AM -
print variable with paint(Graphics g) ??
By tghn2b in forum New To JavaReplies: 10Last Post: 12-29-2008, 12:11 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks