本文整理了Java中java.awt.geom.AffineTransform.createTransformedShape()
方法的一些代码示例,展示了AffineTransform.createTransformedShape()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AffineTransform.createTransformedShape()
方法的具体详情如下:
包路径:java.awt.geom.AffineTransform
类名称:AffineTransform
方法名:createTransformedShape
暂无
代码示例来源:origin: org.apache.poi/poi
public static Rectangle2D getAnchor(Graphics2D graphics, Rectangle2D anchor) {
if(graphics == null) {
return anchor;
}
AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
if(tx != null && !tx.isIdentity() && tx.createTransformedShape(anchor) != null) {
anchor = tx.createTransformedShape(anchor).getBounds2D();
}
return anchor;
}
代码示例来源:origin: plantuml/plantuml
private void appendAndRotate(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg, final Shape shape) {
final AffineTransform at = AffineTransform.getTranslateInstance(point.x, point.y);
final double theta = seg.getAngle();
at.rotate(theta);
final Shape r = at.createTransformedShape(shape);
generalPath.append(r, false);
}
代码示例来源:origin: org.apache.poi/poi
AffineTransform tx = graphics == null ? null : (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
if (tx == null) {
tx = new AffineTransform();
final Rectangle2D anchorO = tx.createTransformedShape(shapeAnchor).getBounds2D();
final AffineTransform txs2 = new AffineTransform();
anchorT = txs2.createTransformedShape(shapeAnchor).getBounds2D();
final AffineTransform txs2 = new AffineTransform();
txs2.translate(centerX, centerY);
txs2.translate(-centerX, -centerY);
normalizedShape = txs2.createTransformedShape(shapeAnchor).getBounds2D();
final java.awt.Shape anc = tx.createTransformedShape(normalizedShape);
return (anc != null) ? anc.getBounds2D() : normalizedShape;
代码示例来源:origin: org.apache.poi/poi
protected Collection<Outline> computeOutlines(Graphics2D graphics) {
List<Outline> lst = new ArrayList<>();
FreeformShape<?,?> fsh = (FreeformShape<?, ?>) getShape();
Path2D sh = fsh.getPath();
AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
if (tx == null) {
tx = new AffineTransform();
}
java.awt.Shape canvasShape = tx.createTransformedShape(sh);
FillStyle fs = fsh.getFillStyle();
StrokeStyle ss = fsh.getStrokeStyle();
Path path = new Path(fs != null, ss != null);
lst.add(new Outline(canvasShape, path));
return lst;
}
代码示例来源:origin: jrtom/jung
public Rectangle2D getForElement(N node, Point p) {
Shape shape = (Shape) rc.getNodeShapeFunction().apply(node);
// Point2D p = (Point2D) layoutModel.apply(node);
log.trace("node is at {}", p);
float x = (float) p.x;
float y = (float) p.y;
AffineTransform xform = AffineTransform.getTranslateInstance(x, y);
return xform.createTransformedShape(shape).getBounds2D();
}
代码示例来源:origin: apache/pdfbox
flipAT = new AffineTransform();
flipAT.translate(0, pdPage.getBBox().getHeight());
flipAT.scale(1, -1);
rotateAT = new AffineTransform();
int rotation = pdPage.getRotation();
if (rotation != 0)
transAT = AffineTransform.getTranslateInstance(-cropBox.getLowerLeftX(), cropBox.getLowerLeftY());
s = flipAT.createTransformedShape(s);
s = rotateAT.createTransformedShape(s);
g2d.setColor(Color.green);
g2d.draw(s);
代码示例来源: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: org.apache.poi/poi
AffineTransform at = new AffineTransform();
java.awt.Shape tailShape = null;
Path p = null;
p = new Path();
tailShape = new Ellipse2D.Double(0, 0, lineWidth * scaleX, lineWidth * scaleY);
bounds = tailShape.getBounds2D();
at.translate(x2 - bounds.getWidth() / 2, y2 - bounds.getHeight() / 2);
at.rotate(alpha, bounds.getX() + bounds.getWidth() / 2, bounds.getY() + bounds.getHeight() / 2);
tailShape = at.createTransformedShape(tailShape);
代码示例来源:origin: org.apache.poi/poi
AffineTransform at = new AffineTransform();
at.translate(anchor.getX(), anchor.getY());
at.scale(scaleX, scaleY);
java.awt.Shape canvasShape = at.createTransformedShape(gp);
代码示例来源:origin: opentripplanner/OpenTripPlanner
public ShapeStroke(Shape shape, float width, float advance, float phase) {
this.advance = advance;
this.phase = phase;
Rectangle2D bounds = shape.getBounds2D();
double scale = width / bounds.getHeight();
t.setToScale(scale, scale);
t.translate(-bounds.getCenterX(), -bounds.getCenterY());
this.theShape = t.createTransformedShape(shape);
}
代码示例来源:origin: stackoverflow.com
Point2D p = gv.getGlyphPosition(i);
double theta = (double) i / (double) (length - 1) * Math.PI / 4;
AffineTransform at = AffineTransform.getTranslateInstance(p.getX(), p.getY());
at.rotate(theta);
Shape glyph = gv.getGlyphOutline(i);
Shape transformedGlyph = at.createTransformedShape(glyph);
g2.fill(transformedGlyph);
代码示例来源:origin: jrtom/jung
public Rectangle2D getForElement(N node, Point p) {
Shape shape = (Shape) rc.getNodeShapeFunction().apply(node);
// Point2D p = (Point2D) layoutModel.apply(node);
log.trace("node is at {}", p);
float x = (float) p.x;
float y = (float) p.y;
AffineTransform xform = AffineTransform.getTranslateInstance(x, y);
return xform.createTransformedShape(shape).getBounds2D();
}
代码示例来源:origin: org.boofcv/boofcv-swing
public static void drawEllipse( EllipseRotated_F64 ellipse , double scale , Graphics2D g2 ) {
AffineTransform rotate = new AffineTransform();
rotate.rotate(ellipse.phi);
double w = scale*ellipse.a*2;
double h = scale*ellipse.b*2;
Shape shape = rotate.createTransformedShape(new Ellipse2D.Double(-w/2,-h/2,w,h));
shape = AffineTransform.getTranslateInstance(scale*ellipse.center.x,scale*ellipse.center.y).createTransformedShape(shape);
g2.draw(shape);
}
代码示例来源:origin: apache/pdfbox
Rectangle2D bounds = at.createTransformedShape(unitRect).getBounds2D();
BufferedImage renderedPaint =
new BufferedImage((int) Math.ceil(bounds.getWidth()),
g = (Graphics2D) renderedMask.getGraphics();
g.translate(-bounds.getMinX(), -bounds.getMinY());
AffineTransform imageTransform = new AffineTransform(at);
imageTransform.scale(1.0 / mask.getWidth(), -1.0 / mask.getHeight());
imageTransform.translate(0, -mask.getHeight());
AffineTransform.getTranslateInstance(bounds.getMinX(), bounds.getMinY()),
null);
代码示例来源:origin: org.apache.poi/poi
AffineTransform at = new AffineTransform();
java.awt.Shape headShape = null;
Path p = null;
p = new Path();
headShape = new Ellipse2D.Double(0, 0, lineWidth * scaleX, lineWidth * scaleY);
bounds = headShape.getBounds2D();
at.translate(x1 - bounds.getWidth() / 2, y1 - bounds.getHeight() / 2);
at.rotate(alpha, bounds.getX() + bounds.getWidth() / 2, bounds.getY() + bounds.getHeight() / 2);
headShape = at.createTransformedShape(headShape);
代码示例来源:origin: org.apache.poi/poi-ooxml
final AffineTransform at = new AffineTransform();
at.scale(1./Units.EMU_PER_POINT, 1./Units.EMU_PER_POINT);
at.translate(-xfrm2d.getCenterX(), -xfrm2d.getCenterY());
return new Path2D.Double(at.createTransformedShape(path));
代码示例来源:origin: geotools/geotools
/**
* Builds a new transformed icon
*
* @param icon The icon to be rescaled
* @param transformation The icon transformation
*/
public TransformedIcon(Icon icon, AffineTransform at) {
this.icon = icon;
this.at = at;
Rectangle2D bounds =
new Rectangle2D.Double(0, 0, icon.getIconWidth(), icon.getIconHeight());
bounds = at.createTransformedShape(bounds).getBounds2D();
this.width = (int) Math.round(bounds.getWidth());
this.height = (int) Math.round(bounds.getHeight());
}
代码示例来源:origin: stackoverflow.com
int spaceX = sz - r.width;
int spaceY = sz - r.height;
AffineTransform trans = AffineTransform.getTranslateInstance(
-r.x + (spaceX / 2), -r.y + (spaceY / 2));
System.out.println("Box2D " + trans);
Shape shapeCentered = trans.createTransformedShape(shape1);
代码示例来源:origin: jrtom/jung
public Rectangle2D getForElement(N node) {
Shape shape = new Rectangle2D.Double();
Point p = (Point) visualizationModel.getLayoutModel().apply(node);
float x = (float) p.x;
float y = (float) p.y;
AffineTransform xform = AffineTransform.getTranslateInstance(x, y);
Rectangle2D xfs = xform.createTransformedShape(shape).getBounds2D();
log.trace("node {} with shape bounds {} is at {}", node, xfs, p);
return xfs;
}
代码示例来源:origin: org.boofcv/visualize
public static void drawEllipse( EllipseRotated_F64 ellipse , double scale , Graphics2D g2 ) {
AffineTransform rotate = new AffineTransform();
rotate.rotate(ellipse.phi);
double w = scale*ellipse.a*2;
double h = scale*ellipse.b*2;
Shape shape = rotate.createTransformedShape(new Ellipse2D.Double(-w/2,-h/2,w,h));
shape = AffineTransform.getTranslateInstance(scale*ellipse.center.x,scale*ellipse.center.y).createTransformedShape(shape);
g2.draw(shape);
}
内容来源于网络,如有侵权,请联系作者删除!