source: other-projects/GlamED/trunk/src/org/honours/gui/Interfaces.java@ 26635

Last change on this file since 26635 was 26635, checked in by davidb, 11 years ago

Change in a variable name, position of some overlay annotations and introduction of a method to position overlay link items relative to the screen size.

File size: 6.2 KB
Line 
1package org.honours.gui;
2
3import java.util.List;
4
5import org.expeditee.gui.*;
6import org.expeditee.items.Text;
7
8import org.honours.Main;
9import org.honours.collection.*;
10
11/**
12 * This class is used for displaying the
13 * various different overlays/interfaces available.
14 * @author Korii
15 */
16public class Interfaces {
17
18 //various frame names for the different interface overlays.
19 public static final String MAIN_INTERFACE_OVERLAY = "interface-overlays1";
20 public static final String NAVIGATION_OVERLAY = "interface-overlays2";
21 public static final String LAYERS_BACK_BTN_OVERLAY = "interface-overlays3";
22 public static final String TOGGLE_TOOLS_OVERLAY = "interface-overlays4";
23 //public static final String DISPLAY_LAYERS_OVERLAY = "interface-overlays5";
24 public static final String BLANK_TOOLBAR_OVERLAY = "interface-overlays6";
25 //public static final String BLANK_DISPLAY_LAYERS_OVERLAY = "interface-overlays7";
26
27 //TODO: Overlay for hiding notes.
28 public static final String BLANK_HIDE_NOTES_OVERLAY = "interface-overlays9";
29
30 public static final String BLANK_TOGGLER_OVERLAY = "interface-overlays10";
31
32 private static final String AO_TEXT3 = "@ao:3";
33 private static final String AO_TEXT4 = "@ao:4";
34
35 //used to determine positioning of the various @ao:3/4 text items.
36 private static int _mainOverAoX = 1272;
37 private static int _mainOverAoY = 130;
38
39 private static int _toolbarAoX = 1272;
40 private static int _toolbarAoY = 130;
41
42 private static int _toggleAoX = 1272;
43 private static int _toggleAoY = 94;
44
45 private static int _notesAoX = 1272;
46 private static int _notesAoY = 58;
47
48 private static String _overlayAnnotationData = "overlay-annotation";
49
50
51 /** Method to set up overlay locations relative to the screen size. **/
52 public static void setUpOverlayLocations(){
53
54 }
55
56 /**
57 * This method sets up the main overlay on the profile
58 * frame.
59 * @param frame - frame to add the main overlay too.
60 */
61 public static void setUpMainOverlay(Frame frame){
62
63 List<Text> list = frame.getBodyTextItems(true);
64
65 boolean found = false;
66 int i = 0;
67
68 while(i < list.size() && !found){
69
70 Text text = list.get(i);
71
72 if(text.getText().equals(AO_TEXT3)){
73 if(text.hasLink()){
74 if(text.getLink().equals(MAIN_INTERFACE_OVERLAY)){
75 found = true;
76 }
77
78 }
79 }
80 i++;
81 }
82
83 if(!found){
84 Text t = frame.addText(_mainOverAoX,_mainOverAoY,AO_TEXT3,null);
85 t.setLink(MAIN_INTERFACE_OVERLAY);
86
87 frame.setSaved();
88 frame.setChanged(true);
89 }
90
91 FrameKeyboardActions.Refresh();
92 }
93
94
95 /**
96 * Set up overlay which displays toolbar for collection items.
97 * @param cItem - the collection item to add the toolbar to (or rather its represented frame).
98 */
99 public static void setUpToolbarOverlay(CollectionItem cItem) {
100
101 Frame ciFrame = cItem.getFrame();
102 List<Text> list = ciFrame.getBodyTextItems(true);
103
104 boolean found = false;
105 int i = 0;
106
107 while(i < list.size() && !found){
108
109 Text t = list.get(i);
110
111 if(t.getText().equals(AO_TEXT3)){
112
113 if(t.hasLink()){
114 if(t.getLink().equals(NAVIGATION_OVERLAY)){
115 found = true;
116 }
117 }
118 }
119
120 i++;
121 }
122
123 if(!found){
124
125 Text newText = ciFrame.addText(_toolbarAoX,_toolbarAoY,AO_TEXT3,null);
126 newText.setLink(NAVIGATION_OVERLAY);
127 }
128
129
130 }
131
132 /**
133 * Method to set up overlay which displays a "toggle toolbar" option/button.
134 * @param cItem - the collection item to add the toggle toolbar option to.
135 */
136 public static void setUpToggleToolbarOverlay(CollectionItem cItem) {
137 Frame ciFrame = cItem.getFrame();
138 List<Text> list = ciFrame.getBodyTextItems(true);
139
140 boolean found = false;
141 int i = 0;
142
143 while(i < list.size() && !found){
144
145 Text t = list.get(i);
146
147 if(t.getText().equals(AO_TEXT3)){
148
149 if(t.hasLink()){
150
151 if(t.getLink().equals(TOGGLE_TOOLS_OVERLAY)){
152 found = true;
153 }
154 }
155 }
156 i++;
157 }
158
159 if(!found){
160 Text newText = ciFrame.addText(_toggleAoX,_toggleAoY,AO_TEXT3,null);
161 newText.setLink(TOGGLE_TOOLS_OVERLAY);
162 }
163
164 }
165
166 /**
167 * Method to set up an overlay for displaying notes for
168 * the passed collection item.
169 * @param cItem - collection item to add notes to.
170 */
171 public static void setUpNotesOverlay(CollectionItem cItem) {
172
173 Frame ciFrame = cItem.getFrame();
174 List<Text> list = ciFrame.getBodyTextItems(true);
175
176 boolean found = false;
177 int i = 0;
178
179 while(i < list.size() && !found){
180
181 Text t = list.get(i);
182
183 if(t.getText().equals(AO_TEXT4)){
184
185 if(t.hasLink()){
186
187 if(t.getLink().startsWith("notes")){
188 found = true;
189 }
190
191 }
192 }
193
194 i++;
195 }
196
197 if(!found){
198
199 //check for an overlay frame in notes frameset associated with this collection item.
200 NoteLayer getNoteLayer = cItem.getNoteLayer();
201 Frame getNotesOverlayFrame = null;
202
203 if(getNoteLayer == null){
204
205 //Create a new notelayer and frame
206 getNoteLayer = new NoteLayer();
207 getNoteLayer.setAssociatedItem(cItem);
208
209 //Create new frame.
210 int frameNumber = FrameIO.getLastNumber("notesmain") + 1;
211 HonoursFrameIO.generateFrame(frameNumber, "notesmain");
212 getNotesOverlayFrame = FrameIO.LoadFrame("notesmain"+frameNumber);
213 getNoteLayer.setFrame(FrameIO.LoadFrame(getNotesOverlayFrame.getName()));
214 cItem.setNoteLayer(getNoteLayer);
215
216 //Add collectionItem back into collection
217 //Add collection back into collections list
218 Collection matchingCollection = Collection.findCollection(cItem.getFrame());
219 int collectionIndex = Collection.getCollectionPosition(matchingCollection);
220 int collectionItemPosition = CollectionItem.getPositionInCollection(cItem, matchingCollection);
221
222 matchingCollection.getItems().remove(collectionItemPosition);
223 matchingCollection.getItems().add(collectionItemPosition,cItem);
224
225 Main._collections.remove(collectionIndex);
226 Main._collections.add(collectionIndex, matchingCollection);
227 }else{
228 getNotesOverlayFrame = getNoteLayer.getFrame();
229 }
230
231 Text newText = ciFrame.addText(_notesAoX,_notesAoY,AO_TEXT4,null);
232 newText.setLink(getNotesOverlayFrame.getName());
233 }
234 }
235
236}
Note: See TracBrowser for help on using the repository browser.