コード例 #1
0
  /**
   * Builds the circular shape and returns the result as an array of <code>Area</code>. Each <code>
   * Area</code> is one of the bars composing the shape.
   */
  private Area[] buildTicker() {
    width = this.getPreferredSize().getWidth();
    height = this.getPreferredSize().getHeight();

    Area[] ticker = new Area[barsCount];
    Point2D.Double center = new Point2D.Double((double) width / 2, (double) height / 2);
    double fixedAngle = 2.0 * Math.PI / ((double) barsCount);

    for (double i = 0.0; i < (double) barsCount; i++) {
      Area primitive = buildPrimitive();

      AffineTransform toCenter = AffineTransform.getTranslateInstance(center.getX(), center.getY());
      AffineTransform toBorder = AffineTransform.getTranslateInstance(45.0 / 8, -6.0 / 8);
      AffineTransform toCircle =
          AffineTransform.getRotateInstance(-i * fixedAngle, center.getX(), center.getY());

      AffineTransform toWheel = new AffineTransform();
      toWheel.concatenate(toCenter);
      toWheel.concatenate(toBorder);

      primitive.transform(toWheel);
      primitive.transform(toCircle);

      ticker[(int) i] = primitive;
    }

    return ticker;
  }
コード例 #2
0
ファイル: PlotImage.java プロジェクト: duncanchild/geocraft
 /**
  * Constructs a plot image.
  *
  * @param image the actual image.
  * @param text the image name.
  * @param corner1 the 1st corner point.
  * @param corner2 the 2nd corner point.
  */
 public PlotImage(
     final Image image,
     final String text,
     final Point2D.Double corner1,
     final Point2D.Double corner2,
     final Point2D.Double corner3,
     final Point2D.Double corner4) {
   super(ShapeType.IMAGE, text);
   setImage(image);
   setAnchorType(ImageAnchor.Center);
   setFixedSize(false);
   _points.add(new PlotPoint(corner1.getX(), corner1.getY(), 0));
   _points.add(new PlotPoint(corner2.getX(), corner2.getY(), 0));
   _points.add(new PlotPoint(corner3.getX(), corner3.getY(), 0));
   _points.add(new PlotPoint(corner4.getX(), corner4.getY(), 0));
   _xmin = Math.min(corner1.x, corner2.x);
   _xmin = Math.min(corner3.x, _xmin);
   _xmin = Math.min(corner4.x, _xmin);
   _xmax = Math.max(corner1.x, corner2.x);
   _xmax = Math.max(corner3.x, _xmax);
   _xmax = Math.max(corner4.x, _xmax);
   _ymin = Math.min(corner1.y, corner2.y);
   _ymin = Math.min(corner3.y, _ymin);
   _ymin = Math.min(corner4.y, _ymin);
   _ymax = Math.max(corner1.y, corner2.y);
   _ymax = Math.max(corner3.y, _ymax);
   _ymax = Math.max(corner4.y, _ymax);
 }
コード例 #3
0
ファイル: JGeoPane.java プロジェクト: cbsistem/PlatypusJS
  /**
   * Fits screen to specified geometry bounds.
   *
   * @param aArea A geometry in geo coordinates space.
   * @throws Exception
   */
  public void fit(Geometry aArea) throws Exception {

    Geometry bounds = aArea.getBoundary();
    Envelope envBounds = bounds.getEnvelopeInternal();
    Point2D.Double leftUpCorner = new Point2D.Double(envBounds.getMinX(), envBounds.getMinY());
    Point2D.Double rightBottomCorner = new Point2D.Double(envBounds.getMaxX(), envBounds.getMaxY());
    Point2D.Double cartlu = geo2Cartesian(leftUpCorner);
    Point2D.Double cartrb = geo2Cartesian(rightBottomCorner);
    double destWidth = Math.abs(cartrb.getX() - cartlu.getX());
    double destHeight = Math.abs(cartrb.getY() - cartlu.getY());
    Coordinate centre =
        new Coordinate((cartrb.getX() + cartlu.getX()) / 2, (cartrb.getY() + cartlu.getY()) / 2);

    Dimension size = getSize();
    Point2D.Double screenLT = awtScreen2Cartesian(new Point(0, 0));
    Point2D.Double screenBR = awtScreen2Cartesian(new Point(size.width, size.height));

    double srcWidth = screenBR.x - screenLT.x;
    double srcHeight = screenBR.y - screenLT.y;
    double sx = srcWidth / destWidth;
    double sy = srcHeight / destHeight;
    double coef = Math.min(sx, sy);
    coef = snapScale(coef);
    scaleView(coef, coef, false);

    Point2D.Double projectedScreenCenter = screen2Cartesian(new Point(0, 0));
    translateView(projectedScreenCenter.x - centre.x, projectedScreenCenter.y - centre.y, true);
    repaint();
  }
