1
1
package org.helioviewer.viewmodel.view;
3
/** View to merged multiple Views.
5
* <p>The LayeredView a central element of the view chain. It is
6
* responsible for displaying multiple views, which are organized
7
* as a stack of layers. The basic functionality this includes to
8
* add, move and remove layers.
10
* <p>When drawing the different layers, the layer with index zero is
11
* drawn first, so the stack of layers is drawn in order bottom to top.
13
* <p>The position of the layers in relation to each other is
14
* calculated based on their regions. Thus, every view that is
15
* connected as a layer must provide a {@link RegionView}. Also, every layer
16
* has to provide a {@link MetaDataView} and a {@link ViewportView}.
17
* To take care of this requirement, implement the {@link ImageInfoView}
18
* as recommended. Since a LayeredView can be used as a layer itself,
19
* its implementation also should implement {@link RegionView},
4
* View to merged multiple Views.
7
* The LayeredView a central element of the view chain. It is responsible for
8
* displaying multiple views, which are organized as a stack of layers. The
9
* basic functionality this includes to add, move and remove layers.
12
* When drawing the different layers, the layer with index zero is drawn first,
13
* so the stack of layers is drawn in order bottom to top.
16
* The position of the layers in relation to each other is calculated based on
17
* their regions. Thus, every view that is connected as a layer must provide a
18
* {@link RegionView}. Also, every layer has to provide a {@link MetaDataView}
19
* and a {@link ViewportView}. To take care of this requirement, implement the
20
* {@link ImageInfoView} as recommended. Since a LayeredView can be used as a
21
* layer itself, its implementation also should implement {@link RegionView},
20
22
* {@link ViewportView} and {@link MetaDataView} as well.
22
* <p>As an additional feature, the LayeredView support hiding layers.
25
* As an additional feature, the LayeredView support hiding layers.
24
27
* @author Ludwig Schmidt
27
30
public interface LayeredView extends View {
29
/** Returns number of layers currently connected to the LayeredView.
31
* @return Number of layers
32
* @see #getNumberOfVisibleLayer
33
* Returns number of layers currently connected to the LayeredView.
35
* @return Number of layers
36
* @see #getNumberOfVisibleLayer
34
38
public int getNumLayers();
36
/** Returns, whether the given view is visible.
38
* If the given view is not a direct child of the LayeredView,
39
* returns false in any case.
41
* @param view View to test for visibility
41
* Returns, whether the given view is visible.
43
* If the given view is not a direct child of the LayeredView, returns false
47
* View to test for visibility
42
48
* @return True if the view is visible
43
49
* @see #toggleVisibility
45
51
public boolean isVisible(View view);
47
/** Returns number of layers currently visible.
54
* Returns number of layers currently visible.
49
* This number is lesser or equal to the number of total layers
50
* currently connected to the LayeredView.
56
* This number is lesser or equal to the number of total layers currently
57
* connected to the LayeredView.
52
59
* @return Number of visible layers
53
60
* @see #getNumLayers
55
62
public int getNumberOfVisibleLayer();
57
/** Toggles the visibility if the given view.
59
* If the given view is not a direct child of the LayeredView,
62
* @param view View to toggle visibility
65
* Toggles the visibility if the given view.
67
* If the given view is not a direct child of the LayeredView, nothing
71
* View to toggle visibility
65
74
public void toggleVisibility(View view);
67
/** Adds a view as a new layer to the LayeredView.
69
* The new layer is inserted on top of the current stack,
70
* thus will be drawn as last.
72
* @param newLayer View to add as a new layer
77
* Adds a view as a new layer to the LayeredView.
79
* The new layer is inserted on top of the current stack, thus will be drawn
83
* View to add as a new layer
73
84
* @see #removeLayer
75
86
public void addLayer(View newLayer);
77
/** Adds a view as a new layer to the LayeredView.
79
* The new layer is inserted at the given position
80
* of the current stack.
82
* @param newLayer View to add as a new layer
89
* Adds a view as a new layer to the LayeredView.
91
* The new layer is inserted at the given position of the current stack.
94
* View to add as a new layer
83
95
* @see #removeLayer
85
97
public void addLayer(View newLayer, int newIndex);
87
/** Removes a layer from the LayeredView.
100
* Removes a layer from the LayeredView.
89
* @param index position of the layer within the stack of layers.
103
* position of the layer within the stack of layers.
92
106
public void removeLayer(int index);
94
/** Removes a layer from the LayeredView.
96
* If the given view is not a direct child of the LayeredView,
99
* @param view View to remove from the LayeredView
109
* Removes a layer from the LayeredView.
111
* If the given view is not a direct child of the LayeredView, nothing
115
* View to remove from the LayeredView
102
118
public void removeLayer(View view);
104
/** Returns the position of the view within the stack of layers.
106
* Zero indicates the most bottom view. If the given view is not
107
* a direct child of the LayeredView, the function returns -1.
109
* @param view View to search for within the stack of layers
121
* Returns the position of the view within the stack of layers.
123
* Zero indicates the most bottom view. If the given view is not a direct
124
* child of the LayeredView, the function returns -1.
127
* View to search for within the stack of layers
110
128
* @return Position of the view within stack
113
131
public int getLayerLevel(View view);
115
/** Returns the view at a given position within the stack of layers.
134
* Returns the view at a given position within the stack of layers.
117
* @param index Position within the stack of layers
137
* Position within the stack of layers
118
138
* @return View at given position
120
140
public View getLayer(int index);
122
/** Moves a layer to a different position within the stack of layers.
124
* If the given view is not a direct child of the LayeredView,
127
* @param view Layer to move to a new position
128
* @param newLevel new position
143
* Moves a layer to a different position within the stack of layers.
145
* If the given view is not a direct child of the LayeredView, nothing
149
* Layer to move to a new position
129
152
* @see #getLayerLevel