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


Java PPaintContext.setRenderQuality方法代码示例

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


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

示例1: createYLineNode

import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
private PNode createYLineNode( double minX, double maxX, double y ) {
    PPath child = new PPath( new Line2D.Double( minX, y, maxX, y ) ) {

        //Use low quality rendering to improve performance when grid is turned on
        @Override protected void paint( PPaintContext paintContext ) {
            int renderQuality = paintContext.getRenderQuality();
            paintContext.setRenderQuality( PPaintContext.LOW_QUALITY_RENDERING );
            super.paint( paintContext );
            paintContext.setRenderQuality( renderQuality );
        }
    };
    boolean thickStroke = MathUtil.isApproxEqual( y, 0, 0.001 );

    //On 11/29/2011 It was requested to make every other line thick instead of every 5 lines.
    if ( (int) y % 2 == 0 ) {
        thickStroke = true;
    }
    child.setStroke( new BasicStroke( 0.01f * ( thickStroke ? 3 : 1 ) ) );
    return child;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:21,代码来源:GridNode.java

示例2: createXLineNode

import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
private PNode createXLineNode( double minY, double maxY, double x ) {
    PPath child = new PPath( new Line2D.Double( x, minY, x, maxY ) ) {

        //Use low quality rendering to improve performance when grid is turned on
        @Override protected void paint( PPaintContext paintContext ) {
            int renderQuality = paintContext.getRenderQuality();
            paintContext.setRenderQuality( PPaintContext.LOW_QUALITY_RENDERING );
            super.paint( paintContext );
            paintContext.setRenderQuality( renderQuality );
        }
    };
    boolean thickStroke = MathUtil.isApproxEqual( x, highlightX, 0.001 );
    child.setStroke( new BasicStroke( 0.01f * ( thickStroke ? 3 : 1 ) ) );
    return child;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:16,代码来源:GridNode.java

示例3: paint

import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
/**
 * Use high quality rendering hints for painting this node.
 *
 * @param paintContext
 */
protected void paint( PPaintContext paintContext ) {
    int rq = paintContext.getRenderQuality();
    paintContext.setRenderQuality( PPaintContext.HIGH_QUALITY_RENDERING );
    super.paint( paintContext );
    paintContext.setRenderQuality( rq );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:HighQualityPhetPPath.java

示例4: paint

import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
@Override public void paint( Graphics2D graphicsContext ) {
    // clear everything, since we may not be repainting
    graphicsContext.setBackground( new Color( 0, 0, 0, 0 ) );
    graphicsContext.clearRect( 0, 0, getWidth(), getHeight() );

    final PPaintContext paintContext = new PPaintContext( graphicsContext );
    paintContext.setRenderQuality( PPaintContext.HIGH_QUALITY_RENDERING );
    node.fullPaint( paintContext );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:PiccoloImage.java

示例5: print

import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
/**
 * Prints the node into the given Graphics context using the specified
 * format. The zero based index of the requested page is specified by
 * pageIndex. If the requested page does not exist then this method returns
 * NO_SUCH_PAGE; otherwise PAGE_EXISTS is returned. If the printable object
 * aborts the print job then it throws a PrinterException.
 * 
 * @param graphics the context into which the node is drawn
 * @param pageFormat the size and orientation of the page
 * @param pageIndex the zero based index of the page to be drawn
 * 
 * @return Either NO_SUCH_PAGE or PAGE_EXISTS
 */
public int print(final Graphics graphics, final PageFormat pageFormat, final int pageIndex) {
    if (pageIndex != 0) {
        return NO_SUCH_PAGE;
    }

    if (!(graphics instanceof Graphics2D)) {
        throw new IllegalArgumentException("Provided graphics context is not a Graphics2D object");
    }

    final Graphics2D g2 = (Graphics2D) graphics;
    final PBounds imageBounds = getFullBounds();

    imageBounds.expandNearestIntegerDimensions();

    g2.setClip(0, 0, (int) pageFormat.getWidth(), (int) pageFormat.getHeight());
    g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY());

    // scale the graphics so node's full bounds fit in the imageable bounds.
    double scale = pageFormat.getImageableWidth() / imageBounds.getWidth();
    if (pageFormat.getImageableHeight() / imageBounds.getHeight() < scale) {
        scale = pageFormat.getImageableHeight() / imageBounds.getHeight();
    }

    g2.scale(scale, scale);
    g2.translate(-imageBounds.x, -imageBounds.y);

    final PPaintContext pc = new PPaintContext(g2);
    pc.setRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING);
    fullPaint(pc);

    return PAGE_EXISTS;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:46,代码来源:PNode.java

示例6: printAll

import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
/**
 * Prints the entire scene regardless of what the viewable area is.
 * 
 * @param graphics Graphics context onto which to paint the scene for printing
 */
public void printAll(final Graphics graphics) {
    if (!(graphics instanceof Graphics2D)) {
        throw new IllegalArgumentException("Provided graphics context is not a Graphics2D object");
    }
    
    final Graphics2D g2 = (Graphics2D) graphics;

    final PBounds clippingRect = new PBounds(graphics.getClipBounds());
    clippingRect.expandNearestIntegerDimensions();

    final PBounds originalCameraBounds = getCamera().getBounds();
    final PBounds layerBounds = getCamera().getUnionOfLayerFullBounds();
    getCamera().setBounds(layerBounds);

    final double clipRatio = clippingRect.getWidth() / clippingRect.getHeight();
    final double nodeRatio = ((double) getWidth()) / ((double) getHeight());
    final double scale;
    if (nodeRatio <= clipRatio) {
        scale = clippingRect.getHeight() / getCamera().getHeight();
    }
    else {
        scale = clippingRect.getWidth() / getCamera().getWidth();
    }
    g2.scale(scale, scale);
    g2.translate(-clippingRect.x, -clippingRect.y);

    final PPaintContext pc = new PPaintContext(g2);
    pc.setRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING);
    getCamera().fullPaint(pc);

    getCamera().setBounds(originalCameraBounds);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:38,代码来源:PCanvas.java

示例7: render

import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
/**
 * Render this offscreen canvas to the specified graphics.
 * 
 * @param graphics graphics to render this offscreen canvas to, must not be
 *            null
 */
public void render(final Graphics2D graphics) {
    if (graphics == null) {
        throw new IllegalArgumentException("graphics must not be null");
    }
    final PPaintContext paintContext = new PPaintContext(graphics);
    paintContext.setRenderQuality(renderQuality);
    camera.fullPaint(paintContext);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:15,代码来源:POffscreenCanvas.java

示例8: paintComponent

import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
/**
 * Paints the region specified of the canvas onto the given Graphics
 * Context.
 * 
 * @param gc graphics onto within painting should occur
 * @param x left of the dirty region
 * @param y top of the dirty region
 * @param w width of the dirty region
 * @param h height of the dirty region
 */
public void paintComponent(final GC gc, final int x, final int y, final int w, final int h) {
    PDebug.startProcessingOutput();

    GC imageGC = null;
    Graphics2D g2 = null;
    if (doubleBuffered) {
        imageGC = new GC(backBuffer);
        g2 = new SWTGraphics2D(imageGC, getDisplay());
    }
    else {
        g2 = new SWTGraphics2D(gc, getDisplay());
    }

    g2.setColor(Color.white);
    g2.setBackground(Color.white);

    final Rectangle rect = getBounds();
    g2.fillRect(0, 0, rect.width, rect.height);

    // This fixes a problem with standard debugging of region management in
    // SWT
    if (PDebug.debugRegionManagement) {
        final Rectangle r = gc.getClipping();
        final Rectangle2D r2 = new Rectangle2D.Double(r.x, r.y, r.width, r.height);
        g2.setBackground(PDebug.getDebugPaintColor());
        g2.fill(r2);
    }

    // create new paint context and set render quality
    final PPaintContext paintContext = new PPaintContext(g2);
    if (getInteracting() || getAnimating()) {
        if (interactingRenderQuality > animatingRenderQuality) {
            paintContext.setRenderQuality(interactingRenderQuality);
        }
        else {
            paintContext.setRenderQuality(animatingRenderQuality);
        }
    }
    else {
        paintContext.setRenderQuality(defaultRenderQuality);
    }

    // paint Piccolo2D
    camera.fullPaint(paintContext);

    // if switched state from animating to not animating invalidate
    // the entire screen so that it will be drawn with the default instead
    // of animating render quality.
    if (animatingOnLastPaint && !getAnimating()) {
        repaint();
    }
    animatingOnLastPaint = getAnimating();

    final boolean region = PDebug.debugRegionManagement;
    PDebug.debugRegionManagement = false;
    PDebug.endProcessingOutput(g2);
    PDebug.debugRegionManagement = region;

    if (doubleBuffered) {
        gc.drawImage(backBuffer, 0, 0);

        // Dispose of the allocated image gc
        imageGC.dispose();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:76,代码来源:PSWTCanvas.java

示例9: toImage

import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
/**
 * Paint a representation of this node into the specified buffered image. If
 * background, paint is null, then the image will not be filled with a color
 * prior to rendering
 * 
 * @since 1.3
 * @param image Image onto which this node will be painted
 * @param backGroundPaint will fill background of image with this. May be
 *            null.
 * @param fillStrategy strategy to use regarding how node will cover the
 *            image
 * @return a rendering of this image and its descendants onto the specified
 *         image
 */
public Image toImage(final BufferedImage image, final Paint backGroundPaint, final int fillStrategy) {
    final int imageWidth = image.getWidth();
    final int imageHeight = image.getHeight();
    final Graphics2D g2 = image.createGraphics();

    if (backGroundPaint != null) {
        g2.setPaint(backGroundPaint);
        g2.fillRect(0, 0, imageWidth, imageHeight);
    }
    g2.setClip(0, 0, imageWidth, imageHeight);

    final PBounds nodeBounds = getFullBounds();
    nodeBounds.expandNearestIntegerDimensions();

    final double nodeWidth = nodeBounds.getWidth();
    final double nodeHeight = nodeBounds.getHeight();

    double imageRatio = imageWidth / (imageHeight * 1.0);
    double nodeRatio = nodeWidth / nodeHeight;
    double scale;
    switch (fillStrategy) {
        case FILL_STRATEGY_ASPECT_FIT:
            // scale the graphics so node's full bounds fit in the imageable
            // bounds but aspect ration is retained

            if (nodeRatio <= imageRatio) {
                scale = image.getHeight() / nodeHeight;
            }
            else {
                scale = image.getWidth() / nodeWidth;
            }
            g2.scale(scale, scale);
            g2.translate(-nodeBounds.x, -nodeBounds.y);
            break;
        case FILL_STRATEGY_ASPECT_COVER:
            // scale the graphics so node completely covers the imageable
            // area, but retains its aspect ratio.
            if (nodeRatio <= imageRatio) {
                scale = image.getWidth() / nodeWidth;
            }
            else {
                scale = image.getHeight() / nodeHeight;
            }
            g2.scale(scale, scale);
            break;
        case FILL_STRATEGY_EXACT_FIT:
            // scale the node so that it covers then entire image,
            // distorting it if necessary.
            g2.scale(image.getWidth() / nodeWidth, image.getHeight() / nodeHeight);
            g2.translate(-nodeBounds.x, -nodeBounds.y);
            break;
        default:
            throw new IllegalArgumentException("Fill strategy provided is invalid");
    }

    final PPaintContext pc = new PPaintContext(g2);
    pc.setRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING);
    fullPaint(pc);
    return image;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:75,代码来源:PNode.java

示例10: paintComponent

import edu.umd.cs.piccolo.util.PPaintContext; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void paintComponent(final Graphics g) {
    PDebug.startProcessingOutput();

    final Graphics2D g2 = (Graphics2D) g.create();

    // support for non-opaque canvases
    // see
    // http://groups.google.com/group/piccolo2d-dev/browse_thread/thread/134e2792d3a54cf
    if (isOpaque()) {
        g2.setColor(getBackground());
        g2.fillRect(0, 0, getWidth(), getHeight());
    }

    if (getAnimating()) {
        repaintBounds.add(g2.getClipBounds());
    }

    // create new paint context and set render quality to lowest common
    // denominator render quality.
    final PPaintContext paintContext = new PPaintContext(g2);
    if (getInteracting() || getAnimating()) {
        if (interactingRenderQuality < animatingRenderQuality) {
            paintContext.setRenderQuality(interactingRenderQuality);
        }
        else {
            paintContext.setRenderQuality(animatingRenderQuality);
        }
    }
    else {
        paintContext.setRenderQuality(normalRenderQuality);
    }

    camera.fullPaint(paintContext);

    // if switched state from animating to not animating invalidate the
    // repaint bounds so that it will be drawn with the default instead of
    // animating render quality.
    if (!getAnimating() && animatingOnLastPaint) {
        repaint(repaintBounds);
        repaintBounds.reset();
    }

    animatingOnLastPaint = getAnimating();

    PDebug.endProcessingOutput(g2);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:50,代码来源:PCanvas.java


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