コード例 #4
0
ファイル: JGeoPane.java プロジェクト: cbsistem/PlatypusJS
 /**
  * Ajusts view point according to tiles grid offset. E.g. converts grid offset to view point
  * offset. Clears grid offset. Doesn't clear any caches or repaint.
  *
  * @throws NoninvertibleTransformException
  */
 protected void recalcViewPoint() throws NoninvertibleTransformException {
   Point2D.Double screenCenterOnCartesian = screen2Cartesian(new Point(0, 0));
   Point2D.Double screenViewpointOnCartesian = screen2Cartesian(new Point(-offset.x, -offset.y));
   cartesian2Screen.translate(
       screenViewpointOnCartesian.getX() - screenCenterOnCartesian.getX(),
       screenViewpointOnCartesian.getY() - screenCenterOnCartesian.getY());
   clearGridTranslating();
 }
コード例 #5
0
  public static Point2D.Double pointBetween(Point2D.Double p, Point2D.Double p2, double pos) {

    Point2D.Double n =
        new Point2D.Double(
            p.getX() * (1 - pos) + p2.getX() * (pos), p.getY() * (1 - pos) + p2.getY() * (pos));

    return n;
  }
コード例 #6
0
  /** Checks if we are close to a wall and reverse the tank */
  public double avoidWalls(Point2D.Double myPos) {
    double reverse = 0;

    if (myPos.getX() > 720 || myPos.getX() < 80 || myPos.getY() > 520 || myPos.getY() < 80) {
      reverse = -1000;
    }
    return reverse;
  }
コード例 #7
0
 /**
  * Method to convert a Cartesian Point from a point in a normal GridMap, to a visual location on
  * the display
  *
  * @param cartPos Cartesian point from the original map to convert
  * @return Location given as a display point in the pane
  */
 public Point2D.Double getVisualLoc(Point2D.Double pos) {
   /* turn cartesian points into valid units by turning them into digits-multiply by 100
   and by multiplying by the scale factor*/
   int x = (int) (pos.getX() * 100 * scaleFactor);
   int y = (int) (pos.getY() * 100 * scaleFactor);
   // visual location is returned, relative to the display centre. x and y values are inverted so
   // they are displayed correctly
   return new Point2D.Double(displayCentre.getX() + x, displayCentre.getY() - y);
 }
コード例 #8
0
ファイル: L_shape.java プロジェクト: ashley3/Tetris
public class L_shape extends Shape {
  static Point2D.Double center = new Point2D.Double(7, 0);
  static Point2D.Double[] coords = {
    (new Point2D.Double(center.getX() - 1, center.getY())),
    (new Point2D.Double(center.getX(), center.getY())),
    (new Point2D.Double(center.getX() + 1, center.getY())),
    (new Point2D.Double(center.getX() - 1, center.getY() + 1))
  };
  static Color color = Color.orange;
  int rotation = 0;

  public L_shape() {
    super(coords, color, false);
  }

