source: trunk/src/org/expeditee/io/FrameReader.java@ 67

Last change on this file since 67 was 67, checked in by ra33, 16 years ago

Fixed a bunch of problems with rectangles and resizing the window, as well as adding some more unit tests etc.

File size: 4.7 KB
Line 
1package org.expeditee.io;
2
3import java.awt.Color;
4import java.awt.Font;
5import java.awt.Point;
6import java.io.IOException;
7import java.lang.reflect.Method;
8import java.util.LinkedHashMap;
9import java.util.List;
10
11import org.expeditee.gui.Frame;
12import org.expeditee.items.Constraint;
13import org.expeditee.items.Item;
14import org.expeditee.items.Line;
15import org.expeditee.items.Text;
16
17public abstract class FrameReader {
18 protected static LinkedHashMap<Character, Method> _ItemTags = null;
19
20 protected static LinkedHashMap<Character, Method> _FrameTags = null;
21
22 protected static Class[] pString = { String.class };
23 protected static Class[] pInt = { int.class };
24 protected static Class[] pFloat = { float.class };
25 protected static Class[] pColor = { Color.class };
26 protected static Class[] pBool = { boolean.class };
27 protected static Class[] pFont = { Font.class };
28 protected static Class[] pPoint = { Point.class };
29 protected static Class[] pArrow = { int.class, double.class };
30 protected static Class[] pList = { List.class };
31 protected static Class[] pIntArray = { int[].class };
32 protected static Class[] pItem = { Item.class };
33
34 public FrameReader(){
35 if (_ItemTags != null && _FrameTags != null)
36 return;
37
38 _ItemTags = new LinkedHashMap<Character, Method>();
39 _FrameTags = new LinkedHashMap<Character, Method>();
40
41 try {
42 _FrameTags.put('A', Frame.class.getMethod("setFrameName", pString));
43 _FrameTags.put('V', Frame.class.getMethod("setVersion", pInt));
44 _FrameTags
45 .put('p', Frame.class.getMethod("setProtection", pString));
46 _FrameTags.put('U', Frame.class.getMethod("setOwner", pString));
47 _FrameTags.put('D', Frame.class
48 .getMethod("setDateCreated", pString));
49 _FrameTags.put('M', Frame.class.getMethod("setLastModifyUser",
50 pString));
51 _FrameTags.put('d', Frame.class.getMethod("setLastModifyDate",
52 pString));
53 _FrameTags
54 .put('F', Frame.class.getMethod("setFrozenDate", pString));
55
56 _FrameTags.put('O', Frame.class.getMethod("setForegroundColor",
57 pColor));
58 _FrameTags.put('B', Frame.class.getMethod("setBackgroundColor",
59 pColor));
60
61 _ItemTags.put('S', Item.class.getMethod("setID", pInt));
62 _ItemTags.put('s', Item.class.getMethod("setDateCreated", pString));
63 _ItemTags.put('d', Item.class.getMethod("setColor", pColor));
64 _ItemTags.put('G', Item.class.getMethod("setBackgroundColor",
65 pColor));
66 _ItemTags.put('P', Item.class.getMethod("setPosition", pPoint));
67 _ItemTags.put('F', Item.class.getMethod("setLink", pString));
68 _ItemTags.put('X', Item.class.getMethod("setAction", pList));
69 _ItemTags.put('x', Item.class.getMethod("setActionMark", pBool));
70 _ItemTags.put('U', Item.class.getMethod("setActionCursorEnter",
71 pList));
72 _ItemTags.put('V', Item.class.getMethod("setActionCursorLeave",
73 pList));
74 _ItemTags.put('W', Item.class.getMethod("setActionEnterFrame",
75 pList));
76 _ItemTags.put('Y', Item.class.getMethod("setActionLeaveFrame",
77 pList));
78 _ItemTags.put('D', Item.class.getMethod("setData", pString));
79 _ItemTags.put('u', Item.class.getMethod("setHighlight", pBool));
80 _ItemTags.put('e', Item.class.getMethod("setFillColor", pColor));
81 _ItemTags.put('i', Item.class.getMethod("setFillPattern", pString));
82 _ItemTags.put('o', Item.class.getMethod("setOwner", pString));
83 _ItemTags.put('n', Item.class.getMethod("setLinkMark", pBool));
84 _ItemTags
85 .put('q', Item.class.getMethod("setLinkFrameset", pString));
86 _ItemTags
87 .put('y', Item.class.getMethod("setLinkTemplate", pString));
88 _ItemTags.put('g', Item.class
89 .getMethod("setLinePattern", pIntArray));
90
91 _ItemTags.put('j', Item.class.getMethod("setArrow", pArrow));
92
93 _ItemTags.put('f', Text.class.getMethod("setFont", pFont));
94 _ItemTags.put('t', Text.class.getMethod("setSpacing", pInt));
95 _ItemTags.put('T', Text.class.getMethod("appendLine", pString));
96
97 _ItemTags.put('a', Text.class.getMethod("setWordSpacing", pInt));
98 _ItemTags.put('b', Text.class.getMethod("setLetterSpacing", pInt));
99 _ItemTags.put('m', Text.class.getMethod("setInitialSpacing", pInt));
100 _ItemTags.put('w', Text.class.getMethod("setWidth", pInt));
101 _ItemTags.put('k', Text.class.getMethod("setJustification", pInt));
102
103 _ItemTags.put('h', Item.class.getMethod("setThickness", pFloat));
104 _ItemTags.put('l', Item.class.getMethod("setLineIDs", pString));
105 _ItemTags.put('c', Item.class
106 .getMethod("setConstraintIDs", pString));
107 // Lines and constraints are created differently
108 _ItemTags.put('L', Line.class.getMethod("setStartItem", pItem));
109 _ItemTags.put('C', Constraint.class.getMethod("getID",
110 (Class[]) null));
111 } catch (Exception e) {
112 e.printStackTrace();
113 }
114
115 }
116
117 public abstract Frame readFrame(String fullPath) throws IOException;
118}
Note: See TracBrowser for help on using the repository browser.