01: package jdepend.swingui;
02:
03: import java.util.*;
04:
05: import jdepend.framework.*;
06:
07: /**
08: * The <code>EfferentNode</code> class is a <code>PackageNode</code> for an
09: * efferent Java package and its efferent packages.
10: *
11: * @author <b>Mike Clark</b>
12: * @author Clarkware Consulting, Inc.
13: */
14:
15: public class EfferentNode extends PackageNode {
16:
17: /**
18: * Constructs an <code>EfferentNode</code> with the specified parent node
19: * and efferent Java package.
20: *
21: * @param parent Parent package node.
22: * @param jPackage Efferent Java package.
23: */
24: public EfferentNode(PackageNode parent, JavaPackage jPackage) {
25: super (parent, jPackage);
26: }
27:
28: /**
29: * Creates and returns a <code>PackageNode</code> with the specified
30: * parent node and Java package.
31: *
32: * @param parent Parent package node.
33: * @param jPackage Java package.
34: * @return A non-null <code>PackageNode</code.
35: */
36: protected PackageNode makeNode(PackageNode parent,
37: JavaPackage jPackage) {
38: return new EfferentNode(parent, jPackage);
39: }
40:
41: /**
42: * Returns the collection of Java packages coupled to the package
43: * represented in this node.
44: *
45: * @return Collection of coupled packages.
46: */
47: protected Collection getCoupledPackages() {
48: return getPackage().getEfferents();
49: }
50:
51: /**
52: * Indicates whether the specified package should be displayed as a child of
53: * this node.
54: * <p>
55: * Efferent packages without classes are never shown at the root level to
56: * exclude non-analyzed packages.
57: *
58: * @param jPackage Package to test.
59: * @return <code>true</code> to display the package; <code>false</code>
60: * otherwise.
61: */
62: public boolean isChild(JavaPackage jPackage) {
63: if (getParent() != null) {
64: return true;
65: } else if (jPackage.getClassCount() > 0) {
66: return true;
67: }
68:
69: return false;
70: }
71:
72: /**
73: * Returns the string representation of this node in it's current tree
74: * context.
75: *
76: * @return Node label.
77: */
78: public String toString() {
79: if (getParent() == null) {
80: return "Depends Upon - Efferent Dependencies" + " ("
81: + getChildren().size() + " Packages)";
82: }
83:
84: return super.toString();
85: }
86: }
|