Ignore:
Timestamp:
08/07/08 11:44:58 (16 years ago)
Author:
ra33
Message:

Added Frame and Box variables to the Math calculations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/math/ExpediteeJEP.java

    r190 r196  
    8787                                Collection<Item> enclosed = FrameUtils.getItemsEnclosedBy(
    8888                                                frame, t.getEnclosedShape());
    89                                 Collection<Double> vector = new LinkedList<Double>();
    90                                 for (Item i : enclosed) {
    91                                         if (i instanceof Text && !i.isLineEnd()) {
    92                                                 Double value = AttributeUtils.getDoubleValue(i
    93                                                                 .getText());
    94                                                 if (value != null) {
    95                                                         vector.add(value);
    96                                                 }
    97                                         }
    98                                 }
    99                                 if (vector.size() > 0)
    100                                         addVariable(t.getText().toLowerCase(), MVector
    101                                                         .getInstance(vector.toArray()));
     89                                String variableName = t.getText().toLowerCase();
     90                               
     91                                addVectorVariable(enclosed, variableName);
    10292                        }
    10393                }
     94        }
     95
     96        /**
     97         * @param textItems
     98         * @param variableName
     99         */
     100        public void addVectorVariable(Collection<Item> items, String variableName) {
     101                Collection<Double> vector = new LinkedList<Double>();
     102                for (Item i : items) {
     103                        if (i instanceof Text && !i.isLineEnd()) {
     104                                Double value = AttributeUtils.getDoubleValue(i
     105                                                .getText());
     106                                if (value != null) {
     107                                        vector.add(value);
     108                                }
     109                        }
     110                }
     111                if (vector.size() > 0)
     112                        addVariable(variableName, MVector
     113                                        .getInstance(vector.toArray()));
    104114        }
    105115
Note: See TracChangeset for help on using the changeset viewer.