Exemplo n.º 1
0
  private void drawArrow(Graphics2D g2d, double sx, double sy, double px, double py, int pass) {

    if (pass == 0) {

      g2d.setStroke(new BasicStroke(4.0f));
      g2d.setPaint(preSynapticSiteColor.brighter());
      g2d.draw(new Line2D.Double(sx, sy, px, py));

      return;
    }

    double dx = px - sx;
    double dy = py - sy;

    Polygon tip = new Polygon();
    tip.addPoint(0, 0);
    tip.addPoint(-10, -20);
    tip.addPoint(10, -20);

    AffineTransform transform = new AffineTransform();
    transform.concatenate(AffineTransform.getTranslateInstance(px, py));
    transform.concatenate(AffineTransform.getScaleInstance(0.5, 0.5));
    transform.concatenate(AffineTransform.getRotateInstance(Math.atan2(dy, dx) - Math.PI * 0.5));
    Shape shape = new GeneralPath(tip).createTransformedShape(transform);
    g2d.setPaint(preSynapticSiteColor.darker().darker());
    g2d.draw(shape);
    g2d.setPaint(preSynapticSiteColor.brighter().brighter());
    g2d.fill(shape);
  }
Exemplo n.º 2
0
 @Override
 public boolean isInBounds(Bounds bounds) {
   // TODO there is no float polygon, so I have to think about s.th. else (or leave it the way it
   // is now)
   int x[] = new int[nodes.length];
   int y[] = new int[nodes.length];
   int i = 0;
   for (Node node : nodes) {
     x[i] = (int) (node.getPos().getLongitude() * 1000); // 1000 is a random factor, can be changed
     i++;
   }
   i = 0;
   for (Node node : nodes) {
     y[i] = (int) (node.getPos().getLatitude() * 1000);
     i++;
   }
   Polygon area = new Polygon(x, y, nodes.length);
   Rectangle2D.Double box =
       new Rectangle2D.Double(
           bounds.getLeft() * 1000 - 1,
           bounds.getTop() * 1000 - 1,
           bounds.getWidth() * 1000 + 1,
           bounds.getHeight() * 1000 + 1);
   boolean inside = false;
   for (Node node : nodes) {
     if (node.isInBounds(bounds)) {
       inside = true;
     }
   }
   return inside || area.contains(box) || area.intersects(box);
 }
Exemplo n.º 3
0
  /**
   * Determine whether or not the actor is on a spike.
   *
   * @return Whether or not the actor is on a spike.
   */
  private void hitSpike() {
    if (dead) {
      return;
    }
    /*
     * Create a rectangle for comparisons.
     */
    Rectangle2D actor = new Rectangle();
    actor.setRect((int) x, (int) y + 3, width, height);

    for (myIntersectable i : myWorld.inIntersectable) {
      /*
       * Loop through world objects and check for those intersectable.
       */
      if (!i.equals(this) && i instanceof mySpike) {
        /*
         * Cast the intersectable object to paintable and create it's polygon.
         */
        myPaintable p = (myPaintable) i;
        int[] xP =
            new int[] {
              (int) p.getX(), (int) p.getX() + p.getWidth() / 2, (int) p.getX() + p.getWidth()
            };
        int[] yP =
            new int[] {
              (int) p.getY() + p.getHeight(), (int) p.getY(), (int) p.getY() + p.getHeight()
            };
        Polygon other = new Polygon(xP, yP, 3);

        if (other.intersects(actor)) {
          die();
        }
      }
    }
  }
Exemplo n.º 4
0
 public static void drawPolygon(
     Graphics g,
     int x1,
     int y1,
     int x2,
     int y2,
     int x3,
     int y3,
     int x4,
     int y4,
     int x5,
     int y5,
     int x6,
     int y6,
     int x7,
     int y7,
     int x8,
     int y8) {
   Polygon myPoly = new Polygon();
   myPoly.addPoint(x1, y1);
   myPoly.addPoint(x2, y2);
   myPoly.addPoint(x3, y3);
   myPoly.addPoint(x4, y4);
   myPoly.addPoint(x5, y5);
   myPoly.addPoint(x6, y6);
   myPoly.addPoint(x7, y7);
   myPoly.addPoint(x8, y8);
   g.drawPolygon(myPoly);
 }
