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

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

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

AffineTransform.rotate介绍

暂无

代码示例

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

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

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

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

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

private ImageData writeImageMjpeg(OutputStream os, StringBounder stringBounder) throws IOException {
  final LimitFinder limitFinder = new LimitFinder(stringBounder, true);
  udrawable.drawU(limitFinder);
  final Dimension2D dim = new Dimension2DDouble(limitFinder.getMaxX() + 1 + margin1 + margin2,
      limitFinder.getMaxY() + 1 + margin1 + margin2);
  final File f = new File("c:/tmp.avi");
  final int nbframe = 100;
  final MJPEGGenerator m = new MJPEGGenerator(f, getAviImage(null).getWidth(null), getAviImage(null).getHeight(
      null), 12.0, nbframe);
  for (int i = 0; i < nbframe; i++) {
    // AffineTransform at = AffineTransform.getRotateInstance(1.0);
    AffineTransform at = AffineTransform.getTranslateInstance(dim.getWidth() / 2, dim.getHeight() / 2);
    at.rotate(90.0 * Math.PI / 180.0 * i / 100);
    at.translate(-dim.getWidth() / 2, -dim.getHeight() / 2);
    // final AffineTransform at = AffineTransform.getTranslateInstance(i, 0);
    // final ImageIcon ii = new ImageIcon(getAviImage(at));
    // m.addImage(ii.getImage());
    throw new UnsupportedOperationException();
  }
  m.finishAVI();
  FileUtils.copyToStream(f, os);
  return new ImageDataSimple(dim);
}

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

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

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

/**
 * Rotates an image around its center by a given number of radians.
 *
 * @param image The image to be rotated.
 * @param theta The number of radians to rotate the image.
 * @return      The given image, rotated by the given theta.
 */
public static BufferedImage rotateImage(final BufferedImage image, final double theta)
{
  AffineTransform transform = new AffineTransform();
  transform.rotate(theta, image.getWidth() / 2.0, image.getHeight() / 2.0);
  AffineTransformOp transformOp = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
  return transformOp.filter(image, null);
}

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

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

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

case 2: // Flip X
  t.scale(-1.0, 1.0);
  t.translate(-info.width, 0);
  break;
case 3: // PI rotation 
  t.translate(info.width, info.height);
  t.rotate(Math.PI);
  break;
case 4: // Flip Y
  t.scale(1.0, -1.0);
  t.translate(0, -info.height);
  break;
case 5: // - PI/2 and Flip X
  t.rotate(-Math.PI / 2);
  t.scale(-1.0, 1.0);
  break;
case 6: // -PI/2 and -width
  t.translate(info.height, 0);
  t.rotate(Math.PI / 2);
  break;
case 7: // PI/2 and Flip
  t.translate(-info.height, 0);
  t.translate(0, info.width);
  t.rotate(  3 * Math.PI / 2);
  break;
case 8: // PI / 2
  t.translate(0, info.width);
  t.rotate(  3 * Math.PI / 2);

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

public void plotDirectedEdge(Graphics2D g2, double lat, double lon, double lat2, double lon2, float width) {
  g2.setStroke(new BasicStroke(width));
  int startLon = (int) getX(lon);
  int startLat = (int) getY(lat);
  int destLon = (int) getX(lon2);
  int destLat = (int) getY(lat2);
  g2.drawLine(startLon, startLat, destLon, destLat);
  // only for deep zoom show direction
  if (scaleX < 0.0001) {
    g2.setStroke(new BasicStroke(3));
    Path2D.Float path = new Path2D.Float();
    path.moveTo(destLon, destLat);
    path.lineTo(destLon + 6, destLat - 2);
    path.lineTo(destLon + 6, destLat + 2);
    path.lineTo(destLon, destLat);
    AffineTransform at = new AffineTransform();
    double angle = Math.atan2(lat2 - lat, lon2 - lon);
    at.rotate(-angle + Math.PI, destLon, destLat);
    path.transform(at);
    g2.draw(path);
  }
}

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

LabelPainter painter) {
tempTransform.translate(centroid.getX(), centroid.getY());
tempTransform.rotate(rotation);
        - textBounds.getHeight()
        + painter.getLineHeight();
tempTransform.translate(displacementX, displacementY);

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

@Override
 protected void render( Graphics2D gc, int centerX, int centerY, int width, int height, double angleRadians ) {
  AffineTransform oldTransform = gc.getTransform();
  try {
   double scaleX = width * 1.0 / bitmap.getWidth();
   double scaleY = height * 1.0 / bitmap.getHeight();

   AffineTransform affineTransform = new AffineTransform( oldTransform );
   if ( centerX != 0 || centerY != 0 ) {
    affineTransform.translate( centerX, centerY );
   }
   affineTransform.scale( scaleX, scaleY );
   if ( angleRadians != 0 ) {
    affineTransform.rotate( angleRadians );
   }
   affineTransform.translate( -bitmap.getWidth() / 2, -bitmap.getHeight() / 2 );

   gc.setTransform( affineTransform );

   gc.drawImage( bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), null );
  } finally {
   gc.setTransform( oldTransform );
  }
 }
}

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

