Package nextapp.echo2.app

Examples of nextapp.echo2.app.Extent


*
*/
public class FontRenderTest extends TestCase {

    public void testFontRender() {
        Font font = new Font(Font.VERDANA, Font.BOLD | Font.UNDERLINE, new Extent(12, Extent.PT));
        CssStyle cssStyle = new CssStyle();
        FontRender.renderToStyle(cssStyle, font);
        assertEquals("Verdana,Arial,Helvetica,Sans-Serif", cssStyle.getAttribute("font-family"));
        assertEquals("bold", cssStyle.getAttribute("font-weight"));
        assertEquals("underline", cssStyle.getAttribute("text-decoration"));
View Full Code Here


        Grid grid = new Grid(3);
        for (int i = 0; i < 12; ++i) {
            grid.add(new Label());
        }
        for (int i = 0; i < 4; ++i) {
            grid.setColumnWidth(i, new Extent(i + 1));
            grid.setRowHeight(i, new Extent((i + 1)* 10));
        }
       
        GridProcessor gridProcessor = new GridProcessor(grid);
        assertEquals(3, gridProcessor.getColumnCount());
        assertEquals(4, gridProcessor.getRowCount());
        assertEquals(new Extent(1), gridProcessor.getColumnWidth(0));
        assertEquals(new Extent(2), gridProcessor.getColumnWidth(1));
        assertEquals(new Extent(3), gridProcessor.getColumnWidth(2));
        assertEquals(new Extent(10), gridProcessor.getRowHeight(0));
        assertEquals(new Extent(20), gridProcessor.getRowHeight(1));
        assertEquals(new Extent(30), gridProcessor.getRowHeight(2));
        assertEquals(new Extent(40), gridProcessor.getRowHeight(3));
       
        grid.setOrientation(Grid.ORIENTATION_VERTICAL);
        gridProcessor = new GridProcessor(grid);
        assertEquals(4, gridProcessor.getColumnCount());
        assertEquals(3, gridProcessor.getRowCount());
        assertEquals(new Extent(1), gridProcessor.getColumnWidth(0));
        assertEquals(new Extent(2), gridProcessor.getColumnWidth(1));
        assertEquals(new Extent(3), gridProcessor.getColumnWidth(2));
        assertEquals(new Extent(4), gridProcessor.getColumnWidth(3));
        assertEquals(new Extent(10), gridProcessor.getRowHeight(0));
        assertEquals(new Extent(20), gridProcessor.getRowHeight(1));
        assertEquals(new Extent(30), gridProcessor.getRowHeight(2));
    }
View Full Code Here

            }
            grid.add(label);
        }
       
        // Set Column Sizes
        grid.setColumnWidth(0, new Extent(1));
        grid.setColumnWidth(1, new Extent(2));
        grid.setColumnWidth(2, new Extent(4));
        grid.setColumnWidth(3, new Extent(8));
        grid.setColumnWidth(4, new Extent(16));
        grid.setColumnWidth(5, new Extent(32));
        grid.setColumnWidth(6, new Extent(64));

        GridProcessor gridProcessor = new GridProcessor(grid);
       
        // Verify Grid size is correct.
        assertEquals(5, gridProcessor.getColumnCount());
        assertEquals(3, gridProcessor.getRowCount());
       
        // Verify components are at correct positions.
        assertEquals(0, gridProcessor.getComponentIndex(0, 0));
        assertEquals(1, gridProcessor.getComponentIndex(1, 0));
        assertEquals(2, gridProcessor.getComponentIndex(2, 0));
        assertEquals(2, gridProcessor.getComponentIndex(3, 0));
        assertEquals(3, gridProcessor.getComponentIndex(4, 0));
        assertEquals(4, gridProcessor.getComponentIndex(0, 1));
        assertEquals(5, gridProcessor.getComponentIndex(1, 1));
        assertEquals(6, gridProcessor.getComponentIndex(2, 1));
        assertEquals(7, gridProcessor.getComponentIndex(3, 1));
        assertEquals(8, gridProcessor.getComponentIndex(4, 1));
        assertEquals(9, gridProcessor.getComponentIndex(0, 2));
        assertEquals(10, gridProcessor.getComponentIndex(1, 2));
        assertEquals(11, gridProcessor.getComponentIndex(2, 2));
        assertEquals(11, gridProcessor.getComponentIndex(3, 2));
        assertEquals(8, gridProcessor.getComponentIndex(4, 2));
       
        // Verify x-spans were property reduced.
        assertEquals(1, gridProcessor.getColumnSpan(0, 0));
        assertEquals(1, gridProcessor.getColumnSpan(1, 0));
        assertEquals(2, gridProcessor.getColumnSpan(2, 0));
        assertEquals(2, gridProcessor.getColumnSpan(3, 0));
        assertEquals(1, gridProcessor.getColumnSpan(4, 0));
        assertEquals(1, gridProcessor.getColumnSpan(0, 1));
        assertEquals(1, gridProcessor.getColumnSpan(1, 1));
        assertEquals(1, gridProcessor.getColumnSpan(2, 1));
        assertEquals(1, gridProcessor.getColumnSpan(3, 1));
        assertEquals(1, gridProcessor.getColumnSpan(4, 1));
        assertEquals(1, gridProcessor.getColumnSpan(0, 2));
        assertEquals(1, gridProcessor.getColumnSpan(1, 2));
        assertEquals(2, gridProcessor.getColumnSpan(2, 2));
        assertEquals(2, gridProcessor.getColumnSpan(3, 2));
        assertEquals(1, gridProcessor.getColumnSpan(4, 2));
       
        // Verify y-spans were untouched.
        assertEquals(1, gridProcessor.getRowSpan(0, 0));
        assertEquals(1, gridProcessor.getRowSpan(1, 0));
        assertEquals(1, gridProcessor.getRowSpan(2, 0));
        assertEquals(1, gridProcessor.getRowSpan(3, 0));
        assertEquals(1, gridProcessor.getRowSpan(4, 0));
        assertEquals(1, gridProcessor.getRowSpan(0, 1));
        assertEquals(1, gridProcessor.getRowSpan(1, 1));
        assertEquals(1, gridProcessor.getRowSpan(3, 1));
        assertEquals(2, gridProcessor.getRowSpan(4, 1));
        assertEquals(1, gridProcessor.getRowSpan(0, 2));
        assertEquals(1, gridProcessor.getRowSpan(1, 2));
        assertEquals(1, gridProcessor.getRowSpan(2, 2));
        assertEquals(1, gridProcessor.getRowSpan(3, 2));
        assertEquals(2, gridProcessor.getRowSpan(4, 2));
       
        // Verify column sizes were properly combined.
        assertEquals(new Extent(1), gridProcessor.getColumnWidth(0));
        assertEquals(new Extent(6), gridProcessor.getColumnWidth(1));
        assertEquals(new Extent(8), gridProcessor.getColumnWidth(2));
        assertEquals(new Extent(16), gridProcessor.getColumnWidth(3));
        assertEquals(new Extent(96), gridProcessor.getColumnWidth(4));
    }
