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

    r489 r1102  
    11package org.apollo.items;
    2 
    3 import java.awt.Color;
    4 import java.awt.GradientPaint;
    5 import java.awt.Graphics2D;
    6 import java.awt.Paint;
    7 import java.awt.Polygon;
    8 import java.awt.Stroke;
    92
    103import org.apollo.ApolloSystem;
     
    2417import org.apollo.util.ODFrameHeirarchyFetcher.ODFrameReceiver;
    2518import org.apollo.widgets.FramePlayer;
     19import org.expeditee.core.Colour;
     20import org.expeditee.core.Dimension;
     21import org.expeditee.core.Fill;
     22import org.expeditee.core.GradientFill;
     23import org.expeditee.core.Point;
     24import org.expeditee.core.Stroke;
     25import org.expeditee.core.bounds.AxisAlignedBoxBounds;
     26import org.expeditee.core.bounds.Bounds;
     27import org.expeditee.gio.EcosystemManager;
     28import org.expeditee.gio.GraphicsManager;
    2629import org.expeditee.gui.Browser;
    27 import org.expeditee.gui.DisplayIO;
     30import org.expeditee.gui.DisplayController;
    2831import org.expeditee.gui.Frame;
    2932import org.expeditee.gui.FrameIO;
     
    4346        private static int WIDTH = 80;
    4447        private static int HEIGHT = 80;
    45         private static Stroke BORDER_STOKE = Strokes.SOLID_1;
    46        
    47         private static final Color BASE_COLOR = new Color(60, 148, 255);
    48         private static final Color HIGHLIGHT_COLOR = new Color(253, 255, 201);
     48        private static Stroke BORDER_STROKE = Strokes.SOLID_1;
     49       
     50        private static final Colour BASE_COLOR = Colour.FromRGB255(60, 148, 255);
     51        private static final Colour HIGHLIGHT_COLOR = Colour.FromRGB255(253, 255, 201);
    4952       
    5053        private String frameToPlay = null;
     
    7477
    7578        @Override
    76         public void paint(Graphics2D g) {
     79        public void paint()
     80        {
    7781                if (Browser._theBrowser == null) return;
    7882               
    79                 Paint restore = g.getPaint();
    80                
     83                GraphicsManager g = EcosystemManager.getGraphicsManager();
     84               
     85                Fill fill = null;
    8186                if (ApolloSystem.useQualityGraphics) {
    82                         GradientPaint gp = new GradientPaint(
    83                                         _x + (WIDTH / 2), _y, HIGHLIGHT_COLOR,
    84                                         _x + (WIDTH / 2), _y + HEIGHT - (HEIGHT / 5), BASE_COLOR);
    85                         g.setPaint(gp);
     87                        Point fromPoint = new Point(_x + (WIDTH / 2), _y);
     88                        Point toPoint = new Point(_x + (WIDTH / 2), _y + HEIGHT - (HEIGHT / 5));
     89                        fill = new GradientFill(HIGHLIGHT_COLOR, fromPoint, BASE_COLOR, toPoint);
    8690                } else {
    87                         g.setColor(BASE_COLOR);
    88                 }
    89                
    90                 g.fillRect((int)_x, (int)_y, WIDTH, HEIGHT);
    91                
    92                 g.setPaint(restore);
    93                
    94                 g.setColor(Color.BLACK);
    95                 g.setStroke(BORDER_STOKE);
    96                 g.drawRect((int)_x, (int)_y, WIDTH, HEIGHT);
    97                
    98                 IconRepository.getIcon("frameplay.png").paintIcon(
    99                                 Browser._theBrowser.getContentPane(), g, getX() + 25, getY() + 25);
     91                        fill = new Fill(BASE_COLOR);
     92                }
     93
     94                Point topLeft = new Point((int)_x, (int)_y);
     95                Dimension size = new Dimension(WIDTH, HEIGHT);
     96                g.drawRectangle(topLeft, size, 0.0, fill, Colour.BLACK, BORDER_STROKE, null);
     97               
     98                /*IconRepository.getIcon("frameplay.png").paintIcon(
     99                                Browser._theBrowser.getContentPane(), g, getX() + 25, getY() + 25);*/
     100               
     101                g.drawImage(IconRepository.getIcon("frameplay.png"), new Point(getX() + 25, getY() + 25));
    100102               
    101103        }
     
    117119
    118120        @Override
    119         public void updatePolygon() {
    120                
    121                 _poly = new Polygon();
    122 
    123                 int x = (int)_x;
    124                 int y = (int)_y;
    125                
    126                 _poly.addPoint(x, y);
    127                 _poly.addPoint(x + WIDTH, y);
    128                 _poly.addPoint(x + WIDTH, y + HEIGHT);
    129                 _poly.addPoint(x, y + HEIGHT);
    130 
     121        public Bounds updateBounds()
     122        {
     123                return new AxisAlignedBoxBounds((int) _x, (int) _y, WIDTH, HEIGHT);
    131124        }
    132125
     
    148141        }
    149142       
    150         private void selfDestruct() {
    151                
     143        private void selfDestruct()
     144        {
    152145                Frame parent = getParent();
    153146                parent.removeItem(this);
    154147               
    155                 if (DisplayIO.getCurrentFrame() == null) return;
     148                if (DisplayController.getCurrentFrame() == null) return;
    156149               
    157150                Frame audioFrame = null;
    158151               
    159152                // Flag as null if frame to play is actually current frame
    160                 if (frameToPlay != null && frameToPlay.equals(DisplayIO.getCurrentFrame().getName()))
     153                if (frameToPlay != null && frameToPlay.equals(DisplayController.getCurrentFrame().getName()))
    161154                        frameToPlay = null;
    162155               
    163156                if (frameToPlay == null) {
    164                         audioFrame = DisplayIO.getCurrentFrame();
     157                        audioFrame = DisplayController.getCurrentFrame();
    165158                } else {
    166159                        audioFrame = FrameIO.LoadFrame(frameToPlay);
     
    199192                        } else {
    200193                                // Fetch the audio graph for the frame
    201                                 GraphReceiver receiver = new GraphReceiver(DisplayIO.getCurrentFrame());
     194                                GraphReceiver receiver = new GraphReceiver(DisplayController.getCurrentFrame());
    202195                                ODFrameHeirarchyFetcher.getInstance().doFetch(audioFrame.getName(), receiver);
    203196                                // The callback will later begin playback
     
    257250                                // Thus the start frame will be hence taken as a percentage of the whole frame
    258251                               
    259                                 float percent = _x / Browser._theBrowser.getContentPane().getWidth();
     252                                float percent = _x / EcosystemManager.getGraphicsManager().getWindowSize().getWidth();
    260253                                if (percent < 0) percent = 0;
    261254                                if (percent > 1) percent = 1;
Note: See TracChangeset for help on using the changeset viewer.