Package org.apache.batik.bridge

Examples of org.apache.batik.bridge.IllegalAttributeValueException


        }
        int unitsType;
        try {
            unitsType = SVGUtilities.parseCoordinateSystem(patternContentUnits);
        } catch (IllegalArgumentException ex) {
            throw new IllegalAttributeValueException(
                Messages.formatMessage("pattern.units.invalid",
                                       new Object[] {patternContentUnits,
                                                  ATTR_PATTERN_CONTENT_UNITS}));
        }
View Full Code Here


            if (filterResolutionX == 0) {
                return null; // zero value disable rendering of the filter
            }
            if (filterResolutionX < 0) {
                // A negative value is an error
                throw new IllegalAttributeValueException(
                    Messages.formatMessage("filter.filterResX.invalid", null));
            }
        }
        float filterResolutionY = filterResolutionX; // default is filterResX
        if (filterResolution[1] != null) {
            filterResolutionY = filterResolution[1].floatValue();
            if (filterResolutionY == 0) {
                return null; // zero value disable rendering of the filter
            }
            if (filterResolutionY < 0) {
                // A negative value is an error
                throw new IllegalAttributeValueException(
                    Messages.formatMessage("filter.filterResY.invalid", null));
            }
        }

        // Set resolution in filterChain
        filterChain.setFilterResolutionX((int)filterResolutionX);
        filterChain.setFilterResolutionY((int)filterResolutionY);

        // Now build the filter chain. Create a map for filter nodes
        // to advertise themselves as named sources.
        Map filterNodeMap = new HashMap();
        if (in == null) {
            // For the filter element, the in parameter is overridden
            in = sourceGraphic;
            filterNodeMap.put(VALUE_SOURCE_GRAPHIC, sourceGraphic);
        }

        for (Node child=filterElement.getFirstChild();
                 child != null;
                 child = child.getNextSibling()) {

            if (child.getNodeType() != Node.ELEMENT_NODE) {
                continue; // skip node that is not an Element
            }
            Element elt = (Element)child;
            Bridge bridge = bridgeContext.getBridge(elt);
            if (bridge == null || !(bridge instanceof FilterPrimitiveBridge)) {
                continue;
                /*
                throw new IllegalAttributeValueException(
                    Messages.formatMessage("filter.subelement.illegal",
                                           new Object[] {elt.getLocalName()}));*/
            }
            FilterPrimitiveBridge filterBridge =
                (FilterPrimitiveBridge)bridge;
            Filter filterNode = filterBridge.create(filteredNode,
                                                    bridgeContext,
                                                    elt,
                                                    filteredElement,
                                                    in,
                                                    filterRegion,
                                                    filterNodeMap);
            if (filterNode == null) {
                throw new IllegalAttributeValueException(
                    Messages.formatMessage("filter.subelement.invalid",
                                           new Object[] {elt.getLocalName()}));
            }
            in = filterNode;
        }
View Full Code Here

     */
    public static int convertSVGInteger(String attrName, String intStr){
        try {
            return Integer.parseInt(intStr);
        } catch (NumberFormatException ex) {
            throw new IllegalAttributeValueException(
                Messages.formatMessage("integer.invalid",
                                       new Object[] {intStr, attrName}));
        }
    }
View Full Code Here

     */
    public static float convertSVGNumber(String attrName, String numStr){
        try {
            return Float.parseFloat(numStr);
        } catch (NumberFormatException ex) {
            throw new IllegalAttributeValueException(
                Messages.formatMessage("float.invalid",
                                       new Object[] {numStr, attrName}));

        }
    }
View Full Code Here

        int unitsType;
        try {
            unitsType = parseCoordinateSystem(units);
        } catch (IllegalArgumentException ex) {
            throw new IllegalAttributeValueException(
                Messages.formatMessage("region.units.invalid",
                                  new Object[] {units,
                                                unitsAttr,
                                                filterElement.getLocalName()}));
        }
        double x, y, w, h;
        short hd = UnitProcessor.HORIZONTAL_LENGTH;
        short vd = UnitProcessor.VERTICAL_LENGTH;

        switch(unitsType) {
        case OBJECT_BOUNDING_BOX:
            x = svgToObjectBoundingBox(filteredElement,
                                       ATTR_X, xStr,
                                       uctx, hd);
            y = svgToObjectBoundingBox(filteredElement,
                                       ATTR_Y, yStr,
                                       uctx, vd);
            w = svgToObjectBoundingBox(filteredElement,
                                       ATTR_WIDTH, wStr,
                                       uctx, hd);
            h = svgToObjectBoundingBox(filteredElement,
                                       ATTR_HEIGHT, hStr,
                                       uctx, vd);
            // Now, take the bounds of the GraphicsNode into account
            Rectangle2D gnBounds = node.getGeometryBounds();
            x = gnBounds.getX() + x*gnBounds.getWidth();
            y = gnBounds.getY() + y*gnBounds.getHeight();
            w *= gnBounds.getWidth();
            h *= gnBounds.getHeight();
            break;
        case USER_SPACE_ON_USE:
            x = svgToUserSpaceOnUse(filteredElement,
                                    ATTR_X, xStr,
                                    uctx, hd);
            y = svgToUserSpaceOnUse(filteredElement,
                                    ATTR_Y, yStr,
                                    uctx, vd);
            w = svgToUserSpaceOnUse(filteredElement,
                                    ATTR_WIDTH, wStr,
                                    uctx, hd);
            h = svgToUserSpaceOnUse(filteredElement,
                                    ATTR_HEIGHT, hStr,
                                    uctx, vd);
            break;
        default:
            /* Never happen: Bad coordinate system is catched previously */
            throw new Error();
        }

        if (w < 0) {
            throw new IllegalAttributeValueException(
                Messages.formatMessage("region.width.illegal",
                    new Object[] {filterElement.getLocalName()}));
        }
        if (h < 0) {
            throw new IllegalAttributeValueException(
                Messages.formatMessage("region.height.illegal",
                    new Object[] {filterElement.getLocalName()}));
        }

        return new Rectangle2D.Double(x, y, w, h);