View Full Code Here

            }
            grid.add(label);
        }
       
        // Set Row Sizes
        grid.setRowHeight(0, new Extent(1));
        grid.setRowHeight(1, new Extent(2));
        grid.setRowHeight(2, new Extent(4));
        grid.setRowHeight(3, new Extent(8));
        grid.setRowHeight(4, new Extent(16));
        grid.setRowHeight(5, new Extent(32));
        grid.setRowHeight(6, new Extent(64));

        GridProcessor gridProcessor = new GridProcessor(grid);
       
        // Verify Grid size is correct.
        assertEquals(3, gridProcessor.getColumnCount());
        assertEquals(5, gridProcessor.getRowCount());

        // Verify components are at correct positions.
        assertEquals(0, gridProcessor.getComponentIndex(0, 0));
        assertEquals(1, gridProcessor.getComponentIndex(1, 0));
        assertEquals(2, gridProcessor.getComponentIndex(2, 0));
        assertEquals(3, gridProcessor.getComponentIndex(0, 1));
        assertEquals(4, gridProcessor.getComponentIndex(1, 1));
        assertEquals(5, gridProcessor.getComponentIndex(2, 1));
        assertEquals(6, gridProcessor.getComponentIndex(0, 2));
        assertEquals(7, gridProcessor.getComponentIndex(1, 2));
        assertEquals(8, gridProcessor.getComponentIndex(2, 2));
        assertEquals(6, gridProcessor.getComponentIndex(0, 3));
        assertEquals(9, gridProcessor.getComponentIndex(1, 3));
        assertEquals(8, gridProcessor.getComponentIndex(2, 3));
        assertEquals(10, gridProcessor.getComponentIndex(0, 4));
        assertEquals(11, gridProcessor.getComponentIndex(1, 4));
        assertEquals(11, gridProcessor.getComponentIndex(2, 4));
       
        // Verify x-spans were untouched.
        assertEquals(1, gridProcessor.getColumnSpan(0, 0));
        assertEquals(1, gridProcessor.getColumnSpan(1, 0));
        assertEquals(1, gridProcessor.getColumnSpan(2, 0));
        assertEquals(1, gridProcessor.getColumnSpan(0, 1));
        assertEquals(1, gridProcessor.getColumnSpan(1, 1));
        assertEquals(1, gridProcessor.getColumnSpan(2, 1));
        assertEquals(1, gridProcessor.getColumnSpan(0, 2));
        assertEquals(1, gridProcessor.getColumnSpan(1, 2));
        assertEquals(1, gridProcessor.getColumnSpan(2, 2));
        assertEquals(1, gridProcessor.getColumnSpan(0, 3));
        assertEquals(1, gridProcessor.getColumnSpan(1, 3));
        assertEquals(1, gridProcessor.getColumnSpan(2, 3));
        assertEquals(1, gridProcessor.getColumnSpan(0, 4));
        assertEquals(2, gridProcessor.getColumnSpan(1, 4));
        assertEquals(2, gridProcessor.getColumnSpan(2, 4));
       
        // Verify y-spans were properly reduced.
        assertEquals(1, gridProcessor.getRowSpan(0, 0));
        assertEquals(1, gridProcessor.getRowSpan(1, 0));
        assertEquals(1, gridProcessor.getRowSpan(2, 0));
        assertEquals(1, gridProcessor.getRowSpan(0, 1));
        assertEquals(1, gridProcessor.getRowSpan(1, 1));
        assertEquals(1, gridProcessor.getRowSpan(2, 1));
        assertEquals(2, gridProcessor.getRowSpan(0, 2));
        assertEquals(1, gridProcessor.getRowSpan(1, 2));
        assertEquals(2, gridProcessor.getRowSpan(2, 2));
        assertEquals(2, gridProcessor.getRowSpan(0, 3));
        assertEquals(1, gridProcessor.getRowSpan(1, 3));
        assertEquals(2, gridProcessor.getRowSpan(2, 3));
        assertEquals(1, gridProcessor.getRowSpan(0, 4));
        assertEquals(1, gridProcessor.getRowSpan(1, 4));
        assertEquals(1, gridProcessor.getRowSpan(2, 4));
       
        // Verify column sizes were properly combined.
        assertEquals(new Extent(1), gridProcessor.getRowHeight(0));
        assertEquals(new Extent(6), gridProcessor.getRowHeight(1));
        assertEquals(new Extent(8), gridProcessor.getRowHeight(2));
        assertEquals(new Extent(16), gridProcessor.getRowHeight(3));
        assertEquals(new Extent(96), gridProcessor.getRowHeight(4));
    }
