Examples of GVTFactory


Examples of org.apache.batik.gvt.GVTFactory

    public static ShapePainter convertStrokeAndFill(SVGElement svgElement,
                                                    GraphicsNode node,
                                                    BridgeContext ctx,
                                                    CSSStyleDeclaration decl,
                                                    UnitProcessor.Context uctx){
        GVTFactory f = ctx.getGVTFactory();
        // resolve fill
        ShapePainter fillPainter = convertFill(svgElement, node, ctx,
                                               decl, uctx);
        // resolve stroke
        ShapePainter strokePainter = convertStroke(svgElement, node, ctx,
                                                   decl, uctx);
        ShapePainter painter = null;
        if (fillPainter != null && strokePainter != null) {
            CompositeShapePainter comp = f.createCompositeShapePainter();
            comp.addShapePainter(fillPainter);
            comp.addShapePainter(strokePainter);
            painter = comp;
        } else if (fillPainter != null) {
            painter = fillPainter;
View Full Code Here

Examples of org.apache.batik.gvt.GVTFactory

    public static
        BasicStroke convertStrokeToBasicStroke(SVGElement svgElement,
                                               BridgeContext ctx,
                                               CSSStyleDeclaration decl,
                                               UnitProcessor.Context uctx) {
        GVTFactory f = ctx.getGVTFactory();

        // resolve the java.awt.Stroke of the StrokeShapePainter
        CSSPrimitiveValue v =
         (CSSPrimitiveValue)decl.getPropertyCSSValue(CSS_STROKE_WIDTH_PROPERTY);
        short type = v.getPrimitiveType();
View Full Code Here

Examples of org.apache.batik.gvt.GVTFactory

    public static ShapePainter convertFill(SVGElement svgElement,
                                           GraphicsNode node,
                                           BridgeContext ctx,
                                           CSSStyleDeclaration decl,
                                           UnitProcessor.Context uctx) {
        GVTFactory f = ctx.getGVTFactory();
        FillShapePainter painter = null;
        Paint fillPaint = convertFillToPaint(svgElement,
                                             node,
                                             ctx,
                                             decl,
                                             uctx);
        if(fillPaint != null){
            painter = f.createFillShapePainter();
            painter.setPaint(fillPaint);
        }

        return painter;
    }
View Full Code Here

Examples of org.apache.batik.gvt.GVTFactory

        // The 'clipPath' element or any of its children can specify
        // property 'clip-path'.
        //
        Area clipPath = new Area();
        GVTBuilder builder = ctx.getGVTBuilder();
        GVTFactory gvtFactory = ctx.getGVTFactory();

        // parse the transform attribute
        AffineTransform Tx =
            SVGUtilities.convertAffineTransform(clipElement,
                                                ATTR_TRANSFORM,
                                                ctx.getParserFactory());

        // parse the clipPathUnits attribute
        Viewport oldViewport = ctx.getCurrentViewport();
        String units = clipElement.getAttributeNS(null, ATTR_CLIP_PATH_UNITS);
        if (units.length() == 0) {
            units = VALUE_USER_SPACE_ON_USE;
        }
        int unitsType;
        try {
            unitsType = SVGUtilities.parseCoordinateSystem(units);
        } catch (IllegalArgumentException ex) {
            throw new IllegalAttributeValueException(
                Messages.formatMessage("clipPath.units.invalid",
                                       new Object[] {units,
                                                     ATTR_CLIP_PATH_UNITS}));
        }
        if (unitsType == SVGUtilities.OBJECT_BOUNDING_BOX) {
            // units are resolved using objectBoundingBox
            ctx.setCurrentViewport(new ObjectBoundingBoxViewport());
        }
        // compute an additional transform related the clipPathUnits
        Tx = SVGUtilities.convertAffineTransform(Tx, gn, unitsType);

        // build the clipPath according to the clipPath's children
        boolean hasChildren = false;
        for(Node node=clipElement.getFirstChild();
                node != null;
                node = node.getNextSibling()){

            // check if the node is a valid Element
            if (node.getNodeType() != node.ELEMENT_NODE) {
                continue;
            }
            Element child = (Element)node;
            GraphicsNode clipNode = builder.build(ctx, child) ;
            // check if a GVT node has been created
            if (clipNode == null) {
                throw new IllegalAttributeValueException(
                    Messages.formatMessage("clipPath.subelement.illegal",
                                        new Object[] {node.getLocalName()}));
            }
            hasChildren = true;
            // compute the outline of the current Element
            CSSStyleDeclaration c =
                ctx.getViewCSS().getComputedStyle(child, null);
            CSSPrimitiveValue v = (CSSPrimitiveValue)c.getPropertyCSSValue
                (CSS_CLIP_RULE_PROPERTY);
            int wr = (CSSUtilities.rule(v) == CSSUtilities.RULE_NONZERO)
                ? GeneralPath.WIND_NON_ZERO
                : GeneralPath.WIND_EVEN_ODD;
            GeneralPath path = new GeneralPath(clipNode.getOutline());
            path.setWindingRule(wr);
            Shape outline = Tx.createTransformedShape(path);

            // apply the clip-path of the current Element
            ShapeNode outlineNode = gvtFactory.createShapeNode();
            outlineNode.setShape(outline);
            Clip clip = CSSUtilities.convertClipPath(child,
                                                     outlineNode,
                                                     ctx);
            if (clip != null) {
                Area area = new Area(outline);
                area.subtract(new Area(clip.getClipPath()));
                outline = area;
            }
            clipPath.add(new Area(outline));
        }
        // restore the viewport
        ctx.setCurrentViewport(oldViewport);
        if (!hasChildren) {
            return null; // no clipPath defined
        }

        // apply the clip-path of this clipPath Element (already in user space)
        ShapeNode clipPathNode = gvtFactory.createShapeNode();
        clipPathNode.setShape(clipPath);
        Clip clipElementClipPath =
            CSSUtilities.convertClipPath(clipElement, clipPathNode, ctx);
        if (clipElementClipPath != null) {
            clipPath.subtract(new Area(clipElementClipPath.getClipPath()));
View Full Code Here

Examples of org.apache.batik.gvt.GVTFactory

        // When there is a viewbox, need two node:
        //  + one for the viewBox and implements the clipping  (sometimes not,
        // depending on overflow)
        //  + one for the viewBox to patternRegion transform
        //
        GVTFactory gvtFactory = ctx.getGVTFactory();
        AffineTransform nodeTransform = null;
        if(hasViewBox){
            nodeTransform = preserveAspectRatioTransform;
            if(!overflow){
                // Need to do clipping
                CompositeGraphicsNode newPatternContentNode
                    = gvtFactory.createCompositeGraphicsNode();

                newPatternContentNode.getChildren().add(patternContentNode);

                GraphicsNodeRableFactory gnrFactory
                    = ctx.getGraphicsNodeRableFactory();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.