本文整理了Java中java.awt.geom.AffineTransform.translate()
方法的一些代码示例,展示了AffineTransform.translate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AffineTransform.translate()
方法的具体详情如下:
包路径:java.awt.geom.AffineTransform
类名称:AffineTransform
方法名:translate
暂无
代码示例来源: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: pentaho/pentaho-kettle
public void setTransform( float translationX, float translationY, int shadowsize, float magnification ) {
// PDI-9953 - always use original GC's transform.
AffineTransform transform = (AffineTransform) originalTransform.clone();
transform.translate( translationX + shadowsize * magnification, translationY + shadowsize * magnification );
transform.scale( magnification, magnification );
gc.setTransform( transform );
}
代码示例来源: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: 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);
final AffineTransform txs2 = new AffineTransform();
txs2.translate(centerX, centerY);
txs2.scale(scaleY2, scaleX2);
txs2.translate(-centerX, -centerY);
代码示例来源:origin: knowm/XChart
void paintSeriesText(
Graphics2D g,
Map<String, Rectangle2D> seriesTextBounds,
int markerSize,
double x,
double starty) {
g.setColor(chart.getStyler().getChartFontColor());
g.setFont(chart.getStyler().getLegendFont());
double multiLineOffset = 0.0;
for (Map.Entry<String, Rectangle2D> entry : seriesTextBounds.entrySet()) {
double height = entry.getValue().getHeight();
double centerOffsetY = (Math.max(markerSize, height) - height) / 2.0;
FontRenderContext frc = g.getFontRenderContext();
TextLayout tl = new TextLayout(entry.getKey(), chart.getStyler().getLegendFont(), frc);
Shape shape = tl.getOutline(null);
AffineTransform orig = g.getTransform();
AffineTransform at = new AffineTransform();
at.translate(x, starty + height + centerOffsetY + multiLineOffset);
g.transform(at);
g.fill(shape);
g.setTransform(orig);
// // debug box
// Rectangle2D boundsTemp = new Rectangle2D.Double(x, starty + centerOffsetY,
// entry.getValue().getWidth(), height);
// g.setColor(Color.blue);
// g.draw(boundsTemp);
multiLineOffset += height + MULTI_LINE_SPACE;
}
}
代码示例来源:origin: geotools/geotools
/**
* Workaround for RFE #4093999 ("Relax constraint on placement of this()/super() call in
* constructors").
*/
private static MathTransform getMathTransform(
final Rectangle gridRange, final Rectangle2D userRange) {
final double scaleX = userRange.getWidth() / gridRange.getWidth();
final double scaleY = userRange.getHeight() / gridRange.getHeight();
final double transX = userRange.getMinX() - gridRange.x * scaleX;
final double transY = userRange.getMaxY() + gridRange.y * scaleY;
final AffineTransform tr = new AffineTransform(scaleX, 0, 0, -scaleY, transX, transY);
tr.translate(0.5, 0.5); // Maps to pixel center
return ProjectiveTransform.create(tr);
}
代码示例来源: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: stackoverflow.com
Graphics2D g2d = (Graphics2D) g.create();
AffineTransform at = g2d.getTransform();
at.translate(originX, originY);
g2d.setTransform(at);
g2d.scale(scale, scale);
g2d.rotate(Math.toRadians(angle), 0, 0);
g2d.fillRect(xOffset, yOffset, rectWidth, rectHeight);
g2d.dispose();
代码示例来源:origin: mapsforge/mapsforge
@Override
public void scale(float scaleX, float scaleY, float pivotX, float pivotY) {
this.affineTransform.translate(pivotX, pivotY);
this.affineTransform.scale(scaleX, scaleY);
this.affineTransform.translate(-pivotX, -pivotY);
}
代码示例来源:origin: apache/pdfbox
at.translate(mediaBox.getLowerLeftX() - viewBox.getLowerLeftX(),
mediaBox.getLowerLeftY() - viewBox.getLowerLeftY());
switch (rotation)
at.scale(viewBox.getWidth() / viewBox.getHeight(), viewBox.getHeight() / viewBox.getWidth());
at.translate(0, viewBox.getWidth());
at.rotate(-Math.PI / 2.0);
break;
case 180:
at.translate(viewBox.getWidth(), viewBox.getHeight());
at.rotate(-Math.PI);
break;
case 270:
at.scale(viewBox.getWidth() / viewBox.getHeight(), viewBox.getHeight() / viewBox.getWidth());
at.translate(viewBox.getHeight(), 0);
at.rotate(-Math.PI * 1.5);
break;
default:
at.translate(-viewBox.getLowerLeftX(), -viewBox.getLowerLeftY());
if (!at.isIdentity())
代码示例来源:origin: stackoverflow.com
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;
t.translate(-info.height, 0);
t.translate(0, info.width);
case 8: // PI / 2
t.translate(0, info.width);
代码示例来源: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: knowm/XChart
g.setFont(styler.getToolTipFont());
AffineTransform orig = g.getTransform();
AffineTransform at = new AffineTransform();
at.translate(x + MARGIN - 1, y + MARGIN - 1 + halfHeight);
g.transform(at);
g.fill(shape);
g.setTransform(orig);
代码示例来源:origin: nodebox/nodebox
private AffineTransform fullTransform(Rect bounds) {
double cx = bounds.getX() + bounds.getWidth() / 2;
double cy = bounds.getY() + bounds.getHeight() / 2;
AffineTransform t = new AffineTransform();
t.translate(cx, cy);
t.preConcatenate(affineTransform);
t.translate(-cx, -cy);
return t;
}
代码示例来源: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: net.sourceforge.ondex.apps/ovtk2
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2d = (Graphics2D) g.create();
AffineTransform transform = g2d.getTransform();
transform.translate((double) width / 2.0 + 1, (double) height / 2.0 + 1);
g2d.setTransform(transform);
g2d.setColor(Color.BLUE);
g2d.fill(shape);
g2d.dispose();
}
代码示例来源:origin: mapsforge/mapsforge
double verticalScale = tileRect.getHeight() / shadeRect.getHeight();
transform.translate(tileRect.left, tileRect.top);
transform.scale(horizontalScale, verticalScale);
transform.translate(-shadeRect.left, -shadeRect.top);
代码示例来源: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: org.apache.poi/poi
AffineTransform tx = new AffineTransform();
try {
if (bounds != null) {
double scaleX = bounds.getWidth()/shapeBounds.getWidth();
double scaleY = bounds.getHeight()/shapeBounds.getHeight();
tx.translate(bounds.getCenterX(), bounds.getCenterY());
tx.scale(scaleX, scaleY);
tx.translate(-shapeBounds.getCenterX(), -shapeBounds.getCenterY());
内容来源于网络,如有侵权,请联系作者删除!