View Full Code Here

        assertEquals("none", cssStyle.getAttribute("border"));
    }
   
    public void testAll() {
        CssStyle cssStyle = new CssStyle();
        Border border = new Border(new Extent(20, Extent.PX), Color.GREEN, Border.STYLE_SOLID);
        BorderRender.renderToStyle(cssStyle, border);
        assertEquals("20px solid #00ff00", cssStyle.getAttribute("border"));
    }
View Full Code Here

    /**
     * Test <code>ExtentRender.renderCssAttributeValue()</code>.
     */
    public void testExtentRender() {
        assertEquals("50cm", ExtentRender.renderCssAttributeValue(new Extent(50, Extent.CM)));
        assertEquals("50em", ExtentRender.renderCssAttributeValue(new Extent(50, Extent.EM)));
        assertEquals("50ex", ExtentRender.renderCssAttributeValue(new Extent(50, Extent.EX)));
        assertEquals("50in", ExtentRender.renderCssAttributeValue(new Extent(50, Extent.IN)));
        assertEquals("50mm", ExtentRender.renderCssAttributeValue(new Extent(50, Extent.MM)));
        assertEquals("50%", ExtentRender.renderCssAttributeValue(new Extent(50, Extent.PERCENT)));
        assertEquals("50pc", ExtentRender.renderCssAttributeValue(new Extent(50, Extent.PC)));
        assertEquals("50pt", ExtentRender.renderCssAttributeValue(new Extent(50, Extent.PT)));
        assertEquals("50px", ExtentRender.renderCssAttributeValue(new Extent(50, Extent.PX)));
    }
