Package org.apache.batik.gvt.filter

Examples of org.apache.batik.gvt.filter.Filter


        // Extract Blend operation
        CompositeRule rule = getRule(filterElement);

        // Extract sources
        String in1Attr = filterElement.getAttributeNS(null, ATTR_IN);
        Filter in1;
        in1 = CSSUtilities.getFilterSource(filteredNode,
                                           in1Attr,
                                           bridgeContext,
                                           filteredElement,
                                           in,
                                           filterMap);

        String in2Attr = filterElement.getAttributeNS(null, ATTR_IN2);
        if (in2Attr.length() == 0) {
            throw new MissingAttributeException(
                Messages.formatMessage("feBlend.in2.required", null));
        }
        Filter in2;
        in2 = CSSUtilities.getFilterSource(filteredNode,
                                           in2Attr,
                                           bridgeContext,
                                           filteredElement,
                                           in,
                                           filterMap);

        if ((in1 == null) || (in2 == null)) {
            return null;
        }

        //
        // The default region is the union of the input sources
        // regions unless 'in' is 'SourceGraphic' in which case the
        // default region is the filterChain's region
        //
        Filter sourceGraphics = (Filter)filterMap.get(VALUE_SOURCE_GRAPHIC);

        Rectangle2D defaultRegion = in1.getBounds2D();
        defaultRegion.add(in2.getBounds2D());

        if(in1 == sourceGraphics) {
            defaultRegion = filterRegion;
        }

        CSSStyleDeclaration cssDecl
            = bridgeContext.getViewCSS().getComputedStyle(filterElement, null);

        UnitProcessor.Context uctx
            = new DefaultUnitProcessorContext(bridgeContext, cssDecl);

        Rectangle2D blendArea
            = SVGUtilities.convertFilterPrimitiveRegion(filterElement,
                                                        filteredElement,
                                                        defaultRegion,
                                                        filteredNode,
                                                        uctx);

        // Now, do the blend.
        Filter filter = null;
        Vector srcs = new Vector(2);
        srcs.add(in2);
        srcs.add(in1);
        filter = new ConcreteCompositeRable(srcs, rule);
View Full Code Here


            = (CSSPrimitiveValue)cssDecl.getPropertyCSSValue(ATTR_OPACITY);
        Composite composite = CSSUtilities.convertOpacityToComposite(val);
        node.setComposite(composite);

        // Set node filter
        Filter filter = CSSUtilities.convertFilter(element, node, ctx);
        node.setFilter(filter);

        // Set the node mask
        Mask   mask   = CSSUtilities.convertMask(element, node, ctx);
        node.setMask(mask);
View Full Code Here

            at = at.createInverse(); // clip in user space

            GraphicsNodeRableFactory gnrFactory
                = ctx.getGraphicsNodeRableFactory();

            Filter filter = gnrFactory.createGraphicsNodeRable(node);

            Shape clip = at.createTransformedShape
                (new Rectangle2D.Float(x, y, w, h));
            result.setClip(new ConcreteClipRable(filter, clip));
View Full Code Here

            = (CSSPrimitiveValue)cssDecl.getPropertyCSSValue(ATTR_OPACITY);
        Composite composite = CSSUtilities.convertOpacityToComposite(val);
        node.setComposite(composite);

        // Set node filter
        Filter filter = CSSUtilities.convertFilter(element, node, ctx);
        node.setFilter(filter);

        // Set the node mask
        Mask   mask   = CSSUtilities.convertMask(element, node, ctx);
        node.setMask(mask);
View Full Code Here

            at = at.createInverse(); // clip in user space

            GraphicsNodeRableFactory gnrFactory
                = ctx.getGraphicsNodeRableFactory();

            Filter filter = gnrFactory.createGraphicsNodeRable(node);

            Shape clip = at.createTransformedShape
                (new Rectangle2D.Float(x, y, w, h));
            result.setClip(new ConcreteClipRable(filter, clip));
