Examples of NumberProperty


Examples of org.apache.fop.fo.properties.NumberProperty

            // Interpret this in context of the property or do it later?
            prop = new NCnameProperty(currentTokenValue);
            break;

        case TOK_FLOAT:
            prop = new NumberProperty(new Double(currentTokenValue));
            break;

        case TOK_INTEGER:
            prop = new NumberProperty(new Integer(currentTokenValue));
            break;

        case TOK_PERCENT:
            /*
             * Get the length base value object from the Maker. If null, then
             * this property can't have % values. Treat it as a real number.
             */
            double pcval = new Double(currentTokenValue.substring(0,
                        currentTokenValue.length() - 1)).doubleValue() / 100.0;
            PercentBase pcBase = this.propInfo.getPercentBase();
            if (pcBase != null) {
                if (pcBase.getDimension() == 0) {
                    prop = new NumberProperty(pcval * pcBase.getBaseValue());
                } else if (pcBase.getDimension() == 1) {
                    prop = new PercentLength(pcval, pcBase);
                } else {
                    throw new PropertyException("Illegal percent dimension value");
                }
            } else {
                // WARNING? Interpret as a decimal fraction, eg. 50% = .5
                prop = new NumberProperty(pcval);
            }
            break;

        case TOK_NUMERIC:
            // A number plus a valid unit name.
            int numLen = currentTokenValue.length() - currentUnitLength;
            String unitPart = currentTokenValue.substring(numLen);
            Double numPart = new Double(currentTokenValue.substring(0,
                    numLen));
            if (unitPart.equals(RELUNIT)) {
                prop = (Property) NumericOp.multiply(new NumberProperty(numPart.doubleValue()),
                                    propInfo.currentFontSize());
            } else {
                prop = new FixedLength(numPart.doubleValue(), unitPart);
            }
            break;
View Full Code Here

Examples of org.apache.fop.fo.properties.NumberProperty

    private Property evalModulo(Number op1,
                                Number op2) throws PropertyException {
        if (op1 == null || op2 == null) {
            throw new PropertyException("Non number operand to modulo");
        }
        return new NumberProperty(op1.doubleValue() % op2.doubleValue());
    }
View Full Code Here

Examples of org.apache.fop.fo.properties.NumberProperty

        double n = dbl.doubleValue();
        double r = Math.floor(n + 0.5);
        if (r == 0.0 && n < 0.0) {
            r = -r;    // round(-0.2) returns -0 not 0
        }
        return new NumberProperty(r);
    }
View Full Code Here

Examples of org.apache.fop.fo.properties.NumberProperty

            // Interpret this in context of the property or do it later?
            prop = new NCnameProperty(currentTokenValue);
            break;

        case TOK_FLOAT:
            prop = new NumberProperty(new Double(currentTokenValue));
            break;

        case TOK_INTEGER:
            prop = new NumberProperty(new Integer(currentTokenValue));
            break;

        case TOK_PERCENT:
            /*
             * Get the length base value object from the Maker. If null, then
             * this property can't have % values. Treat it as a real number.
             */
            double pcval = new Double(currentTokenValue.substring(0,
                        currentTokenValue.length() - 1)).doubleValue() / 100.0;
            PercentBase pcBase = this.propInfo.getPercentBase();
            if (pcBase != null) {
                if (pcBase.getDimension() == 0) {
                    prop = new NumberProperty(pcval * pcBase.getBaseValue());
                } else if (pcBase.getDimension() == 1) {
                    prop = new PercentLength(pcval, pcBase);
                } else {
                    throw new PropertyException("Illegal percent dimension value");
                }
            } else {
                // WARNING? Interpret as a decimal fraction, eg. 50% = .5
                prop = new NumberProperty(pcval);
            }
            break;

        case TOK_NUMERIC:
            // A number plus a valid unit name.
            int numLen = currentTokenValue.length() - currentUnitLength;
            String unitPart = currentTokenValue.substring(numLen);
            Double numPart = new Double(currentTokenValue.substring(0,
                    numLen));
            if (unitPart.equals(RELUNIT)) {
                prop = (Property) NumericOp.multiply(new NumberProperty(numPart.doubleValue()),
                                    propInfo.currentFontSize());
            } else {
                prop = new FixedLength(numPart.doubleValue(), unitPart);
            }
            break;