  public void rotate() {
    if (rotation == 0) {
      if (super.blocks[0].canMove(1, -1)
          && super.blocks[2].canMove(-1, 1)
          && super.blocks[3].canMove(0, -2)) {
        super.blocks[0].move(1, -1);
        super.blocks[2].move(-1, 1);
        super.blocks[3].move(0, -2);
      }
      rotation++;
    } else if (rotation == 1) {
      if (super.blocks[0].canMove(1, 1)
          && super.blocks[2].canMove(-1, -1)
          && super.blocks[3].canMove(2, 0)) {
        super.blocks[0].move(1, 1);
        super.blocks[2].move(-1, -1);
        super.blocks[3].move(2, 0);
      }
      rotation++;
    } else if (rotation == 2) {
      if (super.blocks[0].canMove(-1, 1)
          && super.blocks[2].canMove(1, -1)
          && super.blocks[3].canMove(0, 2)) {
        super.blocks[0].move(-1, 1);
        super.blocks[2].move(1, -1);
        super.blocks[3].move(0, 2);
      }
      rotation++;
    } else if (rotation == 3) {
      if (super.blocks[0].canMove(-1, -1)
          && super.blocks[2].canMove(1, 1)
          && super.blocks[3].canMove(-2, 0)) {
        super.blocks[0].move(-1, -1);
        super.blocks[2].move(1, 1);
        super.blocks[3].move(-2, 0);
      }
      rotation = 0;
    }
  }
}
コード例 #9
0
ファイル: PanTool.java プロジェクト: Seandebasti/Flox
 /**
  * The mouse location changed during a drag, while this MapTool was the active tool.
  *
  * @param point The location of the mouse in world coordinates.
  * @param evt The original event.
  */
 @Override
 public void updateDrag(Point2D.Double point, MouseEvent evt) {
   // just in case we didn't get a mousePressed event
   if (dragStartPos == null) {
     dragStartPos = (Point2D.Double) point.clone();
   } else {
     double dx = dragStartPos.getX() - point.getX();
     double dy = dragStartPos.getY() - point.getY();
     mapComponent.offsetVisibleArea(dx, dy);
   }
 }
コード例 #10
0
ファイル: GiftWrapping.java プロジェクト: Absor/convexhull
 // Finds the point with minimum x coordinate.
 private Point2D.Double findMinX(LinkedList points) {
   Point2D.Double minXPoint = null;
   LinkedListNode node = points.getHead();
   while (node != null) {
     Point2D.Double point = node.getPoint();
     if (minXPoint == null || point.getX() < minXPoint.getX()) {
       minXPoint = point;
     }
     node = node.getNext();
   }
   return minXPoint;
 }
コード例 #11
0
 public static Shape makeStarDesign(int arms, Point center, double r_out, double r_in) {
   double angle = Math.PI / arms;
   GeneralPath path = new GeneralPath();
   for (int i = 0; i < 2 * arms; i++) {
     double r = (i & 1) == 0 ? r_out : r_in;
     Point2D.Double p =
         new Point2D.Double(
             center.x + Math.cos(i * angle) * r, center.y + Math.sin(i * angle) * r);
     if (i == 0) path.moveTo(p.getX(), p.getY());
     else path.lineTo(p.getX(), p.getY());
   }
   path.closePath();
   return path;
 }
コード例 #12
0
  public double getDistance(Vector<VivaeObject> objects) {
    GeneralPath thisPath = new GeneralPath(this.getTransformedShape());
    PathIntersection pi = new PathIntersection();
    Point2D.Double[] points;
    double dist = ray_length;
    double nd;
    for (VivaeObject vivaeObject : objects) {
      if (vivaeObject != this.owner) {
        GeneralPath gp = new GeneralPath(vivaeObject.getTransformedShape());
        points = pi.getIntersections(thisPath, gp);
        for (Point2D.Double point : points) {
          nd = pi.euclideanDistance(point.getX(), point.getY(), owner.getX(), owner.getY());
          if (nd < dist) {
            dist = nd;
          }
          // System.out.println(dist);
        }
      }
    }

    opacity = Math.max((float) (1d - (dist / ray_length)), opacity);
    opacityOfRay = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity);

    return 1d - (dist / ray_length);
  }
