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


Java AffineTransform.getTranslateY方法代码示例

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


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

示例1: 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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:Font2D.java

示例2: 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:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:AttributeValues.java

示例3: concatfix

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
public void concatfix(AffineTransform at) {
    double m00 = at.getScaleX();
    double m10 = at.getShearY();
    double m01 = at.getShearX();
    double m11 = at.getScaleY();
    double m02 = at.getTranslateX();
    double m12 = at.getTranslateY();
    if (Math.abs(m00-1.0) < 1E-10) m00 = 1.0;
    if (Math.abs(m11-1.0) < 1E-10) m11 = 1.0;
    if (Math.abs(m02) < 1E-10) m02 = 0.0;
    if (Math.abs(m12) < 1E-10) m12 = 0.0;
    if (Math.abs(m01) < 1E-15) m01 = 0.0;
    if (Math.abs(m10) < 1E-15) m10 = 0.0;
    at.setTransform(m00, m10,
                    m01, m11,
                    m02, m12);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:TestInvertMethods.java

示例4: 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

示例5: 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:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:TexturePaintContext.java

示例6: 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

示例7: 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

示例8: 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

示例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:SunburstApps,项目名称:OpenJSharp,代码行数:55,代码来源:PixelToParallelogramConverter.java

示例10: setTexturePaint

import java.awt.geom.AffineTransform; //导入方法依赖的package包/类
/**
 * We use OpenGL's texture coordinate generator to automatically
 * map the TexturePaint image to the geometry being rendered.  The
 * generator uses two separate plane equations that take the (x,y)
 * location (in device space) of the fragment being rendered to
 * calculate (u,v) texture coordinates for that fragment:
 *     u = Ax + By + Cz + Dw
 *     v = Ex + Fy + Gz + Hw
 *
 * Since we use a 2D orthographic projection, we can assume that z=0
 * and w=1 for any fragment.  So we need to calculate appropriate
 * values for the plane equation constants (A,B,D) and (E,F,H) such
 * that {u,v}=0 for the top-left of the TexturePaint's anchor
 * rectangle and {u,v}=1 for the bottom-right of the anchor rectangle.
 * We can easily make the texture image repeat for {u,v} values
 * outside the range [0,1] by specifying the GL_REPEAT texture wrap
 * mode.
 *
 * Calculating the plane equation constants is surprisingly simple.
 * We can think of it as an inverse matrix operation that takes
 * device space coordinates and transforms them into user space
 * coordinates that correspond to a location relative to the anchor
 * rectangle.  First, we translate and scale the current user space
 * transform by applying the anchor rectangle bounds.  We then take
 * the inverse of this affine transform.  The rows of the resulting
 * inverse matrix correlate nicely to the plane equation constants
 * we were seeking.
 */
private static void setTexturePaint(RenderQueue rq,
                                    SunGraphics2D sg2d,
                                    TexturePaint paint,
                                    boolean useMask)
{
    BufferedImage bi = paint.getImage();
    SurfaceData dstData = sg2d.surfaceData;
    SurfaceData srcData =
        dstData.getSourceSurfaceData(bi, SunGraphics2D.TRANSFORM_ISIDENT,
                                     CompositeType.SrcOver, null);
    boolean filter =
        (sg2d.interpolationType !=
         AffineTransformOp.TYPE_NEAREST_NEIGHBOR);

    // calculate plane equation constants
    AffineTransform at = (AffineTransform)sg2d.transform.clone();
    Rectangle2D anchor = paint.getAnchorRect();
    at.translate(anchor.getX(), anchor.getY());
    at.scale(anchor.getWidth(), anchor.getHeight());

    double xp0, xp1, xp3, yp0, yp1, yp3;
    try {
        at.invert();
        xp0 = at.getScaleX();
        xp1 = at.getShearX();
        xp3 = at.getTranslateX();
        yp0 = at.getShearY();
        yp1 = at.getScaleY();
        yp3 = at.getTranslateY();
    } catch (java.awt.geom.NoninvertibleTransformException e) {
        xp0 = xp1 = xp3 = yp0 = yp1 = yp3 = 0.0;
    }

    // assert rq.lock.isHeldByCurrentThread();
    rq.ensureCapacityAndAlignment(68, 12);
    RenderBuffer buf = rq.getBuffer();
    buf.putInt(SET_TEXTURE_PAINT);
    buf.putInt(useMask ? 1 : 0);
    buf.putInt(filter ? 1 : 0);
    buf.putLong(srcData.getNativeOps());
    buf.putDouble(xp0).putDouble(xp1).putDouble(xp3);
    buf.putDouble(yp0).putDouble(yp1).putDouble(yp3);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:72,代码来源:BufferedPaints.java

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