Package org.apache.fop.fo.expr

Examples of org.apache.fop.fo.expr.PropertyException


                } else {
                    throw new NumberFormatException();
                }
                if ((red < 0.0 || red > 1.0) || (green < 0.0 || green > 1.0)
                        || (blue < 0.0 || blue > 1.0)) {
                    throw new PropertyException("Color values out of range");
                }
            } else {
                throw new NullPointerException();
            }
        } catch (Exception e) {
            throw new PropertyException("Unknown color format: " + value);
        }
        return new Color(red, green, blue);
    }
View Full Code Here


                        blue = Float.parseFloat(str) / 255f;
                    }
                }
                if ((red < 0.0 || red > 1.0) || (green < 0.0 || green > 1.0)
                        || (blue < 0.0 || blue > 1.0)) {
                    throw new PropertyException("Color values out of range");
                }
                parsedColor = new Color(red, green, blue);
            } catch (Exception e) {
                throw new PropertyException(
                        "Arguments to rgb() must be [0..255] or [0%..100%]");
            }
        } else {
            throw new PropertyException("Unknown color format: " + value
                    + ". Must be rgb(r,g,b)");
        }
        return parsedColor;
    }
View Full Code Here

                parsedColor = new Color(red, green, blue, alpha);
            } else {
                throw new NumberFormatException();
            }
        } catch (NumberFormatException e) {
            throw new PropertyException("Unknown color format: " + value
                    + ". Must be #RGB. #RGBA, #RRGGBB, or #RRGGBBAA");
        }
        return parsedColor;
    }
View Full Code Here

                }
                /* Verify rgb replacement arguments */
                if ((red < 0.0 || red > 1.0)
                        || (green < 0.0 || green > 1.0)
                        || (blue < 0.0 || blue > 1.0)) {
                  throw new PropertyException("Color values out of range");
                 }
                /* Get and verify ICC profile name */
                String iccProfileName = null;
                if (st.hasMoreTokens()) {
                    iccProfileName = st.nextToken().trim();
                }
                if (iccProfileName == null || iccProfileName.length() == 0) {
                    throw new PropertyException("ICC profile name missing");
                }
                /* Get and verify ICC profile source */
                String iccProfileSrc = null;
                if (st.hasMoreTokens()) {
                    iccProfileSrc = st.nextToken().trim();
                    // Strip quotes
                    iccProfileSrc = iccProfileSrc.substring(1, iccProfileSrc.length() - 1);
                }
                if (iccProfileSrc == null || iccProfileSrc.length() == 0) {
                    throw new PropertyException("ICC profile source missing");
                }
                /* ICC profile arguments */
                List iccArgList = new LinkedList();
                while (st.hasMoreTokens()) {
                    String str = st.nextToken().trim();
                    iccArgList.add(new Float(str));
                }
                /* Copy ICC profile arguments from list to array */
                float[] iccComponents = new float[iccArgList.size()];
                for (int ix = 0; ix < iccArgList.size(); ix++) {
                    iccComponents[ix] = ((Float)iccArgList.get(ix)).floatValue();
                }
                /* Ask FOP factory to get ColorSpace for the specified ICC profile source */
                ColorSpace colorSpace = (foUserAgent != null
                        ? foUserAgent.getFactory().getColorSpace(
                                foUserAgent.getBaseURL(), iccProfileSrc) : null);
                if (colorSpace != null) {
                    // ColorSpace available - create ColorExt (keeps track of replacement rgb
                    // values for possible later colorTOsRGBString call
                    parsedColor = ColorExt.createFromFoRgbIcc(red, green, blue,
                            iccProfileName, iccProfileSrc, colorSpace, iccComponents);
                } else {
                    // ICC profile could not be loaded - use rgb replacement values */
                    log.warn("Color profile '" + iccProfileSrc
                            + "' not found. Using rgb replacement values.");
                    parsedColor = new Color(red, green, blue);
                }
            } catch (Exception e) {
                throw new PropertyException(
                        "Arguments to rgb-icc() must be [0..255] or [0%..100%]");
            }
        } else {
            throw new PropertyException("Unknown color format: " + value
                    + ". Must be fop-rgb-icc(r,g,b,NCNAME,\"src\",....)");
        }
        return parsedColor;
    }
