当前位置: 首页>>代码示例>>Java>>正文


Java AffineTransform.getTranslateX方法代码示例

本文整理汇总了Java中java.awt.geom.AffineTransform.getTranslateX方法的典型用法代码示例。如果您正苦于以下问题:Java AffineTransform.getTranslateX方法的具体用法?Java AffineTransform.getTranslateX怎么用?Java AffineTransform.getTranslateX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.geom.AffineTransform的用法示例。


在下文中一共展示了AffineTransform.getTranslateX方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extractRotation

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
private static AffineTransform extractRotation(Point2D.Double pt,
    AffineTransform tx, boolean andTranslation) {

    tx.deltaTransform(pt, pt);
    AffineTransform rtx = AffineTransform.getRotateInstance(pt.x, pt.y);

    try {
        AffineTransform rtxi = rtx.createInverse();
        double dx = tx.getTranslateX();
        double dy = tx.getTranslateY();
        tx.preConcatenate(rtxi);
        if (andTranslation) {
            if (dx != 0 || dy != 0) {
                tx.setTransform(tx.getScaleX(), tx.getShearY(),
                                tx.getShearX(), tx.getScaleY(), 0, 0);
                rtx.setTransform(rtx.getScaleX(), rtx.getShearY(),
                                 rtx.getShearX(), rtx.getScaleY(), dx, dy);
            }
        }
    }
    catch (NoninvertibleTransformException e) {
        return null;
    }
    return rtx;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:AttributeValues.java

示例2: getStrike

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public FontStrike getStrike(Font font, FontRenderContext frc) {

        AffineTransform at = frc.getTransform();
        double ptSize = font.getSize2D();
        at.scale(ptSize, ptSize);
        if (font.isTransformed()) {
            at.concatenate(font.getTransform());
            if (at.getTranslateX() != 0 || at.getTranslateY() != 0) {
                at.setTransform(at.getScaleX(),
                                at.getShearY(),
                                at.getShearX(),
                                at.getScaleY(),
                                0.0, 0.0);
            }
        }
        int aa = FontStrikeDesc.getAAHintIntVal(this, font, frc);
        int fm = FontStrikeDesc.getFMHintIntVal(frc.getFractionalMetricsHint());
        FontStrikeDesc desc = new FontStrikeDesc(frc.getTransform(),
                                                 at, font.getStyle(),
                                                 aa, fm);
        return getStrike(desc, false);
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:Font2D.java

示例3: removeElement

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
/**
 * Will attempt to remove the specified element.
 *  The element will have coordinates, scale and rotation adjusted such that visually it will not look like anything has changed.
 * 
 * When an element is removed from a group, it will go back to the draw layer it was at before being added to the group.
 * Any changes to the draw layer that the element received while in the group will be discarded when it is
 * removed from the group.
 * 
 * @param e, the element to attempt to remove.
 * @return true if successful, otherwise false.
 */
public boolean removeElement(EZElement e) {
  if (children.contains(e)) {
    ArrayList<EZElement> ancestors = new ArrayList<EZElement>();
    EZElement temp;
    temp = e;
    while (temp.hasParent()) {
      ancestors.add(temp.getParent());
      temp = temp.getParent();
    }

    double fRotation, fScale, fcx, fcy;
    fRotation = 0;
    fScale = 1.0;
    for (EZElement anc : ancestors) {
      fRotation += anc.getRotation();
      fScale *= anc.getScale();
    }
    fcx = e.getBounds().getBounds().getCenterX();
    fcy = e.getBounds().getBounds().getCenterY();
    if(e instanceof EZGroup){
      AffineTransform at = EZElement.transformHelper(e);
      fcx = at.getTranslateX();
      fcy = at.getTranslateY();
    }
    
    e.removeParent();
    children.remove(e);
    e.translateTo(fcx, fcy);
    e.scaleTo(fScale);
    e.rotateTo(fRotation);
    return true;
  }
  System.out.println("Unable to remove specified Element of " +
    Thread.currentThread().getStackTrace()[2].getFileName() + ":" +
    Thread.currentThread().getStackTrace()[2].getLineNumber()
    );
  
  return false;
}
 
开发者ID:gcalica,项目名称:agar.io,代码行数:51,代码来源:EZ.java

示例4: transformConsumer

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public static PathConsumer2D
    transformConsumer(PathConsumer2D out,
                      AffineTransform at)
{
    if (at == null) {
        return out;
    }
    float Mxx = (float) at.getScaleX();
    float Mxy = (float) at.getShearX();
    float Mxt = (float) at.getTranslateX();
    float Myx = (float) at.getShearY();
    float Myy = (float) at.getScaleY();
    float Myt = (float) at.getTranslateY();
    if (Mxy == 0f && Myx == 0f) {
        if (Mxx == 1f && Myy == 1f) {
            if (Mxt == 0f && Myt == 0f) {
                return out;
            } else {
                return new TranslateFilter(out, Mxt, Myt);
            }
        } else {
            if (Mxt == 0f && Myt == 0f) {
                return new DeltaScaleFilter(out, Mxx, Myy);
            } else {
                return new ScaleFilter(out, Mxx, Myy, Mxt, Myt);
            }
        }
    } else if (Mxt == 0f && Myt == 0f) {
        return new DeltaTransformFilter(out, Mxx, Mxy, Myx, Myy);
    } else {
        return new TransformFilter(out, Mxx, Mxy, Mxt, Myx, Myy, Myt);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:TransformingPathConsumer2D.java

示例5: fillRectangle

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public void fillRectangle(SunGraphics2D sg2d,
                          double rx, double ry,
                          double rw, double rh)
{
    double px, py;
    double dx1, dy1, dx2, dy2;
    AffineTransform txform = sg2d.transform;
    dx1 = txform.getScaleX();
    dy1 = txform.getShearY();
    dx2 = txform.getShearX();
    dy2 = txform.getScaleY();
    px = rx * dx1 + ry * dx2 + txform.getTranslateX();
    py = rx * dy1 + ry * dy2 + txform.getTranslateY();
    dx1 *= rw;
    dy1 *= rw;
    dx2 *= rh;
    dy2 *= rh;
    if (adjustfill &&
        sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM &&
        sg2d.strokeHint != SunHints.INTVAL_STROKE_PURE)
    {
        double newx = normalize(px);
        double newy = normalize(py);
        dx1 = normalize(px + dx1) - newx;
        dy1 = normalize(py + dy1) - newy;
        dx2 = normalize(px + dx2) - newx;
        dy2 = normalize(py + dy2) - newy;
        px = newx;
        py = newy;
    }
    outrenderer.fillParallelogram(sg2d, rx, ry, rx+rw, ry+rh,
                                  px, py, dx1, dy1, dx2, dy2);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:PixelToParallelogramConverter.java

示例6: isIntegerTranslation

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
/**
 * Returns true if the given AffineTransform is an integer
 * translation.
 */
private static boolean isIntegerTranslation(AffineTransform xform) {
    if (xform.isIdentity()) {
        return true;
    }
    if (xform.getType() == AffineTransform.TYPE_TRANSLATION) {
        double tx = xform.getTranslateX();
        double ty = xform.getTranslateY();
        return (tx == (int)tx && ty == (int)ty);
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:SunGraphics2D.java

示例7: TexturePaintContext

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
TexturePaintContext(ColorModel cm, AffineTransform xform,
                    int bWidth, int bHeight, int maxw) {
    this.colorModel = getInternedColorModel(cm);
    this.bWidth = bWidth;
    this.bHeight = bHeight;
    this.maxWidth = maxw;

    try {
        xform = xform.createInverse();
    } catch (NoninvertibleTransformException e) {
        xform.setToScale(0, 0);
    }
    this.incXAcross = mod(xform.getScaleX(), bWidth);
    this.incYAcross = mod(xform.getShearY(), bHeight);
    this.incXDown = mod(xform.getShearX(), bWidth);
    this.incYDown = mod(xform.getScaleY(), bHeight);
    this.xOrg = xform.getTranslateX();
    this.yOrg = xform.getTranslateY();
    this.colincx = (int) incXAcross;
    this.colincy = (int) incYAcross;
    this.colincxerr = fractAsInt(incXAcross);
    this.colincyerr = fractAsInt(incYAcross);
    this.rowincx = (int) incXDown;
    this.rowincy = (int) incYDown;
    this.rowincxerr = fractAsInt(incXDown);
    this.rowincyerr = fractAsInt(incYDown);

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:TexturePaintContext.java

示例8: isIdentity

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public static boolean isIdentity(AffineTransform at) {
    return (at.getScaleX() == 1 &&
            at.getScaleY() == 1 &&
            at.getShearX() == 0 &&
            at.getShearY() == 0 &&
            at.getTranslateX() == 0 &&
            at.getTranslateY() == 0);

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:GetTypeOptimization.java

示例9: drawRectangle

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public void drawRectangle(SunGraphics2D sg2d,
                          double rx, double ry,
                          double rw, double rh,
                          double lw)
{
    double px, py;
    double dx1, dy1, dx2, dy2;
    double lw1, lw2;
    AffineTransform txform = sg2d.transform;
    dx1 = txform.getScaleX();
    dy1 = txform.getShearY();
    dx2 = txform.getShearX();
    dy2 = txform.getScaleY();
    px = rx * dx1 + ry * dx2 + txform.getTranslateX();
    py = rx * dy1 + ry * dy2 + txform.getTranslateY();
    // lw along dx1,dy1 scale by transformed length of dx2,dy2 vectors
    // and vice versa
    lw1 = len(dx1, dy1) * lw;
    lw2 = len(dx2, dy2) * lw;
    dx1 *= rw;
    dy1 *= rw;
    dx2 *= rh;
    dy2 *= rh;
    if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM &&
        sg2d.strokeHint != SunHints.INTVAL_STROKE_PURE)
    {
        double newx = normalize(px);
        double newy = normalize(py);
        dx1 = normalize(px + dx1) - newx;
        dy1 = normalize(py + dy1) - newy;
        dx2 = normalize(px + dx2) - newx;
        dy2 = normalize(py + dy2) - newy;
        px = newx;
        py = newy;
    }
    lw1 = Math.max(lw1, minPenSize);
    lw2 = Math.max(lw2, minPenSize);
    double len1 = len(dx1, dy1);
    double len2 = len(dx2, dy2);
    if (lw1 >= len1 || lw2 >= len2) {
        // The line widths are large enough to consume the
        // entire hole in the middle of the parallelogram
        // so we can just fill the outer parallelogram.
        fillOuterParallelogram(sg2d,
                               rx, ry, rx+rw, ry+rh,
                               px, py, dx1, dy1, dx2, dy2,
                               len1, len2, lw1, lw2);
    } else {
        outrenderer.drawParallelogram(sg2d,
                                      rx, ry, rx+rw, ry+rh,
                                      px, py, dx1, dy1, dx2, dy2,
                                      lw1 / len1, lw2 / len2);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:55,代码来源:PixelToParallelogramConverter.java

示例10: paintDoubleBufferedFPScales

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
private void paintDoubleBufferedFPScales(JComponent c, Image image,
                                         Graphics g, int clipX, int clipY,
                                         int clipW, int clipH) {
    Graphics osg = image.getGraphics();
    Graphics2D g2d = (Graphics2D) g;
    Graphics2D osg2d = (Graphics2D) osg;

    AffineTransform identity = new AffineTransform();
    int bw = Math.min(clipW, image.getWidth(null));
    int bh = Math.min(clipH, image.getHeight(null));
    int x, y, maxx, maxy;

    AffineTransform tx = g2d.getTransform();
    double scaleX = tx.getScaleX();
    double scaleY = tx.getScaleY();
    double trX = tx.getTranslateX();
    double trY = tx.getTranslateY();

    boolean translucent = volatileBufferType != Transparency.OPAQUE;
    Composite oldComposite = g2d.getComposite();

    try {
        for (x = clipX, maxx = clipX + clipW; x < maxx; x += bw) {
            for (y = clipY, maxy = clipY + clipH; y < maxy; y += bh) {

                // draw x, y, bw, bh
                int pixelx1 = Region.clipRound(x * scaleX + trX);
                int pixely1 = Region.clipRound(y * scaleY + trY);
                int pixelx2 = Region.clipRound((x + bw) * scaleX + trX);
                int pixely2 = Region.clipRound((y + bh) * scaleY + trY);
                int pixelw = pixelx2 - pixelx1;
                int pixelh = pixely2 - pixely1;

                osg2d.setTransform(identity);
                if (translucent) {
                    final Color oldBg = g2d.getBackground();
                    g2d.setBackground(c.getBackground());
                    g2d.clearRect(pixelx1, pixely1, pixelw, pixelh);
                    g2d.setBackground(oldBg);
                }

                osg2d.setClip(0, 0, pixelw, pixelh);
                osg2d.translate(trX - pixelx1, trY - pixely1);
                osg2d.scale(scaleX, scaleY);
                c.paintToOffscreen(osg, x, y, bw, bh, maxx, maxy);

                g2d.setTransform(identity);
                g2d.setClip(pixelx1, pixely1, pixelw, pixelh);
                AffineTransform stx = new AffineTransform();
                stx.translate(pixelx1, pixely1);
                stx.scale(scaleX, scaleY);
                g2d.setTransform(stx);

                if (translucent) {
                    g2d.setComposite(AlphaComposite.Src);
                }

                g2d.drawImage(image, 0, 0, c);

                if (translucent) {
                    g2d.setComposite(oldComposite);
                }
                g2d.setTransform(tx);
            }
        }
    } finally {
        osg.dispose();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:70,代码来源:RepaintManager.java


注:本文中的java.awt.geom.AffineTransform.getTranslateX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。