Ignore:
Timestamp:
05/21/08 09:40:52 (16 years ago)
Author:
ra33
Message:

Made LOTS of changes...
Added DisplayComet
A whole bunch more stats for items and events
Changed lots of stuff for drawing better especially using text as line endpoints

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/AttributeUtils.java

    r67 r70  
    33import java.awt.Color;
    44import java.awt.Font;
     5import java.awt.Point;
    56import java.lang.reflect.InvocationTargetException;
    67import java.lang.reflect.Method;
     
    2728        private static final String SEPARATOR_STRING = SEPARATOR_CHAR + " ";
    2829
     30        private static final int GET_LENGTH = "get".length();
     31
     32        private static int SET_LENGTH = "set".length();
     33
    2934        // List of method names to ignore when searching for a match
    3035        private static List<Method> _GetMethods = null;
     
    5661                        _Ignore.add("link");
    5762                        _Ignore.add("l");
     63                        _Ignore.add("position");
     64                        _Ignore.add("pos");
     65                        _Ignore.add("p");
    5866
    5967                        _AllowNull = new LinkedList<Method>();
     
    94102                        _GetMethods.add(Item.class.getMethod("getLinkFrameset", param));
    95103                        _GetMethods.add(Item.class.getMethod("getLinkTemplate", param));
     104                        _GetMethods.add(Item.class.getMethod("getPosition", param));
    96105
    97106                        _GetMethods.add(Text.class.getMethod("getFamily", param));
     
    109118                        _GetMethods.add(Frame.class.getMethod("getBackgroundColor", param));
    110119
     120                        Class[] pPoint = { Point.class };
    111121                        Class[] pString = { String.class };
    112122                        Class[] pInt = { int.class };
     
    119129
    120130                        _SetMethods = new HashMap<String, Method>();
    121 
     131                        _SetMethods.put("position", Item.class.getMethod("setPosition",
     132                                        pPoint));
     133                        _SetMethods.put("p", Item.class.getMethod("setPosition", pPoint));
     134                        _SetMethods.put("pos", Item.class.getMethod("setPosition", pPoint));
    122135                        _SetMethods.put("thickness", Item.class.getMethod("setThickness",
    123136                                        pFloat));
     
    143156
    144157                        _SetMethods.put("fillpattern", Item.class.getMethod(
     158                                        "setFillPattern", pString));
     159                        _SetMethods.put("fp", Item.class.getMethod(
    145160                                        "setFillPattern", pString));
    146161
     
    167182
    168183                        _SetMethods.put("linepattern", Item.class.getMethod(
     184                                        "setLinePattern", pIntArray));
     185                        _SetMethods.put("lp", Item.class.getMethod(
    169186                                        "setLinePattern", pIntArray));
    170187                        _SetMethods.put("linkframeset", Item.class.getMethod(
     
    250267                                                                        && convertJustificationToString((Integer) o) != null)
    251268                                                                attributes
    252                                                                                 .append(m.getName().substring(3))
     269                                                                                .append(m.getName().substring(GET_LENGTH))
    253270                                                                                .append(SEPARATOR_STRING)
    254271                                                                                .append(
     
    257274                                                        // -1 indicates default value
    258275                                                        else if (((Integer) o) > -1)
    259                                                                 attributes.append(m.getName().substring(3))
     276                                                                attributes.append(m.getName().substring(GET_LENGTH))
    260277                                                                                .append(SEPARATOR_STRING).append(o)
    261278                                                                                .append("\n");
     
    263280                                                        // -1 indicates default value
    264281                                                        if (((Float) o) > 0.0001)
    265                                                                 attributes.append(m.getName().substring(3))
     282                                                                attributes.append(m.getName().substring(GET_LENGTH))
    266283                                                                                .append(SEPARATOR_STRING).append(o)
    267284                                                                                .append("\n");
     
    269286                                                        // -1 indicates default value
    270287                                                        if (((Double) o) > 0.0001)
    271                                                                 attributes.append(m.getName().substring(3))
     288                                                                attributes.append(m.getName().substring(GET_LENGTH))
    272289                                                                                .append(SEPARATOR_STRING).append(o)
    273290                                                                                .append("\n");
     
    276293                                                        String s = Conversion.getKMSColorCode((Color) o);
    277294                                                        if (s != null)
    278                                                                 attributes.append(m.getName().substring(3))
     295                                                                attributes.append(m.getName().substring(GET_LENGTH))
    279296                                                                                .append(SEPARATOR_STRING).append(s)
    280297                                                                                .append("\n");
     298                                                } else if (o instanceof Point) {
     299                                                        Point p = (Point) o;
     300                                                        String s = (int) p.getX() + " " + (int) p.getY();
     301                                                        attributes.append(m.getName().substring(GET_LENGTH)).append(
     302                                                                        SEPARATOR_STRING).append(s).append("\n");
    281303                                                } else if (o instanceof Font) {
    282304                                                        Font f = (Font) o;
     
    294316                                                        s += "-" + f.getSize();
    295317
    296                                                         attributes.append(m.getName().substring(3)).append(
     318                                                        attributes.append(m.getName().substring(GET_LENGTH)).append(
    297319                                                                        SEPARATOR_STRING).append(s).append("\n");
    298320                                                } else if (o instanceof Text) {
    299                                                         attributes.append(m.getName().substring(3)).append(
     321                                                        attributes.append(m.getName().substring(GET_LENGTH)).append(
    300322                                                                        SEPARATOR_STRING).append(
    301323                                                                        ((Text) o).getFirstLine()).append("\n");
     
    303325                                                        List list = (List) o;
    304326                                                        for (Object ob : list)
    305                                                                 attributes.append(m.getName().substring(3))
     327                                                                attributes.append(m.getName().substring(GET_LENGTH))
    306328                                                                                .append(SEPARATOR_STRING).append(ob)
    307329                                                                                .append("\n");
     
    309331                                                        // true is the default for boolean values
    310332                                                        if (!((Boolean) o).booleanValue())
    311                                                                 attributes.append(m.getName().substring(3))
     333                                                                attributes.append(m.getName().substring(GET_LENGTH))
    312334                                                                                .append(SEPARATOR_STRING).append(o)
    313335                                                                                .append("\n");
    314336                                                } else
    315                                                         attributes.append(m.getName().substring(3)).append(
     337                                                        attributes.append(m.getName().substring(GET_LENGTH)).append(
    316338                                                                        SEPARATOR_STRING).append(o).append("\n");
    317339
     
    325347                                                // are in the AllowNull list
    326348                                        } else if (_AllowNull.contains(m))
    327                                                 attributes.append(m.getName().substring(3)).append(
     349                                                attributes.append(m.getName().substring(GET_LENGTH)).append(
    328350                                                                SEPARATOR_CHAR + "\n");
    329351                                } catch (IllegalArgumentException e) {
     
    530552                        Object current = null;
    531553                        Object[] param = {};
    532 
     554                        Class toSetClass = toSet.getClass();
     555                        Class toSetSuperClass = toSetClass.getSuperclass();
    533556                        // find the corresponding get method for this set method
    534557                        for (Method m : _GetMethods) {
    535                                 if (m.getDeclaringClass() == toSet.getClass()
    536                                                 && m.getName()
    537                                                                 .endsWith(possible.getName().substring(3))) {
     558                                if ((m.getDeclaringClass() == toSetClass || m.getDeclaringClass() == toSetSuperClass)
     559                                                && m.getName().substring(GET_LENGTH).equals(
     560                                                                possible.getName().substring(SET_LENGTH))) {
    538561                                        try {
    539562                                                current = m.invoke(toSet, param);
Note: See TracChangeset for help on using the changeset viewer.