Exemplo n.º 5
0
 /**
  * Converte una lista di ponti in un poligono.
  *
  * @param points Lista di punti.
  * @return Poligono che rappresenta la lista di punti.
  */
 public static Polygon PolygonFromPoints(ArrayList<Point2D> points) {
   Polygon tempPolygon = new Polygon();
   for (Point2D i : points) {
     tempPolygon.addPoint((int) i.getX(), (int) i.getY());
   }
   return tempPolygon;
 }
Exemplo n.º 6
0
  private void enlightTriangles(Wall wall, int width) {
    int brights[] = new int[4];
    for (int i = 0; i < 4; ++i) {
      brights[i] = calculateBrithness(wall.corners3D[i], wall.vector);
    }

    // podzial na 2 trojkaty
    int[][] triangleIndexes = {{0, 1, 2}, {0, 2, 3}};

    Polygon p = new Polygon();
    for (int[] corner : wall.corners2D) {
      p.addPoint(corner[0], corner[1]);
    }

    int minX = p.getBounds().x;
    int minY = p.getBounds().y;

    for (int[] indexes : triangleIndexes) {
      sortIndexes2D(indexes, wall.corners2D);

      int xoffset = wall.corners2D[indexes[0]][0] - minX;
      int yoffset = wall.corners2D[indexes[0]][1] - minY;
      int offset = xoffset + yoffset * width;
      if (shader == Shader.PHONG) {
        phongTriangle(wall, offset, width, indexes);
      } else {
        gouraudTriangle(wall, offset, width, indexes, brights);
      }
    }
  }
Exemplo n.º 7
0
  /**
   * Converts a JTS {@link Polygon}, which represents a ROI, int an AWT {@link java.awt.Polygon} by
   * means of the provided {@link MathTransform}.
   *
   * <p>It also stores the points for this polygon into the provided {@link List}.
   *
   * @param roiInput the input ROI as a JTS {@link Polygon}.
   * @param worldToGridTransform the {@link MathTransform} to apply to the input ROI.
   * @param points a {@link List} that should hold the transformed points.
   * @return an AWT {@link java.awt.Polygon}.
   * @throws TransformException in case the provided {@link MathTransform} chokes.
   */
  public static java.awt.Polygon convertPolygonToPointArray(
      final Polygon roiInput, MathTransform worldToGridTransform, List<Point2D> points)
      throws TransformException {
    final boolean isIdentity = worldToGridTransform.isIdentity();
    final double coords[] = new double[2];
    final LineString exteriorRing = roiInput.getExteriorRing();
    final CoordinateSequence exteriorRingCS = exteriorRing.getCoordinateSequence();
    final int numCoords = exteriorRingCS.size();
    final java.awt.Polygon retValue = new java.awt.Polygon();
    for (int i = 0; i < numCoords; i++) {
      // get the actual coord
      coords[0] = exteriorRingCS.getX(i);
      coords[1] = exteriorRingCS.getY(i);

      // transform it
      if (!isIdentity) worldToGridTransform.transform(coords, 0, coords, 0, 1);

      // send it back to the returned polygon
      final int x = (int) (coords[0] + 0.5d);
      final int y = (int) (coords[1] + 0.5d);
      if (points != null) points.add(new Point2D.Double(coords[0], coords[1]));

      // send it back to the returned polygon
      retValue.addPoint(x, y);
    }

    // return the created polygon.
    return retValue;
  }
Exemplo n.º 8
0
  private void draw_horizon(int rad, Point center, int[] angles) {
    // Draw an arc
    int arc_angle =
        ((angles[0] > angles[1]) ? (360 - angles[0]) + angles[1] : (angles[1] - angles[0]));

    Polygon remainder = new Polygon();

    offgraphics_.setColor(GREEN);
    offgraphics_.fillArc(center.x - rad, center.y - rad, 2 * rad, 2 * rad, angles[0], arc_angle);

    if (pitch_ != 0) {
      if ((pitch_ > 0 && Math.abs(roll_) < 90) || (pitch_ < 0 && Math.abs(roll_) >= 90))
        offgraphics_.setColor(BLUE);

      int cover_angle = (angles[0] + arc_angle / 2 + ((arc_angle < 180) ? 180 : 0)) % 360;

      // System.out.println (points[0] + " " + points[1]);

      // System.out.println (accepted_point);

      remainder.addPoint(
          center.x + polar_to_rect_x(rad, cover_angle),
          center.y - polar_to_rect_y(rad, cover_angle));
      remainder.addPoint(
          center.x + polar_to_rect_x(rad, angles[0]), center.y - polar_to_rect_y(rad, angles[0]));
      remainder.addPoint(
          center.x + polar_to_rect_x(rad, angles[1]), center.y - polar_to_rect_y(rad, angles[1]));
      offgraphics_.fillPolygon(remainder);
      // offgraphics_.setColor (getBackground ());
      // offgraphics_.drawPolygon (remainder);
    }
  }
