Class TextGrid
java.lang.Object
org.stathissideris.ascii2image.text.TextGrid
- Direct Known Subclasses:
GridPattern
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassclassclassclass -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds grid to this.voidaddToMarkupTags(Collection<String> tags) booleanvoidclear()booleanvoidcopyCellsTo(CellSet cells, TextGrid grid) booleanbooleanvoidfillCellsWith(Iterable cells, char c) Fills all the cells incellswithcfillContinuousArea(int x, int y, char c) Fills the continuous area with if c1 characters with c2, flooding from cell x, yfillContinuousArea(TextGrid.Cell cell, char c) Locates and returns the '*' boundaries that we would encounter if we did a flood-fill atseed.Returns an ArrayList of CellStringPairs that represents all the continuous (non-blank) Strings in the grid.followCell(TextGrid.Cell cell) followCell(TextGrid.Cell cell, TextGrid.Cell blocked) followCorner(TextGrid.Cell cell) followCorner(TextGrid.Cell cell, TextGrid.Cell blocked) followCorner1(TextGrid.Cell cell) followCorner1(TextGrid.Cell cell, TextGrid.Cell blocked) followCorner2(TextGrid.Cell cell) followCorner2(TextGrid.Cell cell, TextGrid.Cell blocked) followCorner3(TextGrid.Cell cell) followCorner3(TextGrid.Cell cell, TextGrid.Cell blocked) followCorner4(TextGrid.Cell cell) followCorner4(TextGrid.Cell cell, TextGrid.Cell blocked) followCrossOnLine(TextGrid.Cell cell, TextGrid.Cell blocked) followIntersection(TextGrid.Cell cell, TextGrid.Cell blocked) followLine(int x, int y) followLine(TextGrid.Cell cell) Returns the neighbours of a line-cell that are boundaries (0 to 2 cells are returned)followLine(TextGrid.Cell cell, TextGrid.Cell blocked) followStub(TextGrid.Cell cell) followStub(TextGrid.Cell cell, TextGrid.Cell blocked) charget(int x, int y) charget(TextGrid.Cell cell) chargetEastOf(int x, int y) chargetEastOf(TextGrid.Cell cell) intchargetNorthOf(int x, int y) chargetNorthOf(TextGrid.Cell cell) getRow(int y) protected ArrayList<StringBuilder>getRows()chargetSouthOf(int x, int y) chargetSouthOf(TextGrid.Cell cell) getStringAt(int x, int y, int length) getStringAt(TextGrid.Cell cell, int length) getSubGrid(int x, int y, int width, int height) chargetWestOf(int x, int y) chargetWestOf(TextGrid.Cell cell) intgetWidth()booleanbooleanhasEntryPoint(TextGrid.Cell cell, int entryPointId) This is done in a bit of a messy way, should be impossible to go out of sync with corresponding GridPatternGroup.booleaninitialiseWithLines(ArrayList<StringBuilder> lines, ProcessingOptions options) booleaninitialiseWithText(String text, ProcessingOptions options) booleanisArrowhead(TextGrid.Cell cell) booleanisBlank(int x, int y) booleanisBlank(TextGrid.Cell cell) booleantrue if cell is blank and the east and west cells are not (used to find gaps between words)static booleanisBoundary(char c) booleanisBoundary(int x, int y) booleanisBoundary(TextGrid.Cell cell) booleanisBullet(int x, int y) booleanisBullet(TextGrid.Cell cell) booleanisColumnBlank(int x) booleanisCorner(int x, int y) booleanisCorner(TextGrid.Cell cell) booleanisCorner1(TextGrid.Cell cell) booleanisCorner2(TextGrid.Cell cell) booleanisCorner3(TextGrid.Cell cell) booleanisCorner4(TextGrid.Cell cell) booleanisCross(TextGrid.Cell cell) booleanisCrossOnLine(TextGrid.Cell cell) booleanisEastArrowhead(TextGrid.Cell cell) booleanstatic booleanisHorizontalLine(char c) booleanisHorizontalLine(int x, int y) booleanbooleanbooleanbooleanisIntersection(int x, int y) booleanisIntersection(TextGrid.Cell cell) booleanisInverseK(TextGrid.Cell cell) booleanisInverseT(TextGrid.Cell cell) booleanisK(TextGrid.Cell cell) booleanisLine(TextGrid.Cell cell) booleanisLinesEnd(int x, int y) booleanisLinesEnd(TextGrid.Cell cell) Stubs are also considered end of linesbooleanisLoneDiagonal(TextGrid.Cell cell) booleanisNormalCorner(int x, int y) booleanisNormalCorner(TextGrid.Cell cell) booleanbooleanbooleanbooleanisOutOfBounds(int x, int y) booleanisOutOfBounds(TextGrid.Cell cell) booleanisPointCell(TextGrid.Cell cell) booleanisRoundCorner(int x, int y) booleanisRoundCorner(TextGrid.Cell cell) booleanbooleanisStarOnLine(TextGrid.Cell cell) booleanisStringsEnd(TextGrid.Cell cell) true if the cell is not blank but the next (east) isbooleanisStringsStart(TextGrid.Cell cell) true if the cell is not blank but the previous (west) isbooleanisStub(TextGrid.Cell cell) A stub looks like that:booleanisT(TextGrid.Cell cell) booleanstatic booleanisVerticalLine(char c) booleanisVerticalLine(int x, int y) booleanisVerticalLine(TextGrid.Cell cell) booleanbooleanbooleanisWestArrowhead(TextGrid.Cell cell) static TextGridmakeSameSizeAs(TextGrid grid) booleanmatches(GridPattern criteria) booleanmatchesAll(GridPatternGroup criteria) booleanmatchesAny(GridPatternGroup criteria) booleanmatchesAny(TextGrid.Cell cell, GridPatternGroup criteria) intintvoidvoidvoidvoidvoidvoidMakes blank all the cells that contain non-text elements.voidreplaceAll(char c1, char c2) Replace all occurrences of c1 with c2voidvoidvoidvoidReplaces letters or numbers that are on horizontal or vertical lines, with the appropriate character that will make the line continuous (| for vertical and - for horizontal lines)voidset(int x, int y, char c) voidset(TextGrid.Cell cell, char c) voidvoidsetRow(int y, StringBuilder row) toString()voidwriteStringTo(int x, int y, String str) voidwriteStringTo(TextGrid.Cell cell, String str)
-
Constructor Details
-
TextGrid
public TextGrid() -
TextGrid
public TextGrid(int width, int height) -
TextGrid
-
-
Method Details
-
addToMarkupTags
-
makeSameSizeAs
-
clear
public void clear() -
get
public char get(int x, int y) -
get
-
getRow
-
getSubGrid
-
getTestingSubGrid
-
getStringAt
-
getStringAt
-
getNorthOf
public char getNorthOf(int x, int y) -
getSouthOf
public char getSouthOf(int x, int y) -
getEastOf
public char getEastOf(int x, int y) -
getWestOf
public char getWestOf(int x, int y) -
getNorthOf
-
getSouthOf
-
getEastOf
-
getWestOf
-
writeStringTo
-
writeStringTo
-
set
-
set
public void set(int x, int y, char c) -
setRow
-
setRow
-
getWidth
public int getWidth() -
getHeight
public int getHeight() -
printDebug
public void printDebug() -
getDebugString
-
toString
-
add
Adds grid to this. Space characters in this grid are replaced with the corresponding contents of grid, otherwise the contents are unchanged.- Parameters:
grid-- Returns:
- false if the grids are of different size
-
replaceTypeOnLine
public void replaceTypeOnLine()Replaces letters or numbers that are on horizontal or vertical lines, with the appropriate character that will make the line continuous (| for vertical and - for horizontal lines) -
replacePointMarkersOnLine
public void replacePointMarkersOnLine() -
getPointMarkersOnLine
-
replaceHumanColorCodes
public void replaceHumanColorCodes() -
replaceAll
public void replaceAll(char c1, char c2) Replace all occurrences of c1 with c2- Parameters:
c1-c2-
-
hasBlankCells
public boolean hasBlankCells() -
getAllNonBlank
-
getAllBoundaries
-
getAllBlanksBetweenCharacters
-
findStrings
Returns an ArrayList of CellStringPairs that represents all the continuous (non-blank) Strings in the grid. Used on buffers that contain only type, in order to find the positions and the contents of the strings.- Returns:
-
hasEntryPoint
This is done in a bit of a messy way, should be impossible to go out of sync with corresponding GridPatternGroup.- Parameters:
cell-entryPointId-- Returns:
-
isBlankBetweenCharacters
true if cell is blank and the east and west cells are not (used to find gaps between words)- Parameters:
cell-- Returns:
-
removeNonText
public void removeNonText()Makes blank all the cells that contain non-text elements. -
removeArrowheads
public void removeArrowheads() -
removeColorCodes
public void removeColorCodes() -
removeBoundaries
public void removeBoundaries() -
findArrowheads
-
findColorCodes
-
findMarkupTags
-
removeMarkupTags
public void removeMarkupTags() -
matchesAny
-
matchesAll
-
matches
-
isOnHorizontalLine
-
isOnVerticalLine
-
isBoundary
public static boolean isBoundary(char c) -
isBoundary
public boolean isBoundary(int x, int y) -
isBoundary
-
isLine
-
isHorizontalLine
public static boolean isHorizontalLine(char c) -
isHorizontalLine
-
isHorizontalLine
public boolean isHorizontalLine(int x, int y) -
isVerticalLine
public static boolean isVerticalLine(char c) -
isVerticalLine
-
isVerticalLine
public boolean isVerticalLine(int x, int y) -
isLinesEnd
public boolean isLinesEnd(int x, int y) -
isLinesEnd
Stubs are also considered end of lines- Parameters:
cell-- Returns:
-
isVerticalLinesEnd
-
isHorizontalLinesEnd
-
isPointCell
-
containsAtLeastOneDashedLine
-
exactlyOneNeighbourIsBoundary
-
isStub
A stub looks like that:+- or -+ or + or + or /- or -/ or / (you get the point) | | |- Parameters:
cell-- Returns:
-
isCrossOnLine
-
isHorizontalCrossOnLine
-
isVerticalCrossOnLine
-
isStarOnLine
-
isLoneDiagonal
-
isHorizontalStarOnLine
-
isVerticalStarOnLine
-
isArrowhead
-
isNorthArrowhead
-
isEastArrowhead
-
isWestArrowhead
-
isSouthArrowhead
-
isBullet
public boolean isBullet(int x, int y) -
isBullet
-
replaceBullets
public void replaceBullets() -
isStringsStart
true if the cell is not blank but the previous (west) is- Parameters:
cell-- Returns:
-
isStringsEnd
true if the cell is not blank but the next (east) is- Parameters:
cell-- Returns:
-
otherStringsStartInTheSameColumn
-
otherStringsEndInTheSameColumn
-
isColumnBlank
public boolean isColumnBlank(int x) -
followLine
-
followIntersection
-
followIntersection
-
followLine
Returns the neighbours of a line-cell that are boundaries (0 to 2 cells are returned)- Parameters:
cell-- Returns:
- null if the cell is not a line
-
followLine
-
followCorner
-
followCorner
-
followCorner1
-
followCorner1
-
followCorner2
-
followCorner2
-
followCorner3
-
followCorner3
-
followCorner4
-
followCorner4
-
followStub
-
followStub
-
followCell
-
followCell
-
getCellTypeAsString
-
followCrossOnLine
-
isOutOfBounds
-
isOutOfBounds
public boolean isOutOfBounds(int x, int y) -
isBlank
-
isBlank
public boolean isBlank(int x, int y) -
isCorner
-
isCorner
public boolean isCorner(int x, int y) -
matchesAny
-
isCorner1
-
isCorner2
-
isCorner3
-
isCorner4
-
isCross
-
isK
-
isInverseK
-
isT
-
isInverseT
-
isNormalCorner
-
isNormalCorner
public boolean isNormalCorner(int x, int y) -
isRoundCorner
-
isRoundCorner
public boolean isRoundCorner(int x, int y) -
isIntersection
-
isIntersection
public boolean isIntersection(int x, int y) -
copyCellsTo
-
equals
-
fillCellsWith
Fills all the cells incellswithc- Parameters:
cells-c-
-
fillContinuousArea
Fills the continuous area with if c1 characters with c2, flooding from cell x, y- Parameters:
x-y-c1- the character to replacec2- the character to replace c1 with- Returns:
- the list of cells filled
-
fillContinuousArea
-
findBoundariesExpandingFrom
Locates and returns the '*' boundaries that we would encounter if we did a flood-fill atseed.- Parameters:
seed-- Returns:
-
cellContainsDashedLineChar
-
initialiseWithText
public boolean initialiseWithText(String text, ProcessingOptions options) throws UnsupportedEncodingException - Throws:
UnsupportedEncodingException
-
initialiseWithLines
public boolean initialiseWithLines(ArrayList<StringBuilder> lines, ProcessingOptions options) throws UnsupportedEncodingException - Throws:
UnsupportedEncodingException
-
getRows
- Returns:
-