Package org.apache.myfaces.tobago.internal.layout

Examples of org.apache.myfaces.tobago.internal.layout.Grid


public class GridUnitTest {

  @Test
  public void test1x1() {

    Grid grid = new Grid(LayoutTokens.parse("*"), LayoutTokens.parse("*"));
    Assert.assertEquals(1, grid.getBankHeads(Orientation.HORIZONTAL).length);
    Assert.assertEquals(1, grid.getBankHeads(Orientation.VERTICAL).length);
    Assert.assertEquals(""
        + "┌─┐\n"
        + "│◌│\n"
        + "└─┘\n", grid.gridAsString());

    grid.add(new OriginCell(null), 1, 1);
    Assert.assertEquals(1, grid.getBankHeads(Orientation.HORIZONTAL).length);
    Assert.assertEquals(1, grid.getBankHeads(Orientation.VERTICAL).length);
    Assert.assertEquals(""
        + "┏━┓\n"
        + "┃█┃\n"
        + "┗━┛\n", grid.gridAsString());

    grid.add(new OriginCell(null), 1, 1);
    Assert.assertEquals(1, grid.getBankHeads(Orientation.HORIZONTAL).length);
    Assert.assertEquals(2, grid.getBankHeads(Orientation.VERTICAL).length);
    Assert.assertEquals(""
        + "┏━┓\n"
        + "┃█┃\n"
        + "┣━┫\n"
        + "┃█┃\n"
        + "┗━┛\n", grid.gridAsString());

    grid.add(new OriginCell(null), 1, 2);
    Assert.assertEquals(1, grid.getBankHeads(Orientation.HORIZONTAL).length);
    Assert.assertEquals(4, grid.getBankHeads(Orientation.VERTICAL).length);
    Assert.assertEquals(""
        + "┏━┓\n"
        + "┃█┃\n"
        + "┣━┫\n"
        + "┃█┃\n"
        + "┣━┫\n"
        + "┃█┃\n"
        + "┠─┨\n"
        + "┃⬇┃\n"
        + "┗━┛\n", grid.gridAsString());

    // with warning
    grid.add(new OriginCell(null), 2, 1);
    Assert.assertEquals(1, grid.getBankHeads(Orientation.HORIZONTAL).length);
    Assert.assertEquals(5, grid.getBankHeads(Orientation.VERTICAL).length);
    Assert.assertEquals(""
        + "┏━┓\n"
        + "┃█┃\n"
        + "┣━┫\n"
        + "┃█┃\n"
        + "┣━┫\n"
        + "┃█┃\n"
        + "┠─┨\n"
        + "┃⬇┃\n"
        + "┣━┫\n"
        + "┃✖┃\n"
        + "┗━┛\n", grid.gridAsString());
  }
View Full Code Here


  }

  @Test
  public void test2x1() {

    Grid grid = new Grid(LayoutTokens.parse("*;*"), LayoutTokens.parse("*"));
    Assert.assertEquals(2, grid.getBankHeads(Orientation.HORIZONTAL).length);
    Assert.assertEquals(1, grid.getBankHeads(Orientation.VERTICAL).length);
    Assert.assertEquals(""
        + "┌─┬─┐\n"
        + "│◌│◌│\n"
        + "└─┴─┘\n", grid.gridAsString());

    grid.add(new OriginCell(null), 1, 1);
    Assert.assertEquals(2, grid.getBankHeads(Orientation.HORIZONTAL).length);
    Assert.assertEquals(1, grid.getBankHeads(Orientation.VERTICAL).length);
    Assert.assertEquals(""
        + "┏━┱─┐\n"
        + "┃█┃◌│\n"
        + "┗━┹─┘\n", grid.gridAsString());

    grid.add(new OriginCell(null), 1, 1);
    Assert.assertEquals(2, grid.getBankHeads(Orientation.HORIZONTAL).length);
    Assert.assertEquals(1, grid.getBankHeads(Orientation.VERTICAL).length);
    Assert.assertEquals(""
        + "┏━┳━┓\n"
        + "┃█┃█┃\n"
        + "┗━┻━┛\n", grid.gridAsString());

    grid.add(new OriginCell(null), 2, 2);
    Assert.assertEquals(2, grid.getBankHeads(Orientation.HORIZONTAL).length);
    Assert.assertEquals(3, grid.getBankHeads(Orientation.VERTICAL).length);
    Assert.assertEquals(""
        + "┏━┳━┓\n"
        + "┃█┃█┃\n"
        + "┣━╇━┫\n"
        + "┃█│➞┃\n"
        + "┠─┼─┨\n"
        + "┃⬇│⬇┃\n"
        + "┗━┷━┛\n", grid.gridAsString());

    grid.add(new OriginCell(null), 1, 2);
    Assert.assertEquals(2, grid.getBankHeads(Orientation.HORIZONTAL).length);
    Assert.assertEquals(5, grid.getBankHeads(Orientation.VERTICAL).length);
    Assert.assertEquals(""
        + "┏━┳━┓\n"
        + "┃█┃█┃\n"
        + "┣━╇━┫\n"
        + "┃█│➞┃\n"
        + "┠─┼─┨\n"
        + "┃⬇│⬇┃\n"
        + "┣━╈━┩\n"
        + "┃█┃◌│\n"
        + "┠─╂─┤\n"
        + "┃⬇┃◌│\n"
        + "┗━┹─┘\n", grid.gridAsString());

    grid.add(new OriginCell(null), 1, 1);
    Assert.assertEquals(2, grid.getBankHeads(Orientation.HORIZONTAL).length);
    Assert.assertEquals(5, grid.getBankHeads(Orientation.VERTICAL).length);
    Assert.assertEquals(""
        + "┏━┳━┓\n"
        + "┃█┃█┃\n"
        + "┣━╇━┫\n"
        + "┃█│➞┃\n"
        + "┠─┼─┨\n"
        + "┃⬇│⬇┃\n"
        + "┣━╈━┫\n"
        + "┃█┃█┃\n"
        + "┠─╊━┩\n"
        + "┃⬇┃◌│\n"
        + "┗━┹─┘\n", grid.gridAsString());

    grid.add(new OriginCell(null), 1, 2);
    Assert.assertEquals(2, grid.getBankHeads(Orientation.HORIZONTAL).length);
    Assert.assertEquals(6, grid.getBankHeads(Orientation.VERTICAL).length);
    Assert.assertEquals(""
        + "┏━┳━┓\n"
        + "┃█┃█┃\n"
        + "┣━╇━┫\n"
        + "┃█│➞┃\n"
        + "┠─┼─┨\n"
        + "┃⬇│⬇┃\n"
        + "┣━╈━┫\n"
        + "┃█┃█┃\n"
        + "┠─╊━┫\n"
        + "┃⬇┃█┃\n"
        + "┡━╉─┨\n"
        + "│◌┃⬇┃\n"
        + "└─┺━┛\n", grid.gridAsString());

    grid.add(new OriginCell(null), 2, 1);
    // fehler
    Assert.assertEquals(2, grid.getBankHeads(Orientation.HORIZONTAL).length);
    Assert.assertEquals(6, grid.getBankHeads(Orientation.VERTICAL).length);
  }