_graphics.setTransform(new AffineTransform());
AffineTransform fontTransform = new AffineTransform();
fontTransform.scale(fs, fs);
fontTransform.rotate(-ta.getOrientationAngle() * Math.PI / 180);
font = font.deriveFont(fontTransform);
_graphics.setFont(font);
Rectangle2D bounds = _graphics.getFontMetrics().getStringBounds(str, _graphics);
fontTransform.rotate(-ta.getOrientationAngle() * Math.PI / 180);

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

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

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

// create an AffineTransform 
// and a triangle centered on (0,0) and pointing downward
// somewhere outside Swing's paint loop
AffineTransform tx = new AffineTransform();
Line2D.Double line = new Line2D.Double(0,0,100,100);

Polygon arrowHead = new Polygon();  
arrowHead.addPoint( 0,5);
arrowHead.addPoint( -5, -5);
arrowHead.addPoint( 5,-5);

// [...]
private void drawArrowHead(Graphics2D g2d) {  
  tx.setToIdentity();
  double angle = Math.atan2(line.y2-line.y1, line.x2-line.x1);
  tx.translate(line.x2, line.y2);
  tx.rotate((angle-Math.PI/2d));  

  Graphics2D g = (Graphics2D) g2d.create();
  g.setTransform(tx);   
  g.fill(arrowHead);
  g.dispose();
}

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

public Path2D.Double getPath() {
  if (getDel())
    return null;
  // intentionally shadowing variables here
  double cx = getX(); // center
  double cy = getY();
  double a = getA(); // left
  double b = getB();
  double c = getC(); // top
  double d = getD();
  // compute radius
  double rx = Math.hypot(a - cx, b - cy);
  double ry = Math.hypot(c - cx, d - cy);
  // compute angle of ellipse
  double angle = (2.0 * Math.PI + (cy > b ? 1.0 : -1.0)
      * Math.acos((cx - a) / rx))
      % (2.0 * Math.PI);
  // create ellipse
  Ellipse2D.Double ellipse = new Ellipse2D.Double(cx - rx, cy - ry,
      rx * 2, ry * 2);
  // create a path, rotate it about its center
  Path2D.Double path = new Path2D.Double(ellipse);
  AffineTransform tr = new AffineTransform();
  tr.rotate(angle, cx, cy);
  path.transform(tr);
  return path;
}

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

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

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

public void drawDefaultSequenceFlowIndicator(Line2D.Double line) {
  double length = DEFAULT_INDICATOR_WIDTH;
  double halfOfLength = length / 2;
  double f = 8;
  Line2D.Double defaultIndicator = new Line2D.Double(-halfOfLength,
                            0,
                            halfOfLength,
                            0);
  double angle = Math.atan2(line.y2 - line.y1,
               line.x2 - line.x1);
  double dx = f * Math.cos(angle);
  double dy = f * Math.sin(angle);
  double x1 = line.x1 + dx;
  double y1 = line.y1 + dy;
  AffineTransform transformation = new AffineTransform();
  transformation.setToIdentity();
  transformation.translate(x1,
               y1);
  transformation.rotate((angle - 3 * Math.PI / 4));
  AffineTransform originalTransformation = g.getTransform();
  g.setTransform(transformation);
  g.draw(defaultIndicator);
  g.setTransform(originalTransformation);
}

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

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

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

public void testOGCScaleAffineProjected() throws Exception {
  // 1 pixel == 500 m  =>  0.00028 m [ screen] == 500 m [world]
  // => scaleDenominator = 500/0.00028
  final AffineTransform screenToWord = AffineTransform.getScaleInstance(500, 500);
  final AffineTransform worldToScreen = screenToWord.createInverse();
  final CoordinateReferenceSystem crs = DefaultEngineeringCRS.CARTESIAN_2D;
  double scale;
  scale = RendererUtilities.calculateOGCScaleAffine(crs, worldToScreen, new HashMap());
  assertEquals(500 / 0.00028, scale, 0.0001);
  worldToScreen.rotate(1.0);
  scale = RendererUtilities.calculateOGCScaleAffine(crs, worldToScreen, new HashMap());
  assertEquals(500 / 0.00028, scale, 0.0001);
  worldToScreen.translate(100.0, 100.0);
  scale = RendererUtilities.calculateOGCScaleAffine(crs, worldToScreen, new HashMap());
  assertEquals(500 / 0.00028, scale, 0.0001);
}

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

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

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

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

相关文章