Package java.awt.geom

Examples of java.awt.geom.Point2D


    }

    float radiusX = (float)location.getWidth() / 2;
    float radiusY = (float)location.getHeight() / 2;

    final Point2D center = new Point2D.Double(
      location.getX() + radiusX,
      location.getY() + radiusY
      );

    double radians1 = Math.toRadians(startAngle);
    Point2D point1 = new Point2D.Double(
      center.getX() + Math.cos(radians1) * radiusX,
      center.getY() - Math.sin(radians1) * radiusY
      );

    if(beginPath)
    {beginSubpath(point1);}

    final double endRadians = Math.toRadians(endAngle);
    final double quadrantRadians = Math.PI / 2;
    double radians2 = Math.min(
      radians1 + quadrantRadians - radians1 % quadrantRadians,
      endRadians
      );
    final double kappa = 0.5522847498;
    while(true)
    {
      double segmentX = radiusX * kappa;
      double segmentY = radiusY * kappa;

      // Endpoint 2.
      Point2D point2 = new Point2D.Double(
        center.getX() + Math.cos(radians2) * radiusX,
        center.getY() - Math.sin(radians2) * radiusY
        );

      // Control point 1.
      double tangentialRadians1 = Math.atan(
        -(Math.pow(radiusY,2) * (point1.getX()-center.getX()))
          / (Math.pow(radiusX,2) * (point1.getY()-center.getY()))
        );
      double segment1 = (
        segmentY * (1 - Math.abs(Math.sin(radians1)))
          + segmentX * (1 - Math.abs(Math.cos(radians1)))
        ) * (radians2-radians1) / quadrantRadians; // TODO: control segment calculation is still not so accurate as it should -- verify how to improve it!!!
      Point2D control1 = new Point2D.Double(
        point1.getX() + Math.abs(Math.cos(tangentialRadians1) * segment1) * Math.signum(-Math.sin(radians1)),
        point1.getY() + Math.abs(Math.sin(tangentialRadians1) * segment1) * Math.signum(-Math.cos(radians1))
        );

      // Control point 2.
      double tangentialRadians2 = Math.atan(
        -(Math.pow(radiusY,2) * (point2.getX()-center.getX()))
          / (Math.pow(radiusX,2) * (point2.getY()-center.getY()))
        );
      double segment2 = (
        segmentY * (1 - Math.abs(Math.sin(radians2)))
          + segmentX * (1 - Math.abs(Math.cos(radians2)))
        ) * (radians2-radians1) / quadrantRadians; // TODO: control segment calculation is still not so accurate as it should -- verify how to improve it!!!
      Point2D control2 = new Point2D.Double(
        point2.getX() + Math.abs(Math.cos(tangentialRadians2) * segment2) * Math.signum(Math.sin(radians2)),
        point2.getY() + Math.abs(Math.sin(tangentialRadians2) * segment2) * Math.signum(Math.cos(radians2))
        );

      // Draw the current quadrant curve!
View Full Code Here


    )
  {
    Path2D pathObject = (Path2D)state.getScanner().getRenderObject();
    if(pathObject != null)
    {
      Point2D controlPoint1 = getControl1();
      if(controlPoint1 == null)
      {controlPoint1 = pathObject.getCurrentPoint();}
      Point2D finalPoint = getPoint();
      Point2D controlPoint2 = getControl2();
      if(controlPoint2 == null)
      {controlPoint2 = finalPoint;}
      pathObject.curveTo(
        controlPoint1.getX(),
        controlPoint1.getY(),
        controlPoint2.getX(),
        controlPoint2.getY(),
        finalPoint.getX(),
        finalPoint.getY()
        );
    }
  }
View Full Code Here

    )
  {
    Path2D pathObject = (Path2D)state.getScanner().getRenderObject();
    if(pathObject != null)
    {
      Point2D point = getPoint();
      pathObject.lineTo(point.getX(),point.getY());
    }
  }
