java.awt.geom.AffineTransform.rotate()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(233)

本文整理了Java中java.awt.geom.AffineTransform.rotate()方法的一些代码示例,展示了AffineTransform.rotate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AffineTransform.rotate()方法的具体详情如下:
包路径:java.awt.geom.AffineTransform
类名称:AffineTransform
方法名:rotate

AffineTransform.rotate介绍

暂无

代码示例

代码示例来源:origin: libgdx/libgdx

  1. splitImage = new BufferedImage(region.width, region.height, page.getType());
  2. AffineTransform transform = new AffineTransform();
  3. transform.rotate(Math.toRadians(90.0));
  4. transform.translate(0, -region.width);
  5. AffineTransformOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
  6. op.filter(srcImage, splitImage);

代码示例来源:origin: stackoverflow.com

  1. AffineTransform transform = new AffineTransform();
  2. transform.rotate(radians, bufferedImage.getWidth()/2, bufferedImage.getHeight()/2);
  3. AffineTransformOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
  4. bufferedImage = op.filter(bufferedImage, null);

代码示例来源:origin: plantuml/plantuml

  1. private ImageData writeImageMjpeg(OutputStream os, StringBounder stringBounder) throws IOException {
  2. final LimitFinder limitFinder = new LimitFinder(stringBounder, true);
  3. udrawable.drawU(limitFinder);
  4. final Dimension2D dim = new Dimension2DDouble(limitFinder.getMaxX() + 1 + margin1 + margin2,
  5. limitFinder.getMaxY() + 1 + margin1 + margin2);
  6. final File f = new File("c:/tmp.avi");
  7. final int nbframe = 100;
  8. final MJPEGGenerator m = new MJPEGGenerator(f, getAviImage(null).getWidth(null), getAviImage(null).getHeight(
  9. null), 12.0, nbframe);
  10. for (int i = 0; i < nbframe; i++) {
  11. // AffineTransform at = AffineTransform.getRotateInstance(1.0);
  12. AffineTransform at = AffineTransform.getTranslateInstance(dim.getWidth() / 2, dim.getHeight() / 2);
  13. at.rotate(90.0 * Math.PI / 180.0 * i / 100);
  14. at.translate(-dim.getWidth() / 2, -dim.getHeight() / 2);
  15. // final AffineTransform at = AffineTransform.getTranslateInstance(i, 0);
  16. // final ImageIcon ii = new ImageIcon(getAviImage(at));
  17. // m.addImage(ii.getImage());
  18. throw new UnsupportedOperationException();
  19. }
  20. m.finishAVI();
  21. FileUtils.copyToStream(f, os);
  22. return new ImageDataSimple(dim);
  23. }

代码示例来源:origin: libgdx/libgdx

  1. splitImage = new BufferedImage(region.width, region.height, page.getType());
  2. AffineTransform transform = new AffineTransform();
  3. transform.rotate(Math.toRadians(90.0));
  4. transform.translate(0, -region.width);
  5. AffineTransformOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
  6. op.filter(srcImage, splitImage);

代码示例来源:origin: runelite/runelite

  1. /**
  2. * Rotates an image around its center by a given number of radians.
  3. *
  4. * @param image The image to be rotated.
  5. * @param theta The number of radians to rotate the image.
  6. * @return The given image, rotated by the given theta.
  7. */
  8. public static BufferedImage rotateImage(final BufferedImage image, final double theta)
  9. {
  10. AffineTransform transform = new AffineTransform();
  11. transform.rotate(theta, image.getWidth() / 2.0, image.getHeight() / 2.0);
  12. AffineTransformOp transformOp = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
  13. return transformOp.filter(image, null);
  14. }

代码示例来源:origin: opentripplanner/OpenTripPlanner

  1. currentChar + 1).getAdvance() * 0.5f : 0;
  2. t.setToTranslation(x, y);
  3. t.rotate(angle);
  4. t.translate(-px - advance, -py + height * factor / 2.0f);
  5. result.append(t.createTransformedShape(glyph), false);
  6. next += (advance + nextAdvance) * factor;

代码示例来源:origin: stackoverflow.com

  1. case 2: // Flip X
  2. t.scale(-1.0, 1.0);
  3. t.translate(-info.width, 0);
  4. break;
  5. case 3: // PI rotation
  6. t.translate(info.width, info.height);
  7. t.rotate(Math.PI);
  8. break;
  9. case 4: // Flip Y
  10. t.scale(1.0, -1.0);
  11. t.translate(0, -info.height);
  12. break;
  13. case 5: // - PI/2 and Flip X
  14. t.rotate(-Math.PI / 2);
  15. t.scale(-1.0, 1.0);
  16. break;
  17. case 6: // -PI/2 and -width
  18. t.translate(info.height, 0);
  19. t.rotate(Math.PI / 2);
  20. break;
  21. case 7: // PI/2 and Flip
  22. t.translate(-info.height, 0);
  23. t.translate(0, info.width);
  24. t.rotate( 3 * Math.PI / 2);
  25. break;
  26. case 8: // PI / 2
  27. t.translate(0, info.width);
  28. t.rotate( 3 * Math.PI / 2);

