Ignore:
Timestamp:
10/31/18 10:22:24 (6 years ago)
Author:
bln4
Message:

org.expeditee.gui.FrameIO ->

Added ability to specify were frames are being loaded from.

File:
1 edited

Legend:

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

    r1102 r1188  
    392392                        Attribute a = attribSet.get(prop);
    393393                        // Make sure the classes of the methods match the item
    394                         if (a != null && a.getter != null && a.getter.getDeclaringClass().isAssignableFrom(toExtract.getClass())) {
    395                                
     394                        if (a != null && a.getter != null && a.getter.getDeclaringClass().isAssignableFrom(toExtract.getClass())) {     
    396395                                try {
    397396                                        String s = getValue(prop, a, toExtract, true);
    398                                         if (s == null)
     397                                        if (s == null) {
    399398                                                continue;
     399                                        }
    400400                                        // Append the attributes
    401401                                        attributes.append(a.displayName)
     
    410410
    411411                // if no attributes were extracted
    412                 if (attributes.length() <= 0)
     412                if (attributes.length() <= 0) {
    413413                        return null;
    414 
    415                 while (attributes.charAt(attributes.length() - 1) == '\n')
     414                }
     415
     416                while (attributes.charAt(attributes.length() - 1) == '\n') {
    416417                        attributes.delete(attributes.length() - 1, attributes.length());
     418                }
    417419
    418420                // create the text Item
     
    450452                        // are in the AllowNull list
    451453                        if (_AllowNull.contains(a.getter)) {
    452                                 if (name.equals("color"))
     454                                if (name.equals("color")) {
    453455                                        o = "default";
    454                                 else if (name.equals("backgroundcolor"))
     456                                } else if (name.equals("backgroundcolor")) {
    455457                                        o = "transparent";
    456                                 else if (name.equals("foregroundcolor"))
     458                                } else if (name.equals("foregroundcolor")) {
    457459                                        o = "auto";
    458                                 else
     460                                } else {
    459461                                        o = "";
     462                                }
    460463                        } else {
    461464                                return null;
     
    469472                if (o instanceof Integer) {
    470473                        Integer i = (Integer) o;
    471                         if (i == Item.DEFAULT_INTEGER)
     474                        if (i == Item.DEFAULT_INTEGER) {
    472475                                return null;
     476                        }
    473477                        if (a.getter.getName().endsWith("Justification")
    474                                         && ((Justification) o).toString() != null)
     478                                        && ((Justification) o).toString() != null) {
    475479                                o = ((Justification) o).toString();
    476480                        // -1 indicates default value
    477                         else
     481                        } else {
    478482                                o = i;
     483                        }
    479484                } else if (o instanceof Float) {
    480485                        if (((Float) o) < -0.0001)
     486                         {
    481487                                return null;
    482488                        // Null indicates default
    483489                        // o = Math.round((Float) o);
     490                        }
    484491                } else if (o instanceof Double) {
    485492                        // -1 indicates default value
    486                         if (((Double) o) < 0.0001)
     493                        if (((Double) o) < 0.0001) {
    487494                                return null;
     495                        }
    488496                } else if (o instanceof Colour) {
    489497                        // converts the color to the Expeditee code
    490498                        o = Conversion.getExpediteeColorCode((Colour) o);
    491                         if (o == null)
     499                        if (o == null) {
    492500                                return null;
     501                        }
    493502                } else if (o instanceof Point) {
    494503                        Point p = (Point) o;
     
    498507
    499508                        String s = f.getFamilyName() + "-";
    500                         if (f.isPlain())
     509                        if (f.isPlain()) {
    501510                                s += "Plain";
    502 
    503                         if (f.isBold())
     511                        }
     512
     513                        if (f.isBold()) {
    504514                                s += "Bold";
    505 
    506                         if (f.isItalic())
     515                        }
     516
     517                        if (f.isItalic()) {
    507518                                s += "Italic";
     519                        }
    508520
    509521                        s += "-" + f.getSize();
     
    514526                        List list = (List) o;
    515527                        StringBuffer sb = new StringBuffer();
    516                         for (Object ob : list)
     528                        for (Object ob : list) {
    517529                                // TODO check that this works ok
    518530                                if (sb.length() == 0) {
     
    521533                                        sb.append('\n').append(a.displayName).append(AttributeValuePair.SEPARATOR_STRING).append(ob);
    522534                                }
     535                        }
    523536                        return sb.toString();
    524537                } else if (o instanceof int[]) {
     
    532545                } else if (o instanceof Boolean) {
    533546                        // true is the default for boolean values
    534                         if (((Boolean) o).booleanValue())
     547                        if (((Boolean) o).booleanValue()) {
    535548                                return null;
     549                        }
    536550                }
    537551                return o.toString();
     
    557571                        int minAttributeLength) {
    558572                // error checking
    559                 if (toSet == null || attribs == null)
     573                if (toSet == null || attribs == null) {
    560574                        return false;
     575                }
    561576
    562577                ensureReady();
     
    589604                        // attribute merging
    590605                        if (!avp.hasAttribute()
    591                                         || avp.getAttribute().length() < minAttributeLength)
     606                                        || avp.getAttribute().length() < minAttributeLength) {
    592607                                return false;
     608                        }
    593609
    594610                        // check if the next string is another attribute to merge or a
     
    699715                // if there are duplicate methods with the same name
    700716                List<Method> possibles = new LinkedList<Method>();
    701                 if (a.setter.getDeclaringClass().isInstance(toSet))
     717                if (a.setter.getDeclaringClass().isInstance(toSet)) {
    702718                        possibles.add(a.setter);
     719                }
    703720                int i = 0;
    704721                while (attribSet.containsKey(attribute + i)) {
     
    741758
    742759                if(possibles.size() == 0){
    743                         if(invokeAttributeGetMethod(avp.getAttribute(), toSet) == null)
     760                        if(invokeAttributeGetMethod(avp.getAttribute(), toSet) == null) {
    744761                                throw new NoSuchAttributeException(avp.getAttribute(), toSet.getClass().getSimpleName());
     762                        }
    745763                        throw new ReadOnlyAttributeException(avp.getAttribute(), toSet.getClass().getSimpleName());
    746764                }
Note: See TracChangeset for help on using the changeset viewer.