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/RecordOverdubLauncher.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;
     
    125import org.apollo.io.IconRepository;
    136import org.apollo.widgets.SampleRecorder;
     7import org.expeditee.core.Colour;
     8import org.expeditee.core.Dimension;
     9import org.expeditee.core.Fill;
     10import org.expeditee.core.GradientFill;
     11import org.expeditee.core.Point;
     12import org.expeditee.core.Stroke;
     13import org.expeditee.core.bounds.AxisAlignedBoxBounds;
     14import org.expeditee.core.bounds.Bounds;
     15import org.expeditee.gio.EcosystemManager;
     16import org.expeditee.gio.GraphicsManager;
    1417import org.expeditee.gui.Browser;
    15 import org.expeditee.gui.DisplayIO;
     18import org.expeditee.gui.DisplayController;
    1619import org.expeditee.gui.Frame;
    1720import org.expeditee.items.Item;
     
    2326                private static int WIDTH = 80;
    2427                private static int HEIGHT = 80;
    25                 private static Stroke BORDER_STOKE = Strokes.SOLID_1;
     28                private static Stroke BORDER_STROKE = Strokes.SOLID_1;
    2629                private int countdown;
    2730               
    28                 private static final Color BASE_COLOR = new Color(255, 100, 100);
    29                 private static final Color HIGHLIGHT_COLOR = new Color(253, 255, 201);
     31                private static final Colour BASE_COLOR = Colour.FromRGB255(255, 100, 100);
     32                private static final Colour HIGHLIGHT_COLOR = Colour.FromRGB255(253, 255, 201);
    3033               
    3134                public RecordOverdubLauncher(int countdown) {
     
    4952
    5053                @Override
    51                 public void paint(Graphics2D g) {
     54                public void paint() {
    5255                        if (Browser._theBrowser == null) return;
    5356                       
    54                         Paint restore = g.getPaint();
     57                        GraphicsManager g = EcosystemManager.getGraphicsManager();
    5558                       
     59                        Fill fill = null;
    5660                        if (ApolloSystem.useQualityGraphics) {
    57                                 GradientPaint gp = new GradientPaint(
    58                                                 _x + (WIDTH / 2), _y, HIGHLIGHT_COLOR,
    59                                                 _x + (WIDTH / 2), _y + HEIGHT - (HEIGHT / 5), BASE_COLOR);
    60                                 g.setPaint(gp);
     61                                Point fromPoint = new Point(_x + (WIDTH / 2), _y);
     62                                Point toPoint = new Point(_x + (WIDTH / 2), _y + HEIGHT - (HEIGHT / 5));
     63                                fill = new GradientFill(HIGHLIGHT_COLOR, fromPoint, BASE_COLOR, toPoint);
    6164                        } else {
    62                                 g.setColor(BASE_COLOR);
     65                                fill = new Fill(BASE_COLOR);
    6366                        }
    6467                       
    65                         g.fillRect((int)_x, (int)_y, WIDTH, HEIGHT);
     68                        Point topLeft = new Point((int)_x, (int)_y);
     69                        Dimension size = new Dimension(WIDTH, HEIGHT);
     70                        g.drawRectangle(topLeft, size, 0.0, fill, Colour.BLACK, BORDER_STROKE, null);
    6671                       
    67                         g.setPaint(restore);
     72                        /*IconRepository.getIcon("recordplay.png").paintIcon(
     73                                        Browser._theBrowser.getContentPane(), g, getX() + 25, getY() + 25);*/
    6874                       
    69                         g.setColor(Color.BLACK);
    70                         g.setStroke(BORDER_STOKE);
    71                         g.drawRect((int)_x, (int)_y, WIDTH, HEIGHT);
    72                        
    73                         IconRepository.getIcon("recordplay.png").paintIcon(
    74                                         Browser._theBrowser.getContentPane(), g, getX() + 25, getY() + 25);
     75                        g.drawImage(IconRepository.getIcon("recordplay.png"), new Point(getX() + 25, getY() + 25));
    7576                       
    7677                }
     
    9293
    9394                @Override
    94                 public void updatePolygon() {
    95                        
    96                         _poly = new Polygon();
    97 
    98                         int x = (int)_x;
    99                         int y = (int)_y;
    100                        
    101                         _poly.addPoint(x, y);
    102                         _poly.addPoint(x + WIDTH, y);
    103                         _poly.addPoint(x + WIDTH, y + HEIGHT);
    104                         _poly.addPoint(x, y + HEIGHT);
    105 
     95                public Bounds updateBounds()
     96                {
     97                        return new AxisAlignedBoxBounds((int) _x, (int) _y, WIDTH, HEIGHT);
    10698                }
    10799
     
    128120                        parent.removeItem(this);
    129121                       
    130                         Frame currentFrame = DisplayIO.getCurrentFrame();
     122                        Frame currentFrame = DisplayController.getCurrentFrame();
    131123                       
    132124                        if (currentFrame != null) {
Note: See TracChangeset for help on using the changeset viewer.