Testing for a point inside an object

When drawing Rogue Wave® JViews graphic objects you often need to validate the presence of a point inside the object. The ShadowEllipse example implements the contains method. It returns true if the specified point is located within the main ellipse. All the coordinates are specified relative to the coordinate system of the view.
 /**
   * Tests whether a point lies within the shape of the object.
   * This method will be called when you click the object.
   * @param p The point where user clicks in the object’s coordinate system.
   * @param tp Same point as ’p’ but transformed by transformer ’t’
   * @param t The transformer used to draw the object.
   */
  public boolean contains(IlvPoint p, IlvPoint tp,
                          IlvTransformer t)
  {
    // Allow the user to click the main ellipse
    // but not on the shadow ellipse. 
    // This method will return true when the clicked point is
    // on the main ellipse.
    // First compute the bounding rectangle of the main
    // ellipse in the view coordinate system, just like in the
    // method draw.
    IlvRect r = new IlvRect(drawrect);
             
    if (t != null) 
      t.apply(r);
               
    int thick = thickness;
         
    if ((r.width <= thick) || (r.height <= thick))
      thick = (int)Math.min(r.width, r.height);
 
    r.width  -= thick;
    r.height -= thick;
 
    // Then call PointInFilledArc that will return true
    // if the point is in the ellipse. ’r’ and ’tp’ are both
    // in the view coordinate system.
    return IlvArcUtil.PointInFilledArc(tp, r, (float)0, (float)360);
  }