Class TextGrid
java.lang.Object
org.stathissideris.ascii2image.text.TextGrid
- Direct Known Subclasses:
GridPattern
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
class
class
class
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds grid to this.void
addToMarkupTags
(Collection<String> tags) boolean
void
clear()
boolean
void
copyCellsTo
(CellSet cells, TextGrid grid) boolean
boolean
void
fillCellsWith
(Iterable cells, char c) Fills all the cells incells
withc
fillContinuousArea
(int x, int y, char c) fillContinuousArea
(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) char
get
(int x, int y) char
get
(TextGrid.Cell cell) char
getEastOf
(int x, int y) char
getEastOf
(TextGrid.Cell cell) int
char
getNorthOf
(int x, int y) char
getNorthOf
(TextGrid.Cell cell) getRow
(int y) protected ArrayList<StringBuffer>
getRows()
char
getSouthOf
(int x, int y) char
getSouthOf
(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) char
getWestOf
(int x, int y) char
getWestOf
(TextGrid.Cell cell) int
getWidth()
boolean
boolean
hasEntryPoint
(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.boolean
initialiseWithLines
(ArrayList<StringBuffer> lines, ProcessingOptions options) boolean
initialiseWithText
(String text, ProcessingOptions options) boolean
isArrowhead
(TextGrid.Cell cell) boolean
isBlank
(int x, int y) boolean
isBlank
(TextGrid.Cell cell) boolean
true if cell is blank and the east and west cells are not (used to find gaps between words)static boolean
isBoundary
(char c) boolean
isBoundary
(int x, int y) boolean
isBoundary
(TextGrid.Cell cell) boolean
isBullet
(int x, int y) boolean
isBullet
(TextGrid.Cell cell) boolean
isColumnBlank
(int x) boolean
isCorner
(int x, int y) boolean
isCorner
(TextGrid.Cell cell) boolean
isCorner1
(TextGrid.Cell cell) boolean
isCorner2
(TextGrid.Cell cell) boolean
isCorner3
(TextGrid.Cell cell) boolean
isCorner4
(TextGrid.Cell cell) boolean
isCross
(TextGrid.Cell cell) boolean
isCrossOnLine
(TextGrid.Cell cell) boolean
isEastArrowhead
(TextGrid.Cell cell) boolean
static boolean
isHorizontalLine
(char c) boolean
isHorizontalLine
(int x, int y) boolean
boolean
boolean
boolean
isIntersection
(int x, int y) boolean
isIntersection
(TextGrid.Cell cell) boolean
isInverseK
(TextGrid.Cell cell) boolean
isInverseT
(TextGrid.Cell cell) boolean
isK
(TextGrid.Cell cell) boolean
isLine
(TextGrid.Cell cell) boolean
isLinesEnd
(int x, int y) boolean
isLinesEnd
(TextGrid.Cell cell) Stubs are also considered end of linesboolean
isLoneDiagonal
(TextGrid.Cell cell) boolean
isNormalCorner
(int x, int y) boolean
isNormalCorner
(TextGrid.Cell cell) boolean
boolean
boolean
boolean
isOutOfBounds
(int x, int y) boolean
isOutOfBounds
(TextGrid.Cell cell) boolean
isPointCell
(TextGrid.Cell cell) boolean
isRoundCorner
(int x, int y) boolean
isRoundCorner
(TextGrid.Cell cell) boolean
boolean
isStarOnLine
(TextGrid.Cell cell) boolean
isStringsEnd
(TextGrid.Cell cell) true if the cell is not blank but the next (east) isboolean
isStringsStart
(TextGrid.Cell cell) true if the cell is not blank but the previous (west) isboolean
isStub
(TextGrid.Cell cell) A stub looks like that:boolean
isT
(TextGrid.Cell cell) boolean
static boolean
isVerticalLine
(char c) boolean
isVerticalLine
(int x, int y) boolean
isVerticalLine
(TextGrid.Cell cell) boolean
boolean
boolean
isWestArrowhead
(TextGrid.Cell cell) static TextGrid
makeSameSizeAs
(TextGrid grid) boolean
matches
(GridPattern criteria) boolean
matchesAll
(GridPatternGroup criteria) boolean
matchesAny
(GridPatternGroup criteria) boolean
matchesAny
(TextGrid.Cell cell, GridPatternGroup criteria) int
int
void
void
void
void
void
void
Makes blank all the cells that contain non-text elements.void
replaceAll
(char c1, char c2) Replace all occurences of c1 with c2void
void
void
void
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)void
set
(int x, int y, char c) void
set
(TextGrid.Cell cell, char c) void
void
setRow
(int y, StringBuffer row) toString()
void
writeStringTo
(int x, int y, String str) void
writeStringTo
(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 occurences 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 incells
withc
- Parameters:
cells
-c
-
-
fillContinuousArea
-
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<StringBuffer> lines, ProcessingOptions options) throws UnsupportedEncodingException - Throws:
UnsupportedEncodingException
-
getRows
- Returns:
-