source: trunk/src/org/expeditee/actions/ExploratorySearchActions.java@ 919

Last change on this file since 919 was 919, checked in by jts21, 10 years ago

Added license headers to all files, added full GPL3 license file, moved license header generator script to dev/bin/scripts

  • Property svn:executable set to *
File size: 9.2 KB
Line 
1/**
2 * ExploratorySearchActions.java
3 * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package org.expeditee.actions;
20
21import org.expeditee.gui.Browser;
22import org.expeditee.gui.DisplayIO;
23import org.expeditee.gui.Frame;
24import org.expeditee.gui.FrameIO;
25import org.expeditee.gui.FrameKeyboardActions;
26import org.expeditee.gui.FrameMouseActions;
27import org.expeditee.gui.FreeItems;
28import org.expeditee.items.Item;
29import org.expeditee.items.Justification;
30import org.expeditee.items.Text;
31import org.expeditee.settings.exploratorysearch.ExploratorySearchSettings;
32import org.expeditee.settings.network.NetworkSettings;
33
34/**
35 * List of actions which Exploratory Search uses.
36 * @author csl14
37 */
38public class ExploratorySearchActions {
39
40 /**
41 * Adds a text item to the cursor which is linked to a new frame with the web browser active overlay and a JavaFX browser.
42 * @param caller The item that the action is called from
43 */
44 public static void startBrowserSession(Item caller) {
45 try {
46 String url;
47
48 Text urlItem = FreeItems.getTextAttachedToCursor();
49
50 // If there is a text item attached to the cursor, use it as the URL to load
51 if (urlItem != null) {
52 url = urlItem.getText();
53
54 // Remove the item, since the link to the browser session will added to the cursor
55 urlItem.delete();
56 } else {
57 // Otherwise use the home page specified in the settings
58 url = NetworkSettings.HomePage.get();
59 }
60
61 Text linkToBrowserSession = DisplayIO.getCurrentFrame().addText(FrameMouseActions.getX(), FrameMouseActions.getY(), " - Web Browser Session", null);
62 linkToBrowserSession.setParent(DisplayIO.getCurrentFrame());
63 FrameKeyboardActions.AddDate(linkToBrowserSession);
64 FrameMouseActions.pickup(linkToBrowserSession);
65
66 // Create new frame
67 Frame frame = FrameIO.CreateNewFrame(linkToBrowserSession);
68
69 // link this text item to new frame
70 linkToBrowserSession.setLink("" + frame.getNumber());
71
72 // Remove everything from new frame
73 frame.removeAllItems(frame.getItems());
74
75 // Add web browser active overlay and @old
76 Text t = (Text) frame.addText(-150, 50, "@ao: 2", null, "overlayset2");
77 t.setAnchorRight(-100.0f);
78 t.setAnchorTop(50.0f);
79 t = (Text) frame.addText(-150, 50, "@old", null);
80 t.setFamily("Roboto Condensed");
81 t.setSize(15.0f);
82 t.setColor(null);
83 t.setWidth(116);
84 t.setJustification(Justification.right);
85 t.setLinkMark(false);
86 t.setAnchorLeft(9.0f);
87 t.setAnchorBottom(114.0f);
88
89 Text wt;
90
91 // Extract marigns from settings
92 int lm = ExploratorySearchSettings.BrowserLeftMargin.get();
93 int rm = ExploratorySearchSettings.BrowserRightMargin.get();
94 int tm = ExploratorySearchSettings.BrowserTopMargin.get();
95 int bm = ExploratorySearchSettings.BrowserBottomMargin.get();
96
97 // Start Browser in fullscreen or default, depending on settings
98 if(ExploratorySearchSettings.BrowserFullScreen.get()) {
99 wt = frame.addText(ExploratorySearchSettings.BROWSER_HORZ_OFFSET + lm, ExploratorySearchSettings.BROWSER_VERT_OFFSET + tm,
100 "@iw: org.expeditee.items.widgets.JfxBrowser "
101 + ("--anchorLeft " + (lm + ExploratorySearchSettings.BROWSER_HORZ_OFFSET) + " --anchorRight " + rm + " --anchorTop "
102 + (ExploratorySearchSettings.BROWSER_VERT_OFFSET + tm) + " --anchorBottom " + bm + " ")
103 + (Browser._theBrowser.getContentPane().getWidth() - ExploratorySearchSettings.BROWSER_HORZ_OFFSET - lm - rm) + " "
104 + (Browser._theBrowser.getContentPane().getHeight() - ExploratorySearchSettings.BROWSER_VERT_OFFSET - tm - bm) + " : " + url, null);
105 } else {
106 wt = frame.addText(ExploratorySearchSettings.BROWSER_HORZ_OFFSET + lm, ExploratorySearchSettings.BROWSER_VERT_OFFSET + tm,
107 "@iw: org.expeditee.items.widgets.JfxBrowser " +
108 (ExploratorySearchSettings.BrowserDefaultWidth.get() - lm - rm) + " " +
109 (ExploratorySearchSettings.BrowserDefaultHeight.get() - tm - bm) + " : " + url, null);
110 }
111
112 FrameIO.SaveFrame(frame); // save frame to disk
113 } catch(Exception e) {
114 e.printStackTrace();
115 }
116 }
117
118 /**
119 * Adds a text item to the cursor which is linked to a new frame with the mindmap active overlay.
120 */
121 public static void startMindmapSession() {
122 // Replace any text item on cursor with link to a new mindmap
123 FreeItems.getInstance().clear();
124 Text text = DisplayIO.getCurrentFrame().addText(FrameMouseActions.getX(), FrameMouseActions.getY(), " - Mindmap Session", null);
125 text.setParent(DisplayIO.getCurrentFrame());
126 FrameKeyboardActions.AddDate(text);
127 FrameMouseActions.pickup(text);
128 Frame frame = FrameIO.CreateNewFrame(text);
129 text.setLink("" + frame.getNumber());
130
131 // Clear new frame and add active overlay and @old
132 frame.removeAllItems(frame.getItems());
133 Text t = (Text) frame.addText(-150, 50, "@ao: 2", null, "overlayset3");
134 t.setAnchorLeft(-150.0f);
135 t.setAnchorTop(50.0f);
136 t = (Text) frame.addText(-150, 50, "@old", null);
137 t.setFamily("Roboto Condensed");
138 t.setSize(15.0f);
139 t.setColor(null);
140 t.setWidth(116);
141 t.setJustification(Justification.right);
142 t.setLinkMark(false);
143 t.setAnchorLeft(9.0f);
144 t.setAnchorBottom(114.0f);
145
146 FrameIO.SaveFrame(frame);
147 }
148
149 /**
150 * Adds a text item to the cursor which is linked to a new frame with the web browser active overlay and a JavaFX browser.
151 * @param caller The item that the action is called from
152 */
153 public static void startBrowserWithOverlay(Item caller) {
154 try {
155 String url;
156
157 Text urlItem = FreeItems.getTextAttachedToCursor();
158
159 // If there is a text item attached to the cursor, use it as the URL to load
160 if (urlItem != null) {
161 url = urlItem.getText();
162
163 // Remove the item, since the link to the browser session will added to the cursor
164 urlItem.delete();
165 } else {
166 // Otherwise use the home page specified in the settings
167 url = NetworkSettings.HomePage.get();
168 }
169
170 Text linkToBrowserSession = DisplayIO.getCurrentFrame().addText(FrameMouseActions.getX(), FrameMouseActions.getY(), url, null);
171 linkToBrowserSession.setParent(DisplayIO.getCurrentFrame());
172 FrameMouseActions.pickup(linkToBrowserSession);
173
174 // Create new frame
175 Frame frame = FrameIO.CreateNewFrame(linkToBrowserSession);
176
177 // link this text item to new frame
178 linkToBrowserSession.setLink("" + frame.getNumber());
179
180 // Remove everything from new frame
181 frame.removeAllItems(frame.getItems());
182
183 // Add web browser active overlay and @old
184 Text t = (Text) frame.addText(-150, 50, "@ao: 2", null, "overlayset2");
185 t.setAnchorLeft(-150.0f);
186 t.setAnchorTop(50.0f);
187 t = (Text) frame.addText(-150, 50, "@old", null);
188 t.setFamily("Roboto Condensed");
189 t.setSize(15.0f);
190 t.setColor(null);
191 t.setWidth(116);
192 t.setJustification(Justification.right);
193 t.setLinkMark(false);
194 t.setAnchorLeft(9.0f);
195 t.setAnchorBottom(114.0f);
196
197 Text wt;
198
199 // Extract marigns from settings
200 int lm = ExploratorySearchSettings.BrowserLeftMargin.get();
201 int rm = ExploratorySearchSettings.BrowserRightMargin.get();
202 int tm = ExploratorySearchSettings.BrowserTopMargin.get();
203 int bm = ExploratorySearchSettings.BrowserBottomMargin.get();
204
205 // Start Browser in fullscreen or default, depending on settings
206 if(ExploratorySearchSettings.BrowserFullScreen.get()) {
207 wt = frame.addText(ExploratorySearchSettings.BROWSER_HORZ_OFFSET + lm, ExploratorySearchSettings.BROWSER_VERT_OFFSET + tm,
208 "@iw: org.expeditee.items.widgets.JfxBrowser "
209 + ("--anchorLeft " + (lm + ExploratorySearchSettings.BROWSER_HORZ_OFFSET) + " --anchorRight " + rm + " --anchorTop "
210 + (ExploratorySearchSettings.BROWSER_VERT_OFFSET + tm) + " --anchorBottom " + bm + " ")
211 + (Browser._theBrowser.getContentPane().getWidth() - ExploratorySearchSettings.BROWSER_HORZ_OFFSET - lm - rm) + " "
212 + (Browser._theBrowser.getContentPane().getHeight() - ExploratorySearchSettings.BROWSER_VERT_OFFSET - tm - bm) + " : " + url, null);
213 } else {
214 wt = frame.addText(ExploratorySearchSettings.BROWSER_HORZ_OFFSET + lm, ExploratorySearchSettings.BROWSER_VERT_OFFSET + tm,
215 "@iw: org.expeditee.items.widgets.JfxBrowser " +
216 (ExploratorySearchSettings.BrowserDefaultWidth.get() - lm - rm) + " " +
217 (ExploratorySearchSettings.BrowserDefaultHeight.get() - tm - bm) + " : " + url, null);
218 }
219
220 FrameIO.SaveFrame(frame); // save frame to disk
221 } catch(Exception e) {
222 e.printStackTrace();
223 }
224 }
225
226}
Note: See TracBrowser for help on using the repository browser.