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

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

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

AffineTransform.<init>介绍

暂无

代码示例

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

public void setTransform( float translationX, float translationY, int shadowsize, float magnification ) {
 AffineTransform transform = new AffineTransform();
 transform.translate( translationX + shadowsize * magnification, translationY + shadowsize * magnification );
 transform.scale( magnification, magnification );
 gc.setTransform( transform );
}

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

public static BufferedImage process(BufferedImage im) {
  Log.info("Rotation");
  final BufferedImage newIm = new BufferedImage(im.getHeight(), im.getWidth(), BufferedImage.TYPE_INT_RGB);
  final Graphics2D g2d = newIm.createGraphics();
  final AffineTransform at = new AffineTransform(0, 1, 1, 0, 0, 0);
  at.concatenate(new AffineTransform(-1, 0, 0, 1, im.getWidth(), 0));
  g2d.setTransform(at);
  g2d.drawImage(im, 0, 0, null);
  g2d.dispose();
  return newIm;
}

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

BufferedImage before = getBufferedImage(encoded);
int w = before.getWidth();
int h = before.getHeight();
BufferedImage after = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
AffineTransform at = new AffineTransform();
at.scale(2.0, 2.0);
AffineTransformOp scaleOp = 
  new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
after = scaleOp.filter(before, after);

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

AffineTransform at = new AffineTransform();
at.translate(anchor.getX(), anchor.getY());
at.scale(scaleX, scaleY);

代码示例来源: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 t = new AffineTransform();
  break;
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

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

private AffineTransformation compose(AffineTransformation other) {
  final AffineTransform tmp = new AffineTransform(this.affineTransform);
  tmp.concatenate(other.affineTransform);
  return new AffineTransformation(tmp);
}

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

