Java Code Examples for java.awt.geom.AffineTransform#getQuadrantRotateInstance()

The following examples show how to use java.awt.geom.AffineTransform#getQuadrantRotateInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
private void paintDivider(Graphics2D g2) {
  g2.setStroke(new BasicStroke(5f));
  g2.setPaint(Color.WHITE);
  g2.draw(thumb);

  double cx = thumb.getCenterX();
  double cy = thumb.getCenterY();

  Line2D line = new Line2D.Double(cx, 0d, cx, thumb.getMinY());
  g2.draw(line);

  double v = 8d;
  double mx = cx - thumb.getWidth() / 4d + v / 2d;
  Path2D triangle = new Path2D.Double();
  triangle.moveTo(mx, cy - v);
  triangle.lineTo(mx - v, cy);
  triangle.lineTo(mx, cy + v);
  triangle.lineTo(mx, cy - v);
  triangle.closePath();
  g2.fill(triangle);

  AffineTransform at = AffineTransform.getQuadrantRotateInstance(2, cx, cy);
  g2.draw(at.createTransformedShape(line));
  g2.fill(at.createTransformedShape(triangle));
}
 
Example 2
Source File: TestRotateMethods.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static AffineTransform makeQuadAT(Mode mode, Point2D txpt,
                                         int quads)
{
    AffineTransform at;
    double tx = (txpt == null) ? 0.0 : txpt.getX();
    double ty = (txpt == null) ? 0.0 : txpt.getY();
    switch (mode) {
    case GET:
        if (txpt != null) {
            at = AffineTransform.getQuadrantRotateInstance(quads, tx, ty);
        } else {
            at = AffineTransform.getQuadrantRotateInstance(quads);
        }
        break;
    case SET:
        at = makeRandomAT();
        if (txpt != null) {
            at.setToQuadrantRotation(quads, tx, ty);
        } else {
            at.setToQuadrantRotation(quads);
        }
        break;
    case MOD:
        at = makeRandomAT();
        at.setToIdentity();
        if (txpt != null) {
            at.quadrantRotate(quads, tx, ty);
        } else {
            at.quadrantRotate(quads);
        }
        break;
    default:
        throw new InternalError("unrecognized mode: "+mode);
    }

    return at;
}