NodeAdapter.java

Index Score
freemind.modes
FreeMind

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
LINE_COMMENTNumber of line comments
DECL_COMMENTSComments in declarations
FUNCTIONSNumber of function declarations
CYCLOMATICCyclomatic complexity
RETURNSNumber of return points from functions
EXEC_COMMENTSComments in executable code
JAVA0034JAVA0034 Missing braces in if statement
EXITSProcedure exits
BLOCKSNumber of blocks
COMPARISONSNumber of comparison operators
INTERFACE_COMPLEXITYInterface complexity
OPERATORSNumber of operators
LOGICAL_LINESNumber of statements
PROGRAM_LENGTHHalstead program length
ELOCEffective lines of code
LOCLines of code
SIZESize of the file in bytes
LINESNumber of lines in the source file
UNIQUE_OPERANDSNumber of unique operands
PROGRAM_VOCABHalstead program vocabulary
OPERANDSNumber of operands
JAVA0254JAVA0254 Use enhanced for loop construct instead of Iterator
PARAMSNumber of formal parameter declarations
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
JAVA0153JAVA0153 Inefficient conversion of integer to string
LOOPSNumber of loops
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0179JAVA0179 Local variable hides visible field
WHITESPACENumber of whitespace lines
JAVA0068JAVA0068 Modifiers not declared in recommended order
COMMENTSComment lines
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0064JAVA0064 N variations of identifier name (maximum: M)
JAVA0177JAVA0177 Variable declaration missing initializer
JAVA0143JAVA0143 Synchronized method
UNIQUE_OPERATORSNumber of unique operators
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0030JAVA0030 Private field not used
JAVA0265JAVA0265 Use of Throwable.printStackTrace()
JAVA0100JAVA0100 Class contains N non-final fields (maximum: M)
/*FreeMind - A Program for creating and viewing Mindmaps *Copyright (C) 2000-2001 Joerg Mueller <joergmueller@bigfoot.com> *See COPYING for Details * *This program is free software; you can redistribute it and/or *modify it under the terms of the GNU General Public License *as published by the Free Software Foundation; either version 2 *of the License, or (at your option) any later version. * *This program is distributed in the hope that it will be useful, *but WITHOUT ANY WARRANTY; without even the implied warranty of *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *GNU General Public License for more details. * *You should have received a copy of the GNU General Public License *along with this program; if not, write to the Free Software *Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /*$Id: NodeAdapter.java,v 1.21 2007/08/07 17:37:26 dpolivaev Exp $*/ package freemind.modes; import java.awt.Color; import java.awt.Font; import java.io.IOException; import java.io.Writer; import java.util.Collection; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.TreeMap; import java.util.Vector; import javax.swing.ImageIcon; import javax.swing.tree.MutableTreeNode; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; import freemind.extensions.NodeHook; import freemind.extensions.PermanentNodeHook; import freemind.main.FreeMind; import freemind.main.FreeMindMain; import freemind.main.Tools; import freemind.main.XMLElement; import freemind.view.mindmapview.NodeView; /** * This class represents a single Node of a Tree. It contains direct handles * to its parent and children and to its view. */ public abstract class NodeAdapter implements MindMapNode { final static int SHIFT = -2;//height of the vertical shift between node and its closest child public final static int HGAP = 20;//width of the horizontal gap that contains the edges public final static int VGAP = 3;//height of the vertical gap between nodes private HashSet activatedHooks; private List hooks; protected Object userObject = "no text"; private String link = null; //Change this to vector in future for full graph support private HashMap toolTip = null; // lazy, fc, 30.6.2005 //these Attributes have default values, so it can be useful to directly access them in //the save() method instead of using getXXX(). This way the stored file is smaller and looks better. //(if the default is used, it is not stored) Look at mindmapmode for an example. protected String style; /**stores the icons associated with this node.*/ protected Vector/*<MindIcon>*/ icons = null; // lazy, fc, 30.6.2005 protected TreeMap /* of String to MindIcon s*/ stateIcons = null; // lazy, fc, 30.6.2005 // /**stores the label associated with this node:*/ // protected String mLabel; /** parameters of an eventually associated cloud*/ protected MindMapCloud cloud; protected Color color; protected Color backgroundColor; protected boolean folded; private Tools.BooleanHolder left; private int vGap = AUTO; private int hGap = HGAP; private int shiftY = 0; protected List children; private MindMapNode preferredChild; protected Font font; protected boolean underlined = false; private MindMapNode parent; private MindMapEdge edge;//the edge which leads to this node, only root has none //In future it has to hold more than one view, maybe with a Vector in which the index specifies //the MapView which contains the NodeViews private NodeView viewer = null; private FreeMindMain frame; private static final boolean ALLOWSCHILDREN = true; private static final boolean ISLEAF = false; //all nodes may have children private HistoryInformation historyInformation = null; // Logging: static protected java.util.logging.Logger logger; // // Constructors // protected NodeAdapter(FreeMindMain frame) { this(null, frame); } protected NodeAdapter(Object userObject, FreeMindMain frame) { this.userObject = userObject; this.frame = frame; hooks = null; // lazy, fc, 30.6.2005. activatedHooks = null; //lazy, fc, 30.6.2005 if(logger == null) logger = frame.getLogger(this.getClass().getName()); // create creation time: setHistoryInformation(new HistoryInformation()); } /** * */ public String getText() { return toString(); } /** * */ public void setText(String text) { setUserObject(text); } public String getLink() { return link; } public String getShortText(ModeController controller) { String adaptedText = toString(); adaptedText = adaptedText.replaceAll("<html>", ""); if (adaptedText.length() > 40) adaptedText = adaptedText.substring(0, 40) + " ..."; return adaptedText; } public void setLink(String link) { this.link = link; } public FreeMindMain getFrame() { return frame; } // // Interface MindMapNode // // // get/set methods // public NodeView getViewer() { return viewer; } public void setViewer( NodeView viewer ) { this.viewer = viewer; } /** Creates the TreePath recursively */ public TreePath getPath() { Vector pathVector = new Vector(); TreePath treePath; this.addToPathVector( pathVector ); treePath = new TreePath( pathVector.toArray() ); return treePath; } public MindMapEdge getEdge() { return edge; } public void setEdge( MindMapEdge edge ) { this.edge = edge; } public MindMapCloud getCloud() { return cloud; } public void setCloud( MindMapCloud cloud ) { // Take care to keep the calculated iterative levels consistent if (cloud != null && this.cloud == null) { changeChildCloudIterativeLevels(1); } else if (cloud == null && this.cloud != null) { changeChildCloudIterativeLevels(-1); } this.cloud = cloud; } /** * Correct iterative level values of children */ private void changeChildCloudIterativeLevels(int deltaLevel) { for (ListIterator e = childrenUnfolded(); e.hasNext(); ) { NodeAdapter childNode = (NodeAdapter)e.next(); MindMapCloud childCloud = childNode.getCloud(); if (childCloud != null) { childCloud.changeIterativeLevel(deltaLevel); } childNode.changeChildCloudIterativeLevels(deltaLevel); } } /**A Node-Style like MindMapNode.STYLE_FORK or MindMapNode.STYLE_BUBBLE*/ public String getStyle() { String returnedString = style; /* Style string returned */ if (style==null) { if (this.isRoot()) { returnedString=getFrame().getProperty(FreeMind.RESOURCES_ROOT_NODE_STYLE); } else{ String stdstyle = getFrame().getProperty(FreeMind.RESOURCES_NODE_STYLE); if( stdstyle.equals(MindMapNode.STYLE_AS_PARENT)){ returnedString=getParentNode().getStyle(); } else{ returnedString = stdstyle; } } } else if (this.isRoot() && style.equals(MindMapNode.STYLE_AS_PARENT)) { returnedString = getFrame().getProperty(FreeMind.RESOURCES_ROOT_NODE_STYLE); } else if( style.equals(MindMapNode.STYLE_AS_PARENT)){ returnedString = getParentNode().getStyle(); } // Handle the combined node style if (returnedString.equals(MindMapNode.STYLE_COMBINED)) { if (this.isFolded()){ return MindMapNode.STYLE_BUBBLE; } else{ return MindMapNode.STYLE_FORK; } } return returnedString; } /**The Foreground/Font Color*/ public Color getColor() { return color; } ////// // The set methods. I'm not sure if they should be here or in the implementing class. ///// public void setStyle(String style) { this.style = style; } public void setColor(Color color) { this.color = color; } //fc, 24.2.2004: background color: public Color getBackgroundColor( ) { return backgroundColor; }; public void setBackgroundColor(Color color) { this.backgroundColor = color; }; // // font handling // // Remark to setBold and setItalic implemetation // // Using deriveFont() is a bad idea, because it does not really choose // the appropriate face. For example, instead of choosing face // "Arial Bold", it derives the bold face from "Arial". // Node holds font only in the case that the font is not default. public void estabilishOwnFont() { font = (font != null) ? font : getFrame().getController().getDefaultFont(); } public void setBold(boolean bold) { if (bold != isBold()) { toggleBold(); }} public void toggleBold() { estabilishOwnFont(); setFont(getFrame().getController().getFontThroughMap (new Font(font.getFamily(), font.getStyle() ^ Font.BOLD, font.getSize()))); } public void setItalic(boolean italic) { if (italic != isItalic()) { toggleItalic(); }} public void toggleItalic() { estabilishOwnFont(); setFont(getFrame().getController().getFontThroughMap (new Font(font.getFamily(), font.getStyle() ^ Font.ITALIC, font.getSize()))); } public void setUnderlined(boolean underlined) { this.underlined = underlined; } public void setFont(Font font) { this.font = font; } public MindMapNode getParentNode() { return parent; } public void setFontSize(int fontSize) { estabilishOwnFont(); setFont(getFrame().getController().getFontThroughMap (new Font(font.getFamily(), font.getStyle(), fontSize))); } public Font getFont() { return font; } public String getFontSize(){ if (getFont() != null){ return new Integer (getFont().getSize()).toString();} else { return getFrame().getProperty("defaultfontsize");} } public String getFontFamilyName(){ if (getFont() != null){ return getFont().getFamily();} else { return getFrame().getProperty("defaultfont");} } public boolean isBold() { return font != null ? font.isBold() : false; } public boolean isItalic() { return font != null ? font.isItalic() : false; } public boolean isUnderlined() { // not implemented return underlined; } public boolean isFolded() { return folded; } // fc, 24.9.2003: public List getIcons() { if(icons==null) return Collections.EMPTY_LIST; return icons; } public void addIcon(MindIcon _icon) { createIcons(); icons.add(_icon); } /** @return returns the number of remaining icons. */ public int removeLastIcon() { createIcons(); if (icons.size() > 0) icons.setSize(icons.size() - 1); int returnSize = icons.size(); if(returnSize==0) { icons = null; } return returnSize; }; // end, fc, 24.9.2003 // public String getLabel() { return mLabel; } // public void setLabel(String newLabel) { mLabel = newLabel; /* bad hack: registry fragen.*/ }; // public Vector/* of NodeLinkStruct*/ getReferences() { return mNodeLinkVector; }; // public void removeReferenceAt(int i) { // if(mNodeLinkVector.size() > i) { // mNodeLinkVector.removeElementAt(i); // } else { // /* exception. */ // } // } // public void addReference(MindMapLink mindMapLink) { mNodeLinkVector.add(mindMapLink); }; /** * True iff one of node's <i>strict</i> descendants is folded. A node N * is not its strict descendant - the fact that node itself is folded * is not sufficient to return true. */ public boolean hasFoldedStrictDescendant() { for (ListIterator e = childrenUnfolded(); e.hasNext(); ) { NodeAdapter child = (NodeAdapter)e.next(); if (child.isFolded() || child.hasFoldedStrictDescendant()) { return true; }} return false; } public void setFolded(boolean folded) { this.folded = folded; } protected MindMapNode basicCopy() { return null; } public MindMapNode shallowCopy() { MindMapNode copy = basicCopy(); copy.setColor(getColor()); copy.setFont(getFont()); copy.setLink(getLink()); if(isLeft() != null) copy.setLeft(isLeft().getValue()); List icons = getIcons(); for(int i = 0; i < icons.size(); ++i) { copy.addIcon((MindIcon) icons.get(i)); } return copy; } // // other // public String toString() { String string=""; if (userObject!=null) { string = userObject.toString(); } // (PN) %%% // Why? If because of presentation, this level shall be self responsible... // Model shall NOT change the real data!!! // // if (string.equals("")) { // string = " "; // } return string; } /** * Returns whether the argument is parent * or parent of one of the grandpa's of this node. * (transitive) */ public boolean isDescendantOf(MindMapNode node) { if(this.isRoot()) return false; else if (node == getParentNode()) return true; else return getParentNode().isDescendantOf(node); } public boolean isRoot() { return (parent==null); } public boolean hasChildren() { return children != null && !children.isEmpty(); } public int getChildPosition(MindMapNode childNode) { int position = 0; for (ListIterator i=children.listIterator(); i.hasNext(); ++position) { if (((MindMapNode)i.next()) == childNode) { return position; }} return -1; } public ListIterator childrenUnfolded() { return children != null ? children.listIterator() : Collections.EMPTY_LIST.listIterator(); } public ListIterator childrenFolded() { if (isFolded()) { return Collections.EMPTY_LIST.listIterator(); } return childrenUnfolded(); } // // Interface TreeNode // /** * 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?) */ public Enumeration children() { throw new UnsupportedOperationException("Use childrenFolded or childrenUnfolded instead"); } public boolean getAllowsChildren() { return ALLOWSCHILDREN; } public TreeNode getChildAt(int childIndex) { // fc, 11.12.2004: This is not understandable, that a child does not // exist if the parent is folded. // if (isFolded()) { // return null; // } return (TreeNode) children.get(childIndex); } public int getChildCount() { return children == null ? 0 : children.size(); } // (PN) // public int getChildCount() { // if (isFolded()) { // return 0; // } // return children.size(); // } // // Daniel: ^ The name of this method is confusing. It does nto convey // // the meaning, at least not to me. public int getIndex( TreeNode node ) { return children.indexOf( (MindMapNode)node ); //uses equals() } public TreeNode getParent() { return parent; } public boolean isLeaf() { return getChildCount() == 0; } // fc, 16.12.2003 left-right bug: public Tools.BooleanHolder isLeft() { return left; } /* (non-Javadoc) * @see freemind.modes.MindMapNode#isOneLeftSideOfRoot() */ public boolean isOneLeftSideOfRoot() { if(isRoot()) return false; // now, the node has a parent: if(getParentNode().isRoot()) { return (isLeft() == null)?false:isLeft().getValue(); } return getParentNode().isOneLeftSideOfRoot(); } public void setLeft(boolean isLeft){ if(left == null) left = new Tools.BooleanHolder(); left.setValue(isLeft); } // // Interface MutableTreeNode // //do all remove methods have to work recursively to make the //Garbage Collection work (Nodes in removed Sub-Trees reference each other)? public void insert( MutableTreeNode child, int index) { logger.finest("Insert at " + index + " the node "+child); if (index < 0) { // add to the end (used in xml load) (PN) index = getChildCount(); children.add( index, child ); } else { // mind preferred child :-) children.add( index, child ); preferredChild = (MindMapNode)child; } child.setParent( this ); } public void remove( int index ) { MutableTreeNode node = (MutableTreeNode)children.get(index); remove(node); } public void remove( MutableTreeNode node ) { if (node == this.preferredChild) { // mind preferred child :-) (PN) int index = children.indexOf(node); if (children.size() > index + 1) { this.preferredChild = (MindMapNode)(children.get(index + 1)); } else { this.preferredChild = (index > 0) ? (MindMapNode)(children.get(index - 1)) : null; } } node.setParent(null); children.remove( node ); // call remove child hook after removal. recursiveCallRemoveChildren(this, (MindMapNode) node, this); } /** * @param node * @param oldDad the last dad node had. */ private void recursiveCallRemoveChildren(MindMapNode node, MindMapNode removedChild, MindMapNode oldDad) { for(Iterator i= node.getActivatedHooks().iterator(); i.hasNext();) { PermanentNodeHook hook = (PermanentNodeHook) i.next(); if (removedChild.getParentNode() == node) { hook.onRemoveChild(removedChild); } hook.onRemoveChildren(removedChild, oldDad); } if(!node.isRoot() && node.getParentNode()!= null) recursiveCallRemoveChildren(node.getParentNode(), removedChild, oldDad); } public MindMapNode getPreferredChild() { // mind preferred child :-) (PN) if (this.children.contains(this.preferredChild)) { return this.preferredChild; } else if (!isLeaf()) { return (MindMapNode)(this.children.get((getChildCount() + 1) / 2 - 1)); } else { return null; } } public void setPreferredChild(MindMapNode node) { this.preferredChild = node; if (node == null) { return; } else if (this.parent != null) { // set also preffered child of parents... this.parent.setPreferredChild(this); } } public void removeFromParent() { parent.remove( this ); } public void setParent( MutableTreeNode newParent ) { parent = (MindMapNode) newParent; } public void setParent( MindMapNode newParent ) { parent = newParent; } public void setUserObject( Object object ) { userObject = object; } //////////////// // Private methods. Internal Implementation ////////////// /** Recursive Method for getPath() */ private void addToPathVector( Vector pathVector ) { pathVector.add( 0, this ); //Add myself to beginning of Vector if ( parent != null ) { ( (NodeAdapter)parent ).addToPathVector( pathVector ); } } public int getNodeLevel() { //for cursor navigation within a level (PN) int level = 0; MindMapNode parent; for (parent = this; !parent.isRoot(); parent = parent.getParentNode()) { level++; } return level; } /* (non-Javadoc) * @see freemind.modes.MindMapNode#addHook(freemind.modes.NodeHook) */ public PermanentNodeHook addHook(PermanentNodeHook hook) { // add then if(hook == null) throw new IllegalArgumentException("Added null hook."); createHooks(); hooks.add(hook); return hook; } public void invokeHook(NodeHook hook) { // initialize: hook.startupMapHook(); // the main invocation: hook.setNode(this); try { hook.invoke(this); } catch (Exception e) { //FIXME: Do something special here, but in any case, do not add the hook // to the activatedHooks: e.printStackTrace(); return; } if (hook instanceof PermanentNodeHook) { createActivatedHooks(); activatedHooks.add(hook); } else { // end of its short life: hook.shutdownMapHook(); } } private void createActivatedHooks() { if(activatedHooks == null) { activatedHooks = new HashSet(); } } private void createToolTip() { if(toolTip == null) { toolTip = new HashMap(); } } private void createHooks() { if(hooks == null) { hooks = new Vector(); } } private void createStateIcons() { if(stateIcons == null) { stateIcons = new TreeMap(); } } private void createIcons() { if(icons == null) { icons = new Vector(); } } /* (non-Javadoc) * @see freemind.modes.MindMapNode#getHooks() */ public List getHooks() { if(hooks==null) return Collections.EMPTY_LIST; return Collections.unmodifiableList(hooks); } /* (non-Javadoc) * @see freemind.modes.MindMapNode#getActivatedHooks() */ public Collection getActivatedHooks() { if(activatedHooks==null) { return Collections.EMPTY_LIST; } return Collections.unmodifiableCollection(activatedHooks); } /* (non-Javadoc) * @see freemind.modes.MindMapNode#removeHook(freemind.modes.NodeHook) */ public void removeHook(PermanentNodeHook hook) { // the order is crucial here: the shutdown method should be able to perform "nodeChanged" // calls without having its own updateNodeHook method to be called again. createActivatedHooks(); activatedHooks.remove(hook); if(activatedHooks.size()==0) { activatedHooks=null; } hook.shutdownMapHook(); createHooks(); hooks.remove(hook); if(hooks.size()==0) hooks=null; } /** * @return */ public java.util.Map getToolTip() { if(toolTip==null) return Collections.EMPTY_MAP; return Collections.unmodifiableMap(toolTip); } /** * @param string */ public void setToolTip(String key, String string) { createToolTip(); if (string == null) { if (toolTip.containsKey(key)) { toolTip.remove(key); } if(toolTip.size()==0) toolTip=null; } else { toolTip.put(key, string); } } /* (non-Javadoc) * @see freemind.modes.MindMapNode#getNodeId() */ public String getObjectId(ModeController controller) { return controller.getNodeID(this); } public XMLElement save(Writer writer, MindMapLinkRegistry registry) throws IOException { XMLElement node = new XMLElement(); // if (!isNodeClassToBeSaved()) { node.setName(XMLElementAdapter.XML_NODE); // } else { // node.setName(XMLElementAdapter.XML_NODE_CLASS_PREFIX // + this.getClass().getName()); // } /** fc, 12.6.2005: XML must not contain any zero characters. */ String text = this.toString().replace('\0', ' '); node.setAttribute(XMLElementAdapter.XML_NODE_TEXT,text); // save additional info: if (getAdditionalInfo() != null) { node.setAttribute(XMLElementAdapter.XML_NODE_ENCRYPTED_CONTENT, getAdditionalInfo()); } // ((MindMapEdgeModel)getEdge()).save(doc,node); XMLElement edge = (getEdge()).save(); if (edge != null) { node.addChild(edge); } if(getCloud() != null) { XMLElement cloud = (getCloud()).save(); node.addChild(cloud); } Vector linkVector = registry.getAllLinksFromMe(this); /* Puh... */ for(int i = 0; i < linkVector.size(); ++i) { if(linkVector.get(i) instanceof ArrowLinkAdapter) { XMLElement arrowLinkElement = ((ArrowLinkAdapter) linkVector.get(i)).save(); node.addChild(arrowLinkElement); } } if (isFolded()) { node.setAttribute("FOLDED","true"); } // fc, 17.12.2003: Remove the left/right bug. // VVV save if and only if parent is root. if ((isLeft()!= null) && !(isRoot()) && (getParentNode().isRoot())) { node.setAttribute("POSITION",(isLeft().getValue())?"left":"right"); } String label = registry.getLabel(this); /* Puh... */ if (label!=null) { node.setAttribute("ID",label); } if (color != null) { node.setAttribute("COLOR", Tools.colorToXml(getColor())); } // new background color. if (getBackgroundColor() != null) { node.setAttribute("BACKGROUND_COLOR", Tools.colorToXml(getBackgroundColor())); } if (style != null) { node.setAttribute("STYLE", this.getStyle()); } // ^ Here cannot be just getStyle() without super. This is because // getStyle's style depends on folded / unfolded. For example, when // real style is fork and node is folded, getStyle returns // MindMapNode.STYLE_BUBBLE, which is not what we want to save. //layout if(vGap != AUTO) { node.setAttribute("VGAP",Integer.toString(vGap)); } if(hGap != HGAP) { node.setAttribute("HGAP",Integer.toString(hGap)); } if(shiftY != 0) { node.setAttribute("VSHIFT",Integer.toString(shiftY)); } //link if (getLink() != null) { node.setAttribute("LINK", getLink()); } //history information, fc, 11.4.2005 if (historyInformation != null) { node.setAttribute(XMLElementAdapter.XML_NODE_HISTORY_CREATED_AT, Tools.dateToString(getHistoryInformation().getCreatedAt())); node.setAttribute( XMLElementAdapter.XML_NODE_HISTORY_LAST_MODIFIED_AT, Tools .dateToString(getHistoryInformation() .getLastModifiedAt())); } //font if (font!=null) { XMLElement fontElement = new XMLElement(); fontElement.setName("font"); if (font != null) { fontElement.setAttribute("NAME",font.getFamily()); } if (font.getSize() != 0) { fontElement.setAttribute("SIZE",Integer.toString(font.getSize())); } if (isBold()) { fontElement.setAttribute("BOLD","true"); } if (isItalic()) { fontElement.setAttribute("ITALIC","true"); } if (isUnderlined()) { fontElement.setAttribute("UNDERLINE","true"); } node.addChild(fontElement); } for(int i = 0; i < getIcons().size(); ++i) { XMLElement iconElement = new XMLElement(); iconElement.setName("icon"); iconElement.setAttribute("BUILTIN", ((MindIcon) getIcons().get(i)).getName()); node.addChild(iconElement); } for (Iterator i = getActivatedHooks().iterator(); i.hasNext();) { XMLElement hookElement = new XMLElement(); hookElement.setName("hook"); ((PermanentNodeHook) i.next()).save(hookElement); node.addChild(hookElement); } if (childrenUnfolded().hasNext()) { node.writeWithoutClosingTag(writer); //recursive for (ListIterator e = childrenUnfolded(); e.hasNext();) { NodeAdapter child = (NodeAdapter) e.next(); child.save(writer, registry); } node.writeClosingTag(writer); } else { node.write(writer); } return node; } public int getShiftY() { return shiftY ; } public int calcShiftY() { try{ return shiftY + (getParent().getChildCount()== 1 ? SHIFT:0); } catch(NullPointerException e){ return 0; } } /** * @param shiftY The shiftY to set. */ public void setShiftY(int shiftY) { this.shiftY = shiftY; } /** * */ public void setAdditionalInfo(String info) { } public String getAdditionalInfo(){ return null; } /** This method must be synchronized as the TreeMap isn't. */ public synchronized void setStateIcon(String key, ImageIcon icon) { // logger.warning("Set state of key:"+key+", icon "+icon); createStateIcons(); if (icon != null) { stateIcons.put(key, icon); } else if(stateIcons.containsKey(key)) { stateIcons.remove(key); } if(stateIcons.size()==0) stateIcons = null; } public Map getStateIcons() { if(stateIcons==null) return Collections.EMPTY_MAP; return Collections.unmodifiableSortedMap(stateIcons); } public HistoryInformation getHistoryInformation() { return historyInformation; } public void setHistoryInformation(HistoryInformation historyInformation) { this.historyInformation = historyInformation; } public int getHGap() { return hGap; } public void setHGap(int gap) { hGap = Math.max(HGAP, gap); } public int getVGap() { return vGap; } public int calcVGap() { if (vGap != AUTO) return vGap; /* // double delta = 8.0 / Math.pow(1.5, 1 + getNodeLevel()); // to expensive... double delta = 8.0 / Math.pow(1 + getNodeLevel(), 1.5); return (int ) ((1 + delta) * VGAP ); */ return VGAP; } public void setVGap(int gap) { if (gap == AUTO) vGap = AUTO; else vGap = Math.max(gap, 0); } }

The table below shows all metrics for NodeAdapter.java.

MetricValueDescription
BLOCKS190.00Number of blocks
BLOCK_COMMENT42.00Number of block comment lines
COMMENTS207.00Comment lines
COMMENT_DENSITY 0.39Comment density
COMPARISONS122.00Number of comparison operators
CYCLOMATIC212.00Cyclomatic complexity
DECL_COMMENTS69.00Comments in declarations
DOC_COMMENT52.00Number of javadoc comment lines
ELOC531.00Effective lines of code
EXEC_COMMENTS38.00Comments in executable code
EXITS142.00Procedure exits
FUNCTIONS102.00Number of function declarations
HALSTEAD_DIFFICULTY73.39Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY181.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 1.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 0.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 1.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 1.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA003421.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 0.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 3.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 4.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076 2.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 1.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA0108 3.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 7.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 1.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 1.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 0.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 2.00JAVA0116 Missing javadoc: field 'field'
JAVA011712.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 0.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 1.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 1.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 1.00JAVA0143 Synchronized method
JAVA0144 0.00JAVA0144 Line exceeds maximum M characters
JAVA0145639.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 1.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 0.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 1.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 0.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 2.00JAVA0177 Variable declaration missing initializer
JAVA0179 4.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 6.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 1.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 1.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 1.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 0.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES1042.00Number of lines in the source file
LINE_COMMENT113.00Number of line comments
LOC673.00Lines of code
LOGICAL_LINES335.00Number of statements
LOOPS10.00Number of loops
NEST_DEPTH 4.00Maximum nesting depth
OPERANDS1318.00Number of operands
OPERATORS3043.00Number of operators
PARAMS52.00Number of formal parameter declarations
PROGRAM_LENGTH4361.00Halstead program length
PROGRAM_VOCAB499.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS129.00Number of return points from functions
SIZE29853.00Size of the file in bytes
UNIQUE_OPERANDS449.00Number of unique operands
UNIQUE_OPERATORS50.00Number of unique operators
WHITESPACE162.00Number of whitespace lines