Package civquest.util

Examples of civquest.util.Coordinate


    public Coordinate getAbsImagePaintCoord(Coordinate coord) {
    return getAbsPaintCoord(coord).sub(new Coordinate(0,2 * halfCellHeight));
    }

    public Coordinate getAbsMiddlePaintCoord(Coordinate coord) {
    return getAbsPaintCoord(coord).add(new Coordinate(halfCellWidth,halfCellHeight));
    }
View Full Code Here


    public Coordinate getAbsMiddlePaintCoord(Coordinate coord) {
    return getAbsPaintCoord(coord).add(new Coordinate(halfCellWidth,halfCellHeight));
    }

  public Coordinate getEllipseSize() {
    return new Coordinate(halfCellWidth, halfCellHeight);
  }
View Full Code Here

  public Coordinate getFieldCornerOffset(Coordinate pos, Coordinate offset) {
    assert offset.equals(-1, -1) || offset.equals(1, -1)
      || offset.equals(1, 1) || offset.equals(-1, 1);

    if (offset.equals(-1, -1)) {
      return new Coordinate(halfCellWidth, 2 * halfCellHeight);
    } else if (offset.equals(1, -1)) {
      return new Coordinate(2 * halfCellWidth, 3 * halfCellHeight);
    } else if (offset.equals(1, 1)) {
      return new Coordinate(halfCellWidth, 4 * halfCellHeight);
    } else if (offset.equals(-1, 1)) {
      return new Coordinate(0, 3 * halfCellHeight);
    } else {
      // Should not happen
      return null;
    }
  }
View Full Code Here

    }
  }

    public Coordinate[] getAbsFieldEdgeCoords(Coordinate coord) {
        Coordinate[] retValue = new Coordinate[4];
        Coordinate base = getAbsPaintCoord(coord);
        retValue[0] = base.add(halfCellWidth, 0);
        retValue[1] = base.add(2 * halfCellWidth, halfCellHeight);
        retValue[2] = base.add(halfCellWidth, 2 * halfCellHeight);
        retValue[3] = base.add(0, halfCellHeight);
        return retValue;
    }
View Full Code Here

        retValue[3] = base.add(0, halfCellHeight);
        return retValue;
    }

    public Rectangle getFieldRectangle(int x1, int y1, int x2, int y2) {
    Coordinate upperLeft = getUnscrolledArrayCoord(x1, y1);
    Coordinate upperRight = getUnscrolledArrayCoord(x2, y1);
    Coordinate bottomLeft = getUnscrolledArrayCoord(x1, y2);
    Coordinate bottomRight = getUnscrolledArrayCoord(x2, y2);

    return new Rectangle(upperLeft.x, upperRight.y, bottomRight.x, bottomLeft.y);
    }
View Full Code Here

    throws InvalidImageException {
    MapData mapData = Game.getMapData();

    Rectangle fieldRect = buffer.getFieldRect();

    Coordinate fieldStart = fieldRect.getTopLeftCorner();
    boolean[][] markedFields = buffer.getMarkedFields();

    Graphics2D graphics = buffer.getGraphics();
    Shape oldClip = graphics.getClip();            // Is this really necessary?

    int arSize = fieldRect.getWidth() + 1 + fieldRect.getHeight() + 1;
   
    boolean[][] markedSections = calculateMarkedSections(markedFields, arSize);

    int startx = fieldRect.getHeight();
    int endx = startx + 1;
    int startDX = -1;
    int endDX = 1;

    // THINK ABOUT the tries to draw non-existent fields - at moment they
    // get prevented by "if"
    int refModValue = (markedFields[0].length - 1) % 2;
    for (int y = 0; y < markedSections[0].length; y++) {
      for (int x = startx; x <= endx; x++) {
        if (markedSections[x][y]) {

          Coordinate scrPos = new Coordinate();
          Coordinate unscrPos = new Coordinate();
          unscrPos.x = (y + x - markedFields[0].length + 1) / 2;
          unscrPos.y = y - unscrPos.x;
          unscrPos = unscrPos.add(fieldStart);

          Coordinate imPos = getAbsImagePaintCoord(unscrPos).
            add(0, 2 * halfCellHeight).
            sub(buffer.getPosition());

          boolean left = ((x + y) % 2 == refModValue);

View Full Code Here

        markedSections[x][y] = false;
      }
    }
   
   
    Coordinate secPos = new Coordinate();

    for (int x = 0; x < markedFields.length; x++) {
      for (int y = 0; y < markedFields[0].length; y++) {
        if (markedFields[x][y]) {
          // Upper left section of current field
          secPos.set(markedFields[0].length - y + x - 1, x + y);
         
          // Mark all sections intersecting the current field
          for (int sy = secPos.y - 2; sy <= secPos.y + 1; sy++) {
            if (sy >= 0) {
              for (int sx = secPos.x; sx <= secPos.x + 1; sx++) {
View Full Code Here

    while (edge.size() > 0) {
      StepInfo best = edge.poll();
      Messages.getMessages().info("DijkstraMoveCalc", "DMCalcDec",
                    "Best choice: " + best);

      Coordinate bestCoord = best.to;
     
      if (finishedFields[bestCoord.x][bestCoord.y] == null) {
        finishedFields[bestCoord.x][bestCoord.y] = best;
        if (bestCoord.equals(to)) {
          Messages.getMessages().info("DijkstraMoveCalc",
                        "DMCalcDec", "Found dest!");
          return;
        }
View Full Code Here

                StepInfo[][] finishedFields,
                Coordinate coord) {
    Iterator<Coordinate> neighborIterator
      = Game.getMapData().getAllNeighborFieldIterator(coord);
    coordLoop: while (neighborIterator.hasNext()) {
      Coordinate nCoord = neighborIterator.next();
      if (finishedFields[nCoord.x][nCoord.y] != null) {
        // we have already computed the optimal distance
        continue;
      }
View Full Code Here

  private LoadedData loadedData = null;

    /** Constructs a new Field with coordinates (x,y) */
    public Field(int x, int y) {
    id = Game.getGame().getNewID();
        position = new Coordinate(x, y);
    }
View Full Code Here

TOP

Related Classes of civquest.util.Coordinate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.