Exemplo n.º 9
0
 /** @see Graphics#fillPolygon(int[], int[], int) */
 public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) {
   Polygon poly = new Polygon();
   for (int i = 0; i < nPoints; i++) {
     poly.addPoint(xPoints[i], yPoints[i]);
   }
   fill(poly);
 }
Exemplo n.º 10
0
  public void drawEventBasedGateway(int x, int y, int width, int height) {
    // rhombus
    drawGateway(x, y, width, height);
    double scale = .6;

    drawCatchingEvent(
        (int) (x + width * (1 - scale) / 2),
        (int) (y + height * (1 - scale) / 2),
        (int) (width * scale),
        (int) (height * scale),
        false,
        null);

    double r = width / 6.;

    // create pentagon (coords with respect to center)
    int topX = (int) (.95 * r); // top right corner
    int topY = (int) (-.31 * r);
    int bottomX = (int) (.59 * r); // bottom right corner
    int bottomY = (int) (.81 * r);

    int[] xPoints = new int[] {0, topX, bottomX, -bottomX, -topX};
    int[] yPoints = new int[] {-(int) r, topY, bottomY, bottomY, topY};
    Polygon pentagon = new Polygon(xPoints, yPoints, 5);
    pentagon.translate(x + width / 2, y + width / 2);

    // draw
    g.drawPolygon(pentagon);
  }
Exemplo n.º 11
0
  /** make new shape polygon */
  private void reMakePolygonShape() {
    ConvexHull convexHull;

    List<Point> newPoints = new ArrayList<Point>();

    for (int j = 0; j < polygon.npoints; j++) {

      if (mainClusterShape.contains(polygon.xpoints[j], polygon.ypoints[j])) {
        newPoints.add(new Point(polygon.xpoints[j], polygon.ypoints[j]));
      }
    }

    for (Point2D point2D : getIntersectPoint()) {
      newPoints.add(new Point((int) point2D.getX(), (int) point2D.getY()));
    }

    for (int i = 0; i < mainClusterShape.npoints; i++) {
      if (polygon.contains(mainClusterShape.xpoints[i], mainClusterShape.ypoints[i])) {
        Point point = new Point(mainClusterShape.xpoints[i], mainClusterShape.ypoints[i]);
        newPoints.add(point);
      }
    }

    convexHull = new ConvexHull();

    for (Point point : newPoints) {
      convexHull.addPoint((int) point.getX(), (int) point.getY());
    }

    setPolygon(convexHull.convex());
    newPoints.clear();
  }
Exemplo n.º 12
0
  /**
   * Draw the LineSelection at its current location. It is the responsibility of the
   * applet/application to draw the LineSelection at the appropriate times, e.g., inside the
   * component's update() and/or paint() method. This gives maximum flexibility for double
   * buffering, etc.
   *
   * @param g The Graphics context to use for drawing.
   */
  public void draw(Graphics g) {

    if (!isVisible()) {
      return;
    }

    Color saveColor = g.getColor();
    g.setColor(color);
    if (thickness > 1) {
      double ratio = ((double) thickness) / ((double) length());
      double txdb = ratio * ((double) height) / 2.0;
      int tx = txdb > 0 ? ((int) Math.ceil(txdb)) : ((int) Math.floor(txdb));
      double tydb = -ratio * ((double) width) / 2.0;
      int ty = tydb > 0 ? ((int) Math.ceil(tydb)) : ((int) Math.floor(tydb));
      Point[] poly = new Point[4];
      for (int i = 0; i < 4; i++) poly[i] = new Point(x, y);
      poly[0].translate(tx, ty);
      poly[1].translate(-tx, -ty);
      poly[2].translate(width, height);
      poly[2].translate(-tx, -ty);
      poly[3].translate(width, height);
      poly[3].translate(tx, ty);
      Polygon polygon = new Polygon();
      for (int i = 0; i < 4; i++) polygon.addPoint(poly[i].x, poly[i].y);
      g.fillPolygon(polygon);
    } else g.drawLine(x, y, x + width, y + height);
    g.setColor(saveColor);
  } // end draw
