ilog.views.diagrammer.application
Class IlvDiagrammerTree

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JTree
                  extended by ilog.views.diagrammer.application.IlvDiagrammerTree
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable

public class IlvDiagrammerTree
extends JTree

A component to display the data model of an IlvDiagrammer as a tree.

This component connects itself automatically to the "current" diagram component in a component hierarchy. All you have to do is create the tree, and add it to a hierarchy that also contains one or more diagram components.

The icons of the tree items are automatically generated reduced "screen dumps" of the real objects of the diagram. The same icon is used for objects that are considered "equal", as defined by a hash function.

The default hash function can be changed through the setIconHashFunction(ilog.views.diagrammer.application.IlvDiagrammerHashFunction) method. You could decide, for example, that you want to differentiate, among all the objects of tag "activity", the objects with different values for the "implementation" property. Here is how you would do this:

   tree.setIconHashFunction(new IlvDiagrammerHashFunction(){
     public Object hashCode(IlvDiagrammer diagrammer, Object obj)
     {
       return diagrammer.getTag(obj) + " " + diagrammer.getObjectProperty(obj, "implementation");
     }
   });
 

Styling Options

The rendering of the tree items can be customized through the style sheet of the diagram component. To do this, you must call setStyleApplicationComponents(true) on the diagram component, and you must define special rules with the "DiagrammerTree" pseudo-class, like the following:

 node:DiagrammerTree {
     foreground : "blue";
 }
 
Like in the diagram itself, you can style the tree items according to the different kinds of nodes and links, for example:
 node[state="Error"]:DiagrammerTree {
     foreground : "red";
 }
 
You can also use the following additional pseudo-classes: The properties that can be set in the property sheet rules are all the properties of the javax.swing.tree.DefaultTreeCellRenderer class (which is a subclass of javax.swing.JLabel). The most useful properties are typically foreground, background, font, text and icon.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JTree
JTree.AccessibleJTree, JTree.DynamicUtilTreeNode, JTree.EmptySelectionModel, JTree.TreeModelHandler, JTree.TreeSelectionRedirector
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JTree
ANCHOR_SELECTION_PATH_PROPERTY, CELL_EDITOR_PROPERTY, CELL_RENDERER_PROPERTY, cellEditor, cellRenderer, editable, EDITABLE_PROPERTY, EXPANDS_SELECTED_PATHS_PROPERTY, INVOKES_STOP_CELL_EDITING_PROPERTY, invokesStopCellEditing, LARGE_MODEL_PROPERTY, largeModel, LEAD_SELECTION_PATH_PROPERTY, ROOT_VISIBLE_PROPERTY, rootVisible, ROW_HEIGHT_PROPERTY, rowHeight, SCROLLS_ON_EXPAND_PROPERTY, scrollsOnExpand, SELECTION_MODEL_PROPERTY, selectionModel, selectionRedirector, SHOWS_ROOT_HANDLES_PROPERTY, showsRootHandles, TOGGLE_CLICK_COUNT_PROPERTY, toggleClickCount, TREE_MODEL_PROPERTY, treeModel, treeModelListener, VISIBLE_ROW_COUNT_PROPERTY, visibleRowCount
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
IlvDiagrammerTree()
          Creates a new Diagrammer tree with the default resource bundle "ilog.views.diagrammer.application.tree".
IlvDiagrammerTree(ResourceBundle bundle)
          Creates a new Diagrammer tree with the specified resource bundle.
 
Method Summary
 void addNotify()
           
 IlvDiagrammer getDiagrammer()
          Returns the diagram component to which this component is currently attached.
 Icon getIcon()
          Returns the icon to be used when this component is displayed in a frame.
 IlvDiagrammerHashFunction getIconHashFunction()
          Returns the object used to determine which objects will have the same icon in the tree.
 int getIconSize()
          Returns the size of the icons for the tree items representing the nodes and links.
 Icon getRootIcon()
          Returns the icon for the root of the tree.
 String getRootLabel()
          Returns the label for the root of the tree.
 String getTitle()
          Returns the title to be used when this component is displayed in a frame.
protected  String makeTreeNodeItemLabel(Object sdmObject, String labelProperty)
          Creates the tree item label for an SDM object.
 void removeNotify()
           
 void setDiagrammer(IlvDiagrammer diagrammer)
          Sets the diagram component to which this component is attached.
 void setIconHashFunction(IlvDiagrammerHashFunction iconHashFunction)
          Changes the object used to determine which objects will have the same icon in the tree.
 void setIconSize(int iconSize)
          Changes the size of the icons for the tree items representing the nodes and links.
 void setRootIcon(Icon rootIcon)
          Changes the icon for the root of the tree.
 void setRootLabel(String rootLabel)
          Changes the label for the root of the tree.
 void updateIcons()
          Resets the cache containing the icons of the tree items and repaints the tree.
 
