Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
TreeElement |
|
| 1.0;1 |
1 | package org.jtheque.primary.view.impl.models.tree; | |
2 | ||
3 | /* | |
4 | * This file is part of JTheque. | |
5 | * | |
6 | * JTheque is free software: you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation, either version 3 of the License. | |
9 | * | |
10 | * JTheque is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
19 | import javax.swing.Icon; | |
20 | ||
21 | /** | |
22 | * Represents an element of a tree model. | |
23 | * | |
24 | * @author Baptiste Wicht | |
25 | */ | |
26 | public interface TreeElement { | |
27 | /** | |
28 | * Return the name of the element. | |
29 | * | |
30 | * @return The name | |
31 | */ | |
32 | String getElementName(); | |
33 | ||
34 | /** | |
35 | * Return the icon of the element. | |
36 | * | |
37 | * @return The icon | |
38 | */ | |
39 | Icon getIcon(); | |
40 | ||
41 | /** | |
42 | * Indicate if the element is root or not. | |
43 | * | |
44 | * @return <code>true</code> if the element is the root else false. | |
45 | */ | |
46 | boolean isRoot(); | |
47 | ||
48 | /** | |
49 | * Indicate if the element is a category or not. | |
50 | * | |
51 | * @return <code>true</code> if the element is a category else <code>false</code>. | |
52 | */ | |
53 | boolean isCategory(); | |
54 | ||
55 | /** | |
56 | * Indicate if the element is a leaf or not. | |
57 | * | |
58 | * @return <code>true</code> if the element is a leaf else <code>false</code>. | |
59 | */ | |
60 | boolean isLeaf(); | |
61 | ||
62 | /** | |
63 | * Return the child a the specified index. | |
64 | * | |
65 | * @param index The index. | |
66 | * | |
67 | * @return The element at the index else <code>null</code>. | |
68 | */ | |
69 | TreeElement getChild(int index); | |
70 | ||
71 | /** | |
72 | * Return the number of childs. | |
73 | * | |
74 | * @return The number of childs. | |
75 | */ | |
76 | int getChildCount(); | |
77 | ||
78 | /** | |
79 | * Return the index of the specified element. | |
80 | * | |
81 | * @param treeElement The element to search. | |
82 | * | |
83 | * @return the index of the element if found else <code>-1</code>. | |
84 | */ | |
85 | int indexOf(TreeElement treeElement); | |
86 | ||
87 | /** | |
88 | * Add a tree element to the element. | |
89 | * | |
90 | * @param element The element to add. | |
91 | */ | |
92 | void add(TreeElement element); | |
93 | ||
94 | /** | |
95 | * Add all the elements to the element. | |
96 | * | |
97 | * @param elements The elements to add. | |
98 | */ | |
99 | void addAll(Iterable<? extends TreeElement> elements); | |
100 | ||
101 | /** | |
102 | * Clear the element. | |
103 | */ | |
104 | void clear(); | |
105 | } |