4740 |
05 Feb 09 |
nicklas |
1 |
/** |
4740 |
05 Feb 09 |
nicklas |
$Id$ |
4740 |
05 Feb 09 |
nicklas |
3 |
|
4740 |
05 Feb 09 |
nicklas |
Copyright (C) 2008 Nicklas Nordborg |
4740 |
05 Feb 09 |
nicklas |
5 |
|
4740 |
05 Feb 09 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
4740 |
05 Feb 09 |
nicklas |
Available at http://base.thep.lu.se/ |
4740 |
05 Feb 09 |
nicklas |
8 |
|
4740 |
05 Feb 09 |
nicklas |
BASE is free software; you can redistribute it and/or |
4740 |
05 Feb 09 |
nicklas |
modify it under the terms of the GNU General Public License |
4740 |
05 Feb 09 |
nicklas |
as published by the Free Software Foundation; either version 3 |
4740 |
05 Feb 09 |
nicklas |
of the License, or (at your option) any later version. |
4740 |
05 Feb 09 |
nicklas |
13 |
|
4740 |
05 Feb 09 |
nicklas |
BASE is distributed in the hope that it will be useful, |
4740 |
05 Feb 09 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4740 |
05 Feb 09 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4740 |
05 Feb 09 |
nicklas |
GNU General Public License for more details. |
4740 |
05 Feb 09 |
nicklas |
18 |
|
4740 |
05 Feb 09 |
nicklas |
You should have received a copy of the GNU General Public License |
4740 |
05 Feb 09 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
4740 |
05 Feb 09 |
nicklas |
21 |
*/ |
4740 |
05 Feb 09 |
nicklas |
22 |
package net.sf.basedb.util.overview.node; |
4740 |
05 Feb 09 |
nicklas |
23 |
|
4740 |
05 Feb 09 |
nicklas |
24 |
import net.sf.basedb.util.overview.Node; |
4740 |
05 Feb 09 |
nicklas |
25 |
|
4740 |
05 Feb 09 |
nicklas |
26 |
|
4740 |
05 Feb 09 |
nicklas |
27 |
/** |
4740 |
05 Feb 09 |
nicklas |
Represents the direction to use for loading child nodes in a tree. |
4740 |
05 Feb 09 |
nicklas |
We need to keep track of this since we need to support rooting a tree |
4740 |
05 Feb 09 |
nicklas |
at any type of item (eg. at an experiment, hybridization, biosource, etc). |
4740 |
05 Feb 09 |
nicklas |
<p> |
4740 |
05 Feb 09 |
nicklas |
32 |
|
6881 |
21 Apr 15 |
nicklas |
For every tree there is a <i>natural</i> order of items. For example, |
4740 |
05 Feb 09 |
nicklas |
BioSource -> Sample -> Extract -> ... -> Experiment. |
4740 |
05 Feb 09 |
nicklas |
The natural order is the forward-loading direction and the opposite |
4740 |
05 Feb 09 |
nicklas |
order is the reverse-loading direction. |
4740 |
05 Feb 09 |
nicklas |
<p> |
4740 |
05 Feb 09 |
nicklas |
38 |
|
4740 |
05 Feb 09 |
nicklas |
For example, if we root the tree at a Hybridization we will load children |
4740 |
05 Feb 09 |
nicklas |
in the forward-loading direction down to experiment and in the |
4740 |
05 Feb 09 |
nicklas |
revers-loading direction up to biosource and array design. For each node |
4740 |
05 Feb 09 |
nicklas |
that is added to a tree we need to keep track if we should continue up |
4740 |
05 Feb 09 |
nicklas |
or down the natural order. Otherwise we will end up in an infinite loop. |
4740 |
05 Feb 09 |
nicklas |
<p> |
4740 |
05 Feb 09 |
nicklas |
45 |
|
4740 |
05 Feb 09 |
nicklas |
In a tree there can also be side-nodes that in most cases are end-point or |
4740 |
05 Feb 09 |
nicklas |
leaf nodes. This is for example nodes containing information about |
4740 |
05 Feb 09 |
nicklas |
protocol, software, annotations, etc. We call such nodes <i>property</i> |
4740 |
05 Feb 09 |
nicklas |
nodes and they are usually loaded in both the forward- and reverse-loading |
4740 |
05 Feb 09 |
nicklas |
directions. |
4740 |
05 Feb 09 |
nicklas |
51 |
|
4740 |
05 Feb 09 |
nicklas |
@author Nicklas |
4740 |
05 Feb 09 |
nicklas |
@version 2.10 |
4740 |
05 Feb 09 |
nicklas |
@base.modified $Date$ |
4740 |
05 Feb 09 |
nicklas |
@see Node#getChildNodeDirection() |
4740 |
05 Feb 09 |
nicklas |
56 |
*/ |
4740 |
05 Feb 09 |
nicklas |
57 |
public enum ChildNodeDirection |
4740 |
05 Feb 09 |
nicklas |
58 |
{ |
4740 |
05 Feb 09 |
nicklas |
59 |
/** |
4740 |
05 Feb 09 |
nicklas |
Represents an end-point node. No more child nodes should be loaded, |
4740 |
05 Feb 09 |
nicklas |
not even property nodes. |
4740 |
05 Feb 09 |
nicklas |
62 |
*/ |
4740 |
05 Feb 09 |
nicklas |
63 |
NONE(false, false, false), |
4740 |
05 Feb 09 |
nicklas |
64 |
|
4740 |
05 Feb 09 |
nicklas |
65 |
/** |
4740 |
05 Feb 09 |
nicklas |
Only property child nodes should be loaded. |
4740 |
05 Feb 09 |
nicklas |
67 |
*/ |
4740 |
05 Feb 09 |
nicklas |
68 |
PROPERTY(false, false, true), |
4740 |
05 Feb 09 |
nicklas |
69 |
|
4740 |
05 Feb 09 |
nicklas |
70 |
/** |
4740 |
05 Feb 09 |
nicklas |
Child nodes should be loaded in the forward-loading direction. |
4740 |
05 Feb 09 |
nicklas |
Property nodes should also be loaded. |
4740 |
05 Feb 09 |
nicklas |
73 |
*/ |
4740 |
05 Feb 09 |
nicklas |
74 |
FORWARD(true, false, true), |
4740 |
05 Feb 09 |
nicklas |
75 |
|
4740 |
05 Feb 09 |
nicklas |
76 |
/** |
4740 |
05 Feb 09 |
nicklas |
Child nodes should be loaded in the reverse-loading direction. |
4740 |
05 Feb 09 |
nicklas |
Property nodes should also be loaded. |
4740 |
05 Feb 09 |
nicklas |
79 |
*/ |
4740 |
05 Feb 09 |
nicklas |
80 |
REVERSE(false, true, true), |
4740 |
05 Feb 09 |
nicklas |
81 |
|
4740 |
05 Feb 09 |
nicklas |
82 |
/* |
4740 |
05 Feb 09 |
nicklas |
Child nodes should be loaded in the all directions. This |
4740 |
05 Feb 09 |
nicklas |
is usually only used on the root node. |
4740 |
05 Feb 09 |
nicklas |
85 |
*/ |
4740 |
05 Feb 09 |
nicklas |
86 |
ALL(true, true, true); |
4740 |
05 Feb 09 |
nicklas |
87 |
|
4740 |
05 Feb 09 |
nicklas |
88 |
private final boolean loadForward; |
4740 |
05 Feb 09 |
nicklas |
89 |
private final boolean loadReverse; |
4740 |
05 Feb 09 |
nicklas |
90 |
private final boolean loadProperty; |
4740 |
05 Feb 09 |
nicklas |
91 |
|
4740 |
05 Feb 09 |
nicklas |
92 |
private ChildNodeDirection(boolean loadForward, boolean loadReverse, boolean loadProperty) |
4740 |
05 Feb 09 |
nicklas |
93 |
{ |
4740 |
05 Feb 09 |
nicklas |
94 |
this.loadForward = loadForward; |
4740 |
05 Feb 09 |
nicklas |
95 |
this.loadReverse = loadReverse; |
4740 |
05 Feb 09 |
nicklas |
96 |
this.loadProperty = loadProperty; |
4740 |
05 Feb 09 |
nicklas |
97 |
} |
4740 |
05 Feb 09 |
nicklas |
98 |
|
4740 |
05 Feb 09 |
nicklas |
99 |
/** |
4740 |
05 Feb 09 |
nicklas |
@return TRUE if child nodes in the reverse-loading |
4740 |
05 Feb 09 |
nicklas |
direction should be loaded |
4740 |
05 Feb 09 |
nicklas |
102 |
*/ |
4740 |
05 Feb 09 |
nicklas |
103 |
public boolean loadReverse() |
4740 |
05 Feb 09 |
nicklas |
104 |
{ |
4740 |
05 Feb 09 |
nicklas |
105 |
return loadReverse; |
4740 |
05 Feb 09 |
nicklas |
106 |
} |
4740 |
05 Feb 09 |
nicklas |
107 |
|
4740 |
05 Feb 09 |
nicklas |
108 |
/** |
4740 |
05 Feb 09 |
nicklas |
@return TRUE if child nodes in the forward-loading |
4740 |
05 Feb 09 |
nicklas |
direction should be loaded |
4740 |
05 Feb 09 |
nicklas |
111 |
*/ |
4740 |
05 Feb 09 |
nicklas |
112 |
public boolean loadForward() |
4740 |
05 Feb 09 |
nicklas |
113 |
{ |
4740 |
05 Feb 09 |
nicklas |
114 |
return loadForward; |
4740 |
05 Feb 09 |
nicklas |
115 |
} |
4740 |
05 Feb 09 |
nicklas |
116 |
|
4740 |
05 Feb 09 |
nicklas |
117 |
/** |
4740 |
05 Feb 09 |
nicklas |
@return TRUE if property child nodes should be loaded |
4740 |
05 Feb 09 |
nicklas |
119 |
*/ |
4740 |
05 Feb 09 |
nicklas |
120 |
public boolean loadProperty() |
4740 |
05 Feb 09 |
nicklas |
121 |
{ |
4740 |
05 Feb 09 |
nicklas |
122 |
return loadProperty; |
4740 |
05 Feb 09 |
nicklas |
123 |
} |
4740 |
05 Feb 09 |
nicklas |
124 |
|
4740 |
05 Feb 09 |
nicklas |
125 |
} |