001: /*
002: * $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/treelayout/TreeNode.java,v 1.1 2005/04/20 22:21:33 paulby Exp $
003: *
004: * Sun Public License Notice
005: *
006: * The contents of this file are subject to the Sun Public License Version
007: * 1.0 (the "License"). You may not use this file except in compliance with
008: * the License. A copy of the License is available at http://www.sun.com/
009: *
010: * The Original Code is the Java 3D(tm) Scene Graph Editor.
011: * The Initial Developer of the Original Code is Paul Byrne.
012: * Portions created by Paul Byrne are Copyright (C) 2002.
013: * All Rights Reserved.
014: *
015: * Contributor(s): Paul Byrne.
016: *
017: **/
018: package org.jdesktop.j3dedit.treelayout;
019:
020: import java.awt.*;
021:
022: /**
023: * This interface provides all the methods required to allow TreeLayout
024: * to automatically layout the tree diagram.
025: *
026: * @author Paul Byrne
027: * @version $Id: TreeNode.java,v 1.1 2005/04/20 22:21:33 paulby Exp $
028: */
029: public interface TreeNode {
030:
031: /**
032: * Tell this node which panel it is contained within
033: * Traverse all the children on this node and set their container
034: */
035: public void setContainer(TreePanel panel);
036:
037: /**
038: * Return the container which currently contains this node
039: */
040: public TreePanel getContainer();
041:
042: /**
043: * Return the number of children of this node
044: */
045: public int numChildren();
046:
047: /**
048: * Return the child at the given index
049: */
050: public TreeNode getChild(int index);
051:
052: /**
053: * Add child as the last child of this node
054: */
055: public void addChild(TreeNode child);
056:
057: /**
058: * Remove the specified child from this node
059: */
060: public void removeChild(TreeNode child);
061:
062: /**
063: * Returns the number of nodes in the subtree starting with this node
064: */
065: public int getNodeCount();
066:
067: /**
068: * Return the parent of this node
069: */
070: public TreeNode getParent();
071:
072: /**
073: * Set the parent of this node
074: */
075: public void setParent(TreeNode parent);
076:
077: /**
078: * Get the link that attaches all the children
079: */
080: public Link getLink();
081:
082: /**
083: * Set the link that attaches all the children
084: */
085: public void setLink(Link link);
086:
087: /**
088: * Return the point where the link line leaves the node
089: */
090: public Point getLinkExit();
091:
092: /**
093: * Return the point where the link line enters the node
094: */
095: public Point getLinkEntry();
096:
097: public Point getComputedPosition();
098:
099: public void setComputedPosition(Point pos);
100:
101: public void setLayoutData(LayoutData data);
102:
103: public LayoutData getLayoutData();
104:
105: /**
106: * Return the dimension and position of the smallest rectangle
107: * that encolses this node and all it's subtree
108: */
109: public Rectangle getSubtreeSize();
110:
111: public void setSubtreeSize(Rectangle size);
112:
113: /**
114: * Returns the preferred dimension of the node
115: * This includes the padding around the edge
116: * ie the space between this node it's sibling on the right
117: */
118: public Dimension getPreferredSize();
119:
120: /**
121: * Returns the mimimum dimension of this node, this is the
122: * smallest enclosing area around the drawing of the node
123: */
124: public Dimension getMinimumSize();
125:
126: /**
127: * Draw this node and it's subgraph
128: */
129: public void paint(Graphics g);
130:
131: /**
132: * Returns true if coordinates are within the area of the
133: * node
134: */
135: public boolean picked(int x, int y);
136: }
|