Package org.foray.fotree.value

Examples of org.foray.fotree.value.PropertyCollection


    /**
     * Returns the "font-weight" component from this compound property.
     * @return The "font-weight" component from this compound property.
     */
    public PdFontWeight getWeight() {
        final PropertyCollection collection = (PropertyCollection) value();
        return (PdFontWeight) collection.findProperty(
                FoProperty.FONT_WEIGHT);
    }
View Full Code Here


    /**
     * Returns the "font-size" component from this compound property.
     * @return The "font-size" component from this compound property.
     */
    public PdFontSize getSize() {
        final PropertyCollection collection = (PropertyCollection) value();
        return (PdFontSize) collection.findProperty(FoProperty.FONT_SIZE);
    }
View Full Code Here

    /**
     * Returns the "line-height" component from this compound property.
     * @return The "line-height" component from this compound property.
     */
    public PdLineHeight getLineHeight() {
        final PropertyCollection collection = (PropertyCollection) value();
        return (PdLineHeight) collection.findProperty(
                FoProperty.LINE_HEIGHT);
    }
View Full Code Here

    /**
     * Returns the "font-family" component from this compound property.
     * @return The "font-family" component from this compound property.
     */
    public PdFontFamily getFamily() {
        final PropertyCollection collection = (PropertyCollection) value();
        return (PdFontFamily) collection.findProperty(
                FoProperty.FONT_FAMILY);
    }
View Full Code Here

     * @return The value of this property.
     */
    public int getValue(final FoContext context, final FObj fobj,
            final AbsoluteAxis axis) {
        if (value() instanceof PropertyCollection) {
            final PropertyCollection collection =
                    (PropertyCollection) value();
            if (collection.getCount() < 1) {
                return getValueNoInstance(axis);
            }
            int index = -1;
            if (axis == AbsoluteAxis.VERTICAL) {
                index = 0;
            } else if (axis == AbsoluteAxis.HORIZONTAL) {
                if (collection.getCount() > 1) {
                    index = 1;
                } else {
                    index = 0;
                }
            }
            final Property property = collection.getItem(index);
            final PropertyValue pv = property.value();
            final DtLength length = (DtLength) pv;
            return length.getValue(fobj.traitFontSize(context));
        }
        if (value().canEvalKeyword()) {
View Full Code Here

            final String value) throws PropertyException {
        final PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
        if (pv != null) {
            return pv;
        }
        final PropertyCollection collection = new PropertyCollection();
        final StringTokenizer st = new StringTokenizer(value);
        if (st.countTokens() < 1 || st.countTokens() > 2) {
            throw unexpectedValue(value, fobj);
        }
        while (st.hasMoreTokens()) {
            PropertyValue insideValue = null;
            Property insideProperty = null;
            insideValue = DtTime.makeTimeDT(value);
            if (insideValue == null) {
                insideValue = DtPercentage.makePercentageDT(value);
            }
            if (insideValue == null) {
                throw unexpectedValue(value, fobj);
            }
            insideProperty = new PdPause(insideValue);
            collection.addItem(insideProperty);
        }
        throw unexpectedValue(value, fobj);
    }
View Full Code Here

            }
        }
        if (! (value() instanceof PropertyCollection)) {
            return 0;
        }
        final PropertyCollection collection = (PropertyCollection) value();
        int index = -1;
        switch (propertyType) {
        case PAUSE_BEFORE: {
            index = 0;
            break;
        }
        case PAUSE_AFTER: {
            if (collection.getCount() > 1) {
                index = 1;
            } else {
                index = 0;
            }
            break;
        }
        default: {
            return getValueNoInstance();
        }
        }
        final AbstractPause pauseProperty =
                (AbstractPause) collection.getItem(index);
        return pauseProperty.getValue(context, fobj, propertyType);
    }
View Full Code Here

        }
        final StringTokenizer st = new StringTokenizer(value);
        if (st.countTokens() < 1 || st.countTokens() > 2) {
            throw unexpectedValue(value, fobj);
        }
        final PropertyCollection collection = new PropertyCollection();
        while (st.hasMoreTokens()) {
            final String token = st.nextToken();
            final DtLength length = DtLength.makeLengthDT(token);
            if (length == null) {
                throw unexpectedValue(value, fobj);
            }
            final PdSize insideSize = new PdSize(length);
            collection.addItem(insideSize);
        }
        return collection;
    }
View Full Code Here

     * @return The parsed, storable property value.
     * @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()
View Full Code Here

     * @return The value of this property.
     */
    public int getShorthandValue(final FoContext context, final FObj fobj,
            final AbsoluteAxis axis, final int paddingRectangleDimension,
            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()) {
View Full Code Here

TOP

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

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.