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/Frame.java

    r69 r70  
    3434public class Frame implements ImageObserver {
    3535
    36         private static final int TITLE_MAX_START_POS = 200;
     36        private static final int TITLE_MAX_START_POS = 100;
    3737
    3838        public static final Color[] COLOR_WHEEL = { Color.BLACK, Color.GRAY,
     
    341341
    342342        public Text getItemTemplate() {
    343                 Text t = UserSettings.ItemTemplate;
    344 
    345                 // check for an updated template...
    346                 for (Item i : this.getItems()) {
    347                         if (ItemUtils.isTag(i, ItemUtils.TAG_ITEM_TEMPLATE)) {
    348                                 t = (Text) i;
    349                                 break;
    350                         }
    351                 }
    352 
    353                 // If the item is linked apply any attribute pairs on the child frame
    354                 String link = t.getAbsoluteLink();
    355                 // need to get link first because copy doesnt copy the link
    356                 t = t.copy();
    357                 if (link != null) {
    358                         t.setLink(null);
    359                         Frame childFrame = FrameIO.LoadFrame(link);
    360                         if (childFrame != null) {
    361                                 // read in attribute value pairs
    362                                 for (Text attribute : childFrame.getBodyTextItems(false)) {
    363                                         AttributeUtils.SetAttribute(t, attribute);
    364                                 }
    365                         }
     343                return getTemplate(UserSettings.ItemTemplate,
     344                                ItemUtils.TAG_ITEM_TEMPLATE);
     345        }
     346
     347        public Text getAnnotationTemplate() {
     348                Text t = getTemplate(UserSettings.AnnotationTemplate,
     349                                ItemUtils.TAG_ANNOTATION_TEMPLATE);
     350
     351                if (t == null) {
     352                        t = getItemTemplate();
    366353                }
    367354
     
    369356        }
    370357
    371         public Text getAnnotationTemplate() {
    372                 Text t = null;
    373                 // check for an updated template...
    374                 for (Item i : this.getItems()) {
    375                         if (ItemUtils.isTag(i, ItemUtils.TAG_ANNOTATION_TEMPLATE)) {
    376                                 t = (Text) i;
    377                                 break;
    378                         }
    379                 }
     358        public Text getCodeCommentTemplate() {
     359                Text t = getTemplate(UserSettings.CodeCommentTemplate,
     360                                ItemUtils.TAG_CODE_COMMENT_TEMPLATE);
    380361
    381362                if (t == null) {
    382                         if (UserSettings.AnnotationTemplate != null)
    383                                 t = UserSettings.AnnotationTemplate;
    384                         else
    385                                 t = getItemTemplate();
    386                 }
    387 
    388                 return t.copy();
    389         }
    390 
    391         public Text getCodeCommentTemplate() {
    392                 Text t = null;
    393 
    394                 // check for an updated template...
    395                 for (Item i : this.getItems()) {
    396                         if (ItemUtils.isTag(i, ItemUtils.TAG_CODE_COMMENT_TEMPLATE)) {
    397                                 t = (Text) i;
    398                                 break;
    399                         }
    400                 }
    401 
    402                 if (t == null) {
    403                         if (UserSettings.CodeCommentTemplate != null)
    404                                 t = UserSettings.CodeCommentTemplate;
    405                         else
    406                                 t = getItemTemplate();
    407                 }
    408 
    409                 return t.copy();
     363                        t = getItemTemplate();
     364                }
     365
     366                return t;
    410367        }
    411368
     
    420377         */
    421378        public List<Item> getItemsWithin(Polygon poly) {
    422                 ArrayList<Item> results = new ArrayList<Item>();
     379                List<Item> results = new ArrayList<Item>();
    423380
    424381                for (Item i : _body)
     
    11141071
    11151072        /**
    1116          * TODO document what this method is actually doing and why Merge text?!?!
     1073         * This method is for merging frames or setting frame attributes via
     1074         * injecting a text item into the frameName item.
    11171075         *
    11181076         * @param toMerge
    1119          * @return the items that cant be merged?!?!
     1077         * @return the items that cant be merged
    11201078         */
    11211079        public List<Item> merge(List<Item> toMerge) {
     
    11911149        }
    11921150
     1151        public Dot createDot() {
     1152                Dot dot = new Dot(DisplayIO.getRealMouseX(), DisplayIO.getMouseY(),
     1153                                getNextItemID());
     1154
     1155                Text template = getTemplate(UserSettings.LineTemplate,
     1156                                ItemUtils.TAG_LINE_TEMPLATE);
     1157                float thickness = template.getThickness();
     1158                if(thickness > 0)
     1159                        dot.setThickness(template.getThickness());
     1160                dot.setColor(template.getColor());
     1161                // reset attributes
     1162                dot.setParent(this);
     1163                return dot;
     1164        }
     1165
     1166        private Text getTemplate(Text defaultTemplate, int templateTag) {
     1167                Text t = defaultTemplate;
     1168
     1169                // check for an updated template...
     1170                for (Item i : this.getItems()) {
     1171                        if (ItemUtils.isTag(i, templateTag)) {
     1172                                t = (Text) i;
     1173                                break;
     1174                        }
     1175                }
     1176
     1177                // If the item is linked apply any attribute pairs on the child frame
     1178                String link = t.getAbsoluteLink();
     1179                // need to get link first because copy doesnt copy the link
     1180                t = t.copy();
     1181                if (link != null) {
     1182                        t.setLink(null);
     1183                        Frame childFrame = FrameIO.LoadFrame(link);
     1184                        if (childFrame != null) {
     1185                                // read in attribute value pairs
     1186                                for (Text attribute : childFrame.getBodyTextItems(false)) {
     1187                                        AttributeUtils.SetAttribute(t, attribute);
     1188                                }
     1189                        }
     1190                }
     1191                return t;
     1192        }
     1193
    11931194        private Text getItemTemplate(char firstChar) {
    11941195                switch (firstChar) {
Note: See TracChangeset for help on using the changeset viewer.