Exemplo n.º 13
0
  /**
   * This method exists for the following reason:
   *
   * <p>The segmenter receives at each frame a cropped image to operate on, depending on the user
   * specifying a ROI. It therefore returns spots whose coordinates are with respect to the top-left
   * corner of the ROI, not of the original image.
   *
   * <p>This method modifies the given spots to put them back in the image coordinate system.
   * Additionally, is a non-square ROI was specified (e.g. a polygon), it prunes the spots that are
   * not within the polygon of the ROI.
   *
   * @param spotsThisFrame the spot list to inspect
   * @param settings the {@link Settings} object that will be used to retrieve the image ROI and
   *     cropping information
   * @return a list of spot. Depending on the presence of a polygon ROI, it might be a new, pruned
   *     list. Or not.
   */
  protected List<Spot> translateAndPruneSpots(
      final List<Spot> spotsThisFrame, final Settings settings) {
    // Get Roi
    final Polygon polygon;
    if (null == settings.imp || null == settings.imp.getRoi()) {
      polygon = null;
    } else {
      polygon = settings.imp.getRoi().getPolygon();
    }

    // Put them back in the right referential
    final float[] calibration = settings.getCalibration();
    TMUtils.translateSpots(
        spotsThisFrame,
        settings.xstart * calibration[0],
        settings.ystart * calibration[1],
        settings.zstart * calibration[2]);
    List<Spot> prunedSpots;
    // Prune if outside of ROI
    if (null != polygon) {
      prunedSpots = new ArrayList<Spot>();
      for (Spot spot : spotsThisFrame) {
        if (polygon.contains(
            spot.getFeature(Spot.POSITION_X) / calibration[0],
            spot.getFeature(Spot.POSITION_Y) / calibration[1])) prunedSpots.add(spot);
      }
    } else {
      prunedSpots = spotsThisFrame;
    }
    return prunedSpots;
  }
Exemplo n.º 14
0
 public void printLoop(int n, float x[], float y[]) {
   // Need to swap the y component
   Polygon P = new Polygon();
   for (int i = 0; i < n; i++) P.addPoint(Math.round(x[i]), Math.round(height - y[i]));
   poly_draw.add(P);
   poly_draw_color.add(curColor);
 }
Exemplo n.º 15
0
 /** Draw the current map and pieces. */
 @Override
 protected void paintComponentMiddleLayer(
     final Graphics2D g2d, final int topLeftX, final int topLeftY) {
   g2d.setColor(Color.lightGray);
   // g2d.fillRect(0, 0, getWidth(), getHeight());
   g2d.fillRect(0, 0, m_model.getMaxWidth(), m_model.getMaxHeight());
   g2d.setColor(Color.white);
   g2d.fillRect(
       m_mapData.getBevelWidth(),
       m_mapData.getBevelHeight(),
       m_model.getMaxWidth() - (m_mapData.getBevelWidth() * 2),
       m_model.getMaxHeight() - (m_mapData.getBevelHeight() * 2));
   for (final Map.Entry<Territory, Polygon> entry :
       m_mapData.getTerritoryPolygons(m_gameData.getMap()).entrySet()) {
     final Polygon p = entry.getValue();
     final Territory at = entry.getKey();
     final Color backgroundColor = Color.WHITE;
     g2d.setColor(Color.black);
     final Image image = m_images.get(at);
     if (image != null) {
       final Rectangle square = p.getBounds();
       g2d.drawImage(
           image, square.x, square.y, square.width, square.height, backgroundColor, null);
     }
     g2d.drawPolygon(p);
   }
 }
Exemplo n.º 16
0
  /**
   * make new shape polygon
   *
   * @param p
   * @param polygon
   * @param intersectPoint
   */
  private Polygon reMakePolygonShape(Polygon p, Polygon polygon, List<Point2D> intersectPoint) {
    ConvexHull convexHull;

    List<Point> newPoints = new ArrayList<Point>();

    for (int j = 0; j < p.npoints; j++) {
      if (polygon.contains(p.xpoints[j], p.ypoints[j])) {
        newPoints.add(new Point(p.xpoints[j], p.ypoints[j]));
      }
    }

    for (Point2D point2D : intersectPoint) {
      newPoints.add(new Point((int) point2D.getX(), (int) point2D.getY()));
    }

    for (int i = 0; i < polygon.npoints; i++) {
      if (p.contains(polygon.xpoints[i], polygon.ypoints[i])) {
        Point point = new Point(polygon.xpoints[i], polygon.ypoints[i]);
        newPoints.add(point);
      }
    }

    convexHull = new ConvexHull();

    for (Point point : newPoints) {
      convexHull.addPoint((int) point.getX(), (int) point.getY());
    }

    Polygon polygon1 = convexHull.convex();
    //        newPoints.clear();

    return polygon1;
  }
