Class LayerList

All Implemented Interfaces:
Serializable, ListModel<Layer>

public class LayerList extends AbstractListModel<Layer>
The LayerList provides a data model consisting of layers of spatial data. Each layer in the model is an object of type Layer.

The LayerList is a container for Layers, and provides a means for controllers to invoke operations on the layers, and for viewers to render the contents of the layers.

The LayerList and each Layer maintains a heavy amount of state data, in particular each Layer maintains a backing store, and the LayerList maintains a composite backing store. The MapPanel viewer makes use of this state data to optimize its drawing environment.

Due to the tight binding between the MapPanel viewer and the LayerList state data the LayerList usually only supports a single viewer. Multiple controllers are allowed of course.

Multiple light weight listeners can listen on the TableModel listener interface. These listeners will receive event notification of list modifications. Typical uses are for legend lists.

See Also:
Layer, MapPanel, Serialized Form
  • Constructor Details

    • LayerList

      public LayerList()
    • LayerList

      public LayerList(boolean listenToEvents)
  • Method Details

    • clone

      public Object clone()
    • snapShot

      public void snapShot(OutputStream stream)
      Take a snapshop of the current contents of the backing store and output as a PNG image.
    • setPeriod

      public void setPeriod(int period)
      Set the period of interest. All layers will be rendered in this context.
    • getPeriod

      public int getPeriod()
      Get the period of interest that is being used to render layers.
    • setBackground

      public void setBackground(Color backgroundColor)
      Set the background colour for the backing store.
    • getImage

      public BufferedImage getImage()
      Get a reference to the backing store.
    • close

      public void close()
      Close the layer list. This method will release resources. After calling this method the LayerList can not be used again.
    • free

      public void free()
      Free backing store memory. This memory is reallocated when required so this is a safe call.
    • setConnected

      public void setConnected(boolean state)
      Set the datastore listeners on all layers to the desired state.
    • showTable

      public void showTable()
      Display a geo-relational table associated with the currently selected layer. Ring the bell if no layer is selected or the selected layer does not have a table (e.g. an ImageLayer). This method accesses Swing components. In order to correctly follow the Swing threading policy, this method must only be called from the event dispatch thread. For more information see
    • maybePopup

      public void maybePopup(MouseEvent e, double x, double y, double fuzz)
      Popup a context sensitive menu based on the capabilities of the currently selected layer. Ring the bell if no layer is selected.
    • queryTable

      public void queryTable(Frame owner)
      Display the query builder on the table of the currently selected layer.
    • selectNone

      public void selectNone(Frame owner)
      Unselect all records in the selected table
    • selectedExtent

      public Extent2D selectedExtent()
      Obtain the extent of the currently selected layer.
    • selectRecords

      public void selectRecords(Extent2D box, boolean add)
      Invoke a method on the currently selected layer to select records that overlap the box.
      box - The extent to test for overlaps
      add - If true add records to the selection, if false then remove records from the selection.
    • identifyRecords

      public void identifyRecords(Extent2D box)
      Invoke a method on the currently selected layer to identify records in the vicinity of the point.
    • processRecords

      public void processRecords(Extent2D box, RecordHandler handler)
      Invoke a method on the currently selected layer to identify records in the vicinity of the point and call a custom processing method for each record.
    • clearSelection

      public void clearSelection()
      Clear the selection list of the currently selected layer.
    • resetSelectionContext

      public void resetSelectionContext()
      Reset the selection context of the currently selected layer.
    • resetSelectionContext

      public void resetSelectionContext(int index)
      Reset the selection context of a layer
    • resetSelectionContextAll

      public void resetSelectionContextAll()
      Reset the selection context for all layers that have a context.
    • requiresSelectionContext

      public boolean requiresSelectionContext()
      Determines if any of the the layers in this list use a selection context
    • buildSpatialIndex

      public void buildSpatialIndex()
      Build a spatial index for this layer
    • dissolveLayer

      public void dissolveLayer(Window parent)
      Dissolve features
    • selectWithinConvexHull

      public void selectWithinConvexHull(boolean within)
      Select records within/intersecting the convex hull that is around the currently selected records
      within - Specifies if the seleciton should be wwithin (true) or intersecting (false) the convex hull.
    • getSelectedTable

      public AttributeStore getSelectedTable()
      Get a reference to the selected table.
    • setSelected

      public void setSelected(Layer lle, boolean state)
      Set the selected status of a layer and notify listeners.
    • getSelected

      public int getSelected()
      Get the index of the selected layer
    • isSelected

      public boolean isSelected(Layer lle)
      Test if a layer is selected.
    • getSize

      public int getSize()
      Get the number of layers in the list.
    • getElementAt

      public Layer getElementAt(int index)
      Get the layer in the list.
    • indexOf

      public int indexOf(Layer element)
      Find the index of a layer.
    • setRedraw

      public void setRedraw(boolean scaleChanged)
      Mark the layer as being dirty and in need of a redraw. Notify listeners in case the scale has changed.
    • setRefresh

      public void setRefresh()
      Mark layers that they are in need of a refresh, perhaps due to a change in stacking order or visibility (scale threshold, transparency).
    • needsRefresh

      public boolean needsRefresh()
      Test to see if the backing store requires a refresh.
    • needsRedraw

      public boolean needsRedraw()
      Test to see if any layers are in need of redrawing their backing stores.
    • setLayerListListener

      public void setLayerListListener(LayerListListener listener)
      Set up a connection to the MapPanel that is the view for this LayerList.
    • add

      public Layer add(int index, Layer element)
      Add a layer to the list at a given index, and notify listeners
    • add

      public Layer add(Layer element)
      Add a layer to the front of the list, and notify listeners
    • add

      @Deprecated public Layer add(GeoRelationalStore store, ChoroplethTheme theme)
      Create a layer and add it to the front of the list.
    • add

      public Layer add(GeoRelationalStore store)
      Create a layer using a default theme and add it to the front of the list.
    • itemChanged

      public void itemChanged(Layer lle)
      Receive notification that a layer should be redrawn, possibly because the symbology has changed.
    • get

      public Layer get(int index)
      Get a layer at a given index.
    • remove

      public Layer remove()
      Remove the selected layer.
    • remove

      public Layer remove(int index)
      Remove the layer at the specified index and notify listeners.
    • reposition

      public void reposition(int fromIndex, int toIndex)
      Reposition a layer in the stacking order and notify listeners.
    • getExtent2D

      public Extent2D getExtent2D()
      Get the aggregate extent of all layers.
    • drawLayers

      public void drawLayers(Extent2D extent, AffineTransform af, double scale)
      Create a background drawing thread to render the backing stores of the layers in this list. Each layer will render into its own private backing store. Layers may choose not to redraw themselves if they know they are already up to date.
    • refreshLayers

      public void refreshLayers(Graphics2D g, double scale)
      Refresh as much as possible of the layers on to the backing store and subsequently on to the screen. If any of the layers are still painting then stop the refresh process.
    • print

      public void print(Graphics2D g, Extent2D extent, double scale, AffineTransform af, int dpi, LayerPrintCallback callback)
      Print the layers on to the PrinterGraphics. Do not use the backing store in order to get full printer resolution.
    • stopDrawing

      public void stopDrawing()
      Stop the background drawing process if it is in progress.
    • isDrawing

      public boolean isDrawing()
      Test to see if there is a background drawing thread in progress.
    • resize

      public void resize(GraphicsConfiguration gc, int width, int height)
      Resize the backing store and the backing stores of all layers. Stop the background drawing thread if it is active. Create a Graphics object for use on this backing store and keep a reference to it so that it does not have to be continually reinstantiated.
    • setActions

      public void setActions()
      Set up a hashtable of Actions that this class can perform.
    • getAction

      public Action getAction(String command)