代码示例来源:origin: graphhopper/graphhopper

  1. public void plotDirectedEdge(Graphics2D g2, double lat, double lon, double lat2, double lon2, float width) {
  2. g2.setStroke(new BasicStroke(width));
  3. int startLon = (int) getX(lon);
  4. int startLat = (int) getY(lat);
  5. int destLon = (int) getX(lon2);
  6. int destLat = (int) getY(lat2);
  7. g2.drawLine(startLon, startLat, destLon, destLat);
  8. // only for deep zoom show direction
  9. if (scaleX < 0.0001) {
  10. g2.setStroke(new BasicStroke(3));
  11. Path2D.Float path = new Path2D.Float();
  12. path.moveTo(destLon, destLat);
  13. path.lineTo(destLon + 6, destLat - 2);
  14. path.lineTo(destLon + 6, destLat + 2);
  15. path.lineTo(destLon, destLat);
  16. AffineTransform at = new AffineTransform();
  17. double angle = Math.atan2(lat2 - lat, lon2 - lon);
  18. at.rotate(-angle + Math.PI, destLon, destLat);
  19. path.transform(at);
  20. g2.draw(path);
  21. }
  22. }

代码示例来源:origin: geotools/geotools

  1. LabelPainter painter) {
  2. tempTransform.translate(centroid.getX(), centroid.getY());
  3. tempTransform.rotate(rotation);
  4. - textBounds.getHeight()
  5. + painter.getLineHeight();
  6. tempTransform.translate(displacementX, displacementY);

代码示例来源:origin: pentaho/pentaho-kettle

  1. @Override
  2. protected void render( Graphics2D gc, int centerX, int centerY, int width, int height, double angleRadians ) {
  3. AffineTransform oldTransform = gc.getTransform();
  4. try {
  5. double scaleX = width * 1.0 / bitmap.getWidth();
  6. double scaleY = height * 1.0 / bitmap.getHeight();
  7. AffineTransform affineTransform = new AffineTransform( oldTransform );
  8. if ( centerX != 0 || centerY != 0 ) {
  9. affineTransform.translate( centerX, centerY );
  10. }
  11. affineTransform.scale( scaleX, scaleY );
  12. if ( angleRadians != 0 ) {
  13. affineTransform.rotate( angleRadians );
  14. }
  15. affineTransform.translate( -bitmap.getWidth() / 2, -bitmap.getHeight() / 2 );
  16. gc.setTransform( affineTransform );
  17. gc.drawImage( bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), null );
  18. } finally {
  19. gc.setTransform( oldTransform );
  20. }
  21. }
  22. }

代码示例来源:origin: plantuml/plantuml

  1. _graphics.setTransform(new AffineTransform());
  2. AffineTransform fontTransform = new AffineTransform();
  3. fontTransform.scale(fs, fs);
  4. fontTransform.rotate(-ta.getOrientationAngle() * Math.PI / 180);
  5. font = font.deriveFont(fontTransform);
  6. _graphics.setFont(font);
  7. Rectangle2D bounds = _graphics.getFontMetrics().getStringBounds(str, _graphics);
  8. fontTransform.rotate(-ta.getOrientationAngle() * Math.PI / 180);

代码示例来源:origin: dermotte/LIRE

  1. affine.rotate(-angle, xo2, yo2);
  2. affine.translate(-dx, -dy);

代码示例来源:origin: stackoverflow.com

  1. // create an AffineTransform
  2. // and a triangle centered on (0,0) and pointing downward
  3. // somewhere outside Swing's paint loop
  4. AffineTransform tx = new AffineTransform();
  5. Line2D.Double line = new Line2D.Double(0,0,100,100);
  6. Polygon arrowHead = new Polygon();
  7. arrowHead.addPoint( 0,5);
  8. arrowHead.addPoint( -5, -5);
  9. arrowHead.addPoint( 5,-5);
  10. // [...]
  11. private void drawArrowHead(Graphics2D g2d) {
  12. tx.setToIdentity();
  13. double angle = Math.atan2(line.y2-line.y1, line.x2-line.x1);
  14. tx.translate(line.x2, line.y2);
  15. tx.rotate((angle-Math.PI/2d));
  16. Graphics2D g = (Graphics2D) g2d.create();
  17. g.setTransform(tx);
  18. g.fill(arrowHead);
  19. g.dispose();
  20. }