View Full Code Here

    // Showing the clown photo...
    // Instantiate a jpeg image object!
    Image image = Image.get(getInputPath() + java.io.File.separator + "images" + java.io.File.separator + "Clown.jpg"); // Abstract image (entity).

    Point2D imageLocation = new Point2D.Double(
      blockComposer.getBoundBox().getX() + blockComposer.getBoundBox().getWidth() - image.getWidth(),
      blockComposer.getBoundBox().getY() + blockComposer.getBoundBox().getHeight() + 25
      );
    // Show the image!
    composer.showXObject(
      image.toXObject(document),
      imageLocation,
      new Dimension(0,0)
      );

    Rectangle2D descriptionFrame = new Rectangle2D.Double(
      imageLocation.getX(),
      imageLocation.getY() + image.getHeight() + 5,
      image.getWidth(),
      20
      );

    frame = new Rectangle2D.Double(
      blockComposer.getBoundBox().getX(),
      imageLocation.getY(),
      blockComposer.getBoundBox().getWidth() - image.getWidth() - 20,
      image.getHeight()
      );
    blockComposer.begin(frame,AlignmentXEnum.Left,AlignmentYEnum.Middle);
    composer.setFont(font,30);
View Full Code Here

    )
  {
    Path2D pathObject = (Path2D)state.getScanner().getRenderObject();
    if(pathObject != null)
    {
      Point2D point = getPoint();
      pathObject.moveTo(point.getX(),point.getY());
    }
  }
View Full Code Here

        && destination instanceof PlanComponent
        && this.homeController.getPlanController() != null) {
      try {
        List<Selectable> transferedItems =
            (List<Selectable>)transferable.getTransferData(HomeTransferableList.HOME_FLAVOR);
        Point2D dropLocation = getDropModelLocation(destination);
        this.homeController.getPlanController().startDraggedItems(transferedItems,
            (float)dropLocation.getX(), (float)dropLocation.getY());
        this.isDragging = true;
      } catch (UnsupportedFlavorException ex) {
        throw new RuntimeException("Can't import", ex);
      } catch (IOException ex) {
        throw new RuntimeException("Can't access to data", ex);
View Full Code Here

  @Override
  protected void dragMoved(JComponent destination, Transferable transferable, int dragAction) {
    if (transferable.isDataFlavorSupported(HomeTransferableList.HOME_FLAVOR)
        && destination instanceof PlanComponent
        && this.homeController.getPlanController() != null) {
        Point2D dropLocation = getDropModelLocation(destination);
      this.homeController.getPlanController().moveMouse(
          (float)dropLocation.getX(), (float)dropLocation.getY());
    }
  }
View Full Code Here

 

  private boolean importHomeTransferableList(final JComponent destination,
                                             final List<Selectable> transferedItems) {
    if (isDrop()) {
      Point2D dropLocation = getDropModelLocation(destination);
      if (destination instanceof View) {
        this.homeController.drop(transferedItems, (View)destination,
            (float)dropLocation.getX(), (float)dropLocation.getY());
      } else {
        this.homeController.drop(transferedItems, 
            (float)dropLocation.getX(), (float)dropLocation.getY());
      }
    } else {
      this.homeController.paste(transferedItems);
    }
    return true;
View Full Code Here

    }
    return true;
  }
 
  private boolean importFileList(final JComponent destination, List<File> files) {
    final Point2D dropLocation = isDrop()
        ? getDropModelLocation(destination)
        : new Point2D.Float();
    final List<String> importableModels = getModelContents(files, contentManager);
    EventQueue.invokeLater(new Runnable() {
        public void run() {
          homeController.dropFiles(importableModels,
              (float)dropLocation.getX(), (float)dropLocation.getY());       
        }
      });
    return !importableModels.isEmpty();
  }
View Full Code Here

  void paintBundleNode(Graphics2D g,
                       BundleSelectionModel bundleSelModel,
                       BundleNode node,
                       Node hoverNode) {
    Point2D p = node.getPoint();
    if(p == null) {
      return;
    }

    Bundle b = node.getBundle();
    Dimension size = getSize();

    AffineTransform oldTrans = g.getTransform();

    Icon icon = Util.getBundleIcon(b);

    int w = icon.getIconWidth();
    int h = icon.getIconHeight();

    double x = p.getX();
    double y = p.getY();

    float f = (float)(1.0 / (1 + 2*node.getDepth()));

    g.translate(x, y);
    g.scale(f, f);
View Full Code Here

TOP

Related Classes of java.awt.geom.Point2D

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.