Package org.foray.fotree.value

Examples of org.foray.fotree.value.PropertyValue


     * @return The parsed, storable property value.
     * @throws PropertyException For an invalid property value.
     */
    private PropertyValue createPropertyValue(final FObj fobj,
            final String value) throws PropertyException {
        final PropertyValue pv = standardParse(fobj, value);
        if (pv.canEvalKeyword()) {
            return pv;
        }
        if (pv.canEvalNumeric()) {
            if (pv.getUnitPower() == Expr.UNIT_POWER_NUMERIC) {
                return pv;
            }
        }
        throw unexpectedValue(value, fobj);
    }
View Full Code Here


     * @return The parsed, storable property value.
     * @throws PropertyException For an invalid property value.
     */
    private PropertyValue createPropertyValue(final FObj fobj,
            final String value) throws PropertyException {
        final PropertyValue pv = standardParse(fobj, value);
        if (pv.canEvalNumeric()) {
            return pv;
        }
        throw unexpectedValue(value, fobj);
    }
View Full Code Here

     * @return The parsed, storable property value.
     * @throws PropertyException For an invalid property value.
     */
    private PropertyValue createPropertyValue(final FObj fobj,
            final String value) throws PropertyException {
        final PropertyValue pv = standardParse(fobj, value);
        if (pv.canEvalKeyword()) {
            return pv;
        }
        throw unexpectedValue(value, fobj);
    }
