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

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

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

AffineTransform.setToIdentity介绍

暂无

代码示例

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

  1. // create an AffineTransform
  2. // and a triangle centered on (0,0) and pointing downward
  3. // somewhere outside Swing's paint loop
  4. AffineTransform tx = new AffineTransform();
  5. Line2D.Double line = new Line2D.Double(0,0,100,100);
  6. Polygon arrowHead = new Polygon();
  7. arrowHead.addPoint( 0,5);
  8. arrowHead.addPoint( -5, -5);
  9. arrowHead.addPoint( 5,-5);
  10. // [...]
  11. private void drawArrowHead(Graphics2D g2d) {
  12. tx.setToIdentity();
  13. double angle = Math.atan2(line.y2-line.y1, line.x2-line.x1);
  14. tx.translate(line.x2, line.y2);
  15. tx.rotate((angle-Math.PI/2d));
  16. Graphics2D g = (Graphics2D) g2d.create();
  17. g.setTransform(tx);
  18. g.fill(arrowHead);
  19. g.dispose();
  20. }

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

  1. public void drawDefaultSequenceFlowIndicator(Line2D.Double line) {
  2. double length = DEFAULT_INDICATOR_WIDTH;
  3. double halfOfLength = length / 2;
  4. double f = 8;
  5. Line2D.Double defaultIndicator = new Line2D.Double(-halfOfLength,
  6. 0,
  7. halfOfLength,
  8. 0);
  9. double angle = Math.atan2(line.y2 - line.y1,
  10. line.x2 - line.x1);
  11. double dx = f * Math.cos(angle);
  12. double dy = f * Math.sin(angle);
  13. double x1 = line.x1 + dx;
  14. double y1 = line.y1 + dy;
  15. AffineTransform transformation = new AffineTransform();
  16. transformation.setToIdentity();
  17. transformation.translate(x1,
  18. y1);
  19. transformation.rotate((angle - 3 * Math.PI / 4));
  20. AffineTransform originalTransformation = g.getTransform();
  21. g.setTransform(transformation);
  22. g.draw(defaultIndicator);
  23. g.setTransform(originalTransformation);
  24. }

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

  1. transformation.setToIdentity();
  2. double angle = Math.atan2(line.y2 - line.y1,
  3. line.x2 - line.x1);

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

  1. transformation.setToIdentity();
  2. transformation.rotate(270 * Math.PI / 180);

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

  1. public void drawConditionalSequenceFlowIndicator(Line2D.Double line) {
  2. int horizontal = (int) (CONDITIONAL_INDICATOR_WIDTH * 0.7);
  3. int halfOfHorizontal = horizontal / 2;
  4. int halfOfVertical = CONDITIONAL_INDICATOR_WIDTH / 2;
  5. Polygon conditionalIndicator = new Polygon();
  6. conditionalIndicator.addPoint(0,
  7. 0);
  8. conditionalIndicator.addPoint(-halfOfHorizontal,
  9. halfOfVertical);
  10. conditionalIndicator.addPoint(0,
  11. CONDITIONAL_INDICATOR_WIDTH);
  12. conditionalIndicator.addPoint(halfOfHorizontal,
  13. halfOfVertical);
  14. AffineTransform transformation = new AffineTransform();
  15. transformation.setToIdentity();
  16. double angle = Math.atan2(line.y2 - line.y1,
  17. line.x2 - line.x1);
  18. transformation.translate(line.x1,
  19. line.y1);
  20. transformation.rotate((angle - Math.PI / 2d));
  21. AffineTransform originalTransformation = g.getTransform();
  22. g.setTransform(transformation);
  23. g.draw(conditionalIndicator);
  24. Paint originalPaint = g.getPaint();
  25. g.setPaint(CONDITIONAL_INDICATOR_COLOR);
  26. g.fill(conditionalIndicator);
  27. g.setPaint(originalPaint);
  28. g.setTransform(originalTransformation);
  29. }

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

  1. @Override
  2. public void reset() {
  3. this.affineTransform.setToIdentity();
  4. }

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

  1. /** Checks for {@linkplain #checkPermission permission} before setting this transform. */
  2. @Override
  3. public void setToIdentity() {
  4. checkPermission();
  5. super.setToIdentity();
  6. }

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

  1. transform.setToIdentity();

代码示例来源:origin: dermotte/LIRE

  1. @Override
  2. public boolean fit(PointMatch[] min_matches) {
  3. PointMatch m1 = min_matches[0];
  4. float[] m1_p1 = m1.getP1().getL();
  5. float[] m1_p2 = m1.getP2().getL();
  6. float tx = m1_p1[0] - m1_p2[0];
  7. float ty = m1_p1[1] - m1_p2[1];
  8. affine.setToIdentity();
  9. affine.translate(tx, ty);
  10. return true;
  11. }

