Changeset 121


Ignore:
Timestamp:
07/03/08 16:48:09 (16 years ago)
Author:
bjn8
Message:

Added invalidation for graphics... biiiig commit. LOts of effeciency improvements - now can animate

Location:
trunk/src/org/expeditee
Files:
1 deleted
38 edited

Legend:

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

    r115 r121  
    1919import org.expeditee.gui.DisplayIO;
    2020import org.expeditee.gui.Frame;
    21 import org.expeditee.gui.FrameGraphics;
    2221import org.expeditee.gui.FrameIO;
    2322import org.expeditee.gui.FrameUtils;
     23import org.expeditee.gui.MessageBay;
    2424import org.expeditee.io.Conversion;
    2525import org.expeditee.io.Logger;
     
    315315                // check for protection on frame
    316316                if (ItemUtils.ContainsTag(source.getItems(), "@No" + mname)) {
    317                         FrameGraphics.DisplayMessage("Frame is protected by @No" + mname
     317                        MessageBay.displayMessage("Frame is protected by @No" + mname
    318318                                        + " tag.");
    319319                        return;
     
    365365                }
    366366                if (possibles.size() > 0) {
    367                         FrameGraphics.ErrorMessage("Incorrect parameters for " + mname);
     367                        MessageBay.errorMessage("Incorrect parameters for " + mname);
    368368                } else {
    369369                        assert (false);
    370                         FrameGraphics.ErrorMessage(mname + " action not found");
     370                        MessageBay.errorMessage(mname + " action not found");
    371371                }
    372372        }
     
    431431                        // if there is no constructor, return
    432432                        if (con == null) {
    433                                 FrameGraphics.DisplayMessage(INVALID_PARAMETERS_ERROR
     433                                MessageBay.displayMessage(INVALID_PARAMETERS_ERROR
    434434                                                + nameWithCorrectCase);
    435435                                // System.out.println("Constructor not found...");
     
    445445                        // check for errors during initialisation
    446446                        if (!_Agent.initialise(source)) {
    447                                 FrameGraphics.ErrorMessage("Error initialising agent: "
     447                                MessageBay.errorMessage("Error initialising agent: "
    448448                                                + nameWithCorrectCase);
    449449                                return;
     
    461461
    462462                } catch (ClassNotFoundException cnf) {
    463                         FrameGraphics.ErrorMessage(nameWithCorrectCase
     463                        MessageBay.errorMessage(nameWithCorrectCase
    464464                                        + "' is not an action or agent.");
    465465                } catch (Exception e) {
    466                         FrameGraphics.ErrorMessage("Error creating Agent: '"
     466                        MessageBay.errorMessage("Error creating Agent: '"
    467467                                        + nameWithCorrectCase + "'");
    468468                        System.out.println("Agent set to Null.");
     
    494494        public static void stopAgent() {
    495495                if (_Agent != null && _Agent.isRunning()) {
    496                         FrameGraphics.ErrorMessage("Stopping Agent...");
     496                        MessageBay.errorMessage("Stopping Agent...");
    497497                        _Agent.stop();
    498498                }
  • trunk/src/org/expeditee/actions/IDE.java

    r80 r121  
    88import org.expeditee.gui.DisplayIO;
    99import org.expeditee.gui.Frame;
    10 import org.expeditee.gui.FrameGraphics;
     10import org.expeditee.gui.MessageBay;
    1111
    1212public class IDE {
     
    2323                        try {
    2424                                Runtime.getRuntime().exec("javac -d expeditee/bin " + fileName);
    25                                 FrameGraphics.DisplayMessage("Compiled " + fileName, Color.darkGray);
     25                                MessageBay.displayMessage("Compiled " + fileName, Color.darkGray);
    2626                        } catch (Exception e) {
    27                                 FrameGraphics.ErrorMessage("Could not compile class!");
     27                                MessageBay.errorMessage("Could not compile class!");
    2828                        }
    2929                } else {
    30                         FrameGraphics.ErrorMessage("Could not initialise agent!");
     30                        MessageBay.errorMessage("Could not initialise agent!");
    3131                }
    3232        }
     
    5050                        String message = "";
    5151                        while ((message = stdInput.readLine()) != null) {
    52                                 FrameGraphics.DisplayMessage(message);
     52                                MessageBay.displayMessage(message);
    5353                        }
    5454                        while ((message = stdError.readLine()) != null) {
    55                                 FrameGraphics.ErrorMessage(message);
     55                                MessageBay.errorMessage(message);
    5656                        }
    5757                } catch (Exception e) {
    58                         FrameGraphics.ErrorMessage("Could not run class!");
     58                        MessageBay.errorMessage("Could not run class!");
    5959                }
    6060        }
  • trunk/src/org/expeditee/actions/Misc.java

    r115 r121  
    2020import org.expeditee.gui.FrameIO;
    2121import org.expeditee.gui.FrameMouseActions;
     22import org.expeditee.gui.MessageBay;
    2223import org.expeditee.gui.TimeKeeper;
    2324import org.expeditee.items.Item;
     
    5556        public static void Restore() {
    5657                FrameIO.Reload();
    57                 // FrameGraphics.DisplayMessage("Restoration complete.");
     58                // MessageBay.displayMessage("Restoration complete.");
    5859        }
    5960
     
    144145                                DisplayIO.Back();
    145146                                FrameGraphics.Repaint();
    146                                 FrameGraphics.DisplayMessage(deletedFrame + " deleted");
     147                                MessageBay.displayMessage(deletedFrame + " deleted");
    147148                                return;
    148149                        }
     
    156157                        e.printStackTrace();
    157158                }
    158                 FrameGraphics.ErrorMessage(errorMessage);
     159                MessageBay.errorMessage(errorMessage);
    159160        }
    160161
     
    249250        public static void GetCometStats(Frame frame) {
    250251                TimeKeeper timer = new TimeKeeper();
    251                 FrameGraphics.DisplayMessage("Computing comet stats...");
     252                MessageBay.displayMessage("Computing comet stats...");
    252253
    253254                CometStats cometStats = new CometStats(frame);
    254255                attachStatsToCursor(cometStats.toString());
    255                 FrameGraphics.OverwriteMessage("Comet stats time: "
     256                MessageBay.overwriteMessage("Comet stats time: "
    256257                                + timer.getElapsedStringSeconds());
    257258        }
     
    259260        public static void GetTreeStats(Frame frame) {
    260261                TimeKeeper timer = new TimeKeeper();
    261                 FrameGraphics.DisplayMessage("Computing tree stats...");
     262                MessageBay.displayMessage("Computing tree stats...");
    262263
    263264                TreeStats treeStats = new TreeStats(frame);
    264265                attachStatsToCursor(treeStats.toString());
    265                 FrameGraphics.OverwriteMessage("Tree stats time: "
     266                MessageBay.overwriteMessage("Tree stats time: "
    266267                                + timer.getElapsedStringSeconds());
    267268        }
     
    473474                        String frameName = ImageFrame(loaded, format, path);
    474475                        if (frameName != null)
    475                                 FrameGraphics.DisplayMessage("Frame successfully saved to "
     476                                MessageBay.displayMessage("Frame successfully saved to "
    476477                                                + path + frameName);
    477478                        else
    478                                 FrameGraphics.ErrorMessage("Could not find image writer for "
     479                                MessageBay.errorMessage("Could not find image writer for "
    479480                                                + format + " format");
    480481                        // if the frame was not loaded successfully, alert the user
    481482                } else
    482                         FrameGraphics.DisplayMessage("Frame '" + framename
     483                        MessageBay.displayMessage("Frame '" + framename
    483484                                        + "' could not be found.");
    484485        }
     
    491492         */
    492493        public static void MessageLn(String message) {
    493                 FrameGraphics.DisplayMessage(message);
     494                MessageBay.displayMessage(message);
    494495        }
    495496
    496497        public static void MessageLn2(String message, String message2) {
    497                 FrameGraphics.DisplayMessage(message + " " + message2);
     498                MessageBay.displayMessage(message + " " + message2);
    498499        }
    499500
     
    502503                        // TODO is there a built in method which will do this faster?
    503504
    504                         FrameGraphics.DisplayMessage("Copying file " + existingFile
     505                        MessageBay.displayMessage("Copying file " + existingFile
    505506                                        + " to " + newFileName + "...");
    506507                        FrameIO.copyFile(existingFile, newFileName);
    507                         FrameGraphics.DisplayMessage("File copied successfully");
     508                        MessageBay.displayMessage("File copied successfully");
    508509                } catch (FileNotFoundException e) {
    509                         FrameGraphics.DisplayMessage("Error opening file: " + existingFile);
     510                        MessageBay.displayMessage("Error opening file: " + existingFile);
    510511                } catch (Exception e) {
    511                         FrameGraphics.DisplayMessage("File could not be copied");
     512                        MessageBay.displayMessage("File could not be copied");
    512513                }
    513514        }
     
    561562                        float aveTimeB = timeB * 1000F / repsPerTest / tests;
    562563                        // Display Results
    563                         FrameGraphics.DisplayMessage("Average Execution Time");
    564                         FrameGraphics.DisplayMessage(methodNameA + ": "
     564                        MessageBay.displayMessage("Average Execution Time");
     565                        MessageBay.displayMessage(methodNameA + ": "
    565566                                        + TimeKeeper.Formatter.format(aveTimeA) + "us");
    566                         FrameGraphics.DisplayMessage(methodNameB + ": "
     567                        MessageBay.displayMessage(methodNameB + ": "
    567568                                        + TimeKeeper.Formatter.format(aveTimeB) + "us");
    568569                } catch (Exception e) {
    569                         FrameGraphics.ErrorMessage(e.getClass().getSimpleName() + ": "
     570                        MessageBay.errorMessage(e.getClass().getSimpleName() + ": "
    570571                                        + e.getMessage());
    571572                }
     
    634635                // the item must link to a frame
    635636                if (current.getLink() == null) {
    636                         FrameGraphics
    637                                         .DisplayMessage("Cannot get item from child - this item has no link");
     637                        MessageBay
     638                                        .displayMessage("Cannot get item from child - this item has no link");
    638639                        return null;
    639640                }
     
    643644                // if the frame could not be loaded
    644645                if (child == null) {
    645                         FrameGraphics.ErrorMessage("Could not load child frame.");
     646                        MessageBay.errorMessage("Could not load child frame.");
    646647                        return null;
    647648                }
     
    663664                // if no item was found
    664665                if (item == null) {
    665                         FrameGraphics.DisplayMessage("No item found to copy");
     666                        MessageBay.displayMessage("No item found to copy");
    666667                        return null;
    667668                }
  • trunk/src/org/expeditee/actions/NavigationActions.java

    r108 r121  
    55import org.expeditee.gui.DisplayIO;
    66import org.expeditee.gui.Frame;
    7 import org.expeditee.gui.FrameGraphics;
    87import org.expeditee.gui.FrameIO;
    98import org.expeditee.gui.FrameUtils;
     9import org.expeditee.gui.MessageBay;
    1010import org.expeditee.items.Item;
    1111
     
    143143                // if there is no parent frame (i.e. the user is on the home frame) //
    144144                if (back == null) { // No frame was on the Backup stack
    145                         FrameGraphics.DisplayMessage("No Parent Frame Found.");
     145                        MessageBay.displayMessage("No Parent Frame Found.");
    146146                        _LastItemUsed = null; // ByRob: what is reason for setting
    147147                        // this to null, who is going to use it????
     
    200200                } // ByRob: End of For
    201201
    202                 FrameGraphics.DisplayMessage("No more child frames found.");
     202                MessageBay.displayMessage("No more child frames found.");
    203203        }
    204204
  • trunk/src/org/expeditee/actions/Simple.java

    r117 r121  
    2727import org.expeditee.gui.FrameMouseActions;
    2828import org.expeditee.gui.FrameUtils;
     29import org.expeditee.gui.FreeItems;
     30import org.expeditee.gui.MessageBay;
    2931import org.expeditee.io.Conversion;
    3032import org.expeditee.items.Dot;
     
    144146                newSimpleTest.getTitleItem().setActions(actions);
    145147                FrameUtils.DisplayFrame(newSimpleTest, true);
    146                 FrameGraphics.DisplayMessage("New test created");
     148                MessageBay.displayMessage("New test created");
    147149        }
    148150
     
    206208
    207209                FrameIO.SaveFrame(DisplayIO.getCurrentFrame(), false);
    208                 FrameGraphics.DisplayMessage("Starting test suite: " + _frameset,
     210                MessageBay.displayMessage("Starting test suite: " + _frameset,
    209211                                Color.CYAN);
    210212
     
    257259                                if (passed) {
    258260                                        if (_verbose)
    259                                                 FrameGraphics.DisplayMessage("Test passed: "
     261                                                MessageBay.displayMessage("Test passed: "
    260262                                                                + title.toString(), Item.GREEN);
    261263                                        testsPassed++;
     
    263265                                        testsFailed++;
    264266                                        // Print out the reason for failed tests
    265                                         FrameGraphics.LinkedErrorMessage(errorMessage);
     267                                        MessageBay.linkedErrorMessage(errorMessage);
    266268                                        if (Simple._stop) {
    267269                                                Simple._stop = false;
     
    275277                assert (_programsRunning == 0);
    276278                // Report the number of test passed and failed
    277                 FrameGraphics.DisplayMessage("Total tests: "
     279                MessageBay.displayMessage("Total tests: "
    278280                                + (testsPassed + testsFailed), Color.CYAN);
    279281                if (testsPassed > 0)
    280                         FrameGraphics.DisplayMessage("Passed: " + testsPassed, Item.GREEN);
     282                        MessageBay.displayMessage("Passed: " + testsPassed, Item.GREEN);
    281283                if (testsFailed > 0)
    282                         FrameGraphics.DisplayMessage("Failed: " + testsFailed, Color.RED);
     284                        MessageBay.displayMessage("Failed: " + testsFailed, Color.RED);
    283285                // Remove items from the cursor...
    284                 Frame.FreeItems.clear();
     286                FreeItems.getInstance().clear();
    285287
    286288                return testsFailed == 0;
     
    14371439                                        .getValue();
    14381440                        try {
    1439                                 FrameGraphics.DisplayMessage(((Text) message).copy());
     1441                                MessageBay.displayMessage(((Text) message).copy());
    14401442                        } catch (NullPointerException e) {
    1441                                 FrameGraphics.DisplayMessage("null");
     1443                                MessageBay.displayMessage("null");
    14421444                        } catch (ClassCastException e) {
    14431445                                // Just ignore not text items!
    1444                                 FrameGraphics.DisplayMessage(message.toString());
     1446                                MessageBay.displayMessage(message.toString());
    14451447                        } catch (Exception e) {
    14461448                                // Just ignore other errors
     
    14551457
    14561458                        if (tokens[0].equals("errorln") || tokens[0].equals("errorline"))
    1457                                 FrameGraphics.ErrorMessage(message);
     1459                                MessageBay.errorMessage(message);
    14581460                        else
    1459                                 FrameGraphics.DisplayMessageAlways(message);
     1461                                MessageBay.displayMessageAlways(message);
    14601462                } else if (tokens[0].equals("typeatrate")) {
    14611463                        assertMinParametreCount(tokens, 1);
     
    14881490                        try {
    14891491                                Process p = Runtime.getRuntime().exec(command);
    1490                                 FrameGraphics.DisplayMessage(command, Color.darkGray);
     1492                                MessageBay.displayMessage(command, Color.darkGray);
    14911493
    14921494                                BufferedReader stdInput = new BufferedReader(
     
    14961498                                String message = "";
    14971499                                while ((message = stdInput.readLine()) != null) {
    1498                                         FrameGraphics.DisplayMessage(message);
     1500                                        MessageBay.displayMessage(message);
    14991501                                }
    15001502                                while ((message = stdError.readLine()) != null) {
    1501                                         FrameGraphics.ErrorMessage(message);
     1503                                        MessageBay.errorMessage(message);
    15021504                                }
    15031505                        } catch (Exception e) {
     
    17581760                                success = FrameIO.DeleteFrame(frame);
    17591761                                if (!success && _verbose)
    1760                                         FrameGraphics.WarningMessage(errorMessage);
     1762                                        MessageBay.warningMessage(errorMessage);
    17611763                        } catch (Exception e) {
    17621764                                // If an exception is thrown then success is false
    17631765                                if (_verbose) {
    1764                                         FrameGraphics.WarningMessage(errorMessage
     1766                                        MessageBay.warningMessage(errorMessage
    17651767                                                        + (e.getMessage() != null ? ". " + e.getMessage()
    17661768                                                                        : ""));
     
    17771779                        boolean success = FrameIO.DeleteFrameset(framesetName);
    17781780                        if (!success && _verbose) {
    1779                                 FrameGraphics.WarningMessage("Error deleting " + framesetName);
     1781                                MessageBay.warningMessage("Error deleting " + framesetName);
    17801782                        }
    17811783                        if (tokens.length > 2) {
     
    18001802                                        copiedFrameset);
    18011803                        if (!success && _verbose)
    1802                                 FrameGraphics.WarningMessage("Error copying " + framesetToCopy);
     1804                                MessageBay.warningMessage("Error copying " + framesetToCopy);
    18031805                        if (tokens.length > 3) {
    18041806                                context.getPrimitives().setValue(tokens[3],
     
    18291831                        boolean success = fileContents != null;
    18301832                        if (!success && _verbose)
    1831                                 FrameGraphics.WarningMessage("Error copying "
     1833                                MessageBay.warningMessage("Error copying "
    18321834                                                + frameToCopy.getName());
    18331835                        if (tokens.length > 4) {
     
    20262028                                        if (freeMemory < DisplayTree.GARBAGE_COLLECTION_THRESHOLD) {
    20272029                                                runtime.gc();
    2028                                                 FrameGraphics
    2029                                                                 .DisplayMessage("Force Garbage Collection!");
     2030                                                MessageBay
     2031                                                                .displayMessage("Force Garbage Collection!");
    20302032                                        }
    20312033                                }
     
    21282130                                success = false;
    21292131                                if (_verbose)
    2130                                         FrameGraphics.WarningMessage("Error parsing " + frameName);
     2132                                        MessageBay.warningMessage("Error parsing " + frameName);
    21312133                        }
    21322134                        // assertPrimitiveType(tokens[2], 2);
     
    22992301                        // DisplayIO.setCursorPosition(finalX, finalY);
    23002302                        FrameMouseActions.anchor(item);
    2301                         Frame.FreeItems.clear();
     2303                        FreeItems.getInstance().clear();
    23022304                        FrameGraphics.Repaint();
    23032305                        // FrameMouseActions.updateCursor();
     
    25912593                _programsRunning++;
    25922594                AgentStats.reset();
    2593                 FrameGraphics.DisplayMessage("Running SimpleProgram...", Color.BLUE);
     2595                MessageBay.displayMessage("Running SimpleProgram...", Color.BLUE);
    25942596        }
    25952597
  • trunk/src/org/expeditee/agents/CopyTree.java

    r80 r121  
    55
    66import org.expeditee.gui.Frame;
    7 import org.expeditee.gui.FrameGraphics;
    87import org.expeditee.gui.FrameIO;
    98import org.expeditee.gui.FrameUtils;
     9import org.expeditee.gui.MessageBay;
    1010import org.expeditee.items.Item;
    1111
     
    4949                        processFrame(zero);
    5050                } catch (ExistingFramesetException efe) {
    51                         FrameGraphics.ErrorMessage("A frameset called " + _nameTo
     51                        MessageBay.errorMessage("A frameset called " + _nameTo
    5252                                        + " already exists.");
    5353                        return false;
  • trunk/src/org/expeditee/agents/DefaultAgent.java

    r108 r121  
    22
    33import org.expeditee.gui.Frame;
    4 import org.expeditee.gui.FrameGraphics;
     4import org.expeditee.gui.MessageBay;
    55import org.expeditee.gui.TimeKeeper;
    66import org.expeditee.stats.SessionStats;
     
    9393                // init is now called by Actions.java
    9494                /*
    95                  * if(!initialise(_start)){ FrameGraphics.ErrorMessage("Error
     95                 * if(!initialise(_start)){ MessageBay.errorMessage("Error
    9696                 * initialising agent."); _running = false; return; }
    9797                 */
     
    135135         */
    136136        protected void message(String message) {
    137                 FrameGraphics.DisplayMessageAlways(message);
     137                MessageBay.displayMessageAlways(message);
    138138        }
    139139
    140140        protected void overwriteMessage(String message) {
    141                 FrameGraphics.OverwriteMessage(message);
     141                MessageBay.overwriteMessage(message);
    142142        }
    143143
  • trunk/src/org/expeditee/agents/DisplayComet.java

    r103 r121  
    77import org.expeditee.gui.DisplayIO;
    88import org.expeditee.gui.Frame;
    9 import org.expeditee.gui.FrameGraphics;
    109import org.expeditee.gui.FrameIO;
     10import org.expeditee.gui.MessageBay;
    1111import org.expeditee.items.Item;
    1212import org.expeditee.items.ItemUtils;
     
    4545                                if (link != null && !seen.contains(linkLowerCase)) {
    4646                                        oldFrame = FrameIO.LoadFrame(linkLowerCase);
    47                                         FrameGraphics.OverwriteMessage("Loading frames: " + link);
     47                                        MessageBay.overwriteMessage("Loading frames: " + link);
    4848                                }
    4949                        }
  • trunk/src/org/expeditee/agents/DisplayTree.java

    r108 r121  
    33import org.expeditee.gui.DisplayIO;
    44import org.expeditee.gui.Frame;
    5 import org.expeditee.gui.FrameGraphics;
     5import org.expeditee.gui.MessageBay;
    66import org.expeditee.items.Item;
    77import org.expeditee.items.ItemUtils;
     
    5555                if (freeMemory < GARBAGE_COLLECTION_THRESHOLD) {
    5656                        _runtime.gc();
    57                         FrameGraphics.DisplayMessage("Force Garbage Collection!");
     57                        MessageBay.displayMessage("Force Garbage Collection!");
    5858                }
    5959
  • trunk/src/org/expeditee/agents/SwitchyardTree.java

    r108 r121  
    1212        @Override
    1313        protected Frame process(Frame frame) {
    14                 //FrameGraphics.DisplayMessage("Running switchyard tree...");
     14                //MessageBay.displayMessage("Running switchyard tree...");
    1515
    1616                for (Text textItem : frame.getBodyTextItems(false)) {
  • trunk/src/org/expeditee/agents/WriteTree.java

    r80 r121  
    66import org.expeditee.actions.Actions;
    77import org.expeditee.gui.Frame;
    8 import org.expeditee.gui.FrameGraphics;
     8import org.expeditee.gui.MessageBay;
    99import org.expeditee.io.FrameWriter;
    1010import org.expeditee.io.Logger;
     
    8888                                // check that o is a valid treewriter
    8989                                if (!(o instanceof TreeWriter)) {
    90                                         FrameGraphics.WarningMessage(_format.toUpperCase()
     90                                        MessageBay.warningMessage(_format.toUpperCase()
    9191                                                        + " format cannot be used to write trees.");
    9292                                        return false;
     
    101101                        } else {
    102102                                if (!(o instanceof FrameWriter) && !(o instanceof TreeWriter)) {
    103                                         FrameGraphics.WarningMessage(_format.toUpperCase()
     103                                        MessageBay.warningMessage(_format.toUpperCase()
    104104                                                        + " format cannot be used to write frames.");
    105105                                        return false;
     
    115115
    116116                } catch (ClassNotFoundException e) {
    117                         FrameGraphics
    118                                         .WarningMessage("The agent does not exist or has incorrect parametres.");
     117                        MessageBay
     118                                        .warningMessage("The agent does not exist or has incorrect parametres.");
    119119                        return false;
    120120                } catch (Exception e) {
     
    141141                        //System.out.println("Caught");
    142142                        Logger.Log(e);
    143                         FrameGraphics.ErrorMessage("IOException in WriteTree: "
     143                        MessageBay.errorMessage("IOException in WriteTree: "
    144144                                        + e.getMessage());
    145145                        e.printStackTrace();
  • trunk/src/org/expeditee/gui/AttributeUtils.java

    r115 r121  
    476476                                                // Display an error message if its not in our list of
    477477                                                // attributes to ignore when copying
    478                                                 FrameGraphics.WarningMessage("Attribute: '"
     478                                                MessageBay.warningMessage("Attribute: '"
    479479                                                                + getAttribute(v.toString())
    480480                                                                + "' does not exist.");
     
    484484                                                                .getParameterTypes())
    485485                                                        types += c.getSimpleName() + " ";
    486                                                 FrameGraphics.WarningMessage("Wrong arguments for: '"
     486                                                MessageBay.warningMessage("Wrong arguments for: '"
    487487                                                                + getAttribute(v.toString()) + "' expecting "
    488488                                                                + types.trim() + " found '"
     
    576576                                        e.printStackTrace();
    577577                                } catch (InvocationTargetException e) {
    578                                         FrameGraphics.DisplayMessage(toSet.getClass()
     578                                        MessageBay.displayMessage(toSet.getClass()
    579579                                                        .getSimpleName()
    580580                                                        + " type does not support that attribute.");
  • trunk/src/org/expeditee/gui/Browser.java

    r115 r121  
    1515
    1616import javax.swing.JFrame;
     17import javax.swing.RepaintManager;
    1718
    1819import org.expeditee.AbsoluteLayout;
     
    4849         */
    4950        public static void main(String[] args) {
    50                 //FrameGraphics.SupressMessages(true);
     51                //MessageBay.supressMessages(true);
    5152                _theBrowser = new Browser();
    52                 //FrameGraphics.SupressMessages(false);
     53                //MessageBay.supressMessages(false);
    5354                // Why do we want to ignore repaint?
    5455                // _theBrowser.setIgnoreRepaint(true);
     
    114115                addComponentListener(this);
    115116                pack();
     117               
     118                // Expeditee handles its own repainting of AWT/Swing components
     119                RepaintManager.setCurrentManager(ExpediteeRepaintManager.getInstance());
     120               
     121               
    116122                try {
    117123                        Collection<String> warningMessages = Actions.Init();
     
    129135                        //Must be loaded after setupGraphics if images are on the frame
    130136                        //Turn off XRay mode and load the first frame
     137                        FrameUtils.loadFirstFrame(profile);
    131138                        FrameGraphics.setMode(FrameGraphics.MODE_NORMAL, false);
    132                         FrameUtils.loadFirstFrame(profile);
    133139                        DisplayIO.UpdateTitle();
    134140                       
     
    136142                        //It used to crash the program trying to print error messages up the top
    137143                        for (String message : warningMessages)
    138                                 FrameGraphics.WarningMessage(message);
     144                                MessageBay.warningMessage(message);
    139145
    140146                        FrameKeyboardActions keyboardListner = new FrameKeyboardActions();
     
    142148                        this.addKeyListener(keyboardListner);
    143149                       
    144                         //FrameKeyboardActions.Refresh();
     150                        FrameKeyboardActions.Refresh();
    145151                        //setVisible(true);
    146152                } catch (Exception e) {
     
    150156        }
    151157
    152         Graphics2D g;
     158        public Graphics2D g;
    153159
    154160        private void setupGraphics() {
     
    170176                // then moved back into view
    171177                super.paint(g);
    172                 FrameGraphics.Repaint();
     178                FrameGraphics.ForceRepaint();
    173179                // System.out.println("Paint " + count++);
    174180        }
     
    181187                setupGraphics();
    182188                FrameIO.RefreshCasheImages();
    183                 FrameGraphics.Repaint();
     189                FrameGraphics.ForceRepaint();
    184190        }
    185191
  • trunk/src/org/expeditee/gui/DisplayIO.java

    r116 r121  
    1010import java.awt.geom.Point2D;
    1111import java.awt.image.MemoryImageSource;
     12import java.util.ArrayList;
    1213import java.util.Collection;
    1314import java.util.LinkedList;
     
    205206
    206207                if (Frame.itemAttachedToCursor()) {
    207                         List<Item> toMove = Frame.FreeItems;
     208                        List<Item> toMove = FreeItems.getInstance();
    208209                        for (Item move : toMove) {
    209210                                move.setPosition(move.getX() + deltax, move.getY() + deltay);
     
    333334                if (frame == null)
    334335                        return;
    335 
     336               
    336337                if (_TwinFrames) {
    337338                        if (_CurrentFrames[0] == null) {
     
    348349                if (frame == getCurrentFrame()) {
    349350                        FrameGraphics.Repaint();
    350                         FrameGraphics.DisplayMessage(frame.getName()
     351                        MessageBay.displayMessage(frame.getName()
    351352                                        + " is already the current frame.");
    352353                        return;
     
    355356                }
    356357
     358               
     359                // Invalidate free items
     360                if (!FreeItems.getInstance().isEmpty() && getCurrentFrame() != null) {
     361       
     362                        // Empty free items temporarily so that the old frames buffer is repainted
     363                        // without the free items.
     364                        ArrayList<? extends Item> tmp = (ArrayList<? extends Item>)FreeItems.getInstance().clone();
     365                        FreeItems.getInstance().clear(); // NOTE: This will invalidate all the cleared free items
     366                        FrameGraphics.refresh(true);
     367                        FreeItems.getInstance().addAll(tmp);
     368                       
     369                       
     370                }
     371               
     372               
    357373                if (_TwinFrames) {
    358374                        // if the same frame is being shown in both sides, load a fresh
     
    379395                        _CurrentFrames[getCurrentSide()] = frame;
    380396
    381                         // BROOK : TODO...
     397                        // BROOK : TODO... overlays and loadable widgets
    382398                        for (Item i : _CurrentFrames[getCurrentSide()].getItems()) {
    383399                                i.onParentStateChanged(new ItemParentStateChangedEvent(
     
    469485                }
    470486
    471                 FrameGraphics.Repaint();
     487                FrameGraphics.refresh(false);
    472488        }
    473489
     
    573589                // there must be a frame to go back to
    574590                if (_VisitedFrames[side].size() < 1) {
    575                         FrameGraphics
    576                                         .DisplayMessageOnce("You are already on the home frame");
     591                        MessageBay
     592                                        .displayMessageOnce("You are already on the home frame");
    577593                        return;
    578594                }
    579595
    580596                if (!FrameUtils.LeavingFrame(getCurrentFrame())) {
    581                         FrameGraphics.DisplayMessage("Back operation cancelled");
     597                        MessageBay.displayMessage("Back operation cancelled");
    582598                        return;
    583599                }
  • trunk/src/org/expeditee/gui/Frame.java

    r116 r121  
    2424import org.expeditee.items.InteractiveWidget;
    2525import org.expeditee.items.Item;
     26import org.expeditee.items.ItemAppearence;
    2627import org.expeditee.items.ItemParentStateChangedEvent;
    2728import org.expeditee.items.ItemUtils;
     
    99100        // Note: Needs to be able to be iterated through (for painting)
    100101        private List<Item> _body = new ArrayList<Item>();
    101 
    102         public static List<Item> FreeItems = new ArrayList<Item>();
    103102
    104103        // for drawing purposes
     
    660659                _body.add(item);
    661660                item.setParent(this);
     661                item.invalidateCommonTrait(ItemAppearence.Added);
    662662
    663663                // If the item is a line end and has constraints with items already
     
    717717                                        _iWidgets.remove(((WidgetCorner) item).getWidgetSource());
    718718                                }
    719                         }
     719                                item.invalidateCommonTrait(ItemAppearence.Removed);
     720                        }
     721                       
    720722                }
    721723        }
     
    862864                _background = back;
    863865                change();
    864                 // FrameGraphics.Repaint();
     866               
     867                if (this == DisplayIO.getCurrentFrame()) {
     868                        FrameGraphics.refresh(false);
     869                }
    865870        }
    866871
     
    10121017                                        toAdd.permission));
    10131018                        _vectorItems.add(i);
     1019                        i.invalidateAll();
     1020                        i.invalidateFill();
    10141021                }
    10151022                return true;
     
    10971104        public void clearVectors() {
    10981105                _vectors.clear();
     1106               
     1107                for (Item i : _vectorItems) { // TODO: Rethink where this should live
     1108                        i.invalidateAll();
     1109                        i.invalidateFill();
     1110                }
    10991111                _vectorItems.clear();
     1112               
    11001113        }
    11011114
     
    11041117                        return false;
    11051118                for (Item i : toRemove.Frame.getVectorItems()) {
     1119                        i.invalidateAll();
     1120                        i.invalidateFill();
    11061121                        _overlayItems.remove(i);
    11071122                        i.onParentStateChanged(new ItemParentStateChangedEvent(this,
    11081123                                        ItemParentStateChangedEvent.EVENT_TYPE_REMOVED_VIA_OVERLAY,
    11091124                                        toRemove.permission));
     1125                       
    11101126                }
    11111127                return true;
     
    11421158                }
    11431159        }
    1144 
     1160       
    11451161        public void addAllOverlays(Collection<Overlay> overlays) {
    11461162                for (Overlay o : overlays) {
     
    13961412
    13971413        public static boolean rubberbandingLine() {
    1398                 return FreeItems.size() == 2
    1399                                 && (FreeItems.get(0) instanceof Line || FreeItems.get(1) instanceof Line);
     1414                return FreeItems.getInstance().size() == 2
     1415                                && (FreeItems.getInstance().get(0) instanceof Line || FreeItems.getInstance().get(1) instanceof Line);
    14001416        }
    14011417
    14021418        public static boolean itemAttachedToCursor() {
    1403                 return FreeItems.size() > 0;
     1419                return FreeItems.getInstance().size() > 0;
    14041420        }
    14051421
    14061422        public static boolean textItemAttachedToCursor() {
    1407                 return itemAttachedToCursor() && FreeItems.get(0) instanceof Text;
     1423                return itemAttachedToCursor() && FreeItems.getInstance().get(0) instanceof Text;
    14081424        }
    14091425
    14101426        public static Item getItemAttachedToCursor() {
    14111427                if (itemAttachedToCursor())
    1412                         return FreeItems.get(0);
     1428                        return FreeItems.getInstance().get(0);
    14131429
    14141430                return null;
  • trunk/src/org/expeditee/gui/FrameGraphics.java

    r115 r121  
    55import java.awt.Container;
    66import java.awt.Dimension;
    7 import java.awt.Font;
     7import java.awt.EventQueue;
    88import java.awt.Graphics;
    99import java.awt.Graphics2D;
     
    1111import java.awt.Image;
    1212import java.awt.Point;
     13import java.awt.Rectangle;
    1314import java.awt.RenderingHints;
     15import java.awt.geom.Area;
    1416import java.awt.image.BufferedImage;
    15 import java.awt.image.VolatileImage;
    1617import java.util.Collection;
    1718import java.util.Collections;
     
    2122import java.util.List;
    2223
     24import javax.swing.JComponent;
    2325import javax.swing.JPopupMenu;
    2426import javax.swing.SwingUtilities;
    2527
    26 import org.expeditee.actions.Misc;
    2728import org.expeditee.items.Circle;
    2829import org.expeditee.items.InteractiveWidget;
     
    3031import org.expeditee.items.ItemUtils;
    3132import org.expeditee.items.Line;
    32 import org.expeditee.items.Text;
    3333import org.expeditee.items.WidgetEdge;
    3434import org.expeditee.items.XRayable;
    3535
    3636public class FrameGraphics {
    37         public static final int MESSAGE_BUFFER_HEIGHT = 100;
    38 
    39         private static final int MESSAGE_LINK_Y_OFFSET = 100;
    40 
    41         private static final int MESSAGE_LINK_X = 50;
    4237
    4338        // the graphics used to paint with
     
    4742        private static Dimension _MaxSize;
    4843
    49         // messages shown in the message window
    50         public static Text[] Messages = new Text[4];
    51 
    52         // buffer of the message window
    53         private static VolatileImage _MessageBuffer = null;
    54 
    55         // font used for the messages
    56         private static Font _MessageFont = Font.decode("Serif-Plain-16");
    57 
    58         // the number of messages currently shown (used for scrolling up)
    59         private static int _MessageCount = 0;
    60 
    6144        // modes
    6245        public static final int MODE_NORMAL = 0;
     
    6548
    6649        public static final int MODE_XRAY = 2;
    67 
    68         public static final Color ERROR_COLOR = Color.red;
    6950
    7051        // Start in XRay mode so that errors arnt thrown when parsing the profile
    7152        // frame if it has images on it
    7253        private static int _Mode = MODE_XRAY;
    73 
    74         // if true, error messages are not shown to the user
    75         private static boolean _SupressMessages = false;
    76 
    77         public static String MESSAGES_FRAMESET_NAME = "Messages";
    78 
    79         // The link to the message frameset
    80         public static Item MessageLink = new Text(-2, "@" + MESSAGES_FRAMESET_NAME,
    81                         Color.black, Color.white);
    82 
    83         // creator for creating the message frames
    84         private static FrameCreator _creator;
     54       
     55        private FrameGraphics() {
     56                // util constructor
     57        }
    8558
    8659        /**
     
    10477                FrameUtils.Parse(current);
    10578                DisplayIO.UpdateTitle();
    106                 setMaxSize(new Dimension(_MaxSize.width, _MessageBuffer.getHeight()
     79                setMaxSize(new Dimension(_MaxSize.width, MessageBay.getMessageBufferHeight()
    10780                                + _MaxSize.height));
    108                 Repaint();
     81                refresh(false);
    10982        }
    11083
     
    12093                DisplayIO.UpdateTitle();
    12194                FrameMouseActions.getInstance().refreshHighlights();
    122                 Repaint();
     95                refresh(false);
    12396        }
    12497
     
    151124                // Hide the message buffer if in audience mode
    152125                int newMaxHeight = max.height
    153                                 - (isAudienceMode() ? 0 : MESSAGE_BUFFER_HEIGHT);
     126                                - (isAudienceMode() ? 0 : MessageBay.MESSAGE_BUFFER_HEIGHT);
    154127                if (newMaxHeight > 0) {
    155128                        _MaxSize.setSize(max.width, newMaxHeight);
     
    161134                }
    162135
    163                 if (newMaxHeight > 0) {
    164                         _MessageBuffer = null;
    165 
    166                         for (int i = 0; i < Messages.length; i++) {
    167                                 if (Messages[i] != null) {
    168                                         Messages[i].setOffset(0, -_MaxSize.height);
    169                                         Messages[i].setMaxSize(_MaxSize);
    170                                 }
    171                         }
    172 
    173                         MessageLink.setOffset(0, -_MaxSize.height);
    174                         MessageLink.setMaxSize(_MaxSize);
    175                         MessageLink.setPosition(_MaxSize.width - MESSAGE_LINK_Y_OFFSET,
    176                                         MESSAGE_LINK_X);
    177                 }
    178                 // Repaint();
     136                if (newMaxHeight > 0)
     137                        MessageBay.updateSize();
    179138        }
    180139
     
    205164         * Displays the given Item on the screen
    206165         */
    207         private static void PaintItem(Graphics2D g, Item i) {
     166        static void PaintItem(Graphics2D g, Item i) {
    208167                if (i == null || g == null)
    209168                        return;
     
    286245        }
    287246
    288         private static Image Paint(Frame toPaint) {
    289                 return Paint(toPaint, true);
    290         }
    291 
    292         private static Image Paint(Frame toPaint, boolean isActualFrame) {
     247        private static Image Paint(Frame toPaint, Area clip) {
     248                return Paint(toPaint, clip, true);
     249        }
     250
     251        /**
     252         *
     253         * @param toPaint
     254         * @param clip If null, then no clip applied.
     255         * @param isActualFrame
     256         * @return
     257         */
     258        private static Image Paint(Frame toPaint, Area clip, boolean isActualFrame) {
    293259                if (toPaint == null)
    294260                        return null;
     
    313279
    314280                        Graphics2D bg = (Graphics2D) buffer.getGraphics();
     281                        bg.setClip(clip);
     282                       
     283                        // TODO: Revise images and clip - VERY IMPORTANT
    315284
    316285                        // Nicer looking lines, but may be too jerky while
     
    331300                        }
    332301
     302                       
    333303                        bg.setColor(backgroundColor);
     304                        // bg.setColor(Color.pink); // TODO: TEMP FOR DEBUGGING
     305                       
    334306                        bg.fillRect(0, 0, _MaxSize.width, _MaxSize.height);
    335307
    336                         List<Item> paintItems = new LinkedList<Item>();
     308                        List<Item> visibleItems = new LinkedList<Item>();
    337309                        List<InteractiveWidget> paintWidgets;
    338310
     
    340312                                // Add all the items for this frame and any other from other
    341313                                // frames
    342                                 paintItems.addAll(toPaint.getAllItems());
    343 
     314                                visibleItems.addAll(toPaint.getAllItems());
    344315                                paintWidgets = new LinkedList<InteractiveWidget>();
    345316                                AddAllOverlayWidgets(paintWidgets, toPaint,
    346317                                                new LinkedList<Frame>());
    347318                        } else {
    348                                 paintItems.addAll(toPaint.getVisibleItems());
    349                                 paintItems.addAll(toPaint.getVectorItems());
     319                                visibleItems.addAll(toPaint.getVisibleItems());
     320                                visibleItems.addAll(toPaint.getVectorItems());
    350321                                paintWidgets = toPaint.getInteractiveWidgets();
    351322                        }
    352323
    353324                        // FIRST: Paint widgets swing gui (not expeditee gui) .
    354                         // Note that these are the ancored widgets
     325                        // Note that these are the anchored widgets
    355326                        for (InteractiveWidget iw : paintWidgets) {
    356                                 iw.paint(bg);
    357                         }
    358 
    359                         PaintPictures(bg, paintItems);
    360                         PaintLines(bg, paintItems);
    361 
     327                                if (clip == null || clip.intersects(iw.getComponant().getBounds()))
     328                                        iw.paint(bg);
     329                        }
     330                       
     331                        // Filter out items that do not need to be painted
     332                        List<Item> paintItems;
     333                        HashSet<Item> fillOnlyItems = null; // only contains items that do not need drawing but fills might
     334                       
     335                        if (clip == null) {
     336                                paintItems = visibleItems;
     337                        } else {
     338                                fillOnlyItems = new HashSet<Item>();
     339                                paintItems = new LinkedList<Item>();
     340                                for (Item i : visibleItems) {
     341                                        if (i.isInDrawingArea(clip)) {
     342                                                paintItems.add(i);
     343                                        } else if (i.isEnclosed()) {
     344                                                // just add all fill items despite possibility of fills not being in clip
     345                                                // because it will be faster than having to test twice for fills that do need
     346                                                // repainting.
     347                                                fillOnlyItems.add(i);
     348                                        }
     349                                }
     350                        }
     351                        // Only paint files and lines once ... between anchored AND free items
     352                        HashSet<Item> paintedFillsAndLines = new HashSet<Item> ();
     353                        PaintPictures(bg, paintItems, fillOnlyItems, paintedFillsAndLines);
     354                        PaintLines(bg, visibleItems);
     355
     356                        // Filter out free items that do not need to be painted
     357                        // This is efficient in cases with animation while free items exist
     358                       
     359                        List<Item> freeItemsToPaint = new LinkedList<Item>();
     360                        if (clip == null) {
     361                                freeItemsToPaint = FreeItems.getInstance();
     362                        } else {
     363                                freeItemsToPaint = new LinkedList<Item>();
     364                                fillOnlyItems.clear();
     365                                for (Item i : FreeItems.getInstance()) {
     366                                        if (i.isInDrawingArea(clip)) {
     367                                                freeItemsToPaint.add(i);
     368                                        } else if (i.isEnclosed()) {
     369                                                fillOnlyItems.add(i);
     370                                        }
     371                                }
     372                        }
     373                       
    362374                        if (isActualFrame /* && toPaint == DisplayIO.getCurrentFrame() */)
    363                                 PaintPictures(bg, Frame.FreeItems);
    364                         // TODO if we can get transparency with FreeItems... then text can
     375                                PaintPictures(bg, freeItemsToPaint, fillOnlyItems, paintedFillsAndLines);
     376                        // TODO if we can get transparency with FreeItems.getInstance()... then text can
    365377                        // be done before freeItems
    366378                        PaintNonLinesNonPicture(bg, paintItems);
     
    374386                        if (DisplayIO.isTwinFramesOn()) {
    375387                                List<Item> lines = new LinkedList<Item>();
    376                                 for (Item i : Frame.FreeItems) {
     388                                for (Item i : freeItemsToPaint) {
    377389                                        if (i instanceof Line) {
    378390                                                Line line = (Line) i;
     
    411423                                // Dont paint the
    412424                                if (isActualFrame)
    413                                         PaintLines(bg, Frame.FreeItems);
     425                                        PaintLines(bg, freeItemsToPaint);
    414426                        }
    415427
    416428                        if (isActualFrame /* && toPaint == DisplayIO.getCurrentFrame() */)
    417                                 PaintNonLinesNonPicture(bg, Frame.FreeItems);
     429                                PaintNonLinesNonPicture(bg, freeItemsToPaint);
    418430
    419431                        // BROOK: Ensure popups are repainted
     
    465477        }
    466478
    467         private static void Paint(Image left, Image right, Color background) {
    468                 if (_MessageBuffer == null) {
    469                         GraphicsEnvironment ge = GraphicsEnvironment
    470                                         .getLocalGraphicsEnvironment();
    471                         _MessageBuffer = ge.getDefaultScreenDevice()
    472                                         .getDefaultConfiguration().createCompatibleVolatileImage(
    473                                                         _MaxSize.width,
    474                                                         (isAudienceMode() ? 0 : MESSAGE_BUFFER_HEIGHT));
    475                 }
    476 
    477                 paintMessage(_MessageBuffer.createGraphics(), background);
    478                 Graphics g = _DisplayGraphics.create();
     479        private static void Paint(Graphics g, Image left, Image right, Color background) {
    479480
    480481                // if TwinFrames mode is on, then clipping etc has to be set
     
    503504                                g.drawImage(right, 0, 0, Item.DEFAULT_BACKGROUND, null);
    504505                }
    505                 // Dont display the message area in audience mode
    506                 if (!isAudienceMode()) {
    507                         // draw the message area
    508                         g.drawImage(_MessageBuffer, 0, _MaxSize.height, null);
    509                 }
    510                 g.dispose();
    511 
    512         }
    513 
    514         /**
    515          * Paints the message area
    516          *
    517          * @param g
    518          * @param background
    519          */
    520         private static void paintMessage(Graphics2D g, Color background) {
    521                 ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
    522                                 RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    523                 g.setColor(background);
    524                 g.fillRect(0, 0, _MaxSize.width, MESSAGE_BUFFER_HEIGHT);
    525                 g.setFont(_MessageFont);
    526                 g.setColor(Color.BLACK);
    527                 g.drawLine(0, 0, _MaxSize.width, 0);
    528                 for (Item t : Messages)
    529                         PaintItem(g, t);
    530                 if (MessageLink.getLink() != null)
    531                         PaintItem(g, MessageLink);
    532                 g.dispose();
     506
    533507        }
    534508
     
    539513                g.dispose();
    540514        }
    541 
    542         /**
    543          * Called to refresh the display screen.
    544          *
    545          */
    546         public static void Repaint() {
    547                 Runtime.getRuntime();
    548                 if (_DisplayGraphics == null)
    549                         return;
    550 
    551                 if (UserSettings.Threading) {
    552                         if (painter == null) {
    553                                 painter = new FrameGraphics().new Repainter();
    554 
    555                                 painter.setDaemon(true);
    556                                 painter.setPriority(Thread.MIN_PRIORITY);
    557 
    558                                 painter.start();
    559                         } else
    560                                 painter.run();
    561                 } else {
    562                         Frame[] toPaint = DisplayIO.getFrames();
    563 
    564                         if (toPaint != null) {
    565                                 Image left = Paint(toPaint[0]);
    566                                 Image right = Paint(toPaint[1]);
    567                                 Paint(left, right, Item.DEFAULT_BACKGROUND);
    568                         }
    569                 }
    570         }
    571 
    572         private static Repainter painter = null;
    573515
    574516        private static void PaintNonLinesNonPicture(Graphics2D g, List<Item> toPaint) {
     
    601543        }
    602544
     545
    603546        /**
    604547         * Paint filled areas and their surrounding lines as well as pictures.
    605          *
     548         * Note: floating widgets are painted as fills
    606549         * @param g
    607550         * @param toPaint
    608551         */
    609         private static void PaintPictures(Graphics2D g, List<Item> toPaint) {
    610                 // Use this set to keep track of the items that dont need to be
    611                 // repainted
    612                 Collection<Item> done = new HashSet<Item>();
     552        private static void PaintPictures(Graphics2D g, List<Item> toPaint,
     553                        HashSet<Item> fillOnlyItems, HashSet<Item> done) {
     554               
    613555                List<Item> toFill = new LinkedList<Item>();
    614556                for (Item i : toPaint) {
     
    634576                        }
    635577                }
     578               
     579                if (fillOnlyItems != null) {
     580                        for (Item i : fillOnlyItems) {
     581                                if (done.contains(i)) continue;
     582                                else if (!isAudienceMode() || !i.isConnectedToAnnotation()) {
     583                                        toFill.add(i);
     584                                }
     585                                done.addAll(i.getAllConnected());
     586                        }
     587                }
     588               
    636589                // Sort the items to fill
    637590                Collections.sort(toFill, new Comparator<Item>() {
     
    639592                                Double aArea = a.getEnclosedArea();
    640593                                Double bArea = b.getEnclosedArea();
    641                                 return aArea.compareTo(bArea) * -1;
     594                                int cmp = aArea.compareTo(bArea);
     595                                if (cmp == 0) {
     596                                        return new Integer(a.getID()).compareTo(b.getID());
     597                                }
     598                                return cmp * -1;
    642599                        }
    643600                });
     
    715672                // Mike: TODO comment on why the line below is used!!
    716673                // I forgot already!!Opps
    717                 boolean freeItem = Frame.FreeItems.contains(item);
     674                boolean freeItem = FreeItems.getInstance().contains(item);
    718675                for (Item i : item.getAllConnected()) {
    719                         if (/* freeItem || */!Frame.FreeItems.contains(i)) {
     676                        if (/* freeItem || */!FreeItems.getInstance().contains(i)) {
    720677                                i.setHighlightMode(connectedNewMode);
    721678                        }
     
    723680                if (!freeItem && newMode != connectedNewMode)
    724681                        item.setHighlightMode(newMode);
    725                 Repaint();
    726         }
    727 
    728         public static void OverwriteMessage(String message) {
    729                 for (int ind = Messages.length - 1; ind >= 0; ind--) {
    730                         if (Messages[ind] != null) {
    731                                 Messages[ind].setText(getMessagePrefix(false) + message);
    732                                 Repaint();
    733                                 return;
    734                         }
    735                 }
    736 
    737                 // if we have not returned, then there are no messages yet
    738                 DisplayMessage(message, Color.darkGray);
    739         }
    740 
    741         /**
    742          * Displays the given message in the message area of the Frame, any previous
    743          * message is cleared from the screen.
    744          *
    745          * @param message
    746          *            The message to display to the user in the message area
    747          */
    748         public static void DisplayMessage(String message) {
    749                 DisplayMessageAlways(message);
    750         }
    751 
    752         public static void DisplayMessageOnce(String message) {
    753                 displayMessage(message, null, null, Color.BLACK, false);
    754         }
    755 
    756         public static void DisplayMessage(String message, Color textColor) {
    757                 displayMessage(message, null, null, textColor);
    758                 // Misc.Beep();
    759         }
    760 
    761         public static void DisplayMessage(Text message) {
    762                 displayMessage(message.getFirstLine(), message.getLink(), message
    763                                 .getAction(), message.getColor());
    764                 // Misc.Beep();
    765         }
    766 
    767         public static void DisplayMessageAlways(String message) {
    768                 displayMessage(message, null, null, Color.BLACK);
    769                 // Misc.Beep();
    770         }
    771 
    772         public static void WarningMessage(String message) {
    773                 displayMessage(message, null, null, Color.MAGENTA);
    774                 // Misc.Beep();
    775         }
    776 
    777         private static String _lastMessage = null;
    778 
    779         private static void displayMessage(String message, String link,
    780                         List<String> actions, Color color) {
    781                 displayMessage(message, link, actions, color, true);
    782         }
    783 
    784         private static void displayMessage(String message, String link,
    785                         List<String> actions, Color color, boolean displayAlways) {
    786 
    787                 System.out.println(message);
    788                 assert (message != null);
    789 
    790                 if (_SupressMessages)
    791                         return;
    792 
    793                 if (!displayAlways && message.equals(_lastMessage)) {
    794                         Misc.Beep();
    795                         return;
    796                 }
    797                 _lastMessage = message;
    798 
    799                 if (_creator == null) {
    800                         _creator = new FrameCreator(MESSAGES_FRAMESET_NAME, true);
    801 
    802                         // set up 'Messages' link on the right hand side
    803                         MessageLink.setPosition(_MaxSize.width - MESSAGE_LINK_Y_OFFSET,
    804                                         MESSAGE_LINK_X);
    805                         MessageLink.setOffset(0, -_MaxSize.height);
    806                 }
    807 
    808                 // if the message slots have not all been used yet
    809                 if (_MessageCount <= Messages.length) {
    810                         int pos = 15;
    811                         // find the next empty slot, and create the new message
    812                         for (int i = 0; i < Messages.length; i++) {
    813                                 if (Messages[i] == null) {
    814                                         Messages[i] = new Text(getMessagePrefix(true) + message);
    815                                         Messages[i].setPosition(20, pos);
    816                                         Messages[i].setOffset(0, -_MaxSize.height);
    817                                         Messages[i].setMaxSize(_MaxSize);
    818                                         Messages[i].setColor(color);
    819                                         Messages[i].setLink(link);
    820                                         _creator.addItem(Messages[i].copy());
    821                                         MessageLink.setLink(_creator.getCurrent());
    822                                         Repaint();
    823                                         return;
    824                                 }
    825 
    826                                 pos += 25;
    827                         }
    828                 }
    829 
    830                 // if we have not returned then all message slots are used
    831                 for (int i = 0; i < Messages.length - 1; i++) {
    832                         Messages[i].setText(Messages[i + 1].getFirstLine());
    833                         Messages[i].setColor(Messages[i + 1].getColor());
    834                         Messages[i].setLink(Messages[i + 1].getLink());
    835                 }
    836 
    837                 // show the new message
    838                 Text last = Messages[Messages.length - 1];
    839                 last.setColor(color);
    840                 // Make set the text for the new message
    841                 last.setText(getMessagePrefix(true) + message);
    842                 last.setLink(link);
    843                 last.setActions(actions);
    844 
    845                 _creator.addItem(last.copy());
    846                 // update the link to the latest message frame
    847                 MessageLink.setLink(_creator.getCurrent());
    848                 Repaint();
    849         }
    850 
    851         private static String getMessagePrefix(boolean incrementCounter) {
    852                 if (incrementCounter)
    853                         _MessageCount++;
    854                 return "@" + _MessageCount + ": ";
    855         }
    856 
    857         /**
    858          * Checks if the error message ends with a frame name after the
    859          * frameNameSeparator symbol
    860          *
    861          * @param message
    862          *            the message to be displayed
    863          */
    864         public static void LinkedErrorMessage(String message) {
    865                 if (_SupressMessages)
    866                         return;
    867                 Misc.Beep();
    868                 String[] tokens = message.split(Text.FRAME_NAME_SEPARATOR);
    869                 String link = null;
    870                 if (tokens.length > 1)
    871                         link = tokens[tokens.length - 1];
    872                 displayMessage(message, link, null, ERROR_COLOR);
    873         }
    874 
    875         public static void ErrorMessage(String message) {
    876                 if (_SupressMessages)
    877                         return;
    878                 Misc.Beep();
    879                 displayMessage(message, null, null, ERROR_COLOR);
    880         }
    881 
    882         private class Repainter extends Thread {
    883                 public boolean isPainting = false;
    884 
    885                 public void run() {
    886                         // TODO see if there is any other way to deal with this
    887                         if (_MaxSize.width <= 0 || _MaxSize.height <= 0) {
    888                                 return;
    889                         }
    890                         isPainting = true;
    891 
    892                         Frame[] toPaint = DisplayIO.getFrames();
    893 
    894                         if (toPaint != null) {
    895                                 Image left = Paint(toPaint[0]);
    896                                 Image right = Paint(toPaint[1]);
    897                                 Paint(left, right, Item.DEFAULT_BACKGROUND);
    898                         }
    899                         isPainting = false;
    900                 }
    901         }
    902 
    903         /**
    904          * Invalidates the buffered image of the current Frame and forces it to be
    905          * repainted on to the screen.
    906          */
    907         public static void ForceRepaint() {
    908                 Frame current = DisplayIO.getCurrentFrame();
    909 
    910                 if (current == null)
    911                         return;
    912 
    913682                Repaint();
    914683        }
     
    925694                        return;
    926695
    927                 Image vi = Paint(toUpdate, paintOverlays);
     696                Image vi = Paint(toUpdate, null, paintOverlays);
    928697                toUpdate.setBuffer(vi);
    929         }
    930 
    931         public static void SupressMessages(boolean val) {
    932                 _SupressMessages = val;
    933698        }
    934699
     
    939704                                                Browser._theBrowser.getContentPane());
    940705
     706                                c.setIgnoreRepaint(true);
     707                                ((JComponent)c).setDoubleBuffered(false);
    941708                                g.translate(p.x, p.y);
    942709                                c.paint(g);
     
    952719                return _Mode;
    953720        }
     721
     722        // Damaged areas pending to render. Accessessed by multiple threads
     723        private static HashSet<Rectangle> damagedAreas = new HashSet<Rectangle>();
     724       
     725        /**
     726         * Checks that the item is visible (on current frame && overlays) - if visible
     727         * then damaged area will be re-rendered on the next refresh.
     728         * @param damagedItem
     729         * @param toRepaint
     730         */
     731        public static void invalidateItem(Item damagedItem, Rectangle toRepaint) {
     732                // Only add area to repaint if item is visible...
     733                if (ItemUtils.isVisible(damagedItem)) {
     734                        synchronized(damagedAreas) {
     735                                damagedAreas.add(toRepaint);
     736                        }
     737                } else if(MessageBay.isMessageItem(damagedItem)) {
     738                        MessageBay.addDirtyArea(toRepaint);
     739                }
     740        }
     741       
     742        /**
     743         * The given area will be re-rendered in the next refresh. This is the quicker version
     744         * and is more useful for re-rendering animated areas.
     745         * @param toRepaint
     746         */
     747        public static void invalidateArea(Rectangle toRepaint) {
     748                synchronized(damagedAreas) {
     749                        damagedAreas.add(toRepaint);
     750                }
     751        }
     752       
     753        public static void clearInvalidAreas() {
     754                synchronized(damagedAreas) {
     755                        damagedAreas.clear();
     756                }
     757        }
     758       
     759        /**
     760         * Invalidates the buffered image of the current Frame and forces it to be
     761         * repainted on to the screen. Repaints all items. This is more expensive
     762         * than refresh.
     763         */
     764        public static void ForceRepaint() {  // TODO: TEMP: Use refresh
     765                Frame current = DisplayIO.getCurrentFrame();
     766
     767                if (current == null)
     768                        return;
     769                refresh(false);
     770        }
     771       
     772        public static void Repaint() { // TODO: TEMP: Use refresh
     773                refresh(true);
     774        }
     775
     776        /**
     777         * Called to refresh the display screen. Thread safe.
     778         */
     779        public static void refresh(boolean useInvalidation) {
     780               
     781                if (_DisplayGraphics == null) return;
     782
     783                Area clip = null;
     784                if (useInvalidation) { // build clip
     785                       
     786                        synchronized(damagedAreas) {
     787                                if (!damagedAreas.isEmpty()) {
     788                                       
     789                                        for (Rectangle r : damagedAreas) {
     790                                                if (clip == null) clip = new Area(r);
     791                                                clip.add(new Area(r)); 
     792                                        }
     793                                        damagedAreas.clear();
     794                                } else return; // nothing to render
     795                        }
     796               
     797                } else {
     798                        synchronized(damagedAreas) {
     799                                damagedAreas.clear();
     800                        }
     801                        System.out.println("FULLSCREEN REFRESH"); // TODO: REMOVE
     802                }
     803
     804                Frame[] toPaint = DisplayIO.getFrames();
     805                Image left = Paint(toPaint[0], clip);
     806                Image right = Paint(toPaint[1], clip);
     807               
     808                Graphics dg = _DisplayGraphics.create();
     809               
     810                // Paint frame to window
     811                Paint(dg, left, right, Item.DEFAULT_BACKGROUND);
     812               
     813                // Paint message bay
     814                MessageBay.refresh(useInvalidation, dg, Item.DEFAULT_BACKGROUND);
     815               
     816                dg.dispose();
     817        }
     818       
     819        /**
     820         * If wanting to refresh from another thread - other than the main thread that
     821         * handles the expeditee datamodel (modifying / accessing / rendering). Use
     822         * this method for thread safety.
     823         */
     824        public static synchronized void requestRefresh(boolean useInvalidation) {
     825               
     826                _requestMarsheller._useInvalidation = useInvalidation;
     827               
     828                if (_requestMarsheller._isQueued) {
     829                        return;
     830                }
     831               
     832                _requestMarsheller._isQueued = true;
     833                EventQueue.invokeLater(_requestMarsheller); // Render on AWT thread
     834        }
     835       
     836        private static RenderRequestMarsheller _requestMarsheller = new FrameGraphics().new RenderRequestMarsheller();
     837       
     838        /**
     839         * Used for marshelling render requests from foreign threads to the event dispatcher thread... (AWT)
     840         * @author Brook Novak
     841         */
     842        private class RenderRequestMarsheller implements Runnable {
     843
     844                boolean _useInvalidation = true;
     845                boolean _isQueued = false;
     846               
     847                public void run() {
     848                        refresh(_useInvalidation);
     849                        _isQueued = false;
     850                        _useInvalidation = true;
     851                }
     852
     853        }
     854       
    954855}
  • trunk/src/org/expeditee/gui/FrameIO.java

    r108 r121  
    116116                // do not display errors encountered to the user
    117117                // (they will be shown at load time)
    118                 FrameGraphics.SupressMessages(true);
     118                MessageBay.supressMessages(true);
    119119                // loading automatically caches the frame is caching is turned on
    120120                LoadUnknownPath(framename);
    121                 FrameGraphics.SupressMessages(false);
     121                MessageBay.supressMessages(false);
    122122        }
    123123
     
    255255
    256256                        if (frame == null) {
    257                                 FrameGraphics.ErrorMessage("Error: " + frameName
     257                                MessageBay.errorMessage("Error: " + frameName
    258258                                                + " could not be successfully loaded.");
    259259                                return null;
     
    276276                        e.printStackTrace();
    277277                        Logger.Log(e);
    278                         FrameGraphics.ErrorMessage("Error: " + frameName
     278                        MessageBay.errorMessage("Error: " + frameName
    279279                                        + " could not be successfully loaded.");
    280280                }
     
    311311                // if we did not find another Frame then this one must be the last one
    312312                // in the frameset
    313                 FrameGraphics
    314                                 .DisplayMessageOnce("This is the first frame in the frameset");
     313                MessageBay
     314                                .displayMessageOnce("This is the first frame in the frameset");
    315315                return null;
    316316        }
     
    335335                        max = ReadINF(current.path, current.getFramesetName());
    336336                } catch (IOException ioe) {
    337                         FrameGraphics.ErrorMessage("Error loading INF file for frameset '"
     337                        MessageBay.errorMessage("Error loading INF file for frameset '"
    338338                                        + name + "'");
    339339                        return null;
     
    349349                // if we did not find another Frame then this one must be the last one
    350350                // in the frameset
    351                 FrameGraphics
    352                                 .DisplayMessageOnce("This is the last frame in the frameset");
     351                MessageBay
     352                                .displayMessageOnce("This is the last frame in the frameset");
    353353                return null;
    354354        }
     
    375375                        max = ReadINF(path, framesetName);
    376376                } catch (IOException ioe) {
    377                         FrameGraphics.ErrorMessage("Error loading INF file for frameset '"
     377                        MessageBay.errorMessage("Error loading INF file for frameset '"
    378378                                        + framesetName + "'");
    379379                        return null;
     
    389389                // if we did not find another Frame then this one must be the last one
    390390                // in the frameset
    391                 FrameGraphics.DisplayMessage("This is the last frame in the frameset");
     391                MessageBay.displayMessage("This is the last frame in the frameset");
    392392                return null;
    393393        }
     
    701701                        if (savedVersion > toSave.getVersion()
    702702                                        && !toSave.getFramesetName().equalsIgnoreCase(
    703                                                         FrameGraphics.MESSAGES_FRAMESET_NAME)) {
     703                                                        MessageBay.MESSAGES_FRAMESET_NAME)) {
    704704                                // remove this frame from the cache if it is there
    705705                                // This will make sure links to the original are set correctly
     
    714714                                // Show the messages alerting the user
    715715                                Text originalMessage = new Text(-1);
    716                                 originalMessage.setColor(FrameGraphics.ERROR_COLOR);
     716                                originalMessage.setColor(MessageBay.ERROR_COLOR);
    717717                                originalMessage.setText(original.getName()
    718718                                                + " was updated by another user.");
    719719                                originalMessage.setLink(original.getName());
    720720                                Text yourMessage = new Text(-1);
    721                                 yourMessage.setColor(FrameGraphics.ERROR_COLOR);
     721                                yourMessage.setColor(MessageBay.ERROR_COLOR);
    722722                                yourMessage.setText("Your version was renamed "
    723723                                                + toSave.getName());
    724724                                yourMessage.setLink(toSave.getName());
    725                                 FrameGraphics.DisplayMessage(originalMessage);
    726                                 FrameGraphics.DisplayMessage(yourMessage);
     725                                MessageBay.displayMessage(originalMessage);
     726                                MessageBay.displayMessage(yourMessage);
    727727                        } else if (checkBackup
    728728                                        && ItemUtils.ContainsExactTag(toSave.getItems(),
  • trunk/src/org/expeditee/gui/FrameKeyboardActions.java

    r115 r121  
    8282                // permission check
    8383                if (on != null && !on.hasPermission(Permission.full)) {
    84                         FrameGraphics
    85                                         .DisplayMessage("Insufficient permission to edit this item");
     84                        MessageBay
     85                                        .displayMessage("Insufficient permission to edit this item");
    8686                        return;
    8787                }
     
    577577                                                        && clicked.getParent() != null
    578578                                                        && clicked.getParent().getNameItem() != clicked) {
    579                                                 FrameGraphics.DisplayMessage("Insufficient Permission");
     579                                                MessageBay.displayMessage("Insufficient Permission");
    580580                                                return;
    581581                                        }
     
    621621                        if (current instanceof Text) {
    622622                                if (current != null && !current.hasPermission(Permission.copy)) {
    623                                         FrameGraphics
    624                                                         .DisplayMessage("Insufficient permission to copy that item");
     623                                        MessageBay
     624                                                        .displayMessage("Insufficient permission to copy that item");
    625625                                        return;
    626626                                }
    627627                                copyItemToClipboard(current);
    628                                 // FrameGraphics.DisplayMessage("Item copied to clipboard");
     628                                // MessageBay.displayMessage("Item copied to clipboard");
    629629                                return;
    630630                        }
    631631                        if (current != null && !current.hasPermission(Permission.full)) {
    632                                 FrameGraphics
    633                                                 .DisplayMessage("Insufficient permission edit that item");
     632                                MessageBay
     633                                                .displayMessage("Insufficient permission edit that item");
    634634                                return;
    635635                        }
     
    656656                                return;
    657657                        if (current != null && !current.hasPermission(Permission.full)) {
    658                                 FrameGraphics
    659                                                 .DisplayMessage("Insufficient permission to cut that item");
     658                                MessageBay
     659                                                .displayMessage("Insufficient permission to cut that item");
    660660                                return;
    661661                        }
     
    667667                                return;
    668668                        if (current != null && !current.hasPermission(Permission.full)) {
    669                                 FrameGraphics
    670                                                 .DisplayMessage("Insufficient permission toggle the items mark");
     669                                MessageBay
     670                                                .displayMessage("Insufficient permission toggle the items mark");
    671671                                return;
    672672                        }
     
    742742
    743743                if (item != null && !item.hasPermission(Permission.full)) {
    744                         FrameGraphics
    745                                         .DisplayMessage("Insufficient permission to copy that item");
     744                        MessageBay
     745                                        .displayMessage("Insufficient permission to copy that item");
    746746                        return null;
    747747                }
     
    840840                                break;
    841841                        default:
    842                                 FrameGraphics.DisplayMessageOnce(displayMessage);
     842                                MessageBay.displayMessageOnce(displayMessage);
    843843                                return;
    844844                        }
     
    892892                Collection<Item> enclosed = FrameUtils.getCurrentItems(on);
    893893                if (on == null && (enclosed == null || enclosed.size() == 0))
    894                         FrameGraphics.DisplayMessage(displayMessage);
     894                        MessageBay.displayMessage(displayMessage);
    895895        }
    896896
     
    932932                        // if no item was found, return
    933933                        if (toDropFrom == null) {
    934                                 FrameGraphics
    935                                                 .ErrorMessage("No item could be found to drop from");
     934                                MessageBay.errorMessage("No item could be found to drop from");
    936935                                return;
    937936                        }
    938937
    939938                        if (!(toDropFrom instanceof Text)) {
    940                                 FrameGraphics
    941                                                 .DisplayMessage("Only text items can be dropped from");
     939                                MessageBay
     940                                                .displayMessage("Only text items can be dropped from");
    942941                                return;
    943942                        }
     
    948947
    949948                        if (column == null) {
    950                                 FrameGraphics.ErrorMessage("No column found to align items to");
     949                                MessageBay.errorMessage("No column found to align items to");
    951950                                return;
    952951                        }
     
    10251024                                                                FrameMouseActions.getY());
    10261025                                        } else {
    1027                                                 FrameGraphics
    1028                                                                 .WarningMessage("Can not create items outside the frame area");
     1026                                                MessageBay
     1027                                                                .warningMessage("Can not create items outside the frame area");
    10291028                                                // ensures correct repainting when items don't move
    10301029                                                DisplayIO.setCursorPosition(DisplayIO.getMouseX(),
     
    10451044                                        int deltaY = firstItem.getY() - dummyItem.getY();
    10461045
    1047                                         for (Item i : Frame.FreeItems) {
     1046                                        for (Item i : FreeItems.getInstance()) {
    10481047                                                i.setPosition(i.getX() - deltaX, i.getY() - deltaY);
    10491048                                        }
     
    10571056                        FrameGraphics.Repaint();
    10581057                } catch (RuntimeException e) {
    1059                         // FrameGraphics.ErrorMessage(e.getMessage());
     1058                        // MessageBay.errorMessage(e.getMessage());
    10601059                        e.printStackTrace();
    10611060                }
     
    12371236                if (item == null) {
    12381237                        if (Frame.itemAttachedToCursor())
    1239                                 toSize.addAll(Frame.FreeItems);
     1238                                toSize.addAll(FreeItems.getInstance());
    12401239                        else {
    1241                                 FrameGraphics
    1242                                                 .DisplayMessage("There are no Items selected on the Frame or on the Cursor");
     1240                                MessageBay
     1241                                                .displayMessage("There are no Items selected on the Frame or on the Cursor");
    12431242                                return;
    12441243                        }
    12451244                } else {
    12461245                        if (item.isFrameName()) {
    1247                                 FrameGraphics.DisplayMessage("Can not resize the frame name");
     1246                                MessageBay.displayMessage("Can not resize the frame name");
    12481247                                return;
    12491248                        }
    12501249                        // check permissions
    12511250                        if (!item.hasPermission(Permission.full)) {
    1252                                 FrameGraphics
    1253                                                 .DisplayMessage("Insufficient permission to change the size of that item");
     1251                                MessageBay
     1252                                                .displayMessage("Insufficient permission to change the size of that item");
    12541253                                return;
    12551254                        }
     
    13621361
    13631362                // if (color == null) {
    1364                 // FrameGraphics.DisplayMessage("FillColor is now transparent");
     1363                // MessageBay.displayMessage("FillColor is now transparent");
    13651364                // }
    13661365
     
    13851384                if (item == null) {
    13861385                        if (Frame.itemAttachedToCursor()) {
    1387                                 color = Frame.FreeItems.get(0).getColor();
     1386                                color = FreeItems.getInstance().get(0).getColor();
    13881387                        } else {
    13891388                                return;
     
    13941393                        // check permissions
    13951394                        if (!item.hasPermission(Permission.full)) {
    1396                                 FrameGraphics
    1397                                                 .DisplayMessage("Insufficient permission to the frame's background color");
     1395                                MessageBay
     1396                                                .displayMessage("Insufficient permission to the frame's background color");
    13981397                                return;
    13991398                        }
     
    14051404                        // if (currentFrame.getBackgroundColor() == null)
    14061405                        // FrameGraphics
    1407                         // .DisplayMessage("Background color is now transparent");
     1406                        // .displayMessage("Background color is now transparent");
    14081407                        FrameGraphics.Repaint();
    14091408                        return;
     
    14111410                        // check permissions
    14121411                        if (!item.hasPermission(Permission.full)) {
    1413                                 FrameGraphics
    1414                                                 .DisplayMessage("Insufficient permission to change that item's color");
     1412                                MessageBay
     1413                                                .displayMessage("Insufficient permission to change that item's color");
    14151414                                return;
    14161415                        }
     
    14391438                // if color is being set to default display a message to indicate that
    14401439                // if (color == null) {
    1441                 // FrameGraphics.DisplayMessage("Color is set to default");
     1440                // MessageBay.displayMessage("Color is set to default");
    14421441                // }
    14431442
    14441443                if (setBackgroundColor) {
    14451444                        if (item == null && Frame.itemAttachedToCursor()) {
    1446                                 for (Item i : Frame.FreeItems)
     1445                                for (Item i : FreeItems.getInstance())
    14471446                                        i.setBackgroundColor(color);
    14481447                        } else {
     
    14521451                } else {
    14531452                        if (item == null && Frame.itemAttachedToCursor()) {
    1454                                 for (Item i : Frame.FreeItems)
     1453                                for (Item i : FreeItems.getInstance())
    14551454                                        i.setColor(color);
    14561455                        } else {
     
    14701469        private static void ToggleAnnotation(Item toToggle) {
    14711470                if (toToggle == null) {
    1472                         FrameGraphics.DisplayMessage("There is no Item selected to toggle");
     1471                        MessageBay.displayMessage("There is no Item selected to toggle");
    14731472                        return;
    14741473                }
     
    14761475                // check permissions
    14771476                if (!toToggle.hasPermission(Permission.full)) {
    1478                         FrameGraphics
    1479                                         .DisplayMessage("Insufficient permission to toggle that item's annotation");
     1477                        MessageBay
     1478                                        .displayMessage("Insufficient permission to toggle that item's annotation");
    14801479                        return;
    14811480                }
     
    14941493        private static void ToggleFontStyle(Item toToggle) {
    14951494                if (toToggle == null) {
    1496                         FrameGraphics.DisplayMessage("There is no Item selected to toggle");
     1495                        MessageBay.displayMessage("There is no Item selected to toggle");
    14971496                        return;
    14981497                }
     
    15001499                // check permissions
    15011500                if (!toToggle.hasPermission(Permission.full)) {
    1502                         FrameGraphics
    1503                                         .DisplayMessage("Insufficient permission to toggle that item's annotation");
     1501                        MessageBay
     1502                                        .displayMessage("Insufficient permission to toggle that item's annotation");
    15041503                        return;
    15051504                }
     
    15221521        private static void ToggleFontFamily(Item toToggle) {
    15231522                if (toToggle == null) {
    1524                         FrameGraphics.DisplayMessage("There is no Item selected to toggle");
     1523                        MessageBay.displayMessage("There is no Item selected to toggle");
    15251524                        return;
    15261525                }
     
    15281527                // check permissions
    15291528                if (!toToggle.hasPermission(Permission.full)) {
    1530                         FrameGraphics
    1531                                         .DisplayMessage("Insufficient permission to toggle that item's annotation");
     1529                        MessageBay.displayMessage("Insufficient permission to toggle that item's annotation");
    15321530                        return;
    15331531                }
     
    15651563                                // permission check
    15661564                                if (!toAdd.hasPermission(Permission.full)) {
    1567                                         FrameGraphics
    1568                                                         .DisplayMessage("Insufficicent permission to add the date to that item");
     1565                                        MessageBay
     1566                                                        .displayMessage("Insufficicent permission to add the date to that item");
    15691567                                        return;
    15701568                                }
     
    16171615                                FrameGraphics.Repaint();
    16181616                        } else {
    1619                                 FrameGraphics
    1620                                                 .DisplayMessage("Only text items can have the date prepended to them");
     1617                                MessageBay
     1618                                                .displayMessage("Only text items can have the date prepended to them");
    16211619                        }
    16221620                        // otherwise, create a new text item
     
    16401638        private static void CreateFrameset(Item item) {
    16411639                if (item == null) {
    1642                         FrameGraphics
    1643                                         .DisplayMessage("There is no selected item to use for the frameset name");
     1640                        MessageBay
     1641                                        .displayMessage("There is no selected item to use for the frameset name");
    16441642                        return;
    16451643                }
    16461644
    16471645                if (!(item instanceof Text)) {
    1648                         FrameGraphics
    1649                                         .DisplayMessage("Framesets can only be created from text items");
     1646                        MessageBay
     1647                                        .displayMessage("Framesets can only be created from text items");
    16501648                        return;
    16511649                }
     
    16531651                // dont create frameset if the item is linked
    16541652                if (item.getLink() != null) {
    1655                         FrameGraphics
    1656                                         .DisplayMessage("A frameset can not be created from a linked item");
     1653                        MessageBay
     1654                                        .displayMessage("A frameset can not be created from a linked item");
    16571655                        return;
    16581656                }
     
    16601658                // check permissions
    16611659                if (!item.hasPermission(Permission.full)) {
    1662                         FrameGraphics
    1663                                         .DisplayMessage("Insufficient permission to create a frameset from this item");
     1660                        MessageBay
     1661                                        .displayMessage("Insufficient permission to create a frameset from this item");
    16641662                        return;
    16651663                }
     
    16781676                        DisplayIO.setCursor(Item.DEFAULT_CURSOR);
    16791677                } catch (Exception e) {
    1680                         FrameGraphics.ErrorMessage(e.getMessage());
     1678                        MessageBay.errorMessage(e.getMessage());
    16811679                }
    16821680        }
     
    16951693                                        + "1");
    16961694                        assert (profile != null);
     1695                        FrameUtils.Parse(currentFrame);
    16971696                        FrameUtils.ParseProfile(profile);
    16981697                } else {
  • trunk/src/org/expeditee/gui/FrameMouseActions.java

    r116 r121  
    165165                                public void actionPerformed(ActionEvent ae) {
    166166                                        // check if we are in free space
    167                                         if (_lastClickedOn == null && Frame.FreeItems.size() == 0) {
     167                                        if (_lastClickedOn == null && FreeItems.getInstance().size() == 0) {
    168168                                                // System.out.println("SuperBack!");
    169169                                                _MouseTimer.setDelay(ZERO_MOUSE_PAUSE);
     
    172172                                                if (FrameUtils.getCurrentItem() == null) {
    173173                                                        // Check if we are toggling arrowhead
    174                                                         if (Frame.FreeItems.size() <= 2) {
    175                                                                 for (Item i : Frame.FreeItems) {
     174                                                        if (FreeItems.getInstance().size() <= 2) {
     175                                                                for (Item i : FreeItems.getInstance()) {
    176176                                                                        if (i instanceof Line) {
    177177                                                                                ((Line) i).toggleArrow();
     
    273273                // the other
    274274                // Long depress actions if that is what is wanted.
    275                 if (_lastClickedOn == null && Frame.FreeItems.size() == 0) {
     275                if (_lastClickedOn == null && FreeItems.getInstance().size() == 0) {
    276276                        // System.out.println(e.getClickCount());
    277277                        if (e.getClickCount() >= 2) {
    278278                                _MouseTimer.start();
    279279                        }
    280                 } else if (_lastClickedOn != null && Frame.FreeItems.size() == 0
     280                } else if (_lastClickedOn != null && FreeItems.getInstance().size() == 0
    281281                                && e.getButton() == MouseEvent.BUTTON3) {
    282282                        _ExtrudeMouseTimer.start();
     
    318318
    319319                        _lastHighlightedItem = Frame.getItemAttachedToCursor();
    320                         for (Item i : Frame.FreeItems) {
     320                        for (Item i : FreeItems.getInstance()) {
    321321                                i.setHighlightColor(Item.DEPRESSED_HIGHLIGHT);
    322322                        }
     
    438438
    439439                        if (Frame.itemAttachedToCursor()) {
    440                                 move(Frame.FreeItems);
    441                         }
    442 
    443                         FrameGraphics
    444                                         .DisplayMessage("Action cancelled, mouse moved more than "
     440                                move(FreeItems.getInstance());
     441                        }
     442
     443                        MessageBay
     444                                        .displayMessage("Action cancelled, mouse moved more than "
    445445                                                        + UserSettings.NoOpThreshold + " pixels.");
    446446                        FrameGraphics.Repaint();
     
    456456                                if (i != null && i instanceof Text) {
    457457                                        lastRanged.replaceSelectedText(((Text) i).getText());
    458                                         Frame.FreeItems.clear();
     458                                        FreeItems.getInstance().clear();
    459459                                } else
    460460                                        lastRanged.cutSelectedText();
     
    504504                                if (!lastRanged.hasPermission(Permission.full)
    505505                                                || lastRanged.isFrameName()) {
    506                                         FrameGraphics
    507                                                         .DisplayMessage("Insufficient permission to cut text");
     506                                        MessageBay
     507                                                        .displayMessage("Insufficient permission to cut text");
    508508                                        lastRanged.clearSelection();
    509509                                        FrameGraphics.Repaint();
     
    524524                                // do not have permission to do so... or it is the frame name
    525525                                if (!lastRanged.hasPermission(Permission.copy)) {
    526                                         FrameGraphics
    527                                                         .DisplayMessage("Insufficient permission to copy text");
     526                                        MessageBay
     527                                                        .displayMessage("Insufficient permission to copy text");
    528528                                        lastRanged.clearSelection();
    529529                                        FrameGraphics.Repaint();
     
    628628                        // check item permissions
    629629                        if (!clicked.hasPermission(Permission.followLinks)) {
    630                                 FrameGraphics
    631                                                 .DisplayMessage("Insufficient permissions to perform action on item");
     630                                MessageBay
     631                                                .displayMessage("Insufficient permissions to perform action on item");
    632632                                return;
    633633                        }
     
    658658                                // check for TDFC permission
    659659                                if (!clicked.hasPermission(Permission.createFrames)) {
    660                                         FrameGraphics
    661                                                         .DisplayMessage("Insufficient permission to TDFC from that item");
     660                                        MessageBay
     661                                                        .displayMessage("Insufficient permission to TDFC from that item");
    662662                                        return;
    663663                                }
     
    675675                                        tdfc(clickedOn);
    676676                                } catch (RuntimeException e) {
    677                                         FrameGraphics.ErrorMessage(e.getMessage());
     677                                        MessageBay.errorMessage(e.getMessage());
    678678                                }
    679679                                return;
     
    698698                        return false;
    699699
    700                 // System.out.println(Frame.FreeItems.size());
     700                // System.out.println(FreeItems.getInstance().size());
    701701                if (isRubberBandingCorner()) {
    702702                        if (clicked.isLineEnd()
     
    707707                }
    708708
    709                 if (Frame.FreeItems.size() > 2)
     709                if (FreeItems.getInstance().size() > 2)
    710710                        return false;
    711711
     
    734734                                                && clicked.getParent() != null
    735735                                                && clicked.getParent().getNameItem() != clicked) {
    736                                         FrameGraphics.DisplayMessage("Insufficient permission");
     736                                        MessageBay.displayMessage("Insufficient permission");
    737737                                        return;
    738738                                }
    739739
    740                                 Item merger = Frame.FreeItems.get(0);
     740                                Item merger = FreeItems.getInstance().get(0);
    741741                                assert (merger != null);
    742                                 Collection<Item> left = merge(Frame.FreeItems, clicked);
     742                                Collection<Item> left = merge(FreeItems.getInstance(), clicked);
    743743                                anchor(left);
    744                                 Frame.FreeItems.clear();
     744                                FreeItems.getInstance().clear();
    745745                                FrameGraphics.Repaint();
    746746                                updateCursor();
     
    750750                                // if a line is being rubber-banded, check for auto
    751751                                // straightening
    752                                 anchor(Frame.FreeItems);
    753                                 Frame.FreeItems.clear();
     752                                anchor(FreeItems.getInstance());
     753                                FreeItems.getInstance().clear();
    754754                                updateCursor();
    755755                                _offX = _offY = 0;
     
    760760                        // check permissions
    761761                        if (!clicked.hasPermission(Permission.full)) {
    762                                 FrameGraphics
    763                                                 .DisplayMessage("Insufficient permission to pick up item");
     762                                MessageBay
     763                                                .displayMessage("Insufficient permission to pick up item");
    764764                                return;
    765765                        }
     
    885885                        return;
    886886                }
    887                 SessionStats.MovedItems(Frame.FreeItems);
     887                SessionStats.MovedItems(FreeItems.getInstance());
    888888        }
    889889
    890890        private static Item getFirstFreeLineEnd() {
    891                 for (Item i : Frame.FreeItems)
     891                for (Item i : FreeItems.getInstance())
    892892                        if (i.isLineEnd())
    893893                                return i;
     
    896896
    897897        private static boolean isRubberBandingCorner() {
    898                 return getShapeCorner(Frame.FreeItems) != null;
     898                return getShapeCorner(FreeItems.getInstance()) != null;
    899899        }
    900900
     
    949949                                if (!clicked.hasPermission(Permission.full)
    950950                                                && clicked.getParent().getNameItem() != clicked) {
    951                                         FrameGraphics
    952                                                         .DisplayMessage("Insufficient permission to merge items");
     951                                        MessageBay
     952                                                        .displayMessage("Insufficient permission to merge items");
    953953                                        return;
    954954                                }
     
    988988                                                copies = copy(toCopy);
    989989                                                // Now do the merging
    990                                                 Collection<Item> remain = merge(Frame.FreeItems,
     990                                                Collection<Item> remain = merge(FreeItems.getInstance(),
    991991                                                                clicked);
    992992                                                // anchor the points
    993993                                                anchor(remain);
    994                                                 Frame.FreeItems.clear();
     994                                                FreeItems.getInstance().clear();
    995995                                                pickup(copies);
    996996                                                // line onto something
    997                                         } else if (Frame.FreeItems.size() == 2
     997                                        } else if (FreeItems.getInstance().size() == 2
    998998                                        /* && clicked instanceof XRayable */) {
    999                                                 copies = ItemUtils.UnreelLine(Frame.FreeItems,
     999                                                copies = ItemUtils.UnreelLine(FreeItems.getInstance(),
    10001000                                                                _controlDown);
    1001                                                 Collection<Item> leftOver = merge(Frame.FreeItems,
     1001                                                Collection<Item> leftOver = merge(FreeItems.getInstance(),
    10021002                                                                clicked);
    10031003                                                anchor(leftOver);
    10041004                                                if (copies == null)
    1005                                                         copies = copy(Frame.FreeItems);
    1006                                                 Frame.FreeItems.clear();
     1005                                                        copies = copy(FreeItems.getInstance());
     1006                                                FreeItems.getInstance().clear();
    10071007                                                for (Item i : copies)
    10081008                                                        i.setOffset(0, 0);
     
    10111011                                                pickup(copies);
    10121012                                                // point onto point
    1013                                         } else if (Frame.FreeItems.size() == 1) {
    1014                                                 copies = copy(Frame.FreeItems);
     1013                                        } else if (FreeItems.getInstance().size() == 1) {
     1014                                                copies = copy(FreeItems.getInstance());
    10151015                                                Collection<Item> remain = merge(copies, clicked);
    10161016
     
    10191019                                        } else {
    10201020                                                stampItemsOnCursor();
    1021                                                 copies = Frame.FreeItems;
     1021                                                copies = FreeItems.getInstance();
    10221022                                        }
    10231023                                } else {
    10241024                                        copies = ItemUtils
    1025                                                         .UnreelLine(Frame.FreeItems, _controlDown);
     1025                                                        .UnreelLine(FreeItems.getInstance(), _controlDown);
    10261026                                        if (copies == null)
    1027                                                 copies = copy(Frame.FreeItems);
     1027                                                copies = copy(FreeItems.getInstance());
    10281028                                        for (Item i : copies) {
    10291029                                                i.setOffset(0, 0);
    10301030                                        }
    1031                                         anchor(Frame.FreeItems);
    1032                                         Frame.FreeItems.clear();
     1031                                        anchor(FreeItems.getInstance());
     1032                                        FreeItems.getInstance().clear();
    10331033                                        pickup(copies);
    10341034                                }
     
    10391039                                        Item d = getFirstFreeLineEnd();
    10401040                                        // anchor the points
    1041                                         anchor(Frame.FreeItems);
    1042                                         Frame.FreeItems.clear();
     1041                                        anchor(FreeItems.getInstance());
     1042                                        FreeItems.getInstance().clear();
    10431043                                        updateCursor();
    10441044                                        // pick up a copy of all enclosed items
     
    10831083                                        if (rubberBanding()) {
    10841084                                                if (clicked != null) {
    1085                                                         Collection<Item> leftOver = merge(Frame.FreeItems,
     1085                                                        Collection<Item> leftOver = merge(FreeItems.getInstance(),
    10861086                                                                        clicked);
    10871087                                                        anchor(leftOver);
     
    10891089                                                // This is executed when the user is putting down a line
    10901090                                                // endpoint and unreeling. ie. Normal unreeling
    1091                                                 copies = ItemUtils.UnreelLine(Frame.FreeItems,
     1091                                                copies = ItemUtils.UnreelLine(FreeItems.getInstance(),
    10921092                                                                _controlDown);
    10931093
    10941094                                                if (copies == null)
    1095                                                         copies = copy(Frame.FreeItems);
    1096                                                 anchor(Frame.FreeItems);
     1095                                                        copies = copy(FreeItems.getInstance());
     1096                                                anchor(FreeItems.getInstance());
    10971097                                                for (Item i : copies)
    10981098                                                        i.setOffset(0, 0);
     
    11041104                                                // remove any lines that dont have both endpoints
    11051105                                                // floating
    1106                                                 for (Item i : Frame.FreeItems) {
     1106                                                for (Item i : FreeItems.getInstance()) {
    11071107                                                        if (i.isFloating())
    11081108                                                                originals.add(i);
     
    11121112                                                for (Item i : copies)
    11131113                                                        i.setOffset(0, 0);
    1114                                                 anchor(Frame.FreeItems);
     1114                                                anchor(FreeItems.getInstance());
    11151115                                                // Move isnt working right for extruding!!
    11161116                                                // move(copies);
     
    11181118                                        } else {
    11191119                                                stampItemsOnCursor();
    1120                                                 copies = Frame.FreeItems;
     1120                                                copies = FreeItems.getInstance();
    11211121                                        }
    11221122                                }
     
    11271127                                // check permissions
    11281128                                if (!clicked.hasPermission(Permission.copy)) {
    1129                                         FrameGraphics
    1130                                                         .DisplayMessage("Insufficient permission to copy item");
     1129                                        MessageBay
     1130                                                        .displayMessage("Insufficient permission to copy item");
    11311131                                        return;
    11321132                                }
     
    11641164                                        Collection<Item> enclosed = getFullyEnclosedItems(clickedIn);
    11651165                                        if (enclosed.size() == 0) {
    1166                                                 FrameGraphics
    1167                                                                 .DisplayMessage("Insufficient permission to copy items");
     1166                                                MessageBay
     1167                                                                .displayMessage("Insufficient permission to copy items");
    11681168                                        } else {
    11691169                                                copies = copy(enclosed);
     
    12021202                                                merge(toMerge, on);
    12031203                                                // anchor(left);
    1204                                                 // Frame.FreeItems.clear();
     1204                                                // FreeItems.getInstance().clear();
    12051205                                                FrameGraphics.Repaint();
    12061206                                                updateCursor();
     
    12511251         */
    12521252        private static void stampItemsOnCursor() {
    1253                 List<Item> copies = copy(Frame.FreeItems);
     1253                List<Item> copies = copy(FreeItems.getInstance());
    12541254                // MIKE: what does the below 2 lines do?
    12551255                for (Item i : copies)
     
    12571257                // The below code has a little problem withflicker when stamp
    12581258                // and dragging
    1259                 move(Frame.FreeItems);
     1259                move(FreeItems.getInstance());
    12601260                for (Item i : copies) {
    12611261                        i.setHighlightMode(HighlightMode.None);
     
    13791379                                        e.getY());
    13801380
    1381                         if (Frame.FreeItems.size() == 0) {
     1381                        if (FreeItems.getInstance().size() == 0) {
    13821382                                // if the user can spot-weld, show the virtual spot
    13831383                                if (on instanceof Line) {
     
    14541454                        // Wait until the last Robot mouse move event arrives before
    14551455                        // processing other events
    1456                         if (/* Frame.FreeItems.size() == 0 || */
     1456                        if (/* FreeItems.getInstance().size() == 0 || */
    14571457                        (LastRobotX == e.getX() && LastRobotY == e.getY())) {
    14581458                                LastRobotX = null;
     
    14601460                                _RobotTimer.stop();
    14611461                        } else {
    1462                                 // System.out.println("Ignored: " + Frame.FreeItems.size());
     1462                                // System.out.println("Ignored: " + FreeItems.getInstance().size());
    14631463                                return;
    14641464                        }
     
    14771477
    14781478                // If shift is down then the movement is constrained
    1479                 if (_controlDown && Frame.FreeItems.size() > 0) {
     1479                if (_controlDown && FreeItems.getInstance().size() > 0) {
    14801480                        // Check if we are rubber banding a line
    14811481                        if (shiftStateChanged && rubberBanding()) {
    14821482                                // Get the line end that is being rubber banded
    1483                                 Item thisEnd = Frame.FreeItems.get(0).isLineEnd() ? Frame.FreeItems
     1483                                Item thisEnd = FreeItems.getInstance().get(0).isLineEnd() ? FreeItems.getInstance()
    14841484                                                .get(0)
    1485                                                 : Frame.FreeItems.get(1);
    1486                                 Line line = (Line) (Frame.FreeItems.get(0).isLineEnd() ? Frame.FreeItems
     1485                                                : FreeItems.getInstance().get(1);
     1486                                Line line = (Line) (FreeItems.getInstance().get(0).isLineEnd() ? FreeItems.getInstance()
    14871487                                                .get(1)
    1488                                                 : Frame.FreeItems.get(0));
     1488                                                : FreeItems.getInstance().get(0));
    14891489                                Item otherEnd = line.getOppositeEnd(thisEnd);
    14901490                                int deltaX = Math.abs(e.getX() - otherEnd.getX());
     
    15331533                        }// If its a lineend attached to two lines lengthen the shorter
    15341534                        // so it is the same length as the longer line
    1535                         else if (Frame.FreeItems.size() == 3) {
     1535                        else if (FreeItems.getInstance().size() == 3) {
    15361536                                // check if we are rubber banding the corner of a shape
    1537                                 Item thisEnd = getShapeCorner(Frame.FreeItems);
     1537                                Item thisEnd = getShapeCorner(FreeItems.getInstance());
    15381538                                if (thisEnd != null) {
    15391539                                        Line line1 = thisEnd.getLines().get(0);
     
    16141614                } else if (shiftStateChanged && !_controlDown && rubberBanding()) {
    16151615                        // Get the line end that is being rubber banded
    1616                         Item thisEnd = Frame.FreeItems.get(0).isLineEnd() ? Frame.FreeItems
    1617                                         .get(0) : Frame.FreeItems.get(1);
     1616                        Item thisEnd = FreeItems.getInstance().get(0).isLineEnd() ? FreeItems.getInstance()
     1617                                        .get(0) : FreeItems.getInstance().get(1);
    16181618                        thisEnd.removeAllConstraints();
    16191619                }
     
    16271627
    16281628                if (Frame.itemAttachedToCursor()) {
    1629                         move(Frame.FreeItems);
    1630                         // System.out.println(Frame.FreeItems.size());
     1629                        move(FreeItems.getInstance());
     1630                        // System.out.println(FreeItems.getInstance().size());
    16311631                }
    16321632
     
    16521652                                _context = CONTEXT_AT_TEXT;
    16531653                        }
    1654                         if (Frame.FreeItems.size() > 0)
     1654                        if (FreeItems.getInstance().size() > 0)
    16551655                                _alpha = 60;
    16561656                        else
     
    16621662
    16631663                // if the user is pointing at an item, highlight it
    1664                 if (on != null && !Frame.FreeItems.contains(on)) {
     1664                if (on != null && !FreeItems.getInstance().contains(on)) {
    16651665                        // if the user can spot-weld, show the virtual spot
    1666                         if (Frame.FreeItems.size() == 2 && on instanceof Line) {
     1666                        if (FreeItems.getInstance().size() == 2 && on instanceof Line) {
    16671667                                Line line = (Line) on;
    1668                                 Item freeItem0 = Frame.FreeItems.get(0);
    1669                                 Item freeItem1 = Frame.FreeItems.get(1);
     1668                                Item freeItem0 = FreeItems.getInstance().get(0);
     1669                                Item freeItem1 = FreeItems.getInstance().get(1);
    16701670                                Item lineEnd = freeItem0.isLineEnd() ? freeItem0 : (freeItem1
    16711671                                                .isLineEnd() ? freeItem1 : null);
     
    17021702                                // check that the enclosure is not part of a point being
    17031703                                                // dragged in space
    1704                                                 !ContainsOneOf(enclosure, Frame.FreeItems)) {
     1704                                                !ContainsOneOf(enclosure, FreeItems.getInstance())) {
    17051705                                        on = firstLineEnd.getLines().get(0);
    17061706                                        // System.out.println(on == null ? "Null" :
     
    17601760         */
    17611761        private static boolean rubberBanding() {
    1762                 if (Frame.FreeItems.size() != 2) {
     1762                if (FreeItems.getInstance().size() != 2) {
    17631763                        return false;
    17641764                }
     
    17661766                // if rubber-banding, there will be 1 lineend and the rest will be lines
    17671767                boolean foundLineEnd = false;
    1768                 for (Item i : Frame.FreeItems) {
     1768                for (Item i : FreeItems.getInstance()) {
    17691769                        if (i.isLineEnd()) {
    17701770                                if (foundLineEnd) {
     
    18031803        public static void resetOffset() {
    18041804                if (Frame.itemAttachedToCursor()) {
    1805                         _offX = DisplayIO.getMouseX() - Frame.FreeItems.get(0).getX()
    1806                                         + Frame.FreeItems.get(0).getOffset().x;
    1807                         _offY = getY() - Frame.FreeItems.get(0).getY()
    1808                                         + Frame.FreeItems.get(0).getOffset().y;
     1805                        _offX = DisplayIO.getMouseX() - FreeItems.getInstance().get(0).getX()
     1806                                        + FreeItems.getInstance().get(0).getOffset().x;
     1807                        _offY = getY() - FreeItems.getInstance().get(0).getY()
     1808                                        + FreeItems.getInstance().get(0).getOffset().y;
    18091809                }
    18101810        }
     
    18351835                        FrameUtils.DisplayFrame(toLoad);
    18361836                } else {
    1837                         FrameGraphics.ErrorMessage(toLoad + " is not a valid frame name.");
     1837                        MessageBay.errorMessage(toLoad + " is not a valid frame name.");
    18381838                }
    18391839        }
     
    18441844                // repaint things if necessary
    18451845                if (Frame.itemAttachedToCursor())
    1846                         move(Frame.FreeItems);
     1846                        move(FreeItems.getInstance());
    18471847        }
    18481848
     
    19211921
    19221922                if (attribs == null)
    1923                         FrameGraphics
    1924                                         .DisplayMessage("All attributes of that item are default values.");
     1923                        MessageBay
     1924                                        .displayMessage("All attributes of that item are default values.");
    19251925                else {
    19261926                        // Give the attribute text item the color of the item for which
     
    19461946                if (Frame.itemAttachedToCursor()) {
    19471947                        // if this is an item-swap
    1948                         if (Frame.FreeItems.size() == 1
    1949                                         && Frame.FreeItems.get(0) instanceof Text
     1948                        if (FreeItems.getInstance().size() == 1
     1949                                        && FreeItems.getInstance().get(0) instanceof Text
    19501950                                        && toDelete != null && toDelete instanceof Text) {
    19511951
    19521952                                // check permissions
    19531953                                if (!toDelete.hasPermission(Permission.full)) {
    1954                                         FrameGraphics
    1955                                                         .DisplayMessage("Insufficient permission to swap Item text");
     1954                                        MessageBay
     1955                                                        .displayMessage("Insufficient permission to swap Item text");
    19561956                                        return;
    19571957                                }
    19581958                                Text anchored = (Text) toDelete;
    1959                                 Text free = (Text) Frame.FreeItems.get(0);
     1959                                Text free = (Text) FreeItems.getInstance().get(0);
    19601960                                SessionStats.DeletedItem(free);
    19611961                                // List<String> temp = anchored.getText();
     
    19631963
    19641964                                // free.setTextList(temp);
    1965                                 Frame.FreeItems.clear();
     1965                                FreeItems.getInstance().clear();
    19661966
    19671967                                anchored.getParent().setChanged(true);
     
    19721972                                _offY = getY() - anchored.getY() + anchored.getOffset().y;
    19731973                        } else {
    1974                                 deleteItems(Frame.FreeItems);
     1974                                deleteItems(FreeItems.getInstance());
    19751975                        }
    19761976                        // reset the mouse cursor
     
    20322032                        // check permissions
    20332033                        if (!toDelete.hasPermission(Permission.full)) {
    2034                                 FrameGraphics
    2035                                                 .DisplayMessage("Insufficient permission to delete item");
     2034                                MessageBay
     2035                                                .displayMessage("Insufficient permission to delete item");
    20362036                                return;
    20372037                        }
     
    23552355
    23562356                if (!toGrab.hasPermission(Permission.full)) {
    2357                         FrameGraphics
    2358                                         .DisplayMessage("Insufficient permission pickup the item");
     2357                        MessageBay
     2358                                        .displayMessage("Insufficient permission pickup the item");
    23592359                        return;
    23602360                }
     
    24022402                                        i.setParent(null);
    24032403                        }
    2404                         Frame.FreeItems.add(i);
     2404                        FreeItems.getInstance().add(i);
    24052405                        i.setFloating(true);
    24062406                        if (i.hasVector()) {
     
    24092409                                // Collection<Item> copies = ItemUtils.CopyItems(overlayFrame
    24102410                                // .getNonAnnotationItems(), i.getVector());
    2411                                 // Frame.FreeItems.addAll(copies);
     2411                                // FreeItems.getInstance().addAll(copies);
    24122412                                // TODO add the copies to the free items so they are visible
    24132413                                // when the cursor is moving around but are not anchored
     
    24292429                                        // make the offset item the first item in the list (so
    24302430                                        // move method knows which item to use)
    2431                                         Frame.FreeItems.set(Frame.FreeItems.indexOf(i),
    2432                                                         Frame.FreeItems.get(0));
    2433                                         Frame.FreeItems.set(0, i);
     2431                                        FreeItems.getInstance().set(FreeItems.getInstance().indexOf(i),
     2432                                                        FreeItems.getInstance().get(0));
     2433                                        FreeItems.getInstance().set(0, i);
    24342434                                        break;
    24352435                                }
    24362436                        }
    24372437
    2438                         move(Frame.FreeItems);
     2438                        move(FreeItems.getInstance());
    24392439                        ItemUtils.EnclosedCheck(toGrab);
    24402440                        // otherwise, just use the first item
     
    24482448                        move(toGrab);
    24492449                } else {
    2450                         FrameGraphics
    2451                                         .DisplayMessage("Insufficient permission pickup the items");
     2450                        MessageBay
     2451                                        .displayMessage("Insufficient permission pickup the items");
    24522452                }
    24532453                if (bReparse)
     
    25362536                int clicks = arg0.getClickCount();
    25372537
    2538                 if (Frame.FreeItems.size() == 2) {
    2539                         if ((Frame.FreeItems.get(0).isLineEnd() && Frame.FreeItems.get(1) instanceof Line)
    2540                                         || (Frame.FreeItems.get(1).isLineEnd() && Frame.FreeItems
     2538                if (FreeItems.getInstance().size() == 2) {
     2539                        if ((FreeItems.getInstance().get(0).isLineEnd() && FreeItems.getInstance().get(1) instanceof Line)
     2540                                        || (FreeItems.getInstance().get(1).isLineEnd() && FreeItems.getInstance()
    25412541                                                        .get(0) instanceof Line)) {
    25422542
    25432543                                Line line;
    2544                                 if (Frame.FreeItems.get(0) instanceof Line)
    2545                                         line = (Line) Frame.FreeItems.get(0);
     2544                                if (FreeItems.getInstance().get(0) instanceof Line)
     2545                                        line = (Line) FreeItems.getInstance().get(0);
    25462546                                else
    2547                                         line = (Line) Frame.FreeItems.get(1);
     2547                                        line = (Line) FreeItems.getInstance().get(1);
    25482548
    25492549                                // User must do multiple clicks to toggle the line
     
    25902590                                // check permissions
    25912591                                if (!item.hasPermission(Permission.full)) {
    2592                                         FrameGraphics
    2593                                                         .DisplayMessage("Insufficient permission to edit the Line");
     2592                                        MessageBay
     2593                                                        .displayMessage("Insufficient permission to edit the Line");
    25942594                                        return;
    25952595                                }
  • trunk/src/org/expeditee/gui/FrameUtils.java

    r116 r121  
    331331                if (Frame.itemAttachedToCursor()) {
    332332                        List<Item> toAdd = new ArrayList<Item>();
    333                         List<Item> toCheck = new ArrayList<Item>(Frame.FreeItems);
     333                        List<Item> toCheck = new ArrayList<Item>(FreeItems.getInstance());
    334334
    335335                        while (toCheck.size() > 0) {
     
    339339                                // // Only move completely enclosed items
    340340                                // if (!toCheck.containsAll(connected)) {
    341                                 // connected.retainAll(Frame.FreeItems);
    342                                 // Frame.FreeItems.removeAll(connected);
     341                                // connected.retainAll(FreeItems.getInstance());
     342                                // FreeItems.getInstance().removeAll(connected);
    343343                                // toCheck.removeAll(connected);
    344344                                // FrameMouseActions.anchor(connected);
     
    349349                                // Anchor overlay items where they belong
    350350                                if (i.getParent() != null && i.getParent() != current) {
    351                                         Frame.FreeItems.removeAll(connected);
     351                                        FreeItems.getInstance().removeAll(connected);
    352352                                        toCheck.removeAll(connected);
    353353                                        FrameMouseActions.anchor(connected);
     
    357357                                        toCheck.removeAll(connected);
    358358                                        // Dont add the items that are free
    359                                         connected.removeAll(Frame.FreeItems);
     359                                        connected.removeAll(FreeItems.getInstance());
    360360                                        toAdd.addAll(connected);
    361361                                }
     
    376376                // if the saving happened properly, we can continue
    377377                if (!LeavingFrame(current)) {
    378                         FrameGraphics.DisplayMessage("Navigation cancelled");
     378                        MessageBay.displayMessage("Navigation cancelled");
    379379                        return;
    380380                }
     
    437437
    438438                if (f == null) {
    439                         FrameGraphics.ErrorMessage("Frame '" + frameName
     439                        MessageBay.errorMessage("Frame '" + frameName
    440440                                        + "' could not be found.");
    441441                }
     
    461461                        if (imagePath.length() == 0) {
    462462                                return false;
    463                                 // FrameGraphics.ErrorMessage("Expected image path after @i:");
     463                                // MessageBay.errorMessage("Expected image path after @i:");
    464464                        } else {
    465                                 FrameGraphics.ErrorMessage("Image " + imagePath
     465                                MessageBay.errorMessage("Image " + imagePath
    466466                                                + " could not be loaded");
    467467                        }
     
    506506                } catch (InteractiveWidgetNotAvailableException e) {
    507507                        e.printStackTrace();
    508                         FrameGraphics.ErrorMessage("Cannot create iWidget: "
    509                                         + e.getMessage());
     508                        MessageBay.errorMessage("Cannot create iWidget: " + e.getMessage());
    510509                } catch (InteractiveWidgetInitialisationFailedException e) {
    511510                        e.printStackTrace();
    512                         FrameGraphics.ErrorMessage("Cannot create iWidget: "
    513                                         + e.getMessage());
     511                        MessageBay.errorMessage("Cannot create iWidget: " + e.getMessage());
    514512                } catch (IllegalArgumentException e) {
    515513                        e.printStackTrace();
    516                         FrameGraphics.ErrorMessage("Cannot create iWidget: "
    517                                         + e.getMessage());
     514                        MessageBay.errorMessage("Cannot create iWidget: " + e.getMessage());
    518515                }
    519516
     
    557554                                // warn the user
    558555                                else {
    559                                         // FrameGraphics.WarningMessage("Home frame: " + first
     556                                        // MessageBay.warningMessage("Home frame: " + first
    560557                                        // + " is not a valid frame.");
    561558                                        UserSettings.FirstFrame = profile.getName();
     
    627624                                UserSettings.FrameDirs.addAll(getDirs(item));
    628625                        } else {
    629                                 FrameGraphics.WarningMessage(attributeFullCase
     626                                MessageBay.warningMessage(attributeFullCase
    630627                                                + " is not a profile frame tag");
    631628                        }
     
    636633                if (UserSettings.FirstFrame == null)
    637634                        UserSettings.FirstFrame = profile.getName();
    638                 else {
    639                         Frame firstFrame = FrameIO.LoadFrame(UserSettings.FirstFrame);
    640                         if (firstFrame == null) {
    641                                 FrameGraphics.WarningMessage("Home frame not found: "
    642                                                 + UserSettings.FirstFrame);
    643                                 UserSettings.FirstFrame = profile.getName();
    644                                 DisplayIO.setCurrentFrame(profile);
    645                         } else {
    646                                 DisplayIO.setCurrentFrame(firstFrame);
    647                         }
    648                 }
     635                // else {
     636                Frame firstFrame = FrameIO.LoadFrame(UserSettings.FirstFrame);
     637                if (firstFrame == null) {
     638                        MessageBay.warningMessage("Home frame not found: "
     639                                        + UserSettings.FirstFrame);
     640                        UserSettings.FirstFrame = profile.getName();
     641                        DisplayIO.setCurrentFrame(profile);
     642                } else {
     643                        DisplayIO.setCurrentFrame(firstFrame);
     644                }
     645                // }
    649646        }
    650647
     
    727724                                        return name + File.separator;
    728725                        } else {
    729                                 FrameGraphics.ErrorMessage("Directory not found: " + name);
     726                                MessageBay.errorMessage("Directory not found: " + name);
    730727                        }
    731728                } else {
    732                         FrameGraphics.WarningMessage("Missing value for profile attribute"
     729                        MessageBay.warningMessage("Missing value for profile attribute"
    733730                                        + name);
    734731                }
     
    866863                                                }
    867864                                        }// check for new VECTOR items
    868                                         else if (ItemUtils.startsWithTag(i, ItemUtils.TAG_VECTOR)
     865                                        else if (!FrameGraphics.isXRayMode()
     866                                                        && ItemUtils.startsWithTag(i, ItemUtils.TAG_VECTOR)
    869867                                                        && i.getLink() != null) {
    870868                                                // TODO It is possible to get into an infinate loop if a
     
    879877                                                vectorPermission = Permission.min(vectorPermission,
    880878                                                                permission);
    881                                                 //Highest permissable permission for vectors is copy
    882                                                 vectorPermission = Permission.min(vectorPermission, Permission.copy);
     879                                                // Highest permissable permission for vectors is copy
     880                                                vectorPermission = Permission.min(vectorPermission,
     881                                                                Permission.copy);
    883882                                                if (vector != null) {
    884883                                                        String scaleString = AttributeUtils
     
    889888                                                        } catch (Exception e) {
    890889                                                        }
    891                                                         Vector newVector = new Vector(vector, vectorPermission, i
    892                                                                         .getPosition(), scale, i.getColor(), i
    893                                                                         .getBackgroundColor());
     890                                                        Vector newVector = new Vector(vector,
     891                                                                        vectorPermission, i.getPosition(), scale, i
     892                                                                                        .getColor(), i.getBackgroundColor());
    894893                                                        i.setOverlay(newVector);
    895894                                                        vectors.add(newVector);
     
    903902                                                        // This frame contains an active overlay which
    904903                                                        // points to itself
    905                                                         FrameGraphics.ErrorMessage(toParse.getName()
     904                                                        MessageBay.errorMessage(toParse.getName()
    906905                                                                        + " contains an @o which links to itself");
    907906                                                        continue;
     
    921920                                                        // This frame contains an active overlay which
    922921                                                        // points to itself
    923                                                         FrameGraphics.ErrorMessage(toParse.getName()
     922                                                        MessageBay.errorMessage(toParse.getName()
    924923                                                                        + " contains an @ao which links to itself");
    925924                                                        continue;
     
    10541053                                Logger.Log(e);
    10551054                                e.printStackTrace();
    1056                                 FrameGraphics.WarningMessage("Exception occured when loading "
     1055                                MessageBay.warningMessage("Exception occured when loading "
    10571056                                                + i.getClass().getSimpleName() + "(ID: " + i.getID()
    10581057                                                + ") " + e.getMessage());
     
    11001099                if (y > FrameGraphics.getMaxFrameSize().getHeight()) {
    11011100                        // check the individual message items
    1102                         for (Item message : FrameGraphics.Messages) {
     1101                        for (Item message : MessageBay.getMessages()) {
    11031102                                if (message != null) {
    11041103                                        if (message.contains(x, y)) {
     
    11141113
    11151114                        // check the link to the message frame
    1116                         if (FrameGraphics.MessageLink != null) {
    1117                                 if (FrameGraphics.MessageLink.contains(x, y)) {
    1118                                         FrameGraphics.MessageLink.setPermission(Permission.copy);
    1119                                         possibles.add(FrameGraphics.MessageLink);
     1115                        if (MessageBay.getMessageLink() != null) {
     1116                                if (MessageBay.getMessageLink().contains(x, y)) {
     1117                                        MessageBay.getMessageLink().setPermission(Permission.copy);
     1118                                        possibles.add(MessageBay.getMessageLink());
    11201119                                }
    11211120                        }
     
    11281127                                                                                 * LastEdited.isVisible() &&
    11291128                                                                                 */LastEdited.contains(x, y)
    1130                                         && !Frame.FreeItems.contains(LastEdited)
     1129                                        && !FreeItems.getInstance().contains(LastEdited)
    11311130                                        && LastEdited.getParent() == DisplayIO.getCurrentFrame()
    11321131                                        && LastEdited.getParent().getItems().contains(LastEdited)) {
     
    11411140                        for (Item i : checkList) {
    11421141                                // do not check annotation items in audience mode
    1143                                 if (i.isVisible() && !(FrameGraphics.isAudienceMode() && i.isAnnotation())) {
    1144                                         if (i.contains(x, y) && !Frame.FreeItems.contains(i)) {
     1142                                if (i.isVisible()
     1143                                                && !(FrameGraphics.isAudienceMode() && i.isAnnotation())) {
     1144                                        if (i.contains(x, y)
     1145                                                        && !FreeItems.getInstance().contains(i)) {
    11451146                                                possibles.add(i);
    11461147                                        }
     
    12321233
    12331234                // Remove all items that are connected to freeItems
    1234                 List<Item> freeItems = new ArrayList<Item>(Frame.FreeItems);
     1235                List<Item> freeItems = new ArrayList<Item>(FreeItems.getInstance());
    12351236                while (freeItems.size() > 0) {
    12361237                        Item item = freeItems.get(0);
  • trunk/src/org/expeditee/io/AbstractHTMLWriter.java

    r80 r121  
    55
    66import org.expeditee.gui.Frame;
    7 import org.expeditee.gui.FrameGraphics;
     7import org.expeditee.gui.MessageBay;
    88import org.expeditee.items.Item;
    99
     
    3939                                        dir.mkdirs();
    4040                                } catch (Exception e) {
    41                                         FrameGraphics.ErrorMessage("Could not create folder: "
     41                                        MessageBay.errorMessage("Could not create folder: "
    4242                                                        + dir.getName());
    4343                                        _filesFolderName = null;
  • trunk/src/org/expeditee/io/DefaultTreeWriter.java

    r80 r121  
    66
    77import org.expeditee.gui.Frame;
    8 import org.expeditee.gui.FrameGraphics;
    98import org.expeditee.gui.FrameIO;
     9import org.expeditee.gui.MessageBay;
    1010import org.expeditee.items.Item;
    1111import org.expeditee.items.Text;
     
    9191                                this.resumeFrame(next);
    9292                        } else {
    93                                 FrameGraphics.OverwriteMessage("Writing: " + next.getName());
     93                                MessageBay.overwriteMessage("Writing: " + next.getName());
    9494                                _frameCount++;
    9595                                writeStartFrame(next);
  • trunk/src/org/expeditee/io/KMSReader.java

    r108 r121  
    1212
    1313import org.expeditee.gui.Frame;
    14 import org.expeditee.gui.FrameGraphics;
     14import org.expeditee.gui.MessageBay;
    1515import org.expeditee.items.Constraint;
    1616import org.expeditee.items.Dot;
     
    361361                if (_FrameTags.get(tag) == null) {
    362362                        if (!tag.equals("t") && !tag.equals("v"))
    363                                 FrameGraphics.ErrorMessage("Tag '" + tag + "' in '" + line
     363                                MessageBay.errorMessage("Tag '" + tag + "' in '" + line
    364364                                                + "' is not supported.");
    365365                        return;
     
    379379        private Frame readFrameClass() throws IOException {
    380380                if (_data.size() == 0) {
    381                         FrameGraphics
    382                                         .ErrorMessage("IO Error: File contains no valid KMS lines.");
     381                        MessageBay
     382                                        .errorMessage("IO Error: File contains no valid KMS lines.");
    383383                        return null;
    384384                }
  • trunk/src/org/expeditee/io/PNGWriter.java

    r80 r121  
    66import org.expeditee.agents.DefaultAgent;
    77import org.expeditee.gui.Frame;
    8 import org.expeditee.gui.FrameGraphics;
    98import org.expeditee.gui.FrameIO;
     9import org.expeditee.gui.MessageBay;
    1010import org.expeditee.items.Item;
    1111
     
    2626                        _writer.write(ItemWriter.NEW_LINE);
    2727                } else {
    28                         FrameGraphics.ErrorMessage("Could not create image for "
     28                        MessageBay.errorMessage("Could not create image for "
    2929                                        + starting.getName());
    3030                }
  • trunk/src/org/expeditee/items/Circle.java

    r115 r121  
    77import java.awt.Graphics2D;
    88import java.awt.Polygon;
     9import java.awt.Rectangle;
    910import java.awt.geom.Point2D;
    1011import java.util.Collection;
     
    3637                updatePolygon();
    3738        }
    38        
     39
    3940        public Collection<Item> getItemsToSave() {
    40                 Collection<Item> toSave =super.getItemsToSave();
     41                Collection<Item> toSave = super.getItemsToSave();
    4142                toSave.add(_center);
    4243                return toSave;
     
    196197                return super.setHighlightColor(c);
    197198        }
    198        
     199
    199200        @Override
    200201        public void setFillColor(Color c) {
     
    254255        @Override
    255256        public float getSize() {
    256                 return (float)getRadius();
     257                return (float) getRadius();
    257258        }
    258259
    259260        /**
    260          *Resizes the circle from the center.
     261         * Resizes the circle from the center.
    261262         */
    262263        @Override
     
    283284        public void translate(Point2D origin, double ratio) {
    284285                updatePolygon();
    285                 //_center.translate(origin, ratio);
    286                 //super.translate(origin, ratio);
     286                // _center.translate(origin, ratio);
     287                // super.translate(origin, ratio);
     288        }
     289
     290        @Override
     291        public Rectangle[] getDrawingArea() {
     292
     293                float thickness = getThickness();
     294                double radius = getRadius();
     295
     296                int size = (int) ((2 * radius) + 3.0 + thickness);
     297
     298                return new Rectangle[] { new Rectangle((int) (_center.getX() - radius
     299                                - 0.5 - (thickness / 2.0)), (int) (_center.getY() - radius
     300                                - 0.5 - (thickness / 2.0)), size, size) };
     301        }
     302
     303        // @Override
     304        // public void setPosition(float x, float y){
     305        // float deltaX = x - _source._x;
     306        // float deltaY = y = _source._y;
     307        // _center.setPosition(deltaX, deltaY);
     308        // super.setPosition(x,y);
     309        // }
     310        public Item getCenter() {
     311                return _center;
    287312        }
    288313       
    289 //      @Override
    290 //      public void setPosition(float x, float y){
    291 //              float deltaX = x - _source._x;
    292 //              float deltaY = y = _source._y;
    293 //              _center.setPosition(deltaX, deltaY);
    294 //              super.setPosition(x,y);
    295 //      }
    296         public Item getCenter(){
    297                 return _center;
    298         }
     314       
    299315}
  • trunk/src/org/expeditee/items/Dot.java

    r115 r121  
    8686        @Override
    8787        public void paint(Graphics2D g) {
    88                 if (isHighlighted() /* && !Frame.FreeItems.contains(this) */) {
     88                if (isHighlighted() /* && !FreeItems.getInstance().contains(this) */) {
    8989                        Color highlightColor = getHighlightColor();
    9090                        g.setColor(highlightColor);
  • trunk/src/org/expeditee/items/InteractiveWidget.java

    r108 r121  
    2020import org.expeditee.gui.Frame;
    2121import org.expeditee.gui.FrameGraphics;
     22import org.expeditee.gui.FreeItems;
    2223
    2324/**
     
    5354        // world
    5455        private Text _textRepresentation;
     56       
     57        private final static Color FREESPACE_BACKCOLOR = new Color(100,100,100,128);
    5558
    5659        // A flag for signifying whether the swing components are ready to paint.
    5760        // If the swing components has not been layed out, if they are painted they
    58         // will
    59         // not draw in the correct positions.
     61        // will not draw in the correct positions.
     62        // Also for setting AWT and Swing -Related drawing options after construction
    6063        private boolean _isReadyToPaint = false;
    61 
     64       
    6265        /**
    6366         * Creates a InteractiveWidget from a text item.
     
    356359                _swingComponent = component;
    357360                _textRepresentation = source;
    358 
     361               
    359362                _minWidth = minWidth;
    360363
     
    742745
    743746                }
     747               
     748                FrameGraphics.invalidateItem(_d1, _swingComponent.getBounds());
    744749        }
    745750
     
    772777
    773778                                synchronized (_widgetsToAddLater) {
    774                                         _widgetsToAddLater.add(new WidgetInfo(this, e));
     779                                        _widgetsToAddLater.add(new DelayedWidgetEvent(this, e));
    775780                                }
    776781                                SwingUtilities.invokeLater(new AddToFrameLater());
     
    780785
    781786        }
     787       
     788        /**
     789         * @return True if at least one corner is floating
     790         */
     791        public boolean isFloating() {
     792                return _d1.isFloating() || _d2.isFloating()
     793                                || _d3.isFloating() || _d4.isFloating();
     794        }
     795       
     796        public boolean areCornersFullyAnchored() {
     797                return _d1.getParent() != null && _d2.getParent() != null
     798                && _d3.getParent() != null && _d4.getParent() != null;
     799        }
    782800
    783801        /**
     
    786804         * @author Brook Novak
    787805         */
    788         class WidgetInfo {
    789 
    790                 WidgetInfo(InteractiveWidget widget, ItemParentStateChangedEvent e) {
     806        class DelayedWidgetEvent {
     807
     808                DelayedWidgetEvent(InteractiveWidget widget, ItemParentStateChangedEvent e) {
    791809                        _widget = widget;
    792810                        _e = e;
     
    802820         * before the browser singleton is made available.
    803821         */
    804         private static List<WidgetInfo> _widgetsToAddLater = new LinkedList<WidgetInfo>();
     822        private static List<DelayedWidgetEvent> _widgetsToAddLater = new LinkedList<DelayedWidgetEvent>();
    805823
    806824        /**
     
    810828                public void run() {
    811829                        if (!_widgetsToAddLater.isEmpty()) {
    812                                 List<WidgetInfo> tmp = null;
     830                                List<DelayedWidgetEvent> tmp = null;
    813831                                synchronized (_widgetsToAddLater) {
    814                                         tmp = new LinkedList<WidgetInfo>(_widgetsToAddLater);
     832                                        tmp = new LinkedList<DelayedWidgetEvent>(_widgetsToAddLater);
    815833                                }
    816834                                _widgetsToAddLater.clear();
    817                                 for (WidgetInfo iwi : tmp) {
     835                                for (DelayedWidgetEvent iwi : tmp) {
    818836                                        iwi._widget.addJComponantToFrame(iwi._e);
    819837                                }
     
    821839                }
    822840        }
     841       
     842        public void onBoundsChanged() {
     843
     844                _swingComponent.setBounds(getX(), getY(), getWidth(), getHeight());
     845
     846        }
     847
    823848
    824849        /**
     
    841866                }
    842867
     868        }
     869
     870        private void ignoreAWTPainting(Component c) {
     871               
     872                if (c instanceof JComponent) {
     873                        ((JComponent)c).setDoubleBuffered(false);
     874                }
     875               
     876                c.setIgnoreRepaint(true);
     877               
     878                if (c instanceof Container) {
     879                        for (Component child : ((Container) c).getComponents()) {
     880
     881                                if (child instanceof Container) {
     882                                        ignoreAWTPainting(child);
     883                                } else {
     884                                        if (child instanceof JComponent) {
     885                                                ((JComponent)child).setDoubleBuffered(false);
     886                                        }
     887                                       
     888                                        child.setIgnoreRepaint(true);
     889                                }
     890                        }
     891                }
     892        }
     893       
     894        private void prepareToPaint() {
    843895                _isReadyToPaint = true;
    844         }
    845 
    846         public void onBoundsChanged() {
    847 
    848                 _swingComponent.setBounds(getX(), getY(), getWidth(), getHeight());
    849 
    850         }
     896                layout(_swingComponent);
     897                ignoreAWTPainting(_swingComponent);
     898        }
     899       
    851900
    852901        /**
     
    858907
    859908                if (!_isReadyToPaint) {
    860                         layout(_swingComponent);
     909                        prepareToPaint();
    861910                }
    862911
    863912                Point loc = _swingComponent.getLocation();
     913               
    864914                g.translate(loc.x, loc.y - 1);
    865915                _swingComponent.paint(g);
     
    867917
    868918        }
    869 
    870         /**
    871          * Called from the widgets corners: Whenever the corners are repainted and
    872          * the widget is floating (e.g. currently picked up / rubberbanding) then a
     919       
     920        /**
     921         * Invoked whenever the widget is to be repainted in free space.
     922         * @param g
     923         */
     924        protected void paintInFreeSpace(Graphics g) {
     925                g.setColor(FREESPACE_BACKCOLOR);
     926                g.fillRect(getX(), getY(), getWidth(), getHeight());
     927        }
     928
     929        /**
     930         * Called from the widgets corners: Whenever one of the corners are invoked for
     931         * a refill of the enclosed area.
     932         *
     933         * If the widget is floating (e.g. currently picked up / rubberbanding) then a
    873934         * shaded area is drawn instead of the actual widget so the manipulation of
    874          * the widget is as smooth as possible. The shaded area is only draw once so
    875          * it selects one of the 4 possible notifiers to be the actual trigger to
    876          * draw the shaded area
     935         * the widget is as smooth as possible.
    877936         *
    878937         * @param g
    879938         * @param notifier
    880939         */
    881         void paint(Graphics g, WidgetCorner notifier) {
     940        void paintFill(Graphics g) {
    882941                if (_swingComponent.getParent() == null) {
    883942                        // Note that frames with @f may want to paint the widgets so do not
    884943                        // paint over the widget interface in these cases: must only
    885944                        // paint if an object is floating
    886                         if (notifier == _d4
    887                                         && (_d1.isFloating() || _d2.isFloating()
    888                                                         || _d3.isFloating() || _d4.isFloating())) {
    889                                 g.setColor(Color.DARK_GRAY);
    890                                 g.fillRect(getX(), getY(), getWidth(), getHeight());
     945                        if (isFloating()) {
     946                                paintInFreeSpace(g);
    891947                        }
    892948                }
     
    909965         *
    910966         * The purpose of this is so that widgets can have an extra context: no
    911          * expeditee highlighting if focus is on a swing componet.
     967         * expeditee highlighting if focus is on a swing componant.
    912968         *
    913969         * @param enable
     
    921977        }
    922978
    923         public static boolean isExepiteeHighlightingEnabled() {
     979        public static boolean isExpediteeHighlightingEnabled() {
    924980                return _isExepiteeHighlightingEnabled;
    925981        }
    926982
     983        /**
     984         * Removes this widget from the parent frame or free space
     985         */
     986        protected void removeSelf() {
     987               
     988                Frame parent = getParentFrame();
     989               
     990                if (parent == null) {
     991                        FreeItems.getInstance().removeAll(_expediteeItems);
     992                } else {
     993                        parent.removeAllItems(_expediteeItems);
     994                }
     995
     996        }
     997       
     998        /**
     999         * @return The parent frame. Null if has none. Note: Based on corners parents.
     1000         */
     1001        public Frame getParentFrame() {
     1002
     1003                Frame parent = null;
     1004                if (_d1.getParent() != null) parent = _d1.getParent();
     1005                else if (_d2.getParent() != null) parent = _d2.getParent();
     1006                else if (_d3.getParent() != null) parent = _d3.getParent();
     1007                else if (_d4.getParent() != null) parent = _d4.getParent();
     1008               
     1009                return parent;
     1010        }
     1011       
     1012       
    9271013}
  • trunk/src/org/expeditee/items/Item.java

    r116 r121  
    55import java.awt.Cursor;
    66import java.awt.Dimension;
     7import java.awt.GradientPaint;
    78import java.awt.Graphics2D;
    89import java.awt.Point;
    910import java.awt.Polygon;
    1011import java.awt.Rectangle;
     12import java.awt.Shape;
    1113import java.awt.Stroke;
    1214import java.awt.geom.AffineTransform;
     
    2931import org.expeditee.gui.FrameIO;
    3032import org.expeditee.gui.FrameUtils;
     33import org.expeditee.gui.MessageBay;
    3134import org.expeditee.gui.Overlay;
    3235import org.expeditee.gui.Vector;
     
    185188                if (parent != null) {
    186189                        dest.setID(source.getParentOrCurrentFrame().getNextItemID());
    187                 }
     190                }
     191//              else {
     192//                      dest.setID(source.getID());
     193//              }
    188194        }
    189195
     
    254260        private Color _color = null;
    255261
    256         private Color _highlightColor = DEFAULT_HIGHLIGHT;
     262        protected Color _highlightColor = DEFAULT_HIGHLIGHT;
    257263
    258264        private Color _colorBackground = null;
     
    525531        }
    526532
    527         protected Polygon getCircle() {
     533        protected Polygon getLinkPoly() {
    528534                if (_circle == null) {
    529535                        int points = 16;
     
    552558                        _circleCross = new Polygon();
    553559
    554                         Rectangle bounds = getCircle().getBounds();
     560                        Rectangle bounds = getLinkPoly().getBounds();
    555561                        int x1 = (int) bounds.getMinX();
    556562                        int x2 = (int) bounds.getMaxX();
     
    943949                        g.setColor(fillColor);
    944950                        // The painting is not efficient enough for gradients...
    945                         // Shape s = getEnclosedShape();
    946                         // Rectangle b = s.getBounds();
    947                         // GradientPaint gp = new GradientPaint((int) (b.x + b.width * 0.3),
    948                         // b.y, getFillColor(), (int) (b.x + b.width * 1.3), b.y,
    949                         // Color.white);
    950                         // g.setPaint(gp);
    951                         // g.fill(s);
     951//                       Polygon s = getEnclosedShape();
     952//                      Rectangle b = s.getBounds();
     953//                      GradientPaint gp = new GradientPaint((int) (b.x + b.width * 0.3),
     954//                      b.y, getFillColor(), (int) (b.x + b.width * 1.3), b.y,
     955//                      Color.white);
     956//                      g.setPaint(gp);
     957//                       g.fillPolygon(s);
    952958                        g.fillPolygon(getEnclosedShape());
    953959                }
     
    9941000         */
    9951001        public void removeAllLines() {
     1002                for (Line l : _lines) {
     1003                        l.invalidateAll();
     1004                }
    9961005                _lines.clear();
    9971006        }
     
    10161025         */
    10171026        public void removeLine(Line line) {
    1018                 _lines.remove(line);
     1027                if (_lines.remove(line))
     1028                        line.invalidateAll();
    10191029        }
    10201030
     
    10241034                        Simple.RunFrameAndReportError(this, new Context());
    10251035                        Simple.ProgramFinished();
    1026                         FrameGraphics.DisplayMessage(AgentStats.getStats(), GREEN);
     1036                        MessageBay.displayMessage(AgentStats.getStats(), GREEN);
    10271037                } catch (ConcurrentModificationException ce) {
    10281038                        Simple.ProgramFinished();
    10291039                        ce.printStackTrace();
    10301040                } catch (Exception e) {
    1031                         FrameGraphics.LinkedErrorMessage(e.getMessage());
     1041                        MessageBay.linkedErrorMessage(e.getMessage());
    10321042                        Simple.ProgramFinished();
    10331043                }
     
    11421152
    11431153        public void setBackgroundColor(Color c) {
    1144                 _colorBackground = c;
     1154                if (c != _colorBackground) {
     1155                        _colorBackground = c;
     1156                        invalidateCommonTrait(ItemAppearence.BackgroundColorChanged);
     1157                }
    11451158        }
    11461159
     
    11631176         */
    11641177        public void setColor(Color c) {
    1165                 _color = c;
     1178                if (c != _color) {
     1179                        _color = c;
     1180                        invalidateCommonTrait(ItemAppearence.ForegroundColorChanged);
     1181                }
    11661182        }
    11671183
     
    11911207
    11921208        public void setFillColor(Color c) {
     1209
    11931210                _colorFill = c;
    11941211
     
    11981215                                other.setFillColor(c);
    11991216                }
     1217               
     1218                invalidateCommonTrait(ItemAppearence.FillColor);
     1219                invalidateFill();
    12001220        }
    12011221
    12021222        public void setFillPattern(String patternLink) {
    12031223                _fillPattern = patternLink;
     1224                invalidateCommonTrait(ItemAppearence.FillPattern);
     1225                invalidateFill();
    12041226        }
    12051227
     
    12441266                for (Line line : lines)
    12451267                        line.setLinePattern(getLinePattern());
     1268               
     1269               
    12461270        }
    12471271
     
    12541278         */
    12551279        public void setLink(String frameName) {
    1256                 if (FrameIO.isValidLink(frameName))
     1280                if (FrameIO.isValidLink(frameName)) 
    12571281                        _link = frameName;
    12581282                else
    1259                         FrameGraphics.ErrorMessage("[" + frameName
     1283                        MessageBay.errorMessage("[" + frameName
    12601284                                        + "] is not a valid frame name");
    12611285                // TODO make this throw exceptions etc...
     1286               
     1287                invalidate(getLinkDrawArea());
    12621288        }
    12631289
     
    12661292                        _link_frameset = frameset;
    12671293                else
    1268                         FrameGraphics.ErrorMessage("[" + frameset
     1294                        MessageBay.errorMessage("[" + frameset
    12691295                                        + "] is not a valid frameset name");
    12701296                // TODO make this throw exceptions etc...
     
    12801306                        _link_template = template;
    12811307                else
    1282                         FrameGraphics.ErrorMessage("[" + template
     1308                        MessageBay.errorMessage("[" + template
    12831309                                        + "] is not a valid frame name");
    12841310                // TODO make this throw exceptions etc...
     
    13161342
    13171343        /**
     1344         * Invalidates this, connected lines and fill
     1345         * @param trait
     1346         */
     1347        private void invalidateCommonTraitForAll(ItemAppearence trait) {
     1348                invalidateCommonTrait(trait);
     1349                for (Line line : getLines())
     1350                        line.invalidateCommonTrait(trait);
     1351                if (_colorFill != null) {
     1352                        invalidateFill(); // only invalidates if has fill
     1353                }
     1354                for(XRayable x: getEnclosures()){
     1355                        x.invalidateCommonTrait(trait);
     1356                }
     1357
     1358        }
     1359       
     1360       
     1361        /**
    13181362         * Sets the position of this item on the screen
    13191363         *
     
    13261370                float deltaX = x - _x;
    13271371                float deltaY = y - _y;
     1372               
     1373                if (deltaX == 0 && deltaY == 0) return;
     1374               
     1375                invalidateCommonTraitForAll(ItemAppearence.PreMoved);
    13281376
    13291377                _x = x;
     
    14131461                }
    14141462
    1415                 for (Line line : getLines())
    1416                         line.updatePolygon();
     1463                for (Line line : getLines()) {
     1464                        line.updatePolygon();   
     1465                }
     1466               
     1467                invalidateCommonTraitForAll(ItemAppearence.PostMoved);
     1468               
    14171469        }
    14181470
     
    14631515         */
    14641516        public void setThickness(float thick, boolean setConnectedThickness) {
     1517               
     1518                if (thick == _thickness) return;
     1519                boolean bigger = thick > _thickness;
     1520               
     1521                if (!bigger) invalidateCommonTrait(ItemAppearence.Thickness);
     1522               
    14651523                _thickness = thick;
    14661524                // update the size of any lines
    14671525                for (Line line : getLines())
    14681526                        line.setThickness(thick, setConnectedThickness);
     1527
     1528                if (bigger) invalidateCommonTrait(ItemAppearence.Thickness);
    14691529        }
    14701530
     
    15341594
    15351595        public int setHighlightColor(Color c) {
     1596               
    15361597                _highlightThickness = DEFAULT_HIGHLIGHT_THICKNESS;
    1537                 if (c != null)
    1538                         _highlightColor = c;
    1539                 else
    1540                         _highlightColor = DEFAULT_HIGHLIGHT;
     1598               
     1599                Color selColor = (c != null) ? c : DEFAULT_HIGHLIGHT;
     1600                if (_highlightColor != c) {
     1601                        _highlightColor = selColor;
     1602                        this.invalidateCommonTrait(ItemAppearence.HighlightColorChanged);
     1603                }
    15411604
    15421605                return Item.UNCHANGED_CURSOR;
     1606               
    15431607        }
    15441608
     
    15891653        public void setHighlightMode(HighlightMode mode, Color color) {
    15901654                setHighlightColor(color);
    1591                 _mode = mode;
     1655                if (_mode != mode) {
     1656                        _mode = mode;
     1657                        this.invalidateCommonTrait(ItemAppearence.HighlightModeChanged);
     1658                }
    15921659        }
    15931660
     
    16551722         */
    16561723        public void setEnclosedList(Collection<Item> enclosed) {
     1724               
     1725                boolean changed = (_enclosure == null && enclosed != null);
     1726               
     1727                if (_enclosure != null && enclosed == null) {
     1728                        invalidateFill();
     1729                }
     1730               
    16571731                _enclosure = enclosed;
     1732               
     1733                if (changed) {
     1734                        invalidateFill();;
     1735                }
    16581736        }
    16591737
     
    17731851                if (_actions == null || _actions.size() == 0) {
    17741852                        _poly = null;
     1853                        invalidateCommonTrait(ItemAppearence.LinkChanged);
    17751854                }
    17761855                _actions = new LinkedList<String>();
     
    17801859        protected int getLinkYOffset() {
    17811860                return 0;
     1861        }
     1862       
     1863        protected Rectangle getLinkDrawArea() { // TODO: Revise
     1864                return new Rectangle(getX() - LEFT_MARGIN - 3, getY() + getLinkYOffset() - 3, 6, 6);
    17821865        }
    17831866
     
    18041887
    18051888                        if (getLinkMark() && getLink() != null) {
    1806                                 g.drawPolygon(getCircle());
     1889                                g.drawPolygon(getLinkPoly());
    18071890
    18081891                                // if the link is not valid, cross out the circle
     
    18121895
    18131896                        if (getActionMark() && getAction() != null) {
    1814                                 g.drawPolygon(getCircle());
    1815                                 g.fillPolygon(getCircle());
     1897                                g.drawPolygon(getLinkPoly());
     1898                                g.fillPolygon(getLinkPoly());
    18161899
    18171900                                // if the link is not valid, cross out the circle
     
    19732056         */
    19742057        public void translate(Point2D origin, double ratio) {
     2058               
     2059                invalidateCommonTraitForAll(ItemAppearence.PreMoved);
     2060               
    19752061                _x = (float) (origin.getX() + ratio * (_x - origin.getX()));
    19762062                _y = (float) (origin.getY() + ratio * (_y - origin.getY()));
     
    19782064                for (Line line : getLines())
    19792065                        line.updatePolygon();
     2066               
     2067                invalidateCommonTraitForAll(ItemAppearence.PostMoved);
     2068               
    19802069        }
    19812070
     
    20052094                                        setLinePattern(new int[] { LinePatterns[i], LinePatterns[i] });
    20062095                                }
     2096                               
     2097                                invalidateCommonTrait(ItemAppearence.ToggleDashed);
    20072098                                return;
    20082099                        }
    20092100                }
     2101               
     2102               
    20102103        }
    20112104
     
    20372130        public boolean isDeleted() {
    20382131                return _deleted;
     2132        }
     2133       
     2134        /**
     2135         * @return The full canvas that this item draws to. Must include highlighting bounds
     2136         */
     2137        public Rectangle[] getDrawingArea() {
     2138               
     2139                return new Rectangle[] {
     2140                                ItemUtils.expandRectangle(getPolygon().getBounds(),
     2141                                _highlightThickness)
     2142                        };
     2143               
     2144        }
     2145       
     2146        /**
     2147         *
     2148         * @param area
     2149         * @return True if area intersects with this items drawing area.
     2150         */
     2151        public final boolean isInDrawingArea(Area area) {
     2152                for (Rectangle r : getDrawingArea()) {
     2153                        if (area.intersects(r)) return true;
     2154                }
     2155                return false;
     2156        }
     2157       
     2158        /**
     2159         * Completetly invalidates the item - so that it should be redrawed.
     2160         * Note: This is handled internally, it should be reare to invoke this
     2161         * externally
     2162         */
     2163        public final void invalidateAll() {
     2164                invalidate(getDrawingArea());
     2165        }
     2166       
     2167        /**
     2168         * Invalidates areas on the parent frame.
     2169         * Purpose: to be called on specific areas of the item that needs redrawing.
     2170         * @param damagedAreas
     2171         */
     2172        protected final void invalidate(Rectangle[] damagedAreas) {
     2173                for (Rectangle r : damagedAreas) invalidate(r);
     2174        }
     2175       
     2176        /**
     2177         * Invalidates areas on the parent frame.
     2178         * Purpose: to be called on specific areas of the item that needs redrawing.
     2179         * @param damagedAreas
     2180         */
     2181        protected final void invalidate(Rectangle damagedArea) {
     2182                FrameGraphics.invalidateItem(this, damagedArea);
     2183        }
     2184       
     2185        /**
     2186         * Used to invalidate visual traits commonly shared by all items.
     2187         * @param trait
     2188         */
     2189        public final void invalidateCommonTrait(ItemAppearence trait) {
     2190                invalidate(getDamagedArea(trait));
     2191               
     2192                if (_colorFill != null && (
     2193                                trait == ItemAppearence.Added
     2194                                || trait == ItemAppearence.Removed)
     2195                                ) {
     2196                        invalidateFill();
     2197                }
     2198        }
     2199       
     2200        /**
     2201         * Invalidates fill if has one, even if no color is set.
     2202         */
     2203        public void invalidateFill() {
     2204                if (isLineEnd() && _enclosure != null) {
     2205                        invalidate(getEnclosedShape().getBounds());
     2206                }
     2207        }
     2208       
     2209        /**
     2210         * Default implementation always uses drawing area except for links,
     2211         * where the link drawing area is used. Override to make item
     2212         * drawing more efficient - defining only parts of the item that needs
     2213         * redrawing.
     2214         *
     2215         * @see Item.getDrawingArea
     2216         *
     2217         * @param trait The visual trait that has changed.
     2218         *
     2219         * @return The damaged area according to the visual trait that has changed.
     2220         */
     2221        protected Rectangle[] getDamagedArea(ItemAppearence trait) {
     2222               
     2223                if (trait == ItemAppearence.LinkChanged)
     2224                        return new Rectangle[] {getLinkDrawArea()}; // Invalidate area where link is drawn
     2225                       
     2226                return getDrawingArea();
     2227
    20392228        }
    20402229
     
    20562245                _overlay = overlay;
    20572246        }
     2247
    20582248}
  • trunk/src/org/expeditee/items/ItemUtils.java

    r115 r121  
    22
    33import java.awt.Color;
     4import java.awt.Rectangle;
    45import java.awt.image.ImageObserver;
    56import java.io.File;
     
    1718import org.expeditee.gui.DisplayIO;
    1819import org.expeditee.gui.Frame;
     20import org.expeditee.gui.FreeItems;
    1921import org.expeditee.gui.Vector;
    2022import org.expeditee.items.Item.HighlightMode;
     23
    2124
    2225//Static methods that provide functions for the objects\
     
    847850        }
    848851
     852        /**
     853         * Determines if an item is visible from a the current frame(s).
     854         * If the item is free then it is considered visible.
     855         * @param i The item to check
     856         * @return True if visible/free from given frame.
     857         */
     858        public static boolean isVisible(Item i) {
     859                if (DisplayIO.isTwinFramesOn()) {
     860                        if (!isVisible(DisplayIO.getFrames()[0], i)) {
     861                                return isVisible(DisplayIO.getFrames()[1], i);
     862                        } else {
     863                                return true;
     864                        }
     865                } else  {
     866                        return isVisible(DisplayIO.getCurrentFrame(), i);
     867                }
     868        }
     869
     870        /**
     871         * Determines if an item is visible from a given frame.
     872         * If the item is free then it is considered visible.
     873         *
     874         * @param fromFrame The frame to check from.
     875         * @param i The item to check
     876         * @return True if visible/free from given frame.
     877         */
     878        public static boolean isVisible(Frame fromFrame, Item i) {
     879                if (fromFrame == null) return false;
     880               
     881                Frame parent = i.getParent();
     882               
     883                if (parent == fromFrame) return true;
     884               
     885                else if (parent == null) return FreeItems.getInstance().contains(i);
     886               
     887                return fromFrame.getAllItems().contains(i) && i.isVisible();
     888        }
     889       
     890        public static Rectangle expandRectangle(Rectangle r, int n) {
     891                return new Rectangle(r.x - (n >> 1), r.y - (n >> 1),
     892                                r.width + n, r.height + n);
     893        }
     894       
    849895        /*
    850896         * FrameMouseActions while (!copies.isEmpty()) { Iterator<Item> iterator =
  • trunk/src/org/expeditee/items/Line.java

    r115 r121  
    5454                return _lineStroke;
    5555        }
     56       
     57       
    5658
    5759        /**
     
    344346                if (_virtualSpot != null) {
    345347                        _virtualSpot.paint(g);
     348                        invalidateVirtualSpot();
    346349                        _virtualSpot = null;
    347350                }
     351        }
     352       
     353        private void invalidateVirtualSpot() {
     354                assert (_virtualSpot != null);
     355               
     356                invalidate(_virtualSpot.getDrawingArea());
     357               
    348358        }
    349359
     
    390400                        return;
    391401                if (arrowLength == AUTO_ARROWHEAD_LENGTH) {
    392                         arrowLength = length / ARROW_HEAD_TO_LENGTH_RATIO;
    393                         arrowLength = Math.max(MINIMUM_ARROW_HEAD_LENGTH, arrowLength);
    394                         arrowLength = Math.min(MAXIMUM_ARROW_HEAD_LENGTH, arrowLength);
     402                        arrowLength = getAutoArrowheadLength(length);
    395403                        withArrow.setArrowhead(null);
    396404                        if (arrowRatio < 0)
     
    416424                AffineTransform tx = AffineTransform.getRotateInstance(rad, x0, y0);
    417425                g.draw(tx.createTransformedShape((Shape) arrowhead));
     426        }
     427
     428
     429        /**
     430         *
     431         * @param length The length of the line
     432         * @return
     433         */
     434        private float getAutoArrowheadLength(float length) {
     435                float arrowLength;
     436                arrowLength = length / ARROW_HEAD_TO_LENGTH_RATIO;
     437                arrowLength = Math.max(MINIMUM_ARROW_HEAD_LENGTH, arrowLength);
     438                arrowLength = Math.min(MAXIMUM_ARROW_HEAD_LENGTH, arrowLength);
     439                return arrowLength;
    418440        }
    419441
     
    540562        @Override
    541563        public void setThickness(float thick, boolean setConnectedThickness) {
     564               
     565                float oldThickness = this.getThickness();
     566                if (thick == oldThickness) return;
     567                boolean bigger = thick > oldThickness;
     568               
     569                if (!bigger) invalidateAll();
     570               
    542571                if (thick < 0)
    543572                        thick = DEFAULT_THICKNESS;
     
    564593                        _lineStroke = new BasicStroke(Math.max(thick, MINIMUM_THICKNESS),
    565594                                        CAP, JOIN);
     595               
     596                if (bigger) invalidateAll();
    566597        }
    567598
     
    759790                spot.setPosition((int) x, (int) y);
    760791                _virtualSpot = spot;
     792                invalidateVirtualSpot();
    761793        }
    762794
     
    797829                spot.setPosition((int) x, (int) y);
    798830                _virtualSpot = spot;
     831                invalidateVirtualSpot();
    799832        }
    800833
     
    9741007                        _poly.addPoint((int) one.getMaxX(), (int) one.getMaxY());
    9751008                }
     1009       
    9761010        }
    9771011
     
    10351069                return Point.distance(p1.x, p1.y, p2.x, p2.y);
    10361070        }
     1071
     1072        @Override
     1073        public Rectangle[] getDrawingArea() { // TODO: CACHE - LIKE UPDATE POLYGON
     1074
     1075                float currentThickness = this.getThickness();
     1076               
     1077                // Establish bounds
     1078                int x = Math.min(_start.getX(), _end.getX());
     1079                int y = Math.min(_start.getY(), _end.getY());
     1080                int w = (Math.max(_start.getX(), _end.getX()) - x) + 1;
     1081                int h = (Math.max(_start.getY(), _end.getY()) - y) + 1;
     1082               
     1083                int thickness = (int)Math.ceil(currentThickness);
     1084                if (thickness < 4) thickness = 4;
     1085                int halfThickness = (int)Math.ceil(currentThickness / 2);
     1086               
     1087                // Consider line thickness
     1088                w += thickness;
     1089                h += thickness;
     1090                x -= halfThickness;
     1091                y -= halfThickness;
     1092       
     1093                Rectangle bounds = new Rectangle(x, y, w, h);
     1094               
     1095                // TODO: Cap bounds
     1096               
     1097                if (_end.hasVisibleArrow()) {
     1098                       
     1099                        double arrowLength = _end.getArrowheadLength();
     1100                       
     1101                        if (arrowLength == AUTO_ARROWHEAD_LENGTH) {
     1102                                arrowLength = Math.ceil(getAutoArrowheadLength((float)getLength()));
     1103                        } else {
     1104                                arrowLength = Math.ceil(arrowLength);
     1105                        }
     1106
     1107                        arrowLength += ((thickness * 2) + 1);
     1108                        int nArrowLength = (int)arrowLength;
     1109                               
     1110                        // NAIVE version - but probably more efficient in the long run... overall
     1111                        // as opposed to advanced/expensive calculations for getting exact bounding box
     1112                        Rectangle arrowBounds = new Rectangle(
     1113                                        _end.getX() - nArrowLength,
     1114                                        _end.getY() - nArrowLength,
     1115                                        2 * nArrowLength,
     1116                                        2 * nArrowLength);
     1117                       
     1118                        if (currentThickness > 0.0f) {
     1119
     1120                                arrowBounds = new Rectangle(
     1121                                                arrowBounds.x - halfThickness,
     1122                                                arrowBounds.y - halfThickness,
     1123                                                arrowBounds.width + thickness,
     1124                                                arrowBounds.height + thickness);
     1125                        }
     1126                       
     1127                        return new Rectangle[] { bounds, arrowBounds };
     1128                } else {
     1129                        return new Rectangle[] { bounds };
     1130                }
     1131
     1132        }
    10371133       
    10381134        @Override
     
    10461142                _end.setPermission(p);
    10471143        }
     1144       
    10481145}
  • trunk/src/org/expeditee/items/Picture.java

    r115 r121  
    526526                super.translate(origin, ratio);
    527527        }
     528
     529        @Override
     530        public Rectangle[] getDrawingArea() {
     531               
     532                Rectangle[] da = super.getDrawingArea();
     533               
     534                if (getLink() != null || getAction() != null) {
     535                        Rectangle[] da2 = new Rectangle[da.length + 1];
     536                        System.arraycopy(da, 0, da2, 0, da.length);
     537                        da2[da.length] = getLinkPoly().getBounds();
     538                        da2[da.length].translate(getX() - LEFT_MARGIN, getY() + getLinkYOffset());
     539                        da2[da.length].width += 2;
     540                        da2[da.length].height += 2;
     541                        da = da2;
     542                }
     543               
     544                return da;
     545               
     546        }
     547       
     548       
    528549}
  • trunk/src/org/expeditee/items/Text.java

    r116 r121  
    182182        }
    183183
     184        @Override
     185        public Color getHighlightColor() {
     186                if (_highlightColor.equals(getPaintBackgroundColor()))
     187                        return ALTERNATE_HIGHLIGHT;
     188                return _highlightColor;
     189        }
     190
     191       
    184192        /**
    185193         * Sets the justification of this Text item. The given integer should
     
    225233         */
    226234        public void setText(String text) {
     235        //      if (_text != null && text.length() < _text.length())
     236        //              invalidateAll();
    227237                _text = new StringBuffer(text);
    228238                rebuild(false);
     239        //      invalidateAll();
    229240        }
    230241
     
    265276         */
    266277        public void removeText(String text) {
    267                 if (_text.length() > 0 && _text.indexOf(text) == 0)
     278               
     279                if (_text.length() > 0 && _text.indexOf(text) == 0) {
     280                        //invalidateAll();
    268281                        _text.delete(0, text.length());
     282                }
     283               
    269284
    270285        }
     
    273288                int length = _text.length();
    274289                if (length > 0) {
     290                        //invalidateAll();
    275291                        int pos = _text.indexOf(textToRemove);
    276292                        int textToRemoveLength = textToRemove.length();
     
    279295                        }
    280296                }
     297               
    281298        }
    282299
     
    411428                TextHitInfo hit = getCharPosition(line, mouseX);
    412429                _selectionStart = hit.getInsertionIndex() + _lineOffsets.get(line);
     430                invalidateAll();
    413431        }
    414432
     
    420438                TextHitInfo hit = getCharPosition(line, mouseX);
    421439                _selectionEnd = hit.getInsertionIndex() + _lineOffsets.get(line);
     440                invalidateAll();
    422441        }
    423442
     
    425444                _selectionStart = -1;
    426445                _selectionEnd = -1;
     446                invalidateAll();
    427447        }
    428448
    429449        public void clearSelectionEnd() {
    430450                _selectionEnd = -1;
     451                invalidateAll();
    431452        }
    432453
     
    448469                if (_selectionStart < 0 || _selectionEnd < 0)
    449470                        return null;
    450                 else if (_selectionEnd > _text.length())
     471               
     472                invalidateAll();
     473               
     474                if (_selectionEnd > _text.length())
    451475                        _selectionEnd = _text.length();
    452476
     
    459483                _text.insert(left, newText);
    460484                rebuild(true);
     485               
     486                invalidateAll();
    461487
    462488                return s;
     
    493519                TextLayout current = null;
    494520                int line;
     521               
     522                invalidateAll();
    495523
    496524                // check for empty string
     
    635663                                                x,
    636664                                                (getX() - Item.MARGIN_RIGHT - (2 * getGravity()) + getBoundsWidth()));
     665               
     666                invalidateAll();
     667               
    637668                return new Point2D.Float(Math.round(x), Math.round(getY() + y
    638669                                + caret[1]));
     
    777808        public void setFont(Font font) {
    778809                // all decoding occurs in the Utils class
     810               
    779811                _font = font;
    780 
    781812                // rejustify();
    782813                rebuild(false);
     
    11051136                        return;
    11061137                }
    1107 
     1138               
    11081139                AttributedString paragraphText = new AttributedString(_text.toString());
    11091140                paragraphText.addAttribute(TextAttribute.FONT, getPaintFont());
     
    11541185
    11551186                updatePolygon();
     1187               
    11561188        }
    11571189
     
    15151547                        _lineBreaker.deleteChar(inserting.getIterator(), pos);
    15161548                }
     1549               
     1550               
     1551               
    15171552        }
    15181553
     
    16821717        @Override
    16831718        protected int getLinkYOffset() {
     1719                if (_textLayouts.size() == 0) return  0;
    16841720                return Math.round(-(_textLayouts.get(0).getAscent() / 2));
    16851721        }
  • trunk/src/org/expeditee/items/WidgetCorner.java

    r115 r121  
    11package org.expeditee.items;
    22
     3import java.awt.Color;
    34import java.awt.Graphics2D;
     5import java.awt.Polygon;
     6import java.awt.geom.Point2D;
    47
    58
     
    1013        WidgetCorner(int x, int y, int id, InteractiveWidget widgetSource) {
    1114                super(x, y, id);
     15               
     16                super.setThickness(2.0f);
     17               
    1218                if (widgetSource == null) throw new NullPointerException("widgetSource");
    1319                _widgetSource = widgetSource;
     
    2228        @Override
    2329        public void setPosition(float x, float y) {
     30                invalidateFill();
     31                if (_widgetSource != null) { // _widgetSource == null on construction
     32                        if (!_widgetSource.setPositions(this,(int)(x+0.5),(int)(y+0.5))) {
     33                                super.setPosition(x, y);
     34                        }
     35                } else super.setPosition(x, y);
     36                invalidateFill();
     37        }
     38       
     39        @Override
     40        public void setXY(float x, float y) {
     41                invalidateFill();
     42                if (_widgetSource != null) { // _widgetSource == null on construction
     43                        if (!_widgetSource.setPositions(this,(int)(x+0.5),(int)(y+0.5))) {
     44                                super.setXY(x, y);
     45                        }
     46                } else super.setXY(x, y);
     47                invalidateFill();
     48        }
    2449
    25                 if (_widgetSource != null) { // _widgetSource == null on construction
    26                         if (!_widgetSource.setPositions(this,(int)(x+0.5),(int)(y+0.5)))
    27                                 super.setPosition(x, y);
    28                 } else super.setPosition(x, y);
     50        @Override
     51        public void translate(Point2D origin, double ratio) {
     52                //super.translate(origin, ratio);
    2953        }
    3054
     
    4165        @Override
    4266        public void paint(Graphics2D g) {
    43                 if (InteractiveWidget.isExepiteeHighlightingEnabled()) { // only paint if flag is set to true
     67                if (InteractiveWidget.isExpediteeHighlightingEnabled()) { // only paint if flag is set to true
    4468                       
    4569                        // For fixed widgets, always have corner selected with connected context
     
    5175                        _mode = tmp; // restore mode
    5276                }
    53                 _widgetSource.paint(g, this);   
     77        }
     78       
     79        @Override
     80        public void paintFill(Graphics2D g) {
     81                _widgetSource.paintFill(g); // only paints a fill if floating
    5482        }
    5583       
     
    6997                return "WidgetCorner: [" + this.getX() + "," +  this.getY() + "]";
    7098        }
     99
     100        @Override
     101        public void setThickness(float thick) {
     102        }
     103
     104        @Override
     105        public void setArrow(float length, double ratio) {
     106        }
     107
     108        @Override
     109        public void setArrowhead(Polygon arrow) {
     110        }
     111
     112        @Override
     113        public void setArrowheadLength(float length) {
     114        }
     115
     116        @Override
     117        public void setArrowheadRatio(double ratio) {
     118        }
     119
     120        @Override
     121        public void setBackgroundColor(Color c) {
     122        }
     123
     124        @Override
     125        public void setBottomShadowColor(Color bottom) {
     126        }
     127
     128        @Override
     129        public void setFillColor(Color c) {
     130        }
     131
     132        @Override
     133        public void setFillPattern(String patternLink) {
     134        }
     135
     136        @Override
     137        public void toggleDashed(int amount) {
     138        }
     139
     140        @Override
     141        public void setSize(float size) {
     142        }
     143
     144
    71145       
    72        
     146
    73147}
  • trunk/src/org/expeditee/items/WidgetEdge.java

    r54 r121  
    22
    33import java.awt.Color;
     4import java.awt.Polygon;
    45
    56/**
     
    6061        }
    6162
    62        
     63        @Override
     64        public void setArrow(float length, double ratio) {
     65        }
     66
     67        @Override
     68        public void setArrowhead(Polygon arrow) {
     69        }
     70
     71        @Override
     72        public void setArrowheadLength(float length) {
     73        }
     74
     75        @Override
     76        public void setArrowheadRatio(double ratio) {
     77        }
     78
     79        @Override
     80        public void setBackgroundColor(Color c) {
     81        }
     82
     83        @Override
     84        public void setBottomShadowColor(Color bottom) {
     85        }
     86
     87        @Override
     88        public void setFillColor(Color c) {
     89        }
     90
     91        @Override
     92        public void setFillPattern(String patternLink) {
     93        }
     94
     95        @Override
     96        public void setSize(float size) {
     97        }
    6398}
  • trunk/src/org/expeditee/items/XRayable.java

    r109 r121  
    107107        @Override
    108108        public void setThickness(float thick) {
     109                this.invalidateCommonTrait(ItemAppearence.Thickness);
    109110                _source.setThickness(thick);
     111                this.invalidateCommonTrait(ItemAppearence.Thickness);
    110112        }
    111113       
     
    171173        public void setPosition(float x, float y) {
    172174                //_source.setPosition(x, y);
     175               
    173176        }
    174177       
  • trunk/src/org/expeditee/simple/Context.java

    r108 r121  
    99import org.expeditee.actions.Simple;
    1010import org.expeditee.gui.Frame;
    11 import org.expeditee.gui.FrameGraphics;
    1211import org.expeditee.gui.FrameIO;
     12import org.expeditee.gui.MessageBay;
    1313import org.expeditee.items.Text;
    1414
     
    4040        public void display() {
    4141                if (size() == 0) {
    42                         FrameGraphics.ErrorMessage("No variables exist!");
     42                        MessageBay.errorMessage("No variables exist!");
    4343                        return;
    4444                }
     
    238238                }
    239239                if (!success && Simple.isVerbose())
    240                         FrameGraphics.WarningMessage("Error creating " + framesetName);
     240                        MessageBay.warningMessage("Error creating " + framesetName);
    241241                if (successVar != null) {
    242242                        primitives_.setValue(successVar, new SBoolean(success));
  • trunk/src/org/expeditee/simple/Variables.java

    r80 r121  
    33import java.util.ArrayList;
    44
    5 import org.expeditee.gui.FrameGraphics;
     5import org.expeditee.gui.MessageBay;
    66
    77public abstract class Variables<T extends SVariable<?>> {
     
    2323        public void display() {
    2424                for (T v : list_) {
    25                         FrameGraphics.DisplayMessage(v.getName() + ": " + v.stringValue());
     25                        MessageBay.displayMessage(v.getName() + ": " + v.stringValue());
    2626                }
    2727        }
  • trunk/src/org/expeditee/stats/TreeStats.java

    r115 r121  
    66
    77import org.expeditee.gui.Frame;
    8 import org.expeditee.gui.FrameGraphics;
    98import org.expeditee.gui.FrameIO;
     9import org.expeditee.gui.MessageBay;
    1010import org.expeditee.io.Logger;
    1111import org.expeditee.items.Item;
     
    2727                super(topFrame);
    2828                visited.add(_name.toLowerCase());
    29                 FrameGraphics.OverwriteMessage("Computed: " + _name);
     29                MessageBay.overwriteMessage("Computed: " + _name);
    3030
    3131                // Initialise variables with the data for this frames comet
Note: See TracChangeset for help on using the changeset viewer.