View Full Code Here

Examples of org.apache.fop.fo.properties.NumberProperty

    private Property evalModulo(Number op1,
                                Number op2) throws PropertyException {
        if (op1 == null || op2 == null) {
            throw new PropertyException("Non number operand to modulo");
        }
        return new NumberProperty(op1.doubleValue() % op2.doubleValue());
    }
View Full Code Here

Examples of org.apache.fop.fo.properties.NumberProperty

                         PropertyInfo pInfo) throws PropertyException {
        Number dbl = args[0].getNumber();
        if (dbl == null) {
            throw new PropertyException("Non number operand to ceiling function");
        }
        return new NumberProperty(Math.ceil(dbl.doubleValue()));
    }
View Full Code Here

Examples of org.apache.fop.fo.properties.NumberProperty

        double n = dbl.doubleValue();
        double r = Math.floor(n + 0.5);
        if (r == 0.0 && n < 0.0) {
            r = -r;    // round(-0.2) returns -0 not 0
        }
        return new NumberProperty(r);
    }
View Full Code Here

Examples of org.apache.fop.fo.properties.NumberProperty

            // Interpret this in context of the property or do it later?
            prop = new NCnameProperty(currentTokenValue);
            break;

        case TOK_FLOAT:
            prop = new NumberProperty(new Double(currentTokenValue));
            break;

        case TOK_INTEGER:
            prop = new NumberProperty(new Integer(currentTokenValue));
            break;

        case TOK_PERCENT:
            /*
             * Get the length base value object from the Maker. If null, then
             * this property can't have % values. Treat it as a real number.
             */
            double pcval = new Double(currentTokenValue.substring(0,
                        currentTokenValue.length() - 1)).doubleValue() / 100.0;
            PercentBase pcBase = this.propInfo.getPercentBase();
            if (pcBase != null) {
                if (pcBase.getDimension() == 0) {
                    prop = new NumberProperty(pcval * pcBase.getBaseValue());
                } else if (pcBase.getDimension() == 1) {
                    prop = new PercentLength(pcval, pcBase);
                } else {
                    throw new PropertyException("Illegal percent dimension value");
                }
            } else {
                // WARNING? Interpret as a decimal fraction, eg. 50% = .5
                prop = new NumberProperty(pcval);
            }
            break;

        case TOK_NUMERIC:
            // A number plus a valid unit name.
            int numLen = currentTokenValue.length() - currentUnitLength;
            String unitPart = currentTokenValue.substring(numLen);
            Double numPart = new Double(currentTokenValue.substring(0,
                    numLen));
            if (unitPart.equals(RELUNIT)) {
                prop = (Property) NumericOp.multiply(new NumberProperty(numPart.doubleValue()),
                                    propInfo.currentFontSize());
            } else {
                prop = new FixedLength(numPart.doubleValue(), unitPart);
            }
            break;
View Full Code Here

Examples of org.apache.fop.fo.properties.NumberProperty

    private Property evalModulo(Number op1,
                                Number op2) throws PropertyException {
        if (op1 == null || op2 == null) {
            throw new PropertyException("Non number operand to modulo");
        }
        return new NumberProperty(op1.doubleValue() % op2.doubleValue());
    }
View Full Code Here

Examples of org.apache.fop.fo.properties.NumberProperty

                         PropertyInfo pInfo) throws PropertyException {
        Number dbl = args[0].getNumber();
        if (dbl == null) {
            throw new PropertyException("Non number operand to floor function");
        }
        return new NumberProperty(Math.floor(dbl.doubleValue()));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.