本文整理了Java中java.awt.geom.AffineTransform.getRotateInstance()
方法的一些代码示例,展示了AffineTransform.getRotateInstance()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AffineTransform.getRotateInstance()
方法的具体详情如下:
包路径:java.awt.geom.AffineTransform
类名称:AffineTransform
方法名:getRotateInstance
暂无
代码示例来源:origin: plantuml/plantuml
public void rotate(double theta) {
final AffineTransform rotate = AffineTransform.getRotateInstance(theta);
for (Point2D.Double pt : all) {
rotate.transform(pt, pt);
}
}
代码示例来源:origin: plantuml/plantuml
public MagicPointsFactory2(Point2D.Double p1, Point2D.Double p2) {
this.p1 = p1;
this.p2 = p2;
final double dx = p2.x - p1.x;
final double dy = p2.y - p1.y;
final int interv = 5;
final int intervAngle = 10;
final double theta = Math.PI * 2 / intervAngle;
for (int a = 0; a < 10; a++) {
final AffineTransform at = AffineTransform.getRotateInstance(theta * a, p1.x, p1.y);
for (int i = 0; i < interv * 2; i++) {
final Point2D.Double p = new Point2D.Double(p1.x + dx * i / interv, p1.y + dy * i / interv);
result.add((Point2D.Double) at.transform(p, null));
}
}
}
代码示例来源:origin: plantuml/plantuml
public USegment rotate(double theta) {
if (coord.length != 2) {
throw new UnsupportedOperationException();
}
Point2D p1 = new Point2D.Double(coord[0], coord[1]);
final AffineTransform rotate = AffineTransform.getRotateInstance(theta);
rotate.transform(p1, p1);
return new USegment(new double[] { p1.getX(), p1.getY() }, pathType);
}
代码示例来源:origin: plantuml/plantuml
public void drawU(UGraphic ug) {
final int xWing = 4;
final AffineTransform rotate = AffineTransform.getRotateInstance(this.angle);
Point2D firstLineTop = new Point2D.Double(-xWing, -lineHeight);
Point2D firstLineBottom = new Point2D.Double(-xWing, lineHeight);
Point2D secondLineTop = new Point2D.Double(-xWing - 3, -lineHeight);
Point2D secondLineBottom = new Point2D.Double(-xWing - 3, lineHeight);
Point2D middle = new Point2D.Double(0, 0);
Point2D base = new Point2D.Double(-xWing - 4, 0);
rotate.transform(middle, middle);
rotate.transform(base, base);
rotate.transform(firstLineTop, firstLineTop);
rotate.transform(firstLineBottom, firstLineBottom);
rotate.transform(secondLineTop, secondLineTop);
rotate.transform(secondLineBottom, secondLineBottom);
drawLine(ug, contact.getX(), contact.getY(), firstLineTop, firstLineBottom);
drawLine(ug, contact.getX(), contact.getY(), secondLineTop, secondLineBottom);
drawLine(ug, contact.getX(), contact.getY(), base, middle);
}
代码示例来源:origin: plantuml/plantuml
public void drawU(UGraphic ug) {
final int xWing = 8;
final int yAperture = 8;
final AffineTransform rotate = AffineTransform.getRotateInstance(this.angle);
Point2D middle = new Point2D.Double(0, 0);
Point2D left = new Point2D.Double(0, -yAperture);
Point2D base = new Point2D.Double(-xWing, 0);
Point2D right = new Point2D.Double(0, yAperture);
rotate.transform(left, left);
rotate.transform(base, base);
rotate.transform(right, right);
if (side == Side.WEST || side == Side.EAST) {
left.setLocation(middle.getX(), left.getY());
right.setLocation(middle.getX(), right.getY());
}
if (side == Side.SOUTH || side == Side.NORTH) {
left.setLocation(left.getX(), middle.getY());
right.setLocation(right.getX(), middle.getY());
}
drawLine(ug, contact.getX(), contact.getY(), base, left);
drawLine(ug, contact.getX(), contact.getY(), base, right);
drawLine(ug, contact.getX(), contact.getY(), base, middle);
}
代码示例来源:origin: plantuml/plantuml
public void drawU(UGraphic ug) {
final int xWing = 8;
final int yAperture = 6;
final AffineTransform rotate = AffineTransform.getRotateInstance(this.angle);
Point2D middle = new Point2D.Double(0, 0);
Point2D left = new Point2D.Double(0, -yAperture);
Point2D base = new Point2D.Double(-xWing, 0);
Point2D lineTop = new Point2D.Double(-xWing-2, -lineHeight);
Point2D lineBottom = new Point2D.Double(-xWing-2, lineHeight);
Point2D right = new Point2D.Double(0, yAperture);
rotate.transform(left, left);
rotate.transform(base, base);
rotate.transform(right, right);
rotate.transform(lineTop, lineTop);
rotate.transform(lineBottom, lineBottom);
drawLine(ug, contact.getX(), contact.getY(), base, left);
drawLine(ug, contact.getX(), contact.getY(), base, right);
drawLine(ug, contact.getX(), contact.getY(), base, middle);
drawLine(ug, contact.getX(), contact.getY(), lineTop, lineBottom);
}
代码示例来源:origin: plantuml/plantuml
public void drawU(UGraphic ug) {
final int xWing = 4;
final AffineTransform rotate = AffineTransform.getRotateInstance(this.angle);
Point2D middle = new Point2D.Double(0, 0);
Point2D base = new Point2D.Double(-xWing-radius-3, 0);
Point2D circleBase = new Point2D.Double(-xWing-radius-3, 0);
Point2D lineTop = new Point2D.Double(-xWing, -lineHeight);
Point2D lineBottom = new Point2D.Double(-xWing, lineHeight);
rotate.transform(lineTop, lineTop);
rotate.transform(lineBottom, lineBottom);
rotate.transform(base, base);
rotate.transform(circleBase, circleBase);
drawLine(ug, contact.getX(), contact.getY(), base, middle);
ug.apply(new UTranslate(contact.getX()+circleBase.getX()-radius, contact.getY()+circleBase.getY()-radius)).draw(new UEllipse(2*radius, 2*radius));
drawLine(ug, contact.getX(), contact.getY(), lineTop, lineBottom);
}
代码示例来源:origin: biezhi/wechat-api
@Override
public LuminanceSource rotateCounterClockwise45() {
int width = getWidth();
int height = getHeight();
int oldCenterX = left + width / 2;
int oldCenterY = top + height / 2;
// Rotate 45 degrees counterclockwise.
AffineTransform transform = AffineTransform.getRotateInstance(MINUS_45_IN_RADIANS, oldCenterX, oldCenterY);
int sourceDimension = Math.max(image.getWidth(), image.getHeight());
BufferedImage rotatedImage = new BufferedImage(sourceDimension, sourceDimension, BufferedImage.TYPE_BYTE_GRAY);
// Draw the original image into rotated, via transformation
Graphics2D g = rotatedImage.createGraphics();
g.drawImage(image, transform, null);
g.dispose();
int halfDimension = Math.max(width, height) / 2;
int newLeft = Math.max(0, oldCenterX - halfDimension);
int newTop = Math.max(0, oldCenterY - halfDimension);
int newRight = Math.min(sourceDimension - 1, oldCenterX + halfDimension);
int newBottom = Math.min(sourceDimension - 1, oldCenterY + halfDimension);
return new BufferedImageLuminanceSource(rotatedImage, newLeft, newTop, newRight - newLeft, newBottom - newTop);
}
代码示例来源:origin: plantuml/plantuml
public void drawU(UGraphic ug) {
final int xWing = 8;
final int yAperture = 6;
final AffineTransform rotate = AffineTransform.getRotateInstance(this.angle);
Point2D middle = new Point2D.Double(0, 0);
Point2D left = new Point2D.Double(0, -yAperture);
Point2D base = new Point2D.Double(-xWing, 0);
Point2D right = new Point2D.Double(0, yAperture);
Point2D circleBase = new Point2D.Double(-xWing-radius-2, 0);
rotate.transform(left, left);
rotate.transform(base, base);
rotate.transform(right, right);
rotate.transform(circleBase, circleBase);
drawLine(ug, contact.getX(), contact.getY(), base, left);
drawLine(ug, contact.getX(), contact.getY(), base, right);
drawLine(ug, contact.getX(), contact.getY(), base, middle);
ug.apply(new UTranslate(contact.getX()+circleBase.getX()-radius, contact.getY()+circleBase.getY()-radius)).draw(new UEllipse(2*radius, 2*radius));
}
代码示例来源:origin: plantuml/plantuml
private static AffineTransformation createSimple(String value) {
Matcher m = rotate.matcher(StringUtils.trin(value));
if (m.find()) {
final double angle = Double.parseDouble(m.group(1));
return new AffineTransformation(AffineTransform.getRotateInstance(angle * Math.PI / 180.0));
}
m = shear.matcher(value);
if (m.find()) {
final double shx = Double.parseDouble(m.group(1));
final double shy = Double.parseDouble(m.group(2));
return new AffineTransformation(AffineTransform.getShearInstance(shx, shy));
}
m = translate.matcher(value);
if (m.find()) {
final double tx = Double.parseDouble(m.group(1));
final double ty = Double.parseDouble(m.group(2));
return new AffineTransformation(AffineTransform.getTranslateInstance(tx, ty));
}
m = scale.matcher(value);
if (m.find()) {
final double scalex = Double.parseDouble(m.group(1));
final double scaley = Double.parseDouble(m.group(2));
return new AffineTransformation(AffineTransform.getScaleInstance(scalex, scaley));
}
m = color.matcher(value);
if (m.find()) {
return new AffineTransformation(new AffineTransform());
}
return null;
}
代码示例来源:origin: stackoverflow.com
int len = (int) Math.sqrt(dx*dx + dy*dy);
AffineTransform at = AffineTransform.getTranslateInstance(x1, y1);
at.concatenate(AffineTransform.getRotateInstance(angle));
g.transform(at);
代码示例来源:origin: org.apache.poi/poi-ooxml
AffineTransform at = AffineTransform.getRotateInstance(-c);
double[] pts = new double[] { x0, y0, x, y, a, b };
at.transform(pts, 0, pts, 0, 3);
代码示例来源:origin: org.apache.poi/poi
@SuppressWarnings("WeakerAccess")
protected Paint createLinearGradientPaint(GradientPaint fill, Graphics2D graphics) {
// TODO: we need to find the two points for gradient - the problem is, which point at the outline
// do you take? My solution would be to apply the gradient rotation to the shape in reverse
// and then scan the shape for the largest possible horizontal distance
double angle = fill.getGradientAngle();
if (!fill.isRotatedWithShape()) {
angle -= shape.getRotation();
}
Rectangle2D anchor = DrawShape.getAnchor(graphics, shape);
AffineTransform at = AffineTransform.getRotateInstance(Math.toRadians(angle), anchor.getCenterX(), anchor.getCenterY());
double diagonal = Math.sqrt(Math.pow(anchor.getWidth(),2) + Math.pow(anchor.getHeight(),2));
final Point2D p1 = at.transform(new Point2D.Double(anchor.getCenterX() - diagonal / 2, anchor.getCenterY()), null);
final Point2D p2 = at.transform(new Point2D.Double(anchor.getMaxX(), anchor.getCenterY()), null);
// snapToAnchor(p1, anchor);
// snapToAnchor(p2, anchor);
// gradient paint on the same point throws an exception ... and doesn't make sense
return (p1.equals(p2)) ? null : safeFractions((f,c)->new LinearGradientPaint(p1,p2,f,c), fill);
}
代码示例来源:origin: org.apache.poi/poi
trans.concatenate(AffineTransform.getRotateInstance(style.getRotation()*2.0*Math.PI/360.0));
trans.concatenate(
AffineTransform.getScaleInstance(1, fontHeightMultiple)
代码示例来源:origin: org.apache.poi/poi-ooxml
180, x0 < x ? 180 : -180, Arc2D.OPEN);
path.append(AffineTransform.getRotateInstance(rotate, x0, y0)
.createTransformedShape(arc), true);
代码示例来源:origin: plantuml/plantuml
final AffineTransform t = AffineTransform.getRotateInstance(Math.toRadians(angle), arc.getCenterX(),
arc.getCenterY());
final Shape s = t.createTransformedShape(arc);
代码示例来源:origin: haraldk/TwelveMonkeys
AffineTransform.getRotateInstance(pAng, width / 2.0, height / 2.0);
代码示例来源: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: haraldk/TwelveMonkeys
@Test
public void testGetPoint2D() {
AffineTransform rotateInstance = AffineTransform.getRotateInstance(2.1);
BufferedImageOp original = new java.awt.image.AffineTransformOp(rotateInstance, null);
BufferedImageOp fallback = new com.twelvemonkeys.image.AffineTransformOp(rotateInstance, null);
Point2D point = new Point2D.Double(39.7, 42.91);
assertEquals(original.getPoint2D(point, null), fallback.getPoint2D(point, null));
}
代码示例来源:origin: geotools/geotools
final Envelope world = new Envelope(0, 50, 0, -100);
final AffineTransform worldToScreen =
AffineTransform.getRotateInstance(Math.toRadians(90), 0, 0);
DefaultFeatureCollection fc = new DefaultFeatureCollection();
fc.add(createPoint(0, 0));
内容来源于网络,如有侵权,请联系作者删除!