Class LayerList
- All Implemented Interfaces:
Serializable
,ListModel<Layer>
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd a layer to the list at a given index, and notify listenersAdd a layer to the front of the list, and notify listenersadd(GeoRelationalStore store)
Create a layer using a default theme and add it to the front of the list.add(GeoRelationalStore store, ChoroplethTheme theme)
Deprecated.void
Build a spatial index for this layervoid
Clear the selection list of the currently selected layer.clone()
void
close()
Close the layer list.void
dissolveLayer(Window parent)
Dissolve featuresvoid
drawLayers(Extent2D extent, AffineTransform af, double scale)
Create a background drawing thread to render the backing stores of the layers in this list.void
free()
Free backing store memory.get(int index)
Get a layer at a given index.getElementAt(int index)
Get the layer in the list.Get the aggregate extent of all layers.getImage()
Get a reference to the backing store.int
Get the period of interest that is being used to render layers.int
Get the index of the selected layerGet a reference to the selected table.int
getSize()
Get the number of layers in the list.void
identifyRecords(Extent2D box)
Invoke a method on the currently selected layer to identify records in the vicinity of the point.int
Find the index of a layer.boolean
Test to see if there is a background drawing thread in progress.boolean
isSelected(Layer lle)
Test if a layer is selected.void
itemChanged(Layer lle)
Receive notification that a layer should be redrawn, possibly because the symbology has changed.void
maybePopup(MouseEvent e, double x, double y, double fuzz)
Popup a context sensitive menu based on the capabilities of the currently selected layer.boolean
Test to see if any layers are in need of redrawing their backing stores.boolean
Test to see if the backing store requires a refresh.void
print(Graphics2D g, Extent2D extent, double scale, AffineTransform af, int dpi, LayerPrintCallback callback)
Print the layers on to the PrinterGraphics.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.void
queryTable(Frame owner)
Display the query builder on the table of the currently selected layer.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.remove()
Remove the selected layer.remove(int index)
Remove the layer at the specified index and notify listeners.void
reposition(int fromIndex, int toIndex)
Reposition a layer in the stacking order and notify listeners.boolean
Determines if any of the the layers in this list use a selection contextvoid
Reset the selection context of the currently selected layer.void
resetSelectionContext(int index)
Reset the selection context of a layervoid
Reset the selection context for all layers that have a context.void
resize(GraphicsConfiguration gc, int width, int height)
Resize the backing store and the backing stores of all layers.Obtain the extent of the currently selected layer.void
selectNone(Frame owner)
Unselect all records in the selected tablevoid
selectRecords(Extent2D box, boolean add)
Invoke a method on the currently selected layer to select records that overlap the box.void
selectWithinConvexHull(boolean within)
Select records within/intersecting the convex hull that is around the currently selected recordsvoid
Set up a hashtable of Actions that this class can perform.void
setBackground(Color backgroundColor)
Set the background colour for the backing store.void
setConnected(boolean state)
Set the datastore listeners on all layers to the desired state.void
setLayerListListener(LayerListListener listener)
Set up a connection to the MapPanel that is the view for this LayerList.void
setPeriod(int period)
Set the period of interest.void
setRedraw(boolean scaleChanged)
Mark the layer as being dirty and in need of a redraw.void
Mark layers that they are in need of a refresh, perhaps due to a change in stacking order or visibility (scale threshold, transparency).void
setSelected(Layer lle, boolean state)
Set the selected status of a layer and notify listeners.void
Display a geo-relational table associated with the currently selected layer.void
snapShot(OutputStream stream)
Take a snapshop of the current contents of the backing store and output as a PNG image.void
Stop the background drawing process if it is in progress.Methods inherited from class javax.swing.AbstractListModel
addListDataListener, getListDataListeners, getListeners, removeListDataListener
-
Constructor Details
-
LayerList
public LayerList() -
LayerList
public LayerList(boolean listenToEvents)
-
-
Method Details
-
clone
-
snapShot
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
Set the background colour for the backing store. -
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 http://download.oracle.com/javase/6/docs/api/javax/swing/package-summary.html#threading -
maybePopup
Popup a context sensitive menu based on the capabilities of the currently selected layer. Ring the bell if no layer is selected. -
queryTable
Display the query builder on the table of the currently selected layer. -
selectNone
Unselect all records in the selected table -
selectedExtent
Obtain the extent of the currently selected layer. -
selectRecords
Invoke a method on the currently selected layer to select records that overlap the box.- Parameters:
box
- The extent to test for overlapsadd
- If true add records to the selection, if false then remove records from the selection.
-
identifyRecords
Invoke a method on the currently selected layer to identify records in the vicinity of the point. -
processRecords
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
Dissolve features -
selectWithinConvexHull
public void selectWithinConvexHull(boolean within)Select records within/intersecting the convex hull that is around the currently selected records- Parameters:
within
- Specifies if the seleciton should be wwithin (true) or intersecting (false) the convex hull.
-
getSelectedTable
Get a reference to the selected table. -
setSelected
Set the selected status of a layer and notify listeners. -
getSelected
public int getSelected()Get the index of the selected layer -
isSelected
Test if a layer is selected. -
getSize
public int getSize()Get the number of layers in the list. -
getElementAt
Get the layer in the list. -
indexOf
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
Set up a connection to the MapPanel that is the view for this LayerList. -
add
Add a layer to the list at a given index, and notify listeners -
add
Add a layer to the front of the list, and notify listeners -
add
Deprecated.Create a layer and add it to the front of the list. -
add
Create a layer using a default theme and add it to the front of the list. -
itemChanged
Receive notification that a layer should be redrawn, possibly because the symbology has changed. -
get
Get a layer at a given index. -
remove
Remove the selected layer. -
remove
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
Get the aggregate extent of all layers. -
drawLayers
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
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
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
-