Class PickCanvas


  • public class PickCanvas
    extends PickTool
    A subclass of PickTool, simplifies picking using mouse events from a canvas. This class allows picking using canvas x,y locations by generating the appropriate pick shape.

    The pick tolerance specifies the distance from the pick center to include in the pick shape. A tolerance of 0.0 may speedup picking slightly, but also make it very difficult to pick points and lines.

    The pick canvas can be used to make a series of picks. For example, to initialize the pick canvas:

         PickCanvas pickCanvas = new PickCanvas(canvas, scene);
         pickCanvas.setMode(PickInfo.PICK_GEOMETRY); 
         pickCanvas.setFlags(PickInfo.NODE | PickInfo.CLOSEST_INTERSECTION_POINT); 
         pickCanvas.setTolerance(4.0f);
     

    Then for each mouse event:

         pickCanvas.setShapeLocation(mouseEvent);
         PickInfo[] pickInfos = pickCanvas.pickAll();
     

    NOTE: For the pickAllSorted or pickClosest methods, the picks will be sorted by the distance from the ViewPlatform to the intersection point.

    See Also:
    PickTool
    • Constructor Detail

      • PickCanvas

        public PickCanvas​(Canvas3D c,
                          BranchGroup b)
        Constructor with Canvas3D for mouse events and BranchGroup to be picked.
      • PickCanvas

        public PickCanvas​(Canvas3D c,
                          Locale l)
        Constructor with Canvas3D for mouse events and Locale to be picked.
    • Method Detail

      • getCanvas

        public Canvas3D getCanvas()
        Inquire the canvas to be used for picking operations.
        Returns:
        the canvas.
      • setTolerance

        public void setTolerance​(float t)
        Set the picking tolerance. Objects within this distance (in pixels) to the mouse x,y location will be picked. The default tolerance is 2.0.
        Parameters:
        t - The tolerance
        Throws:
        java.lang.IllegalArgumentException - if the tolerance is less than 0.
      • getTolerance

        public float getTolerance()
        Get the pick tolerance.
      • setShapeLocation

        public void setShapeLocation​(java.awt.event.MouseEvent mevent)
        Set the pick location. Defines the location on the canvas where the pick is to be performed.
        Parameters:
        mevent - The MouseEvent for the picking point
      • setShapeLocation

        public void setShapeLocation​(int xpos,
                                     int ypos)
        Set the pick location. Defines the location on the canvas where the pick is to be performed (upper left corner of canvas is 0,0).
        Parameters:
        xpos - the X position of the picking point
        ypos - the Y position of the picking point