freemind.modes
Class NodeAdapter

java.lang.Object
  extended byfreemind.modes.NodeAdapter
All Implemented Interfaces:
MindMapNode, javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode
Direct Known Subclasses:
BrowseNodeModel, FileNodeModel, MindMapNodeModel, SchemeNodeModel

public abstract class NodeAdapter
extends java.lang.Object
implements MindMapNode

This class represents a single Node of a Tree. It contains direct handles to its parent and children and to its view.


Field Summary
protected  java.awt.Color backgroundColor
           
protected  java.util.List children
           
protected  MindMapCloud cloud
          parameters of an eventually associated cloud
protected  java.awt.Color color
           
protected  boolean folded
           
protected  java.awt.Font font
           
static int HGAP
           
protected  java.util.Vector icons
          stores the icons associated with this node.
protected static java.util.logging.Logger logger
           
protected  java.util.TreeMap stateIcons
           
protected  java.lang.String style
           
protected  boolean underlined
           
protected  java.lang.Object userObject
           
static int VGAP
           
 
Fields inherited from interface freemind.modes.MindMapNode
AUTO, STYLE_AS_PARENT, STYLE_BUBBLE, STYLE_COMBINED, STYLE_FORK
 
Constructor Summary
protected NodeAdapter(FreeMindMain frame)
           
protected NodeAdapter(java.lang.Object userObject, FreeMindMain frame)
           
 
Method Summary
 PermanentNodeHook addHook(PermanentNodeHook hook)
          Adds the hook to the list of hooks to my node.
 void addIcon(MindIcon _icon)
           
protected  MindMapNode basicCopy()
           
 int calcShiftY()
           
 int calcVGap()
           
 java.util.Enumeration children()
          AFAIK there is no way to get an enumeration out of a linked list.
 java.util.ListIterator childrenFolded()
           
 java.util.ListIterator childrenUnfolded()
           
 void estabilishOwnFont()
           
 java.util.Collection getActivatedHooks()
           
 java.lang.String getAdditionalInfo()
           
 boolean getAllowsChildren()
           
 java.awt.Color getBackgroundColor()
           
 javax.swing.tree.TreeNode getChildAt(int childIndex)
           
 int getChildCount()
           
 int getChildPosition(MindMapNode childNode)
           
 MindMapCloud getCloud()
           
 java.awt.Color getColor()
          The Foreground/Font Color
 MindMapEdge getEdge()
           
 java.awt.Font getFont()
           
 java.lang.String getFontFamilyName()
           
 java.lang.String getFontSize()
           
 FreeMindMain getFrame()
           
 int getHGap()
           
 HistoryInformation getHistoryInformation()
           
 java.util.List getHooks()
           
 java.util.List getIcons()
          Is a vector of MindIcon s
 int getIndex(javax.swing.tree.TreeNode node)
           
 java.lang.String getLink()
           
 int getNodeLevel()
           
 java.lang.String getObjectId(ModeController controller)
           
 javax.swing.tree.TreeNode getParent()
           
 MindMapNode getParentNode()
           
 javax.swing.tree.TreePath getPath()
          Creates the TreePath recursively
 MindMapNode getPreferredChild()
           
 int getShiftY()
           
 java.lang.String getShortText(ModeController controller)
          returns a short textual description of the text contained in the node.
 java.util.Map getStateIcons()
          State icons are icons that are not saved.
 java.lang.String getStyle()
          A Node-Style like MindMapNode.STYLE_FORK or MindMapNode.STYLE_BUBBLE
 java.lang.String getText()
           
 java.util.Map getToolTip()
           
 int getVGap()
           
 NodeView getViewer()
           
 boolean hasChildren()
           
 boolean hasFoldedStrictDescendant()
          True iff one of node's strict descendants is folded.
 void insert(javax.swing.tree.MutableTreeNode child, int index)
           
 void invokeHook(NodeHook hook)
           
 boolean isBold()
           
 boolean isDescendantOf(MindMapNode node)
          Returns whether the argument is parent or parent of one of the grandpa's of this node.
 boolean isFolded()
           
 boolean isItalic()
           
 boolean isLeaf()
           
 Tools.BooleanHolder isLeft()
           
 boolean isOneLeftSideOfRoot()
          Root is on the right side.
 boolean isRoot()
           
 boolean isUnderlined()
           
 void remove(int index)
           
 void remove(javax.swing.tree.MutableTreeNode node)
           
 void removeFromParent()
           
 void removeHook(PermanentNodeHook hook)
          Removes the hook from the activated hooks, calls shutdown method of the hook and removes the hook from allHook belonging to the node afterwards.
 int removeLastIcon()
           
 XMLElement save(java.io.Writer writer, MindMapLinkRegistry registry)
           
 void setAdditionalInfo(java.lang.String info)
          This method can be used to store non-visual additions to a node.
 void setBackgroundColor(java.awt.Color color)
           
 void setBold(boolean bold)
           
 void setCloud(MindMapCloud cloud)
           
 void setColor(java.awt.Color color)
           
 void setEdge(MindMapEdge edge)
           
 void setFolded(boolean folded)
           
 void setFont(java.awt.Font font)
           
 void setFontSize(int fontSize)
           
 void setHGap(int gap)
           
 void setHistoryInformation(HistoryInformation historyInformation)
           
 void setItalic(boolean italic)
           
 void setLeft(boolean isLeft)
           
 void setLink(java.lang.String link)
           
 void setParent(MindMapNode newParent)
           
 void setParent(javax.swing.tree.MutableTreeNode newParent)
           
 void setPreferredChild(MindMapNode node)
           
 void setShiftY(int shiftY)
           
 void setStateIcon(java.lang.String key, javax.swing.ImageIcon icon)
          This method must be synchronized as the TreeMap isn't.
 void setStyle(java.lang.String style)
          currently the style may be one of MindMapNode.STYLE_BUBBLE or MindMapNode.STYLE_FORK.
 void setText(java.lang.String text)
           
 void setToolTip(java.lang.String key, java.lang.String string)
           
 void setUnderlined(boolean underlined)
           
 void setUserObject(java.lang.Object object)
           
 void setVGap(int gap)
           
 void setViewer(NodeView viewer)
           
 MindMapNode shallowCopy()
           
 void toggleBold()
           
 void toggleItalic()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HGAP

