Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#422 closed defect (fixed)

Refactor GraphPanel/GraphWindow class

Reported by: Kevin Milner Owned by:
Priority: major Milestone: OpenSHA 1.3
Component: commons Version:
Keywords: Cc:

Description (last modified by Kevin Milner)

Refactor GraphPanel? and related classes - remove nasty APIs and make self contained GraphWidget? class which can be shared by GraphWindow? and regular applications.

DONE - here is a summary of changes

Previously there were 4 primary classes:

  • GraphPanel? - actually does the graphing, extends JSplitPane
  • GraphWindow? - used for peel off and most non-application embedded plotting, extends JFrame
  • GraphiWindowAPI_Impl - wrapper for GraphWindow? which implements all of its various APIs
  • HeadlessGraphPanel? - for headless plotting

As well as a some utility/GUI component classes:

As well as a bunch of interfaces which applications must implement in order to use the above classes:

All of these interfaces were created such that the ButtonControlPanel? and various other GUI components could be embedded in an application or used separately in a GraphWindow?. The thing is, none of them are actually needed if we just had a class which represented a GraphPanel? and associated controls that could be embedded into an application or standalone window...enter GraphWidget?. GraphWidget? encompasses the GraphPanel? and all controls (buttons, style, axis limits) and is used both by applications and GraphWindow?. Here is the new class list:

New primary classes:

All of those APIs have be removed, and our applications are much cleaner. There is also much less code duplication as the controls and APIs don't need to be implemented everywhere. The GraphWindow? class functions much like (and has similar constructors/methods to) the old GraphiWindowAPI_Impl class. I tried to document as much as I could, and make sure everything was working correctly but there may be bugs. Also some very old one off plots (classes that were used to make a plot in UCERF2 for example) did not get fully upgraded in that they might not display in log format by default where they previously might have been. There were over 1000 errors when I finished the new class structure so I did my best but didn't spend much time on plots which are likely never going to be used again.

There was also a some nastiness in the way that WeightedFunctionLists? were handled - basically GraphPanel? took an ArrayList? of Objects, which were mixed between XYDataSets and WeightedFunctionLists?. Both of these now extend a common interface PlotElement?, with some common methods which allowed for simplification of GraphPanel? and use of Generics.

Additionally, these updates/new features have been added:

  • All classes work with PlotSpec? objects
  • Auto scale has been separated for the X an Y axis, so that for example you can specify a custom X scale but still use auto Y scale
  • XY annotation support added - you can now add XYAnnotations (such as text annotations) to a PlotSpec? object and they will be included in the plots
  • All plotting classes moved to commons from sha
  • new PlotMultiDataLayer? object which implements PlotElement? for adding many lines to plots such as separators and such with the same characteristics without flooding the plot data window. For example, the fault based paleo plots could have very clean metadata now if I used this new object.
  • subplot support, currently only at the GraphPanel? level (can only be used by HeadlessGraphPanel? right now but could be exposed further).
  • plot preferences (font sizes and background colors) now in PlotPreferences? object, could potentially store user specific properties that get loaded in on application start.

Change History (2)

comment:1 Changed 11 years ago by Kevin Milner

Resolution: fixed
Status: newclosed

Done. Merged to trunk from feature branch in [10181]

comment:2 Changed 11 years ago by Kevin Milner

Description: modified (diff)
Note: See TracTickets for help on using tickets.