View Full Code Here

    /**
     * Test <code>ExtentRender.toExtent()</code>.
     */
    public void testToExtent() {
        assertEquals(new Extent(50, Extent.CM), ExtentRender.toExtent("50cm"));
        assertEquals(new Extent(50, Extent.EM), ExtentRender.toExtent("50em"));
        assertEquals(new Extent(50, Extent.EX), ExtentRender.toExtent("50ex"));
        assertEquals(new Extent(50, Extent.IN), ExtentRender.toExtent("50in"));
        assertEquals(new Extent(50, Extent.MM), ExtentRender.toExtent("50mm"));
        assertEquals(new Extent(50, Extent.PERCENT), ExtentRender.toExtent("50%"));
        assertEquals(new Extent(50, Extent.PC), ExtentRender.toExtent("50pc"));
        assertEquals(new Extent(50, Extent.PT), ExtentRender.toExtent("50pt"));
        assertEquals(new Extent(50, Extent.PX), ExtentRender.toExtent("50px"));
        assertEquals(null, ExtentRender.toExtent(null));
        assertEquals(null, ExtentRender.toExtent("50foo"));
        assertEquals(null, ExtentRender.toExtent("50"));
        assertEquals(null, ExtentRender.toExtent("foo"));
        assertEquals(null, ExtentRender.toExtent("50m30cm"));
View Full Code Here

        ColorRender.renderToStyle(tableCssStyle, component);
        FontRender.renderToStyle(tableCssStyle, component);
        BorderRender.renderToStyle(tableCssStyle, border);
        ExtentRender.renderToStyle(tableCssStyle, "height", (Extent) grid.getRenderProperty(Grid.PROPERTY_HEIGHT));
       
        Extent width = (Extent) grid.getRenderProperty(Grid.PROPERTY_WIDTH);
        boolean render100PercentWidthWorkaround = false;
        if (rc.getContainerInstance().getClientProperties().getBoolean(
                ClientProperties.QUIRK_IE_TABLE_PERCENT_WIDTH_SCROLLBAR_ERROR)) {
            if (width != null && width.getUnits() == Extent.PERCENT && width.getValue() == 100) {
                width = null;
                render100PercentWidthWorkaround = true;
            }
        }
        ExtentRender.renderToStyle(tableCssStyle, "width", width);
       
        Extent borderSize = border == null ? null : border.getSize();
        if (borderSize != null) {
            if (!rc.getContainerInstance().getClientProperties().getBoolean(ClientProperties.QUIRK_CSS_BORDER_COLLAPSE_INSIDE)) {
                tableCssStyle.setAttribute("margin", ExtentRender.renderCssAttributeValueHalf(borderSize));
            }
        }
       
        tableElement.setAttribute("style", tableCssStyle.renderInline());
       
        parentNode.appendChild(tableElement);
       
        boolean someColumnsHaveWidths = false;
        for (int i = 0; i < columnCount; ++i) {
            if (gridProcessor.getColumnWidth(i) != null) {
                someColumnsHaveWidths = true;
            }
        }
        if (someColumnsHaveWidths) {
            Element colGroupElement = document.createElement("colgroup");
            tableElement.appendChild(colGroupElement);

            for (int i = 0; i < columnCount; ++i) {
                Element colElement = document.createElement("col");
                Extent columnWidth = gridProcessor.getColumnWidth(i);
                if (columnWidth != null) {
                    colElement.setAttribute("style", "width:" + ExtentRender.renderCssAttributeValue(columnWidth));
                }
                colGroupElement.appendChild(colElement);
            }
View Full Code Here

                    getCellArray(y, false)[x] = getCellArray(y, false)[x + 1];
                }
            }
           
            // Calculate Extent-size of merged indices.
            Extent retainedExtent = (Extent) xExtents.get(removedX - 1);
            Extent removedExtent = (Extent) xExtents.get(removedX);
            xExtents.remove(removedX);
            if (removedExtent != null) {
                xExtents.set(removedX - 1, Extent.add(removedExtent, retainedExtent));
            }
           
View Full Code Here

           
            // Remove the duplicate cell array.
            cellArrays.remove(removedY);
           
            // Calculate Extent-size of merged indices.
            Extent retainedExtent = (Extent) yExtents.get(removedY - 1);
            Extent removedExtent = (Extent) yExtents.get(removedY);
            yExtents.remove(removedY);
            if (removedExtent != null) {
                yExtents.set(removedY - 1, Extent.add(removedExtent, retainedExtent));
            }
View Full Code Here

TOP

Related Classes of nextapp.echo2.app.Extent

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.