Tabnine Logo
jsettlers.common.map.shapes
Code IndexAdd Tabnine to your IDE (free)

How to use jsettlers.common.map.shapes

Best Java code snippets using jsettlers.common.map.shapes (Showing top 20 results out of 315)

origin: jsettlers/settlers-remake

private int countElements(MapCircle circle) {
  int counter = 0;
  MapCircleIterator iter = circle.iterator();
  while (iter.hasNext()) { // count the elements in the circle to create array
    iter.nextX();
    counter++;
  }
  return counter;
}
origin: jsettlers/settlers-remake

/**
 * This method checks if the point is contained by the map and by the shape.
 */
@Override
public boolean contains(ShortPoint2D position) {
  return inMap(position) && base.contains(position);
}
origin: jsettlers/settlers-remake

public MapCircleIterator(MapCircle circle) {
  this.circle = circle;
  radius = circle.getRadius();
  currentY = -(int) (radius / MapCircle.Y_SCALE);
  currentLineHalfWidth = circle.getHalfLineWidth(currentY);
  currentX = -currentLineHalfWidth;
  centerX = circle.getCenterX();
  centerY = circle.getCenterY();
}
origin: jsettlers/settlers-remake

public final boolean contains(int x, int y) {
  if (!containsLine(y)) {
    return false;
  }
  return !(x < getLineStartX(y - getMinY()) || x > getLineEndX(y - getMinY()));
}
origin: jsettlers/settlers-remake

/**
 * Test method for {@link jsettlers.common.map.shapes.MapCircle#iterator()}.
 */
@Test
public void testIterator() {
  MapCircle circle = new MapCircle((short) (TEST_WIDTH / 2), (short) (TEST_WIDTH / 2), 31.123f);
  testShapeIterator(circle);
}
origin: jsettlers/settlers-remake

@Override
public final boolean contains(ShortPoint2D pos) {
  return contains(pos.x, pos.y);
}
origin: jsettlers/settlers-remake

@Override
public CoordinateStream stream() {
  return stream(centerX, centerY, radius);
}
origin: jsettlers/settlers-remake

/**
 * Gets the distance of map coordinates to the center.
 *
 * @param x
 *            The x coordinate.
 * @param y
 *            The y coordinate
 * @return The distance to the center of this circle, so that the tiles around the center all have distance 1.
 */
public final float squaredDistanceToCenter(int x, int y) {
  return getSquaredDistance(x - centerX, y - centerY);
}
origin: jsettlers/settlers-remake

/**
 * Gets the last x coordinate contained by a line.
 *
 * @param line
 *            The line relative to the first line of this rectangle.
 */
public final int getLineEndX(int line) {
  return getLineStartX(line) + this.width - 1;
}
origin: jsettlers/settlers-remake

@Test
public void testParallelogramIterator() {
  Parallelogram rect = new Parallelogram((short) (TEST_WIDTH / 4), (short) (TEST_WIDTH / 4), (short) (TEST_WIDTH / 2), (short) (TEST_WIDTH / 2));
  testShapeIterator(rect);
  Parallelogram rect2 = new Parallelogram((short) (TEST_WIDTH / 4 + 1), (short) (TEST_WIDTH / 4), (short) (TEST_WIDTH / 2),
      (short) (TEST_WIDTH / 2));
  testShapeIterator(rect2);
  Parallelogram rect3 = new Parallelogram((short) (TEST_WIDTH / 4), (short) (TEST_WIDTH / 4 + 1), (short) (TEST_WIDTH / 2),
      (short) (TEST_WIDTH / 2));
  testShapeIterator(rect3);
}
origin: jsettlers/settlers-remake

/**
 * NOTE: nextY() MUST BE CALLED before this method is called!
 * 
 * @return gives the x of the current iterator position
 */
public final int nextX() {
  return computeNextXAndProgress();
}
origin: jsettlers/settlers-remake

/**
 * Gets the half width of a line, roundend.
 *
 * @param relativeY
 *            The x coordinate of the line relative to the center
 * @return The width of the line, NAN if the line is outside the circle.
 */
protected final float getHalfLineWidth(int relativeY) {
  return calculateHalfLineWidth(radius, relativeY);
}
origin: jsettlers/settlers-remake

/**
 * Creates a free map area by converting the relative points to absolute ones.
 * 
 * @param pos
 *            The origin for the relative points
 * @param relativePoints
 *            The relative points
 */
public FreeMapArea(ShortPoint2D pos, RelativePoint[] relativePoints) {
  this(convertRelative(pos, relativePoints));
}
origin: jsettlers/settlers-remake

/**
 * Gets the first x coordinate contained by a line.
 *
 * @param line
 *            The line relative to the first line of this rectangle.
 */
public final int getLineStartX(int line) {
  return minX + getOffsetForLine(line);
}
origin: jsettlers/settlers-remake

public boolean contains(int x, int y) {
  int dx = x - xOffset;
  int dy = y - yOffset;
  return isValidMapPos(dx, dy) && areaMap[dx][dy];
}
origin: jsettlers/settlers-remake

@Override
public boolean contains(ShortPoint2D position) {
  return contains(position.x, position.y);
}
origin: jsettlers/settlers-remake

@Override
public Iterator<ShortPoint2D> iterator() {
  return new ParallelogramIterator();
}
origin: jsettlers/settlers-remake

@Override
public HexGridAreaIterator iterator() {
  return new HexGridAreaIterator(this);
}
origin: jsettlers/settlers-remake

@Override
public final MapCircleIterator iterator() {
  return new MapCircleIterator(this);
}
origin: jsettlers/settlers-remake

public static final float getDistanceSquared(int x1, int y1, int x2, int y2) {
  int dx = x1 - x2;
  int dy = y1 - y2;
  return getSquaredDistance(dx, dy);
}
jsettlers.common.map.shapes

Most used classes

  • MapCircle
    This class represents a circular area of the map. It contains all elements whose distance to the cen
  • MapRectangle
    This class defines an area on the map that is a rectangle on the screen.
  • FreeMapArea
    This class gives a fast lookup (in O(1)) for contains if a MapArea is given by a list of n positions
  • HexGridArea
    Represents a hexagon on the grid.
  • IMapArea
    This defines an area on the map of a given shape. TODO: Not all map Areas are serializable
  • HexGridArea$HexGridAreaIterator,
  • MapLine,
  • MapNeighboursArea,
  • MapShapeFilter,
  • Parallelogram,
  • FreeMapArea$FreeMapAreaIterator,
  • HexGridAreaTest,
  • MapAreasTest,
  • MapLine$LineIterator,
  • MapNeighboursArea$NeighbourIterator,
  • MapRectangle$RectangleIterator,
  • Parallelogram$ParallelogramIterator
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now