代码示例来源:origin: org.apache.poi/poi-ooxml

  1. public Path2D.Double getPath() {
  2. if (getDel())
  3. return null;
  4. // intentionally shadowing variables here
  5. double cx = getX(); // center
  6. double cy = getY();
  7. double a = getA(); // left
  8. double b = getB();
  9. double c = getC(); // top
  10. double d = getD();
  11. // compute radius
  12. double rx = Math.hypot(a - cx, b - cy);
  13. double ry = Math.hypot(c - cx, d - cy);
  14. // compute angle of ellipse
  15. double angle = (2.0 * Math.PI + (cy > b ? 1.0 : -1.0)
  16. * Math.acos((cx - a) / rx))
  17. % (2.0 * Math.PI);
  18. // create ellipse
  19. Ellipse2D.Double ellipse = new Ellipse2D.Double(cx - rx, cy - ry,
  20. rx * 2, ry * 2);
  21. // create a path, rotate it about its center
  22. Path2D.Double path = new Path2D.Double(ellipse);
  23. AffineTransform tr = new AffineTransform();
  24. tr.rotate(angle, cx, cy);
  25. path.transform(tr);
  26. return path;
  27. }

代码示例来源:origin: dermotte/LIRE

  1. affine.rotate(-angle, xo2, yo2);
  2. affine.translate(-dx, -dy);

代码示例来源:origin: Activiti/Activiti

  1. public void drawDefaultSequenceFlowIndicator(Line2D.Double line) {
  2. double length = DEFAULT_INDICATOR_WIDTH;
  3. double halfOfLength = length / 2;
  4. double f = 8;
  5. Line2D.Double defaultIndicator = new Line2D.Double(-halfOfLength,
  6. 0,
  7. halfOfLength,
  8. 0);
  9. double angle = Math.atan2(line.y2 - line.y1,
  10. line.x2 - line.x1);
  11. double dx = f * Math.cos(angle);
  12. double dy = f * Math.sin(angle);
  13. double x1 = line.x1 + dx;
  14. double y1 = line.y1 + dy;
  15. AffineTransform transformation = new AffineTransform();
  16. transformation.setToIdentity();
  17. transformation.translate(x1,
  18. y1);
  19. transformation.rotate((angle - 3 * Math.PI / 4));
  20. AffineTransform originalTransformation = g.getTransform();
  21. g.setTransform(transformation);
  22. g.draw(defaultIndicator);
  23. g.setTransform(originalTransformation);
  24. }

代码示例来源:origin: Activiti/Activiti

  1. AffineTransform transformation = new AffineTransform();
  2. transformation.setToIdentity();
  3. transformation.rotate(270 * Math.PI / 180);

代码示例来源:origin: geotools/geotools

  1. public void testOGCScaleAffineProjected() throws Exception {
  2. // 1 pixel == 500 m => 0.00028 m [ screen] == 500 m [world]
  3. // => scaleDenominator = 500/0.00028
  4. final AffineTransform screenToWord = AffineTransform.getScaleInstance(500, 500);
  5. final AffineTransform worldToScreen = screenToWord.createInverse();
  6. final CoordinateReferenceSystem crs = DefaultEngineeringCRS.CARTESIAN_2D;
  7. double scale;
  8. scale = RendererUtilities.calculateOGCScaleAffine(crs, worldToScreen, new HashMap());
  9. assertEquals(500 / 0.00028, scale, 0.0001);
  10. worldToScreen.rotate(1.0);
  11. scale = RendererUtilities.calculateOGCScaleAffine(crs, worldToScreen, new HashMap());
  12. assertEquals(500 / 0.00028, scale, 0.0001);
  13. worldToScreen.translate(100.0, 100.0);
  14. scale = RendererUtilities.calculateOGCScaleAffine(crs, worldToScreen, new HashMap());
  15. assertEquals(500 / 0.00028, scale, 0.0001);
  16. }

代码示例来源:origin: nutzam/nutz

  1. Graphics2D gs = rotatedImage.createGraphics();
  2. gs.fillRect(0, 0, w, h);// 以给定颜色绘制旋转后图片的背景
  3. AffineTransform at = new AffineTransform();
  4. at.rotate(ang, w / 2, h / 2);// 旋转图象
  5. at.translate(x, y);
  6. AffineTransformOp op = new AffineTransformOp(at, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
  7. op.filter(image, rotatedImage);

代码示例来源:origin: stackoverflow.com

  1. AffineTransform transform = new AffineTransform();
  2. transform.rotate(Math.toRadians(45), rectangle.getX() + rectangle.width/2, rectangle.getY() + rectangle.height/2);
  3. g2.fill(transformed);

相关文章