public static final int HGAP
See Also:
Constant Field Values

VGAP

public static final int VGAP
See Also:
Constant Field Values

userObject

protected java.lang.Object userObject

style

protected java.lang.String style

icons

protected java.util.Vector icons
stores the icons associated with this node.


stateIcons

protected java.util.TreeMap stateIcons

cloud

protected MindMapCloud cloud
parameters of an eventually associated cloud


color

protected java.awt.Color color

backgroundColor

protected java.awt.Color backgroundColor

folded

protected boolean folded

children

protected java.util.List children

font

protected java.awt.Font font

underlined

protected boolean underlined

logger

protected static java.util.logging.Logger logger
Constructor Detail

NodeAdapter

protected NodeAdapter(FreeMindMain frame)

NodeAdapter

protected NodeAdapter(java.lang.Object userObject,
                      FreeMindMain frame)
Method Detail

getText

public java.lang.String getText()
Specified by:
getText in interface MindMapNode

setText

public void setText(java.lang.String text)
Specified by:
setText in interface MindMapNode

getLink

public java.lang.String getLink()
Specified by:
getLink in interface MindMapNode

getShortText

public java.lang.String getShortText(ModeController controller)
Description copied from interface: MindMapNode
returns a short textual description of the text contained in the node. Html is filtered out.

Specified by:
getShortText in interface MindMapNode

setLink

public void setLink(java.lang.String link)
Specified by:
setLink in interface MindMapNode

getFrame

public FreeMindMain getFrame()

getViewer

public NodeView getViewer()
Specified by:
getViewer in interface MindMapNode

setViewer

public void setViewer(NodeView viewer)
Specified by:
setViewer in interface MindMapNode

getPath

public javax.swing.tree.TreePath getPath()
Creates the TreePath recursively

Specified by:
getPath in interface MindMapNode

getEdge

public MindMapEdge getEdge()
Specified by:
getEdge in interface MindMapNode

setEdge

public void setEdge(MindMapEdge edge)

getCloud

public MindMapCloud getCloud()
Specified by:
getCloud in interface MindMapNode

setCloud

public void setCloud(MindMapCloud cloud)
Specified by:
setCloud in interface MindMapNode

getStyle

public java.lang.String getStyle()
A Node-Style like MindMapNode.STYLE_FORK or MindMapNode.STYLE_BUBBLE

Specified by:
getStyle in interface MindMapNode

getColor

public java.awt.Color getColor()
The Foreground/Font Color

Specified by:
getColor in interface MindMapNode

setStyle

public void setStyle(java.lang.String style)
Description copied from interface: MindMapNode
currently the style may be one of MindMapNode.STYLE_BUBBLE or MindMapNode.STYLE_FORK.

Specified by:
setStyle in interface MindMapNode

setColor

public void setColor(java.awt.Color color)
Specified by:
setColor in interface MindMapNode

getBackgroundColor

public java.awt.Color getBackgroundColor()
Specified by:
getBackgroundColor in interface MindMapNode

setBackgroundColor

public void setBackgroundColor(java.awt.Color color)
Specified by:
setBackgroundColor in interface MindMapNode

estabilishOwnFont

public void estabilishOwnFont()

setBold

