This is the mail archive of the java-patches@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch: RoundRectangle2D


Tom Tromey wrote:

> Here's another awt class.
> This class should mostly work.  The PathIterator hasn't been written
> yet.

Cool, good to see some progress on the AWT stuff. I've been wanting to get back
to work on the gtk peers for a while, but I want to finish off the collections
work first...

> +  /** Return true if this object contains the specified point.
> +   * @param x The x coordinate
> +   * @param y The y coordinate
> +   */
> +  public boolean contains (double x, double y)
> +  {
> +    double mx = getX ();
> +    double mw = getWidth ();

I think in cases like this that, for efficiency, we want to refer to the fields
directly rather than going through public accessor methods like getX (). I've
checked this sort of thing before by subclassing AWT components and Collection
classes, and its clear that Sun's implementation uses fields directly in every
case that I've tried.

There is an argument that using the accessors is more correct in case somebody
overrides them, but if override setX(), for example, then you really need to
call super.setX() as well in order to do anything useful.

regards

  [ bryce ]



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]