Class TLcdLayerTreeNodeCellRenderer

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, TreeCellRenderer
Direct Known Subclasses:
TLcdGXYLayerTreeNodeCellRenderer, TLspLayerTreeNodeCellRenderer

public class TLcdLayerTreeNodeCellRenderer extends JPanel implements TreeCellRenderer

A TreeCellRenderer for visualizing ILcdLayers and ILcdLayerTreeNodes in a JTree.

For every layer it shows:

The standard behavior of toggling the checkbox is to toggle the visibility of the layer. This behavior can be altered by overwriting the updateLayerFromRenderer(com.luciad.view.ILcdLayer) method. This method will always be called when the checkbox changes state.

The visualisation of a layer can be adjusted by overwriting the updateRendererFromLayer method.

Since:
9.0
See Also:
  • Constructor Details

    • TLcdLayerTreeNodeCellRenderer

      public TLcdLayerTreeNodeCellRenderer(ILcdTreeLayered aView, int aIconWidth, int aIconHeight)

      Create a new renderer for a layer tree with the specified icon height and width. Layer icons that are larger as the specified size are resized to fit. Layer icons that are smaller as the given icon size are painted centered.

      This renderer can only be used on one LayerTree at the same time.

      Parameters:
      aView - the ILcdTreeLayered containing the layers which will be displayed in the layer tree.
      aIconWidth - the height of the icon
      aIconHeight - the width of the icon
    • TLcdLayerTreeNodeCellRenderer

      public TLcdLayerTreeNodeCellRenderer(ILcdTreeLayered aView)

      Create a new renderer for a layer tree with an icon height and width of 16. This renderer can only be used on one LayerTree at the same time.

      Parameters:
      aView - the ILcdTreeLayered containing the layers which will be displayed in the layer tree
  • Method Details

    • getDefaultNodeIcon

      public ILcdIcon getDefaultNodeIcon()
      The default icon, used for nodes (not leafs) that don't have an icon.
      Returns:
      the default icon, used for nodes (not leafs) that don't have an icon. Can be null.
      See Also:
    • setDefaultNodeIcon

      public void setDefaultNodeIcon(ILcdIcon aDefaultNodeIcon)
      Sets the default icon, used for nodes (not leafs) that don't have an icon.
      Parameters:
      aDefaultNodeIcon - The new default node icon, can be null.
      See Also:
    • getDefaultLeafIcon

      public ILcdIcon getDefaultLeafIcon()
      The default icon, used for leafs that don't have an icon.
      Returns:
      the default icon, used for leafs that don't have an icon. Can be null.
      See Also:
    • setDefaultLeafIcon

      public void setDefaultLeafIcon(ILcdIcon aDefaultLeafIcon)
      Sets the default icon, used for leafs that don't have an icon.
      Parameters:
      aDefaultLeafIcon - The new default leaf icon, can be null.
      See Also:
    • updateLayerFromRenderer

      protected void updateLayerFromRenderer(ILcdLayer aLayer)
      Updates the layer to match the state of the renderer. This method is called whenever the checkbox is clicked.

      The default behavior updates the layer's visibility. If the layer is an empty tree node, it will update the visibility of the child layers.

      Parameters:
      aLayer - the layer to be updated
    • getLabel

      public JLabel getLabel()
      Returns the JLabel visualizing the label of the layer
      Returns:
      the JLabel visualizing the label of the layer
    • getTreeCellRendererComponent

      public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
      Specified by:
      getTreeCellRendererComponent in interface TreeCellRenderer
    • getPreferredSize

      public Dimension getPreferredSize()
      Overrides:
      getPreferredSize in class JComponent
    • updateRendererFromLayer

      protected void updateRendererFromLayer(JTree aTree, ILcdLayer aLayer, boolean aSelected, boolean aExpanded, boolean aLeaf, int aRow, boolean aHasFocus)
      Update the state of the renderer to match the state of the given layer. Override this method if you want to customize, for example, the appearance or content of the label, or the displayed tool tip text.
      Parameters:
      aTree - the tree which is currently rendered
      aLayer - the layer which state the renderer should match
      aSelected - if true, the cell must be drawn as if selected
      aExpanded - if true, the node is currently expanded
      aLeaf - if true, the node represents a leaf
      aRow - the row number
      aHasFocus - if true, the node currently has focus
    • getCheckBox

      public JCheckBox getCheckBox()

      Returns the visibility checkbox.

      Returns:
      the visibility checkbox