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

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

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

AffineTransform.translate介绍

暂无

代码示例

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

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

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

  1. public void setTransform( float translationX, float translationY, int shadowsize, float magnification ) {
  2. // PDI-9953 - always use original GC's transform.
  3. AffineTransform transform = (AffineTransform) originalTransform.clone();
  4. transform.translate( translationX + shadowsize * magnification, translationY + shadowsize * magnification );
  5. transform.scale( magnification, magnification );
  6. gc.setTransform( transform );
  7. }

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

  1. AffineTransform tx = graphics == null ? null : (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
  2. if (tx == null) {
  3. tx = new AffineTransform();
  4. final AffineTransform txs2 = new AffineTransform();
  5. txs2.translate(centerX, centerY);
  6. txs2.quadrantRotate(1);
  7. txs2.translate(-centerX, -centerY);
  8. txs2.concatenate(tx);
  9. txs2.translate(centerX, centerY);
  10. txs2.quadrantRotate(3);
  11. txs2.translate(-centerX, -centerY);
  12. final AffineTransform txs2 = new AffineTransform();
  13. txs2.translate(centerX, centerY);
  14. txs2.scale(scaleY2, scaleX2);
  15. txs2.translate(-centerX, -centerY);

代码示例来源:origin: knowm/XChart

  1. void paintSeriesText(
  2. Graphics2D g,
  3. Map<String, Rectangle2D> seriesTextBounds,
  4. int markerSize,
  5. double x,
  6. double starty) {
  7. g.setColor(chart.getStyler().getChartFontColor());
  8. g.setFont(chart.getStyler().getLegendFont());
  9. double multiLineOffset = 0.0;
  10. for (Map.Entry<String, Rectangle2D> entry : seriesTextBounds.entrySet()) {
  11. double height = entry.getValue().getHeight();
  12. double centerOffsetY = (Math.max(markerSize, height) - height) / 2.0;
  13. FontRenderContext frc = g.getFontRenderContext();
  14. TextLayout tl = new TextLayout(entry.getKey(), chart.getStyler().getLegendFont(), frc);
  15. Shape shape = tl.getOutline(null);
  16. AffineTransform orig = g.getTransform();
  17. AffineTransform at = new AffineTransform();
  18. at.translate(x, starty + height + centerOffsetY + multiLineOffset);
  19. g.transform(at);
  20. g.fill(shape);
  21. g.setTransform(orig);
  22. // // debug box
  23. // Rectangle2D boundsTemp = new Rectangle2D.Double(x, starty + centerOffsetY,
  24. // entry.getValue().getWidth(), height);
  25. // g.setColor(Color.blue);
  26. // g.draw(boundsTemp);
  27. multiLineOffset += height + MULTI_LINE_SPACE;
  28. }
  29. }

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

  1. /**
  2. * Workaround for RFE #4093999 ("Relax constraint on placement of this()/super() call in
  3. * constructors").
  4. */
  5. private static MathTransform getMathTransform(
  6. final Rectangle gridRange, final Rectangle2D userRange) {
  7. final double scaleX = userRange.getWidth() / gridRange.getWidth();
  8. final double scaleY = userRange.getHeight() / gridRange.getHeight();
  9. final double transX = userRange.getMinX() - gridRange.x * scaleX;
  10. final double transY = userRange.getMaxY() + gridRange.y * scaleY;
  11. final AffineTransform tr = new AffineTransform(scaleX, 0, 0, -scaleY, transX, transY);
  12. tr.translate(0.5, 0.5); // Maps to pixel center
  13. return ProjectiveTransform.create(tr);
  14. }

代码示例来源: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: stackoverflow.com

  1. Graphics2D g2d = (Graphics2D) g.create();
  2. AffineTransform at = g2d.getTransform();
  3. at.translate(originX, originY);
  4. g2d.setTransform(at);
  5. g2d.scale(scale, scale);
  6. g2d.rotate(Math.toRadians(angle), 0, 0);
  7. g2d.fillRect(xOffset, yOffset, rectWidth, rectHeight);
  8. g2d.dispose();

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

  1. @Override
  2. public void scale(float scaleX, float scaleY, float pivotX, float pivotY) {
  3. this.affineTransform.translate(pivotX, pivotY);
  4. this.affineTransform.scale(scaleX, scaleY);
  5. this.affineTransform.translate(-pivotX, -pivotY);
  6. }

代码示例来源:origin: apache/pdfbox

  1. at.translate(mediaBox.getLowerLeftX() - viewBox.getLowerLeftX(),
  2. mediaBox.getLowerLeftY() - viewBox.getLowerLeftY());
  3. switch (rotation)
  4. at.scale(viewBox.getWidth() / viewBox.getHeight(), viewBox.getHeight() / viewBox.getWidth());
  5. at.translate(0, viewBox.getWidth());
  6. at.rotate(-Math.PI / 2.0);
  7. break;
  8. case 180:
  9. at.translate(viewBox.getWidth(), viewBox.getHeight());
  10. at.rotate(-Math.PI);
  11. break;
  12. case 270:
  13. at.scale(viewBox.getWidth() / viewBox.getHeight(), viewBox.getHeight() / viewBox.getWidth());
  14. at.translate(viewBox.getHeight(), 0);
  15. at.rotate(-Math.PI * 1.5);
  16. break;
  17. default:
  18. at.translate(-viewBox.getLowerLeftX(), -viewBox.getLowerLeftY());
  19. if (!at.isIdentity())

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

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

代码示例来源:origin: rkalla/imgscalr

  1. AffineTransform tx = new AffineTransform();
  2. tx.translate(newWidth, 0);
  3. tx.quadrantRotate(1);
  4. tx.translate(0, newHeight);
  5. tx.quadrantRotate(3);
  6. break;
  7. tx.translate(newWidth, newHeight);
  8. tx.quadrantRotate(2);
  9. break;
  10. tx.translate(newWidth, 0);
  11. tx.scale(-1.0, 1.0);
  12. break;
  13. tx.translate(0, newHeight);
  14. tx.scale(1.0, -1.0);
  15. break;

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

  1. g.setFont(styler.getToolTipFont());
  2. AffineTransform orig = g.getTransform();
  3. AffineTransform at = new AffineTransform();
  4. at.translate(x + MARGIN - 1, y + MARGIN - 1 + halfHeight);
  5. g.transform(at);
  6. g.fill(shape);
  7. g.setTransform(orig);

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

  1. private AffineTransform fullTransform(Rect bounds) {
  2. double cx = bounds.getX() + bounds.getWidth() / 2;
  3. double cy = bounds.getY() + bounds.getHeight() / 2;
  4. AffineTransform t = new AffineTransform();
  5. t.translate(cx, cy);
  6. t.preConcatenate(affineTransform);
  7. t.translate(-cx, -cy);
  8. return t;
  9. }

代码示例来源: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: net.sourceforge.ondex.apps/ovtk2

  1. public void paintIcon(Component c, Graphics g, int x, int y) {
  2. Graphics2D g2d = (Graphics2D) g.create();
  3. AffineTransform transform = g2d.getTransform();
  4. transform.translate((double) width / 2.0 + 1, (double) height / 2.0 + 1);
  5. g2d.setTransform(transform);
  6. g2d.setColor(Color.BLUE);
  7. g2d.fill(shape);
  8. g2d.dispose();
  9. }

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

  1. double verticalScale = tileRect.getHeight() / shadeRect.getHeight();
  2. transform.translate(tileRect.left, tileRect.top);
  3. transform.scale(horizontalScale, verticalScale);
  4. transform.translate(-shadeRect.left, -shadeRect.top);

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

  1. AffineTransform tx = new AffineTransform();
  2. try {
  3. if (bounds != null) {
  4. double scaleX = bounds.getWidth()/shapeBounds.getWidth();
  5. double scaleY = bounds.getHeight()/shapeBounds.getHeight();
  6. tx.translate(bounds.getCenterX(), bounds.getCenterY());
  7. tx.scale(scaleX, scaleY);
  8. tx.translate(-shapeBounds.getCenterX(), -shapeBounds.getCenterY());

相关文章