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

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

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

AffineTransform.concatenate介绍

暂无

代码示例

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

private AffineTransformation compose(AffineTransformation other) {
  final AffineTransform tmp = new AffineTransform(this.affineTransform);
  tmp.concatenate(other.affineTransform);
  return new AffineTransformation(tmp);
}

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

public static BufferedImage process(BufferedImage im) {
  Log.info("Rotation");
  final BufferedImage newIm = new BufferedImage(im.getHeight(), im.getWidth(), BufferedImage.TYPE_INT_RGB);
  final Graphics2D g2d = newIm.createGraphics();
  final AffineTransform at = new AffineTransform(0, 1, 1, 0, 0, 0);
  at.concatenate(new AffineTransform(-1, 0, 0, 1, im.getWidth(), 0));
  g2d.setTransform(at);
  g2d.drawImage(im, 0, 0, null);
  g2d.dispose();
  return newIm;
}

代码示例来源:origin: org.apache.poi/poi

AffineTransform trans = new AffineTransform();
trans.concatenate(AffineTransform.getRotateInstance(style.getRotation()*2.0*Math.PI/360.0));
trans.concatenate(
AffineTransform.getScaleInstance(1, fontHeightMultiple)
);

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

public MathTransform getOriginalGridToWorld(PixelInCell pixInCell) {
  if (homogeneousCoverages) {
    return delegate.getOriginalGridToWorld(referenceName, pixInCell);
  }
  final GridToEnvelopeMapper geMapper =
      new GridToEnvelopeMapper(getOriginalGridRange(), getOriginalEnvelope());
  geMapper.setPixelAnchor(PixelInCell.CELL_CENTER);
  MathTransform2D coverageGridToWorld2D = (MathTransform2D) geMapper.createTransform();
  // we do not have to change the pixel datum
  if (pixInCell == PixelInCell.CELL_CENTER) return coverageGridToWorld2D;
  // we do have to change the pixel datum
  if (coverageGridToWorld2D instanceof AffineTransform) {
    final AffineTransform tr = new AffineTransform((AffineTransform) coverageGridToWorld2D);
    tr.concatenate(AffineTransform.getTranslateInstance(-0.5, -0.5));
    return ProjectiveTransform.create(tr);
  }
  throw new IllegalStateException("This reader's grid to world transform is invalid!");
}

代码示例来源: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.quadrantRotate(1);
      txs2.translate(-centerX, -centerY);
      txs2.concatenate(tx);
      txs2.concatenate(tx);
    final AffineTransform txs2 = new AffineTransform();
    txs2.translate(centerX, centerY);

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

public void skew(double kx, double ky) {
  kx = Math.PI * kx / 180.0;
  ky = Math.PI * ky / 180.0;
  affineTransform.concatenate(new AffineTransform(1, Math.tan(ky), -Math.tan(kx), 1, 0, 0));
}

代码示例来源:origin: com.google.gwt/gwt-servlet

public AffineTransform transform() {
 AffineTransform toReturn = new AffineTransform();
 // Translate
 toReturn.translate(left, top);
 // Scale
 assert !(height > 0 ^ width > 0);
 if (height > 0) {
  toReturn.scale((double) height / intrinsicHeight, (double) width
    / intrinsicWidth);
 }
 // Use the base concatenation
 toReturn.concatenate(transform);
 assert checkTransform(toReturn);
 return toReturn;
}

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

public void paintIcon(Component c, Graphics g, int x, int y) {
    Graphics2D g2d = (Graphics2D) g;
    AffineTransform tmp = g2d.getTransform();
    Object oldInterpolation = g2d.getRenderingHint(RenderingHints.KEY_INTERPOLATION);
    if (oldInterpolation == null) {
      oldInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
    }
    try {
      AffineTransform at = new AffineTransform(tmp);
      at.concatenate(this.at);
      g2d.setTransform(at);
      g2d.setRenderingHint(
          RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
      icon.paintIcon(c, g2d, 0, 0);
    } finally {
      g2d.setTransform(tmp);
      g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, oldInterpolation);
    }
  }
}

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

