source: trunk/src/org/expeditee/io/DefaultFrameReader.java@ 1415

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

Renamed Frame.getItems() to Frame.getSortedItems() to better represent its functionality.

-> org.apollo.ApolloGestureActions
-> org.apollo.ApolloSystem
-> org.expeditee.actions.Actions
-> org.expeditee.actions.Debug
-> org.expeditee.actions.ExploratorySearchActions
-> org.expeditee.actions.JfxBrowserActions
-> org.expeditee.actions.Misc
-> org.expeditee.actions.Navigation
-> org.expeditee.actions.ScriptBase
-> org.expeditee.actions.Simple
-> org.expeditee.agents.ComputeTree
-> org.expeditee.agents.CopyTree
-> org.expeditee.agents.DisplayComet
-> org.expeditee.agents.DisplayTree
-> org.expeditee.agents.DisplayTreeLeaves
-> org.expeditee.agents.GraphFramesetLinks
-> org.expeditee.agents.TreeProcessor
-> org.expeditee.gio.gesture.StandardGestureActions
-> org.expeditee.gui.DisplayController
-> org.expeditee.gui.FrameCreator
-> org.expeditee.gui.FrameIO
-> org.expeditee.io.DefaultTreeWriter
-> org.expeditee.io.JavaWriter
-> org.expeditee.io.PDF2Writer
-> org.expeditee.io.TXTWriter
-> org.expeditee.io.WebParser
-> org.expeditee.io.flowlayout.XGroupItem
-> org.expeditee.items.Dot
-> org.expeditee.items.Item
-> org.expeditee.items.ItemUtils
-> org.expeditee.network.FrameShare
-> org.expeditee.stats.TreeStats


Created ItemsList class to wrap ArrayList<Item>. Frames now use this new class to store its body list (used for display) as well as its primaryBody and surrogateBody.

-> org.expeditee.agents.Format
-> org.expeditee.agents.HFormat
-> org.expeditee.gio.gesture.StandardGestureActions
-> org.expeditee.gui.Frame
-> org.expeditee.gui.FrameUtils


Refactorted Frame.setResort(bool) to Frame.invalidateSorted() to better function how it is intended to with a more accurate name.

-> org.expeditee.agents.Sort


When writing out .exp files and getting attributes to respond to LEFT + RIGHT click, boolean items are by default true. This has always been the case. An ammendment to this is that defaults can now be established.
Also added 'EnterClick' functionality. If cursored over a item with this property and you press enter, it acts as if you have clicked on it instead.

-> org.expeditee.assets.resources-public.framesets.authentication.1.exp to 6.exp
-> org.expeditee.gio.gesture.StandardGestureActions
-> org.expeditee.gio.input.KBMInputEvent
-> org.expeditee.gio.javafx.JavaFXConversions
-> org.expeditee.gio.swing.SwingConversions
-> org.expeditee.gui.AttributeUtils
-> org.expeditee.io.Conversion
-> org.expeditee.io.DefaultFrameWriter
-> org.expeditee.items.Item


Fixed a bug caused by calling Math.abs on Integer.MIN_VALUE returning unexpected result. Due to zero being a thing, you cannot represent Math.abs(Integer.MIN_VALUE) in a Integer object. The solution is to use Integer.MIN_VALUE + 1 instead of Integer.MIN_VALUE.

-> org.expeditee.core.bounds.CombinationBounds
-> org.expeditee.io.flowlayout.DimensionExtent


Recoded the contains function in EllipticalBounds so that intersection tests containing circles work correctly.

-> org.expeditee.core.bounds.EllipticalBounds


Added toString() to PolygonBounds to allow for useful printing during debugging.

-> org.expeditee.core.bounds.PolygonBounds

Implemented Surrogate Mode!

-> org.expeditee.encryption.io.EncryptedExpReader
-> org.expeditee.encryption.io.EncryptedExpWriter
-> org.expeditee.encryption.items.surrogates.EncryptionDetail
-> org.expeditee.encryption.items.surrogates.Label
-> org.expeditee.gui.FrameUtils
-> org.expeditee.gui.ItemsList
-> org.expeditee.items.Item
-> org.expeditee.items.Text


???? Use Integer.MAX_VALUE cast to a float instead of Float.MAX_VALUE. This fixed some bug which I cannot remember.

-> org.expeditee.gio.TextLayoutManager
-> org.expeditee.gio.swing.SwingTextLayoutManager


Improved solution for dealing with the F10 key taking focus away from Expeditee due to it being a assessibility key.

-> org.expeditee.gio.swing.SwingInputManager


Renamed variable visibleItems in FrameGraphics.paintFrame to itemsToPaintCanditates to better represent functional intent.

