xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Avery <da...@frontgatetickets.com>
Subject rotate element?
Date Wed, 08 Feb 2006 18:50:54 GMT

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


Mime
View raw message