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

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

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

AffineTransform.getScaleY介绍

暂无

代码示例

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

public final void addNotify () {
  super.addNotify();
  AffineTransform transform = getGraphicsConfiguration().getDefaultTransform();
  scaleX = (float)transform.getScaleX();
  scaleY = (float)transform.getScaleY();
  if (SharedLibraryLoader.isMac) {
    EventQueue.invokeLater(new Runnable() {
      public void run () {
        create();
      }
    });
  } else
    create();
}

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

writer.setValue(Double.toString(atx.getScaleX()));
writer.endNode();
writer.startNode("scaleY");
writer.setValue(Double.toString(atx.getScaleY()));
writer.endNode();
writer.startNode("shearX");
writer.setValue(Double.toString(atx.getShearX()));
writer.endNode();
writer.startNode("shearY");
writer.setValue(Double.toString(atx.getShearY()));
writer.endNode();
writer.startNode("translateX");
writer.setValue(Double.toString(atx.getTranslateX()));
writer.endNode();
writer.startNode("translateY");
writer.setValue(Double.toString(atx.getTranslateY()));
writer.endNode();
writer.endNode();

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

/**
 * Returns the magnitude of scale factor <var>y</var> by cancelling the effect of eventual flip
 * and rotation. This factor is calculated by <IMG
 * src="{@docRoot}/org/geotools/display/canvas/doc-files/scaleY0.png">.
 */
public static double getScaleY0(final AffineTransform tr) {
  final double scale = tr.getScaleY();
  final double shear = tr.getShearY();
  if (shear == 0) return Math.abs(scale); // Optimization for a very common case.
  if (scale == 0) return Math.abs(shear); // Not as common as above, but still common enough.
  return Math.hypot(scale, shear);
}

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

AffineTransform aTX = (AffineTransform) geometry.getGridToCRS();
writer.write("<geoTransform>");
writer.write("<scaleX>" + aTX.getScaleX() + "</scaleX>\n");
writer.write("<scaleY>" + aTX.getScaleY() + "</scaleY>\n");
writer.write("<shearX>" + aTX.getShearX() + "</shearX>\n");
writer.write("<shearY>" + aTX.getShearY() + "</shearY>\n");
writer.write("<translateX>" + aTX.getTranslateX() + "</translateX>\n");
writer.write("<translateY>" + aTX.getTranslateY() + "</translateY>\n");
writer.write("</geoTransform>\n");

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

public final void addNotify () {
  super.addNotify();
  AffineTransform transform = getGraphicsConfiguration().getDefaultTransform();
  scaleX = (float)transform.getScaleX();
  scaleY = (float)transform.getScaleY();
  if (SharedLibraryLoader.isMac) {
    EventQueue.invokeLater(new Runnable() {
      public void run () {
        create();
      }
    });
  } else
    create();
}

代码示例来源:origin: apache/pdfbox

/**
 * Creates a matrix with the same elements as the given AffineTransform.
 * @param at
 */
public Matrix(AffineTransform at)
{
  single = new float[DEFAULT_SINGLE.length];
  System.arraycopy(DEFAULT_SINGLE, 0, single, 0, DEFAULT_SINGLE.length);
  single[0] = (float)at.getScaleX();
  single[1] = (float)at.getShearY();
  single[3] = (float)at.getShearX();
  single[4] = (float)at.getScaleY();
  single[6] = (float)at.getTranslateX();
  single[7] = (float)at.getTranslateY();
}

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

float scaleX = (float)transform.getScaleX(), scaleY = (float)transform.getScaleY();
Dimension size = new Dimension(Math.round(config.width / scaleX), Math.round(config.height / scaleY));
getContentPane().setPreferredSize(size);

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

/**
 * Sets this matrix to the specified affine transform.
 *
 * @since 2.3
 */
public void setMatrix(final AffineTransform transform) {
  mat.a11 = transform.getScaleX();
  mat.a12 = transform.getShearX();
  mat.a13 = transform.getTranslateX();
  mat.a21 = transform.getShearY();
  mat.a22 = transform.getScaleY();
  mat.a23 = transform.getTranslateY();
  mat.a31 = 0;
  mat.a32 = 0;
  mat.a33 = 1;
}

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

float scaleX = (float)transform.getScaleX(), scaleY = (float)transform.getScaleY();
Dimension size = new Dimension(Math.round(config.width / scaleX), Math.round(config.height / scaleY));
getContentPane().setPreferredSize(size);

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

/**
 * Returns {@code true} if this matrix is equals to the specified affine transform.
 *
 * @since 2.3
 */
public boolean equalsAffine(final AffineTransform transform) {
  return mat.a11 == transform.getScaleX()
      && mat.a12 == transform.getShearX()
      && mat.a13 == transform.getTranslateX()
      && mat.a21 == transform.getShearY()
      && mat.a22 == transform.getScaleY()
      && mat.a23 == transform.getTranslateY()
      && mat.a31 == 0
      && mat.a32 == 0
      && mat.a33 == 1;
}

代码示例来源:origin: apache/pdfbox

private void addImage(Image img)
{
  // for JDK9; see explanation in PagePane
  AffineTransform tx = GraphicsEnvironment.getLocalGraphicsEnvironment().
      getDefaultScreenDevice().getDefaultConfiguration().getDefaultTransform();
  label.setSize((int) Math.ceil(img.getWidth(null) / tx.getScaleX()), 
         (int) Math.ceil(img.getHeight(null) / tx.getScaleY()));
  label.setIcon(new HighResolutionImageIcon(img, label.getWidth(), label.getHeight()));
  label.revalidate();
}

