Пример #1
0
  /**
   * Removes the {@link VisualVertex} from the specified {@link GridPoint} on the Grid.
   *
   * @param gridPoint The GridPoint from which the VisualVertex will be removed
   * @return <code>true</code> if a VisualVertex was removed from this GridPoint on the Grid, <code>
   *     false</code> otherwise
   */
  boolean removeVisualVertexAtGridPoint(GridPoint gridPoint) {

    // Early negative return if specified GridPoint is invalid
    if (!Validation.isValidGridPoint(
        gridPoint, this.horizontalGridPoints, this.verticalGridPoints)) {
      return false;
    }

    // Get VisualVertex at specified GridPoint
    VisualVertex visualVertex = this.grid[gridPoint.getPositionX()][gridPoint.getPositionY()];

    // Return false if GridPoint is empty
    if (visualVertex == null) {
      return false;
    }

    // Remove VisualVertex
    this.grid[gridPoint.getPositionX()][gridPoint.getPositionY()] = null;

    return true;
  }
Пример #2
0
  /**
   * Returns the {@link VisualVertex} at the specified {@link GridPoint}.
   *
   * @param gridPoint the GridPoint of the VisualVertex to return
   * @return the VisualVertex at the specified GridPoint or <code>null</code> if the GridPoint is
   *     empty
   */
  public VisualVertex getVisualVertexAtGridPoint(GridPoint gridPoint) {

    // Early negative return if specified GridPoint is invalid
    if (!Validation.isValidGridPoint(
        gridPoint, this.horizontalGridPoints, this.verticalGridPoints)) {
      return null;
    }

    // Get VisualVertex at specified GridPoint
    VisualVertex visualVertex = this.grid[gridPoint.getPositionX()][gridPoint.getPositionY()];

    return visualVertex;
  }