You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by David Avery <da...@frontgatetickets.com> on 2006/02/08 19:50:54 UTC

rotate element?

Does anyone have an example of how to rotate an element?

I'm experimenting with the following code and getting a NPE at 
Rectangle2D centerBounds = bridgeContext.getGraphicsNode(c).getBounds();

      public static final void rotate(Element e, double angle, Element 
center){
          if (e == null) return;
       
         
          GVTBuilder gvt = new GVTBuilder();
        
          UserAgentAdapter userAgentAdapter = new UserAgentAdapter();
 
          BridgeContext bridgeContext = new BridgeContext(userAgentAdapter);
     

         GraphicsNode graphicsNode = bridgeContext.getGraphicsNode(e);
     
         
          Element c;
          if (center == null) {
              System.out.println("rotate using el center ");
              c = e;
          } else {
              c = center;
          }
 
        // NPE right here      
          Rectangle2D centerBounds = 
bridgeContext.getGraphicsNode(c).getBounds();
         
         
          if (centerBounds == null)
              return;
          AffineTransform t = graphicsNode.getTransform();
          if (t==null)
              t=new AffineTransform();
          t.rotate(angle, centerBounds.getCenterX(), 
centerBounds.getCenterY());
         
          graphicsNode.setTransform(t);
         
       
      }




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


Re: rotate element?

Posted by Tonny Kohar <to...@kiyut.com>.
Hi,

On Wed, 2006-02-08 at 12:50 -0600, David Avery wrote:
> Does anyone have an example of how to rotate an element?
> 
> I'm experimenting with the following code and getting a NPE at 
> Rectangle2D centerBounds = bridgeContext.getGraphicsNode(c).getBounds();

Have you load the css stuff as well or you only load the DOM.

Because bridgeContext will only work if you load the whole stuff.

Regards
Tonny Kohar
-- 
Sketsa 
SVG Graphics Editor
http://www.kiyut.com


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