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/apollo/gui/EditableSampledTrackGraphView.java

    r355 r1102  
    11package org.apollo.gui;
    22
    3 import java.awt.Color;
    43import java.awt.Graphics;
    54import java.awt.Graphics2D;
    65import java.awt.Point;
    7 import java.awt.Rectangle;
    86import java.awt.event.KeyEvent;
    97import java.awt.event.KeyListener;
     
    2321import org.apollo.util.TrackNameCreator;
    2422import org.apollo.widgets.SampledTrack;
     23import org.expeditee.core.Colour;
     24import org.expeditee.core.bounds.AxisAlignedBoxBounds;
     25import org.expeditee.gio.gesture.StandardGestureActions;
     26import org.expeditee.gio.swing.SwingConversions;
     27import org.expeditee.gio.swing.SwingMiscManager;
    2528import org.expeditee.gui.Browser;
    26 import org.expeditee.gui.DisplayIO;
     29import org.expeditee.gui.DisplayController;
    2730import org.expeditee.gui.Frame;
    28 import org.expeditee.gui.FrameGraphics;
    29 import org.expeditee.gui.FrameMouseActions;
    3031import org.expeditee.gui.FreeItems;
    3132import org.expeditee.items.Item;
     
    5253        private boolean selectAllOnDoubleClick = false;
    5354
    54         public static final Color SELECTION_BACKING_COLOR_SELECT_ONLY = Color.BLACK;
    55         private static final Color SELECTION_BACKING_COLOR_SELECT_AND_COPY = Color.GREEN;
     55        public static final Colour SELECTION_BACKING_COLOR_SELECT_ONLY = Colour.BLACK;
     56        private static final Colour SELECTION_BACKING_COLOR_SELECT_AND_COPY = Colour.GREEN;
    5657
    5758        private static final int SELECTION_MODE_SELECT_ONLY = 1;
     
    215216                        }
    216217                       
    217                         FrameGraphics.refresh(true);
     218                        DisplayController.requestRefresh(true);
    218219                       
    219220                }
     
    289290                        assert(copiedAudioRegion != null);
    290291                       
    291                         Frame targetFrame = DisplayIO.getCurrentFrame();
     292                        Frame targetFrame = DisplayController.getCurrentFrame();
    292293                        if (targetFrame != null) {
    293294                               
     
    307308                                assert(Browser._theBrowser != null);
    308309                               
    309                                 // A workround for getting the widget into fre space centered on cursor
     310                                // A workaround for getting the widget into free space centred on cursor
    310311                                Point p = e.getLocationOnScreen();
    311                                 SwingUtilities.convertPointFromScreen(p, Browser._theBrowser.getContentPane());
     312                                SwingUtilities.convertPointFromScreen(p, SwingMiscManager.getIfUsingSwingGraphicsManager().getContentPane());
    312313                                twidget.setPosition(p.x - (twidget.getWidth() / 2), p.y - (twidget.getHeight() / 2));
    313314
    314315                                for (Item i : twidget.getItems()) {
    315                                         i.setOffset(new Point(
    316                                                         (i.getX() - DisplayIO.getMouseX()) + (twidget.getWidth() / 2),
    317                                                         (i.getY() - FrameMouseActions.getY()) + (twidget.getHeight() / 2)
    318                                                 ));
     316                                        i.setOffset(SwingConversions.fromSwingPoint(new Point(
     317                                                        (i.getX() - DisplayController.getMouseX()) + (twidget.getWidth() / 2),
     318                                                        (i.getY() - DisplayController.getMouseY()) + (twidget.getHeight() / 2)
     319                                                )));
    319320                                }
    320321                               
    321322                                // Put the new widget into free space
    322                                 FrameMouseActions.pickup(twidget.getItems());
     323                                StandardGestureActions.pickup(twidget.getItems());
    323324
    324325                        }
     
    399400       
    400401        @Override
    401         public void paint(Graphics g) {
     402        public void paint(Graphics g)
     403        {
    402404                super.paint(g);
    403405
     
    416418                        }
    417419                       
    418                         g.setColor(Color.RED);
    419                         g.drawLine(
    420                                         x,
    421                                         0,
    422                                         x,
    423                                         getHeight());
     420                        g.setColor(SwingConversions.toSwingColor(Colour.RED));
     421                        g.drawLine(x, 0, x, getHeight());
    424422                       
    425423                }
     
    432430        private void paintLock(Graphics g) {
    433431                if (isPlaying()) {
    434                         IconRepository.getIcon("lock.png").paintIcon(null,
     432                        /*IconRepository.getIcon("lock.png").paintIcon(null,
    435433                                        g,
    436434                                        getWidth() - LOCK_ICON_CORNER_OFFSET,
    437                                         LOCK_ICON_CORNER_OFFSET - 16);
     435                                        LOCK_ICON_CORNER_OFFSET - 16);*/
     436                       
     437                        g.drawImage(SwingMiscManager.getIfUsingSwingImageManager().getInternalImage(IconRepository.getIcon("lock.png")),
     438                                        getWidth() - LOCK_ICON_CORNER_OFFSET,
     439                                        LOCK_ICON_CORNER_OFFSET - 16,
     440                                        null);
    438441                }
    439442        }
     
    442445                Point exp = getExpediteePoint();
    443446                if (exp != null) {
    444                         FrameGraphics.invalidateArea(new Rectangle(
     447                        DisplayController.invalidateArea(new AxisAlignedBoxBounds(
    445448                                        exp.x + getWidth() - LOCK_ICON_CORNER_OFFSET,
    446449                                        exp.y + LOCK_ICON_CORNER_OFFSET  - 16,
     
    505508                       
    506509                        color =  (selectionMode == SELECTION_MODE_SELECT_ONLY) ?
    507                                         SELECTION_BACKING_COLOR_SELECT_ONLY : SELECTION_BACKING_COLOR_SELECT_AND_COPY;
     510                                                SwingConversions.toSwingColor(SELECTION_BACKING_COLOR_SELECT_ONLY) :
     511                                                SwingConversions.toSwingColor(SELECTION_BACKING_COLOR_SELECT_AND_COPY);
    508512                        super.paint(g);
    509513                }
Note: See TracChangeset for help on using the changeset viewer.