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

    r1007 r1102  
    11package org.apollo.gui;
    22
     3import java.awt.BasicStroke;
    34import java.awt.Color;
    45import java.awt.Event;
     
    1011import java.awt.Point;
    1112import java.awt.Rectangle;
    12 import java.awt.Stroke;
    1313import java.awt.event.ComponentEvent;
    1414import java.awt.event.ComponentListener;
    15 import java.awt.image.BufferedImage;
    1615import java.util.LinkedList;
    1716import java.util.List;
     
    3130import org.apollo.mvc.Subject;
    3231import org.apollo.mvc.SubjectChangedEvent;
     32import org.expeditee.core.Image;
     33import org.expeditee.core.bounds.AxisAlignedBoxBounds;
     34import org.expeditee.gio.swing.SwingConversions;
     35import org.expeditee.gio.swing.SwingMiscManager;
    3336import org.expeditee.gui.Browser;
    34 import org.expeditee.gui.FrameGraphics;
     37import org.expeditee.gui.DisplayController;
    3538
    3639/**
     
    5962
    6063        private WaveFormRenderProccessingUnit.WaveFormRenderTask renderTask = null;
    61         private BufferedImage backBuffer = null; // Shared resource
     64        private Image backBuffer = null; // Shared resource
    6265        private int bufferWidth = -1; // cached from backBuffer - so don't have to lock
    6366        private int bufferHeight = -1; // cached from backBuffer - so don't have to lock
     
    6770        private int timescaleFrameLength = 0; // in frames
    6871       
    69         private final Font RENDER_MESSAGE_FONT = new Font("Arial", Font.ITALIC | Font.BOLD, 14);
     72        private final Font RENDER_MESSAGE_FONT = new Font("Arial", Font.BOLD | Font.ITALIC, 14);
    7073       
    7174        private boolean alwaysFullViewOn = false;
     
    8083       
    8184        /** The stroke used for drawing graph bars. E.G: The selection Start bar. */
    82         public static final Stroke GRAPH_BAR_STROKE = Strokes.SOLID_1;
     85        public static final BasicStroke GRAPH_BAR_STROKE = SwingConversions.toSwingStroke(Strokes.SOLID_1);
    8386        public static final int GRAPH_BAR_NWIDTH = 1;
    8487       
     
    139142                                this,
    140143                                0, 0,
    141                                 Browser._theBrowser.getContentPane());
     144                                SwingMiscManager.getIfUsingSwingGraphicsManager().getContentPane());
    142145        }
    143146       
     
    339342                               
    340343                                if (x >= 0 && x <= viewWidth) { // is the playback position in view?
    341                                         FrameGraphics.invalidateArea(new Rectangle(
     344                                        DisplayController.invalidateArea(new AxisAlignedBoxBounds(
    342345                                                x + expediteePosition.x,
    343346                                                expediteePosition.y,
     
    356359                               
    357360                                if (x >= 0 && x <= viewWidth) { // is the playback position in view?
    358                                         FrameGraphics.invalidateArea(new Rectangle(
     361                                        DisplayController.invalidateArea(new AxisAlignedBoxBounds(
    359362                                                x + expediteePosition.x ,
    360363                                                expediteePosition.y,
     
    565568               
    566569                renderTask = null; // must be on swing thread because could be painting
    567                 if (backBuffer != null) backBuffer.flush();
     570                if (backBuffer != null) backBuffer.releaseImage();
    568571                backBuffer = null; // must be on swing thread because could be painting
    569572        }
     
    605608                               
    606609                                // Create new sized buffer
    607                                 backBuffer = new BufferedImage(
     610                                backBuffer = Image.createImage(width, height);
     611/*                              backBuffer = new BufferedImage(
    608612                                                width,
    609613                                                height,
    610614                                                BufferedImage.TYPE_BYTE_INDEXED,
    611                                                 ApolloColorIndexedModels.graphIndexColorModel);
     615                                                ApolloColorIndexedModels.graphIndexColorModel);*/
    612616                        }
    613617                }
     
    624628                                );
    625629               
    626                 // Wait for invalidation recomendation messages
     630                // Wait for invalidation recommendation messages
    627631                renderTask.addObserver(this);
    628632
     
    693697                                synchronized(backBuffer) {
    694698       
    695                                         g.drawImage(backBuffer,
     699                                        g.drawImage(SwingMiscManager.getIfUsingSwingImageManager().getInternalImage(backBuffer),
    696700                                                        0,
    697701                                                        0,
    698702                                                        getWidth(),
    699                                                         getHeight(), 
     703                                                        getHeight(),
    700704                                                        null);
    701705                                       
     
    709713                                // No need to synchronize waveformBuffer because there is no thread accessing it,
    710714                                // and a new render thread is always created on this thread.
    711                                 g.drawImage(backBuffer,
     715                                g.drawImage(SwingMiscManager.getIfUsingSwingImageManager().getInternalImage(backBuffer),
    712716                                                0,
    713717                                                0,
    714718                                                getWidth(),
    715                                                 getHeight(), 
     719                                                getHeight(),
    716720                                                null);
    717721                               
     
    919923         *
    920924         */
    921         public interface EffecientInvalidator {
     925        public interface EffecientInvalidator
     926        {
    922927                public void onGraphDirty(SampledTrackGraphView graph, Rectangle dirty);
    923928        }
    924929
    925         public Color getBackColor() {
     930        public Color getBackColor()
     931        {
    926932                return backColor;
    927933        }
     
    935941         *     
    936942         */
    937         public void setBackColor(Color backColor, Color highlights) {
     943        public void setBackColor(Color backColor, Color highlights)
     944        {
    938945                setBackColor(backColor, highlights, true);
    939946        }
     
    949956         *              Doesnt invalidate if the color has not changed.
    950957         */
    951         public void setBackColor(Color backColor, Color highlights, boolean invalidate) {
     958        public void setBackColor(Color backColor, Color highlights, boolean invalidate)
     959        {
    952960                if (backColor == null) throw new NullPointerException("backColor");
    953961                if (this.backColor != backColor || backColorHighlights != highlights) {
Note: See TracChangeset for help on using the changeset viewer.