View Full Code Here

  }

  @Test
  public void test5x5() {

    Grid grid = new Grid(LayoutTokens.parse("*;*;*;*;*"), LayoutTokens.parse("*;*;*;*;*"));
    Assert.assertEquals(5, grid.getBankHeads(Orientation.HORIZONTAL).length);
    Assert.assertEquals(5, grid.getBankHeads(Orientation.VERTICAL).length);
    Assert.assertEquals(""
        + "┌─┬─┬─┬─┬─┐\n"
        + "│◌│◌│◌│◌│◌│\n"
        + "├─┼─┼─┼─┼─┤\n"
        + "│◌│◌│◌│◌│◌│\n"
        + "├─┼─┼─┼─┼─┤\n"
        + "│◌│◌│◌│◌│◌│\n"
        + "├─┼─┼─┼─┼─┤\n"
        + "│◌│◌│◌│◌│◌│\n"
        + "├─┼─┼─┼─┼─┤\n"
        + "│◌│◌│◌│◌│◌│\n"
        + "└─┴─┴─┴─┴─┘\n", grid.gridAsString());

    grid.add(new OriginCell(null), 1, 2);
    grid.add(new OriginCell(null), 1, 3);
    grid.add(new OriginCell(null), 1, 1);
    grid.add(new OriginCell(null), 2, 1);
    grid.add(new OriginCell(null), 3, 1);
    grid.add(new OriginCell(null), 1, 1);
    grid.add(new OriginCell(null), 1, 1);
    grid.add(new OriginCell(null), 1, 3);
    grid.add(new OriginCell(null), 1, 1);
    grid.add(new OriginCell(null), 3, 1);
    grid.add(new OriginCell(null), 1, 2);
    grid.add(new OriginCell(null), 2, 1);
    grid.add(new OriginCell(null), 1, 1);
    Assert.assertEquals(5, grid.getBankHeads(Orientation.HORIZONTAL).length);
    Assert.assertEquals(5, grid.getBankHeads(Orientation.VERTICAL).length);
    Assert.assertEquals(""
        + "┏━┳━┳━┳━┯━┓\n"
        + "┃█┃█┃█┃█│➞┃\n"
        + "┠─╂─╊━╇━┿━┫\n"
        + "┃⬇┃⬇┃█│➞│➞┃\n"
        + "┣━╉─╊━╈━╈━┫\n"
        + "┃█┃⬇┃█┃█┃█┃\n"
        + "┣━╇━╇━╉─╊━┫\n"
        + "┃█│➞│➞┃⬇┃█┃\n"
        + "┣━┿━╈━╉─╂─┨\n"
        + "┃█│➞┃█┃⬇┃⬇┃\n"
        + "┗━┷━┻━┻━┻━┛\n", grid.gridAsString());
  }
View Full Code Here

    if (!getLayoutContainer().isLayoutChildren()) {
      return;
    }

    grid = new Grid(LayoutTokens.parse(getColumns()), LayoutTokens.parse(getRows()));

    List<LayoutComponent> components = getLayoutContainer().getComponents();
    for (LayoutComponent component : components) {
      component.setCurrentHeight(null);
      component.setCurrentWidth(null);
View Full Code Here

TOP

Related Classes of org.apache.myfaces.tobago.internal.layout.Grid

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.