-> org.expeditee.gui.FrameGraphics


Improved checking for if personal resources exist before recreating them

-> org.expeditee.gui.FrameIO


Repeated messages to message bay now have a visual feedback instead of just a beep. This visual feedback is in the form of a count of the amount of times it has repeated.

-> org.expeditee.gui.MessageBay


Updated comment on the Vector class to explain what vectors are.

-> org.expeditee.gui.Vector


Added constants to represent all of the property keys in DefaultFrameReader and DefaultFrameWriter.

-> org.expeditee.io.DefaultFrameReader
-> org.expeditee.io.DefaultFrameWriter


Updated the KeyList setting to be more heirarcial with how users will store their Secrets.

-> org.expeditee.settings.identity.secrets.KeyList

File size: 10.7 KB
Line 
1/**
2 * DefaultFrameReader.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.io;
20
21import java.io.BufferedReader;
22import java.io.File;
23import java.io.FileInputStream;
24import java.io.IOException;
25import java.io.InputStreamReader;
26import java.io.Reader;
27import java.lang.reflect.Method;
28import java.util.LinkedHashMap;
29import java.util.List;
30import java.util.LinkedList;
31
32import org.expeditee.core.Colour;
33import org.expeditee.core.Font;
34import org.expeditee.core.Point;
35import org.expeditee.encryption.items.EncryptionPermissionTriple;
36import org.expeditee.gui.Frame;
37import org.expeditee.items.Constraint;
38import org.expeditee.items.Dot;
39import org.expeditee.items.DotType;
40import org.expeditee.items.Item;
41import org.expeditee.items.Justification;
42import org.expeditee.items.Line;
43import org.expeditee.items.PermissionTriple;
44import org.expeditee.items.Text;
45
46public abstract class DefaultFrameReader implements FrameReader {
47
48 protected static LinkedHashMap<Character, Method> _ItemTags = null;
49 // IMPORTANT: keys in _ItemTagsExt must start with underscore as their first character
50 protected static LinkedHashMap<String, Method> _ItemTagsExt = null;
51
52 protected static List<Character> _DelayedItemTags = null;
53
54 protected static LinkedHashMap<Character, Method> _FrameTags = null;
55
56 protected static Class[] pString = { String.class };
57 protected static Class[] pInt = { int.class };
58 protected static Class[] pIntO = { Integer.class };
59 protected static Class[] pFloat = { float.class };
60 protected static Class[] pFloatO = { Float.class };
61 protected static Class[] pDouble = { double.class };
62 protected static Class[] pColor = { Colour.class };
63 protected static Class[] pBool = { boolean.class };
64 protected static Class[] pFont = { Font.class };
65 protected static Class[] pPoint = { Point.class };
66 protected static Class[] pArrow = { float.class, double.class, double.class };
67 protected static Class[] pList = { List.class };
68 protected static Class[] pIntArray = { int[].class };
69 protected static Class[] pItem = { Item.class };
70 protected static Class[] pJustification = { Justification.class };
71 protected static Class[] pPermission = { PermissionTriple.class };
72 protected static Class[] pDotType = { DotType.class };
73 protected static Class[] pEncPermission = { EncryptionPermissionTriple.class };
74
75 public DefaultFrameReader(){
76 if (_ItemTags != null && _FrameTags != null)
77 return;
78
79 _ItemTags = new LinkedHashMap<Character, Method>();
80 _ItemTagsExt = new LinkedHashMap<String, Method>();
81 _FrameTags = new LinkedHashMap<Character, Method>();
82 _DelayedItemTags = new LinkedList<Character>();
83
84 try {
85 _FrameTags.put('A', Frame.class.getMethod("setName", pString));
86 _FrameTags.put('V', Frame.class.getMethod("setVersion", pInt));
87 _FrameTags.put('p', Frame.class.getMethod("setPermission", pPermission));
88 _FrameTags.put('U', Frame.class.getMethod("setOwner", pString));
89 _FrameTags.put('D', Frame.class.getMethod("setDateCreated", pString));
90 _FrameTags.put('M', Frame.class.getMethod("setLastModifyUser", pString));
91 _FrameTags.put('d', Frame.class.getMethod("setLastModifyDate", pString));
92 _FrameTags.put('F', Frame.class.getMethod("setFrozenDate", pString));
93 _FrameTags.put('O', Frame.class.getMethod("setForegroundColor", pColor));
94 _FrameTags.put('B', Frame.class.getMethod("setBackgroundColor", pColor));
95 _FrameTags.put('K', Frame.class.getMethod("setEncryptionLabel", pString));
96 _FrameTags.put('T', Frame.class.getMethod("addToData", pString));
97 _FrameTags.put('E', Frame.class.getMethod("setEncryptionPermission", pEncPermission));
98 _FrameTags.put('G', Frame.class.getMethod("setGroup", pString));
99
100 // Note: As of 26/11/18 there are no unused letter item tags. Use other characters.
101 _ItemTags.put(DefaultFrameWriter.TYPE_AND_ID, Item.class.getMethod("setID", pInt));
102 _ItemTags.put(DefaultFrameWriter.DATE_CREATED, Item.class.getMethod("setDateCreated", pString));
103 _ItemTags.put(DefaultFrameWriter.COLOR, Item.class.getMethod("setColor", pColor));
104 _ItemTags.put(DefaultFrameWriter.BACKGROUND_COLOR, Item.class.getMethod("setBackgroundColor",
105 pColor));
106 _ItemTags.put(DefaultFrameWriter.BORDER_COLOR, Item.class.getMethod("setBorderColor",
107 pColor));
108
109 _ItemTags.put(DefaultFrameWriter.ANCHOR_LEFT, Item.class.getMethod("setAnchorLeft", pIntO));
110 _ItemTags.put(DefaultFrameWriter.ANCHOR_RIGHT, Item.class.getMethod("setAnchorRight", pIntO));
111 _ItemTags.put(DefaultFrameWriter.ANCHOR_TOP, Item.class.getMethod("setAnchorTop", pIntO));
112 _ItemTags.put(DefaultFrameWriter.ANCHOR_BOTTOM, Item.class.getMethod("setAnchorBottom", pIntO));
113
114 _ItemTags.put(DefaultFrameWriter.POSITION, Item.class.getMethod("setPosition", pPoint));
115 _ItemTags.put(DefaultFrameWriter.LINK, Item.class.getMethod("setLink", pString));
116 _ItemTags.put(DefaultFrameWriter.FORMULA, Item.class.getMethod("setFormula", pString));
117
118 _ItemTags.put(DefaultFrameWriter.ACTION, Item.class.getMethod("setActions", pList));
119 _ItemTags.put(DefaultFrameWriter.ACTION_MARK, Item.class.getMethod("setActionMark", pBool));
120 _ItemTags.put(DefaultFrameWriter.ACTION_CURSOR_ENTER, Item.class.getMethod("setActionCursorEnter",
121 pList));
122 _ItemTags.put(DefaultFrameWriter.ACTION_CURSOR_LEAVE, Item.class.getMethod("setActionCursorLeave",
123 pList));
124 _ItemTags.put(DefaultFrameWriter.ACTION_ENTER_FRAME, Item.class.getMethod("setActionEnterFrame",
125 pList));
126 _ItemTags.put(DefaultFrameWriter.ACTION_LEAVE_FRAME, Item.class.getMethod("setActionLeaveFrame",
127 pList));
128 _ItemTags.put(DefaultFrameWriter.DATA, Item.class.getMethod("addToData", pString));
129 _ItemTags.put(DefaultFrameWriter.HIGHLIGHT, Item.class.getMethod("setHighlight", pBool));
130 _ItemTags.put(DefaultFrameWriter.FILL_COLOR, Item.class.getMethod("setFillColor", pColor));
131 _ItemTags.put(DefaultFrameWriter.GRADIENT_COLOR, Item.class.getMethod("setGradientColor", pColor));
132 _ItemTags.put(DefaultFrameWriter.GRADIENT_ANGLE, Item.class.getMethod("setGradientAngle", pDouble));
133
134 _ItemTags.put(DefaultFrameWriter.FILL_PATTERN, Item.class.getMethod("setFillPattern", pString));
135 _ItemTags.put(DefaultFrameWriter.OWNER, Item.class.getMethod("setOwner", pString));
136 _ItemTags.put(DefaultFrameWriter.LINK_MARK, Item.class.getMethod("setLinkMark", pBool));
137 _ItemTags
138 .put(DefaultFrameWriter.LINK_FRAMESET, Item.class.getMethod("setLinkFrameset", pString));
139 _ItemTags
140 .put(DefaultFrameWriter.LINK_TEMPLATE, Item.class.getMethod("setLinkTemplate", pString));
141 _ItemTags.put(DefaultFrameWriter.LINE_PATTERN, Item.class.getMethod("setLinePattern", pIntArray));
142
143 _ItemTags.put(DefaultFrameWriter.ARROW, Item.class.getMethod("setArrow", pArrow));
144
145 _ItemTags.put(DefaultFrameWriter.DOT_TYPE, Dot.class.getMethod("setDotType", pDotType));
146 _ItemTags.put(DefaultFrameWriter.FILLED, Dot.class.getMethod("setFilled", pBool));
147
148 _ItemTags.put(DefaultFrameWriter.FONT, Text.class.getMethod("setFont", pFont));
149 _ItemTags.put(DefaultFrameWriter.SPACING, Text.class.getMethod("setSpacing", pFloat));
150 _ItemTags.put(DefaultFrameWriter.TEXT, Text.class.getMethod("appendLine", pString));
151 _ItemTags.put(DefaultFrameWriter.WORD_SPACING, Text.class.getMethod("setWordSpacing", pInt));
152 _ItemTags.put(DefaultFrameWriter.LETTER_SPACING, Text.class.getMethod("setLetterSpacing", pFloat));
153 _ItemTags.put(DefaultFrameWriter.INITIAL_SPACING, Text.class.getMethod("setInitialSpacing", pFloat));
154 _ItemTags.put(DefaultFrameWriter.WIDTH_TO_SAVE, Text.class.getMethod("setWidth", pIntO));
155 _ItemTags.put(DefaultFrameWriter.MIN_WIDTH_TO_SAVE, Text.class.getMethod("setMinWidth", pIntO));
156 _ItemTags.put(DefaultFrameWriter.JUSTIFICATION, Text.class.getMethod("setJustification", pJustification));
157 _ItemTags.put(DefaultFrameWriter.AUTO_WRAP_TO_SAVE, Text.class.getMethod("setAutoWrap", pBool));
158
159 _ItemTags.put(DefaultFrameWriter.THICKNESS, Item.class.getMethod("setThickness", pFloat));
160 _ItemTags.put(DefaultFrameWriter.LINE_IDS, Item.class.getMethod("setLineIDs", pString));
161 _ItemTags.put(DefaultFrameWriter.CONSTRAINT_IDS, Item.class.getMethod("setConstraintIDs", pString));
162
163 _ItemTags.put(DefaultFrameWriter.TOOLTIP, Item.class.getMethod("setTooltip", pString));
164 _ItemTags.put(DefaultFrameWriter.LINK_HISTORY, Item.class.getMethod("setLinkHistory", pBool));
165
166 _ItemTags.put(DefaultFrameWriter.PERMISSION, Item.class.getMethod("setPermission", pPermission));
167
168 _ItemTags.put(DefaultFrameWriter.MASK, Text.class.getMethod("setMask", pIntO));
169
170 // Lines and constraints are created differently
171 _ItemTags.put('L', Line.class.getMethod("setStartItem", pItem));
172 _ItemTags.put('C', Constraint.class.getMethod("getID", (Class[]) null));
173
174 _ItemTags.put(DefaultFrameWriter.MAGNETIZED_ITEM_LEFT, Item.class.getMethod("setMagnetizedItemLeft", pInt));
175 _DelayedItemTags.add('[');
176 _ItemTags.put(DefaultFrameWriter.MAGNETIZED_ITEM_RIGHT, Item.class.getMethod("setMagnetizedItemRight", pInt));
177 _DelayedItemTags.add(']');
178 _ItemTags.put(DefaultFrameWriter.MAGNETIZED_ITEM_TOP, Item.class.getMethod("setMagnetizedItemTop", pInt));
179 _DelayedItemTags.add('^');
180 _ItemTags.put(DefaultFrameWriter.MAGNETIZED_ITEM_BOTTOM, Item.class.getMethod("setMagnetizedItemBottom", pInt));
181 _DelayedItemTags.add('/');
182
183 _ItemTagsExt.put(DefaultFrameWriter.ENCRYPTION_LABEL_STR, Item.class.getMethod("setEncryptionLabelOnLoad", pString));
184
185 _ItemTagsExt.put(DefaultFrameWriter.PLACEHOLDER_STR, Text.class.getMethod("setPlaceholder", pString));
186 _ItemTagsExt.put(DefaultFrameWriter.SINGLE_LINE_ONLY_STR, Text.class.getMethod("setSingleLineOnly", pBool));
187 _ItemTagsExt.put(DefaultFrameWriter.TAB_INDEX_STR, Text.class.getMethod("setTabIndex", pInt));
188 _ItemTagsExt.put(DefaultFrameWriter.ACCEPTS_ENTER, Item.class.getMethod("setAcceptsEnter", pBool));
189 } catch (Exception e) {
190 e.printStackTrace();
191 }
192
193 }
194
195 public Frame readFrame(String fullPath) throws IOException {
196 File f = new File(fullPath);
197 Reader in = new InputStreamReader(new FileInputStream(fullPath), "UTF-8");
198 Frame frame = readFrame(new BufferedReader(in));
199 frame.setLastModifyDate(frame.getLastModifyDate(), f.lastModified());
200 return frame;
201 }
202}
Note: See TracBrowser for help on using the repository browser.