source: trunk/src/org/expeditee/settings/templates/TemplateSettings.java@ 1242

Last change on this file since 1242 was 1242, checked in by bln4, 5 years ago

Support for new regime in the form of new fields and conditional setting of all paths fields.

Settings are now able to generate their own representation. This allows for the user to explicitly inspect the default values.

When profiles are created, an optional parameter may now be provided. If not null, the new map parameter can contain default values for settings to apply to this profile. This allows for the creation of profiles to that have (for example), their username set to an explicit value. Multiuser mode uses this functionality for usernames and key values among other things.

Frames can now be asked were they are located on the file system. Furthermore, frame indirection is now a thing. Rather than containing data to display, an exp file can contain a line in the format of "REDIRECT:<path>" to go looking for that data. Frames are able to return both their logical (their exp file) and real (the file actually containing the data) paths.

Frames can now store data.

Further fixes to how edits from other users are loaded in.

File size: 5.9 KB
Line 
1/**
2 * TemplateSettings.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.settings.templates;
20
21import org.expeditee.core.Colour;
22import org.expeditee.gui.DisplayController;
23import org.expeditee.gui.Frame;
24import org.expeditee.gui.FrameUtils;
25import org.expeditee.gui.FreeItems;
26import org.expeditee.items.Item;
27import org.expeditee.items.ItemUtils;
28import org.expeditee.items.Text;
29import org.expeditee.setting.ArraySetting;
30import org.expeditee.setting.FrameSetting;
31import org.expeditee.setting.StringSetting;
32import org.expeditee.setting.TextSetting;
33
34public class TemplateSettings {
35
36 public static final StringSetting DefaultFrame = new StringSetting("The default frame", null) {
37 @Override
38 public boolean setSetting(Text text) {
39 _value = FrameUtils.getLink(text, _value);
40 return true;
41 }
42 };
43
44 public static final FrameSetting CursorFrame = new FrameSetting("Items on this frame will be used as the cursor (clearing the frame or removing the link will default back to a normal cursor)", "CursorFrame") {
45 @Override
46 public void run(Frame frame) {
47 FreeItems.getCursor().addAll(ItemUtils.CopyItems(frame.getAllItems()));
48 for (Item i : FreeItems.getCursor()) {
49 i.setParent(null);
50 }
51 DisplayController.setCursor(Item.HIDDEN_CURSOR);
52 DisplayController.setCursor(Item.DEFAULT_CURSOR);
53 }
54 };
55
56 public static final ArraySetting<Colour> ColorWheel = new ArraySetting<Colour>("The colours of items in the child frame are used to populate the colour wheel",
57 "ColorWheel", new Colour[] { Colour.BLACK, Colour.RED, Colour.BLUE, Item.GREEN, Colour.MAGENTA, Colour.YELLOW.darker(), Colour.WHITE }) {
58 @Override
59 public boolean setSetting(Text text) {
60 Frame child = text.getChild();
61 if (child == null) {
62 return false;
63 }
64 _value = FrameUtils.getColorWheel(child);
65 return true;
66 }
67 };
68
69 public static final ArraySetting<Colour> FillColorWheel = new ArraySetting<Colour>("The colours of items in the child frame are used to populate the colour wheel",
70 "FillColorWheel", new Colour[] { Colour.FromRGB255(255, 150, 150), Colour.FromRGB255(150, 150, 255), Colour.FromRGB255(150, 255, 150),
71 Colour.FromRGB255(255, 150, 255), Colour.FromRGB255(255, 255, 100), Colour.WHITE, Colour.BLACK }) {
72 @Override
73 public boolean setSetting(Text text) {
74 Frame child = text.getChild();
75 if (child == null) {
76 return false;
77 }
78 _value = FrameUtils.getColorWheel(child);
79 return true;
80 }
81 };
82
83 public static final ArraySetting<Colour> BackgroundColorWheel = new ArraySetting<Colour>("The colours of items in the child frame are used to populate the colour wheel",
84 "BackgroundColorWheel",
85 new Colour[] { Colour.FromRGB255(235, 235, 235), Colour.FromRGB255(225, 225, 255), Colour.FromRGB255(195, 255, 255),
86 Colour.FromRGB255(225, 255, 225), Colour.FromRGB255(255, 255, 195), Colour.FromRGB255(255, 225, 225),
87 Colour.FromRGB255(255, 195, 255), Colour.WHITE, Colour.GREY, Colour.DARK_GREY, Colour.BLACK, null }) {
88 @Override
89 public boolean setSetting(Text text) {
90 Frame child = text.getChild();
91 if (child == null) {
92 return false;
93 }
94 _value = FrameUtils.getColorWheel(child);
95 return true;
96 }
97 };
98
99 public static final TextSetting ItemTemplate = new TextSetting("Template for normal text items", "ItemTemplate") {
100 @Override
101 public Text generateText() {
102 return new Text("ItemTemplate");
103 }
104 };
105 public static final TextSetting AnnotationTemplate = new TextSetting("Template for annotation text items", "AnnotationTemplate") {
106 @Override
107 public Text generateText() {
108 Text t = new Text("AnnotationTemplate");
109 t.setColor(Colour.GREY);
110 return t;
111 }
112 };
113
114 public static final TextSetting CommentTemplate = new TextSetting("Template for code comment text items", "CommentTemplate") {
115 @Override
116 public Text generateText() {
117 Text t = new Text("CommentTemplate");
118 t.setColor(Colour.GREEN.darker());
119 return t;
120 }
121 };
122
123 public static final TextSetting StatTemplate = new TextSetting("Template for statistics (e.g. extracted attributes) text items", "StatTemplate") {
124 @Override
125 public Text generateText() {
126 Text t = new Text("StatsTemplate");
127 t.setColor(Colour.BLACK);
128 t.setBackgroundColor(new Colour(0.9F, 0.9F, 0.9F));
129 t.setFamily(Text.MONOSPACED_FONT);
130 t.setSize(14);
131 return t;
132 }
133 };
134
135 public static final TextSetting TitleTemplate = new TextSetting("Template for Title text item", "TitleTemplate") {
136 @Override
137 public Text generateText() {
138 Text t = new Text("TitleTemplate");
139 t.setSize(30);
140 t.setFontStyle("Bold");
141 t.setFamily("SansSerif");
142 t.setColor(Colour.BLUE);
143 t.setPosition(25, 50);
144 return t;
145 }
146 };
147
148 public static final TextSetting DotTemplate = new TextSetting("Template for dot items", "DotTemplate") {
149 @Override
150 public Text generateText() {
151 return new Text("DotTemplate");
152 }
153 };
154
155 public static final TextSetting TooltipTemplate = new TextSetting("Template for tooltips", "TooltipTemplate") {
156 @Override
157 public Text generateText() {
158 Text t = new Text("TooltipTemplate");
159 t.setColor(Colour.BLACK);
160 t.setBackgroundColor(new Colour(0.7F, 0.7F, 0.9F));
161 // t.setFamily(Text.MONOSPACED_FONT);
162 t.setSize(14);
163 return t;
164 }
165 };
166}
Note: See TracBrowser for help on using the repository browser.