コード例 #13
0
ファイル: MapPanel.java プロジェクト: TimJin/map
 public void zoomToGarminGeo(double factor, int longitude, int latitude) {
   Point2D.Double mapCoord = new Point2D.Double();
   COORD tempCoord = transformer.createTempCoord();
   transformer.wgs84ToMap(
       CoordUtils.toWGS84Rad(longitude), CoordUtils.toWGS84Rad(latitude), tempCoord, mapCoord);
   zoom(factor, (int) mapCoord.getX(), (int) mapCoord.getY());
 }
コード例 #14
0
ファイル: MyController.java プロジェクト: spiffy46/CS355-Lab3
  @Override
  public void zoomOutButtonHit() {
    if (zoomLevel < 5) {
      zoomLevel++;

      double x = viewPoint.getX() + viewWidth / 2;
      double y = viewPoint.getY() + viewWidth / 2;
      viewWidth = viewWidth * 2;
      x = x - viewWidth / 2;
      y = y - viewWidth / 2;

      if (x < 0) {
        x = 0;
      } else if (x + viewWidth > 2048) {
        x = x - (x + viewWidth - 2048);
      }
      if (y < 0) {
        y = 0;
      } else if (y + viewWidth > 2048) {
        y = y - (y + viewWidth - 2048);
      }

      viewPoint.setLocation(x, y);

      setChanged();
      notifyObservers();
    }
  }
コード例 #15
0
  private synchronized void initBars() {
    if (bars != null) {
      return;
    }

    bars = new Area[BAR_COUNT];

    final double fixedAngle = 2.0 * Math.PI / (double) bars.length;
    for (int i = 0; i < bars.length; ++i) {
      Area primitive = makeBar();

      Point2D.Double center = new Point2D.Double((double) DIAMETER / 2, (double) DIAMETER / 2);
      AffineTransform toCircle =
          AffineTransform.getRotateInstance(
              ((double) -i) * fixedAngle, center.getX(), center.getY());
      AffineTransform toBorder = AffineTransform.getTranslateInstance(45.0, -6.0);

      AffineTransform toScale = AffineTransform.getScaleInstance(0.1, 0.1);

      primitive.transform(toBorder);
      primitive.transform(toCircle);
      primitive.transform(toScale);

      bars[i] = primitive;
    }
  }
コード例 #16
0
ファイル: BunnyController.java プロジェクト: neduard/sepr4bar
  protected void updateMovement() {
    Point2D.Double newLocation;
    double acceleration = computeAcceleration();

    speed += acceleration;
    if ((speed > -1) && speed < 0) {
      speed = 0;
    } // just a cheat for stabilising the speed if it's close to 0

    if (speed >= 0) {
      tempOrientation = orientation;
      newLocation = updateXY(orientation);
    } else {
      newLocation =
          updateXY(
              direction); // if speed is <0, that means the bunny is spinning and its direction is
                          // different from orientation
      spin();
    }

    // to check if intersectig with something - be that bounds or components
    newLocation = checkIntersects(newLocation);

    // let the bunny rotate if it was trying to (i.e. if arrows were pressed)
    rotate();

    // give the new newLocation to the bunny
    x = newLocation.getX();
    y = newLocation.getY();
  }
コード例 #17
0
ファイル: MyController.java プロジェクト: spiffy46/CS355-Lab3
 @Override
 public void vScrollbarChanged(int value) {
   if (value != viewPoint.getY()) {
     viewPoint.setLocation(viewPoint.getX(), value);
     setChanged();
     notifyObservers();
   }
 }
コード例 #18
0
 void calcPos(AffineTransform w2n) {
   w2n.transform(worldPos, screenPos); // work in normalized coordinate space
   bbPos.setRect(
       screenPos.getX() + bb.getX(),
       screenPos.getY() + bb.getY(),
       bb.getWidth(),
       bb.getHeight());
 }
