xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas DeWeese <Thomas.DeWe...@Kodak.com>
Subject Re: Painting SVG directly on a Graphics2D
Date Fri, 23 Jul 2004 10:19:54 GMT
Hi Stephan,

    The problem here is that the UpdateManager thread has to
be locked while you are rendering the document.  Otherwise
it tries to update the GVT tree 'out from under you'.

    This is really quite tricky because depending on the code
running in the UpdateManager thread it may need access to the
Swing thread (to query the JSVGCanvas for example).  This means
that it is not a good idea to try and wait for a runnable to
complete from the swing thread (as this may cause a deadlock).

    The best thing you could do is probably use
component.getGraphics from the update manager...

sm853234@mail.inf.tu-dresden.de wrote:

> Hello,
> 
> I want to paint a SVG directly on a Graphics2D (including dynamic SVG),
> without creating first a BufferedImage. Therefore I do not want to use the
> DynamicRenderer. I tried it this way:
> 
> // adapt UpdateManager
> class UpManager extends UpdateManager
> {
> 	public UpManager(BridgeContext b, GraphicsNode g, Document d) {
> 		super(b, g, d);
> 	}
> 	protected void updateRendering(List l)
> 	{}
> 
> 	protected void repaint() {
> 	        centerPanel.repaint();
> 	}
> }
> 
> class Panel extends JPanel
> {
> 	protected void paintComponent(Graphics g) {
> 		super.paintComponent(g);
> 		Graphics2D g2d = (Graphics2D) g;
> 		if (gvtRoot != null) {
> 			gvtRoot.paint(g2d);
> 		}
> 	}
> 	GraphicsNode gvtRoot;
> }
> 
> But there seems to be a threading problem doing it this way, because
> sometimes I get an NullPointerException. So are there any restrictions for
> using the
> GraphicsNode.paint()-method concerning threads?
> 
> at java.awt.geom.RectangularShape.intersects(Unknown Source)
> 	at org.apache.batik.gvt.AbstractGraphicsNode.getBounds(Unknown Source) at
> org.apache.batik.gvt.AbstractGraphicsNode.paint(Unknown Source) at
> org.apache.batik.gvt.CompositeGraphicsNode.primitivePaint(Unknown
> Source)
> 	at org.apache.batik.gvt.AbstractGraphicsNode.paint(Unknown Source) at
> gui.TestAbleitung$Panel.paintComponent(TestAbleitung.java:312) at
> javax.swing.JComponent.paint(Unknown Source)
> 	at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown Source) at
> javax.swing.JComponent.paintDoubleBuffered(Unknown Source)
> 	at javax.swing.JComponent._paintImmediately(Unknown Source)
> 	at javax.swing.JComponent.paintImmediately(Unknown Source)
> 	at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
> 	at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown
> Source)
> 	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
> 	at java.awt.EventQueue.dispatchEvent(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(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)
> 
> Thanks for any help!
> 
> Stephan
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message