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