當前位置: 首頁>>代碼示例>>Java>>正文


Java AffineTransform.clone方法代碼示例

本文整理匯總了Java中java.awt.geom.AffineTransform.clone方法的典型用法代碼示例。如果您正苦於以下問題:Java AffineTransform.clone方法的具體用法?Java AffineTransform.clone怎麽用?Java AffineTransform.clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.geom.AffineTransform的用法示例。


在下文中一共展示了AffineTransform.clone方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: paintComponent

import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g;
    AffineTransform origXform = g2d.getTransform();
    AffineTransform newXform = (AffineTransform) (origXform.clone());
    //center of rotation is center of the panel
    int xRot = this.getWidth() / 2;
    int yRot = this.getHeight() / 2;
    newXform.rotate((2 * Math.PI) - currentAngle, xRot, yRot);
    g2d.setTransform(newXform);
    //draw image centered in panel
    int x = (getWidth() - image.getWidth(this)) / 2;
    int y = (getHeight() - image.getHeight(this)) / 2;
    g2d.drawImage(image, x, y, this);
    g2d.setTransform(origXform);
}
 
開發者ID:Esri,項目名稱:defense-solutions-proofs-of-concept,代碼行數:18,代碼來源:RotatableImagePanel.java

示例2: drawYLabel

import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
private void drawYLabel(Graphics2D chartGraphics) {
    if (yAxisLabel != null) {
        // Strings are drawn from the baseline position of the leftmost char.
        int yPosYAxisLabel = heatMapC.y + (yAxisLabelSize.width / 2);
        int xPosYAxisLabel = (margin / 2) + yAxisLabelAscent;

        chartGraphics.setFont(axisLabelsFont);
        chartGraphics.setColor(axisLabelColour);

        // Create 270 degree rotated transform.
        AffineTransform transform = chartGraphics.getTransform();
        AffineTransform originalTransform = (AffineTransform) transform.clone();
        transform.rotate(Math.toRadians(270), xPosYAxisLabel, yPosYAxisLabel);
        chartGraphics.setTransform(transform);

        // Draw string.
        chartGraphics.drawString(yAxisLabel, xPosYAxisLabel, yPosYAxisLabel);

        // Revert to original transform before rotation.
        chartGraphics.setTransform(originalTransform);
    }
}
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:23,代碼來源:HeatChart.java

示例3: AffineTransformOp

import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
/**
 * Constructs an <CODE>AffineTransformOp</CODE> given an affine transform.
 * The interpolation type is determined from the
 * <CODE>RenderingHints</CODE> object.  If the interpolation hint is
 * defined, it will be used. Otherwise, if the rendering quality hint is
 * defined, the interpolation type is determined from its value.  If no
 * hints are specified (<CODE>hints</CODE> is null),
 * the interpolation type is {@link #TYPE_NEAREST_NEIGHBOR
 * TYPE_NEAREST_NEIGHBOR}.
 *
 * @param xform The <CODE>AffineTransform</CODE> to use for the
 * operation.
 *
 * @param hints The <CODE>RenderingHints</CODE> object used to specify
 * the interpolation type for the operation.
 *
 * @throws ImagingOpException if the transform is non-invertible.
 * @see java.awt.RenderingHints#KEY_INTERPOLATION
 * @see java.awt.RenderingHints#KEY_RENDERING
 */
