org.stathissideris.ascii2image.graphics
Class Diagram

java.lang.Object
  extended by org.stathissideris.ascii2image.graphics.Diagram

public class Diagram
extends Object

Author:
Efstathios Sideris

Constructor Summary
Diagram(TextGrid grid, ConversionOptions options, ProcessingOptions processingOptions)
          An outline of the inner workings of this very important (and monstrous) constructor is presented here.
 
Method Summary
 ArrayList getAllDiagramShapes()
          Returns a list of all DiagramShapes in the Diagram, including the ones within CompositeDiagramShapes
 TextGrid.Cell getCellFor(ShapePoint point)
           
 int getCellHeight()
           
 int getCellMaxX(TextGrid.Cell cell)
           
static int getCellMaxX(TextGrid.Cell cell, int cellXSize)
           
 int getCellMaxY(TextGrid.Cell cell)
           
static int getCellMaxY(TextGrid.Cell cell, int cellYSize)
           
 int getCellMidX(TextGrid.Cell cell)
           
static int getCellMidX(TextGrid.Cell cell, int cellXSize)
           
 int getCellMidY(TextGrid.Cell cell)
           
static int getCellMidY(TextGrid.Cell cell, int cellYSize)
           
 int getCellMinX(TextGrid.Cell cell)
           
static int getCellMinX(TextGrid.Cell cell, int cellXSize)
           
 int getCellMinY(TextGrid.Cell cell)
           
static int getCellMinY(TextGrid.Cell cell, int cellYSize)
           
 int getCellWidth()
           
 ArrayList getCompositeShapes()
           
 int getHeight()
           
 float getMinimumOfCellDimension()
           
 ArrayList getShapes()
           
 Iterator getShapesIterator()
           
 ArrayList getTextObjects()
           
 int getWidth()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Diagram

public Diagram(TextGrid grid,
               ConversionOptions options,
               ProcessingOptions processingOptions)

An outline of the inner workings of this very important (and monstrous) constructor is presented here. Boundary processing is the first step of the process:

  1. Copy the grid into a work grid and remove all type-on-line and point markers from the work grid
  2. Split grid into distinct shapes by plotting the grid onto an AbstractionGrid and its getDistinctShapes() method.
  3. Find all the possible boundary sets of each of the distinct shapes. This can produce duplicate shapes (if the boundaries are the same when filling from the inside and the outside).
  4. Remove duplicate boundaries.
  5. Remove obsolete boundaries. Obsolete boundaries are the ones that are the sum of their parts when plotted as filled shapes. (see method removeObsoleteShapes())
  6. Seperate the found boundary sets to open, closed or mixed (See CellSet class on how its done).
  7. Are there any closed boundaries?
    • YES. Subtract all the closed boundaries from each of the open ones. That should convert the mixed shapes into open.
    • NO. In this (harder) case, we use the method breakTrulyMixedBoundaries() of CellSet to break boundaries into open and closed shapes (would work in any case, but it's probably slower than the other method). This method is based on tracing from the lines' ends and splitting when we get to an intersection.
  8. If we had to eliminate any mixed shapes, we seperate the found boundary sets again to open, closed or mixed.

At this stage, the boundary processing is all complete and we proceed with using those boundaries to create the shapes:

  1. Create closed shapes.
  2. Create open shapes. That's when the line end corrections are also applied, concerning the positioning of the ends of lines see methods connectEndsToAnchors() and moveEndsToCellEdges() of DiagramShape.
  3. Assign color codes to closed shapes.
  4. Assing extended markup tags to closed shapes.

  5. Create arrowheads.

  6. Create point markers.

Finally, the text processing occurs: [pending]

Parameters:
grid -
cellWidth -
cellHeight -
Method Detail

getAllDiagramShapes

public ArrayList getAllDiagramShapes()
Returns a list of all DiagramShapes in the Diagram, including the ones within CompositeDiagramShapes

Returns:

getMinimumOfCellDimension

public float getMinimumOfCellDimension()

getShapesIterator

public Iterator getShapesIterator()

getHeight

public int getHeight()
Returns:

getWidth

public int getWidth()
Returns:

getCellWidth

public int getCellWidth()
Returns:

getCellHeight

public int getCellHeight()
Returns:

getCompositeShapes

public ArrayList getCompositeShapes()
Returns:

getShapes

public ArrayList getShapes()
Returns:

getCellMinX

public int getCellMinX(TextGrid.Cell cell)

getCellMinX

public static int getCellMinX(TextGrid.Cell cell,
                              int cellXSize)

getCellMidX

public int getCellMidX(TextGrid.Cell cell)

getCellMidX

public static int getCellMidX(TextGrid.Cell cell,
                              int cellXSize)

getCellMaxX

public int getCellMaxX(TextGrid.Cell cell)

getCellMaxX

public static int getCellMaxX(TextGrid.Cell cell,
                              int cellXSize)

getCellMinY

public int getCellMinY(TextGrid.Cell cell)

getCellMinY

public static int getCellMinY(TextGrid.Cell cell,
                              int cellYSize)

getCellMidY

public int getCellMidY(TextGrid.Cell cell)

getCellMidY

public static int getCellMidY(TextGrid.Cell cell,
                              int cellYSize)

getCellMaxY

public int getCellMaxY(TextGrid.Cell cell)

getCellMaxY

public static int getCellMaxY(TextGrid.Cell cell,
                              int cellYSize)

getCellFor

public TextGrid.Cell getCellFor(ShapePoint point)

getTextObjects

public ArrayList getTextObjects()
Returns:


Copyright © 2013. All Rights Reserved.