1 | package org.expeditee.items.widgets;
|
---|
2 | import java.awt.BorderLayout;
|
---|
3 | import java.awt.Color;
|
---|
4 | import java.awt.Dimension;
|
---|
5 | import java.io.File;
|
---|
6 | import java.net.URL;
|
---|
7 |
|
---|
8 | import javax.swing.JButton;
|
---|
9 | import javax.swing.JPanel;
|
---|
10 | import javax.swing.border.EmptyBorder;
|
---|
11 | import org.expeditee.items.Text;
|
---|
12 | import com.kitfox.svg.app.beans.SVGIcon;
|
---|
13 |
|
---|
14 | //Will be the default class for Rubbish Bin, Reset and Undo Button Widgets
|
---|
15 | public class ButtonWidget extends InteractiveWidget{
|
---|
16 |
|
---|
17 | JButton clicked = new JButton("");
|
---|
18 |
|
---|
19 | public ButtonWidget(int dimension, String filePath, Text source, String[] args)
|
---|
20 | {
|
---|
21 | //Controls how the widget is displayed
|
---|
22 | super(source, new JPanel(new BorderLayout()), 80, 80, 80, 80);
|
---|
23 |
|
---|
24 | clicked.setBorder(new EmptyBorder(0, 0, 0, 0));
|
---|
25 | clicked.setBackground(Color.white);
|
---|
26 |
|
---|
27 | SVGIcon icon = null;
|
---|
28 | Dimension size = new Dimension(dimension, dimension);
|
---|
29 | icon = new SVGIcon();
|
---|
30 | try{
|
---|
31 | URL imageURL = ClassLoader.getSystemResource(filePath);
|
---|
32 | icon.setSvgURI(imageURL.toURI());
|
---|
33 | //This STILL works, unsure why. Don't remove it has an affect on the button appearance.
|
---|
34 | icon.setUseAntiAlias(true);
|
---|
35 | icon.setScaleToFit(true);
|
---|
36 | icon.setPreferredSize(size);
|
---|
37 | clicked.setIcon(icon);
|
---|
38 | _swingComponent.add(clicked);
|
---|
39 | this.setWidgetEdgeThickness(0.0f);
|
---|
40 | this.setWidgetEdgeColor(Color.white);
|
---|
41 | }
|
---|
42 | catch(Exception e){
|
---|
43 |
|
---|
44 | //Set a default image if image is missing
|
---|
45 | System.out.println("Unable to load image from directory");
|
---|
46 | }
|
---|
47 | }
|
---|
48 |
|
---|
49 | @Override
|
---|
50 | protected String[] getArgs() {
|
---|
51 | // TODO Auto-generated method stub
|
---|
52 | return null;
|
---|
53 | }
|
---|
54 | public boolean itemHeldWhileClicked(InteractiveWidget bw) {
|
---|
55 | // TODO Auto-generated method stub
|
---|
56 | return false;
|
---|
57 | }
|
---|
58 | public boolean getdropInteractableStatus(){
|
---|
59 | return false;
|
---|
60 | }
|
---|
61 |
|
---|
62 | }
|
---|