source: trunk/src/org/expeditee/actions/Help.java@ 1102

Last change on this file since 1102 was 1102, checked in by davidb, 6 years ago

Reworking of the code-base to separate logic from graphics. This version of Expeditee now supports a JFX graphics as an alternative to SWING

File size: 3.0 KB
Line 
1/**
2 * Help.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 java.util.Collection;
22import java.util.Collections;
23import java.util.Comparator;
24import java.util.LinkedList;
25import java.util.List;
26
27import org.expeditee.gio.EcosystemManager;
28import org.expeditee.gui.DisplayController;
29import org.expeditee.gui.Frame;
30import org.expeditee.items.Item;
31import org.expeditee.items.Text;
32
33public class Help {
34 /**
35 * Return a list of actions. TODO show the params they take. TODO link the
36 * actions to their help pages.
37 *
38 * @return
39 */
40 public static Collection<Item> getActions(String start, String end) {
41 return getItemList(Actions.getActions(), start, end);
42
43 }
44
45 public static Collection<Item> getActions(String start) {
46 return getItemList(Actions.getActions(), start, null);
47
48 }
49
50 public static Collection<Item> getActions() {
51 return getItemList(Actions.getActions(), null, null);
52
53 }
54
55 public static Collection<Item> getAgents(String start, String end) {
56 return getItemList(Actions.getAgents(), start, end);
57
58 }
59
60 public static Collection<Item> getAgents(String start) {
61 return getItemList(Actions.getAgents(), start, null);
62
63 }
64
65 public static Collection<Item> getAgents() {
66 return getItemList(Actions.getAgents(), null, null);
67 }
68
69 private static Collection<Item> getItemList(List<String> stringList,
70 String start, String end) {
71 Collection<Item> actions = new LinkedList<Item>();
72
73 Collections.sort(stringList, new Comparator<String>() {
74 public int compare(String a, String b) {
75 return String.CASE_INSENSITIVE_ORDER.compare(a, b);
76 }
77 });
78
79 Frame current = DisplayController.getCurrentFrame();
80 float x = DisplayController.getFloatMouseX();
81 float y = DisplayController.getFloatMouseY();
82
83 // Do case sensitive comparison
84 if (start != null)
85 start = start.toLowerCase();
86 if (end != null)
87 end = end.toLowerCase();
88
89 for (String s : stringList) {
90 String lower = s.toLowerCase();
91 if (start != null) {
92 if (end != null) {
93 if (lower.compareToIgnoreCase(start) < 0)
94 continue;
95 if (lower.compareToIgnoreCase(end) > 0)
96 break;
97 } else if (!lower.matches(start) && !lower.startsWith(start)) {
98 continue;
99 }
100 }
101
102 Text t = current.createNewText(s);
103 t.setWidth(1000);
104 t.setPosition(x, y);
105 y += t.getBoundsHeight();
106 actions.add(t);
107 }
108
109 return actions;
110 }
111}
Note: See TracBrowser for help on using the repository browser.