public class TextGrid
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
TextGrid.Cell |
class |
TextGrid.CellColorPair |
class |
TextGrid.CellStringPair |
class |
TextGrid.CellTagPair |
Constructor and Description |
---|
TextGrid() |
TextGrid(int width,
int height) |
TextGrid(TextGrid otherGrid) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(TextGrid grid)
Adds grid to this.
|
void |
addToMarkupTags(java.util.Collection<java.lang.String> tags) |
boolean |
cellContainsDashedLineChar(TextGrid.Cell cell) |
void |
clear() |
boolean |
containsAtLeastOneDashedLine(CellSet set) |
void |
copyCellsTo(CellSet cells,
TextGrid grid) |
boolean |
equals(TextGrid grid) |
boolean |
exactlyOneNeighbourIsBoundary(TextGrid.Cell cell) |
void |
fillCellsWith(java.lang.Iterable cells,
char c)
Fills all the cells in
cells with c |
CellSet |
fillContinuousArea(int x,
int y,
char c)
Fills the continuous area with if c1 characters with c2,
flooding from cell x, y
|
CellSet |
fillContinuousArea(TextGrid.Cell cell,
char c) |
java.util.ArrayList |
findArrowheads() |
CellSet |
findBoundariesExpandingFrom(TextGrid.Cell seed)
Locates and returns the '*' boundaries that we would
encounter if we did a flood-fill at
seed . |
java.util.ArrayList<TextGrid.CellColorPair> |
findColorCodes() |
java.util.ArrayList<TextGrid.CellTagPair> |
findMarkupTags() |
java.util.ArrayList<TextGrid.CellStringPair> |
findStrings()
Returns an ArrayList of CellStringPairs that
represents all the continuous (non-blank) Strings
in the grid.
|
CellSet |
followCell(TextGrid.Cell cell) |
CellSet |
followCell(TextGrid.Cell cell,
TextGrid.Cell blocked) |
CellSet |
followCorner(TextGrid.Cell cell) |
CellSet |
followCorner(TextGrid.Cell cell,
TextGrid.Cell blocked) |
CellSet |
followCorner1(TextGrid.Cell cell) |
CellSet |
followCorner1(TextGrid.Cell cell,
TextGrid.Cell blocked) |
CellSet |
followCorner2(TextGrid.Cell cell) |
CellSet |
followCorner2(TextGrid.Cell cell,
TextGrid.Cell blocked) |
CellSet |
followCorner3(TextGrid.Cell cell) |
CellSet |
followCorner3(TextGrid.Cell cell,
TextGrid.Cell blocked) |
CellSet |
followCorner4(TextGrid.Cell cell) |
CellSet |
followCorner4(TextGrid.Cell cell,
TextGrid.Cell blocked) |
CellSet |
followCrossOnLine(TextGrid.Cell cell,
TextGrid.Cell blocked) |
CellSet |
followIntersection(TextGrid.Cell cell) |
CellSet |
followIntersection(TextGrid.Cell cell,
TextGrid.Cell blocked) |
CellSet |
followLine(int x,
int y) |
CellSet |
followLine(TextGrid.Cell cell)
Returns the neighbours of a line-cell that are boundaries
(0 to 2 cells are returned)
|
CellSet |
followLine(TextGrid.Cell cell,
TextGrid.Cell blocked) |
CellSet |
followStub(TextGrid.Cell cell) |
CellSet |
followStub(TextGrid.Cell cell,
TextGrid.Cell blocked) |
char |
get(int x,
int y) |
char |
get(TextGrid.Cell cell) |
CellSet |
getAllBlanksBetweenCharacters() |
CellSet |
getAllBoundaries() |
CellSet |
getAllNonBlank() |
java.lang.String |
getCellTypeAsString(TextGrid.Cell cell) |
java.lang.String |
getDebugString() |
char |
getEastOf(int x,
int y) |
char |
getEastOf(TextGrid.Cell cell) |
int |
getHeight() |
char |
getNorthOf(int x,
int y) |
char |
getNorthOf(TextGrid.Cell cell) |
CellSet |
getPointMarkersOnLine() |
java.lang.StringBuffer |
getRow(int y) |
protected java.util.ArrayList<java.lang.StringBuffer> |
getRows() |
char |
getSouthOf(int x,
int y) |
char |
getSouthOf(TextGrid.Cell cell) |
java.lang.String |
getStringAt(int x,
int y,
int length) |
java.lang.String |
getStringAt(TextGrid.Cell cell,
int length) |
TextGrid |
getSubGrid(int x,
int y,
int width,
int height) |
TextGrid |
getTestingSubGrid(TextGrid.Cell cell) |
char |
getWestOf(int x,
int y) |
char |
getWestOf(TextGrid.Cell cell) |
int |
getWidth() |
boolean |
hasBlankCells() |
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(java.util.ArrayList<java.lang.StringBuffer> lines,
ProcessingOptions options) |
boolean |
initialiseWithText(java.lang.String text,
ProcessingOptions options) |
boolean |
isArrowhead(TextGrid.Cell cell) |
boolean |
isBlank(int x,
int y) |
boolean |
isBlank(TextGrid.Cell cell) |
boolean |
isBlankBetweenCharacters(TextGrid.Cell cell)
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 |
isHorizontalCrossOnLine(TextGrid.Cell cell) |
static boolean |
isHorizontalLine(char c) |
boolean |
isHorizontalLine(int x,
int y) |
boolean |
isHorizontalLine(TextGrid.Cell cell) |
boolean |
isHorizontalLinesEnd(TextGrid.Cell cell) |
boolean |
isHorizontalStarOnLine(TextGrid.Cell cell) |
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 lines
|
boolean |
isLoneDiagonal(TextGrid.Cell cell) |
boolean |
isNormalCorner(int x,
int y) |
boolean |
isNormalCorner(TextGrid.Cell cell) |
boolean |
isNorthArrowhead(TextGrid.Cell cell) |
boolean |
isOnHorizontalLine(TextGrid.Cell cell) |
boolean |
isOnVerticalLine(TextGrid.Cell cell) |
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 |
isSouthArrowhead(TextGrid.Cell cell) |
boolean |
isStarOnLine(TextGrid.Cell cell) |
boolean |
isStringsEnd(TextGrid.Cell cell)
true if the cell is not blank
but the next (east) is
|
boolean |
isStringsStart(TextGrid.Cell cell)
true if the cell is not blank
but the previous (west) is
|
boolean |
isStub(TextGrid.Cell cell)
A stub looks like that:
+- or -+ or + or + or /- or -/ or / (you get the point)
| | |
|
boolean |
isT(TextGrid.Cell cell) |
boolean |
isVerticalCrossOnLine(TextGrid.Cell cell) |
static boolean |
isVerticalLine(char c) |
boolean |
isVerticalLine(int x,
int y) |
boolean |
isVerticalLine(TextGrid.Cell cell) |
boolean |
isVerticalLinesEnd(TextGrid.Cell cell) |
boolean |
isVerticalStarOnLine(TextGrid.Cell cell) |
boolean |
isWestArrowhead(TextGrid.Cell cell) |
boolean |
loadFrom(java.lang.String filename) |
boolean |
loadFrom(java.lang.String filename,
ProcessingOptions options) |
static void |
main(java.lang.String[] args) |
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 |
otherStringsEndInTheSameColumn(TextGrid.Cell cell) |
int |
otherStringsStartInTheSameColumn(TextGrid.Cell cell) |
void |
printDebug() |
void |
removeArrowheads() |
void |
removeBoundaries() |
void |
removeColorCodes() |
void |
removeMarkupTags() |
void |
removeNonText()
Makes blank all the cells that contain non-text
elements.
|
void |
replaceAll(char c1,
char c2)
Replace all occurences of c1 with c2
|
void |
replaceBullets() |
void |
replaceHumanColorCodes() |
void |
replacePointMarkersOnLine() |
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)
|
void |
set(int x,
int y,
char c) |
void |
set(TextGrid.Cell cell,
char c) |
void |
setRow(int y,
java.lang.String row) |
void |
setRow(int y,
java.lang.StringBuffer row) |
java.lang.String |
toString() |
void |
writeStringTo(int x,
int y,
java.lang.String str) |
void |
writeStringTo(TextGrid.Cell cell,
java.lang.String str) |
public TextGrid()
public TextGrid(int width, int height)
public TextGrid(TextGrid otherGrid)
public void addToMarkupTags(java.util.Collection<java.lang.String> tags)
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
public void clear()
public char get(int x, int y)
public char get(TextGrid.Cell cell)
public java.lang.StringBuffer getRow(int y)
public TextGrid getSubGrid(int x, int y, int width, int height)
public TextGrid getTestingSubGrid(TextGrid.Cell cell)
public java.lang.String getStringAt(int x, int y, int length)
public java.lang.String getStringAt(TextGrid.Cell cell, int length)
public char getNorthOf(int x, int y)
public char getSouthOf(int x, int y)
public char getEastOf(int x, int y)
public char getWestOf(int x, int y)
public char getNorthOf(TextGrid.Cell cell)
public char getSouthOf(TextGrid.Cell cell)
public char getEastOf(TextGrid.Cell cell)
public char getWestOf(TextGrid.Cell cell)
public void writeStringTo(int x, int y, java.lang.String str)
public void writeStringTo(TextGrid.Cell cell, java.lang.String str)
public void set(TextGrid.Cell cell, char c)
public void set(int x, int y, char c)
public void setRow(int y, java.lang.String row)
public void setRow(int y, java.lang.StringBuffer row)
public int getWidth()
public int getHeight()
public void printDebug()
public java.lang.String getDebugString()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean add(TextGrid grid)
grid
- public void replaceTypeOnLine()
public void replacePointMarkersOnLine()
public CellSet getPointMarkersOnLine()
public void replaceHumanColorCodes()
public void replaceAll(char c1, char c2)
c1
- c2
- public boolean hasBlankCells()
public CellSet getAllNonBlank()
public CellSet getAllBoundaries()
public CellSet getAllBlanksBetweenCharacters()
public java.util.ArrayList<TextGrid.CellStringPair> findStrings()
public boolean hasEntryPoint(TextGrid.Cell cell, int entryPointId)
cell
- entryPointId
- public boolean isBlankBetweenCharacters(TextGrid.Cell cell)
cell
- public void removeNonText()
public void removeArrowheads()
public void removeColorCodes()
public void removeBoundaries()
public java.util.ArrayList findArrowheads()
public java.util.ArrayList<TextGrid.CellColorPair> findColorCodes()
public java.util.ArrayList<TextGrid.CellTagPair> findMarkupTags()
public void removeMarkupTags()
public boolean matchesAny(GridPatternGroup criteria)
public boolean matchesAll(GridPatternGroup criteria)
public boolean matches(GridPattern criteria)
public boolean isOnHorizontalLine(TextGrid.Cell cell)
public boolean isOnVerticalLine(TextGrid.Cell cell)
public static boolean isBoundary(char c)
public boolean isBoundary(int x, int y)
public boolean isBoundary(TextGrid.Cell cell)
public boolean isLine(TextGrid.Cell cell)
public static boolean isHorizontalLine(char c)
public boolean isHorizontalLine(TextGrid.Cell cell)
public boolean isHorizontalLine(int x, int y)
public static boolean isVerticalLine(char c)
public boolean isVerticalLine(TextGrid.Cell cell)
public boolean isVerticalLine(int x, int y)
public boolean isLinesEnd(int x, int y)
public boolean isLinesEnd(TextGrid.Cell cell)
cell
- public boolean isVerticalLinesEnd(TextGrid.Cell cell)
public boolean isHorizontalLinesEnd(TextGrid.Cell cell)
public boolean isPointCell(TextGrid.Cell cell)
public boolean containsAtLeastOneDashedLine(CellSet set)
public boolean exactlyOneNeighbourIsBoundary(TextGrid.Cell cell)
public boolean isStub(TextGrid.Cell cell)
+- or -+ or + or + or /- or -/ or / (you get the point) | | |
cell
- public boolean isCrossOnLine(TextGrid.Cell cell)
public boolean isHorizontalCrossOnLine(TextGrid.Cell cell)
public boolean isVerticalCrossOnLine(TextGrid.Cell cell)
public boolean isStarOnLine(TextGrid.Cell cell)
public boolean isLoneDiagonal(TextGrid.Cell cell)
public boolean isHorizontalStarOnLine(TextGrid.Cell cell)
public boolean isVerticalStarOnLine(TextGrid.Cell cell)
public boolean isArrowhead(TextGrid.Cell cell)
public boolean isNorthArrowhead(TextGrid.Cell cell)
public boolean isEastArrowhead(TextGrid.Cell cell)
public boolean isWestArrowhead(TextGrid.Cell cell)
public boolean isSouthArrowhead(TextGrid.Cell cell)
public boolean isBullet(int x, int y)
public boolean isBullet(TextGrid.Cell cell)
public void replaceBullets()
public boolean isStringsStart(TextGrid.Cell cell)
cell
- public boolean isStringsEnd(TextGrid.Cell cell)
cell
- public int otherStringsStartInTheSameColumn(TextGrid.Cell cell)
public int otherStringsEndInTheSameColumn(TextGrid.Cell cell)
public boolean isColumnBlank(int x)
public CellSet followLine(int x, int y)
public CellSet followIntersection(TextGrid.Cell cell)
public CellSet followIntersection(TextGrid.Cell cell, TextGrid.Cell blocked)
public CellSet followLine(TextGrid.Cell cell)
cell
- public CellSet followLine(TextGrid.Cell cell, TextGrid.Cell blocked)
public CellSet followCorner(TextGrid.Cell cell)
public CellSet followCorner(TextGrid.Cell cell, TextGrid.Cell blocked)
public CellSet followCorner1(TextGrid.Cell cell)
public CellSet followCorner1(TextGrid.Cell cell, TextGrid.Cell blocked)
public CellSet followCorner2(TextGrid.Cell cell)
public CellSet followCorner2(TextGrid.Cell cell, TextGrid.Cell blocked)
public CellSet followCorner3(TextGrid.Cell cell)
public CellSet followCorner3(TextGrid.Cell cell, TextGrid.Cell blocked)
public CellSet followCorner4(TextGrid.Cell cell)
public CellSet followCorner4(TextGrid.Cell cell, TextGrid.Cell blocked)
public CellSet followStub(TextGrid.Cell cell)
public CellSet followStub(TextGrid.Cell cell, TextGrid.Cell blocked)
public CellSet followCell(TextGrid.Cell cell)
public CellSet followCell(TextGrid.Cell cell, TextGrid.Cell blocked)
public java.lang.String getCellTypeAsString(TextGrid.Cell cell)
public CellSet followCrossOnLine(TextGrid.Cell cell, TextGrid.Cell blocked)
public boolean isOutOfBounds(TextGrid.Cell cell)
public boolean isOutOfBounds(int x, int y)
public boolean isBlank(TextGrid.Cell cell)
public boolean isBlank(int x, int y)
public boolean isCorner(TextGrid.Cell cell)
public boolean isCorner(int x, int y)
public boolean matchesAny(TextGrid.Cell cell, GridPatternGroup criteria)
public boolean isCorner1(TextGrid.Cell cell)
public boolean isCorner2(TextGrid.Cell cell)
public boolean isCorner3(TextGrid.Cell cell)
public boolean isCorner4(TextGrid.Cell cell)
public boolean isCross(TextGrid.Cell cell)
public boolean isK(TextGrid.Cell cell)
public boolean isInverseK(TextGrid.Cell cell)
public boolean isT(TextGrid.Cell cell)
public boolean isInverseT(TextGrid.Cell cell)
public boolean isNormalCorner(TextGrid.Cell cell)
public boolean isNormalCorner(int x, int y)
public boolean isRoundCorner(TextGrid.Cell cell)
public boolean isRoundCorner(int x, int y)
public boolean isIntersection(TextGrid.Cell cell)
public boolean isIntersection(int x, int y)
public boolean equals(TextGrid grid)
public void fillCellsWith(java.lang.Iterable cells, char c)
cells
with c
cells
- c
- public CellSet fillContinuousArea(int x, int y, char c)
x
- y
- c1
- the character to replacec2
- the character to replace c1 withpublic CellSet fillContinuousArea(TextGrid.Cell cell, char c)
public CellSet findBoundariesExpandingFrom(TextGrid.Cell seed)
seed
.seed
- public boolean cellContainsDashedLineChar(TextGrid.Cell cell)
public boolean loadFrom(java.lang.String filename) throws java.io.FileNotFoundException, java.io.IOException
java.io.FileNotFoundException
java.io.IOException
public boolean loadFrom(java.lang.String filename, ProcessingOptions options) throws java.io.IOException
java.io.IOException
public boolean initialiseWithText(java.lang.String text, ProcessingOptions options) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public boolean initialiseWithLines(java.util.ArrayList<java.lang.StringBuffer> lines, ProcessingOptions options) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
protected java.util.ArrayList<java.lang.StringBuffer> getRows()
Copyright © 2020. All Rights Reserved.