Package org.stathissideris.ascii2image.text

Examples of org.stathissideris.ascii2image.text.AbstractionGrid


    int width = grid.getWidth();
    int height = grid.getHeight();

 
    //split distinct shapes using AbstractionGrid
    AbstractionGrid temp = new AbstractionGrid(workGrid, workGrid.getAllBoundaries());
    ArrayList<CellSet> boundarySetsStep1 = temp.getDistinctShapes();
   
    if(DEBUG){
      System.out.println("******* Distinct shapes found using AbstractionGrid *******");
      Iterator<CellSet> dit = boundarySetsStep1.iterator();
      while (dit.hasNext()) {
        CellSet set = dit.next();
        set.printAsGrid();
      }
      System.out.println("******* Same set of shapes after processing them by filling *******");
    }
   
   
    //Find all the boundaries by using the special version of the filling method
    //(fills in a different buffer than the buffer it reads from)
    ArrayList<CellSet> boundarySetsStep2 = new ArrayList<CellSet>();
    for(CellSet set : boundarySetsStep1) {     
      //the fill buffer keeps track of which cells have been
      //filled already
      TextGrid fillBuffer = new TextGrid(width * 3, height * 3);
     
      for(int yi = 0; yi < height * 3; yi++){
        for(int xi = 0; xi < width * 3; xi++){
          if(fillBuffer.isBlank(xi, yi)){
           
            TextGrid copyGrid = new AbstractionGrid(workGrid, set).getCopyOfInternalBuffer();

            CellSet boundaries =
              copyGrid
              .findBoundariesExpandingFrom(copyGrid.new Cell(xi, yi));
            if(boundaries.size() == 0) continue; //i'm not sure why these occur
            boundarySetsStep2.add(boundaries.makeScaledOneThirdEquivalent());
         
            copyGrid = new AbstractionGrid(workGrid, set).getCopyOfInternalBuffer();
            CellSet filled =
              copyGrid
              .fillContinuousArea(copyGrid.new Cell(xi, yi), '*');
            fillBuffer.fillCellsWith(filled, '*');
            fillBuffer.fillCellsWith(boundaries, '-');
View Full Code Here


    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);
   
View Full Code Here

    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);
View Full Code Here

    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(0, 0));
    int size = boundaries.size();

    assertEquals(154, size);
View Full Code Here

TOP

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

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.