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


Java SunGraphics2D类代码示例

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


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

示例1: doPath

import sun.java2d.SunGraphics2D; //导入依赖的package包/类
private void doPath(SunGraphics2D sg2d, Shape s, boolean isFill) {
    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;
    }
    SunToolkit.awtLock();
    try {
        long xgc = validate(sg2d);
        XDoPath(sg2d, sg2d.surfaceData.getNativeOps(), xgc,
                transx, transy, p2df, isFill);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:X11Renderer.java

示例2: scaleSurfaceData

import sun.java2d.SunGraphics2D; //导入依赖的package包/类
protected boolean scaleSurfaceData(SunGraphics2D sg,
                                   Region clipRegion,
                                   SurfaceData srcData,
                                   SurfaceData dstData,
                                   SurfaceType srcType,
                                   SurfaceType dstType,
                                   int sx1, int sy1,
                                   int sx2, int sy2,
                                   double dx1, double dy1,
                                   double dx2, double dy2)
{
    CompositeType comp = sg.imageComp;
    if (CompositeType.SrcOverNoEa.equals(comp) &&
        (srcData.getTransparency() == Transparency.OPAQUE))
    {
        comp = CompositeType.SrcNoEa;
    }

    ScaledBlit blit = ScaledBlit.getFromCache(srcType, comp, dstType);
    if (blit != null) {
        blit.Scale(srcData, dstData, sg.composite, clipRegion,
                   sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
        return true;
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:DrawImage.java

示例3: fillParallelogram

import sun.java2d.SunGraphics2D; //导入依赖的package包/类
public void fillParallelogram(SunGraphics2D sg2d,
                              double ux1, double uy1,
                              double ux2, double uy2,
                              double x, double y,
                              double dx1, double dy1,
                              double dx2, double dy2)
{
    rq.lock();
    try {
        validateContext(sg2d);
        rq.ensureCapacity(28);
        buf.putInt(FILL_PARALLELOGRAM);
        buf.putFloat((float) x);
        buf.putFloat((float) y);
        buf.putFloat((float) dx1);
        buf.putFloat((float) dy1);
        buf.putFloat((float) dx2);
        buf.putFloat((float) dy2);
    } finally {
        rq.unlock();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:BufferedRenderPipe.java

示例4: drawPath

import sun.java2d.SunGraphics2D; //导入依赖的package包/类
protected void drawPath(SunGraphics2D sg2d,
                        Path2D.Float p2df, int transx, int transy)
{
    rq.lock();
    try {
        validateContext(sg2d);
        drawHandler.validate(sg2d);
        ProcessPath.drawPath(drawHandler, p2df, transx, transy);
    } finally {
        rq.unlock();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:BufferedRenderPipe.java

示例5: validate

import sun.java2d.SunGraphics2D; //导入依赖的package包/类
private final long validate(SunGraphics2D sg2d) {
    // NOTE: getCompClip() will revalidateAll() if the
    // surfaceData is invalid.  This should ensure that
    // the clip and pixel that we are validating against
    // are the most current.
    //
    // The assumption is that the pipeline after that
    // revalidation will either be another X11 pipe
    // (because the drawable format never changes on X11)
    // or a null pipeline if the surface is disposed.
    //
    // Since we do not get the ops structure of the SurfaceData
    // until the actual call down to the native level we will
    // pick up the most recently validated copy.
    // Note that if the surface is disposed, a NullSurfaceData
    // (with null native data structure) will be set in
    // sg2d, so we have to protect against it in native code.

    X11SurfaceData x11sd = (X11SurfaceData)sg2d.surfaceData;
    return x11sd.getRenderGC(sg2d.getCompClip(),
                             sg2d.compositeState, sg2d.composite,
                             sg2d.pixel);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:X11Renderer.java

示例6: copyArea

import sun.java2d.SunGraphics2D; //导入依赖的package包/类
@Override
public boolean copyArea(SunGraphics2D sg2d,
                        int x, int y, int w, int h, int dx, int dy)
{
    if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE &&
        sg2d.compositeState < sg2d.COMP_XOR)
    {
        x += sg2d.transX;
        y += sg2d.transY;

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

        return true;
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:D3DSurfaceData.java

示例7: main

import sun.java2d.SunGraphics2D; //导入依赖的package包/类
public static void main(final String[] args) {
    final GraphicsEnvironment ge =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsConfiguration gc =
            ge.getDefaultScreenDevice().getDefaultConfiguration();
    final VolatileImage vi = gc.createCompatibleVolatileImage(200, 200);
    final SunGraphics2D sg2d = (SunGraphics2D) vi.createGraphics();

    sg2d.constrain(0, 61, 100, 100);
    final AffineTransform expected = sg2d.cloneTransform();
    sg2d.setTransform(sg2d.getTransform());
    final AffineTransform actual = sg2d.cloneTransform();
    sg2d.dispose();
    vi.flush();
    if (!expected.equals(actual)) {
        System.out.println("Expected = " + expected);
        System.out.println("Actual = " + actual);
        throw new RuntimeException("Wrong transform");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:TransformSetGet.java

示例8: drawGlyphVector

import sun.java2d.SunGraphics2D; //导入依赖的package包/类
public void drawGlyphVector(SunGraphics2D sg2d, GlyphVector gv,
                            float x, float y)
{
    FontRenderContext frc = gv.getFontRenderContext();
    FontInfo info = sg2d.getGVFontInfo(gv.getFont(), frc);
    if (info.pixelHeight > OutlineTextRenderer.THRESHHOLD) {
        SurfaceData.outlineTextRenderer.drawGlyphVector(sg2d, gv, x, y);
        return;
    }
    if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
        double origin[] = {x, y};
        sg2d.transform.transform(origin, 0, origin, 0, 1);
        x = (float) origin[0];
        y = (float) origin[1];
    } else {
        x += sg2d.transX; // don't use the glyph info origin, already in gv.
        y += sg2d.transY;
    }

    GlyphList gl = GlyphList.getInstance();
    gl.setFromGlyphVector(info, gv, x, y);
    drawGlyphList(sg2d, gl, info.aaHint);
    gl.dispose();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:GlyphListPipe.java

示例9: fillSpans

import sun.java2d.SunGraphics2D; //导入依赖的package包/类
protected void fillSpans(SunGraphics2D sg2d, SpanIterator si,
                         int transx, int transy)
{
    rq.lock();
    try {
        validateContext(sg2d);
        rq.ensureCapacity(24); // so that we have room for at least a span
        int newpos = fillSpans(rq, buf.getAddress(),
                               buf.position(), buf.capacity(),
                               si, si.getNativeIterator(),
                               transx, transy);
        buf.position(newpos);
    } finally {
        rq.unlock();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:BufferedRenderPipe.java

示例10: getGraphics

import sun.java2d.SunGraphics2D; //导入依赖的package包/类
Graphics getGraphics(SurfaceData surfData, Color afore, Color aback, Font afont) {
    if (surfData == null) return null;

    Component target = this.target;

    /* Fix for bug 4746122. Color and Font shouldn't be null */
    Color bgColor = aback;
    if (bgColor == null) {
        bgColor = SystemColor.window;
    }
    Color fgColor = afore;
    if (fgColor == null) {
        fgColor = SystemColor.windowText;
    }
    Font font = afont;
    if (font == null) {
        font = XWindow.getDefaultFont();
    }
    return new SunGraphics2D(surfData, fgColor, bgColor, font);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:XWindow.java

示例11: createGraphics

import sun.java2d.SunGraphics2D; //导入依赖的package包/类
/**
 * Creates a graphics object for the passed in surface data. If
 * the surface is lost, it is restored.
 * If the surface wasn't lost or the restoration was successful
 * the surface is added to the list of maintained surfaces
 * (if it hasn't been already).
 *
 * If the updater thread hasn't been created yet , it will be created and
 * started.
 *
 * @param sd surface data for which to create SunGraphics2D
 * @param peer peer associated with the surface data
 * @param fgColor fg color to be used in graphics
 * @param bgColor bg color to be used in graphics
 * @param font font to be used in graphics
 * @return a SunGraphics2D object for the surface (or for temp GDI
 * surface data)
 */
@Override
public Graphics2D createGraphics(SurfaceData sd,
        WComponentPeer peer, Color fgColor, Color bgColor, Font font)
{
    if (!done && sd instanceof D3DWindowSurfaceData) {
        D3DWindowSurfaceData d3dw = (D3DWindowSurfaceData)sd;
        if (!d3dw.isSurfaceLost() || validate(d3dw)) {
            trackScreenSurface(d3dw);
            return new SunGraphics2D(sd, fgColor, bgColor, font);
        }
        // could not restore the d3dw surface, use the cached gdi surface
        // instead for this graphics object; note that we do not track
        // this new gdi surface, it is only used for this graphics
        // object
        sd = getGdiSurface(d3dw);
    }
    return super.createGraphics(sd, peer, fgColor, bgColor, font);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:D3DScreenUpdateManager.java

示例12: validateContext

import sun.java2d.SunGraphics2D; //导入依赖的package包/类
@Override
protected void validateContext(SunGraphics2D sg2d) {
    int ctxflags =
        sg2d.paint.getTransparency() == Transparency.OPAQUE ?
            OGLContext.SRC_IS_OPAQUE : OGLContext.NO_CONTEXT_FLAGS;
    OGLSurfaceData dstData;
    try {
        dstData = (OGLSurfaceData)sg2d.surfaceData;
    } catch (ClassCastException e) {
        throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
    }
    OGLContext.validateContext(dstData, dstData,
                               sg2d.getCompClip(), sg2d.composite,
                               null, sg2d.paint, sg2d, ctxflags);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:OGLRenderer.java

示例13: fillRoundRect

import sun.java2d.SunGraphics2D; //导入依赖的package包/类
public void fillRoundRect(SunGraphics2D sg2d,
                          int x, int y, int width, int height,
                          int arcWidth, int arcHeight)
{
    SunToolkit.awtLock();
    try {
        long xgc = validate(sg2d);
        XFillRoundRect(sg2d.surfaceData.getNativeOps(), xgc,
                       x+sg2d.transX, y+sg2d.transY, width, height,
                       arcWidth, arcHeight);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:X11Renderer.java

示例14: TileContext

import sun.java2d.SunGraphics2D; //导入依赖的package包/类
public TileContext(SunGraphics2D sg, PaintContext pCtx,
                   CompositeContext cCtx, ColorModel cModel) {
    sunG2D = sg;
    paintCtxt = pCtx;
    compCtxt = cCtx;
    compModel = cModel;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:GeneralCompositePipe.java

示例15: DrawPath

import sun.java2d.SunGraphics2D; //导入依赖的package包/类
public void DrawPath(SunGraphics2D sg2d, SurfaceData sData,
                     int transX, int transY,
                     Path2D.Float p2df)
{
    tracePrimitive(target);
    target.DrawPath(sg2d, sData, transX, transY, p2df);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:DrawPath.java


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