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

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

setting data to overlay links to make it easier to toggle display of toolbar and notes.

File size: 6.3 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.setData("overlayToolbar");
127 newText.setLink(NAVIGATION_OVERLAY);
128 }
129
130
131 }
132
133 /**
134 * Method to set up overlay which displays a "toggle toolbar" option/button.
135 * @param cItem - the collection item to add the toggle toolbar option to.
136 */
137 public static void setUpToggleToolbarOverlay(CollectionItem cItem) {
138 Frame ciFrame = cItem.getFrame();
139 List<Text> list = ciFrame.getBodyTextItems(true);
140
141 boolean found = false;
142 int i = 0;
143
144 while(i < list.size() && !found){
145
146 Text t = list.get(i);
147
148 if(t.getText().equals(AO_TEXT3)){
149
150 if(t.hasLink()){
151
152 if(t.getLink().equals(TOGGLE_TOOLS_OVERLAY)){
153 found = true;
154 }
155 }
156 }
157 i++;
158 }
159
160 if(!found){
161 Text newText = ciFrame.addText(_toggleAoX,_toggleAoY,AO_TEXT3,null);
162 newText.setData("overlayViewToolbar");
163 newText.setLink(TOGGLE_TOOLS_OVERLAY);
164 }
165
166 }
167
168 /**
169 * Method to set up an overlay for displaying notes for
170 * the passed collection item.
171 * @param cItem - collection item to add notes to.
172 */
173 public static void setUpNotesOverlay(CollectionItem cItem) {
174
175 Frame ciFrame = cItem.getFrame();
176 List<Text> list = ciFrame.getBodyTextItems(true);
177
178 boolean found = false;
179 int i = 0;
180
181 while(i < list.size() && !found){
182
183 Text t = list.get(i);
184
185 if(t.getText().equals(AO_TEXT4)){
186
187 if(t.hasLink()){
188
189 if(t.getLink().startsWith("notes")){
190 found = true;
191 }
192
193 }
194 }
195
196 i++;
197 }
198
199 if(!found){
200
201 //check for an overlay frame in notes frameset associated with this collection item.
202 NoteLayer getNoteLayer = cItem.getNoteLayer();
203 Frame getNotesOverlayFrame = null;
204
205 if(getNoteLayer == null){
206
207 //Create a new notelayer and frame
208 getNoteLayer = new NoteLayer();
209 getNoteLayer.setAssociatedItem(cItem);
210
211 //Create new frame.
212 int frameNumber = FrameIO.getLastNumber("notesmain") + 1;
213 HonoursFrameIO.generateFrame(frameNumber, "notesmain");
214 getNotesOverlayFrame = FrameIO.LoadFrame("notesmain"+frameNumber);
215 getNoteLayer.setFrame(FrameIO.LoadFrame(getNotesOverlayFrame.getName()));
216 cItem.setNoteLayer(getNoteLayer);
217
218 //Add collectionItem back into collection
219 //Add collection back into collections list
220 Collection matchingCollection = Collection.findCollection(cItem.getFrame());
221 int collectionIndex = Collection.getCollectionPosition(matchingCollection);
222 int collectionItemPosition = CollectionItem.getPositionInCollection(cItem, matchingCollection);
223
224 matchingCollection.getItems().remove(collectionItemPosition);
225 matchingCollection.getItems().add(collectionItemPosition,cItem);
226
227 Main._collections.remove(collectionIndex);
228 Main._collections.add(collectionIndex, matchingCollection);
229 }else{
230 getNotesOverlayFrame = getNoteLayer.getFrame();
231 }
232
233 Text newText = ciFrame.addText(_notesAoX,_notesAoY,AO_TEXT4,null);
234 newText.setData("overlayNotes");
235 newText.setLink(getNotesOverlayFrame.getName());
236 }
237 }
238
239}
Note: See TracBrowser for help on using the repository browser.