Ignore:
Timestamp:
05/10/18 16:04:51 (6 years ago)
Author:
davidb
Message:

Reworking of the code-base to separate logic from graphics. This version of Expeditee now supports a JFX graphics as an alternative to SWING

File:
1 edited

Legend:

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

    r919 r1102  
    1919package org.expeditee.actions;
    2020
    21 import java.awt.Color;
    2221import java.util.LinkedList;
    2322import java.util.List;
     
    2625import org.expeditee.agents.Agent;
    2726import org.expeditee.agents.DefaultAgent;
    28 import org.expeditee.gui.DisplayIO;
     27import org.expeditee.core.Colour;
     28import org.expeditee.gui.DisplayController;
    2929import org.expeditee.gui.Frame;
    30 import org.expeditee.gui.FrameGraphics;
    3130import org.expeditee.gui.FrameIO;
    3231import org.expeditee.gui.MessageBay;
     
    7574        private static int _stepPause = -1;
    7675
    77         private static Color _stepColor;
     76        private static Colour _stepColor;
    7877
    7978        private static boolean _nextStatement;
     
    9392        //Have changed parameters, so it takes an Item, not just a Text item.
    9493        private static void RunJavascriptFrame(Frame frame, Item current,
    95                         boolean acceptKeyboardInput, boolean step, int pause, Color color) {
     94                        boolean acceptKeyboardInput, boolean step, int pause, Colour color) {
    9695                try {
    9796                        if (current != null) {
     
    101100                                 */
    102101                                // DisplayIO.addToBack(current.getParent());
    103                                 DisplayIO.addToBack(DisplayIO.getCurrentFrame());
     102                                DisplayController.addToBack(DisplayController.getCurrentFrame());
    104103                        } else {
    105104                                /* TODO we should not have to pass an item just to run a frame! */
     
    108107                        }
    109108
    110                         _stepColor = color == null ? Color.green : color;
    111                         _stepColor = new Color(_stepColor.getRed(), _stepColor.getGreen(),
    112                                         _stepColor.getBlue(), 50);
     109                        _stepColor = color == null ? Colour.GREEN : color;
     110                        _stepColor = new Colour(_stepColor.getRed(), _stepColor.getGreen(),
     111                                        _stepColor.getBlue(), Colour.FromComponent255(50));
    113112                        _stepPause = pause;
    114113                        _step = step;
     
    168167                FrameUtils.DisplayFrame(item.getParent().getName(), true, true);
    169168                item.setHighlightMode(HighlightMode.Normal);
    170                 item.setHighlightColor(Color.CYAN);
     169                item.setHighlightColor(Colour.CYAN);
    171170                FrameIO.SaveFrame(item.getParent());
    172171        }
     
    192191
    193192                if (_step) {
    194                         if (child != DisplayIO.getCurrentFrame()) {
    195                                 DisplayIO.setCurrentFrame(child, true);
    196                         }
    197                         DisplayIO.addToBack(child);
     193                        if (child != DisplayController.getCurrentFrame()) {
     194                                DisplayController.setCurrentFrame(child, true);
     195                        }
     196                        DisplayController.addToBack(child);
    198197                }
    199198
     
    216215                        AgentStats.ItemExecuted();
    217216                        try {
    218                                 Color oldColor = item.getBackgroundColor();
     217                                Colour oldColor = item.getBackgroundColor();
    219218                                if (_step) {
    220219                                        pause(item);
     
    226225                                        } else {
    227226                                                item.setHighlightMode(Item.HighlightMode.None);
     227                                                item.setHighlightColorToDefault();
    228228                                        }
    229229                                }
     
    233233                                                        && lastItemStatus != Status.FalseIf) {
    234234                                                if (_step) {
    235                                                         DisplayIO.removeFromBack();
     235                                                        DisplayController.removeFromBack();
    236236                                                }
    237237                                                return lastItemStatus;
     
    257257
    258258                if (_step) {
    259                         DisplayIO.removeFromBack();
    260                         if (DisplayIO.getCurrentFrame() != current.getParent())
    261                                 DisplayIO.setCurrentFrame(current.getParent(), true);
     259                        DisplayController.removeFromBack();
     260                        if (DisplayController.getCurrentFrame() != current.getParent())
     261                                DisplayController.setCurrentFrame(current.getParent(), true);
    262262                }
    263263
     
    276276                        return;
    277277
    278                 Color oldColor = item.getBackgroundColor();
     278                Colour oldColor = item.getBackgroundColor();
    279279                item.setBackgroundColor(_stepColor);
    280280                item.setHighlightMode(Item.HighlightMode.None);
     281                item.setHighlightColorToDefault();
    281282
    282283                // Make sure we are on the frame with this item
    283284                Frame parent = item.getParentOrCurrentFrame();
    284                 if (!parent.equals(DisplayIO.getCurrentFrame())) {
    285                         DisplayIO.setCurrentFrame(parent, true);
    286                 }
    287 
    288                 FrameGraphics.Repaint();
     285                if (!parent.equals(DisplayController.getCurrentFrame())) {
     286                        DisplayController.setCurrentFrame(parent, true);
     287                }
     288
     289                DisplayController.requestRefresh(true);
    289290
    290291                int timeRemaining;
     
    297298                        if (_stop) {
    298299                                item.setBackgroundColor(oldColor);
    299                                 item.setHighlightMode(HighlightMode.Normal, _stepColor);
     300                                item.setHighlightModeAndColour(HighlightMode.Normal, _stepColor);
    300301                                throw new Exception("Program terminated");
    301302                        }
     
    388389                _programsRunning++;
    389390                AgentStats.reset();
    390                 MessageBay.displayMessage("Running Javascript Program ...", Color.BLUE);
     391                MessageBay.displayMessage("Running Javascript Program ...", Colour.BLUE);
    391392        }
    392393
Note: See TracChangeset for help on using the changeset viewer.