コード例 #19
0
ファイル: PlotImage.java プロジェクト: duncanchild/geocraft
 public Rectangle getRectangle(final IModelSpaceCanvas canvas) {
   Rectangle rect = _image.getBounds();
   int w = rect.x;
   int h = rect.y;
   int numPoints = getPointCount();
   if (numPoints == 1) {
     ImageAnchor anchor = getAnchorType();
     Point2D.Double m = new Point2D.Double(getPoint(0).getX(), getPoint(0).getY());
     Point2D.Double p = new Point2D.Double(0, 0);
     canvas.transformModelToPixel(getModelSpace(), m.getX(), m.getY(), p);
     if (anchor.equals(ImageAnchor.Center)) {
       rect = new Rectangle((int) (p.x - w / 2), (int) (p.y - h / 2), w, h);
     } else if (anchor.equals(ImageAnchor.UpperLeft)) {
       rect = new Rectangle((int) p.x, (int) p.y, w, h);
     } else if (anchor.equals(ImageAnchor.UpperRight)) {
       rect = new Rectangle((int) (p.x - w), (int) p.y, w, h);
     } else if (anchor.equals(ImageAnchor.LowerLeft)) {
       rect = new Rectangle((int) p.x, (int) (p.y - h), w, h);
     } else if (anchor.equals(ImageAnchor.LowerRight)) {
       rect = new Rectangle((int) (p.x - w), (int) (p.y - h), w, h);
     } else {
       throw new RuntimeException("Invalid image anchor: " + anchor);
     }
   } else if (numPoints >= 2) {
     int xmin = Integer.MAX_VALUE;
     int xmax = -Integer.MAX_VALUE;
     int ymin = Integer.MAX_VALUE;
     int ymax = -Integer.MAX_VALUE;
     for (int i = 0; i < numPoints; i++) {
       Point2D.Double m = new Point2D.Double(getPoint(i).getX(), getPoint(i).getY());
       Point2D.Double p = new Point2D.Double(0, 0);
       canvas.transformModelToPixel(getModelSpace(), m.getX(), m.getY(), p);
       xmin = Math.min(xmin, (int) p.getX());
       xmax = Math.max(xmax, (int) p.getX());
       ymin = Math.min(ymin, (int) p.getY());
       ymax = Math.max(ymax, (int) p.getY());
     }
     w = xmax - xmin + 1;
     h = ymax - ymin + 1;
     rect = new Rectangle(xmin, ymin, w, h);
   } else {
     throw new RuntimeException("Invalid image definition.");
   }
   return rect;
 }
コード例 #20
0
 public boolean isInside(Point2D.Double point) {
   double x = point.getX();
   double y = point.getY();
   if ((x < center.getX() + radius && x > center.getX() - radius)
       && (y < center.getY() + radius && y > center.getY() - radius)) {
     return true;
   }
   return false;
 }
コード例 #21
0
 public String toString() {
   return getClass().getName()
       + "[label = "
       + label
       + ", point.getX() = "
       + point.getX()
       + ", point.getY() = "
       + point.getY()
       + "]";
 }
コード例 #22
0
  @Override
  public void mouseDragged(MouseEvent e, CS355Drawing model, Color c) {

    // Get shape at saved index from model and verify it is a circle
    Shape shape = model.getShape(this.index);
    if (!(shape instanceof cs355.model.drawing.Circle)) {
      GUIFunctions.printf(
          "Invalid shape - expected cs355.model.drawing.Circle at index %d", this.index);
      return;
    }

    // Cast the shape to a circle and save the new coordinates
    Circle circle = (Circle) shape;

    // Initialize new center coordinates to initial coordinates
    Point2D.Double center = new Point2D.Double();
    center.setLocation(this.initialCoordinates);

    // Get current pointer coordinates
    Point2D.Double currentCoordinates = new Point2D.Double();
    currentCoordinates.setLocation(e.getPoint());

    // Find difference between pointer and initial coordinates to get correct orientation
    double xDifference = currentCoordinates.getX() - initialCoordinates.getX();
    double yDifference = currentCoordinates.getY() - initialCoordinates.getY();

    // Get radius
    double radius = Math.min(Math.abs(xDifference), Math.abs(yDifference)) / 2.0;

    // Get unit vectors for the differences to preserve sign
    double xDirection = xDifference / Math.abs(xDifference);
    double yDirection = yDifference / Math.abs(yDifference);

    // Calculate position of the center of the circle
    center.x = this.initialCoordinates.getX() + (xDirection * radius);
    center.y = this.initialCoordinates.getY() + (yDirection * radius);

    // Set the new parameters
    circle.setCenter(center);
    circle.setRadius(radius);
  }
