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/OverdubbedFrameTimeAxis.java

    r1059 r1102  
    11package org.apollo.gui;
    2 
    3 import java.awt.BasicStroke;
    4 import java.awt.Color;
    5 import java.awt.Graphics;
    6 import java.awt.Graphics2D;
    7 import java.awt.Rectangle;
    8 import java.awt.Stroke;
    9 import java.awt.event.ComponentEvent;
    10 import java.awt.event.ComponentListener;
    11 
    12 import javax.swing.SwingUtilities;
    132
    143import org.apollo.audio.util.Timeline;
     
    165import org.apollo.mvc.Subject;
    176import org.apollo.mvc.SubjectChangedEvent;
     7import org.expeditee.core.Colour;
     8import org.expeditee.core.Dimension;
     9import org.expeditee.core.Fill;
     10import org.expeditee.core.Point;
     11import org.expeditee.core.Stroke;
     12import org.expeditee.core.bounds.AxisAlignedBoxBounds;
     13import org.expeditee.gio.EcosystemManager;
     14import org.expeditee.gio.GraphicsManager;
     15import org.expeditee.gio.InputManager.WindowEventListener;
     16import org.expeditee.gio.InputManager.WindowEventType;
    1817import org.expeditee.gui.Browser;
    19 import org.expeditee.gui.DisplayIO;
    20 import org.expeditee.gui.FrameGraphics;
    21 import org.expeditee.gui.MessageBay;
     18import org.expeditee.gui.DisplayController;
    2219
    2320/**
     
    3027
    3128        private TimeAxis timeAxis = null;
    32         private Rectangle lastInvalidated;
     29        private AxisAlignedBoxBounds lastInvalidated;
    3330        private Timeline lastTimeline = null;
    3431
     
    3633
    3734        private static final int GLOBAL_TIMELINE_HEIGHT = 30;
    38         private static final Color GLOBAL_TIMELINE_BACKCOLOR = new Color(220, 220, 220, 100);
    39         private static final Color GLOBAL_EMPTY_TIMELINE_BACKCOLOR = new Color(240, 240, 240, 100);
     35        private static final Colour GLOBAL_TIMELINE_BACKCOLOR = Colour.FromRGBA255(220, 220, 220, 100);
     36        private static final Colour GLOBAL_EMPTY_TIMELINE_BACKCOLOR = Colour.FromRGBA255(240, 240, 240, 100);
    4037       
    41         public static final Stroke TRACK_TIMELINE_STROKE = new BasicStroke(
    42                         1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL, 0.0f, new float[] { 5.0f, 5.0f }, 0.0f);
     38        public static final Stroke TRACK_TIMELINE_STROKE = new Stroke(1.0f, Stroke.CAP.SQUARE, Stroke.JOIN.BEVEL, new float[] { 5.0f, 5.0f }, 0.0f);
    4339       
    44         private static final Stroke TIMELINE_BORDER_STROKE = new BasicStroke(1.0f);
     40        private static final Stroke TIMELINE_BORDER_STROKE = new Stroke(1.0f);
    4541                       
    4642        /**
     
    5450               
    5551                // Listen for resize events
    56                 SwingUtilities.invokeLater(new Runnable() {
    57                         public void run() {
    58 
    59                                 // Keep expanded view centered to the browser window
    60                                 if (Browser._theBrowser != null) {
    61                                         Browser._theBrowser.addComponentListener(new ComponentListener() {
    62 
    63                                                 public void componentHidden(ComponentEvent e) {
    64                                                 }
    65 
    66                                                 public void componentMoved(ComponentEvent e) {
    67                                                 }
    68 
    69                                                 public void componentResized(ComponentEvent e) {
    70                                                         updateAxis();
    71                                                 }
    72 
    73                                                 public void componentShown(ComponentEvent e) {
    74                                                 }
    75                                                
    76                                         });
    77                                 }
    78                                
     52                EcosystemManager.getInputManager().addWindowEventListener(new WindowEventListener()
     53                {
     54                        @Override
     55                        public void onWindowEvent(WindowEventType type)
     56                        {
     57                                if (type == WindowEventType.WINDOW_RESIZED) updateAxis();
    7958                        }
    8059                });
     
    11392                lastTimeline = FrameLayoutDaemon.getInstance().getLastComputedTimeline();
    11493                if (lastTimeline == null ||
    115                         FrameLayoutDaemon.getInstance().getTimelineOwner() != DisplayIO.getCurrentFrame()) {
     94                        FrameLayoutDaemon.getInstance().getTimelineOwner() != DisplayController.getCurrentFrame()) {
    11695                       
    11796                        // The frame layout daemon only lays out frames once - unless the user rearranges tracks
    11897                        // on a frame then the daemon we re-calc the timeline... thus a timeline must be infferred
    11998                       
    120                         lastTimeline = FrameLayoutDaemon.inferTimeline(DisplayIO.getCurrentFrame());
     99                        lastTimeline = FrameLayoutDaemon.inferTimeline(DisplayController.getCurrentFrame());
    121100                       
    122101                        if (lastTimeline == null) { // no widgets
    123102                                if (timeAxis != null && lastInvalidated != null) {
    124                                         FrameGraphics.invalidateArea(lastInvalidated); // old position
     103                                        DisplayController.invalidateArea(lastInvalidated); // old position
    125104                                }
    126105                               
     
    141120
    142121               
    143                 Rectangle newBounds = getCurrentTimelineArea();
     122                AxisAlignedBoxBounds newBounds = getCurrentTimelineArea();
    144123                if (lastInvalidated != null && !lastInvalidated.equals(newBounds)) {
    145                         FrameGraphics.invalidateArea(lastInvalidated); // old position
     124                        DisplayController.invalidateArea(lastInvalidated); // old position
    146125                }
    147126               
    148                 FrameGraphics.invalidateArea(newBounds);
     127                DisplayController.invalidateArea(newBounds);
    149128               
    150129                lastInvalidated = newBounds;
    151130               
    152                 FrameGraphics.refresh(true);
     131                DisplayController.requestRefresh(true);
    153132               
    154133        }
    155134
    156         public Rectangle getCurrentTimelineArea() {
     135        public AxisAlignedBoxBounds getCurrentTimelineArea()
     136        {
    157137                assert(Browser._theBrowser != null);
    158                 int y = Browser._theBrowser.getContentPane().getHeight() - GLOBAL_TIMELINE_HEIGHT;
    159                 if (!FrameGraphics.isAudienceMode()) {
    160                         y -= MessageBay.MESSAGE_BUFFER_HEIGHT;
     138                int y = EcosystemManager.getGraphicsManager().getWindowSize().getHeight() - GLOBAL_TIMELINE_HEIGHT;
     139                if (!DisplayController.isAudienceMode()) {
     140                        y -= DisplayController.getMessageBayPaintArea().getHeight();
    161141                }
    162142               
    163143                if (y < 0) y = 0;
    164144
    165                 return new Rectangle(0, y, Browser._theBrowser.getContentPane().getWidth(), GLOBAL_TIMELINE_HEIGHT);
     145                return new AxisAlignedBoxBounds(0, y, EcosystemManager.getGraphicsManager().getWindowSize().getWidth(), GLOBAL_TIMELINE_HEIGHT);
    166146        }
    167147       
    168148
    169         public void paint(Graphics g) {
     149        public void paint()
     150        {
    170151                if (Browser._theBrowser == null) return;
    171152
    172153                if (timeAxis != null && lastTimeline != null) {
    173154               
    174                         Rectangle r = getCurrentTimelineArea();
    175 
    176                         g.setColor(GLOBAL_EMPTY_TIMELINE_BACKCOLOR);
    177                         g.fillRect(0, r.y, Browser._theBrowser.getContentPane().getWidth(), r.height);
     155                        GraphicsManager gm = EcosystemManager.getGraphicsManager();
    178156                       
    179                         timeAxis.paint(g,
     157                        AxisAlignedBoxBounds r = getCurrentTimelineArea();
     158                        gm.drawRectangle(new Point(0, r.getMinY()), new Dimension(EcosystemManager.getGraphicsManager().getWindowSize().getWidth(), r.getHeight()), 0.0, new Fill(GLOBAL_EMPTY_TIMELINE_BACKCOLOR), null, null, null);
     159                       
     160                        timeAxis.paint(
    180161                                        lastTimeline.getInitiationXPixel(),
    181                                         r.y,
    182                                         r.height,
     162                                        r.getMinY(),
     163                                        r.getHeight(),
    183164                                        GLOBAL_TIMELINE_BACKCOLOR);
    184165                       
    185                        
    186                         g.setColor(Color.DARK_GRAY);
    187                        
    188                         ((Graphics2D)g).setStroke(TIMELINE_BORDER_STROKE);
    189                         g.drawLine(0, r.y, Browser._theBrowser.getContentPane().getWidth(), r.y);
     166                        gm.drawLine(new Point(0, r.getMinY()), new Point(EcosystemManager.getGraphicsManager().getWindowSize().getWidth(), r.getMinY()), Colour.DARK_GREY, TIMELINE_BORDER_STROKE);
    190167       
    191168                }
Note: See TracChangeset for help on using the changeset viewer.