#323 reuse event object instances

open
David Gilbert
General (246)
5
2007-02-28
2007-02-26
Sergei Ivanov
No

Event objects, such as AxisChangeEvent or MarkerChangeEvent, can be created just once on demand and reused. A pattern, similar to delivering javax.swing.AbstractButton#changeEvent, can be employed.

Also, there is no need for AxisChangeEvent or MarkerChangeEvent to subclass ChartChangeEvent. If they subclass EventObject directly, they will be immutable and, consequently, reusable.

Discussion

  • David Gilbert
    David Gilbert
    2007-02-28

    Logged In: YES
    user_id=112975
    Originator: NO

    Good suggestion. I've been aware for a while that it is unnecessary to always create a new event instance, but haven't found the time to fix it yet. I've started just now with an update to the AbstractRenderer class. I'll continue on the other classes as I find time.

     
  • David Gilbert
    David Gilbert
    2007-02-28

    • labels: --> General
    • assigned_to: nobody --> mungady
     
  • Sergei Ivanov
    Sergei Ivanov
    2007-02-28

    Logged In: YES
    user_id=1606022
    Originator: YES

    Please keep in mind that ChartChangeEvent (and, consequently, all its subclasses) is mutable and its instances cannot be reused. For example, the 'chart' property is set on the instance of PlotChangeEvent in JFreeChart#plotChanged().

    Therefore Axis or Marker change events must not subclass ChartChangeEvent.

    If you'd like me to undertake part of the work, let me know.

     
  • David Gilbert
    David Gilbert
    2007-03-02

    Logged In: YES
    user_id=112975
    Originator: NO

    Yes, that is going to make it slightly awkward to fix without breaking the API. I'll take another look at it.