Methods inherited from class javax.swing.JTree
addSelectionInterval, addSelectionPath, addSelectionPaths, addSelectionRow, addSelectionRows, addTreeExpansionListener, addTreeSelectionListener, addTreeWillExpandListener, cancelEditing, clearSelection, clearToggledPaths, collapsePath, collapseRow, convertValueToText, createTreeModel, createTreeModelListener, expandPath, expandRow, fireTreeCollapsed, fireTreeExpanded, fireTreeWillCollapse, fireTreeWillExpand, fireValueChanged, getAccessibleContext, getAnchorSelectionPath, getCellEditor, getCellRenderer, getClosestPathForLocation, getClosestRowForLocation, getDefaultTreeModel, getDescendantToggledPaths, getDragEnabled, getEditingPath, getExpandedDescendants, getExpandsSelectedPaths, getInvokesStopCellEditing, getLastSelectedPathComponent, getLeadSelectionPath, getLeadSelectionRow, getMaxSelectionRow, getMinSelectionRow, getModel, getNextMatch, getPathBetweenRows, getPathBounds, getPathForLocation, getPathForRow, getPreferredScrollableViewportSize, getRowBounds, getRowCount, getRowForLocation, getRowForPath, getRowHeight, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getScrollsOnExpand, getSelectionCount, getSelectionModel, getSelectionPath, getSelectionPaths, getSelectionRows, getShowsRootHandles, getToggleClickCount, getToolTipText, getTreeExpansionListeners, getTreeSelectionListeners, getTreeWillExpandListeners, getUI, getUIClassID, getVisibleRowCount, hasBeenExpanded, isCollapsed, isCollapsed, isEditable, isEditing, isExpanded, isExpanded, isFixedRowHeight, isLargeModel, isPathEditable, isPathSelected, isRootVisible, isRowSelected, isSelectionEmpty, isVisible, makeVisible, paramString, removeDescendantSelectedPaths, removeDescendantToggledPaths, removeSelectionInterval, removeSelectionPath, removeSelectionPaths, removeSelectionRow, removeSelectionRows, removeTreeExpansionListener, removeTreeSelectionListener, removeTreeWillExpandListener, scrollPathToVisible, scrollRowToVisible, setAnchorSelectionPath, setCellEditor, setCellRenderer, setDragEnabled, setEditable, setExpandedState, setExpandsSelectedPaths, setInvokesStopCellEditing, setLargeModel, setLeadSelectionPath, setModel, setRootVisible, setRowHeight, setScrollsOnExpand, setSelectionInterval, setSelectionModel, setSelectionPath, setSelectionPaths, setSelectionRow, setSelectionRows, setShowsRootHandles, setToggleClickCount, setUI, setVisibleRowCount, startEditingAtPath, stopEditing, treeDidChange, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IlvDiagrammerTree

public IlvDiagrammerTree(ResourceBundle bundle)
Creates a new Diagrammer tree with the specified resource bundle.

Parameters:
bundle - resource bundle

IlvDiagrammerTree

public IlvDiagrammerTree()
Creates a new Diagrammer tree with the default resource bundle "ilog.views.diagrammer.application.tree".

Method Detail

addNotify

public void addNotify()
Overrides:
addNotify in class JComponent

removeNotify

public void removeNotify()
Overrides:
removeNotify in class JComponent

setRootLabel

public void setRootLabel(String rootLabel)
Changes the label for the root of the tree.

Parameters:
rootLabel - The new label for the root.

getRootLabel

public String getRootLabel()
Returns the label for the root of the tree.

Returns:
root label

setRootIcon

public void setRootIcon(Icon rootIcon)
Changes the icon for the root of the tree.

Parameters:
rootIcon - The new icon for the root.

getRootIcon

public Icon getRootIcon()
Returns the icon for the root of the tree.

Returns:
root icon

getIconSize

public int getIconSize()
Returns the size of the icons for the tree items representing the nodes and links.

Returns:
icon size

setIconSize

public void setIconSize(int iconSize)
Changes the size of the icons for the tree items representing the nodes and links.

Parameters:
iconSize - The new icon size.

getDiagrammer

public IlvDiagrammer getDiagrammer()
Returns the diagram component to which this component is currently attached.

Returns:
attached diagrammer

setDiagrammer

public void setDiagrammer(IlvDiagrammer diagrammer)
Sets the diagram component to which this component is attached.

You do not usually need to call this method, because this component is attached automatically to the current diagram component of the Swing hierarchy.

Parameters:
diagrammer - The new diagram component to which this component is attached.

getIconHashFunction

public IlvDiagrammerHashFunction getIconHashFunction()
Returns the object used to determine which objects will have the same icon in the tree. See IlvDiagrammerHashFunction.

Returns:
an IlvDiagrammerHashFunction object.

setIconHashFunction

public void setIconHashFunction(IlvDiagrammerHashFunction iconHashFunction)
Changes the object used to determine which objects will have the same icon in the tree. See IlvDiagrammerHashFunction.

Parameters:
iconHashFunction - The new IlvDiagrammerHashFunction object.

updateIcons

public void updateIcons()
Resets the cache containing the icons of the tree items and repaints the tree. You can call this method when you change the style sheet of a diagram component, to make sure that the tree icons will reflect the new style.


getTitle

public String getTitle()
Returns the title to be used when this component is displayed in a frame.

Returns:
title

getIcon

public Icon getIcon()
Returns the icon to be used when this component is displayed in a frame.

Returns:
icon

makeTreeNodeItemLabel

protected String makeTreeNodeItemLabel(Object sdmObject,
                                       String labelProperty)
Creates the tree item label for an SDM object.

Parameters:
sdmObject - The SDM object to be displayed in the tree.
labelProperty - The label property.
Returns:
The label of the tree node.
Since:
JViews 8.0


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.