Changeset 584


Ignore:
Timestamp:
12/08/13 17:16:58 (11 years ago)
Author:
jts21
Message:

Make FrameReader an interface and move it's HashMap to DefaultFrameReader

Location:
trunk/src/org/expeditee/io
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/io/ExpReader.java

    r504 r584  
    2222 *
    2323 */
    24 public class ExpReader extends FrameReader {
     24public class ExpReader extends DefaultFrameReader {
    2525
    2626        public static final String EXTENTION = ".exp";
  • trunk/src/org/expeditee/io/FrameReader.java

    r476 r584  
    11package org.expeditee.io;
    22
    3 import java.awt.Color;
    4 import java.awt.Font;
    5 import java.awt.Point;
    63import java.io.BufferedReader;
    7 import java.io.FileInputStream;
    84import java.io.IOException;
    9 import java.io.InputStreamReader;
    10 import java.io.Reader;
    11 import java.lang.reflect.Method;
    12 import java.util.LinkedHashMap;
    13 import java.util.List;
    145
    156import org.expeditee.gui.Frame;
    16 import org.expeditee.items.Constraint;
    17 import org.expeditee.items.DotType;
    18 import org.expeditee.items.Item;
    19 import org.expeditee.items.Justification;
    20 import org.expeditee.items.Line;
    21 import org.expeditee.items.PermissionPair;
    22 import org.expeditee.items.Text;
    237
    24 public abstract class FrameReader {
    25         protected static LinkedHashMap<Character, Method> _ItemTags = null;
    26 
    27         protected static LinkedHashMap<Character, Method> _FrameTags = null;
    28        
    29         protected static Class[] pString = { String.class };
    30         protected static Class[] pInt = { int.class };
    31         protected static Class[] pIntO = { Integer.class };
    32         protected static Class[] pFloat = { float.class };
    33         protected static Class[] pFloatO = { Float.class };
    34         protected static Class[] pColor = { Color.class };
    35         protected static Class[] pBool = { boolean.class };
    36         protected static Class[] pFont = { Font.class };
    37         protected static Class[] pPoint = { Point.class };
    38         protected static Class[] pArrow = { float.class, double.class, double.class };
    39         protected static Class[] pList = { List.class };
    40         protected static Class[] pIntArray = { int[].class };
    41         protected static Class[] pItem = { Item.class };
    42         protected static Class[] pJustification = { Justification.class };
    43         protected static Class[] pPermission = { PermissionPair.class };
    44        
    45         public FrameReader(){
    46                 if (_ItemTags != null && _FrameTags != null)
    47                         return;
    48 
    49                 _ItemTags = new LinkedHashMap<Character, Method>();
    50                 _FrameTags = new LinkedHashMap<Character, Method>();
    51 
    52                 try {
    53                         _FrameTags.put('A', Frame.class.getMethod("setName", pString));
    54                         _FrameTags.put('V', Frame.class.getMethod("setVersion", pInt));
    55                         _FrameTags
    56                                         .put('p', Frame.class.getMethod("setPermission", pPermission));
    57                         _FrameTags.put('U', Frame.class.getMethod("setOwner", pString));
    58                         _FrameTags.put('D', Frame.class
    59                                         .getMethod("setDateCreated", pString));
    60                         _FrameTags.put('M', Frame.class.getMethod("setLastModifyUser",
    61                                         pString));
    62                         _FrameTags.put('d', Frame.class.getMethod("setLastModifyDate",
    63                                         pString));
    64                         _FrameTags
    65                                         .put('F', Frame.class.getMethod("setFrozenDate", pString));
    66 
    67                         _FrameTags.put('O', Frame.class.getMethod("setForegroundColor",
    68                                         pColor));
    69                         _FrameTags.put('B', Frame.class.getMethod("setBackgroundColor",
    70                                         pColor));
    71 
    72                         _ItemTags.put('S', Item.class.getMethod("setID", pInt));
    73                         _ItemTags.put('s', Item.class.getMethod("setDateCreated", pString));
    74                         _ItemTags.put('d', Item.class.getMethod("setColor", pColor));
    75                         _ItemTags.put('G', Item.class.getMethod("setBackgroundColor",
    76                                         pColor));
    77                         _ItemTags.put('K', Item.class.getMethod("setBorderColor",
    78                                         pColor));
    79                         _ItemTags.put('H', Item.class.getMethod("setAnchorRight", pFloatO));
    80                         _ItemTags.put('I', Item.class.getMethod("setAnchorBottom", pFloatO));
    81                         _ItemTags.put('P', Item.class.getMethod("setPosition", pPoint));
    82                         _ItemTags.put('F', Item.class.getMethod("setLink", pString));
    83                         _ItemTags.put('J', Item.class.getMethod("setFormula", pString));
    84                        
    85                         _ItemTags.put('X', Item.class.getMethod("setActions", pList));
    86                         _ItemTags.put('x', Item.class.getMethod("setActionMark", pBool));
    87                         _ItemTags.put('U', Item.class.getMethod("setActionCursorEnter",
    88                                         pList));
    89                         _ItemTags.put('V', Item.class.getMethod("setActionCursorLeave",
    90                                         pList));
    91                         _ItemTags.put('W', Item.class.getMethod("setActionEnterFrame",
    92                                         pList));
    93                         _ItemTags.put('Y', Item.class.getMethod("setActionLeaveFrame",
    94                                         pList));
    95                         _ItemTags.put('D', Item.class.getMethod("addToData", pString));
    96                         _ItemTags.put('u', Item.class.getMethod("setHighlight", pBool));
    97                         _ItemTags.put('e', Item.class.getMethod("setFillColor", pColor));
    98                         _ItemTags.put('E', Item.class.getMethod("setGradientColor", pColor));
    99                         _ItemTags.put('Q', Item.class.getMethod("setGradientAngle", pInt));
    100                        
    101                         _ItemTags.put('i', Item.class.getMethod("setFillPattern", pString));
    102                         _ItemTags.put('o', Item.class.getMethod("setOwner", pString));
    103                         _ItemTags.put('n', Item.class.getMethod("setLinkMark", pBool));
    104                         _ItemTags
    105                                         .put('q', Item.class.getMethod("setLinkFrameset", pString));
    106                         _ItemTags
    107                                         .put('y', Item.class.getMethod("setLinkTemplate", pString));
    108                         _ItemTags.put('g', Item.class
    109                                         .getMethod("setLinePattern", pIntArray));
    110 
    111                         _ItemTags.put('j', Item.class.getMethod("setArrow", pArrow));
    112 
    113                         _ItemTags.put('v', Item.class.getMethod("setDotType", new Class[]{DotType.class}));
    114                         _ItemTags.put('z', Item.class.getMethod("setFilled", pBool));
    115                        
    116                         _ItemTags.put('f', Text.class.getMethod("setFont", pFont));
    117                         _ItemTags.put('t', Text.class.getMethod("setSpacing", pInt));
    118                         _ItemTags.put('T', Text.class.getMethod("appendLine", pString));
    119                         _ItemTags.put('a', Text.class.getMethod("setWordSpacing", pInt));
    120                         _ItemTags.put('b', Text.class.getMethod("setLetterSpacing", pInt));
    121                         _ItemTags.put('m', Text.class.getMethod("setInitialSpacing", pInt));
    122                         _ItemTags.put('w', Text.class.getMethod("setWidth", pIntO));
    123                         _ItemTags.put('k', Text.class.getMethod("setJustification", pJustification));
    124 
    125                         _ItemTags.put('h', Item.class.getMethod("setThickness", pFloat));
    126                         _ItemTags.put('l', Item.class.getMethod("setLineIDs", pString));
    127                         _ItemTags.put('c', Item.class
    128                                         .getMethod("setConstraintIDs", pString));
    129                         // Lines and constraints are created differently
    130                         _ItemTags.put('L', Line.class.getMethod("setStartItem", pItem));
    131                         _ItemTags.put('C', Constraint.class.getMethod("getID",
    132                                         (Class[]) null));
    133                 } catch (Exception e) {
    134                         e.printStackTrace();
    135                 }
    136                
    137         }
    138        
    139         public Frame readFrame(String fullPath) throws IOException {
    140                 Reader in = new InputStreamReader(new FileInputStream(fullPath), "UTF-8");
    141                 return readFrame(new BufferedReader(in));
    142         }
    143        
    144         public abstract Frame readFrame(BufferedReader frameContents) throws IOException;
     8public interface FrameReader {
     9        public Frame readFrame(String fullPath) throws IOException;
     10        public Frame readFrame(BufferedReader frameContents) throws IOException;
    14511}
  • trunk/src/org/expeditee/io/KMSReader.java

    r410 r584  
    2727 *
    2828 */
    29 public class KMSReader extends FrameReader {
     29public class KMSReader extends DefaultFrameReader {
    3030
    3131        private BufferedReader _reader = null;
Note: See TracChangeset for help on using the changeset viewer.