/**
 * Retrieves the original grid to world transformation for this {@link
 * AbstractGridCoverage2DReader}.
 *
 * @param pixInCell specifies the datum of the transformation we want.
 * @return the original grid to world transformation
 */
public static MathTransform getOriginalGridToWorld(
    MathTransform raster2Model, final PixelInCell pixInCell) {
  // we do not have to change the pixel datum
  if (pixInCell == PixelInCell.CELL_CENTER) return raster2Model;
  // we do have to change the pixel datum
  if (raster2Model instanceof AffineTransform) {
    final AffineTransform tr = new AffineTransform((AffineTransform) raster2Model);
    tr.concatenate(AffineTransform.getTranslateInstance(-0.5, -0.5));
    return ProjectiveTransform.create(tr);
  }
  if (raster2Model instanceof IdentityTransform) {
    final AffineTransform tr = new AffineTransform(1, 0, 0, 1, 0, 0);
    tr.concatenate(AffineTransform.getTranslateInstance(-0.5, -0.5));
    return ProjectiveTransform.create(tr);
  }
  throw new IllegalStateException("This grid to world transform is invalud!");
}

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

final double scaleY = originalGridRange.getSpan(1) / (1.0 * ssHeight);
final AffineTransform tempRaster2Model =
    new AffineTransform((AffineTransform) raster2Model);
AffineTransform scale = new AffineTransform(scaleX, 0, 0, scaleY, 0, 0);
if (!XAffineTransform.isIdentity(scale, EPS)) {
  tempRaster2Model.concatenate(CoverageUtilities.CENTER_TO_CORNER);
  tempRaster2Model.concatenate(scale);
  tempRaster2Model.concatenate(CoverageUtilities.CORNER_TO_CENTER);

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

/**
 * Returns a List of AffineTransformations objects to use for backward mapping the
 * destination image pixels into each source image
 *
 * @param list
 * @param index
 * @return
 */
public List<AffineTransform> getTransformationList(List<GridGeometry2D> list, int index) {
  // Creation of a List of Transformations
  List<AffineTransform> transforms = new ArrayList<AffineTransform>();
  // Get the g2w transform to use for the remapping
  AffineTransform g2w = getGridToCRS2D(list, index);
  // Get all the other w2g transforms to concatenate for the remapping
  for (GridGeometry2D gg2D : list) {
    AffineTransform tr = new AffineTransform(getAffineTransform(gg2D, false));
    tr.concatenate(g2w);
    transforms.add(tr);
  }
  // Returns the transformations list
  return transforms;
}

代码示例来源: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: stackoverflow.com

AffineTransform stretch = new AffineTransform();
int w = 640; // image width
int h = 200; // image height
  g.drawString(s, 0, (i*f)+f);
  stretch.concatenate(
      AffineTransform.getScaleInstance(1.18, 1d));
  g.setTransform(stretch);

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

public MathTransform getOriginalGridToWorld(final PixelInCell pixInCell) {
    synchronized (this) {
      if (coverageGridToWorld2D == null) {
        final GridToEnvelopeMapper geMapper =
            new GridToEnvelopeMapper(gridEnvelope, coverageEnvelope);
        geMapper.setPixelAnchor(PixelInCell.CELL_CENTER);
        coverageGridToWorld2D = (MathTransform2D) geMapper.createTransform();
      }
    }
    // we do not have to change the pixel datum
    if (pixInCell == PixelInCell.CELL_CENTER) return coverageGridToWorld2D;
    // we do have to change the pixel datum
    if (coverageGridToWorld2D instanceof AffineTransform) {
      final AffineTransform tr =
          new AffineTransform((AffineTransform) coverageGridToWorld2D);
      tr.concatenate(AffineTransform.getTranslateInstance(-0.5, -0.5));
      return ProjectiveTransform.create(tr);
    }
    if (coverageGridToWorld2D instanceof IdentityTransform) {
      final AffineTransform tr = new AffineTransform(1, 0, 0, 1, 0, 0);
      tr.concatenate(AffineTransform.getTranslateInstance(-0.5, -0.5));
      return ProjectiveTransform.create(tr);
    }
    throw new IllegalStateException("This reader's grid to world transform is invalud!");
  }
}

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

