|
24 | 24 | import java.util.List;
|
25 | 25 |
|
26 | 26 | import javax.swing.BorderFactory;
|
| 27 | +import javax.swing.ImageIcon; |
27 | 28 | import javax.swing.JFrame;
|
28 | 29 | import javax.swing.JPanel;
|
29 | 30 | import javax.swing.JSpinner;
|
|
40 | 41 | public class ColorPicker extends JPanel {
|
41 | 42 | private final JFrame owner;
|
42 | 43 |
|
| 44 | + private final ImageIcon eraserIcon = new ImageIcon(this.getClass().getResource("/net/rptools/lib/image/icons/eraser.png")); |
| 45 | + private final ImageIcon pencilIcon = new ImageIcon(this.getClass().getResource("/net/rptools/lib/image/icons/pencil.png")); |
| 46 | + private final ImageIcon roundCapIcon = new ImageIcon(this.getClass().getResource("/net/rptools/lib/image/icons/round_cap2.png")); |
| 47 | + private final ImageIcon squareCapIcon = new ImageIcon(this.getClass().getResource("/net/rptools/lib/image/icons/square_cap2.png")); |
| 48 | + private final ImageIcon snapToIcon = new ImageIcon(this.getClass().getResource("/net/rptools/lib/image/icons/shape_handles2.png")); |
| 49 | + private final ImageIcon freeDrawIcon = new ImageIcon(this.getClass().getResource("/net/rptools/lib/image/icons/freehand2.png")); |
| 50 | + |
43 | 51 | private final PaintedPanel foregroundColor;
|
44 | 52 | private final PaintedPanel backgroundColor;
|
45 | 53 | private final List<PaintedPanel> recentColors = new ArrayList<PaintedPanel>(16);
|
46 | 54 | private final JToggleButton snapToggle;
|
47 | 55 | private final JToggleButton eraseToggle;
|
| 56 | + private final JToggleButton squareCapToggle; |
48 | 57 | private final PaintChooser paintChooser;
|
49 | 58 | private final JSpinner penWidthSpinner;
|
50 | 59 | private final JSpinner transparencySpinner;
|
@@ -99,7 +108,16 @@ public ColorPicker(JFrame owner) {
|
99 | 108 | recentColors.add(paintedPanel);
|
100 | 109 | }
|
101 | 110 | snapToggle = (JToggleButton) panel.getButton("toggleSnapToGrid");
|
| 111 | + snapToggle.setIcon(freeDrawIcon); |
| 112 | + snapToggle.setSelectedIcon(snapToIcon); |
| 113 | + |
102 | 114 | eraseToggle = (JToggleButton) panel.getButton("toggleErase");
|
| 115 | + eraseToggle.setIcon(pencilIcon); |
| 116 | + eraseToggle.setSelectedIcon(eraserIcon); |
| 117 | + |
| 118 | + squareCapToggle = (JToggleButton) panel.getButton("toggelSquareCap"); |
| 119 | + squareCapToggle.setIcon(roundCapIcon); |
| 120 | + squareCapToggle.setSelectedIcon(squareCapIcon); |
103 | 121 |
|
104 | 122 | penWidthSpinner = panel.getSpinner("penWidth");
|
105 | 123 | penWidthSpinner.setModel(new SpinnerNumberModel(3, 1, maxPenWidth, 1));
|
@@ -173,6 +191,14 @@ public boolean isSnapSelected() {
|
173 | 191 | return snapToggle.isSelected();
|
174 | 192 | }
|
175 | 193 |
|
| 194 | + public boolean isSquareCapSelected() { |
| 195 | + return squareCapToggle.isSelected(); |
| 196 | + } |
| 197 | + |
| 198 | + public void setSquareCapSelected(boolean selected) { |
| 199 | + squareCapToggle.setSelected(selected); |
| 200 | + } |
| 201 | + |
176 | 202 | public void setTranslucency(int percent) {
|
177 | 203 | percent = Math.max(0, percent);
|
178 | 204 | percent = Math.min(100, percent);
|
|
0 commit comments