AffineTransform tx = graphics == null ? null : (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
if (tx == null) {
  tx = new AffineTransform();
    final AffineTransform txs2 = new AffineTransform();
      txs2.translate(centerX, centerY);
      txs2.quadrantRotate(1);
      txs2.translate(-centerX, -centerY);
      txs2.concatenate(tx);
    txs2.translate(centerX, centerY);
    txs2.quadrantRotate(3);
    txs2.translate(-centerX, -centerY);
      txs2.concatenate(tx);
    final AffineTransform txs2 = new AffineTransform();
    txs2.translate(centerX, centerY);
    txs2.scale(scaleY2, scaleX2);
    txs2.translate(-centerX, -centerY);

代码示例来源: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: org.apache.poi/poi

graphics.setRenderingHint(Drawable.GROUP_TRANSFORM, new AffineTransform());
  AffineTransform at = graphics.getTransform();
  graphics.setTransform(at);

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

public void testAutoWrapLocalTransform() throws Exception {
  Style style = RendererBaseTest.loadStyle(this, "textWrapEnabled.sld");
  MapContent mc = new MapContent();
  mc.getViewport().setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84);
  mc.addLayer(new FeatureLayer(fs, style));
  StreamingRenderer renderer = new StreamingRenderer();
  renderer.setJava2DHints(new RenderingHints(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON));
  renderer.setMapContent(mc);
  int SIZE = 300;
  final BufferedImage image = new BufferedImage(SIZE, SIZE, BufferedImage.TYPE_INT_ARGB);
  Graphics2D g = (Graphics2D) image.getGraphics();
  g.setColor(Color.white);
  g.fillRect(0, 0, SIZE, SIZE);
  g.setTransform(
      new AffineTransform(
          1.1,
          Math.sin(Math.toRadians(15)),
          -Math.sin(Math.toRadians(15)),
          1.1,
          15,
          20));
  renderer.paint(g, new Rectangle(SIZE, SIZE), bounds);
  mc.dispose();
  renderer.getMapContent().dispose();
  String refPath =
      "./src/test/resources/org/geotools/renderer/lite/test-data/textWrapEnabledLocalTransform.png";
  ImageAssert.assertEquals(new File(refPath), image, 3000);
}

代码示例来源:origin: tabulapdf/tabula-java

protected ObjectExtractorStreamEngine(PDPage page) {
  super(page);
  this.log = LoggerFactory.getLogger(ObjectExtractorStreamEngine.class);
  this.rulings = new ArrayList<>();
  this.pageTransform = null;
  // calculate page transform
  PDRectangle cb = this.getPage().getCropBox();
  int rotation = this.getPage().getRotation();
  this.pageTransform = new AffineTransform();
  if (Math.abs(rotation) == 90 || Math.abs(rotation) == 270) {
    this.pageTransform = AffineTransform.getRotateInstance(rotation * (Math.PI / 180.0), 0, 0);
    this.pageTransform.concatenate(AffineTransform.getScaleInstance(1, -1));
  } else {
    this.pageTransform.concatenate(AffineTransform.getTranslateInstance(0, cb.getHeight()));
    this.pageTransform.concatenate(AffineTransform.getScaleInstance(1, -1));
  }
  this.pageTransform.translate(-cb.getLowerLeftX(), -cb.getLowerLeftY());
}

代码示例来源:origin: nguyenq/tess4j

g2.fillRect(0, 0, bi.getWidth(), bi.getHeight());
AffineTransform at = new AffineTransform();
at.rotate(theta, cx, cy);
g2.setTransform(at);
g2.drawImage(image, -minX, -minY, null);
g2.dispose();

代码示例来源: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: rkalla/imgscalr

AffineTransform tx = new AffineTransform();
  tx.translate(newWidth, 0);
  tx.quadrantRotate(1);
  tx.translate(0, newHeight);
  tx.quadrantRotate(3);
  break;
  tx.translate(newWidth, newHeight);
  tx.quadrantRotate(2);
  break;
  tx.translate(newWidth, 0);
  tx.scale(-1.0, 1.0);
  break;
  tx.translate(0, newHeight);
  tx.scale(1.0, -1.0);
  break;

代码示例来源: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: pentaho/pentaho-kettle

public static void render( Graphics2D gc, GraphicsNode svgGraphicsNode, Dimension2D svgGraphicsSize, int centerX,
   int centerY, int width, int height, double angleRadians ) {
  double scaleX = width / svgGraphicsSize.getWidth();
  double scaleY = height / svgGraphicsSize.getHeight();

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

  svgGraphicsNode.setTransform( affineTransform );

  svgGraphicsNode.paint( gc );
 }
}

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

public MathTransform getOriginalGridToWorld(PixelInCell pixInCell) {
  if (homogeneousCoverages) {
    return delegate.getOriginalGridToWorld(referenceName, pixInCell);
  }
  final GridToEnvelopeMapper geMapper =
      new GridToEnvelopeMapper(getOriginalGridRange(), getOriginalEnvelope());
  geMapper.setPixelAnchor(PixelInCell.CELL_CENTER);
  MathTransform2D coverageGridToWorld2D = (MathTransform2D) geMapper.createTransform();
  // we do not have to change the pixel datum
  if (pixInCell == PixelInCell.CELL_CENTER) return coverageGridToWorld2D;
  // we do have to change the pixel datum
  if (coverageGridToWorld2D instanceof AffineTransform) {
    final AffineTransform tr = new AffineTransform((AffineTransform) coverageGridToWorld2D);
    tr.concatenate(AffineTransform.getTranslateInstance(-0.5, -0.5));
    return ProjectiveTransform.create(tr);
  }
  throw new IllegalStateException("This reader's grid to world transform is invalid!");
}

代码示例来源:origin: com.google.gwt/gwt-servlet

public AffineTransform transform() {
 AffineTransform toReturn = new AffineTransform();
 // Translate
 toReturn.translate(left, top);
 // Scale
 assert !(height > 0 ^ width > 0);
 if (height > 0) {
  toReturn.scale((double) height / intrinsicHeight, (double) width
    / intrinsicWidth);
 }
 // Use the base concatenation
 toReturn.concatenate(transform);
 assert checkTransform(toReturn);
 return toReturn;
}

代码示例来源: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);
}

相关文章