📄 node.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><!--NewPage--><html><head><!-- Generated by javadoc on Tue Nov 03 15:31:36 EST 1998 --><title> Class Node</title></head><body><a name="_top_"></a><h1> Class Node</h1><pre>java.lang.Object | +----Node</pre><hr><dl> <dt> public class <b>Node</b> <dt> extends Object <dt> implements <a href="DrawingObj.html#_top_">DrawingObj</a></dl>This class holds the information regarding a node from the heap/complete binary tree. This class implements the <code>DrawingObj</code> interface and hence can be freely added to the drawing panel using the <code>addDrawingObj</code> method. e.g. <code><pre> Node node = new Node(); drawingPanel.addDrawingObj(node); </pre></code> Any added drawing object can be remove from the panel by using the <code>removeObj</code> method. e.g. <code><pre> drawingPanel.removeObj(node); </pre></code><p><dl> <dt> <b>See Also:</b> <dd> <a href="DrawingPanel.html#addDrawingObj">addDrawingObj</a>, <a href="DrawingPanel.html#removeObj">removeObj</a>, Heap</dl><hr><a name="index"></a><h2> <img src="images/variable-index.gif" width=207 height=38 alt="Variable Index"></h2><dl> <dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o "> <a href="#highlight"><b>highlight</b></a> <dd> Attribute to indicate if the node is to be highlighted. <dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o "> <a href="#highlightLeft"><b>highlightLeft</b></a> <dd> Attribute to indicate if the left branch is to be highlighted. <dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o "> <a href="#highlightRight"><b>highlightRight</b></a> <dd> Attribute to indicate if the right branch is to be highlighted.</dl><h2> <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index"></h2><dl> <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o "> <a href="#Node()"><b>Node</b></a>() <dd> Create a new left node with weight 0. <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o "> <a href="#Node(int)"><b>Node</b></a>(int) <dd> Create a new leaf node with the specified weight. <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o "> <a href="#Node(Node)"><b>Node</b></a>(Node) <dd> Create a node with the left node as set and weight of the current node set to 0. <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o "> <a href="#Node(Node, Node)"><b>Node</b></a>(Node, Node) <dd> Create a node with the left and right child nodes specified and the weight of the current node is the sum of the child node. <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o "> <a href="#Node(java.lang.String)"><b>Node</b></a>(String) <dd> Create a new leaf node with 0 weight and label as specified. <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o "> <a href="#Node(java.lang.String, int)"><b>Node</b></a>(String, int) <dd> Create a new leaf node with label and weight as specified in the parameters.</dl><h2> <img src="images/method-index.gif" width=207 height=38 alt="Method Index"></h2><dl> <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#draw(java.awt.Graphics)"><b>draw</b></a>(Graphics) <dd> This method draws the node on the corresponding graphical context normally passed in from the drawing panel. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#getDepth()"><b>getDepth</b></a>() <dd> Get the depth of his node. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#getLabel()"><b>getLabel</b></a>() <dd> Get the label of this node. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#getLeftNode()"><b>getLeftNode</b></a>() <dd> Get the left child of this node. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#getRightNode()"><b>getRightNode</b></a>() <dd> Get the right child of this node. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#getWeight()"><b>getWeight</b></a>() <dd> Get the weight of this node. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#getX()"><b>getX</b></a>() <dd> Get the left most position of the node. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#getY()"><b>getY</b></a>() <dd> Get the top most position of the node. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#initColors(java.awt.Color)"><b>initColors</b></a>(Color) <dd> Set the color of the node. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#initFonts(java.awt.Font, java.awt.Font)"><b>initFonts</b></a>(Font, Font) <dd> Assign some font instances to reduce initialization over during redraw. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#isLeaf()"><b>isLeaf</b></a>() <dd> Check if this node is a leaf node. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#move(int, int)"><b>move</b></a>(int, int) <dd> Move the node and all its branches based on the parameters. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#moveNode(int, int)"><b>moveNode</b></a>(int, int) <dd> Move the tree starting with node dx pixels to the right and dy pixels down. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#setDepth(int)"><b>setDepth</b></a>(int) <dd> Sets the depth of this node corresponding to the root node of the tree. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#setLabel(java.lang.String)"><b>setLabel</b></a>(String) <dd> Set the label of this node. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#setLeftNode(Node)"><b>setLeftNode</b></a>(Node) <dd> Link the left branch of this node to the node passed in as the parameter. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#setRightNode(Node)"><b>setRightNode</b></a>(Node) <dd> Link the right branch of this node to the node passed in as the parameter. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#setWeight(int)"><b>setWeight</b></a>(int) <dd> Set the weight of this node. <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#setX(int)"><b>setX</b></a>(int) <dd> Sets the x coordinate of the top-left corner of the node <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o "> <a href="#setY(int)"><b>setY</b></a>(int) <dd> Sets the y coordinate of the top-left corner of the node</dl><a name="variables"></a><h2> <img src="images/variables.gif" width=153 height=38 alt="Variables"></h2><a name="highlightLeft"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a><b>highlightLeft</b><pre> public boolean highlightLeft</pre><dl> <dd> Attribute to indicate if the left branch is to be highlighted.<p></dl><a name="highlightRight"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a><b>highlightRight</b><pre> public boolean highlightRight</pre><dl> <dd> Attribute to indicate if the right branch is to be highlighted.<p></dl><a name="highlight"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a><b>highlight</b><pre> public boolean highlight</pre><dl> <dd> Attribute to indicate if the node is to be highlighted.<p></dl><a name="constructors"></a><h2> <img src="images/constructors.gif" width=231 height=38 alt="Constructors"></h2><a name="Node"></a><a name="Node(Node, Node)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a><b>Node</b><pre> public Node(<a href="#_top_">Node</a> node1, <a href="#_top_">Node</a> node2)</pre><dl> <dd> Create a node with the left and right child nodes specified and the weight of the current node is the sum of the child node.<p> <dd><dl> <dt> <b>Parameters:</b> <dd> node1 - The left node of this newly created node. <dd> node2 - The right node of this newly created node. </dl></dd></dl><a name="Node(Node)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a><b>Node</b><pre> public Node(<a href="#_top_">Node</a> node)</pre><dl> <dd> Create a node with the left node as set and weight of the current node set to 0.<p> <dd><dl> <dt> <b>Parameters:</b> <dd> node - The left node of the newly created node. </dl></dd></dl><a name="Node()"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a><b>Node</b><pre> public Node()</pre><dl> <dd> Create a new left node with weight 0.<p></dl><a name="Node(java.lang.String, int)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a><b>Node</b><pre> public Node(String label, int weight)</pre><dl> <dd> Create a new leaf node with label and weight as specified in the parameters.<p> <dd><dl> <dt> <b>Parameters:</b> <dd> label - The label of the new node. <dd> weight - The weight of the new node. </dl></dd></dl><a name="Node(int)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a><b>Node</b><pre> public Node(int weight)</pre><dl> <dd> Create a new leaf node with the specified weight.<p> <dd><dl> <dt> <b>Parameters:</b> <dd> weight - The weight of the new node. </dl></dd></dl><a name="Node(java.lang.String)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a><b>Node</b><pre> public Node(String label)</pre><dl> <dd> Create a new leaf node with 0 weight and label as specified.<p> <dd><dl> <dt> <b>Parameters:</b>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -