Package org.foray.fotree.value

Examples of org.foray.fotree.value.PropertyCollection


            final String value) throws PropertyException {
        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 PropertyValue pv = createPropertyValue(fobj,
                    st.nextToken());
            final PdCue cueProperty = new PdCue(pv);
            collection.addItem(cueProperty);
        }
        return collection;
    }
View Full Code Here


    public String getShorthandValue(final FoContext context, final FObj fobj,
            final FoProperty propertyType) {
        if (! (value() instanceof PropertyCollection)) {
            return "";
        }
        final PropertyCollection collection = (PropertyCollection) value();
        int index = -1;
        switch (propertyType) {
        case CUE_BEFORE: {
            index = 0;
            break;
        }
        case CUE_AFTER: {
            if (collection.getCount() > 1) {
                index = 1;
            } else {
                index = 0;
            }
            break;
        }
        default: {
            return getValueNoInstance();
        }
        }
        final AbstractCue cueProperty = (AbstractCue) collection.getItem(index);
        return cueProperty.getValue(context, fobj, propertyType);
    }
View Full Code Here

     * @throws PropertyException For an invalid property value.
     */
    private PropertyValue createPropertyValue(final FObj fobj,
            final String propertyFullName, final String value)
            throws PropertyException {
        final PropertyCollection collection = new PropertyCollection();
        final PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
        if (pv != null) {
            collection.addItem(new PdBackgroundColor(pv));
            collection.addItem(new PdBackgroundImage(pv));
            collection.addItem(new PdBackgroundRepeat(pv));
            collection.addItem(new PdBackgroundAttachment(pv));
            collection.addItem(new PdBackgroundPosition(pv));
            return collection;
        }
        // There are 5 properties supported, one of which can have 2 tokens
        final byte maxTokens = 6;
        // Tokenize the input & put the tokens into an ArrayList
        final StringTokenizer st = new StringTokenizer(value);
        if (st.countTokens() < 1 || st.countTokens() > maxTokens) {
            throw unexpectedValue(value, fobj);
        }
        final List<String> tokenList = new ArrayList<String>(st.countTokens());
        while (st.hasMoreTokens()) {
            tokenList.add(st.nextToken());
        }
        // Create an array indicating which property is in each position
        final FoProperty[] positionArray = new FoProperty[tokenList.size()];
        for (int i = 0; i < tokenList.size(); i++) {
            final FoProperty contentType = getContentType(tokenList.get(i));
            if (contentType == null) {
                throw unexpectedValue(value, fobj);
            }
            positionArray[i] = contentType;
        }
        boolean colorFound = false;
        boolean imageFound = false;
        boolean repeatFound = false;
        boolean attachmentFound = false;
        boolean positionFound = false;
        for (int i = 0; i < positionArray.length; i++) {
            switch (positionArray[i]) {
            case BACKGROUND_COLOR: {
                if (colorFound) {
                    throw unexpectedValue(value, fobj);
                }
                collection.addItem(new PdBackgroundColor(fobj,
                        propertyFullName, tokenList.get(i)));
                colorFound = true;
                break;
            }
            case BACKGROUND_IMAGE: {
                if (imageFound) {
                    throw unexpectedValue(value, fobj);
                }
                collection.addItem(new PdBackgroundImage(fobj,
                        propertyFullName, tokenList.get(i)));
                imageFound = true;
                break;
            }
            case BACKGROUND_REPEAT: {
                if (repeatFound) {
                    throw unexpectedValue(value, fobj);
                }
                collection.addItem(new PdBackgroundRepeat(fobj,
                        propertyFullName, tokenList.get(i)));
                repeatFound = true;
                break;
            }
            case BACKGROUND_ATTACHMENT: {
                if (attachmentFound) {
                    throw unexpectedValue(value, fobj);
                }
                collection.addItem(new PdBackgroundAttachment(fobj,
                        propertyFullName, tokenList.get(i)));
                attachmentFound = true;
                break;
            }
            case BACKGROUND_POSITION: {
                if (positionFound) {
                    throw unexpectedValue(value, fobj);
                }
                final String propertyInput = tokenList.get(i);
                if (i < positionArray.length && positionArray[i + 1]
                        == FoProperty.BACKGROUND_POSITION) {
                    propertyInput.concat(" " + tokenList.get(i + 1));
                    i++;
                }
                collection.addItem(new PdBackgroundPosition(fobj,
                        propertyFullName, tokenList.get(i)));
                positionFound = true;
                break;
            }
            }
View Full Code Here

    /**
     * Returns the background-color component of this compound property.
     * @return The background-color component of this compound property.
     */
    public PdBackgroundColor getColor() {
        final PropertyCollection collection = (PropertyCollection) value();
        return (PdBackgroundColor) collection.findProperty(
                FoProperty.BACKGROUND_COLOR);
    }
View Full Code Here

    /**
     * Returns the background-image component of this compound property.
     * @return The background-image component of this compound property.
     */
    public PdBackgroundImage getImage() {
        final PropertyCollection collection = (PropertyCollection) value();
        return (PdBackgroundImage) collection.findProperty(
                FoProperty.BACKGROUND_IMAGE);
    }
View Full Code Here

    /**
     * Returns the background-repeat component of this compound property.
     * @return The background-repeat component of this compound property.
     */
    public PdBackgroundRepeat getRepeat() {
        final PropertyCollection collection = (PropertyCollection) value();
        return (PdBackgroundRepeat) collection.findProperty(
                FoProperty.BACKGROUND_REPEAT);
    }
View Full Code Here

    /**
     * Returns the background-attachment component of this compound property.
     * @return The background-attachment component of this compound property.
     */
    public PdBackgroundAttachment getAttachment() {
        final PropertyCollection collection = (PropertyCollection) value();
        return (PdBackgroundAttachment) collection.findProperty(
                FoProperty.BACKGROUND_ATTACHMENT);
    }
View Full Code Here

    /**
     * Returns the background-position component of this compound property.
     * @return The background-position component of this compound property.
     */
    public PdBackgroundPosition getPosition() {
        final PropertyCollection collection = (PropertyCollection) value();
        return (PdBackgroundPosition) collection.findProperty(
                FoProperty.BACKGROUND_POSITION);
    }
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.