Package org.foray.fotree

Examples of org.foray.fotree.FObj


     * @param fobj The FO object for whom this property is being evaluated.
     * @return The value of this function.
     */
    public PropertyValue eval(final Property callingProperty, final FObj fobj) {
        /* TODO: Provide the right context. */
        FObj parent = fobj.effectiveParent(null);
        final FoProperty propertyType = this.getPropertyType();
        Property ps = null;
        while (parent != null && ps == null) {
            ps = parent.getPropertyList().getProperty(propertyType);
            /* TODO: Provide the right context. */
            parent = fobj.effectiveParent(null);
        }
        if (ps == null) {
            return null;
View Full Code Here


     * evaluated.
     * @param context An object that knows how to resolve FO context issues.
     * @return The Numeric representation of the function value.
     */
    public DtLength eval(final FObj fobj, final FoContext context) {
        final FObj item = fobj.getNearestListItem(null);
        final int startIndent = item.traitStartIndent(context);
        /* TODO: We don't know how to compute this yet. */
        final int startIntrusionAdjustment = 0;
        final int provisionalDistanceBetweenStarts
                /* TODO: Not sure the parameter passed here is correct. */
                = item.traitProvisionalDistanceBetweenStarts(context);

        final int length
                = startIndent
                + startIntrusionAdjustment
                + provisionalDistanceBetweenStarts;
View Full Code Here

        final FoDocumentReader reader = FoDocumentReader.getInstance();
        final FOTreeBuilder foTree = reader.buildFoTree(
                "fo/font-family-001.fo");
        final Flow flow = this.getFlow(foTree);

        FObj node = flow.getChildAt(0);
        assertTrue(node instanceof Block);
        Block block = (Block) node;
        String[] fontFamilies = block.traitFontFamily(null);
        assertEquals(1, fontFamilies.length);
        /* The default font-family is "serif". */
 
View Full Code Here

    public void testFontSize001() throws FOrayException {
        final FoDocumentReader reader = FoDocumentReader.getInstance();
        final FOTreeBuilder foTree = reader.buildFoTree("fo/font-size-001.fo");
        final Flow flow = this.getFlow(foTree);

        FObj node = flow.getChildAt(0);
        assertTrue(node instanceof Block);
        Block block = (Block) node;
        int fontSize = block.traitFontSize(null);
        /* The default font size is 12 points. */
        assertEquals(12000, fontSize);

        node = flow.getChildAt(1);
        assertTrue(node instanceof Block);
        block = (Block) node;
        fontSize = block.traitFontSize(null);
        assertEquals(8000, fontSize);

        node = flow.getChildAt(2);
        assertTrue(node instanceof Block);
        block = (Block) node;
        final Font font = node.getPrimaryFont(null).getFont();
        assertEquals("Courier", font.getFamilyName());
        assertEquals(426, font.getXHeight(1000));
        final int nominalFontSize = block.traitFontSize(null);
        /* The nominal font-size is 10 pts. */
        assertEquals(10000, nominalFontSize);
View Full Code Here

     * @param foTree The fo tree whose first flow is needed.
     * @return The first flow in {@code foTree}.
     */
    protected Flow getFlow(final FOTreeBuilder foTree) {
        final Root root = foTree.getRootFo();
        FObj node = root.getChildAt(1);
        assertTrue(node instanceof PageSequence);
        final PageSequence sequence = (PageSequence) node;
        node = sequence.getChildAt(0);
        assertTrue(node instanceof Flow);
        final Flow flow = (Flow) node;
View Full Code Here

        final FOTreeBuilder foTree = reader.buildFoTree(
                "fo/graphic-001.fo");
        final Flow flow = this.getFlow(foTree);

        /* The second child should be a block ... */
        FObj node = flow.getChildAt(1);
        assertTrue(node instanceof Block);
        final Block block = (Block) node;

        /* ... which contains an InstreamForeignObject ... */
        node = block.getChildAt(0);
View Full Code Here

     */
    public FoValue getValue(final FoContext context, final FObj fobj) {
        if (value().canEvalKeyword()) {
            final FoValue keyword = this.convertValueToFoValue(value());
            if (keyword == FoValue.INHERIT) {
                final FObj parent = fobj.effectiveParent(context);
                if (parent != null) {
                    return getInheritedValue(context, parent);
                }
                return getValueNoInstance();
            }
View Full Code Here

     * @param fobj The FO for which this value is needed.
     * @return The initial value for this property.
     */
    public static FoValue getValueNoInstance(final FoContext context,
            final FObj fobj) {
        final FObj parent = fobj.effectiveParent(context);
        if (parent != null) {
            return parent.getPropertyList().traitSpeak(parent, context);
        }
        return FoValue.NORMAL;
    }
View Full Code Here

     */
    public FoValue getValue(final FoContext context, final FObj fobj) {
        if (value().canEvalKeyword()) {
            final FoValue keyword = this.convertValueToFoValue(value());
            if (keyword == FoValue.INHERIT) {
                final FObj parent = fobj.effectiveParent(context);
                if (parent != null) {
                    return getInheritedValue(context, parent);
                }
                return getValueNoInstance(context, fobj);
            }
View Full Code Here

     * @param fobj The FO for which this value is needed.
     * @return The initial value for this property.
     */
    public static String[] getValueNoInstance(final FoContext context,
            final FObj fobj) {
        final FObj parent = fobj.effectiveParent(context);
        if (parent != null) {
            return parent.traitFontFamily(context);
        }
        return PdFontFamily.DEFAULT_FONT_FAMILY;
    }
View Full Code Here

TOP

Related Classes of org.foray.fotree.FObj

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.