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

Last change on this file since 289 was 241, checked in by ra33, 16 years ago
File size: 5.3 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.Justification;
15import org.expeditee.items.Line;
16import org.expeditee.items.Permission;
17import org.expeditee.items.Text;
18
19public abstract class FrameReader {
20 protected static LinkedHashMap<Character, Method> _ItemTags = null;
21
22 protected static LinkedHashMap<Character, Method> _FrameTags = null;
23
24 protected static Class[] pString = { String.class };
25 protected static Class[] pInt = { int.class };
26 protected static Class[] pFloat = { float.class };
27 protected static Class[] pFloatO = { Float.class };
28 protected static Class[] pColor = { Color.class };
29 protected static Class[] pBool = { boolean.class };
30 protected static Class[] pFont = { Font.class };
31 protected static Class[] pPoint = { Point.class };
32 protected static Class[] pArrow = { float.class, double.class };
33 protected static Class[] pList = { List.class };
34 protected static Class[] pIntArray = { int[].class };
35 protected static Class[] pItem = { Item.class };
36 protected static Class[] pJustification = { Justification.class };
37 protected static Class[] pPermission = { Permission.class };
38
39 public FrameReader(){
40 if (_ItemTags != null && _FrameTags != null)
41 return;
42
43 _ItemTags = new LinkedHashMap<Character, Method>();
44 _FrameTags = new LinkedHashMap<Character, Method>();
45
46 try {
47 _FrameTags.put('A', Frame.class.getMethod("setName", pString));
48 _FrameTags.put('V', Frame.class.getMethod("setVersion", pInt));
49 _FrameTags
50 .put('p', Frame.class.getMethod("setPermission", pPermission));
51 _FrameTags.put('U', Frame.class.getMethod("setOwner", pString));
52 _FrameTags.put('D', Frame.class
53 .getMethod("setDateCreated", pString));
54 _FrameTags.put('M', Frame.class.getMethod("setLastModifyUser",
55 pString));
56 _FrameTags.put('d', Frame.class.getMethod("setLastModifyDate",
57 pString));
58 _FrameTags
59 .put('F', Frame.class.getMethod("setFrozenDate", pString));
60
61 _FrameTags.put('O', Frame.class.getMethod("setForegroundColor",
62 pColor));
63 _FrameTags.put('B', Frame.class.getMethod("setBackgroundColor",
64 pColor));
65
66 _ItemTags.put('S', Item.class.getMethod("setID", pInt));
67 _ItemTags.put('s', Item.class.getMethod("setDateCreated", pString));
68 _ItemTags.put('d', Item.class.getMethod("setColor", pColor));
69 _ItemTags.put('G', Item.class.getMethod("setBackgroundColor",
70 pColor));
71 _ItemTags.put('K', Item.class.getMethod("setBorderColor",
72 pColor));
73 _ItemTags.put('H', Item.class.getMethod("setAnchorRight", pFloatO));
74 _ItemTags.put('I', Item.class.getMethod("setAnchorBottom", pFloatO));
75 _ItemTags.put('P', Item.class.getMethod("setPosition", pPoint));
76 _ItemTags.put('F', Item.class.getMethod("setLink", pString));
77 _ItemTags.put('J', Item.class.getMethod("setFormula", pString));
78
79 _ItemTags.put('X', Item.class.getMethod("setActions", pList));
80 _ItemTags.put('x', Item.class.getMethod("setActionMark", pBool));
81 _ItemTags.put('U', Item.class.getMethod("setActionCursorEnter",
82 pList));
83 _ItemTags.put('V', Item.class.getMethod("setActionCursorLeave",
84 pList));
85 _ItemTags.put('W', Item.class.getMethod("setActionEnterFrame",
86 pList));
87 _ItemTags.put('Y', Item.class.getMethod("setActionLeaveFrame",
88 pList));
89 _ItemTags.put('D', Item.class.getMethod("addToData", pString));
90 _ItemTags.put('u', Item.class.getMethod("setHighlight", pBool));
91 _ItemTags.put('e', Item.class.getMethod("setFillColor", pColor));
92 _ItemTags.put('E', Item.class.getMethod("setGradientColor", pColor));
93 _ItemTags.put('i', Item.class.getMethod("setFillPattern", pString));
94 _ItemTags.put('o', Item.class.getMethod("setOwner", pString));
95 _ItemTags.put('n', Item.class.getMethod("setLinkMark", pBool));
96 _ItemTags
97 .put('q', Item.class.getMethod("setLinkFrameset", pString));
98 _ItemTags
99 .put('y', Item.class.getMethod("setLinkTemplate", pString));
100 _ItemTags.put('g', Item.class
101 .getMethod("setLinePattern", pIntArray));
102
103 _ItemTags.put('j', Item.class.getMethod("setArrow", pArrow));
104
105 _ItemTags.put('f', Text.class.getMethod("setFont", pFont));
106 _ItemTags.put('t', Text.class.getMethod("setSpacing", pInt));
107 _ItemTags.put('T', Text.class.getMethod("appendLine", pString));
108 _ItemTags.put('a', Text.class.getMethod("setWordSpacing", pInt));
109 _ItemTags.put('b', Text.class.getMethod("setLetterSpacing", pInt));
110 _ItemTags.put('m', Text.class.getMethod("setInitialSpacing", pInt));
111 _ItemTags.put('w', Text.class.getMethod("setWidth", pInt));
112 _ItemTags.put('k', Text.class.getMethod("setJustification", pJustification));
113
114 _ItemTags.put('h', Item.class.getMethod("setThickness", pFloat));
115 _ItemTags.put('l', Item.class.getMethod("setLineIDs", pString));
116 _ItemTags.put('c', Item.class
117 .getMethod("setConstraintIDs", pString));
118 // Lines and constraints are created differently
119 _ItemTags.put('L', Line.class.getMethod("setStartItem", pItem));
120 _ItemTags.put('C', Constraint.class.getMethod("getID",
121 (Class[]) null));
122 } catch (Exception e) {
123 e.printStackTrace();
124 }
125
126 }
127
128 public abstract Frame readFrame(String fullPath) throws IOException;
129}
Note: See TracBrowser for help on using the repository browser.