Skip to content

Commit dcfed5d

Browse files
Merge pull request #94 from UCSDOalads/XYGBranch
Add Functionality Buttons on the Tool Bar
2 parents df0e0d7 + f81ad2e commit dcfed5d

5 files changed

Lines changed: 375 additions & 8 deletions

File tree

src/painttools/toolbar/ToolBar.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,45 @@
11
package painttools.toolbar;
22

3-
import java.awt.Button;
4-
import java.awt.Component;
5-
import java.awt.Graphics;
63
import java.awt.event.ActionEvent;
74
import java.awt.event.ActionListener;
85
import java.util.ArrayList;
96

107
import javax.swing.BoxLayout;
11-
import javax.swing.Icon;
128
import javax.swing.JButton;
139
import javax.swing.JPanel;
14-
import javax.tools.Tool;
1510

1611
import painttools.tools.*;
12+
13+
1714
import ui.PaintPanel;
1815

1916
public class ToolBar extends JPanel {
2017

2118
public ArrayList<ToolBarListener> listeners;
2219
private SelectTool selectTool;
23-
20+
private PaintPanel panel;
21+
2422
/**
2523
* Creates a default toolbar and add necessary tools
2624
*/
2725
public ToolBar(PaintPanel panel) {
2826
listeners = new ArrayList<>();
27+
this.panel = panel;
2928

3029
//sets the box layout
3130
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
3231

3332
selectTool = new SelectTool(panel);
3433
addTool(new DotTool());
3534
addTool(selectTool);
35+
36+
37+
addTool(new AddClassTool(panel));
38+
addTool(new AddInputBoxTool(panel));
39+
addTool(new AddOutputBoxTool(panel));
40+
3641
addTool(new LineTool());
42+
3743
}
3844

3945
/**
@@ -75,7 +81,6 @@ private void select(PaintTool tool) {
7581
public SelectTool getSelectTool() {
7682
return selectTool;
7783
}
78-
7984

80-
85+
8186
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package painttools.tools;
2+
3+
import java.awt.event.ActionEvent;
4+
import java.awt.event.ActionListener;
5+
import java.awt.event.MouseEvent;
6+
7+
import javax.swing.JButton;
8+
9+
import actions.AddLazyJavaClassAction;
10+
import ui.PaintPanel;
11+
12+
public class AddClassTool extends PaintTool {
13+
14+
private JButton button;
15+
16+
public AddClassTool(PaintPanel panel) {
17+
button = new JButton("Add Class");
18+
19+
AddLazyJavaClassAction action = new AddLazyJavaClassAction(panel);
20+
21+
button.addActionListener(new ActionListener() {
22+
@Override
23+
public void actionPerformed(ActionEvent e) {
24+
25+
if (action.canPerformAction()) {
26+
action.performAction();
27+
}
28+
29+
}
30+
});
31+
}
32+
33+
@Override
34+
public void start(PaintPanel panel) {
35+
}
36+
37+
@Override
38+
public JButton getButton() {
39+
return button;
40+
}
41+
42+
@Override
43+
public void reset() {
44+
45+
}
46+
47+
@Override
48+
public void mouseClicked(MouseEvent e) {
49+
// TODO Auto-generated method stub
50+
51+
}
52+
53+
@Override
54+
public void mouseEntered(MouseEvent e) {
55+
// TODO Auto-generated method stub
56+
57+
}
58+
59+
@Override
60+
public void mouseExited(MouseEvent e) {
61+
// TODO Auto-generated method stub
62+
63+
}
64+
65+
@Override
66+
public void mousePressed(MouseEvent e) {
67+
// TODO Auto-generated method stub
68+
69+
}
70+
71+
@Override
72+
public void mouseReleased(MouseEvent e) {
73+
// TODO Auto-generated method stub
74+
75+
}
76+
77+
@Override
78+
public void mouseDragged(MouseEvent e) {
79+
// TODO Auto-generated method stub
80+
81+
}
82+
83+
@Override
84+
public void mouseMoved(MouseEvent e) {
85+
// TODO Auto-generated method stub
86+
87+
}
88+
89+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package painttools.tools;
2+
3+
import java.awt.event.ActionEvent;
4+
import java.awt.event.ActionListener;
5+
import java.awt.event.MouseEvent;
6+
7+
import javax.swing.JButton;
8+
9+
import ui.PaintPanel;
10+
import actions.AddDataInputBoxAction;
11+
12+
public class AddInputBoxTool extends PaintTool {
13+
14+
private JButton button;
15+
16+
public AddInputBoxTool(PaintPanel panel) {
17+
button = new JButton("Add Input Box");
18+
19+
AddDataInputBoxAction action = new AddDataInputBoxAction(panel);
20+
21+
button.addActionListener(new ActionListener() {
22+
@Override
23+
public void actionPerformed(ActionEvent e) {
24+
25+
if (action.canPerformAction()) {
26+
action.performAction();
27+
}
28+
29+
}
30+
});
31+
}
32+
33+
34+
@Override
35+
public void start(PaintPanel panel) {
36+
}
37+
38+
@Override
39+
public JButton getButton() {
40+
return button;
41+
}
42+
43+
@Override
44+
public void reset() {
45+
46+
}
47+
48+
@Override
49+
public void mouseClicked(MouseEvent e) {
50+
// TODO Auto-generated method stub
51+
52+
}
53+
54+
@Override
55+
public void mouseEntered(MouseEvent e) {
56+
// TODO Auto-generated method stub
57+
58+
}
59+
60+
@Override
61+
public void mouseExited(MouseEvent e) {
62+
// TODO Auto-generated method stub
63+
64+
}
65+
66+
@Override
67+
public void mousePressed(MouseEvent e) {
68+
// TODO Auto-generated method stub
69+
70+
}
71+
72+
@Override
73+
public void mouseReleased(MouseEvent e) {
74+
// TODO Auto-generated method stub
75+
76+
}
77+
78+
@Override
79+
public void mouseDragged(MouseEvent e) {
80+
// TODO Auto-generated method stub
81+
82+
}
83+
84+
@Override
85+
public void mouseMoved(MouseEvent e) {
86+
// TODO Auto-generated method stub
87+
88+
}
89+
90+
91+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package painttools.tools;
2+
3+
import java.awt.event.ActionEvent;
4+
import java.awt.event.ActionListener;
5+
import java.awt.event.MouseEvent;
6+
7+
import javax.swing.JButton;
8+
9+
import ui.PaintPanel;
10+
import actions.AddLazyJavaMethodComponentAction;
11+
12+
public class AddMethodTool extends PaintTool {
13+
14+
private JButton button;
15+
16+
public AddMethodTool(PaintPanel panel) {
17+
button = new JButton("Add Method");
18+
19+
AddLazyJavaMethodComponentAction action = new AddLazyJavaMethodComponentAction(panel);
20+
21+
button.addActionListener(new ActionListener() {
22+
@Override
23+
public void actionPerformed(ActionEvent e) {
24+
25+
if (action.canPerformAction()) {
26+
action.performAction();
27+
}
28+
29+
}
30+
});
31+
}
32+
33+
34+
@Override
35+
public void start(PaintPanel panel) {
36+
}
37+
38+
@Override
39+
public JButton getButton() {
40+
return button;
41+
}
42+
43+
@Override
44+
public void reset() {
45+
46+
}
47+
48+
@Override
49+
public void mouseClicked(MouseEvent e) {
50+
// TODO Auto-generated method stub
51+
52+
}
53+
54+
@Override
55+
public void mouseEntered(MouseEvent e) {
56+
// TODO Auto-generated method stub
57+
58+
}
59+
60+
@Override
61+
public void mouseExited(MouseEvent e) {
62+
// TODO Auto-generated method stub
63+
64+
}
65+
66+
@Override
67+
public void mousePressed(MouseEvent e) {
68+
// TODO Auto-generated method stub
69+
70+
}
71+
72+
@Override
73+
public void mouseReleased(MouseEvent e) {
74+
// TODO Auto-generated method stub
75+
76+
}
77+
78+
@Override
79+
public void mouseDragged(MouseEvent e) {
80+
// TODO Auto-generated method stub
81+
82+
}
83+
84+
@Override
85+
public void mouseMoved(MouseEvent e) {
86+
// TODO Auto-generated method stub
87+
88+
}
89+
90+
91+
}

0 commit comments

Comments
 (0)