Class CellSet
- java.lang.Object
-
- org.stathissideris.ascii2image.text.CellSet
-
- All Implemented Interfaces:
java.lang.Iterable<TextGrid.Cell>
public class CellSet extends java.lang.Object implements java.lang.Iterable<TextGrid.Cell>
-
-
Field Summary
Fields Modifier and Type Field Description static intTYPE_CLOSEDstatic intTYPE_HAS_CLOSED_AREAstatic intTYPE_MIXEDstatic intTYPE_OPENstatic intTYPE_UNDETERMINED
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectadd(TextGrid.Cell cell)voidaddAll(CellSet set)voidaddSet(CellSet set)voidappendSet(CellSet set)java.util.ArrayListbreakIntoDistinctBoundaries()java.util.ArrayListbreakIntoDistinctBoundaries(TextGrid grid)Takes into account character info from the gridjava.util.ArrayListbreakTrulyMixedBoundaries(TextGrid grid)Breaks that:booleancontains(TextGrid.Cell cell)static CellSetcopyCellSet(CellSet set)Deep copybooleanequals(java.lang.Object o)TextGrid.Cellfind(int x, int y)TextGrid.Cellfind(TextGrid.Cell cell)TextGrid.CellfindCellNextTo(TextGrid.Cell cell)Returns the first cell that is found to be next tocell.CellSetfindCellsNextTo(TextGrid.Cell cell)Returns all the cells that are found to be next tocell.java.lang.StringgetCellsAsString()CellSetgetFilledEquivalent(TextGrid textGrid)TextGrid.CellgetFirst()intgetHeight()intgetMaxX()intgetMaxY()intgetMinX()intgetMinY()intgetType(TextGrid grid)intgetWidth()booleanhasCommonCells(CellSet otherSet)java.util.Iterator<TextGrid.Cell>iterator()TextGridmakeIntoGrid()CellSetmakeScaledOneThirdEquivalent()voidprintAsGrid()voidprintDebug()java.lang.Objectremove(TextGrid.Cell cell)static java.util.ArrayListremoveDuplicateSets(java.util.ArrayList list)intsize()voidsubtractSet(CellSet set)java.lang.StringtoString()voidtranslate(int dx, int dy)
-
-
-
Field Detail
-
TYPE_CLOSED
public static final int TYPE_CLOSED
- See Also:
- Constant Field Values
-
TYPE_OPEN
public static final int TYPE_OPEN
- See Also:
- Constant Field Values
-
TYPE_MIXED
public static final int TYPE_MIXED
- See Also:
- Constant Field Values
-
TYPE_HAS_CLOSED_AREA
public static final int TYPE_HAS_CLOSED_AREA
- See Also:
- Constant Field Values
-
TYPE_UNDETERMINED
public static final int TYPE_UNDETERMINED
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CellSet
public CellSet()
-
CellSet
public CellSet(CellSet other)
-
-
Method Detail
-
iterator
public java.util.Iterator<TextGrid.Cell> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<TextGrid.Cell>
-
add
public java.lang.Object add(TextGrid.Cell cell)
-
addAll
public void addAll(CellSet set)
-
size
public int size()
-
getFirst
public TextGrid.Cell getFirst()
-
printAsGrid
public void printAsGrid()
-
printDebug
public void printDebug()
-
getCellsAsString
public java.lang.String getCellsAsString()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getType
public int getType(TextGrid grid)
-
translate
public void translate(int dx, int dy)
-
find
public TextGrid.Cell find(TextGrid.Cell cell)
-
contains
public boolean contains(TextGrid.Cell cell)
-
addSet
public void addSet(CellSet set)
-
hasCommonCells
public boolean hasCommonCells(CellSet otherSet)
-
find
public TextGrid.Cell find(int x, int y)
-
findCellNextTo
public TextGrid.Cell findCellNextTo(TextGrid.Cell cell)
Returns the first cell that is found to be next tocell.- Parameters:
cell-- Returns:
-
findCellsNextTo
public CellSet findCellsNextTo(TextGrid.Cell cell)
Returns all the cells that are found to be next tocell.- Parameters:
cell-- Returns:
-
appendSet
public void appendSet(CellSet set)
-
subtractSet
public void subtractSet(CellSet set)
-
getWidth
public int getWidth()
-
getHeight
public int getHeight()
-
getMaxX
public int getMaxX()
-
getMinX
public int getMinX()
-
getMaxY
public int getMaxY()
-
getMinY
public int getMinY()
-
remove
public java.lang.Object remove(TextGrid.Cell cell)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
removeDuplicateSets
public static java.util.ArrayList removeDuplicateSets(java.util.ArrayList list)
-
breakIntoDistinctBoundaries
public java.util.ArrayList breakIntoDistinctBoundaries(TextGrid grid)
Takes into account character info from the grid- Returns:
- ArrayList of distinct BoundarySetS
-
breakIntoDistinctBoundaries
public java.util.ArrayList breakIntoDistinctBoundaries()
- Returns:
- ArrayList of distinct BoundarySetS
-
breakTrulyMixedBoundaries
public java.util.ArrayList breakTrulyMixedBoundaries(TextGrid grid)
Breaks that:+-----+ | | + ---+------------------- | | +-----+
into the following 3:+-----+ | | + + | | +-----+ --- -------------------- Parameters:
grid-- Returns:
- a list of boundaries that are either open or closed but not mixed
and they are equivalent to the
this
-
makeIntoGrid
public TextGrid makeIntoGrid()
-
makeScaledOneThirdEquivalent
public CellSet makeScaledOneThirdEquivalent()
-
-