Package org.newdawn.slick.geom

Examples of org.newdawn.slick.geom.Polygon


  public org.newdawn.slick.geom.Shape shapeForBody(Body body) {
    Shape shape = body.getShape();
    if(shape instanceof Box) {
      Box box  = (Box) shape;
      ROVector2f[] points = box.getPoints(new Vector2f(0.0f, 0.0f), 0.0f);
      Polygon poly = new Polygon();
      for(ROVector2f point: points) {
        poly.addPoint(point.getX(), point.getY());
      }
      return poly;
    } else if(shape instanceof Circle) {
      return new org.newdawn.slick.geom.Circle(0, 0, ((Circle) shape).getRadius());
    }
View Full Code Here


    rect = new Rectangle(400,100,200,150);
    round = new RoundedRectangle(150,100,200,150,50);
    round2 = new RoundedRectangle(150,300,200,150,50);
    center = new Rectangle(350,250,100,100);
   
    poly = new Polygon();
    poly.addPoint(400,350);
    poly.addPoint(550,320);
    poly.addPoint(600,380);
    poly.addPoint(620,450);
    poly.addPoint(500,450);
View Full Code Here

    if (element.getNodeName().equals("path")) {
      points = element.getAttribute("d");
    }
   
    StringTokenizer tokens = new StringTokenizer(points, ", ");
    Polygon poly = new Polygon();
    int count = processPoly(poly, element, tokens);
   
    NonGeometricData data = Util.getNonGeometricData(element);
    if (count > 3) {
      Shape shape = poly.transform(transform);
     
      diagram.addFigure(new Figure(Figure.POLYGON, shape, data, transform));
    }
  }
View Full Code Here

      y1 = Float.parseFloat(element.getAttribute("y1"));
      y2 = Float.parseFloat(element.getAttribute("y2"));
    } else {
      String points = element.getAttribute("d");
      StringTokenizer tokens = new StringTokenizer(points, ", ");
      Polygon poly = new Polygon();
      if (processPoly(poly, element, tokens) == 2) {
        x1 = poly.getPoint(0)[0];
        y1 = poly.getPoint(0)[1];
        x2 = poly.getPoint(1)[0];
        y2 = poly.getPoint(1)[1];
      } else {
        return;
      }
    }
   
View Full Code Here

        x + halfLength, y + halfLength,
        x - halfLength, y + halfLength,
      };
      break;
    }
    Shape shape = new Polygon(points);
    graphics.fill(shape);
  }
View Full Code Here

    // The basic line
    drawHArrowLine(g, x, y, width - arrowWidth);

    // The final triangle
    Polygon triangle = new Polygon();
    triangle.addPoint(x + width - arrowWidth, y - arrowHeight);
    triangle.addPoint(x + width, y);
    triangle.addPoint(x + width - arrowWidth, y + arrowHeight);
    g.fill(triangle);
  }
View Full Code Here

    // 20);
    for (int i = 0; i < max; i++) {
      if (row % 2 == 1 && i % this.width == 0) {
        continue;
      }
      Polygon p;
      if (!this.inizialited) {
        p = createHexagonAt(curx, cury, this.hexagonSize);
        this.zones[i] = p;
      } else {
        p = this.zones[i];
      }
      if (exploratation[i] == true) {
        g.setColor(Color.gray);
        g.fill(p);
      }
      if (this.elements[i] != null) {
        int x = curx + (this.hexagonSize / 2)
            - (Settings.TILE_SIZE / 2);
        int y = cury + (this.hexagonSize / 2)
            - (Settings.TILE_SIZE / 2);
        ImageManager.getGfx("command_center").draw(x, y);
      }

      if (this.exploratation[i] == true) {
        g.setColor(Color.green);
      } else {
        g.setColor(Color.red);
      }
      g.draw(p);
      // font.drawString(curx + 25, cury + 25, String.valueOf(i));

      curx += wpad;

      if (i % this.width == this.width - 1) {
        // Start a new line
        row++;
        cury += hpad;
        if (row % 2 == 0) {
          curx = getOX() + 1;
        } else {
          curx = getOX() + (this.hexagonSize / 2) + 1;
        }
      }

      if (p.equals(hoveredZone)) {
        hoveredIndex = i;
      }
    }

    if (this.hoveredZone != null && this.selectMode) {
      if (this.exploratation[hoveredIndex] == this.selectableZoneIsDiscovered) {
        g.setColor(Color.green);
        g.draw(this.hoveredZone);
      } else {
        g.setColor(Color.red);
        g.draw(this.hoveredZone);
      }
    }

    // Zones with action in progress
    List<HexagonMapAction> actions = GameData.getHexagonMapActions();
    for (HexagonMapAction a : actions) {
      if (this.equals(a.getMap())) {
        Polygon poly = this.zones[a.getIndex()];
        g.setColor(Color.yellow);
        g.draw(poly);

        int x = (int) (poly.getMinX() + (this.hexagonSize / 2) - (Settings.TILE_SIZE / 2));
        int y = (int) (poly.getMinY() + (this.hexagonSize / 2) - (Settings.TILE_SIZE / 2));
        if(a.isExploration()){
          ImageManager.getGfx("exploration-white").draw(x, y);
        }else{
          ImageManager.getGfx("top_right_expand-white").draw(x, y);
        }
View Full Code Here

  public void update(Input input) throws SlickException {
    int mx = input.getMouseX();
    int my = input.getMouseY();
    boolean found = false;
    for (int i = 0; i < this.zones.length; i++) {
      Polygon p = this.zones[i];
      if (p != null && p.contains(mx, my)) {
        this.hoveredZone = p;
        found = true;

        if (this.selectMode) {
          if (this.exploratation[i] == this.selectableZoneIsDiscovered) {
View Full Code Here

      this.hoveredZone = null;
    }
  }

  private Polygon createHexagonAt(int x, int y, int size) {
    Polygon p = new Polygon();
    final int quarter = size / 4;
    final int midSize = size / 2;
    final int treeQuarter = quarter * 3;

    p.addPoint(x + midSize, y + 0);
    p.addPoint(x + size, y + quarter);
    p.addPoint(x + size, y + treeQuarter);
    p.addPoint(x + midSize, y + size);
    p.addPoint(x + 0, y + treeQuarter);
    p.addPoint(x + 0, y + quarter);

    return p;
  }
View Full Code Here

    if (element.getNodeName().equals("path")) {
      points = element.getAttribute("d");
    }
   
    StringTokenizer tokens = new StringTokenizer(points, ", ");
    Polygon poly = new Polygon();
    int count = processPoly(poly, element, tokens);
   
    NonGeometricData data = Util.getNonGeometricData(element);
    if (count > 3) {
      Shape shape = poly.transform(transform);
     
      diagram.addFigure(new Figure(Figure.POLYGON, shape, data, transform));
    }
  }
View Full Code Here

TOP

Related Classes of org.newdawn.slick.geom.Polygon

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.