View Full Code Here

              }
                if ((cyan < 0.0 || cyan > 1.0)
                        || (magenta < 0.0 || magenta > 1.0)
                        || (yellow < 0.0 || yellow > 1.0)
                        || (black < 0.0 || black > 1.0)) {
                    throw new PropertyException("Color values out of range");
                }
                float[] cmyk = new float[] {cyan, magenta, yellow, black};
                CMYKColorSpace cmykCs = CMYKColorSpace.getInstance();
                float[] rgb = cmykCs.toRGB(cmyk);
                parsedColor = ColorExt.createFromFoRgbIcc(rgb[0], rgb[1], rgb[2],
                        null, "#CMYK", cmykCs, cmyk);

               
            } catch (Exception e) {
                throw new PropertyException(
                        "Arguments to cmyk() must be in the range [0%-100%] or [0.0-1.0]");
            }
        } else {
            throw new PropertyException("Unknown color format: " + value
                    + ". Must be cmyk(c,m,y,k)");
        }
        return parsedColor;
    }
View Full Code Here

       
        //TODO do we need context for getBPPaddingAndBorder() and getIPPaddingAndBorder()?
        if (getUserAgent().validateStrictly()
                && (getCommonBorderPaddingBackground().getBPPaddingAndBorder(false, null) != 0
                || getCommonBorderPaddingBackground().getIPPaddingAndBorder(false, null) != 0)) {
            throw new PropertyException("Border and padding for region \""
                    + regionName + "\" must be '0' (See 6.4.13 in XSL 1.0).");
        }
    }
View Full Code Here

            }
            if (newProp != null) {
                newProp = convertProperty(newProp, propertyList, fo);
            }
            if (newProp == null) {
                throw new PropertyException("No conversion defined " + pvalue);
            }
            return newProp;
        } catch (PropertyException propEx) {
            propEx.setLocator(fo.getLocator());
            propEx.setPropertyName(getName());
View Full Code Here

        while (i.hasNext()) {
            Property prop = (Property)i.next();
            switch (prop.getEnum()) {
                case Constants.EN_NONE:
                    if (under | over | through | blink) {
                        throw new PropertyException(
                                "Invalid combination of values");
                    }
                    none = true;
                    break;
                case Constants.EN_UNDERLINE:
                case Constants.EN_NO_UNDERLINE:
                    if (none) {
                        throw new PropertyException("'none' specified, no additional values allowed");
                    }
                    if (under) {
                        throw new PropertyException("Invalid combination of values");
                    }
                    under = true;
                    break;
                case Constants.EN_OVERLINE:
                case Constants.EN_NO_OVERLINE:
                    if (none) {
                        throw new PropertyException("'none' specified, no additional values allowed");
                    }
                    if (over) {
                        throw new PropertyException("Invalid combination of values");
                    }
                    over = true;
                    break;
                case Constants.EN_LINE_THROUGH:
                case Constants.EN_NO_LINE_THROUGH:
                    if (none) {
                        throw new PropertyException("'none' specified, no additional values allowed");
                    }
                    if (through) {
                        throw new PropertyException("Invalid combination of values");
                    }
                    through = true;
                    break;
                case Constants.EN_BLINK:
                case Constants.EN_NO_BLINK:
                    if (none) {
                        throw new PropertyException("'none' specified, no additional values allowed");
                    }
                    if (blink) {
                        throw new PropertyException("Invalid combination of values");
                    }
                    blink = true;
                    break;
                default:
                    throw new PropertyException("Invalid value specified: " + prop);
            }
            addProperty(prop);
        }
    }
View Full Code Here

                    return new TextDecorationProperty((ListProperty)p);
                } else if (p instanceof EnumProperty) {
                    ListProperty lst = new ListProperty(p);
                    return new TextDecorationProperty(lst);
                } else {
                    throw new PropertyException("Cannot convert anything other "
                            + "than a list property, got a " + p.getClass().getName());
                }
            }
        }
View Full Code Here

                if (prop instanceof EnumProperty) {
                    //skip
                } else if (prop instanceof NCnameProperty) {
                    Property prop_enum = checkEnumValues(((NCnameProperty)prop).getString());
                    if (prop_enum == null) {
                        throw new PropertyException("Illegal enum value: " + prop.getString());
                    }
                    l.set(i, prop_enum);
                } else {
                    throw new PropertyException("Invalid content for text-decoration "
                            + "property: " + prop);
                }
            }
            return lst;
        }
View Full Code Here

TOP

Related Classes of org.apache.fop.fo.expr.PropertyException

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.