Examples of Polygon2D


Examples of de.hpi.eworld.gui.util.Polygon2D

   * updates all the cached values
   *
   * @param state
   */
  private void updateCache(mxCellState state) {
    Polygon2D polygon = getParent().getBasicShape();
    Rectangle2D boundsOnGraph = getParent().canvasBounds(state);

    offset = new Point2D.Double(boundsOnGraph.getX() - polygon.getBounds2D().getMinX(), boundsOnGraph.getY()
        - polygon.getBounds2D().getMinY());

    scaledPolygon = getParent().getScaledShape();
  }
View Full Code Here

Examples of diva.util.java2d.Polygon2D

        FigureLayer layer = graphicsPane.getForegroundLayer();

        // Create the graphic
        PaintedList graphic = new PaintedList();

        Polygon2D polygon = new Polygon2D.Double();
        polygon.moveTo(30, 50);
        polygon.lineTo(70, 80);
        polygon.lineTo(70, 20);
        graphic.add(new PaintedShape(polygon, Color.red, 1.0f));

        Line2D line1 = new Line2D.Double(10, 50, 30, 50);
        graphic.add(new PaintedPath(line1));
View Full Code Here

Examples of diva.util.java2d.Polygon2D

            PaintedShape ps = new PaintedShape(new Ellipse2D.Double(coords[0],
                    coords[1], coords[2], coords[3]));
            processPaintedShapeAttributes(ps, attributes);
            return ps;
        } else if (type.equals("polygon")) {
            Polygon2D poly = new Polygon2D.Double();
            poly.moveTo(coords[0], coords[1]);

            for (int i = 2; i < coords.length; i += 2) {
                poly.lineTo(coords[i], coords[i + 1]);
            }

            poly.closePath();

            PaintedShape ps = new PaintedShape(poly);
            processPaintedShapeAttributes(ps, attributes);
            return ps;
        } else if (type.equals("line")) {
            Shape s;

            if (coords.length == 4) {
                s = new Line2D.Double(coords[0], coords[1], coords[2],
                        coords[3]);
            } else {
                Polyline2D poly = new Polyline2D.Double();
                poly.moveTo(coords[0], coords[1]);

                for (int i = 2; i < coords.length; i += 2) {
                    poly.lineTo(coords[i], coords[i + 1]);
                }

                s = poly;
            }
View Full Code Here

Examples of diva.util.java2d.Polygon2D

            PaintedShape ps = new PaintedShape(new Ellipse2D.Double(coords[0],
                    coords[1], coords[2], coords[3]));
            processPaintedShapeAttributes(ps, attributes);
            return ps;
        } else if (type.equals("polygon")) {
            Polygon2D poly = new Polygon2D.Double();
            poly.moveTo(coords[0], coords[1]);

            for (int i = 2; i < coords.length; i += 2) {
                poly.lineTo(coords[i], coords[i + 1]);
            }

            poly.closePath();

            PaintedShape ps = new PaintedShape(poly);
            processPaintedShapeAttributes(ps, attributes);
            return ps;
        } else if (type.equals("line")) {
            Shape s;

            if (coords.length == 4) {
                s = new Line2D.Double(coords[0], coords[1], coords[2],
                        coords[3]);
            } else {
                Polyline2D poly = new Polyline2D.Double();
                poly.moveTo(coords[0], coords[1]);

                for (int i = 2; i < coords.length; i += 2) {
                    poly.lineTo(coords[i], coords[i + 1]);
                }

                s = poly;
            }
View Full Code Here

Examples of diva.util.java2d.Polygon2D

            }

            xout = x + rx + dx;
            yout = y + ry + dy;
        } else if (shape instanceof Polygon2D) {
            Polygon2D polygon = (Polygon2D) shape;
            double pointx = xCenter;
            double pointy = yCenter;
            double max_r = 0;
            int vertexes = polygon.getVertexCount();

            if (vertexes > 1) {
                // compute the intersection of the line segment passing through
                // (x0,y0) and (x1,y1) with the ray passing through
                // (xCenter, yCenter) and (px,py)
                double x0;

                // compute the intersection of the line segment passing through
                // (x0,y0) and (x1,y1) with the ray passing through
                // (xCenter, yCenter) and (px,py)
                double x1;

                // compute the intersection of the line segment passing through
                // (x0,y0) and (x1,y1) with the ray passing through
                // (xCenter, yCenter) and (px,py)
                double y0;

                // compute the intersection of the line segment passing through
                // (x0,y0) and (x1,y1) with the ray passing through
                // (xCenter, yCenter) and (px,py)
                double y1;
                double px = xCenter + Math.cos(alpha);
                double py = yCenter + Math.sin(alpha);

                // Assume the polygon is closed, so do the "closing stroke"
                // first
                x1 = polygon.getX(vertexes - 1);
                y1 = polygon.getY(vertexes - 1);

                for (int vertexPair = 0; vertexPair < vertexes; vertexPair++) {
                    x0 = x1;
                    y0 = y1;
                    x1 = polygon.getX(vertexPair);
                    y1 = polygon.getY(vertexPair);

                    double A = ((x0 - xCenter) * (py - yCenter))
                            - ((y0 - yCenter) * (px - xCenter));
                    double B = ((y1 - y0) * (px - xCenter))
                            - ((x1 - x0) * (py - yCenter));
View Full Code Here

Examples of diva.util.java2d.Polygon2D

                    2 * _unit, 2 * _unit);
            break;

        case BLOB_DIAMOND:

            Polygon2D polygon = new Polygon2D.Float();
            polygon.moveTo(_originX, _originY);
            polygon.lineTo(_originX + (1.5 * _unit), _originY - _unit);
            polygon.lineTo(_originX + (3.0 * _unit), _originY);
            polygon.lineTo(_originX + (1.5 * _unit), _originY + _unit);
            polygon.lineTo(_originX, _originY);
            polygon.closePath();
            _shape = polygon;
            break;
        }

        _shape = at.createTransformedShape(_shape);
View Full Code Here

Examples of diva.util.java2d.Polygon2D

        public Figure createFigure() {
            // Create the graphic
            PaintedList graphic = new PaintedList();

            Polygon2D polygon = new Polygon2D.Double();
            polygon.moveTo(30, 50);
            polygon.lineTo(70, 80);
            polygon.lineTo(70, 20);
            graphic.add(new PaintedShape(polygon, Color.red, 1.0f));

            Line2D line1 = new Line2D.Double(10, 50, 30, 50);
            graphic.add(new PaintedPath(line1));
View Full Code Here

Examples of eas.math.geometry.Polygon2D

    @Override
    public Vector2D getRealPosFromScreenPos(Vector2D screenPos) {
        Vector2D pos = new Vector2D(screenPos.x, screenPos.y);
        Rectangle2D box = env.getCurrentViewBox();
       
        Polygon2D pinkBorder = env.getPinkBorder();
       
        pos.sub(new Vector2D(
                pinkBorder.getBoundingBox().upperLeftCorner().x,
                pinkBorder.getBoundingBox().upperLeftCorner().y));
       
        pos.x = pos.x / env.globalScale();
        pos.y = pos.y / env.globalScale();
       
        pos.translate(box.upperLeftCorner());
View Full Code Here

Examples of eas.math.geometry.Polygon2D

  public static final double radius = 2;

  @Override
  public synchronized Polygon2D getAgentShape() {
    if (pacman == null) {
      pacman = new Polygon2D();

      for (double d = 0; d < Math.PI * 1.75; d += Math.PI * 2 / precision) {
        pacman.add(new Vector2D(Math.sin(d) * radius, Math.cos(d) * radius));
      }
      pacman.add(new Vector2D(0, 0));
View Full Code Here

Examples of eas.math.geometry.Polygon2D

     * @return Returns the eckPunkte.
     */
    @Override
    public Polygon2D getAgentShape() {
        if (pol == null) {
            pol = new Polygon2D();
            pol.add(new Vector2D(-this.ausd.x / 2, -this.ausd.y / 2));
            pol.add(new Vector2D(+this.ausd.x / 2, -this.ausd.y / 2));
            pol.add(new Vector2D(+this.ausd.x / 2, +this.ausd.y / 2));
            pol.add(new Vector2D(-this.ausd.x / 2, +this.ausd.y / 2));
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.