/**
 * Sets up the affine transform
 *
 * <p>((Taken from the old LiteRenderer))
 *
 * @param mapExtent the map extent
 * @param paintArea the size of the rendering output area
 * @return a transform that maps from real world coordinates to the screen
 * @deprecated Uses the alternative based on <code>ReferencedEnvelope</code> that doe not assume
 *     anything on axes order.
 */
public static AffineTransform worldToScreenTransform(Envelope mapExtent, Rectangle paintArea) {
  double scaleX = paintArea.getWidth() / mapExtent.getWidth();
  double scaleY = paintArea.getHeight() / mapExtent.getHeight();
  double tx = -mapExtent.getMinX() * scaleX;
  double ty = (mapExtent.getMinY() * scaleY) + paintArea.getHeight();
  AffineTransform at = new AffineTransform(scaleX, 0.0d, 0.0d, -scaleY, tx, ty);
  AffineTransform originTranslation =
      AffineTransform.getTranslateInstance(paintArea.x, paintArea.y);
  originTranslation.concatenate(at);
  return originTranslation != null ? originTranslation : at;
}

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

@Override
public MathTransform getOriginalGridToWorld(String coverageName, PixelInCell pixInCell) {
  coverageName = checkUnspecifiedCoverage(coverageName);
  try {
    final CoverageSource source = getGridCoverageSource(coverageName);
    VariableAdapter.UnidataSpatialDomain spatialDomain =
        (UnidataSpatialDomain) source.getSpatialDomain();
    MathTransform2D gridToWorld = spatialDomain.getGridToWorldTransform(null);
    if (pixInCell == PixelInCell.CELL_CENTER) {
      return gridToWorld;
    }
    // we do have to change the pixel datum
    if (gridToWorld instanceof AffineTransform) {
      final AffineTransform tr = new AffineTransform((AffineTransform) gridToWorld);
      tr.concatenate(AffineTransform.getTranslateInstance(-0.5, -0.5));
      return ProjectiveTransform.create(tr);
    }
    if (gridToWorld instanceof IdentityTransform) {
      final AffineTransform tr = new AffineTransform(1, 0, 0, 1, 0, 0);
      tr.concatenate(AffineTransform.getTranslateInstance(-0.5, -0.5));
      return ProjectiveTransform.create(tr);
    }
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  throw new IllegalStateException("This reader's grid to world transform is invalid!");
}

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

/**
 * Returns an iterator object that iterates along the <code>Shape</code> boundary and provides
 * access to the geometry of the <code>Shape</code> outline.
 */
public PathIterator getPathIterator(AffineTransform at) {
  if (!isIdentity()) {
    if (at == null || at.isIdentity()) {
      return shape.getPathIterator(this);
    }
    at = new AffineTransform(at);
    at.concatenate(this);
  }
  return shape.getPathIterator(at);
}

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

/**
 * Returns an iterator object that iterates along the <code>Shape</code> boundary and provides
 * access to a flattened view of the <code>Shape</code> outline geometry.
 */
public PathIterator getPathIterator(AffineTransform at, final double flatness) {
  if (!isIdentity()) {
    if (at == null || at.isIdentity()) {
      return shape.getPathIterator(this, flatness);
    }
    at = new AffineTransform(at);
    at.concatenate(this);
  }
  return shape.getPathIterator(at, flatness);
}

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

g2.setClip(r);
AffineTransform original = g2.getTransform();
AffineTransform at = new AffineTransform();
at.concatenate(original);
at.rotate(Math.toRadians( angleInDegrees ), x + cWidth, y + cHeight);
g2.setTransform(at);

代码示例来源:origin: haraldk/TwelveMonkeys

double cH = h / 2.0;
AffineTransform orientationTransform = new AffineTransform();
switch (orientation) {
  case TIFFBaseline.ORIENTATION_TOPLEFT:
transform.concatenate(orientationTransform);
AffineTransformOp transformOp = new AffineTransformOp(transform, null);
return transformOp.filter(input, null);

相关文章