代码示例来源:origin: dermotte/LIRE

  1. @Override
  2. public boolean fit(PointMatch[] min_matches) {
  3. PointMatch m1 = min_matches[0];
  4. float[] m1_p1 = m1.getP1().getL();
  5. float[] m1_p2 = m1.getP2().getL();
  6. float tx = m1_p1[0] - m1_p2[0];
  7. float ty = m1_p1[1] - m1_p2[1];
  8. affine.setToIdentity();
  9. affine.translate(tx, ty);
  10. return true;
  11. }

代码示例来源:origin: dermotte/LIRE

  1. public void minimize(Collection<PointMatch> matches) {
  2. // center of mass:
  3. float xo1 = 0, yo1 = 0;
  4. float xo2 = 0, yo2 = 0;
  5. int length = matches.size();
  6. for (PointMatch m : matches) {
  7. float[] m_p1 = m.getP1().getL();
  8. float[] m_p2 = m.getP2().getW();
  9. xo1 += m_p1[0];
  10. yo1 += m_p1[1];
  11. xo2 += m_p2[0];
  12. yo2 += m_p2[1];
  13. }
  14. xo1 /= length;
  15. yo1 /= length;
  16. xo2 /= length;
  17. yo2 /= length;
  18. float dx = xo1 - xo2; // reversed, because the second will be moved relative to the first
  19. float dy = yo1 - yo2;
  20. affine.setToIdentity();
  21. affine.translate(-dx, -dy);
  22. }

代码示例来源:origin: dermotte/LIRE

  1. public void minimize(Collection<PointMatch> matches) {
  2. // center of mass:
  3. float xo1 = 0, yo1 = 0;
  4. float xo2 = 0, yo2 = 0;
  5. int length = matches.size();
  6. for (PointMatch m : matches) {
  7. float[] m_p1 = m.getP1().getL();
  8. float[] m_p2 = m.getP2().getW();
  9. xo1 += m_p1[0];
  10. yo1 += m_p1[1];
  11. xo2 += m_p2[0];
  12. yo2 += m_p2[1];
  13. }
  14. xo1 /= length;
  15. yo1 /= length;
  16. xo2 /= length;
  17. yo2 /= length;
  18. float dx = xo1 - xo2; // reversed, because the second will be moved relative to the first
  19. float dy = yo1 - yo2;
  20. affine.setToIdentity();
  21. affine.translate(-dx, -dy);
  22. }

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

  1. g2d.drawPolygon(p1);
  2. g2d.drawPolygon(p2);
  3. at.setToIdentity();
  4. at.translate(w / 2, h / 2);
  5. at.scale(scale, scale);

代码示例来源:origin: dermotte/LIRE

  1. affine.setToIdentity();
  2. affine.rotate(-angle, xo2, yo2);
  3. affine.translate(-dx, -dy);

代码示例来源:origin: dermotte/LIRE

  1. affine.setToIdentity();
  2. affine.rotate(-angle, xo2, yo2);
  3. affine.translate(-dx, -dy);

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

  1. while (Math.abs(currOffset) <= labelOffset * 2 && !painted) {
  2. tx.setToIdentity();
  3. Rectangle2D labelEnvelope;
  4. double maxAngleChange = 0;

代码示例来源:origin: org.icepdf.os/icepdf-core

  1. private static AffineTransform createRotation(Point2D point,
  2. Point2D startOfLine,
  3. Point2D endOfLine) {
  4. AffineTransform tx = new AffineTransform();
  5. Line2D.Double line = new Line2D.Double(startOfLine, endOfLine);
  6. tx.setToIdentity();
  7. double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1);
  8. tx.translate(point.getX(), point.getY());
  9. tx.rotate(angle - (Math.PI / 2));
  10. return tx;
  11. }

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

  1. while (Math.abs(currOffset) <= (labelOffset * 2) && !painted) {
  2. tx.setToIdentity();
  3. double maxAngleChange = 0;
  4. boolean curved = false;

代码示例来源:origin: net.sf.jung/jung-visualization

  1. public void setToIdentity() {
  2. inverse = null;
  3. transform.setToIdentity();
  4. fireStateChanged();
  5. }
  6. }

代码示例来源:origin: jrtom/jung

  1. /**
  2. * setter for the scale fires a PropertyChangeEvent with the AffineTransforms representing the
  3. * previous and new values for scale and offset
  4. *
  5. * @param scalex the amount to scale in the x direction
  6. * @param scaley the amount to scale in the y direction
  7. * @param from the point to transform
  8. */
  9. public void setScale(double scalex, double scaley, Point2D from) {
  10. transform.setToIdentity();
  11. scale(scalex, scaley, from);
  12. }

相关文章