コード例 #23
0
  public static int closest(Point2D.Double[] BTS, Point2D.Double p) {

    double[] dist = new double[BTS.length];
    int min = 0;
    for (int i = 0; i < BTS.length; i++) {
      dist[i] = distanceSq(BTS[i].getX(), BTS[i].getY(), p.getX(), p.getY());
      if (dist[i] < dist[min]) min = i;
    }
    // System.out.println(dist[min] + " " + min);

    return min;
  }
コード例 #24
0
ファイル: Line.java プロジェクト: GitSage/3DDrawing
  // Compute the distance from AB to C
  private double lineToPointDistance2D(Point2D.Double pointC) {
    Point2D.Double start = getStart();
    Point2D.Double end = new Point2D.Double(getEnd().getX(), getEnd().getY());

    // get the cross product
    Point2D.Double AB = new Point2D.Double(end.getX() - start.getX(), end.getY() - start.getY());
    Point2D.Double AC =
        new Point2D.Double(pointC.getX() - start.getX(), pointC.getY() - start.getY());
    double cross = AB.getX() * AC.getY() - AB.getY() * AC.getX();

    double dist = cross / start.distance(end);

    // check for endpoints
    double dot1 = dotProduct(start, end, pointC);
    if (dot1 > 0) {
      return end.distance(pointC);
    }

    double dot2 = dotProduct(end, start, pointC);
    if (dot2 > 0) {
      return start.distance(pointC);
    }

    return Math.abs(dist);
  }
コード例 #25
0
    public void run() {

      Point2D.Double center = new Point2D.Double((double) width / 2, (double) height / 2);
      double fixedIncrement = 2.0 * Math.PI / ((double) barsCount);
      AffineTransform toCircle =
          AffineTransform.getRotateInstance(fixedIncrement, center.getX(), center.getY());

      long start = System.currentTimeMillis();
      if (rampDelay == 0) alphaLevel = rampUp ? 255 : 0;

      started = true;
      boolean inRamp = rampUp;

      while (!Thread.interrupted()) {
        if (!inRamp) {
          for (int i = 0; i < ticker.length; i++) ticker[i].transform(toCircle);
        }

        repaint();

        if (rampUp) {
          if (alphaLevel < 255) {
            alphaLevel = (int) (255 * (System.currentTimeMillis() - start) / rampDelay);
            if (alphaLevel >= 255) {
              alphaLevel = 255;
              inRamp = false;
            }
          }
        } else if (alphaLevel > 0) {
          alphaLevel = (int) (255 - (255 * (System.currentTimeMillis() - start) / rampDelay));
          if (alphaLevel <= 0) {
            alphaLevel = 0;
            break;
          }
        }

        try {
          Thread.sleep(inRamp ? 10 : (int) (1000 / fps));
        } catch (InterruptedException ie) {
          break;
        }
        Thread.yield();
      }

      if (!rampUp) {
        started = false;
        repaint();

        setVisible(false);
        removeMouseListener(InfiniteProgressPanel.this);
      }
    }
コード例 #26
0
ファイル: VProfileJoin.java プロジェクト: akoyro/furman
  @Override
  public void setBounds(Point2D.Double anchor, Point2D.Double lead) {
    Point2D.Double near = new Point2D.Double(-1000, -1000);
    Point2D.Double min = new Point2D.Double();
    Point2D.Double max = new Point2D.Double();

    if (anchor.distance(near) < lead.distance(near)) {
      min.setLocation(anchor);
      max.setLocation(anchor.getX(), lead.getY());
    } else {
      min.setLocation(anchor.getX(), lead.getY());
      max.setLocation(anchor);
    }

    if (rec == null) {
      rec = new Rectangle2D.Double();
    }

    rec.setRect(min.getX(), min.getY(), profileWidth, max.getY() - min.getY());

    createLine();
  }
