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/items/widgets/JfxBrowser.java

    r1060 r1102  
    7676import netscape.javascript.JSObject;
    7777
    78 import org.expeditee.gui.DisplayIO;
    79 import org.expeditee.gui.FrameMouseActions;
     78import org.expeditee.gio.gesture.StandardGestureActions;
     79import org.expeditee.gio.swing.SwingConversions;
     80import org.expeditee.gui.DisplayController;
    8081import org.expeditee.gui.FreeItems;
    8182import org.expeditee.gui.MessageBay;
     
    468469                                public void handle(KeyEvent e) {
    469470                                        // Hiding the cursor when typing, to be more Expeditee-like
    470                                         DisplayIO.setCursor(org.expeditee.items.Item.HIDDEN_CURSOR);
     471                                        DisplayController.setCursor(org.expeditee.items.Item.HIDDEN_CURSOR);
    471472                                }
    472473                        });
     
    481482                                        }
    482483                                        // Checking if the user has been typing - if so, move the cursor to the caret position
    483                                         if (DisplayIO.getCursor() == Item.HIDDEN_CURSOR) {
    484                                                 DisplayIO.setCursor(org.expeditee.items.Item.TEXT_CURSOR);
    485                                                 DisplayIO.setCursorPosition(getCoordFromCaret(JfxBrowser.this._urlField));
     484                                        if (DisplayController.getCursor() == Item.HIDDEN_CURSOR) {
     485                                                DisplayController.setCursor(org.expeditee.items.Item.TEXT_CURSOR);
     486                                                DisplayController.setCursorPosition(SwingConversions.fromSwingPoint(getCoordFromCaret(JfxBrowser.this._urlField)));
    486487                                        } else {
    487488                                                // Otherwise, move the caret to the cursor location
     
    523524                public void changed(ObservableValue<? extends Boolean> property, Boolean oldValue, Boolean newValue) {
    524525                                        if(newValue.booleanValue()) {
    525                                                 DisplayIO.setCursor(org.expeditee.items.Item.TEXT_CURSOR);
     526                                                DisplayController.setCursor(org.expeditee.items.Item.TEXT_CURSOR);
    526527                                        } else {
    527528                                                // Restoring the standard cursor, since it is changed to a text cursor when focus is gained
    528                                                 DisplayIO.setCursor(org.expeditee.items.Item.DEFAULT_CURSOR);
     529                                                DisplayController.setCursor(org.expeditee.items.Item.DEFAULT_CURSOR);
    529530                                        }
    530531                }
     
    545546                                        if (e.getButton() == MouseButton.SECONDARY) {
    546547                                                // Right mouse button released, so copy the selection (i.e. don't remove the original)
    547                                                 item = DisplayIO.getCurrentFrame().createNewText(JfxBrowser.this._urlField.getSelectedText());
    548                                                 FrameMouseActions.pickup(item);
     548                                                item = DisplayController.getCurrentFrame().createNewText(JfxBrowser.this._urlField.getSelectedText());
     549                                                StandardGestureActions.pickup(item);
    549550                                        } else if (e.getButton() == MouseButton.MIDDLE) {
    550551                                                // Middle mouse button released, so copy the selection then remove it from the URL field
    551                                                 item = DisplayIO.getCurrentFrame().createNewText(JfxBrowser.this._urlField.getSelectedText());
     552                                                item = DisplayController.getCurrentFrame().createNewText(JfxBrowser.this._urlField.getSelectedText());
    552553                                                JfxBrowser.this._urlField.setText(
    553554                                                                JfxBrowser.this._urlField.getText().substring(0, JfxBrowser.this._urlField.getSelection().getStart())
     
    555556                                                                                JfxBrowser.this._urlField.getText().length()));
    556557
    557                                                 FrameMouseActions.pickup(item);
     558                                                StandardGestureActions.pickup(item);
    558559                                        }
    559560                }
     
    660661                                                                       
    661662                                                                        if (((String) style.call("getPropertyValue", new Object[] { "background-image" })).startsWith("url(")) {
    662                                                                                 pic = WebParser.getBackgroundImageFromNode(node, style, DisplayIO.getCurrentFrame(), null,
    663                                                                                         (float) FrameMouseActions.getX(), (float) FrameMouseActions.getY(), width, height);
     663                                                                                pic = WebParser.getBackgroundImageFromNode(node, style, DisplayController.getCurrentFrame(), null,
     664                                                                                        (float) DisplayController.getMouseX(), (float) DisplayController.getMouseY(), width, height);
    664665                                                                               
    665666                                                                        } else {
     
    667668                                                                                if(node.getNodeName().toLowerCase().equals("img") &&
    668669                                                                                                (imgSrc = ((JSObject) node).getMember("src").toString()) != null) {
    669                                                                                         pic = WebParser.getImageFromUrl(imgSrc, null, DisplayIO.getCurrentFrame(),
    670                                                                                                         (float) FrameMouseActions.getX(), (float) FrameMouseActions.getY(), (int) width, null, null, null, null, null, 0, 0);
     670                                                                                        pic = WebParser.getImageFromUrl(imgSrc, null, DisplayController.getCurrentFrame(),
     671                                                                                                        (float) DisplayController.getMouseX(), (float) DisplayController.getMouseY(), (int) width, null, null, null, null, null, 0, 0);
    671672                                                                                } else {
    672673                                                                                        return;
     
    685686                                                                        }
    686687                                                                       
    687                                                                         pic.setXY(FrameMouseActions.getX(), FrameMouseActions.getY());
    688                                                 FrameMouseActions.pickup(pic);
     688                                                                        pic.setXY(DisplayController.getMouseX(), DisplayController.getMouseY());
     689                                                StandardGestureActions.pickup(pic);
    689690                                        } catch (Exception e1) {
    690691                                        // TODO Auto-generated catch block
     
    714715                                                                                        + ((JSObject)node).getMember("height")
    715716                                                                                        + ":" + src);
    716                                                                         t.setParent(DisplayIO.getCurrentFrame());
    717                                                                         t.setXY(FrameMouseActions.getX(), FrameMouseActions.getY());
     717                                                                        t.setParent(DisplayController.getCurrentFrame());
     718                                                                        t.setXY(DisplayController.getMouseX(), DisplayController.getMouseY());
    718719                                                                        JfxMedia media = new JfxMedia(t, new String[] { src });
    719                                                                         FrameMouseActions.pickup(media.getItems());
     720                                                                        StandardGestureActions.pickup(media.getItems());
    720721                                                                       
    721722                                                                } else if(node.getNodeName().toLowerCase().equals("a") && ((JSObject)node).getMember("href") != null) {
    722723                                                                        // If a link is right clicked, copy the text content and give it an action to create
    723724                                                                        // a new frame containing a browser pointing to the linked page
    724                                                                         Text t = DisplayIO.getCurrentFrame().createNewText(((String) ((JSObject)node).getMember("textContent")).trim());
     725                                                                        Text t = DisplayController.getCurrentFrame().createNewText(((String) ((JSObject)node).getMember("textContent")).trim());
    725726                                                                        t.addAction("createFrameWithBrowser " + (String) ((JSObject)node).getMember("href"));
    726                                                                         t.setXY(FrameMouseActions.getX(), FrameMouseActions.getY());
    727                                                                         FrameMouseActions.pickup(t);
     727                                                                        t.setXY(DisplayController.getMouseX(), DisplayController.getMouseY());
     728                                                                        StandardGestureActions.pickup(t);
    728729                                                                }
    729730                                                        }
    730731                                                } else {
    731732                                                        // Copy text and attach to cursor
    732                                                         Text t = DisplayIO.getCurrentFrame().createNewText(selection);
    733                                                         t.setXY(FrameMouseActions.getX(), FrameMouseActions.getY());
    734                                                         FrameMouseActions.pickup(t);
     733                                                        Text t = DisplayController.getCurrentFrame().createNewText(selection);
     734                                                        t.setXY(DisplayController.getMouseX(), DisplayController.getMouseY());
     735                                                        StandardGestureActions.pickup(t);
    735736                                                }
    736737                                        }
     
    871872        public void getFrame() {
    872873                try {
    873                         WebParser.parsePageSimple(this, _webEngine, _webView, DisplayIO.getCurrentFrame());
     874                        WebParser.parsePageSimple(this, _webEngine, _webView, DisplayController.getCurrentFrame());
    874875                } catch (Exception e) {
    875876                        e.printStackTrace();
     
    886887                        new Thread(new Runnable() {
    887888                                public void run() {
    888                                         WebParser.parsePageSimple(JfxBrowser.this, JfxBrowser.this._webEngine, JfxBrowser.this._webView, DisplayIO.getCurrentFrame());
     889                                        WebParser.parsePageSimple(JfxBrowser.this, JfxBrowser.this._webEngine, JfxBrowser.this._webView, DisplayController.getCurrentFrame());
    889890                                }
    890891                        }).start();
     
    954955                }
    955956
    956                 final int x = FrameMouseActions.getX() - this.getX(), y = FrameMouseActions.getY() - this.getY();
     957                final int x = DisplayController.getMouseX() - this.getX(), y = DisplayController.getMouseY() - this.getY();
    957958                if(!this._urlField.getBoundsInParent().contains(x, y)) {
    958959                        // fails if not clicking on urlField
Note: See TracChangeset for help on using the changeset viewer.