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


Java SunGraphics2D.TRANSFORM_TRANSLATESCALE属性代码示例

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


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

示例1: isSimpleTranslate

public static boolean isSimpleTranslate(SunGraphics2D sg) {
    int ts = sg.transformState;
    if (ts <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
        // Integer translates are always "simple"
        return true;
    }
    if (ts >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
        // Scales and beyond are always "not simple"
        return false;
    }
    // non-integer translates are only simple when not interpolating
    if (sg.interpolationType == AffineTransformOp.TYPE_NEAREST_NEIGHBOR) {
        return true;
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:DrawImage.java

示例2: copyArea

@Override
public boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h,
                        int dx, int dy) {
    final int state = sg2d.transformState;
    if (state > SunGraphics2D.TRANSFORM_TRANSLATESCALE
        || sg2d.compositeState >= SunGraphics2D.COMP_XOR) {
        return false;
    }
    if (state <= SunGraphics2D.TRANSFORM_ANY_TRANSLATE) {
        x += sg2d.transX;
        y += sg2d.transY;
    } else if (state == SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
        final double[] coords = {x, y, x + w, y + h, x + dx, y + dy};
        sg2d.transform.transform(coords, 0, coords, 0, 3);
        x = (int) Math.ceil(coords[0] - 0.5);
        y = (int) Math.ceil(coords[1] - 0.5);
        w = ((int) Math.ceil(coords[2] - 0.5)) - x;
        h = ((int) Math.ceil(coords[3] - 0.5)) - y;
        dx = ((int) Math.ceil(coords[4] - 0.5)) - x;
        dy = ((int) Math.ceil(coords[5] - 0.5)) - y;
    }
    oglRenderPipe.copyArea(sg2d, x, y, w, h, dx, dy);
    return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:CGLSurfaceData.java

示例3: draw

public void draw(SunGraphics2D sg2d, Shape s) {
    if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
        if (s instanceof Polygon) {
            if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
                Polygon p = (Polygon)s;
                drawPolygon(sg2d, p.xpoints, p.ypoints, p.npoints);
                return;
            }
        }
        Path2D.Float p2df;
        int transx, transy;
        if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
            if (s instanceof Path2D.Float) {
                p2df = (Path2D.Float)s;
            } else {
                p2df = new Path2D.Float(s);
            }
            transx = sg2d.transX;
            transy = sg2d.transY;
        } else {
            p2df = new Path2D.Float(s, sg2d.transform);
            transx = 0;
            transy = 0;
        }
        drawPath(sg2d, p2df, transx, transy);
    } else if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM) {
        ShapeSpanIterator si = LoopPipe.getStrokeSpans(sg2d, s);
        try {
            fillSpans(sg2d, si, 0, 0);
        } finally {
            si.dispose();
        }
    } else {
        fill(sg2d, sg2d.stroke.createStrokedShape(s));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:BufferedRenderPipe.java

示例4: drawString

public void drawString(SunGraphics2D sg2d, String s,
                       double x, double y)
{
    FontInfo info = sg2d.getFontInfo();
    if (info.pixelHeight > OutlineTextRenderer.THRESHHOLD) {
        SurfaceData.outlineTextRenderer.drawString(sg2d, s, x, y);
        return;
    }

    float devx, devy;
    if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
        double origin[] = {x + info.originX, y + info.originY};
        sg2d.transform.transform(origin, 0, origin, 0, 1);
        devx = (float)origin[0];
        devy = (float)origin[1];
    } else {
        devx = (float)(x + info.originX + sg2d.transX);
        devy = (float)(y + info.originY + sg2d.transY);
    }
    /* setFromString returns false if shaping is needed, and we then back
     * off to a TextLayout. Such text may benefit slightly from a lower
     * overhead in this approach over the approach in previous releases.
     */
    GlyphList gl = GlyphList.getInstance();
    if (gl.setFromString(info, s, devx, devy)) {
        drawGlyphList(sg2d, gl);
        gl.dispose();
    } else {
        gl.dispose(); // release this asap.
        TextLayout tl = new TextLayout(s, sg2d.getFont(),
                                       sg2d.getFontRenderContext());
        tl.draw(sg2d, (float)x, (float)y);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:GlyphListPipe.java

示例5: drawChars

public void drawChars(SunGraphics2D sg2d,
                      char data[], int offset, int length,
                      int ix, int iy)
{
    FontInfo info = sg2d.getFontInfo();
    float x, y;
    if (info.pixelHeight > OutlineTextRenderer.THRESHHOLD) {
        SurfaceData.outlineTextRenderer.drawChars(
                                    sg2d, data, offset, length, ix, iy);
        return;
    }
    if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
        double origin[] = {ix + info.originX, iy + info.originY};
        sg2d.transform.transform(origin, 0, origin, 0, 1);
        x = (float) origin[0];
        y = (float) origin[1];
    } else {
        x = ix + info.originX + sg2d.transX;
        y = iy + info.originY + sg2d.transY;
    }
    GlyphList gl = GlyphList.getInstance();
    if (gl.setFromChars(info, data, offset, length, x, y)) {
        drawGlyphList(sg2d, gl);
        gl.dispose();
    } else {
        gl.dispose(); // release this asap.
        TextLayout tl = new TextLayout(new String(data, offset, length),
                                       sg2d.getFont(),
                                       sg2d.getFontRenderContext());
        tl.draw(sg2d, ix, iy);

    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:GlyphListPipe.java

示例6: draw

public void draw(SunGraphics2D sg2d, Shape s) {
    if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
        // Delegate to drawPolygon() if possible...
        if (s instanceof Polygon &&
            sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE)
        {
            Polygon p = (Polygon) s;
            drawPolygon(sg2d, p.xpoints, p.ypoints, p.npoints);
            return;
        }

        // Otherwise we will use drawPath() for
        // high-quality thin paths.
        doPath(sg2d, s, false);
    } else if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM) {
        // REMIND: X11 can handle uniform scaled wide lines
        // and dashed lines itself if we set the appropriate
        // XGC attributes (TBD).
        ShapeSpanIterator si = LoopPipe.getStrokeSpans(sg2d, s);
        try {
            SunToolkit.awtLock();
            try {
                long xgc = validate(sg2d);
                XFillSpans(sg2d.surfaceData.getNativeOps(), xgc,
                           si, si.getNativeIterator(),
                           0, 0);
            } finally {
                SunToolkit.awtUnlock();
            }
        } finally {
            si.dispose();
        }
    } else {
        fill(sg2d, sg2d.stroke.createStrokedShape(s));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:X11Renderer.java

示例7: copyArea

public boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h,
                        int dx, int dy) {
    if (xrpipe == null) {
        if (!isXRDrawableValid()) {
            return true;
        }
        makePipes();
    }
    CompositeType comptype = sg2d.imageComp;
    if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
        (CompositeType.SrcOverNoEa.equals(comptype) ||
         CompositeType.SrcNoEa.equals(comptype)))
    {
        x += sg2d.transX;
        y += sg2d.transY;
        try {
            SunToolkit.awtLock();
            boolean needExposures = canSourceSendExposures(x, y, w, h);
            validateCopyAreaGC(sg2d.getCompClip(), needExposures);
            renderQueue.copyArea(xid, xid, xgc, x, y, w, h, x + dx, y + dy);
        } finally {
            SunToolkit.awtUnlock();
        }
        return true;
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:XRSurfaceData.java

示例8: isSupportedOperation

@Override
public boolean isSupportedOperation(SurfaceData srcData,
                                    int txtype,
                                    CompositeType comp,
                                    Color bgColor)
{
    return (txtype < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
            (CompositeType.SrcOverNoEa.equals(comp) ||
             CompositeType.SrcNoEa.equals(comp)));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:X11SurfaceDataProxy.java

示例9: copyArea

public boolean copyArea(SunGraphics2D sg2d,
                        int x, int y, int w, int h, int dx, int dy)
{
    if (x11pipe == null) {
        if (!isDrawableValid()) {
            return true;
        }
        makePipes();
    }
    CompositeType comptype = sg2d.imageComp;
    if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
        (CompositeType.SrcOverNoEa.equals(comptype) ||
         CompositeType.SrcNoEa.equals(comptype)))
    {
        x += sg2d.transX;
        y += sg2d.transY;
        SunToolkit.awtLock();
        try {
            boolean needExposures = canSourceSendExposures(x, y, w, h);
            long xgc = getBlitGC(sg2d.getCompClip(), needExposures);
            x11pipe.devCopyArea(getNativeOps(), xgc,
                                x, y,
                                x + dx, y + dy,
                                w, h);
        } finally {
            SunToolkit.awtUnlock();
        }
        return true;
    }
    return false;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:31,代码来源:X11SurfaceData.java

示例10: copyArea

public boolean copyArea(SunGraphics2D sg2d,
                        int x, int y, int w, int h, int dx, int dy)
{
    if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
        sg2d.compositeState < SunGraphics2D.COMP_XOR)
    {
        x += sg2d.transX;
        y += sg2d.transY;

        oglRenderPipe.copyArea(sg2d, x, y, w, h, dx, dy);

        return true;
    }
    return false;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:OGLSurfaceData.java

示例11: validatePipe

public void validatePipe(SunGraphics2D sg2d) {
    if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON &&
        sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
        (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY ||
         sg2d.compositeState == SunGraphics2D.COMP_XOR))
    {
        if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
            // Do this to init textpipe correctly; we will override the
            // other non-text pipes below
            // REMIND: we should clean this up eventually instead of
            // having this work duplicated.
            super.validatePipe(sg2d);
        } else {
            switch (sg2d.textAntialiasHint) {

            case SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT:
                /* equate DEFAULT to OFF which it is for us */
            case SunHints.INTVAL_TEXT_ANTIALIAS_OFF:
                sg2d.textpipe = solidTextRenderer;
                break;

            case SunHints.INTVAL_TEXT_ANTIALIAS_ON:
                sg2d.textpipe = aaTextRenderer;
                break;

            default:
                switch (sg2d.getFontInfo().aaHint) {

                case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_HRGB:
                case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_VRGB:
                    sg2d.textpipe = lcdTextRenderer;
                    break;

                case SunHints.INTVAL_TEXT_ANTIALIAS_ON:
                    sg2d.textpipe = aaTextRenderer;
                    break;

                default:
                    sg2d.textpipe = solidTextRenderer;
                }
            }
        }
        sg2d.imagepipe = imagepipe;
        if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
            sg2d.drawpipe = gdiTxPipe;
            sg2d.fillpipe = gdiTxPipe;
        } else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN){
            sg2d.drawpipe = gdiTxPipe;
            sg2d.fillpipe = gdiPipe;
        } else {
            sg2d.drawpipe = gdiPipe;
            sg2d.fillpipe = gdiPipe;
        }
        sg2d.shapepipe = gdiPipe;
        // This is needed for AA text.
        // Note that even a SolidTextRenderer can dispatch AA text
        // if a GlyphVector overrides the AA setting.
        // We use getRenderLoops() rather than setting solidloops
        // directly so that we get the appropriate loops in XOR mode.
        if (sg2d.loops == null) {
            // assert(some pipe will always be a LoopBasedPipe)
            sg2d.loops = getRenderLoops(sg2d);
        }
    } else {
        super.validatePipe(sg2d);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:67,代码来源:GDIWindowSurfaceData.java


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