View Full Code Here

     * @return The parsed, storable property value.
     * @throws PropertyException For an invalid property value.
     */
    private PropertyValue createPropertyValue(final FObj fobj,
            final String value) throws PropertyException {
        final PropertyValue pv = this.standardParse(fobj, value);
        if (pv.canEvalKeyword()) {
            return pv;
        }

        /* It is a series of 1-4 tokens. */
        final StringTokenizer st = new StringTokenizer(value);
        if (st.countTokens() < 1
                || st.countTokens() > PdMargin.MAX_TOKENS) {
            throw this.unexpectedValue(value, fobj);
        }
        final ValueCollection collection = new ValueCollection();
        while (st.hasMoreTokens()) {
            final String token = st.nextToken();
            final PropertyValue parsedToken = this.standardParse(fobj, value,
                    null);
            if (parsedToken.canEvalLength()
                    || parsedToken.canEvalPercentage()) {
                collection.addItem(parsedToken);
            } else {
                throw this.unexpectedValue(token, fobj);
            }
        }
View Full Code Here

    private int getCollectionValue(final FoContext context,
            final AbsoluteCompass direction, final FObj fobj) {
        final ValueCollection collection = (ValueCollection) value();
        final int whichElement = PropertyCollection.whichElementForDirectional(
                direction, collection.getCount());
        final PropertyValue value = collection.getItem(whichElement);
        if (value.canEvalPercentage()) {
            int base = 0;
            if (fobj instanceof SimplePageMaster) {
                final SimplePageMaster spm = (SimplePageMaster) fobj;
                base = spm.traitPageHeight();
            } else {
                base = context.widthContainingBlock();
            }
            final float percent = value.evalPercentage();
            return Math.round(base * percent / WKConstants.PERCENT_CONVERSION);
        }
        if (value.canEvalLength()) {
            return this.convertValueToLength(value, fobj, context);
        }
        throw this.unexpectedRetrieval();
    }
View Full Code Here

     * @throws PropertyException If the input is inconsistent.
     */
    protected PropertyValue standardParse(final FObj fobj,
            final String rawPropertyValue, final FoValue[] validKeywords)
            throws PropertyException {
        final PropertyValue pv = checkKeywords(validKeywords, rawPropertyValue);
        if (pv != null) {
            return pv;
        }
        return PropertyParser.parse(fobj, rawPropertyValue,
                this.getPropertyType());
View Full Code Here

     * @return The parsed, storable property value.
     * @throws PropertyException For an invalid property value.
     */
    private PropertyValue createPropertyValue(final FObj fobj,
            final String value) throws PropertyException {
        final PropertyValue pv = standardParse(fobj, value);
        if (pv.canEvalKeyword()) {
            return pv;
        }
        throw unexpectedValue(value, fobj);
    }
View Full Code Here

     * @throws PropertyException For an invalid property value.
     */
    private PropertyValue createShorthandValue(final FObj fobj,
            final String value) throws PropertyException {
        final PropertyCollection collection = new PropertyCollection();
        PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
        if (pv != null) {
            final PdBackgroundPosition property =
                new PdBackgroundPosition(pv);
            collection.addItem(property);
            return collection;
        }
        final StringTokenizer st = new StringTokenizer(value);
        if (st.countTokens() < 1 || st.countTokens() > 2) {
            throw unexpectedValue(value, fobj);
        }
        while (st.hasMoreTokens()) {
            final String token = st.nextToken();
            pv = DtPercentage.makePercentageDT(token);
            if (pv == null) {
                pv = DtLength.makeLengthDT(token);
            }
            if (pv == null) {
                final FoValue keyword = FoValue.xslValueOf(token);
                if (Property.keywordInSet(keyword,
                        PdBackgroundPositionHorizontal.VALID_KEYWORDS)
                        && keyword != FoValue.INHERIT) {
                    pv = FoPropertyKeyword.getPropertyKeyword(keyword);
                }
            }
            if (pv == null) {
                final FoValue keyword = FoValue.xslValueOf(token);
                if (Property.keywordInSet(keyword,
                        PdBackgroundPositionVertical.VALID_KEYWORDS)
                        && keyword != FoValue.INHERIT) {
                    pv = FoPropertyKeyword.getPropertyKeyword(keyword);
                }
            }
            if (pv != null) {
                final PdBackgroundPosition property =
                    new PdBackgroundPosition(pv);
                collection.addItem(property);
            } else {
                throw unexpectedValue(value, fobj);
            }
        }
        if (collection.getCount() == 1) {
            return collection;
        }
        pv = collection.getItem(0).value();
        final PropertyValue pv2 = collection.getItem(1).value();
        /* If the first item is a length or percentage, the other needs to be
         * also. */
        if (pv.canEvalPercentage()
                || pv.canEvalLength()) {
            if (pv2.canEvalPercentage()
                    || pv2.canEvalLength()) {
                return collection;
            }
            throw unexpectedValue(value, fobj);
        }
        /* If the first item is a keyword, the other needs to be also. */
        if (pv.canEvalKeyword()) {
            if (! (pv2.canEvalKeyword())) {
                throw unexpectedValue(value, fobj);
            }
        }
        // The two keywords need to be from each of the two sets.
        final FoValue keyword = ((FoPropertyKeyword) pv).getValue();
View Full Code Here

            final int backgroundImageDimension) {
        final PropertyCollection collection = (PropertyCollection) value();
        final PdBackgroundPosition bpProperty =
            (PdBackgroundPosition) collection
                .getItem(0);
        final PropertyValue pv = bpProperty.value();
        if (collection.getCount() == 1) {
            if (pv.canEvalPercentage()
                    || pv.canEvalLength()) {
                if (axis == AbsoluteAxis.VERTICAL) {
                    return Math.round((paddingRectangleDimension
                            - backgroundImageDimension) / 2);
                }
            }
            if (pv.canEvalKeyword()) {
                final FoValue keyword = this.convertValueToFoValue(pv);
                if (axis == AbsoluteAxis.HORIZONTAL
                        && keywordInSet(keyword,
                                PdBackgroundPositionVertical.VALID_KEYWORDS)) {
                    return Math.round((paddingRectangleDimension
                            - backgroundImageDimension) / 2);
                }
                if (axis == AbsoluteAxis.VERTICAL
                        && keywordInSet(keyword,
                                PdBackgroundPositionHorizontal.VALID_KEYWORDS)) {
                    return Math.round((paddingRectangleDimension
                            - backgroundImageDimension) / 2);
                }
            }
            /*
             * In all other cases, just return the property value normally.
             */
            return bpProperty.getValue(context, fobj, axis,
                    paddingRectangleDimension, backgroundImageDimension);
        }
        /*
         * What is left here is the case where there are two properties. The
         * only real trick is to make sure we use the right one.
         */
        final PdBackgroundPosition bpProperty2 =
            (PdBackgroundPosition) collection
                .getItem(1);
        final PropertyValue pv2 = bpProperty2.value();
        PdBackgroundPosition bpPropertyToUse = null;
        if (pv.canEvalPercentage()
                || pv.canEvalLength()) {
            if (axis == AbsoluteAxis.HORIZONTAL) {
                bpPropertyToUse = bpProperty;
View Full Code Here

     * @return The parsed, storable property value.
     * @throws PropertyException For an invalid property value.
     */
    private PropertyValue createPropertyValue(final FObj fobj,
            final String value) throws PropertyException {
        final PropertyValue pv = standardParse(fobj, value);
        if (pv.canEvalKeyword()) {
            return pv;
        }
        if (pv instanceof DtAngle) {
            return pv;
        }
View Full Code Here

TOP

Related Classes of org.foray.fotree.value.PropertyValue

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.