public AffineTransformOp(AffineTransform xform, RenderingHints hints){
    validateTransform(xform);
    this.xform = (AffineTransform) xform.clone();
    this.hints = hints;

    if (hints != null) {
        Object value = hints.get(hints.KEY_INTERPOLATION);
        if (value == null) {
            value = hints.get(hints.KEY_RENDERING);
            if (value == hints.VALUE_RENDER_SPEED) {
                interpolationType = TYPE_NEAREST_NEIGHBOR;
            }
            else if (value == hints.VALUE_RENDER_QUALITY) {
                interpolationType = TYPE_BILINEAR;
            }
        }
        else if (value == hints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR) {
            interpolationType = TYPE_NEAREST_NEIGHBOR;
        }
        else if (value == hints.VALUE_INTERPOLATION_BILINEAR) {
            interpolationType = TYPE_BILINEAR;
        }
        else if (value == hints.VALUE_INTERPOLATION_BICUBIC) {
            interpolationType = TYPE_BICUBIC;
        }
    }
    else {
        interpolationType = TYPE_NEAREST_NEIGHBOR;
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:51,代碼來源:AffineTransformOp.java

示例4: getStrike

import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
public FontStrike getStrike(Font font, AffineTransform devTx,
                            int aa, int fm) {

    /* Create the descriptor which is used to identify a strike
     * in the strike cache/map. A strike is fully described by
     * the attributes of this descriptor.
     */
    /* REMIND: generating garbage and doing computation here in order
     * to include pt size in the tx just for a lookup! Figure out a
     * better way.
     */
    double ptSize = font.getSize2D();
    AffineTransform glyphTx = (AffineTransform)devTx.clone();
    glyphTx.scale(ptSize, ptSize);
    if (font.isTransformed()) {
        glyphTx.concatenate(font.getTransform());
    }
    if (glyphTx.getTranslateX() != 0 || glyphTx.getTranslateY() != 0) {
        glyphTx.setTransform(glyphTx.getScaleX(),
                             glyphTx.getShearY(),
                             glyphTx.getShearX(),
                             glyphTx.getScaleY(),
                             0.0, 0.0);
    }
    FontStrikeDesc desc = new FontStrikeDesc(devTx, glyphTx,
                                             font.getStyle(), aa, fm);
    return getStrike(desc, false);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:29,代碼來源:Font2D.java

示例5: AffineTransformOp

import java.awt.geom.AffineTransform; //導入方法依賴的package包/類
/**
 * Constructs an {@code AffineTransformOp} given an affine transform.
 * The interpolation type is determined from the
 * {@code RenderingHints} object.  If the interpolation hint is
 * defined, it will be used. Otherwise, if the rendering quality hint is
 * defined, the interpolation type is determined from its value.  If no
 * hints are specified ({@code hints} is null),
 * the interpolation type is {@link #TYPE_NEAREST_NEIGHBOR
 * TYPE_NEAREST_NEIGHBOR}.
 *
 * @param xform The {@code AffineTransform} to use for the
 * operation.
 *
 * @param hints The {@code RenderingHints} object used to specify
 * the interpolation type for the operation.
 *
 * @throws ImagingOpException if the transform is non-invertible.
 * @see java.awt.RenderingHints#KEY_INTERPOLATION
 * @see java.awt.RenderingHints#KEY_RENDERING
 */
public AffineTransformOp(AffineTransform xform, RenderingHints hints){
    validateTransform(xform);
    this.xform = (AffineTransform) xform.clone();
    this.hints = hints;

    if (hints != null) {
        Object value = hints.get(RenderingHints.KEY_INTERPOLATION);
        if (value == null) {
            value = hints.get(RenderingHints.KEY_RENDERING);
            if (value == RenderingHints.VALUE_RENDER_SPEED) {
                interpolationType = TYPE_NEAREST_NEIGHBOR;
            }
            else if (value == RenderingHints.VALUE_RENDER_QUALITY) {
                interpolationType = TYPE_BILINEAR;
            }
        }
        else if (value == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR) {
            interpolationType = TYPE_NEAREST_NEIGHBOR;
        }
        else if (value == RenderingHints.VALUE_INTERPOLATION_BILINEAR) {
            interpolationType = TYPE_BILINEAR;
        }
        else if (value == RenderingHints.VALUE_INTERPOLATION_BICUBIC) {
            interpolationType = TYPE_BICUBIC;
        }
    }
    else {
        interpolationType = TYPE_NEAREST_NEIGHBOR;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:51,代碼來源:AffineTransformOp.java


注:本文中的java.awt.geom.AffineTransform.clone方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。