Class AbstractOverlayListPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public abstract class AbstractOverlayListPanel extends JPanel

The AbstractOverlayListPanel class is the abstract parent of all overlay list panels. It allows the user to add new overlays via a set of buttons, remove overlays from the current list, edit a specific overlay using an overlay property chooser, and rearrange the overlay layers within the list. Child classes must implement the getAddButtons() method which returns a list of the "add overlay" buttons, and the getTitle() method which determine the title for parts of the panel. Child classes may also override the getCustomPanel() method to supply a custom panel that is inserted between the add button panel and the overlay list.

The overlay list panel signals an add/remove in the overlay list by firing a property change event whose property name is given by the OVERLAY_PROPERTY constant, and old value (if non-null) contains an overlay to remove from the view, and new value (if non-null) contains an overlay to add to the view. If the overlay to add already exists in the view, then the overlay's internal properties have changed and the view should be re-rendered.

Additionally, a selection change in the overlay list is signaled by firing a property change event whose property name is given by the SELECTION_PROPERTY constant. The selection value is the currently selected EarthDataOverlay object, or null if none is selected. If multiple overlays are selected, no event is fired.

Since:
3.1.7
Author:
Peter Hollemans
See Also:
  • Field Details

    • OVERLAY_PROPERTY

      public static String OVERLAY_PROPERTY
      The overlay property for change events.
    • SELECTION_PROPERTY

      public static String SELECTION_PROPERTY
      The selection property for change events.
    • overlayList

      protected ComponentList<VisualOverlay> overlayList
      The list of overlays.
  • Constructor Details

    • AbstractOverlayListPanel

      protected AbstractOverlayListPanel()
      Creates a new list panel, showing the Remove/Edit/Up/Down buttons.
    • AbstractOverlayListPanel

      protected AbstractOverlayListPanel(boolean showRemove, boolean showEdit, boolean showArrange, boolean showVisibility, boolean showGroup)
      Creates a new list panel with the specified buttons.
      Parameters:
      showRemove - if true, shows the remove overlay button.
      showEdit - if true, shows the edit selected overlay button.
      showArrange - if true, shows the up and down overlay buttons.
      showVisibility - if true, shows the visibility modifier buttons.
      showGroup - if true, shows the overlay group panel.
  • Method Details

    • setDataSource

      public void setDataSource(EarthDataReader reader, List variableList)
      Sets the data source for bitmask grid data. This method need only be used if the overlay group feature is enabled, and the group manager needs to load bitmask overlays.
      Parameters:
      reader - the reader to use for data variables.
      variableList - the list of allowed data variable names.
      See Also:
    • getCustomPanel

      protected JPanel getCustomPanel()
      Gets a custom panel to be placed between the add overlay button panel and the overlay list.
      Returns:
      the custom panel or null for none (the default).
    • setVisibleRowCount

      public void setVisibleRowCount(int rows)
      Sets the preferred number of visible overlay list rows.
      Parameters:
      rows - the number of visible rows.
    • setBaseLayer

      public void setBaseLayer(int baseLayer)
      Sets the base layer. When overlays are added to the list, they are given a layer number that is higher than any other overlay currently in the list so that the new overlay is rendered on top of existing overlays. The base layer determines what layer value the initially added overlay will have. By default the base layer is 0.
      Parameters:
      baseLayer - the base layer for the initial overlay.
    • removeOverlays

      protected void removeOverlays()
      Removes all overlays from the list. No property change event is fired.
    • addOverlays

      protected void addOverlays(List overlays)
      Adds a set of overlays to the list. This method should be called by the child class to setup the initial list of overlays. No property change event is fired, and no layer numbers are assigned, since we assume that the layers are set correctly. Overlays are displayed in the order that the layer values dictate.
      Parameters:
      overlays - the initial set of overlays.
    • addOverlay

      protected void addOverlay(EarthDataOverlay overlay)
      Adds an overlay to the list. This method should be called by the child class when a new overlay is added. A property change event is fired to indicate that the overlay has been added. The layer number of the overlay is set to be larger than any existing layer number in the list. The new overlay is set to be selected in the list.
      Parameters:
      overlay - the overlay to add.
    • getAddButtons

      protected abstract List getAddButtons()
      Gets the list of add overlay buttons. Generally, the list should contain buttons of all one size with tool text and action listeners attached. In order to add an overlay when clicked, the button listener should invoke the addOverlay() method.
      Returns:
      the list of add buttons, or null to not create a button panel.
    • getTitle

      protected abstract String getTitle()
      Gets the title that will be used to annotate the button and list panels.
      Returns:
      the title string, or null if no titles should be used.
    • getButtonTitle

      protected String getButtonTitle()
      Gets the title that will be used to annotate the button panel.
      Returns:
      the title string, or null if no titles should be used.
    • getListTitle

      protected String getListTitle()
      Gets the title that will be used to annotate the list panel.
      Returns:
      the title string, or null if no titles should be used.
    • getGroupTitle

      protected String getGroupTitle()
      Gets the title that will be used to annotate the groups panel.
      Returns:
      the title string, or null if no titles should be used.
    • getOverlayCount

      protected int getOverlayCount(Object overlayKey)
      Gets and increments the current count of overlays created with the specified key. This method may be used by child classes to help name new overlays as they are created.
      Parameters:
      overlayKey - the overlay key used to uniquely identify a set of overlays.
      Returns:
      the total number of calls to this method with the specified overlay key.
    • getOverlayList

      public List getOverlayList()
      Gets the list of overlays.
      Returns:
      the list of overlays.
    • main

      public static void main(String[] argv)
      Tests this class.
      Parameters:
      argv - the array of arguments (ignored).