Package org.stathissideris.ascii2image.text

Examples of org.stathissideris.ascii2image.text.TextGrid


   
    DiagramShape shape = new DiagramShape();
    shape.setClosed(true);
    if(grid.containsAtLeastOneDashedLine(cells)) shape.setStrokeDashed(true);
   
    TextGrid workGrid = new TextGrid(grid.getWidth(), grid.getHeight());
    grid.copyCellsTo(cells, workGrid);
   
    if (DEBUG){
      System.out.println("Making closed shape from buffer:");
      workGrid.printDebug();
    }
   
    TextGrid.Cell start = (TextGrid.Cell) cells.getFirst();
    if(workGrid.isCorner(start)) shape.addToPoints(makePointForCell(start, workGrid, cellWidth, cellHeight, allRound));
    TextGrid.Cell previous = start;
    TextGrid.Cell cell = null;
    CellSet nextCells = workGrid.followCell(previous);
    if(nextCells.size() == 0) return null;
    cell = (TextGrid.Cell) nextCells.getFirst();
    if(workGrid.isCorner(cell)) shape.addToPoints(makePointForCell(cell, workGrid, cellWidth, cellHeight, allRound));
   
    while(!cell.equals(start)){
      nextCells = workGrid.followCell(cell, previous);
      if(nextCells.size() == 1) {
        previous = cell;
        cell = (TextGrid.Cell) nextCells.getFirst();
        if(!cell.equals(start) && workGrid.isCorner(cell))
          shape.addToPoints(makePointForCell(cell, workGrid, cellWidth, cellHeight, allRound));
      } else if(nextCells.size() > 1) {
        return null;
      }
    }
View Full Code Here


 
  @Before public void setUp() {
  }
 
  @Test public void testFillContinuousAreaSquareOutside() throws FileNotFoundException, IOException {
    TextGrid squareGrid;
    squareGrid = new TextGrid();
    squareGrid.loadFrom("tests/text/simple_square01.txt");

    CellSet filledArea = squareGrid.fillContinuousArea(0, 0, '*');
    int size = filledArea.size();
    assertEquals(64, size);
   
    CellSet expectedFilledArea = new CellSet();
    addSquareToCellSet(squareGrid, expectedFilledArea, 0,0, 11,2);
View Full Code Here

    addSquareToCellSet(squareGrid, expectedFilledArea, 9,2, 2,5);
    assertEquals(expectedFilledArea, filledArea);
  }

  @Test public void testFillContinuousAreaSquareInside() throws FileNotFoundException, IOException {
    TextGrid squareGrid;
    squareGrid = new TextGrid();
    squareGrid.loadFrom("tests/text/simple_square01.txt");
   
    CellSet filledArea = squareGrid.fillContinuousArea(3, 3, '*');
    int size = filledArea.size();
    assertEquals(15, size);
   
    CellSet expectedFilledArea = new CellSet();
    addSquareToCellSet(squareGrid, expectedFilledArea, 3,3, 5,3);
View Full Code Here

    addSquareToCellSet(squareGrid, expectedFilledArea, 3,3, 5,3);
    assertEquals(expectedFilledArea, filledArea);
  }

  @Test public void testFillContinuousAreaUInside() throws FileNotFoundException, IOException {
    TextGrid uGrid;
    uGrid = new TextGrid();
    uGrid.loadFrom("tests/text/simple_U01.txt");
   
    CellSet filledArea = uGrid.fillContinuousArea(3, 3, '*');
    int size = filledArea.size();
   
    assertEquals(62, size);
   
    CellSet expectedFilledArea = new CellSet();
View Full Code Here

    addSquareToCellSet(uGrid, expectedFilledArea,  8,6, 6,2);
    assertEquals(expectedFilledArea, filledArea);
  }

  @Test public void testFillContinuousAreaUOutside() throws FileNotFoundException, IOException {
    TextGrid uGrid;
    uGrid = new TextGrid();
    uGrid.loadFrom("tests/text/simple_U01.txt");
   
    CellSet filledArea = uGrid.fillContinuousArea(0, 0, '*');
    int size = filledArea.size();
   
    assertEquals(128, size);
   
    CellSet expectedFilledArea = new CellSet();
View Full Code Here

   
    assertEquals(expectedFilledArea, filledArea);
  }

  @Test public void testFillContinuousAreaSOutside() throws FileNotFoundException, IOException {
    TextGrid uGrid;
    uGrid = new TextGrid();
    uGrid.loadFrom("tests/text/simple_S01.txt");
   
    CellSet filledArea = uGrid.fillContinuousArea(0, 0, '*');
    int size = filledArea.size();
   
    assertEquals(246, size);
   
    CellSet expectedFilledArea = new CellSet();
View Full Code Here

   
    assertEquals(expectedFilledArea, filledArea);
  }

  @Test public void testFillContinuousAreaSInside1() throws FileNotFoundException, IOException {
    TextGrid uGrid;
    uGrid = new TextGrid();
    uGrid.loadFrom("tests/text/simple_S01.txt");
   
    CellSet filledArea = uGrid.fillContinuousArea(3, 3, '*');
    int size = filledArea.size();
   
    assertEquals(15, size);
   
    CellSet expectedFilledArea = new CellSet();
View Full Code Here

    addSquareToCellSet(uGrid, expectedFilledArea,  3, 35, 3);
    assertEquals(expectedFilledArea, filledArea);
  }

  @Test public void testFillContinuousAreaSInside2() throws FileNotFoundException, IOException {
    TextGrid uGrid;
    uGrid = new TextGrid();
    uGrid.loadFrom("tests/text/simple_S01.txt");
   
    CellSet filledArea = uGrid.fillContinuousArea(17, 3, '*');
    int size = filledArea.size();

    assertEquals(15, size);
   
    CellSet expectedFilledArea = new CellSet();
View Full Code Here

    assertEquals(expectedFilledArea, filledArea);
  }

 
  @Test public void testFindBoundariesExpandingFromSquare() throws FileNotFoundException, IOException {
    TextGrid grid;
    grid = new TextGrid();
    grid.loadFrom("tests/text/simple_square01.txt");

    CellSet wholeGridSet = new CellSet();
    addSquareToCellSet(grid, wholeGridSet, 0,0, grid.getWidth(),grid.getHeight());
   
    TextGrid copyGrid = new AbstractionGrid(grid, wholeGridSet).getCopyOfInternalBuffer();
    CellSet boundaries = copyGrid.findBoundariesExpandingFrom(copyGrid.new Cell(8, 8));
    int size = boundaries.size();
   
    assertEquals(56, size);
   
    CellSet expectedBoundaries = new CellSet();
View Full Code Here

    assertEquals(expectedBoundaries, boundaries);

  }

  @Test public void testFindBoundariesExpandingFromUInside() throws FileNotFoundException, IOException {
    TextGrid grid;
    grid = new TextGrid();
    grid.loadFrom("tests/text/simple_U01.txt");

    CellSet wholeGridSet = new CellSet();
    addSquareToCellSet(grid, wholeGridSet, 0,0, grid.getWidth(),grid.getHeight());
   
    TextGrid copyGrid = new AbstractionGrid(grid, wholeGridSet).getCopyOfInternalBuffer();
    CellSet boundaries = copyGrid.findBoundariesExpandingFrom(copyGrid.new Cell(8, 8));
    int size1 = boundaries.size();

    assertEquals(150, size1);

    String expectedBoundariesString =
View Full Code Here

TOP

Related Classes of org.stathissideris.ascii2image.text.TextGrid

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.