本文整理了Java中java.awt.geom.AffineTransform.scale()
方法的一些代码示例,展示了AffineTransform.scale()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AffineTransform.scale()
方法的具体详情如下:
包路径:java.awt.geom.AffineTransform
类名称:AffineTransform
方法名:scale
暂无
代码示例来源: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: 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: 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: 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
private UImage scale(double scale, final int type) {
if (scale == 1) {
return this;
}
final int w = (int) Math.round(image.getWidth() * scale);
final int h = (int) Math.round(image.getHeight() * scale);
final BufferedImage after = new BufferedImage(w, h, image.getType());
final AffineTransform at = new AffineTransform();
at.scale(scale, scale);
final AffineTransformOp scaleOp = new AffineTransformOp(at, type);
return new UImage(scaleOp.filter(image, after), formula);
}
代码示例来源: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: 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
break;
case 7: // PI/2 and Flip
t.scale(-1.0, 1.0);
t.translate(-info.height, 0);
t.translate(0, info.width);
代码示例来源:origin: org.apache.poi/poi
@Override
public BufferedImage getImage(Dimension dim) {
double w_old = img.getWidth();
double h_old = img.getHeight();
BufferedImage scaled = new BufferedImage((int)w_old, (int)h_old, BufferedImage.TYPE_INT_ARGB);
double w_new = dim.getWidth();
double h_new = dim.getHeight();
AffineTransform at = new AffineTransform();
at.scale(w_new/w_old, h_new/h_old);
AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
scaleOp.filter(img, scaled);
return scaled;
}
代码示例来源: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
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: 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);
代码示例来源:origin: org.mapsforge/mapsforge-map-awt
@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: org.apache.poi/poi
public void draw(Graphics2D graphics) {
// the coordinate system of this group of shape
Rectangle2D interior = getShape().getInteriorAnchor();
// anchor of this group relative to the parent shape
Rectangle2D exterior = getShape().getAnchor();
AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
AffineTransform tx0 = new AffineTransform(tx);
double scaleX = interior.getWidth() == 0. ? 1.0 : exterior.getWidth() / interior.getWidth();
double scaleY = interior.getHeight() == 0. ? 1.0 : exterior.getHeight() / interior.getHeight();
tx.translate(exterior.getX(), exterior.getY());
tx.scale(scaleX, scaleY);
tx.translate(-interior.getX(), -interior.getY());
DrawFactory drawFact = DrawFactory.getInstance(graphics);
AffineTransform at2 = graphics.getTransform();
for (Shape<?,?> child : getShape()) {
// remember the initial transform and restore it after we are done with the drawing
AffineTransform at = graphics.getTransform();
graphics.setRenderingHint(Drawable.GSAVE, true);
Drawable draw = drawFact.getDrawable(child);
draw.applyTransform(graphics);
draw.draw(graphics);
// restore the coordinate system
graphics.setTransform(at);
graphics.setRenderingHint(Drawable.GRESTORE, true);
}
graphics.setTransform(at2);
graphics.setRenderingHint(Drawable.GROUP_TRANSFORM, tx0);
}
代码示例来源:origin: apache/pdfbox
private BufferedImage adjustImage(BufferedImage gray) throws IOException
{
AffineTransform at = new AffineTransform(xform);
Matrix m = new Matrix(at);
at.scale(1.0 / Math.abs(m.getScalingFactorX()), 1.0 / Math.abs(m.getScalingFactorY()));
Rectangle originalBounds = new Rectangle(gray.getWidth(), gray.getHeight());
Rectangle2D transformedBounds = at.createTransformedShape(originalBounds).getBounds2D();
at.preConcatenate(AffineTransform.getTranslateInstance(-transformedBounds.getMinX(),
-transformedBounds.getMinY()));
int width = (int) Math.ceil(transformedBounds.getWidth());
int height = (int) Math.ceil(transformedBounds.getHeight());
BufferedImage transformedGray = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
Graphics2D g2 = (Graphics2D) transformedGray.getGraphics();
g2.drawImage(gray, at, null);
g2.dispose();
return transformedGray;
}
代码示例来源: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);
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Returns a transform that can translate shape-local coordinates to the
* coordinates of its parent shape
*/
protected AffineTransform getParentTransform() {
// TODO: There's probably a better way to do this
AffineTransform tr = new AffineTransform();
Double locX = getLocPinX();
Double locY = getLocPinY();
Boolean flipX = getFlipX();
Boolean flipY = getFlipY();
Double angle = getAngle();
tr.translate(-locX, -locY);
tr.translate(getPinX(), getPinY());
// rotate about the origin
if (angle != null && Math.abs(angle) > 0.001) {
tr.rotate(angle, locX, locY);
}
// flip if necessary
if (flipX != null && flipX) {
tr.scale(-1, 1);
tr.translate(-getWidth(), 0);
}
if (flipY != null && flipY) {
tr.scale(1, -1);
tr.translate(0, -getHeight());
}
return tr;
}
代码示例来源:origin: apache/pdfbox
private void adjustRectangle(Rectangle2D r)
{
Matrix m = new Matrix(xform);
double scaleX = Math.abs(m.getScalingFactorX());
double scaleY = Math.abs(m.getScalingFactorY());
AffineTransform adjustedTransform = new AffineTransform(xform);
adjustedTransform.scale(1.0 / scaleX, 1.0 / scaleY);
r.setRect(adjustedTransform.createTransformedShape(r).getBounds2D());
}
代码示例来源:origin: movsim/movsim
protected void setTransform() {
transform.setToIdentity();
transform.scale(scale, scale);
transform.translate(xOffset, yOffset);
}
代码示例来源: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: stackoverflow.com
if (img != null) {
Graphics2D g2d = (Graphics2D) g.create();
AffineTransform at = new AffineTransform();
at.scale(scale, scale);
g2d.drawImage(img, at, this);
g2d.dispose();
内容来源于网络,如有侵权,请联系作者删除!