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

    r1005 r1102  
    11package org.expeditee.items.widgets;
    22import java.awt.BorderLayout;
    3 import java.awt.Color;
    43import java.awt.Dimension;
    54import java.net.URL;
     
    98import javax.swing.border.EmptyBorder;
    109
     10import org.expeditee.core.Colour;
     11import org.expeditee.gio.swing.SwingConversions;
    1112import org.expeditee.items.Text;
    1213
     
    1415
    1516//Will be the default class for Rubbish Bin, Reset and Undo Button Widgets
    16 public class ButtonWidget extends InteractiveWidget{
    17 
     17public class ButtonWidget extends SwingWidget
     18{
    1819        protected JButton clicked_ = new JButton("");   
    1920        protected SVGIcon icon_ = null;
    20        
     21
    2122        public ButtonWidget(int dimension, String filePath, Text source, String[] args)
    2223        {
     
    2526                               
    2627                clicked_.setBorder(new EmptyBorder(0, 0, 0, 0));
    27                 clicked_.setBackground(Color.white);
     28                clicked_.setBackground(SwingConversions.toSwingColor(Colour.WHITE));
    2829               
    2930                Dimension size = new Dimension(dimension, dimension);
    3031                icon_ = new SVGIcon();
    31                 try{
     32               
     33                try {
    3234                        URL imageURL = ClassLoader.getSystemResource(filePath);         
    3335                        icon_.setSvgURI(imageURL.toURI());
    34                         //This STILL works, unsure why. Don't remove it has an affect on the button appearance.         
     36                        // This STILL works, unsure why. Don't remove it has an affect on the button appearance.
    3537                        icon_.setUseAntiAlias(true);
    3638                        icon_.setScaleToFit(true);
     
    3941                        _swingComponent.add(clicked_);
    4042                        this.setWidgetEdgeThickness(0.0f);
    41                         this.setWidgetEdgeColor(Color.white);   
    42                 }
    43                 catch(Exception e){
    44                        
     43                        this.setWidgetEdgeColor(Colour.WHITE); 
     44                } catch(Exception e) {
    4545                        //Set a default image if image is missing
    4646                        System.out.println("Unable to load image from directory");                     
     
    4949
    5050        @Override
    51         protected String[] getArgs() {
     51        protected String[] getArgs()
     52        {
    5253                // TODO Auto-generated method stub
    5354                return null;
    5455        }
    55         public boolean itemHeldWhileClicked(InteractiveWidget bw) {
     56       
     57        public boolean itemHeldWhileClicked(Widget bw)
     58        {
    5659                // TODO Auto-generated method stub
    5760                return false;
    5861        }
    59         public boolean getdropInteractableStatus(){
     62       
     63        public boolean getdropInteractableStatus()
     64        {
    6065                return false;
    6166        }
    6267
    6368        @Override
    64         boolean setPositions(WidgetCorner src, float x, float y) {
     69        public boolean setPositions(WidgetCorner src, float x, float y)
     70        {
    6571                boolean result = super.setPositions(src, x, y);
    6672
Note: See TracChangeset for help on using the changeset viewer.