コード例 #27
0
  /**
   * Method to get the coordinates of the enclosing rectangle after this transformation is applied
   * to the current picture
   *
   * @return the enclosing rectangle
   */
  public Rectangle2D getTransformEnclosingRect(AffineTransform trans) {
    int width = getWidth();
    int height = getHeight();
    double maxX = width - 1;
    double maxY = height - 1;
    double minX, minY;
    Point2D.Double p1 = new Point2D.Double(0, 0);
    Point2D.Double p2 = new Point2D.Double(maxX, 0);
    Point2D.Double p3 = new Point2D.Double(maxX, maxY);
    Point2D.Double p4 = new Point2D.Double(0, maxY);
    Point2D.Double result = new Point2D.Double(0, 0);
    Rectangle2D.Double rect = null;

    // get the new points and min x and y and max x and y
    trans.deltaTransform(p1, result);
    minX = result.getX();
    maxX = result.getX();
    minY = result.getY();
    maxY = result.getY();
    trans.deltaTransform(p2, result);
    minX = Math.min(minX, result.getX());
    maxX = Math.max(maxX, result.getX());
    minY = Math.min(minY, result.getY());
    maxY = Math.max(maxY, result.getY());
    trans.deltaTransform(p3, result);
    minX = Math.min(minX, result.getX());
    maxX = Math.max(maxX, result.getX());
    minY = Math.min(minY, result.getY());
    maxY = Math.max(maxY, result.getY());
    trans.deltaTransform(p4, result);
    minX = Math.min(minX, result.getX());
    maxX = Math.max(maxX, result.getX());
    minY = Math.min(minY, result.getY());
    maxY = Math.max(maxY, result.getY());

    // create the bounding rectangle to return
    rect = new Rectangle2D.Double(minX, minY, maxX - minX + 1, maxY - minY + 1);
    return rect;
  }
コード例 #28
0
ファイル: Line.java プロジェクト: GitSage/3DDrawing
 // Compute the dot product AB . AC
 private double dotProduct(Point2D.Double pointA, Point2D.Double pointB, Point2D.Double pointC) {
   Point2D.Double AB =
       new Point2D.Double(pointB.getX() - pointA.getX(), pointB.getY() - pointA.getY());
   Point2D.Double BC =
       new Point2D.Double(pointC.getX() - pointB.getX(), pointC.getY() - pointB.getY());
   double dot = AB.getX() * BC.getX() + AB.getY() * BC.getY();
   return dot;
 }
コード例 #29
0
ファイル: Polygon2D.java プロジェクト: gvtools/gvtools-legacy
  /** @param vp */
  private void newGP(ViewPortData vp) {
    // if (gp != null) return;
    gp = new GeneralPath();

    Point2D pt0 = null;
    Point2D pt = null;
    Point2D pt1 = null;
    Point2D.Double ptTmp = new Point2D.Double(0.0, 0.0);
    Iterator iter = iterator();

    while (iter.hasNext()) {
      pt1 = (Point2D) iter.next();
      vp.mat.transform(pt1, ptTmp);

      if (pt0 == null) {
        pt0 = ptTmp;
        gp.moveTo((float) ptTmp.getX(), (float) ptTmp.getY());
      } else {
        gp.lineTo((float) ptTmp.getX(), (float) ptTmp.getY());
      }
    }

    gp.closePath();
  }
コード例 #30
0
ファイル: PlotImage.java プロジェクト: duncanchild/geocraft
 /**
  * Constructs a plot image.
  *
  * @param image the actual image.
  * @param name the image name.
  * @param anchorType the anchor type.
  * @param anchorPoint the anchor point.
  */
 public PlotImage(
     final Image image,
     final String name,
     final ImageAnchor anchorType,
     final Point2D.Double anchorPoint) {
   super(ShapeType.IMAGE, name);
   setImage(image);
   setAnchorType(anchorType);
   setFixedSize(true);
   _isMovable = false;
   _points.add(new PlotPoint(anchorPoint.getX(), anchorPoint.getY(), 0));
   _xmin = Double.NaN;
   _xmax = Double.NaN;
   _ymin = Double.NaN;
   _ymax = Double.NaN;
 }