代码示例来源:origin: apache/pdfbox

/**
 * Set the values of the matrix from the AffineTransform.
 *
 * @param af The transform to get the values from.
 * @deprecated Use the {@link #Matrix(AffineTransform)} constructor instead.
 */
@Deprecated
public void setFromAffineTransform( AffineTransform af )
{
  single[0] = (float)af.getScaleX();
  single[1] = (float)af.getShearY();
  single[3] = (float)af.getShearX();
  single[4] = (float)af.getScaleY();
  single[6] = (float)af.getTranslateX();
  single[7] = (float)af.getTranslateY();
}

代码示例来源:origin: apache/pdfbox

@Override
  protected void done()
  {
    try
    {
      BufferedImage image = get();
      // We cannot use "label.setIcon(new ImageIcon(get()))" here 
      // because of blurry upscaling in JDK9. Instead, the label is now created with 
      // a smaller size than the image to compensate that the
      // image is scaled up with some screen configurations (e.g. 125% on windows).
      // See PDFBOX-3665 for more sample code and discussion.
      label.setSize((int) Math.ceil(image.getWidth() / defaultTransform.getScaleX()), 
             (int) Math.ceil(image.getHeight() / defaultTransform.getScaleY()));
      label.setIcon(new HighResolutionImageIcon(image, label.getWidth(), label.getHeight()));
      label.setText(null);
    }
    catch (InterruptedException | ExecutionException e)
    {
      label.setText(e.getMessage());
      throw new RuntimeException(e);
    }
  }
}

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

/** Gets the derivative of this transform at a point. */
@Override
public Matrix derivative(final Point2D point) {
  final AffineTransform tr = new AffineTransform();
  getAffineTransform(point.getX(), point.getY(), tr);
  return new Matrix2(
      tr.getScaleX(), tr.getShearX(),
      tr.getShearY(), tr.getScaleY());
}

代码示例来源:origin: apache/pdfbox

boolean isScaledUp = pdImage.getWidth() < Math.round(at.getScaleX()) ||
           pdImage.getHeight() < Math.round(at.getScaleY());

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

/**
 * @param ls
 * @param at
 * @param generalize
 * @param maxDistance
 */
public void init(LineString ls, AffineTransform at, boolean generalize, float maxDistance) {
  if (at == null) at = new AffineTransform();
  _init(ls, at, generalize, maxDistance);
  xScale =
      (float)
          Math.sqrt(
              (at.getScaleX() * at.getScaleX())
                  + (at.getShearX() * at.getShearX()));
  yScale =
      (float)
          Math.sqrt(
              (at.getScaleY() * at.getScaleY())
                  + (at.getShearY() * at.getShearY()));
}

代码示例来源:origin: apache/pdfbox

float offsetY = page.getCropBox().getLowerLeftY();
float zoomScale = zoomMenu.getPageZoomScale();
float x = e.getX() / zoomScale * (float) defaultTransform.getScaleX();
float y = e.getY() / zoomScale * (float) defaultTransform.getScaleY();
int x1, y1;
switch ((RotationMenu.getRotationDegrees() + page.getRotation()) % 360)

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

/**
 * Constructs a 3&times;3 matrix from the specified affine transform.
 *
 * @param transform The matrix to copy.
 */
public GeneralMatrix(final AffineTransform transform) {
  mat =
      new DMatrixRMaj(
          3,
          3,
          true,
          new double[] {
            transform.getScaleX(),
            transform.getShearX(),
            transform.getTranslateX(),
            transform.getShearY(),
            transform.getScaleY(),
            transform.getTranslateY(),
            0,
            0,
            1
          });
  assert isAffine() : this;
}

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

Rectangle2D rect = tp.getAnchorRect();
AffineTransform at = graphics.getTransform();
double width = rect.getWidth() * at.getScaleX();
double height = rect.getHeight() * at.getScaleY();
Rectangle2D scaledRect = new Rectangle2D.Double(0, 0, width, height);
paint = new TexturePaint(image, scaledRect);

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

/**
   * Checks whether the matrix coefficients are close to whole numbers. If this is the case, these
   * coefficients will be rounded up to the nearest whole numbers. This rounding up is useful, for
   * example, for speeding up image displays. Above all, it is efficient when we know that a
   * matrix has a chance of being close to the similarity matrix.
   *
   * @param tr The matrix to round. Rounding will be applied in place.
   * @param tolerance The maximal departure from integers in order to allow rounding. It is
   *     typically a small number like {@code 1E-6}.
   * @since 2.3.1
   */
  public static void round(final AffineTransform tr, final double tolerance) {
    double r;
    final double m00, m01, m10, m11;
    if (Math.abs((m00 = Math.rint(r = tr.getScaleX())) - r) <= tolerance
        && Math.abs((m01 = Math.rint(r = tr.getShearX())) - r) <= tolerance
        && Math.abs((m11 = Math.rint(r = tr.getScaleY())) - r) <= tolerance
        && Math.abs((m10 = Math.rint(r = tr.getShearY())) - r) <= tolerance) {
      if ((m00 != 0 || m01 != 0) && (m10 != 0 || m11 != 0)) {
        double m02 = Math.rint(r = tr.getTranslateX());
        if (!(Math.abs(m02 - r) <= tolerance)) m02 = r;
        double m12 = Math.rint(r = tr.getTranslateY());
        if (!(Math.abs(m12 - r) <= tolerance)) m12 = r;
        tr.setTransform(m00, m10, m01, m11, m02, m12);
      }
    }
  }
}

相关文章