Exemplo n.º 17
0
 /**
  * Draws a solid "filled-in" irregular polygon using between 3 and 12 sets of provided
  * coordinates. <br>
  * Examples: <br>
  * Expo.fillPolygon(g,100,300,200,100,300,300); // for a triangle
  * Expo.fillPolygon(g,525,300,600,250,650,250,725,300,725,350,650,400); // for a hexagon
  */
 public static void fillPolygon(Graphics g, int x1, int y1, int x2, int y2, int x3, int y3) {
   Polygon myPoly = new Polygon();
   myPoly.addPoint(x1, y1);
   myPoly.addPoint(x2, y2);
   myPoly.addPoint(x3, y3);
   g.fillPolygon(myPoly);
 }
Exemplo n.º 18
0
  public void drawMathObject(PolygonObject object, Graphics g, Point pageOrigin, float zoomLevel) {
    g.setColor(Color.BLACK);
    ScaledSizeAndPosition sap =
        getSizeAndPositionWithLineThickness(object, pageOrigin, zoomLevel, object.getThickness());

    Graphics2D g2d = (Graphics2D) g;

    g2d.setStroke(new BasicStroke(sap.getLineThickness()));

    Polygon p = new Polygon();

    GridPoint[] points = object.getAdjustedVertices();
    for (int i = 0; i < points.length; i++) {
      p.addPoint(
          (int) (points[i].getx() * sap.getWidth()) + sap.getxOrigin(),
          (int) (points[i].gety() * sap.getHeight()) + sap.getyOrigin());
    }

    if (object.getColor() != null) {
      g2d.setColor(object.getColor());
      g2d.fillPolygon(p);
      g2d.setColor(Color.BLACK);
    }

    g2d.drawPolygon(p);

    g2d.setStroke(new BasicStroke(1));
  }
Exemplo n.º 19
0
  private static void graph(Polygon[] finalPolygons) {
    int weiners = 0;
    String[] Starter = sPoint.split(",");
    String[] Ender = ePoint.split(",");
    int endx = Integer.parseInt(Ender[0]);
    int endy = Integer.parseInt(Ender[1]);
    int G = 40;
    for (int i = 0; i < G; i++) {
      for (int j = 0; j < G; j++) {
        int loketest = 0;
        if ((i == Startx && j == Starty) || i == endx && j == endy) {
          loketest = 2;
        }
        for (Polygon helpme : finalPolygons) {
          if (helpme.contains(i, j)) {
            loketest = 1;
          }
        }
        if (loketest == 1) {
          System.out.print("1");
        } else if (loketest == 2) {
          System.out.print("X");
        } else {
          System.out.print("0");
        }
      }

      System.out.println("     \t");
      weiners++;
    }
  }
Exemplo n.º 20
0
  public void drawConditionalSequenceFlowIndicator(Line2D.Double line) {
    int horizontal = (int) (CONDITIONAL_INDICATOR_WIDTH * 0.7);
    int halfOfHorizontal = horizontal / 2;
    int halfOfVertical = CONDITIONAL_INDICATOR_WIDTH / 2;

    Polygon conditionalIndicator = new Polygon();
    conditionalIndicator.addPoint(0, 0);
    conditionalIndicator.addPoint(-halfOfHorizontal, halfOfVertical);
    conditionalIndicator.addPoint(0, CONDITIONAL_INDICATOR_WIDTH);
    conditionalIndicator.addPoint(halfOfHorizontal, halfOfVertical);

    AffineTransform transformation = new AffineTransform();
    transformation.setToIdentity();
    double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1);
    transformation.translate(line.x1, line.y1);
    transformation.rotate((angle - Math.PI / 2d));

    AffineTransform originalTransformation = g.getTransform();
    g.setTransform(transformation);
    g.draw(conditionalIndicator);

    Paint originalPaint = g.getPaint();
    g.setPaint(CONDITIONAL_INDICATOR_COLOR);
    g.fill(conditionalIndicator);

    g.setPaint(originalPaint);
    g.setTransform(originalTransformation);
  }
