Beispiel #1
0
  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 |");
          }
        }
      }
    }
  }
Beispiel #2
0
  /**
   * 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;
  }
Beispiel #3
0
 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);
 }
Beispiel #4
0
 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;
 }
Beispiel #5
0
 public boolean containsAtLeastOneDashedLine(CellSet set) {
   for (Cell cell : set) {
     if (StringUtils.isOneOf(get(cell), dashedLines)) return true;
   }
   return false;
 }
Beispiel #6
0
 public boolean isVerticalLine(int x, int y) {
   char c = get(x, y);
   return 0 != c && StringUtils.isOneOf(c, verticalLines);
 }
Beispiel #7
0
 public static boolean isVerticalLine(char c) {
   return StringUtils.isOneOf(c, verticalLines);
 }
Beispiel #8
0
 public boolean isHorizontalLine(int x, int y) {
   char c = get(x, y);
   return 0 != c && StringUtils.isOneOf(c, horizontalLines);
 }
Beispiel #9
0
 public static boolean isHorizontalLine(char c) {
   return StringUtils.isOneOf(c, horizontalLines);
 }
Beispiel #10
0
 public boolean cellContainsDashedLineChar(Cell cell) {
   char c = get(cell);
   return StringUtils.isOneOf(c, dashedLines);
 }