public void setBold(boolean bold)

toggleBold

public void toggleBold()

setItalic

public void setItalic(boolean italic)

toggleItalic

public void toggleItalic()

setUnderlined

public void setUnderlined(boolean underlined)

setFont

public void setFont(java.awt.Font font)
Specified by:
setFont in interface MindMapNode

getParentNode

public MindMapNode getParentNode()
Specified by:
getParentNode in interface MindMapNode

setFontSize

public void setFontSize(int fontSize)
Specified by:
setFontSize in interface MindMapNode

getFont

public java.awt.Font getFont()
Specified by:
getFont in interface MindMapNode

getFontSize

public java.lang.String getFontSize()
Specified by:
getFontSize in interface MindMapNode

getFontFamilyName

public java.lang.String getFontFamilyName()
Specified by:
getFontFamilyName in interface MindMapNode

isBold

public boolean isBold()
Specified by:
isBold in interface MindMapNode

isItalic

public boolean isItalic()
Specified by:
isItalic in interface MindMapNode

isUnderlined

public boolean isUnderlined()
Specified by:
isUnderlined in interface MindMapNode

isFolded

public boolean isFolded()
Specified by:
isFolded in interface MindMapNode

getIcons

public java.util.List getIcons()
Description copied from interface: MindMapNode
Is a vector of MindIcon s

Specified by:
getIcons in interface MindMapNode

addIcon

public void addIcon(MindIcon _icon)
Specified by:
addIcon in interface MindMapNode

removeLastIcon

public int removeLastIcon()
Specified by:
removeLastIcon in interface MindMapNode
Returns:
returns the number of remaining icons.

hasFoldedStrictDescendant

public boolean hasFoldedStrictDescendant()
True iff one of node's strict descendants is folded. A node N is not its strict descendant - the fact that node itself is folded is not sufficient to return true.


setFolded

public void setFolded(boolean folded)
Specified by:
setFolded in interface MindMapNode

basicCopy

protected MindMapNode basicCopy()

shallowCopy

public MindMapNode shallowCopy()
Specified by:
shallowCopy in interface MindMapNode

toString

public java.lang.String toString()
Specified by:
toString in interface MindMapNode

isDescendantOf

public boolean isDescendantOf(MindMapNode node)
Returns whether the argument is parent or parent of one of the grandpa's of this node. (transitive)

Specified by:
isDescendantOf in interface MindMapNode

isRoot

public boolean isRoot()
Specified by:
isRoot in interface MindMapNode

hasChildren

public boolean hasChildren()
Specified by:
hasChildren in interface MindMapNode

getChildPosition

public int getChildPosition(MindMapNode childNode)
Specified by:
getChildPosition in interface MindMapNode
Returns:
-1 if the argument childNode is not a child.

childrenUnfolded

public java.util.ListIterator childrenUnfolded()
Specified by:
childrenUnfolded in interface MindMapNode
Returns:
returns a ListIterator of all (and not only the unfolded ones!!) children of the node.

childrenFolded

public java.util.ListIterator childrenFolded()
Specified by:
childrenFolded in interface MindMapNode
Returns:
returns a ListIterator of all children of the node if the node is unfolded. EMPTY_LIST_ITERATOR otherwise.

children

public java.util.Enumeration children()
AFAIK there is no way to get an enumeration out of a linked list. So this exception must be thrown, or we can't implement TreeNode anymore (maybe we shouldn't?)

Specified by:
children in interface javax.swing.tree.TreeNode

getAllowsChildren

public boolean getAllowsChildren()
Specified by:
getAllowsChildren in interface javax.swing.tree.TreeNode

getChildAt

public javax.swing.tree.TreeNode getChildAt(int childIndex)
Specified by:
getChildAt in interface javax.swing.tree.TreeNode

getChildCount

public int getChildCount()
Specified by:
getChildCount in interface javax.swing.tree.TreeNode

getIndex

public int getIndex(javax.swing.tree.TreeNode node)
Specified by:
getIndex in interface javax.swing.tree.TreeNode

getParent

public javax.swing.tree.TreeNode getParent()
Specified by:
getParent in interface javax.swing.tree.TreeNode

isLeaf

public boolean isLeaf()
Specified by:
isLeaf in interface javax.swing.tree.TreeNode

isLeft

public Tools.BooleanHolder isLeft()
Specified by:
isLeft in interface MindMapNode

isOneLeftSideOfRoot

public boolean isOneLeftSideOfRoot()
Description copied from interface: MindMapNode
Root is on the right side.

Specified by:
isOneLeftSideOfRoot in interface MindMapNode
Returns:

setLeft

public void setLeft(boolean isLeft)
Specified by:
setLeft in interface MindMapNode

insert

public void insert(javax.swing.tree.MutableTreeNode child,
                   int index)