View Full Code Here

        int unitsType;
        try {
            unitsType = parseCoordinateSystem(units);
        } catch (IllegalArgumentException ex) {
            throw new IllegalAttributeValueException(
                Messages.formatMessage("region.units.invalid",
                                  new Object[] {units,
                                                ATTR_PRIMITIVE_UNITS,
                                       filterPrimitiveElement.getLocalName()}));
        }

        double x = defaultRegion.getX();
        double y = defaultRegion.getY();
        double w = defaultRegion.getWidth();
        double h = defaultRegion.getHeight();
        short hd = UnitProcessor.HORIZONTAL_LENGTH;
        short vd = UnitProcessor.VERTICAL_LENGTH;

        switch(unitsType) {
        case OBJECT_BOUNDING_BOX:
            Rectangle2D gnBounds = node.getGeometryBounds();
            if (xStr.length() != 0) {
                x = svgToObjectBoundingBox(filteredElement,
                                           ATTR_X, xStr,
                                           uctx, hd);
                x = gnBounds.getX() + x*gnBounds.getWidth();
            }
            if (yStr.length() != 0) {
                y = svgToObjectBoundingBox(filteredElement,
                                           ATTR_Y, yStr,
                                           uctx, vd);
                y = gnBounds.getY() + y*gnBounds.getHeight();
            }
            if (wStr.length() != 0) {
                w = svgToObjectBoundingBox(filteredElement,
                                           ATTR_WIDTH, wStr,
                                           uctx, hd);
                w *= gnBounds.getWidth();
            }
            if (hStr.length() != 0) {
                h = svgToObjectBoundingBox(filteredElement,
                                           ATTR_HEIGHT, hStr,
                                           uctx, vd);
                h *= gnBounds.getHeight();
            }
            break;
        case USER_SPACE_ON_USE:
            if (xStr.length() != 0) {
                x = svgToUserSpaceOnUse(filteredElement,
                                        ATTR_X, xStr,
                                        uctx, hd);
            }
            if (yStr.length() != 0) {
                y = svgToUserSpaceOnUse(filteredElement,
                                        ATTR_Y, yStr,
                                        uctx, vd);
            }
            if (wStr.length() != 0) {
                w = svgToUserSpaceOnUse(filteredElement,
                                        ATTR_WIDTH, wStr,
                                        uctx, hd);
            }
            if (hStr.length() != 0) {
                h = svgToUserSpaceOnUse(filteredElement,
                                        ATTR_HEIGHT, hStr,
                                        uctx, vd);
            }
            break;
        default:
            /* Never happen: Bad coordinate system is catched previously */
            throw new Error();
        }

        if (w < 0) {
            throw new IllegalAttributeValueException(
                Messages.formatMessage("region.width.illegal",
                    new Object[] {filterPrimitiveElement.getLocalName()}));
        }
        if (h < 0) {
            throw new IllegalAttributeValueException(
                Messages.formatMessage("region.height.illegal",
                    new Object[] {filterPrimitiveElement.getLocalName()}));
        }

        return new Rectangle2D.Double(x, y, w, h);
View Full Code Here

        default:
            /* Never happen: Bad coordinate system is catched previously */
            throw new Error();
        }
        if (length < 0) {
            throw new IllegalAttributeValueException(
                Messages.formatMessage("length.illegal",
                                       new Object[] {attrLengthName}));
        }
        return length;
    }
View Full Code Here

                                                         ParserFactory pf) {
        try {
            StringReader r = new StringReader(e.getAttributeNS(null, attrName));
            return AWTTransformProducer.createAffineTransform(r, pf);
        } catch (ParseException ex) {
            throw new IllegalAttributeValueException(
                Messages.formatMessage("transform.invalid",
                                       new Object[] {e.getLocalName(),
                                                     ex.getMessage()}));
        }
    }
View Full Code Here

        UnitProcessor.UnitResolver ur = new UnitProcessor.UnitResolver();
        p.setLengthHandler(ur);
        try {
            p.parse(new StringReader(valueStr));
        } catch (ParseException ex) {
            throw new IllegalAttributeValueException(
                Messages.formatMessage("length.invalid",
                                       new Object[] {valueStr, attrName}));
        }
        return UnitProcessor.svgToUserSpace(ur.unit,
                                            ur.value,
View Full Code Here

        UnitProcessor.UnitResolver ur = new UnitProcessor.UnitResolver();
        p.setLengthHandler(ur);
        try {
            p.parse(new StringReader(valueStr));
        } catch (ParseException ex) {
            throw new IllegalAttributeValueException(
                Messages.formatMessage("length.invalid",
                                       new Object[] {valueStr, attrName}));
        }
        float value = ur.value;
        if (ur.unit == SVGLength.SVG_LENGTHTYPE_PERCENTAGE) {
View Full Code Here

TOP

Related Classes of org.apache.batik.bridge.IllegalAttributeValueException

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.