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


Java GraphicsNode.paint方法代码示例

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


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

示例1: writeEmf

import org.apache.batik.gvt.GraphicsNode; //导入方法依赖的package包/类
/**
 * Private auxiliary method for final to EMF export
 * Method is based on Wolfgang Fang's code - https://github.com/WolfgangFahl/svg2emf
 *
 * @param rootNode  Root node generated in buildGVTTree method
 * @param emfStream EMF output stream for exporting into file
 */
private void writeEmf(GraphicsNode rootNode, OutputStream emfStream) {
    // x,y can be non-(0,0)
    Rectangle2D bounds = rootNode.getBounds();
    int w = (int) (bounds.getX() + bounds.getWidth());
    int h = (int) (bounds.getY() + bounds.getHeight());

    Dimension size = new Dimension(w, h);
    EmfWriterGraphics eg2d = new EmfWriterGraphics(emfStream, size);
    eg2d.setDeviceIndependent(true);
    eg2d.startExport();
    rootNode.paint(eg2d);
    eg2d.endExport();
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:21,代码来源:SvgConverter.java

示例2: render

import org.apache.batik.gvt.GraphicsNode; //导入方法依赖的package包/类
@Override
public void render(JasperReportsContext jasperReportsContext, Graphics2D grx, Rectangle2D rectangle) throws JRException
{
	GraphicsNode rootNode = getRootNode(jasperReportsContext);

	AffineTransform transform = 
		ViewBox.getPreserveAspectRatioTransform(
			new float[]{0, 0, (float) documentSize.getWidth(), (float) documentSize.getHeight()},
			SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_NONE, 
			true,
			(float) rectangle.getWidth(), 
			(float) rectangle.getHeight()
			);
	Graphics2D graphics = (Graphics2D) grx.create();
	try
	{
		graphics.translate(rectangle.getX(), rectangle.getY());
		graphics.transform(transform);

		// CompositeGraphicsNode not thread safe
		synchronized (rootNode)
		{
			rootNode.paint(graphics);
		}
	}
	finally
	{
		graphics.dispose();
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:31,代码来源:AbstractSvgDataToGraphics2DRenderer.java

示例3: graphicFillLineString

import org.apache.batik.gvt.GraphicsNode; //导入方法依赖的package包/类
private static void graphicFillLineString(final LineSymbolizer symbolizer, final Shape shape, final GraphicsNode node, final float size,
        final double opacity) {
    AffineTransform translate = AffineTransform.getTranslateInstance(-node.getBounds().getMinX(), -node.getBounds().getMinY());
    node.setTransform(translate);
    BufferedImage buff = new BufferedImage((int) node.getBounds().getWidth(), (int) node.getBounds().getHeight(), BufferedImage.TYPE_INT_ARGB);
    node.paint((Graphics2D) buff.getGraphics());
    graphicFillLineString(symbolizer, shape, buff, size, opacity);
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:9,代码来源:RenderGL11Util.java

示例4: drawGraphicFillPolygon

import org.apache.batik.gvt.GraphicsNode; //导入方法依赖的package包/类
public static void drawGraphicFillPolygon(GraphicsNode node, float size, Graphics2D graphics, double opacity, double widthSymbol, double heightSymbol, double offsetYSymbol, double offsetXSymbol) {
    AffineTransform translate = AffineTransform.getTranslateInstance(-node.getBounds().getMinX(), -node.getBounds().getMinY());
    node.setTransform(translate);
    BufferedImage buff = new BufferedImage((int) node.getBounds().getWidth(), (int) node.getBounds().getHeight(), BufferedImage.TYPE_INT_ARGB);
    node.paint((Graphics2D) buff.getGraphics());
    drawGraphicFillPolygon(buff, size, graphics, opacity, widthSymbol, heightSymbol, offsetYSymbol, offsetXSymbol);
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:8,代码来源:LayerStylesPanel.java

示例5: graphicFillLineString

import org.apache.batik.gvt.GraphicsNode; //导入方法依赖的package包/类
private static void graphicFillLineString(Shape shape, GraphicsNode node,
        float size, Graphics2D graphics, double opacity) {
    AffineTransform translate = AffineTransform.getTranslateInstance(
            -node.getBounds().getMinX(), -node.getBounds().getMinY());
    node.setTransform(translate);
    BufferedImage buff = new BufferedImage(
            (int) node.getBounds().getWidth(),
            (int) node.getBounds().getHeight(),
            BufferedImage.TYPE_INT_ARGB);
    node.paint((Graphics2D) buff.getGraphics());
    graphicFillLineString(shape, buff, size, graphics, opacity);
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:13,代码来源:RenderUtil.java

示例6: graphicStrokeLineString

import org.apache.batik.gvt.GraphicsNode; //导入方法依赖的package包/类
private static void graphicStrokeLineString(Shape shape, GraphicsNode node,
        float size, Graphics2D graphics, double opacity) {
    double width = node.getBounds().getWidth();
    double height = node.getBounds().getHeight();
    List<AffineTransform> transforms = getGraphicStrokeLineStringTransforms(
            shape, size, width, height, 0.0);
    for (AffineTransform t : transforms) {
        AffineTransform tr = AffineTransform.getTranslateInstance(
                -node.getBounds().getMinX(), -node.getBounds().getMinY());
        t.concatenate(tr);
        node.setTransform(t);
        node.paint(graphics);
    }
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:15,代码来源:RenderUtil.java

示例7: graphicFillPolygon

import org.apache.batik.gvt.GraphicsNode; //导入方法依赖的package包/类
private static void graphicFillPolygon(Shape shape, GraphicsNode node,
        float size, Graphics2D graphics, double opacity) {
    AffineTransform translate = AffineTransform.getTranslateInstance(
            -node.getBounds().getMinX(), -node.getBounds().getMinY());
    node.setTransform(translate);
    BufferedImage buff = new BufferedImage(
            (int) node.getBounds().getWidth(),
            (int) node.getBounds().getHeight(),
            BufferedImage.TYPE_INT_ARGB);
    node.paint((Graphics2D) buff.getGraphics());
    graphicFillPolygon(shape, buff, size, graphics, opacity);
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:13,代码来源:RenderUtil.java

示例8: paintRable

import org.apache.batik.gvt.GraphicsNode; //导入方法依赖的package包/类
/**
 * Should perform the equivilent action as 
 * createRendering followed by drawing the RenderedImage to 
 * Graphics2D, or return false.
 *
 * @param g2d The Graphics2D to draw to.
 * @return true if the paint call succeeded, false if
 *         for some reason the paint failed (in which 
 *         case a createRendering should be used).
 */
public boolean paintRable(Graphics2D g2d) {
    // This optimization only apply if we are using
    // SrcOver.  Otherwise things break...
    Composite c = g2d.getComposite();
    if (!SVGComposite.OVER.equals(c))
        return false;
    
    ColorSpace g2dCS = GraphicsUtil.getDestinationColorSpace(g2d);
    if ((g2dCS == null) ||
        (g2dCS != ColorSpace.getInstance(ColorSpace.CS_sRGB))){
        // Only draw directly into sRGB destinations...
        return false;
    }

    // System.out.println("drawImage GNR: " + g2dCS);
    GraphicsNode gn = getGraphicsNode();
    if (getUsePrimitivePaint()){
        gn.primitivePaint(g2d);
    }
    else{
        gn.paint(g2d);
    }

    // Paint did the work...
    return true;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:37,代码来源:GraphicsNodeRable8Bit.java

示例9: createIconFromSVG

import org.apache.batik.gvt.GraphicsNode; //导入方法依赖的package包/类
public static ImageIcon createIconFromSVG(String path, int height, int width, Color background) {
    try {
        System.setProperty("org.apache.batik.warn_destination", "false");
        Document document;

        String parser = XMLResourceDescriptor.getXMLParserClassName();
        SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);

        document = f.createDocument(ClassLoader.getSystemResource(path).toString());

        UserAgentAdapter userAgentAdapter = new UserAgentAdapter();
        BridgeContext bridgeContext = new BridgeContext(userAgentAdapter);
        GVTBuilder builder = new GVTBuilder();

        GraphicsNode graphicsNode = builder.build(bridgeContext, document);

        double sizeY = bridgeContext.getDocumentSize().getHeight();
        double sizeX = bridgeContext.getDocumentSize().getWidth();

        BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);

        Graphics2D g2d = (Graphics2D) bufferedImage.getGraphics();
        if (background != null) {
            g2d.setColor(background);
            g2d.fillRect(0, 0, width, height);
        }

        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
        g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);

        double scaleX = (width - 1) / sizeX;
        double scaleY = (height - 1) / sizeY;
        double scale = Math.min(scaleX, scaleY);
        g2d.scale(scale, scale);
        g2d.translate(0.5, 0.5);

        graphicsNode.paint(g2d);
        g2d.dispose();
        return new ImageIcon(bufferedImage);
    } catch (Throwable e) {
        System.err.println("Failed to load SVG file " + path);
        System.err.println(e);
        return null;
    }
}
 
开发者ID:workcraft,项目名称:workcraft,代码行数:50,代码来源:GUI.java


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