Examples of Path2D


Examples of java.awt.geom.Path2D


  @Override@Test
  public void testUpdateGeneralPathMiddle() {
    ISquaredShape model = getShape();
    Path2D path;
    PathIterator pi;
    double[] coords = new double[6];
    final double thickness = 3.;
    List<Double> xs = new ArrayList<>();
    List<Double> ys = new ArrayList<>();
    double width = 100;

    model.setPosition(-10, 20);
    model.setWidth(width);
    model.setThickness(thickness);
    model.setBordersPosition(BorderPos.MID);
    view.update();
    path = view.getPath();

    pi = path.getPathIterator(null);
    assertEquals(PathIterator.SEG_MOVETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
View Full Code Here

Examples of java.awt.geom.Path2D


  @Override@Test
  public void testUpdateGeneralPathOutside() {
    ISquaredShape model = getShape();
    Path2D path;
    PathIterator pi;
    double[] coords = new double[6];
    final double thickness = 3.;
    List<Double> xs = new ArrayList<>();
    List<Double> ys = new ArrayList<>();
    double width = 100;

    model.setPosition(-10, 20);
    model.setWidth(width);
    model.setThickness(thickness);
    model.setBordersPosition(BorderPos.OUT);
    view.update();
    path = view.getPath();

    pi = path.getPathIterator(null);
    assertEquals(PathIterator.SEG_MOVETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
View Full Code Here

Examples of java.awt.geom.Path2D

      return false;

    final double rotationAngle = shape.getRotationAngle();
    final boolean intersects;

    final Path2D pa;

    if(shape.getAxesStyle()==AxesStyle.NONE)
      pa = new Path2D.Double(new Rectangle2D.Double(shape.getPosition().getX(), shape.getPosition().getY(), 2, 2));
    else pa = new Path2D.Double(path);

    if(shape.getTicksDisplayed()!=PlottingStyle.NONE)
      pa.append(pathTicks, false);

    if(shape.getLabelsDisplayed()!=PlottingStyle.NONE)
      pa.append(pathLabels, false);

    if(LNumber.equalsDouble(rotationAngle, 0.)) {
      intersects = pa.intersects(r);
    }
    else {
      final IPoint tl   = shape.getTopLeftPoint();
      final IPoint br   = shape.getBottomRightPoint();
      final double cx   = (tl.getX()+br.getX())/2.;
View Full Code Here

Examples of java.awt.geom.Path2D

    if (this.radius >= DistanceUtils.HALF_EARTH_CIRCUMFERENCE) {
      return new Rectangle2D.Double(0.0, 0.0, 360.0, 180.0);
    }
    int numberOfCrossOvers = 0;

    Path2D path = new Path2D.Double();
    LatLon initPT = DistanceUtils.getPointOnGreatCircle(this.center.getLat(),
        this.center.getLon(), this.radius, 0);
    path.moveTo(initPT.getShiftedLon(), initPT.getShiftedLat());

    LatLon currPT = initPT;
    for (int i = 1; i < 360; i++) {

      LatLon pt = DistanceUtils.getPointOnGreatCircle(this.center.getLat(),
          this.center.getLon(), this.radius, i);
      path.lineTo(pt.getShiftedLon(), pt.getShiftedLat());

      if (dateLineCrossOver(currPT.getNormLon(), pt.getNormLon())) {
        numberOfCrossOvers++;
      }
      currPT = pt;
    }
    if (dateLineCrossOver(initPT.getNormLon(), currPT.getNormLon())) {
      numberOfCrossOvers++;
    }

    /**
     * If the path crosses the dateline once, it's a special case, so take care
     * of it differently. It will need to include areas around the pole.
     */
    if (numberOfCrossOvers == 1) {
      Rectangle2D r = path.getBounds2D();
      Rectangle2D lowerHalf = new Rectangle2D.Double(0.0, 0.0, 360.0, r
          .getMaxY());
      if (lowerHalf.contains(this.center.getShiftedLon(), this.center
          .getShiftedLat())) {
        return lowerHalf;
      } else {
        return new Rectangle2D.Double(0.0, r.getMinY(), 360.0, 180.0 - r
            .getMinY());
      }
    }

    if (path.contains(this.center.getShiftedLon(), this.center.getShiftedLat())) {
      Rectangle2D r = path.getBounds2D();
      if ((r.getMaxX() - r.getMinX()) > 359.0) {
        return new Rectangle2D.Double(0.0, 0.0, 360.0, 180.0);
      } else if (r.getMinX() < 0 || r.getMaxX() > 360.0) {
        /**
         * For circles that crosses the dateline instead of splitting in half
         * and having to go down the tree twice, for first version span
         * longitude 360.0 and use the exact height of the box
         */
        return new Rectangle2D.Double(0.0, r.getY(), 360.0, r.getHeight());
      } else {
        return path.getBounds2D();
      }
    } else {
      Area pathArea = new Area(path);
      Area wholeMap = new Area(new Rectangle2D.Double(0.0, 0.0, 360.0, 180.0));
      wholeMap.subtract(pathArea);
View Full Code Here

Examples of java.awt.geom.Path2D

    if (super.getOrdinate(2) >= DistanceUtils.HALF_EARTH_CIRCUMFERENCE) {
      return new Rectangle2D.Double(0.0, 0.0, 360.0, 180.0);
    }
    int numberOfCrossOvers = 0;

    Path2D path = new Path2D.Double();
    LatLon initPT = DistanceUtils.getPointOnGreatCircle(super.getOrdinate(1),
        super.getOrdinate(0), super.getOrdinate(2), 0);
    path.moveTo(initPT.getShiftedLon(), initPT.getShiftedLat());

    LatLon currPT = initPT;
    for (int i = 1; i < 360; i++) {

      LatLon pt = DistanceUtils.getPointOnGreatCircle(super.getOrdinate(1),
          super.getOrdinate(0), super.getOrdinate(2), i);
      path.lineTo(pt.getShiftedLon(), pt.getShiftedLat());

      if (dateLineCrossOver(currPT.getNormLon(), pt.getNormLon())) {
        numberOfCrossOvers++;
      }
      currPT = pt;
    }
    if (dateLineCrossOver(initPT.getNormLon(), currPT.getNormLon())) {
      numberOfCrossOvers++;
    }

    /**
     * If the path crosses the dateline once, it's a special case, so take care
     * of it differently. It will need to include areas around the pole.
     */
    if (numberOfCrossOvers == 1) {
      Rectangle2D r = path.getBounds2D();
      Rectangle2D lowerHalf = new Rectangle2D.Double(0.0, 0.0, 360.0, r
          .getMaxY());
      if (lowerHalf.contains(super.getOrdinate(0) + 180, super.getOrdinate(1) + 90)) {
        return lowerHalf;
      } else {
        return new Rectangle2D.Double(0.0, r.getMinY(), 360.0, 180.0 - r
            .getMinY());
      }
    }

    if (path.contains(super.getOrdinate(0) + 180, super.getOrdinate(1) + 90)) {
      Rectangle2D r = path.getBounds2D();
      if ((r.getMaxX() - r.getMinX()) > 359.0) {
        return new Rectangle2D.Double(0.0, 0.0, 360.0, 180.0);
      } else if (r.getMinX() < 0 || r.getMaxX() > 360.0) {
        /**
         * For circles that crosses the dateline instead of splitting in half
         * and having to go down the tree twice, for first version span
         * longitude 360.0 and use the exact height of the box
         */
        return new Rectangle2D.Double(0.0, r.getY(), 360.0, r.getHeight());
      } else {
        return path.getBounds2D();
      }
    } else {
      Area pathArea = new Area(path);
      Area wholeMap = new Area(new Rectangle2D.Double(0.0, 0.0, 360.0, 180.0));
      wholeMap.subtract(pathArea);
View Full Code Here

Examples of java.awt.geom.Path2D

                }
                else {
                    Graphics g2 = g.create();
                    if (g2 instanceof Graphics2D) {
                        Graphics2D g2d = (Graphics2D) g2;
                        Path2D path = new Path2D.Float();
                        path.append(new Rectangle(borderX, borderY, borderW, labelY - borderY), false);
                        path.append(new Rectangle(borderX, labelY, labelX - borderX - TEXT_SPACING, labelH), false);
                        path.append(new Rectangle(labelX + labelW + TEXT_SPACING, labelY, borderX - labelX + borderW - labelW - TEXT_SPACING, labelH), false);
                        path.append(new Rectangle(borderX, labelY + labelH, borderW, borderY - labelY + borderH - labelH), false);
                        g2d.clip(path);
                    }
                    border.paintBorder(c, g2, borderX, borderY, borderW, borderH);
                    g2.dispose();
                }
View Full Code Here

Examples of java.awt.geom.Path2D

    }

    @Override
    public void draw(Context2d context) {
        String file = getEnvObject().getCurrentRepresentation().getIcon();
        Path2D objectPath = DrawingUtils.freedomPolygonToPath((FreedomPolygon) getEnvObject().getCurrentRepresentation().getShape());
        Rectangle2D box = objectPath.getBounds2D();
        objectBounds = objectPath.getBounds();

        rotation = getEnvObject().getCurrentRepresentation().getRotation();
        dx = getEnvObject().getCurrentRepresentation().getOffset().getX();
        dy = getEnvObject().getCurrentRepresentation().getOffset().getY();
        context.translate(dx, dy);
View Full Code Here

Examples of java.awt.geom.Path2D

public class DrawingUtils {

    //Helper class to transform from a FreedomPolygon to a Path
    public static Path2D freedomPolygonToPath(FreedomPolygon fp) {
        Path2D mP = new Path2D.Double();
        for (int j = 0; j < fp.getPoints().size(); j++) {
            FreedomPoint point = fp.getPoints().get(j);
            if (j == 0) {
                mP.moveTo(point.getX(), point.getY());
            } else {
                mP.lineTo(point.getX(), point.getY());
            }
        }
        //closing the path
        mP.closePath();

        return mP;
    }
View Full Code Here

Examples of java.awt.geom.Path2D

    }

    public void fitArea() {
        Zone room = dr.getRoomObject();
        FreedomPolygon poly = room.getShape();
        Path2D envPath = new Path2D.Double();
        envPath = DrawingUtils.freedomPolygonToPath(poly);
        Rectangle2D bounds = envPath.getBounds2D();
        xScale = (CANVAS_WIDTH - (BORDER_X * 4)) / bounds.getWidth();
        yScale = (CANVAS_HEIGHT - (BORDER_Y * 4)) / bounds.getHeight();
        if (xScale < yScale) {
            yScale = xScale;
        } else {
View Full Code Here

Examples of java.awt.geom.Path2D

  }

  @Override
  public void draw(Context2d context) {   
    String file = getEnvObject().getCurrentRepresentation().getIcon();
    Path2D objectPath = DrawingUtils.freedomPolygonToPath((FreedomPolygon)getEnvObject().getCurrentRepresentation().getShape());
    Rectangle2D box = objectPath.getBounds2D();
    objectBounds=objectPath.getBounds();
           
    rotation =  getEnvObject().getCurrentRepresentation().getRotation();
    dx =getEnvObject().getCurrentRepresentation().getOffset().getX();
    dy = getEnvObject().getCurrentRepresentation().getOffset().getY();   
    context.translate(dx,dy);   
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.