Changeset 154


Ignore:
Timestamp:
07/22/08 10:05:32 (16 years ago)
Author:
ra33
Message:

Fixing bugs for Rob

Location:
trunk/src/org/expeditee
Files:
1 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/actions/Actions.java

    r143 r154  
    1919import org.expeditee.gui.DisplayIO;
    2020import org.expeditee.gui.Frame;
     21import org.expeditee.gui.FrameGraphics;
    2122import org.expeditee.gui.FrameIO;
    2223import org.expeditee.gui.FrameUtils;
     
    470471                        Logger.Log(e);
    471472                }
     473                FrameGraphics.refresh(false);
    472474
    473475                return;
  • trunk/src/org/expeditee/actions/Misc.java

    r140 r154  
    103103                String errorMessage = "Error deleting " + deletedFrame;
    104104                try {
    105                         if (FrameIO.DeleteFrame(toDelete)) {
     105                        String deletedFrameName = FrameIO.DeleteFrame(toDelete);
     106                        if (deletedFrameName != null) {
     107                                DisplayIO.Back();
     108                                //Remove any links on the previous frame to the one being deleted
    106109                                Frame current = DisplayIO.getCurrentFrame();
    107110                                for (Item i : current.getItems())
     
    111114                                                i.setLink(null);
    112115                                        }
    113                                 DisplayIO.Back();
    114                                 FrameGraphics.Repaint();
    115                                 MessageBay.displayMessage(deletedFrame + " deleted");
     116                                MessageBay.displayMessage(deletedFrame + " renamed "
     117                                                + deletedFrameName);
     118                                //FrameGraphics.Repaint();
    116119                                return;
    117120                        }
     
    302305
    303306        public static void getUnicodeCharacters(int start, int finish) {
    304                 if(start < 0 && finish < 0){
     307                if (start < 0 && finish < 0) {
    305308                        throw new RuntimeException("Parameters must be non negative");
    306309                }
    307                 //Swap the start and finish if they are inthe wrong order
    308                 if(start > finish){
     310                // Swap the start and finish if they are inthe wrong order
     311                if (start > finish) {
    309312                        start += finish;
    310                         finish = start-finish;
     313                        finish = start - finish;
    311314                        start = start - finish;
    312315                }
    313316                StringBuilder charList = new StringBuilder();
    314317                int count = 0;
    315                 charList.append(String.format("Unicode block 0x%x - 0x%x", start, finish));
     318                charList.append(String.format("Unicode block 0x%x - 0x%x", start,
     319                                finish));
    316320                System.out.println();
    317                 //charList.append("Unicode block: ").append(String.format(format, args))
    318                 for (char i = (char)start; i < (char)finish; i++) {
     321                // charList.append("Unicode block: ").append(String.format(format,
     322                // args))
     323                for (char i = (char) start; i < (char) finish; i++) {
    319324                        if (Character.isDefined(i)) {
    320                                 if(count++ % 64 == 0)
     325                                if (count++ % 64 == 0)
    321326                                        charList.append(Text.LINE_SEPARATOR);
    322327                                charList.append(Character.valueOf(i));
     
    325330                attachTextToCursor(charList.toString());
    326331        }
    327        
     332
    328333        /**
    329334         * Gets a single block of Unicode characters.
    330          * @param start the start of the block
     335         *
     336         * @param start
     337         *            the start of the block
    331338         */
    332339        public static void getUnicodeCharacters(int start) {
    333                 getUnicodeCharacters(start,start + 256);
    334         }
    335        
     340                getUnicodeCharacters(start, start + 256);
     341        }
     342
    336343        public static void getMathSymbols() {
    337                 getUnicodeCharacters('\u2200','\u2300');
     344                getUnicodeCharacters('\u2200', '\u2300');
    338345        }
    339346
     
    442449                        String frameName = ImageFrame(loaded, format, path);
    443450                        if (frameName != null)
    444                                 MessageBay.displayMessage("Frame successfully saved to "
    445                                                 + path + frameName);
     451                                MessageBay.displayMessage("Frame successfully saved to " + path
     452                                                + frameName);
    446453                        else
    447454                                MessageBay.errorMessage("Could not find image writer for "
     
    471478                        // TODO is there a built in method which will do this faster?
    472479
    473                         MessageBay.displayMessage("Copying file " + existingFile
    474                                         + " to " + newFileName + "...");
     480                        MessageBay.displayMessage("Copying file " + existingFile + " to "
     481                                        + newFileName + "...");
    475482                        FrameIO.copyFile(existingFile, newFileName);
    476483                        MessageBay.displayMessage("File copied successfully");
  • trunk/src/org/expeditee/actions/Simple.java

    r147 r154  
    429429                if (_step) {
    430430                        if (child != DisplayIO.getCurrentFrame()) {
    431                                 DisplayIO.setCurrentFrame(child);
     431                                DisplayIO.setCurrentFrame(child, true);
    432432                        }
    433433                        DisplayIO.addToBack(child);
     
    493493                        DisplayIO.removeFromBack();
    494494                        if (DisplayIO.getCurrentFrame() != current.getParent())
    495                                 DisplayIO.setCurrentFrame(current.getParent());
     495                                DisplayIO.setCurrentFrame(current.getParent(), true);
    496496                }
    497497
     
    516516                Frame parent = item.getParentOrCurrentFrame();
    517517                if (!parent.equals(DisplayIO.getCurrentFrame())) {
    518                         DisplayIO.setCurrentFrame(parent);
     518                        DisplayIO.setCurrentFrame(parent, true);
    519519                }
    520520
     
    18551855                        boolean success = false;
    18561856                        try {
    1857                                 success = FrameIO.DeleteFrame(frame);
     1857                                success = FrameIO.DeleteFrame(frame) != null;
    18581858                                if (!success && _verbose)
    18591859                                        MessageBay.warningMessage(errorMessage);
     
    21192119                                                }
    21202120                                        }
    2121                                         DisplayIO.setCurrentFrame(frame);
     2121                                        DisplayIO.setCurrentFrame(frame, false);
    21222122                                        pause(thisFramesPause);
    21232123
  • trunk/src/org/expeditee/agents/ComputeTree.java

    r108 r154  
    55import org.expeditee.gui.AttributeUtils;
    66import org.expeditee.gui.Frame;
     7import org.expeditee.gui.FrameGraphics;
    78import org.expeditee.gui.FrameIO;
    89import org.expeditee.items.Item;
     
    2324                        message("Nothing to compute!");
    2425                }
    25 
     26               
    2627                return null;
    2728        }
  • trunk/src/org/expeditee/agents/DefaultAgent.java

    r133 r154  
    22
    33import org.expeditee.gui.Frame;
     4import org.expeditee.gui.FrameGraphics;
    45import org.expeditee.gui.MessageBay;
    56import org.expeditee.gui.TimeKeeper;
     
    101102                _running = false;
    102103
     104                FrameGraphics.requestRefresh(true);
    103105                SessionStats.setEnabled(true);
    104106        }
  • trunk/src/org/expeditee/agents/DisplayComet.java

    r121 r154  
    5353                        if(_stop)
    5454                                return null;
    55                         DisplayIO.setCurrentFrame(_frameList.pop());
     55                        DisplayIO.setCurrentFrame(_frameList.pop(), true);
    5656                        _frameCount++;
    5757                        pause(_delay);
  • trunk/src/org/expeditee/agents/DisplayTree.java

    r133 r154  
    33import org.expeditee.gui.DisplayIO;
    44import org.expeditee.gui.Frame;
     5import org.expeditee.gui.FrameUtils;
    56import org.expeditee.gui.MessageBay;
    67import org.expeditee.items.Item;
     
    6263                // ignore loops
    6364                if (toProcess != DisplayIO.getCurrentFrame())
    64                         DisplayIO.setCurrentFrame(toProcess);
    65                 // FrameUtils.DisplayFrame(toProcess,false);
     65                        DisplayIO.setCurrentFrame(toProcess, false);
    6666                // parse the frame for any pause settings
    6767                delay(toProcess);
  • trunk/src/org/expeditee/agents/Format.java

    r143 r154  
    4646                //Check the position of the cursor and only format stuff inside the same box as the cursor
    4747                Collection<Text> itemsToFormat = FrameUtils.getCurrentTextItems();
    48                 if(itemsToFormat.size() <= 1){
     48                if(itemsToFormat.size() < 1){
    4949                        itemsToFormat = start.getBodyTextItems(true);
    5050                }
  • trunk/src/org/expeditee/gui/AttributeUtils.java

    r147 r154  
    436436                List<String> values = attribs.getTextList();
    437437                // if no pairs exist, we are done
    438                 if (values.size() == 0
     438                if (values == null || values.size() == 0
    439439                                || (values.size() == 1 && values.get(0).length() == 0)) {
    440440                        return false;
  • trunk/src/org/expeditee/gui/Browser.java

    r147 r154  
    5454        private boolean _isExiting = false;
    5555
     56        private static boolean _initComplete = false;
     57
    5658        /**
    5759         * Constructs a new Browser object, then launches it
     
    7678                                                .getLocation().y
    7779                                                - _theBrowser.getOrigin().y;
     80                                _initComplete = true;
    7881                        }
    7982                });
     
    97100        public boolean isExisting() {
    98101                return _isExiting;
     102        }
     103
     104        public static boolean isInitComplete() {
     105                return _initComplete;
    99106        }
    100107
     
    167174                EntitySaveManager.getInstance().addSaveStateChangedEventListener(this);
    168175
    169                 // Set the drag and drop handler
    170                 setTransferHandler(FrameDNDTransferHandler.getInstance());
     176                String version = System.getProperty("java.version");
     177
     178                if (version.startsWith("1.6")) {
     179                        // Set the drag and drop handler
     180                        setTransferHandler(FrameDNDTransferHandler.getInstance());
     181                } else {
     182                        System.out.println("Upgrade to Java 1.6 to enable drag and drop");
     183                }
    171184
    172185                try {
     
    373386                                                MessageBay
    374387                                                                .displayMessage("Stopping Simple programs..."); // TODO:
    375                                                                                                                                                                 // Only
    376                                                                                                                                                                 // stop
    377                                                                                                                                                                 // if
    378                                                                                                                                                                 // need
    379                                                                                                                                                                 // to...
     388                                                // Only
     389                                                // stop
     390                                                // if
     391                                                // need
     392                                                // to...
    380393                                                while (Simple.isProgramRunning()) {
    381394                                                        Thread.sleep(100); // Brook: What purpose does this
    382                                                                                                 // serve?
     395                                                        // serve?
    383396                                                }
    384397                                                MessageBay.displayMessage("Stopping Agents..."); // TODO:
    385                                                                                                                                                         // Only
    386                                                                                                                                                         // stop
    387                                                                                                                                                         // if
    388                                                                                                                                                         // need
    389                                                                                                                                                         // to...
     398                                                // Only
     399                                                // stop
     400                                                // if
     401                                                // need
     402                                                // to...
    390403                                                while (Actions.isAgentRunning()) {
    391404                                                        Thread.sleep(100); // Brook: What purpose does this
    392                                                                                                 // serve?
     405                                                        // serve?
    393406                                                }
    394407                                        } catch (Exception e) {
  • trunk/src/org/expeditee/gui/DisplayIO.java

    r152 r154  
    251251        }
    252252
    253         private static boolean _typed = false;
    254 
    255         public static void setKeyTyped(boolean val) {
    256                 _typed = val;
    257         }
    258 
    259         public static boolean getKeyTyped() {
    260                 return _typed;
    261         }
     253//      private static boolean _typed = false;
     254//
     255//      public static void setKeyTyped(boolean val) {
     256//              _typed = val;
     257//      }
     258//
     259//      public static boolean getKeyTyped() {
     260//              return _typed;
     261//      }
    262262
    263263        /**
     
    326326                return null;
    327327        }
    328 
    329         /**
    330          * Sets the currently displayed Frame to the given Frame
    331          *
    332          * @param frame
    333          *            The Frame to display on the screen
    334          */
    335         public static void setCurrentFrame(Frame frame) {
     328       
     329        public static void setCurrentFrame(Frame frame, boolean incrementStats) {
    336330                if (frame == null)
    337331                        return;
     
    357351                                        + " is already the current frame.");
    358352                        return;
    359                 } else {
     353                } else if(incrementStats) {
    360354                        SessionStats.AccessedFrame();
    361355                }
     
    654648                if (_TwinFrames) {
    655649                        // if this is the first time TwinFrames has been toggled on,
    656                         // load
    657                         // the user's first frame
     650                        // load the user's first frame
    658651                        if (_VisitedFrames[opposite].size() == 0) {
    659652                                FrameIO.SuspendCache();
    660                                 setCurrentFrame(FrameIO.LoadFrame(UserSettings.FirstFrame));
     653                                setCurrentFrame(FrameIO.LoadFrame(UserSettings.FirstFrame), true);
    661654                                FrameIO.ResumeCache();
    662655                        } else {
    663656                                // otherwise, restore the frame from the side's back-stack
    664657                                setCurrentFrame(FrameIO.LoadFrame(_VisitedFrames[opposite]
    665                                                 .pop()));
     658                                                .pop()), true);
    666659                        }
    667660
     
    682675
    683676                FrameGraphics.Clear();
     677                FrameGraphics.requestRefresh(false);
    684678                FrameGraphics.Repaint();
    685679        }
  • trunk/src/org/expeditee/gui/Frame.java

    r147 r154  
    13521352                // Make it the width of the page
    13531353                // t.setMaxWidth(FrameGraphics.getMaxFrameSize().width);
    1354                 if (t.getWidth() <= 0) {
     1354                //if (t.getWidth() <= 0) {
    13551355                        t.setRightMargin(FrameGraphics.getMaxFrameSize().width);
    1356                 }
     1356                //}
    13571357                addItem(t);
    13581358                return t;
  • trunk/src/org/expeditee/gui/FrameGraphics.java

    r147 r154  
    123123                        _MaxSize.setSize(max.width, newMaxHeight);
    124124                }
    125 
    126                 if (DisplayIO.getCurrentFrame() != null) {
    127                         DisplayIO.getCurrentFrame().setBuffer(null);
    128                         DisplayIO.getCurrentFrame().refreshSize(_MaxSize);
     125                Frame current = DisplayIO.getCurrentFrame();
     126                if (current != null) {
     127                        current.setBuffer(null);
     128                        current.refreshSize(getMaxFrameSize());
     129                        if (DisplayIO.isTwinFramesOn()) {
     130                                Frame opposite = DisplayIO.getOppositeFrame();
     131                                //if (opposite != null) {
     132                                        opposite.setBuffer(null);
     133                                        opposite.refreshSize(getMaxFrameSize());
     134                                //}
     135                        }
    129136                }
    130137
    131138                if (newMaxHeight > 0) {
    132                         MessageBay.updateSize();       
     139                        MessageBay.updateSize();
    133140                }
    134141        }
     
    398405                                                if (toPaint == DisplayIO.getCurrentFrame()) {
    399406                                                        // If exactly one end of the line is floating...
    400                                                        
    401                                                        
    402                                                        
     407
    403408                                                        if (line.getEndItem().isFloating()
    404409                                                                        ^ line.getStartItem().isFloating()) {
    405 //                                                              Line l = TransposeLine(line, line.getEndItem(),
    406 //                                                                              toPaint, 0, 0);
    407 //                                                              if (l == null)
    408 //                                                                      l = TransposeLine(line,
    409 //                                                                                      line.getStartItem(), toPaint, 0, 0);
    410 //                                                              if (l == null)
    411 //                                                                      l = line;
    412 //                                                              lines.add(l);
    413                                                         } else{
    414                                                                 //lines.add(line);
     410                                                                // Line l = TransposeLine(line,
     411                                                                // line.getEndItem(),
     412                                                                // toPaint, 0, 0);
     413                                                                // if (l == null)
     414                                                                // l = TransposeLine(line,
     415                                                                // line.getStartItem(), toPaint, 0, 0);
     416                                                                // if (l == null)
     417                                                                // l = line;
     418                                                                // lines.add(l);
     419                                                        } else {
     420                                                                // lines.add(line);
    415421                                                        }
    416422                                                } else {
    417 //                                                      if (line.getEndItem().isFloating()
    418 //                                                                      ^ line.getStartItem().isFloating()) {
    419 //                                                              lines.add(TransposeLine(line,
    420 //                                                                              line.getEndItem(), toPaint,
    421 //                                                                              FrameMouseActions.getY(), -DisplayIO
    422 //                                                                                              .getMiddle()));
    423 //                                                              lines.add(TransposeLine(line, line
    424 //                                                                              .getStartItem(), toPaint,
    425 //                                                                              FrameMouseActions.getY(), -DisplayIO
    426 //                                                                                              .getMiddle()));
    427 //                                                      }
     423                                                        // if (line.getEndItem().isFloating()
     424                                                        // ^ line.getStartItem().isFloating()) {
     425                                                        // lines.add(TransposeLine(line,
     426                                                        // line.getEndItem(), toPaint,
     427                                                        // FrameMouseActions.getY(), -DisplayIO
     428                                                        // .getMiddle()));
     429                                                        // lines.add(TransposeLine(line, line
     430                                                        // .getStartItem(), toPaint,
     431                                                        // FrameMouseActions.getY(), -DisplayIO
     432                                                        // .getMiddle()));
     433                                                        // }
    428434                                                }
    429435                                        }
  • trunk/src/org/expeditee/gui/FrameIO.java

    r130 r154  
    292292                if (_Cache.containsKey(fresh.getName().toLowerCase()))
    293293                        addToCache(fresh);
    294                 DisplayIO.setCurrentFrame(fresh);
     294                DisplayIO.setCurrentFrame(fresh, false);
    295295        }
    296296
     
    421421         * @param toDelete
    422422         *            The Frame to be deleted
    423          * @return The result of File.delete()
    424          */
    425         public static boolean DeleteFrame(Frame toDelete) throws IOException,
     423         * @return The name the deleted frame was changed to, or null if the delete failed
     424         */
     425        public static String DeleteFrame(Frame toDelete) throws IOException,
    426426                        SecurityException {
    427427                if (toDelete == null)
    428                         return false;
     428                        return null;
    429429
    430430                // Dont delete the zero frame
     
    458458                toDelete.setFrameNumber(lastNumber + 1);
    459459                toDelete.path = framePath;
    460                 FrameIO.SaveFrame(toDelete);
     460                ForceSaveFrame(toDelete);
    461461
    462462                if (_Cache.containsKey(oldFrameName))
     
    468468                ff.close();
    469469
    470                 return del.delete();
     470                if( del.delete()){
     471                        return toDelete.getName();
     472                }
     473               
     474                return null;
    471475        }
    472476
  • trunk/src/org/expeditee/gui/FrameKeyboardActions.java

    r147 r154  
    2727import org.expeditee.items.Line;
    2828import org.expeditee.items.Permission;
     29import org.expeditee.items.StringUtils;
    2930import org.expeditee.items.Text;
    3031import org.expeditee.items.XRayable;
     
    139140                        text = createText(ch);
    140141                        justify(text);
    141                        
     142
    142143                        FrameUtils.setLastEdited(text);
    143144                        DisplayIO.setTextCursor(text, Text.NONE);
     
    190191         */
    191192        private static void justify(Text text) {
    192                 //Check if that text item is inside an enclosing rectangle...
    193                 //Set its max width accordingly
     193                // Check if that text item is inside an enclosing rectangle...
     194                // Set its max width accordingly
    194195                Polygon enclosure = FrameUtils.getEnlosingPolygon();
    195                 if(enclosure != null){
     196                if (enclosure != null) {
    196197                        Rectangle bounds = enclosure.getBounds();
    197198                        text.setRightMargin(bounds.x + bounds.width);
    198                 }else{
     199                } else {
    199200                        text.setRightMargin(FrameGraphics.getMaxFrameSize().width);
    200201                }
     
    300301                        break;
    301302                case Text.HOME:
     303                case Text.LINE_HOME:
    302304                        NavigationActions.ZeroFrame();
    303305                        break;
    304306                case Text.END:
     307                case Text.LINE_END:
    305308                        NavigationActions.LastFrame();
    306309                        break;
     
    673676                                                .getSystemClipboard().getContents(null)
    674677                                                .getTransferData(DataFlavor.stringFlavor));
     678                                // Covert the line separator char when pasting in
     679                                // windows (\r\n) or max (\r)
     680                                clip = StringUtils.convertNewLineChars(clip);
    675681
    676682                                Item clicked = FrameUtils.getCurrentItem();
     
    812818                                return;
    813819
    814 //                      if (text.getWidth() < 0)
    815 //                              text.setWidth(text.getBoundsWidth() - Item.MARGIN_RIGHT
    816 //                                              - UserSettings.Gravity);
     820                        // if (text.getWidth() < 0)
     821                        // text.setWidth(text.getBoundsWidth() - Item.MARGIN_RIGHT
     822                        // - UserSettings.Gravity);
    817823                        justify(text);
    818824                        break;
     
    11601166                                        || Frame.itemAttachedToCursor())
    11611167                                dummyItem.getParentOrCurrentFrame().removeItem(dummyItem);
     1168                        dummyItem.setRightMargin(FrameGraphics.getMaxFrameSize().width);
    11621169                        DisplayIO.resetCursorOffset();
    11631170                        FrameGraphics.Repaint();
  • trunk/src/org/expeditee/gui/FrameUtils.java

    r147 r154  
    385385
    386386                Parse(toDisplay);
    387                 DisplayIO.setCurrentFrame(toDisplay);
     387                DisplayIO.setCurrentFrame(toDisplay, addToBack);
    388388                FrameMouseActions.updateCursor();
    389389                // FrameMouseActions.getInstance().refreshHighlights();
     
    639639                                        + UserSettings.FirstFrame);
    640640                        UserSettings.FirstFrame = profile.getName();
    641                         DisplayIO.setCurrentFrame(profile);
     641                        DisplayIO.setCurrentFrame(profile, true);
    642642                } else {
    643                         DisplayIO.setCurrentFrame(firstFrame);
     643                        DisplayIO.setCurrentFrame(firstFrame, true);
    644644                }
    645645                // }
     
    866866                                                        && ItemUtils.startsWithTag(i, ItemUtils.TAG_VECTOR)
    867867                                                        && i.getLink() != null) {
    868                                                 // TODO It is possible to get into an infinate loop if a
    869                                                 // frame contains an @ao which leads to a frame with an
    870                                                 // @v which points back to the frame with the @ao
    871                                                 Frame vector = FrameIO.LoadFrame(i.getAbsoluteLink());
    872                                                 // Get the permission from off the vector frame
    873                                                 Permission vectorPermission = Permission.getPermission(
    874                                                                 vector.getAnnotationValue("permission"),
    875                                                                 Permission.none);
    876                                                 // If the frame permission is lower, use that
    877                                                 vectorPermission = Permission.min(vectorPermission,
    878                                                                 permission);
    879                                                 // Highest permissable permission for vectors is copy
    880                                                 vectorPermission = Permission.min(vectorPermission,
    881                                                                 Permission.copy);
    882                                                 if (vector != null) {
    883                                                         String scaleString = AttributeUtils
    884                                                                         .getValue(((Text) i).getText());
    885                                                         Float scale = 1F;
    886                                                         try {
    887                                                                 scale = Float.parseFloat(scaleString);
    888                                                         } catch (Exception e) {
    889                                                         }
    890                                                         Vector newVector = new Vector(vector,
    891                                                                         vectorPermission, i.getPosition(), scale, i
    892                                                                                         .getColor(), i.getBackgroundColor());
    893                                                         i.setOverlay(newVector);
    894                                                         vectors.add(newVector);
    895                                                 }
     868                                                addVector(vectors, Permission.none, permission, i);
     869                                        } else if (!FrameGraphics.isXRayMode()
     870                                                        && ItemUtils.startsWithTag(i,
     871                                                                        ItemUtils.TAG_ACTIVE_VECTOR)
     872                                                        && i.getLink() != null) {
     873                                                addVector(vectors, Permission.followLinks, permission,
     874                                                                i);
    896875                                        }
    897876                                        // check for new OVERLAY items
     
    907886                                                }
    908887
    909                                                 Frame overlay = FrameIO.LoadFrame(i.getAbsoluteLink());
     888                                                Frame overlayFrame = FrameIO.LoadFrame(i
     889                                                                .getAbsoluteLink());
    910890                                                // Parse(overlay);
    911                                                 if (overlay != null && !overlays.contains(overlay))
    912                                                         overlays.add(new Overlay(overlay, Permission.none));
     891                                                if (overlayFrame != null
     892                                                                && Overlay.getOverlay(overlays, overlayFrame) == null)
     893                                                        overlays.add(new Overlay(overlayFrame,
     894                                                                        Permission.none));
    913895                                        }
    914896                                        // check for ACTIVE_OVERLAY items
     
    924906                                                        continue;
    925907                                                }
    926                                                 Frame overlay = FrameIO.LoadFrame(link);
    927                                                 // Parse(overlay);
     908                                                Frame overlayFrame = FrameIO.LoadFrame(link);
    928909                                                // get level if specified
    929910                                                String level = AttributeUtils.getValue(((Text) i)
     
    933914                                                                level, Permission.followLinks);
    934915
    935                                                 if (overlay != null) {
    936                                                         // Add it if its a new overlay
    937                                                         boolean found = false;
    938                                                         // Check if this overlay is already in the list and
    939                                                         // adjust its permissions
    940                                                         for (Overlay o : overlays) {
    941                                                                 if (o.Frame.equals(overlay)) {
    942                                                                         o.Frame.setPermission(permissionLevel);
    943                                                                         found = true;
    944                                                                         break;
    945                                                                 }
    946                                                         }
     916                                                if (overlayFrame != null) {
     917                                                        Overlay existingOverlay = Overlay.getOverlay(
     918                                                                        overlays, overlayFrame);
    947919                                                        // If it wasnt in the list create it and add it.
    948                                                         if (!found) {
    949                                                                 Overlay newOverlay = new Overlay(overlay,
     920                                                        if (existingOverlay == null) {
     921                                                                Overlay newOverlay = new Overlay(overlayFrame,
    950922                                                                                permissionLevel);
    951923                                                                i.setOverlay(newOverlay);
    952924                                                                overlays.add(newOverlay);
     925                                                        } else {
     926                                                                existingOverlay.Frame
     927                                                                                .setPermission(permissionLevel);
    953928                                                        }
    954929                                                }
     
    10431018
    10441019        /**
     1020         * @param vectors
     1021         * @param permission
     1022         * @param i
     1023         */
     1024        private static void addVector(List<Vector> vectors,
     1025                        Permission defaultPermission, Permission framePermission, Item i) {
     1026                // TODO It is possible to get into an infinate loop if a
     1027                // frame contains an @ao which leads to a frame with an
     1028                // @v which points back to the frame with the @ao
     1029                Frame vector = FrameIO.LoadFrame(i.getAbsoluteLink());
     1030                // Get the permission from off the vector frame
     1031                Permission vectorPermission = Permission.getPermission(vector
     1032                                .getAnnotationValue("permission"), defaultPermission);
     1033                // If the frame permission is lower, use that
     1034                vectorPermission = Permission.min(vectorPermission, framePermission);
     1035                // Highest permissable permission for vectors is copy
     1036                vectorPermission = Permission.min(vectorPermission, Permission.copy);
     1037                if (vector != null) {
     1038                        String scaleString = AttributeUtils.getValue(((Text) i).getText());
     1039                        Float scale = 1F;
     1040                        try {
     1041                                scale = Float.parseFloat(scaleString);
     1042                        } catch (Exception e) {
     1043                        }
     1044                        Vector newVector = new Vector(vector, vectorPermission, i
     1045                                        .getPosition(), scale, i.getColor(), i.getBackgroundColor());
     1046                        i.setOverlay(newVector);
     1047                        vectors.add(newVector);
     1048                }
     1049        }
     1050
     1051        /**
    10451052         * Searches through the list of items on this frame to find one at the given
    10461053         * x,y coordinates.
     
    11581165        }
    11591166
    1160         public static Polygon getEnlosingPolygon(){
     1167        public static Polygon getEnlosingPolygon() {
    11611168                Collection<Item> enclosure = getEnclosingLineEnds();
    11621169                if (enclosure == null || enclosure.size() == 0)
     
    11651172                return enclosure.iterator().next().getEnclosedShape();
    11661173        }
    1167        
     1174
    11681175        /**
    11691176         *
     
    14441451
    14451452        public static void setLastEdited(Text lastEdited) {
    1446                 if (LastEdited != null && lastEdited != LastEdited
    1447                                 && LastEdited.getText().length() == 0) {
    1448                         LastEdited.getParentOrCurrentFrame().removeItem(LastEdited);
     1453                // If the lastEdited is being changed then check if its @i
     1454                Frame toReparse = null;
     1455                if (LastEdited != null) {
     1456                        if (lastEdited == null || lastEdited != LastEdited) {
     1457                                if (LastEdited.startsWith("@i")) {
     1458                                        toReparse = LastEdited.getParent();
     1459                                }
     1460                        }
     1461                        if (lastEdited != LastEdited && LastEdited.getText().length() == 0) {
     1462                                LastEdited.getParentOrCurrentFrame().removeItem(LastEdited);
     1463                        }
    14491464                }
    14501465                LastEdited = lastEdited;
     1466               
     1467                if (toReparse != null) {
     1468                        Parse(toReparse, false);
     1469                }
    14511470        }
    14521471
     
    14601479                if (currentItems != null) {
    14611480                        for (Item i : getCurrentItems(null)) {
    1462                                 if (i instanceof Text) {
     1481                                if (i instanceof Text && !i.isLineEnd()) {
    14631482                                        currentTextItems.add((Text) i);
    14641483                                }
  • trunk/src/org/expeditee/gui/Overlay.java

    r115 r154  
    11package org.expeditee.gui;
     2
     3import java.util.Collection;
    24
    35import org.expeditee.items.Permission;
     
    2527                return 0;
    2628        }
     29       
     30        public static Overlay getOverlay(Collection<Overlay>overlays, Frame frame){
     31                // Check the frame is in the list of overlays
     32                for (Overlay o : overlays) {
     33                        if (o.Frame.equals(frame)) {
     34                                return o;
     35                        }
     36                }
     37                return null;
     38        }
    2739}
  • trunk/src/org/expeditee/items/Item.java

    r147 r154  
    19311931
    19321932        public boolean hasAction() {
    1933                 return _actions != null && _actions.size() > 0;
     1933                List<String> actions = getAction();
     1934                return actions != null && actions.size() > 0;
    19341935        }
    19351936
  • trunk/src/org/expeditee/items/ItemUtils.java

    r121 r154  
    7171
    7272        public static final int TAG_VECTOR = 19;
     73       
     74        public static final int TAG_ACTIVE_VECTOR = 21;
    7375
    7476        public static final int TAG_BITMAP_IMAGE = 20;
     
    7678        public static final int TAG_MIN = 0;
    7779
    78         public static final int TAG_MAX = 20;
     80        public static final int TAG_MAX = 21;
    7981
    8082        /**
     
    283285                case TAG_VECTOR:
    284286                        return "@v";
     287                case TAG_ACTIVE_VECTOR:
     288                        return "@av";
    285289                case TAG_ACTIVE_OVERLAY:
    286290                        return "@ao";
  • trunk/src/org/expeditee/items/Text.java

    r147 r154  
    488488                // Trim the text to remove new lines on the beginning and end of the
    489489                // string
    490                 if(_text.charAt(left) == '\n'){
    491                         //if the entire line is being removed then remove one of the new lines
    492                         if(_text.charAt(right) == '\n'){
     490                if (_text.charAt(left) == '\n') {
     491                        // if the entire line is being removed then remove one of the new
     492                        // lines, the first case checks if the last line is being removed
     493                        if (right >= _text.length() || _text.charAt(right) == '\n') {
    493494                                _text.deleteCharAt(left);
    494495                                right--;
    495                         }else{
     496                        } else {
    496497                                left++;
    497498                        }
    498499                }
    499                 //New lines are always at the start of the line for now...
    500 //              if(_text.charAt(right - 1) == '\n' && left < right){
    501 //                      right--;
    502 //              }
     500                // New lines are always at the start of the line for now...
     501                // if(_text.charAt(right - 1) == '\n' && left < right){
     502                // right--;
     503                // }
    503504                String s = _text.substring(left, right);
    504505
     
    570571                        int pos = hit.getInsertionIndex() + _lineOffsets.get(line);
    571572
    572                         if (line > 0 && hit.getInsertionIndex() == 0)
    573                                 pos++;
     573                        if (line > 0 && hit.getInsertionIndex() == 0) {
     574                                // Only move forward a char if the line begins with a hard line
     575                                // break... not a soft line break
     576                                if (_text.charAt(pos) == '\n') {
     577                                        pos++;
     578                                }
     579                        }
    574580
    575581                        if (insertPos < 0)
     
    17951801                String text = getText().toLowerCase();
    17961802                // TODO make it so can just check the _overlay variable
     1803                //Mike cant remember the reason _overlay var cant be use! opps
     1804                if(!text.startsWith("@"))
     1805                        return false;
    17971806                return text.startsWith("@o") || text.startsWith("@ao")
    1798                                 || text.startsWith("@v");
     1807                                || text.startsWith("@v") || text.startsWith("@av");
    17991808        }
    18001809
  • trunk/src/org/expeditee/items/XRayable.java

    r147 r154  
    150150                if (_source == null) {
    151151                        return;
    152                 } else {
    153                         _source.setLink(frameName);
    154152                }
    155 
     153                if(frameName == null)
     154                        invalidateAll();
     155                _source.setLink(frameName);
    156156                updatePolygon();
     157                //TODO: only invalidate the link bit
     158                invalidateAll();
    157159        }
    158160
    159161        @Override
    160162        public void setActions(List<String> action) {
    161                 if (_source == null)
     163                if (_source == null){
    162164                        return;
    163                 else
    164                         _source.setActions(action);
    165 
     165                }
     166                if(action.size() == 0)
     167                        invalidateAll();
     168                _source.setActions(action);
    166169                updatePolygon();
     170                invalidateAll();
    167171        }
    168172
Note: See TracChangeset for help on using the changeset viewer.