public void replacePointMarkersOnLine() { int width = getWidth(); int height = getHeight(); for (int yi = 0; yi < height; yi++) { for (int xi = 0; xi < width; xi++) { char c = get(xi, yi); Cell cell = new Cell(xi, yi); if (StringUtils.isOneOf(c, pointMarkers) && isStarOnLine(cell)) { boolean isOnHorizontalLine = false; if (StringUtils.isOneOf(get(cell.getEast()), horizontalLines)) isOnHorizontalLine = true; if (StringUtils.isOneOf(get(cell.getWest()), horizontalLines)) isOnHorizontalLine = true; boolean isOnVerticalLine = false; if (StringUtils.isOneOf(get(cell.getNorth()), verticalLines)) isOnVerticalLine = true; if (StringUtils.isOneOf(get(cell.getSouth()), verticalLines)) isOnVerticalLine = true; if (isOnHorizontalLine && isOnVerticalLine) { set(xi, yi, '+'); if (DEBUG) System.out.println("replaced marker on line '" + c + "' with +"); } else if (isOnHorizontalLine) { set(xi, yi, '-'); if (DEBUG) System.out.println("replaced marker on line '" + c + "' with -"); } else if (isOnVerticalLine) { set(xi, yi, '|'); if (DEBUG) System.out.println("replaced marker on line '" + c + "' with |"); } } } } }
/** * This is done in a bit of a messy way, should be impossible to go out of sync with corresponding * GridPatternGroup. */ public boolean hasEntryPoint(Cell cell, int entryPointId) { char c = get(cell); if (entryPointId == 1) { return StringUtils.isOneOf(c, entryPoints1); } else if (entryPointId == 2) { return StringUtils.isOneOf(c, entryPoints2); } else if (entryPointId == 3) { return StringUtils.isOneOf(c, entryPoints3); } else if (entryPointId == 4) { return StringUtils.isOneOf(c, entryPoints4); } else if (entryPointId == 5) { return StringUtils.isOneOf(c, entryPoints5); } else if (entryPointId == 6) { return StringUtils.isOneOf(c, entryPoints6); } else if (entryPointId == 7) { return StringUtils.isOneOf(c, entryPoints7); } else if (entryPointId == 8) { return StringUtils.isOneOf(c, entryPoints8); } return false; }
public boolean isBoundary(Cell cell) { char c = get(cell.x, cell.y); if (0 == c) return false; if ('+' == c || '\\' == c || '/' == c) { return isIntersection(cell) || isCorner(cell) || isStub(cell) || isCrossOnLine(cell); } return StringUtils.isOneOf(c, boundaries) && !isLoneDiagonal(cell); }
public CellSet getPointMarkersOnLine() { CellSet result = new CellSet(); int width = getWidth(); int height = getHeight(); for (int yi = 0; yi < height; yi++) { for (int xi = 0; xi < width; xi++) { char c = get(xi, yi); if (StringUtils.isOneOf(c, pointMarkers) && isStarOnLine(new Cell(xi, yi))) { result.add(new Cell(xi, yi)); } } } return result; }
public boolean containsAtLeastOneDashedLine(CellSet set) { for (Cell cell : set) { if (StringUtils.isOneOf(get(cell), dashedLines)) return true; } return false; }
public boolean isVerticalLine(int x, int y) { char c = get(x, y); return 0 != c && StringUtils.isOneOf(c, verticalLines); }
public static boolean isVerticalLine(char c) { return StringUtils.isOneOf(c, verticalLines); }
public boolean isHorizontalLine(int x, int y) { char c = get(x, y); return 0 != c && StringUtils.isOneOf(c, horizontalLines); }
public static boolean isHorizontalLine(char c) { return StringUtils.isOneOf(c, horizontalLines); }
public boolean cellContainsDashedLineChar(Cell cell) { char c = get(cell); return StringUtils.isOneOf(c, dashedLines); }