|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--edu.mit.ai.psg.ui.outliner.OutlineRendererDefault
|
+--edu.mit.ai.psg.ui.outliner.OutlineRendererCaching
Renderer which caches object, label, and tool tip text for better performance; useful when computing text isn't trivial, e.g., if it involves long computation or formatting.
To tailor rendering:
This class overrides OutlineRendererDefault.getObjectText(edu.mit.ai.psg.ui.outliner.OutlineNode),
OutlineRendererDefault.getLabelText(edu.mit.ai.psg.ui.outliner.OutlineNode), and
OutlineRendererDefault.getToolTipText(edu.mit.ai.psg.ui.outliner.OutlineNode) to cache results of calling
OutlineRendererDefault.computeObjectText(edu.mit.ai.psg.ui.outliner.OutlineNode), OutlineRendererDefault.computeLabelText(edu.mit.ai.psg.ui.outliner.OutlineNode), and
OutlineRendererDefault.computeToolTipText(edu.mit.ai.psg.ui.outliner.OutlineNode), respectively.
Thus, to customize rendering, derived classes should override
OutlineRendererDefault.computeObjectText(edu.mit.ai.psg.ui.outliner.OutlineNode), OutlineRendererDefault.computeLabelText(edu.mit.ai.psg.ui.outliner.OutlineNode), or
OutlineRendererDefault.computeToolTipText(edu.mit.ai.psg.ui.outliner.OutlineNode).
To tailor caching:
Caches are HashMapCaches so they don't prevent the garbage
collector from collecting keys nor text. Cache entries for an outline
node are decached When a new node is inserted (i.e., during rerendering),
so text will be recomputed in case it has changed.
getObjectTextCacheKey(edu.mit.ai.psg.ui.outliner.OutlineNode) is appropriate
when OutlineRendererDefault.computeObjectText(edu.mit.ai.psg.ui.outliner.OutlineNode) depends only on object, so results
are reused if renderered multiple places in the outlines.
If result also depends on OutlineNode state (e.g., text of path
from root), objectNode instead. (Alternatively, use
different renderers so each will have its own caches.)
getLabelTextCacheKey(edu.mit.ai.psg.ui.outliner.OutlineNode) is appropriate
when OutlineRendererDefault.computeLabelText(edu.mit.ai.psg.ui.outliner.OutlineNode) depends only on label, so results
are reused if renderered multiple places in the outlines.
If result also depends on OutlineNode state (e.g., depth from root,
or position in parent) objectNode instead.
getToolTipTextCacheKey(edu.mit.ai.psg.ui.outliner.OutlineNode)
is appropriate when OutlineRendererDefault.computeToolTipText(edu.mit.ai.psg.ui.outliner.OutlineNode) returns
the same text for all nodes, and should be overridden if
computeToolTipText is overridden to specialize result for each node.
makeObjectTextCache(), makeLabelTextCache(), or
makeToolTipTextCache(). If a cache is null, the corresponding
compute...Text will be called each time the text is needed,
as in OutlineRendererDefault.
| Inner classes inherited from class edu.mit.ai.psg.ui.outliner.OutlineRendererDefault |
OutlineRendererDefault.OutlineText |
| Inner classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
| Fields inherited from class edu.mit.ai.psg.ui.outliner.OutlineRendererDefault |
defaultToolTipText,
labelComponent,
myOutlineMaker,
objectComponent |
| 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 |
| Constructor Summary | |
OutlineRendererCaching(OutlineMaker outlineMakr)
|
|
| Method Summary | |
protected void |
decacheLabelText(OutlineNode node)
remove cache entry for this node, e.g., when rerendering node object |
protected void |
decacheObjectText(OutlineNode node)
remove cache entry for this node, e.g., when rerendering node object |
protected void |
decacheToolTipText(OutlineNode node)
remove cache entry for this node, e.g., when rerendering node object |
String |
getLabelText(OutlineNode node)
caches result of OutlineRendererDefault.computeLabelText(edu.mit.ai.psg.ui.outliner.OutlineNode) on key from
getLabelTextCacheKey(edu.mit.ai.psg.ui.outliner.OutlineNode). |
protected Object |
getLabelTextCacheKey(OutlineNode node)
get key for caching node label text: node.getLabel()
Derived classes may override this to return node
if text depends on state in node. |
String |
getObjectText(OutlineNode node)
caches result of OutlineRendererDefault.computeObjectText(edu.mit.ai.psg.ui.outliner.OutlineNode) on key from
getObjectTextCacheKey(edu.mit.ai.psg.ui.outliner.OutlineNode). |
protected Object |
getObjectTextCacheKey(OutlineNode node)
get key for caching node object text: node.getObject()
Derived classes may override this to return node
if text depends on state in node. |
String |
getToolTipText(OutlineNode node)
caches result of OutlineRendererDefault.computeToolTipText(edu.mit.ai.psg.ui.outliner.OutlineNode) on key from
getToolTipTextCacheKey(edu.mit.ai.psg.ui.outliner.OutlineNode). |
protected Object |
getToolTipTextCacheKey(OutlineNode node)
get key for caching node tool tip text: returns null
since default tooltip is same for all nodes. |
protected Map |
makeLabelTextCache()
For initializing cache for label text; override returning null to disable cache. |
protected Map |
makeObjectTextCache()
For initializing cache for object text; override returning null to disable cache. |
protected Map |
makeToolTipTextCache()
For initializing cache for tool tip text; override returning null to disable cache. |
void |
notifyInserted(OutlineModel model,
OutlineNode child,
int index)
notified after model inserts (adds) new child into parent at index; decaches old text in case new text is updated. |
| Methods inherited from class edu.mit.ai.psg.ui.outliner.OutlineRendererDefault |
addPopupMenuItems,
addPopupMenuTitle,
computeLabelText,
computeLabelText,
computeObjectText,
computeObjectText,
computeToolTipText,
equals,
getLabelComponent,
getObjectComponent,
getOutlineMaker,
getTreeCellRendererComponent,
isShowing,
makeChildOutlineNodes,
makeNoteOutlineNode,
makeOutlineNode,
makeOutlineNode,
notifyRemoving,
paint,
toString |
| Methods inherited from class java.awt.Container |
add,
add,
add,
add,
add,
addContainerListener,
addImpl,
countComponents,
deliverEvent,
doLayout,
findComponentAt,
findComponentAt,
getComponent,
getComponentAt,
getComponentAt,
getComponentCount,
getComponents,
getLayout,
insets,
invalidate,
isAncestorOf,
layout,
list,
list,
locate,
minimumSize,
paintComponents,
preferredSize,
print,
printComponents,
processContainerEvent,
processEvent,
remove,
remove,
removeAll,
removeContainerListener,
setCursor,
setLayout,
validate,
validateTree |
| Methods inherited from class java.lang.Object |
clone,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
| Constructor Detail |
public OutlineRendererCaching(OutlineMaker outlineMakr)
| Method Detail |
protected Map makeLabelTextCache()
new HashMapCache(1)protected Map makeObjectTextCache()
new HashMapCache(1)protected Map makeToolTipTextCache()
new HashMapCache(1)public String getLabelText(OutlineNode node)
OutlineRendererDefault.computeLabelText(edu.mit.ai.psg.ui.outliner.OutlineNode) on key from
getLabelTextCacheKey(edu.mit.ai.psg.ui.outliner.OutlineNode).public String getObjectText(OutlineNode node)
OutlineRendererDefault.computeObjectText(edu.mit.ai.psg.ui.outliner.OutlineNode) on key from
getObjectTextCacheKey(edu.mit.ai.psg.ui.outliner.OutlineNode).public String getToolTipText(OutlineNode node)
OutlineRendererDefault.computeToolTipText(edu.mit.ai.psg.ui.outliner.OutlineNode) on key from
getToolTipTextCacheKey(edu.mit.ai.psg.ui.outliner.OutlineNode).protected Object getLabelTextCacheKey(OutlineNode node)
node.getLabel()
Derived classes may override this to return node
if text depends on state in node.protected Object getObjectTextCacheKey(OutlineNode node)
node.getObject()
Derived classes may override this to return node
if text depends on state in node.protected Object getToolTipTextCacheKey(OutlineNode node)
null
since default tooltip is same for all nodes.
Derived classes may override this to return node.getObject()
or node if tooltip differs by object or node, respectively.
if text depends on state in node.protected void decacheLabelText(OutlineNode node)
protected void decacheObjectText(OutlineNode node)
protected void decacheToolTipText(OutlineNode node)
public void notifyInserted(OutlineModel model,
OutlineNode child,
int index)
|
Copyright (c) 1996-1999 Massachusetts Institute of Technology Feedback: jeva-feedback@ai.mit.edu |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||