List of usage examples for java.awt.geom AffineTransform getRotateInstance
public static AffineTransform getRotateInstance(double vecx, double vecy)
From source file:Main.java
public void paint(Graphics g) { Shape shape = new Rectangle2D.Float(100, 50, 80, 80); Graphics2D g2 = (Graphics2D) g; AffineTransform at = AffineTransform.getRotateInstance(-Math.PI / 6, -Math.PI / 6); g2.setTransform(at);//from w w w . j ava 2 s . c o m g2.draw(shape); }
From source file:org.rhwlab.dispim.nucleus.NucleusData.java
public Shape getShape(long slice, int dim, int bufW, int bufH) { //System.out.printf("Ellipsoid center = (%d,%d,%d)\n",this.xC,this.yC,this.zC); Ellipse2d e;//ww w .j a va 2s .com switch (dim) { case 0: e = xPlaneEllipse((double) slice); break; case 1: e = yPlaneEllipse((double) slice); break; default: e = zPlaneEllipse((double) slice); break; } if (e != null) { //System.out.printf("%s dim=%d slice=%d\n",this.getName(),dim,slice); AffineTransform toOrigin = AffineTransform.getTranslateInstance(-e.x, -e.y); AffineTransform back = AffineTransform.getTranslateInstance(e.x, e.y); AffineTransform xform = AffineTransform.getRotateInstance(e.cosine, e.sine); int scrX = SingleSlicePanel.screenX(e.low, dim, bufW); int scrY = SingleSlicePanel.screenY(e.low, dim, bufH); int scrHighX = SingleSlicePanel.screenX(e.high, dim, bufW); int scrHighY = SingleSlicePanel.screenY(e.high, dim, bufH); Shape shape = new Ellipse2D.Double(scrX, scrY, scrHighX - scrX, scrHighY - scrY); shape = toOrigin.createTransformedShape(shape); shape = xform.createTransformedShape(shape); shape = back.createTransformedShape(shape); //System.out.printf("e.a:%f e.b:%f e.x:%f e.y:%f\n",e.a,e.b,e.x,e.y); return shape; } return null; }