List of utility methods to do Graphics Rotate
void | rotateArea(Area a, double rotation, Point2D rotateAround) rotate Area AffineTransform at1 = AffineTransform.getTranslateInstance(rotateAround.getX(), rotateAround.getY()); at1.rotate(rotation); at1.translate(-rotateAround.getX(), -rotateAround.getY()); a.transform(at1); |
void | rotateBy(Vector rotate By Point2D c = centroid(points); Point2D ptSrc, ptDest; for (int i = 0; i < points.size(); i++) { ptSrc = points.get(i); if (newPoints.size() > i) { ptDest = newPoints.get(i); } else { ptDest = new Point2D.Double(); ... |
Point2D | rotateByAngle(final Point2D pos, final Point2D center, final double angle) Rotates a point a given angle around the center. final AffineTransform at = AffineTransform.getRotateInstance(angle, center.getX(), center.getY()); return at.transform(pos, null); |
void | rotateClockwise(Path source, Path target) rotate Clockwise BufferedImage srcImage = ImageIO.read(source.toFile()); int width = srcImage.getWidth(); int height = srcImage.getHeight(); BufferedImage targetImage = new BufferedImage(height, width, srcImage.getType()); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { targetImage.setRGB(y, (width - x - 1), srcImage.getRGB(x, y)); ImageIO.write(targetImage, "jpeg", target.toFile()); |
Point2D.Float | rotateCoor(float x, float y, float theta) rotates a point theta radians, returns a new point rotation is counterclockwise for positive theta in Cartesian system, clockwise in screen display coordinate system double sintheta = Math.sin(theta); double costheta = Math.cos(theta); return new Point2D.Float((float) (x * costheta - y * sintheta), (float) (x * sintheta + y * costheta)); |
Point2D.Float | rotateCoorAroundPoint(float x, float y, float xctr, float yctr, float theta) rotates a point theta radians around a point (xctr, yctr), returns a new point rotation is counterclockwise for positive theta in Cartesian system, clockwise in screen display coordinate system double sintheta = Math.sin(theta); double costheta = Math.cos(theta); Point2D.Float pt = translateCoor(x, y, -xctr, -yctr); pt.setLocation((pt.x * costheta - pt.y * sintheta), (pt.x * sintheta + pt.y * costheta)); return translateCoor(pt, xctr, yctr); |
Color | rotateHue(Color color, float fraction) rotate Hue float af[] = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null); float hue = af[0]; float saturation = af[1]; float brightness = af[2]; float hueNew = hue + fraction; if (hueNew > 1) { hueNew = hueNew - 1; return Color.getHSBColor(hueNew, saturation, brightness); |
Color | rotateHue(Color color, float fraction) Rotate a color through HSB space float af[] = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null); float hue = af[0]; float saturation = af[1]; float brightness = af[2]; float hueNew = hue + fraction; Color hsb = Color.getHSBColor(hueNew, saturation, brightness); return new Color(hsb.getRed(), hsb.getGreen(), hsb.getBlue(), color.getAlpha()); |
Point | rotateMoveClockwise(Point move, int size) rotate Move Clockwise return new Point(size - 1 - move.y, move.x); |
Point2D.Double | rotatePoint(double x0, double y0, double x, double y, double a) Turn of a point round other point counter-clockwise Point2D.Double p = new Point2D.Double(); double sina = Math.sin(a); double cosa = Math.cos(a); p.x = x0 + (x - x0) * cosa + (y0 - y) * sina; p.y = y0 + (x - x0) * sina + (y - y0) * cosa; return p; |