View Full Code Here

                    Messages.formatMessage("feMerge.subelement.invalid",
                                           new Object[] {elt.getLocalName()}));
            }

            String inAttr = elt.getAttributeNS(null, ATTR_IN);
            Filter tmp = CSSUtilities.getFilterSource(filteredNode,
                                                      inAttr,
                                                      bridgeContext,
                                                      elt,
                                                      in,
                                                      filterMap);
            if (tmp == null) {
                continue;
            }
            in = tmp;
            srcs.add(in);
        }

        if (srcs.size() == 0) { // no subelement found
            // <!> FIXME :  the result is unspecified
            return null;
        }

        // The default region is the input sources regions union
        Iterator iter = srcs.iterator();
        Rectangle2D defaultRegion = ((Filter) iter.next()).getBounds2D();
        while (iter.hasNext()) {
            defaultRegion.add(((Filter) iter.next()).getBounds2D());
        }

        CSSStyleDeclaration cssDecl
            = bridgeContext.getViewCSS().getComputedStyle(filterElement, null);

        UnitProcessor.Context uctx
            = new DefaultUnitProcessorContext(bridgeContext, cssDecl);

        Rectangle2D primitiveRegion
            = SVGUtilities.convertFilterPrimitiveRegion(filterElement,
                                                        filteredElement,
                                                        defaultRegion,
                                                        filteredNode,
                                                        uctx);

        Filter filter = null;
        filter = new ConcreteCompositeRable(srcs, CompositeRule.OVER);

        filter = new ConcretePadRable(filter,
                                      primitiveRegion,
                                      PadMode.ZERO_PAD);;
View Full Code Here

            = computeChannelSelector(yChannelSelectorStr);

        //
        // Build filter
        //
        Filter filter = null;

        // Get source 1
        String inAttr = filterElement.getAttributeNS(null, ATTR_IN);
        Filter in1 = CSSUtilities.getFilterSource(filteredNode,
                                                  inAttr,
                                                  bridgeContext,
                                                  filteredElement,
                                                  in,
                                                  filterMap);

        Filter in2 = null;

        // Get source 2
        String in2Attr = filterElement.getAttributeNS(null, ATTR_IN2);
        if (in2Attr.length() == 0) {
            throw new MissingAttributeException(
                Messages.formatMessage("feDisplacementMap.in2.required", null));
        }
        in2 = CSSUtilities.getFilterSource(filteredNode,
                                           in2Attr,
                                           bridgeContext,
                                           filteredElement,
                                           in,
                                           filterMap);

        //
        // The default region is the union of the input sources bounds
        // unless in in is SourceGraphic, in which case the default is
        // the filter chain's region
        //
        Filter sourceGraphics = (Filter)filterMap.get(VALUE_SOURCE_GRAPHIC);

        Rectangle2D defaultRegion = in1.getBounds2D();
        defaultRegion.add(in2.getBounds2D());

        if(in1 == sourceGraphics){
View Full Code Here

        double atScaleY = Math.sqrt(sy*sy + shx*shx);

        AffineTransform srcAt
            = AffineTransform.getScaleInstance(atScaleX, atScaleY);

        Filter displaced = (Filter)getSources().elementAt(0);

        //
        // First, get a rendering from the first source
        //
        /*Rectangle2D aoi = displaced.getBounds2D();
        aoi.intersect(rc.getAreaOfInterest().getBounds2D(), aoi, aoi);
        aoi.setRect(aoi.getX() - scale/2,
                    aoi.getY() - scale/2,
                    aoi.getWidth() + scale,
                    aoi.getHeight() + scale);*/
        Rectangle2D aoi = rc.getAreaOfInterest().getBounds2D();
        aoi.setRect(aoi.getX() - scale/2,
                    aoi.getY() - scale/2,
                    aoi.getWidth() + scale,
                    aoi.getHeight() + scale);
        aoi.intersect(displaced.getBounds2D(), aoi, aoi);

        RenderContext srcRc
            = new RenderContext(srcAt,
                                aoi,
                                rh);
        RenderedImage displacedRed = displaced.createRendering(srcRc);

        if(displacedRed == null){
            return null;
        }

        //
        // Now, get a rendering from the displacement map
        //
        Filter map = (Filter)getSources().elementAt(1);
        PadRable mapPad
            = new ConcretePadRable(map, aoi, PadMode.ZERO_PAD);

        RenderedImage mapRed = mapPad.createRendering(srcRc);

View Full Code Here

        CSSPrimitiveValue val =
            (CSSPrimitiveValue)decl.getPropertyCSSValue(ATTR_OPACITY);
        Composite composite = CSSUtilities.convertOpacityToComposite(val);
        gn.setComposite(composite);

        Filter filter = CSSUtilities.convertFilter(element, gn, ctx);
        gn.setFilter(filter);

        Mask mask = CSSUtilities.convertMask(element, gn, ctx);
        gn.setMask(mask);
View Full Code Here

                    Messages.formatMessage("filter.subelement.illegal",
                                           new Object[] {elt.getLocalName()}));*/
            }
            FilterPrimitiveBridge filterBridge =
                (FilterPrimitiveBridge)bridge;
            Filter filterNode = filterBridge.create(filteredNode,
                                                    bridgeContext,
                                                    elt,
                                                    filteredElement,
                                                    in,
                                                    filterRegion,
View Full Code Here

TOP

Related Classes of org.apache.batik.gvt.filter.Filter

Copyright © 2018 www.massapicom. 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.