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/expeditee/items/widgets/WidgetCorner.java

    r919 r1102  
    1919package org.expeditee.items.widgets;
    2020
    21 import java.awt.Color;
    22 import java.awt.Graphics2D;
    23 import java.awt.Polygon;
    2421import java.util.List;
    2522
     23import org.expeditee.core.Colour;
     24import org.expeditee.core.Point;
     25import org.expeditee.core.bounds.PolygonBounds;
    2626import org.expeditee.items.Dot;
    2727import org.expeditee.items.ItemParentStateChangedEvent;
     
    3030public class WidgetCorner extends Dot {
    3131
    32         private InteractiveWidget _widgetSource;
    33 
    34         WidgetCorner(int x, int y, int id, InteractiveWidget widgetSource) {
     32        private Widget _widgetSource;
     33
     34        WidgetCorner(int x, int y, int id, Widget widgetSource) {
    3535                super(x, y, id);
    3636
     
    3838                        throw new NullPointerException("widgetSource");
    3939                _widgetSource = widgetSource;
    40         }
    41 
    42         @Override
    43         public void updatePolygon() {
    44                 super.updatePolygon();
    45                 if (_widgetSource != null)
    46                         _widgetSource.onBoundsChanged();
    4740        }
    4841
     
    8174
    8275        @Override
    83         public void onParentStateChanged(ItemParentStateChangedEvent e) {
     76        public void onParentStateChanged(ItemParentStateChangedEvent e)
     77        {
    8478                super.onParentStateChanged(e);
    8579                _widgetSource.onParentStateChanged(e);
    8680        }
    8781
    88         public InteractiveWidget getWidgetSource() {
     82        public Widget getWidgetSource() {
    8983                return _widgetSource;
    9084        }
    9185
    9286        @Override
    93         public void paint(Graphics2D g) {
     87        public void paint()
     88        {
    9489                // For fixed widgets, always have corner selected with connected context
    95                 HighlightMode tmp = _mode; // save mode
    96                 if (_mode == HighlightMode.Normal && _widgetSource.isFixedSize()) {
    97                         _mode = HighlightMode.Connected; // draw as connected context for
     90                HighlightMode tmp = _highlightMode; // save mode
     91                if (_highlightMode == HighlightMode.Normal && _widgetSource.isFixedSize()) {
     92                        _highlightMode = HighlightMode.Connected; // draw as connected context for
    9893                        // fixed widgets
    9994                }
    100                 super.paint(g);
    101                 _mode = tmp; // restore mode
    102         }
    103 
    104         @Override
    105         public void paintFill(Graphics2D g) {
    106                 _widgetSource.paintFill(g); // only paints a fill if floating
     95                super.paint();
     96                _highlightMode = tmp; // restore mode
     97        }
     98
     99        @Override
     100        public void paintFill() {
     101                _widgetSource.paintFill(); // only paints a fill if floating
    107102        }
    108103
     
    127122
    128123        @Override
    129         public void setArrowhead(Polygon arrow) {
     124        public void setArrowhead(PolygonBounds arrow) {
    130125        }
    131126
     
    139134
    140135        @Override
    141         public void setBackgroundColor(Color c) {
     136        public void setBackgroundColor(Colour c) {
    142137                if (_widgetSource != null) {
    143138                        super.setBackgroundColor(c);
     
    147142
    148143        @Override
    149         public void setBottomShadowColor(Color bottom) {
    150         }
    151 
    152         @Override
    153         public void setFillColor(Color c) {
     144        public void setBottomShadowColor(Colour bottom) {
     145        }
     146
     147        @Override
     148        public void setFillColor(Colour c) {
    154149        }
    155150
     
    186181        }
    187182
    188         public void setAnchorCornerX(Float anchorLeft, Float anchorRight) {
    189                 _anchorLeft = anchorLeft;
    190                 _anchorRight = anchorRight;
    191         }
    192        
    193         public void setAnchorCornerY(Float anchorTop, Float anchorBottom) {
    194                 _anchorTop = anchorTop;
    195                 _anchorBottom= anchorBottom;
    196         }
    197        
    198         @Override
    199         public void setAnchorLeft(Float anchor) {
     183        public void setAnchorCornerX(Integer anchorLeft, Integer anchorRight)
     184        {
     185                _anchoring.setLeftAnchor(anchorLeft);
     186                _anchoring.setRightAnchor(anchorRight);
     187        }
     188       
     189        public void setAnchorCornerY(Integer anchorTop, Integer anchorBottom)
     190        {
     191                _anchoring.setTopAnchor(anchorTop);
     192                _anchoring.setBottomAnchor(anchorBottom);
     193        }
     194       
     195        @Override
     196        public void setAnchorLeft(Integer anchor) {
    200197                _widgetSource.setAnchorLeft(anchor);
    201                 _anchorLeft = anchor;
    202                 _anchorRight = null;
    203         }
    204 
    205         @Override
    206         public void setAnchorRight(Float anchor) {
     198                _anchoring.setLeftAnchor(anchor);
     199        }
     200
     201        @Override
     202        public void setAnchorRight(Integer anchor) {
    207203                _widgetSource.setAnchorRight(anchor);
    208                 _anchorLeft = null;
    209                 _anchorRight = anchor;
    210         }
    211        
    212         @Override
    213         public void setAnchorTop(Float anchor) {
     204                _anchoring.setRightAnchor(anchor);
     205        }
     206       
     207        @Override
     208        public void setAnchorTop(Integer anchor) {
    214209                _widgetSource.setAnchorTop(anchor);
    215                 _anchorTop = anchor;
    216                 _anchorBottom = null;
    217         }
    218 
    219         @Override
    220         public void setAnchorBottom(Float anchor) {
     210                _anchoring.setTopAnchor(anchor);
     211        }
     212
     213        @Override
     214        public void setAnchorBottom(Integer anchor) {
    221215                _widgetSource.setAnchorBottom(anchor);
    222                 _anchorTop = null;
    223                 _anchorBottom = anchor;
     216                _anchoring.setBottomAnchor(anchor);
    224217        }
    225218       
     
    251244
    252245        @Override
    253         public boolean contains(int x, int y) {
    254                 return super.contains(x, y)
    255                                 && !_widgetSource.getBounds().contains(x, y);
     246        public boolean contains(Point p)
     247        {
     248                return super.contains(p) && !_widgetSource.getBounds().contains(p);
    256249        }
    257250
     
    268261
    269262        @Override
    270         public void setColor(Color color) {
     263        public void setColor(Colour color) {
    271264                if (_widgetSource != null) {
    272265                        super.setColor(color);
Note: See TracChangeset for help on using the changeset viewer.