Exemplo n.º 21
0
  private Polygon getPolygon(ShapeValue s, int w, int h) {

    Geometry g = s.getGeometry();
    Polygon ret = new Polygon();
    HashSet<String> points = new HashSet<String>();
    int sx = 0, sy = 0;
    for (Coordinate c : g.getBoundary().getCoordinates()) {

      int x = (int) ((double) w * (c.x + 180.0) / 360.0);
      int y = h - (int) ((double) h * (c.y + 90.0) / 180.0);

      if (!points.contains(x + "|" + y)) {

        if (ret.npoints == 0) {
          sx = x;
          sy = y;
        }

        ret.addPoint(x, y);
        points.add(x + "|" + y);
      }
    }

    /*
     * close polygon
     */
    if (ret.npoints > 0) {
      ret.addPoint(sx, sy);
    }

    return ret;
  }
Exemplo n.º 22
0
 public void drawSimpleShape(Graphics graphics) {
   graphics.setColor(spaceship.getColor());
   Polygon shape2 = new Polygon();
   float[][] shape = spaceship.getShape();
   for (int i = 4; i < 7; i++)
     shape2.addPoint((int) (shape[i][0] / 5), (int) (shape[i][1] / 5 + 480));
   graphics.fillPolygon(shape2);
 }
Exemplo n.º 23
0
 public void drawGateway(int x, int y, int width, int height) {
   Polygon rhombus = new Polygon();
   rhombus.addPoint(x, y + (height / 2));
   rhombus.addPoint(x + (width / 2), y + height);
   rhombus.addPoint(x + width, y + (height / 2));
   rhombus.addPoint(x + (width / 2), y);
   g.draw(rhombus);
 }
Exemplo n.º 24
0
 public void paint(Graphics g) {
   Polygon pt = at.transform(p);
   g.translate(xtranslate, ytranslate);
   g.drawPolygon(pt);
   for (int i = 0; i < pt.npoints; i++) g.drawString("p" + i, pt.xpoints[i], pt.ypoints[i]);
   Rectangle r = pt.getBounds();
   g.drawString("h=" + r.height + " w=" + r.width, r.height / 2, r.width / 2);
 }
 /** 绘制网关 */
 protected static void drawGateway(int x, int y, int width, int height, Graphics2D graphics) {
   Polygon rhombus = new Polygon();
   rhombus.addPoint(x, y + (height / 2));
   rhombus.addPoint(x + (width / 2), y + height);
   rhombus.addPoint(x + width, y + (height / 2));
   rhombus.addPoint(x + (width / 2), y);
   graphics.draw(rhombus);
 }
Exemplo n.º 26
0
 public static void drawPolygon(
     Graphics g, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
   Polygon myPoly = new Polygon();
   myPoly.addPoint(x1, y1);
   myPoly.addPoint(x2, y2);
   myPoly.addPoint(x3, y3);
   myPoly.addPoint(x4, y4);
   g.drawPolygon(myPoly);
 }
Exemplo n.º 27
0
 public void paintIcon(Component c, Graphics g, int x, int y) {
   int w = getIconWidth(), h = getIconHeight();
   g.setColor(Color.black);
   Polygon p = new Polygon();
   p.addPoint(x + 1, y + h / 2 + 1);
   p.addPoint(x + w, y);
   p.addPoint(x + w, y + h);
   g.fillPolygon(p);
 }
Exemplo n.º 28
0
  public void addArea(Vector<Point> points, ImageModel.Zone zone) {
    Polygon poly = new Polygon();

    for (Point p : points) {
      poly.addPoint(p.x, p.y);
    }

    this.addArea(new Area(poly), zone);
  }
Exemplo n.º 29
0
  private Polygon rectToPolygon(Rectangle r) {
    Polygon poly = new Polygon();

    poly.addPoint(r.x, r.y);
    poly.addPoint(r.x, r.y + r.height);
    poly.addPoint(r.x + r.width, r.y + r.height);
    poly.addPoint(r.x + r.width, r.y);

    return poly;
  }
Exemplo n.º 30
0
  /**
   * Cree un triangle.
   *
   * @param coordX coordonnee x du centre du triangle
   * @param coordY coordonnee y du centre du triangle
   * @param base taille de la base du triangle
   * @return polygone correspondant a un triangle
   */
  private Polygon creeTriangle(int coordX, int coordY, int base) {
    Polygon p = new Polygon();
    int hauteur = (int) (1.2 * base);

    p.addPoint(coordX - base / 2, coordY + hauteur / 2);
    p.addPoint(coordX + base / 2, coordY + hauteur / 2);
    p.addPoint(coordX, coordY - hauteur / 2);

    return p;
  }