Specified by:
insert in interface javax.swing.tree.MutableTreeNode

remove

public void remove(int index)
Specified by:
remove in interface javax.swing.tree.MutableTreeNode

remove

public void remove(javax.swing.tree.MutableTreeNode node)
Specified by:
remove in interface javax.swing.tree.MutableTreeNode

getPreferredChild

public MindMapNode getPreferredChild()
Specified by:
getPreferredChild in interface MindMapNode

setPreferredChild

public void setPreferredChild(MindMapNode node)
Specified by:
setPreferredChild in interface MindMapNode

removeFromParent

public void removeFromParent()
Specified by:
removeFromParent in interface javax.swing.tree.MutableTreeNode

setParent

public void setParent(javax.swing.tree.MutableTreeNode newParent)
Specified by:
setParent in interface javax.swing.tree.MutableTreeNode

setParent

public void setParent(MindMapNode newParent)

setUserObject

public void setUserObject(java.lang.Object object)
Specified by:
setUserObject in interface javax.swing.tree.MutableTreeNode

getNodeLevel

public int getNodeLevel()
Specified by:
getNodeLevel in interface MindMapNode

addHook

public PermanentNodeHook addHook(PermanentNodeHook hook)
Description copied from interface: MindMapNode
Adds the hook to the list of hooks to my node. Does not invoke the hook!

Specified by:
addHook in interface MindMapNode
Parameters:
hook -
Returns:
returns the input parameter hook

invokeHook

public void invokeHook(NodeHook hook)
Specified by:
invokeHook in interface MindMapNode

getHooks

public java.util.List getHooks()
Specified by:
getHooks in interface MindMapNode

getActivatedHooks

public java.util.Collection getActivatedHooks()
Specified by:
getActivatedHooks in interface MindMapNode

removeHook

public void removeHook(PermanentNodeHook hook)
Description copied from interface: MindMapNode
Removes the hook from the activated hooks, calls shutdown method of the hook and removes the hook from allHook belonging to the node afterwards.

Specified by:
removeHook in interface MindMapNode

getToolTip

public java.util.Map getToolTip()
Specified by:
getToolTip in interface MindMapNode
Returns:

setToolTip

public void setToolTip(java.lang.String key,
                       java.lang.String string)
Specified by:
setToolTip in interface MindMapNode
Parameters:
string -

getObjectId

public java.lang.String getObjectId(ModeController controller)
Specified by:
getObjectId in interface MindMapNode
Returns:
returns the unique id of the node. It is generated using the LinkRegistry.

save

public XMLElement save(java.io.Writer writer,
                       MindMapLinkRegistry registry)
                throws java.io.IOException
Specified by:
save in interface MindMapNode
Throws:
java.io.IOException

getShiftY

public int getShiftY()
Specified by:
getShiftY in interface MindMapNode

calcShiftY

public int calcShiftY()
Specified by:
calcShiftY in interface MindMapNode

setShiftY

public void setShiftY(int shiftY)
Specified by:
setShiftY in interface MindMapNode
Parameters:
shiftY - The shiftY to set.

setAdditionalInfo

public void setAdditionalInfo(java.lang.String info)
Description copied from interface: MindMapNode
This method can be used to store non-visual additions to a node. Currently, it is used for encrypted nodes to store the encrypted content.

Specified by:
setAdditionalInfo in interface MindMapNode
Parameters:
info -

getAdditionalInfo

public java.lang.String getAdditionalInfo()
Specified by:
getAdditionalInfo in interface MindMapNode

setStateIcon

public void setStateIcon(java.lang.String key,
                         javax.swing.ImageIcon icon)
This method must be synchronized as the TreeMap isn't.

Specified by:
setStateIcon in interface MindMapNode
Parameters:
key -
icon - use null to remove the state icon. Then it is not required, that the key already exists.

getStateIcons

public java.util.Map getStateIcons()
Description copied from interface: MindMapNode
State icons are icons that are not saved. They indicate that this node is special.

Specified by:
getStateIcons in interface MindMapNode
Returns:

getHistoryInformation

public HistoryInformation getHistoryInformation()
Specified by:
getHistoryInformation in interface MindMapNode

setHistoryInformation

public void setHistoryInformation(HistoryInformation historyInformation)
Specified by:
setHistoryInformation in interface MindMapNode

getHGap

public int getHGap()
Specified by:
getHGap in interface MindMapNode

setHGap

public void setHGap(int gap)
Specified by:
setHGap in interface MindMapNode

getVGap

public int getVGap()
Specified by:
getVGap in interface MindMapNode

calcVGap

public int calcVGap()
Specified by:
calcVGap in interface MindMapNode

setVGap

public void setVGap(int gap)
Specified by:
setVGap in interface MindMapNode