source: osm/applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelTop.java@ 26573

Last change on this file since 26573 was 26573, checked in by malcolmh, 13 years ago

save

File size: 6.4 KB
Line 
1package oseam.panels;
2
3import java.awt.*;
4import java.awt.event.*;
5import javax.swing.*;
6import java.util.*;
7
8import oseam.Messages;
9import oseam.dialogs.OSeaMAction;
10import oseam.seamarks.SeaMark.*;
11
12public class PanelTop extends JPanel {
13
14 private OSeaMAction dlg;
15 public PanelCol panelCol = null;
16 private ButtonGroup topButtons = new ButtonGroup();
17 public JRadioButton noTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/NoneButton.png")));
18 public JRadioButton canTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanTopButton.png")));
19 public JRadioButton coneTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeTopButton.png")));
20 public JRadioButton sphereTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereTopButton.png")));
21 public JRadioButton XTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/XTopButton.png")));
22 public JRadioButton northTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/NorthTopButton.png")));
23 public JRadioButton southTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SouthTopButton.png")));
24 public JRadioButton eastTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/EastTopButton.png")));
25 public JRadioButton westTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/WestTopButton.png")));
26 public JRadioButton spheres2TopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/Spheres2TopButton.png")));
27 public JRadioButton boardDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BoardDayButton.png")));
28 public JRadioButton diamondDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/DiamondDayButton.png")));
29 public JRadioButton triangleDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TriangleDayButton.png")));
30 public JRadioButton triangleInvDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TriangleInvDayButton.png")));
31 public JRadioButton squareDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SquareDayButton.png")));
32 public JRadioButton circleDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CircleDayButton.png")));
33 public JRadioButton mooringTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/MooringTopButton.png")));
34 private EnumMap<Top, JRadioButton> tops = new EnumMap<Top, JRadioButton>(Top.class);
35 private EnumMap<Day, JRadioButton> days = new EnumMap<Day, JRadioButton>(Day.class);
36 private ActionListener alTop = new ActionListener() {
37 public void actionPerformed(java.awt.event.ActionEvent e) {
38 for (Top top : tops.keySet()) {
39 JRadioButton button = tops.get(top);
40 if (button.isSelected()) {
41 dlg.mark.setTopmark(top);
42 dlg.mark.setDaymark(Day.NONE);
43 button.setBorderPainted(true);
44 } else
45 button.setBorderPainted(false);
46 }
47 for (Day day : days.keySet()) {
48 JRadioButton button = days.get(day);
49 if (button.isSelected()) {
50 dlg.mark.setDaymark(day);
51 dlg.mark.setTopmark(Top.NONE);
52 button.setBorderPainted(true);
53 } else
54 button.setBorderPainted(false);
55 }
56 mooringTopButton.setBorderPainted(mooringTopButton.isSelected());
57 }
58 };
59
60 public PanelTop(OSeaMAction dia) {
61 dlg = dia;
62 panelCol = new PanelCol(dlg, alTop, Ent.TOPMARK);
63 panelCol.setBounds(new Rectangle(0, 0, 34, 160));
64 this.setLayout(null);
65 this.add(panelCol, null);
66 this.add(getTopButton(noTopButton, 40, 5, 27, 27, "NoTop", Top.NONE), null);
67 this.add(getTopButton(canTopButton, 70, 5, 27, 27, "CanTop", Top.CAN), null);
68 this.add(getTopButton(coneTopButton, 100, 5, 27, 27, "ConeTop", Top.CONE), null);
69 this.add(getTopButton(sphereTopButton, 130, 5, 27, 27, "SphereTop", Top.SPHERE), null);
70 this.add(getTopButton(XTopButton, 160, 5, 27, 27, "XTop", Top.X_SHAPE), null);
71 this.add(getTopButton(northTopButton, 40, 35, 27, 27, "NorthTop", Top.NORTH), null);
72 this.add(getTopButton(southTopButton, 70, 35, 27, 27, "SouthTop", Top.SOUTH), null);
73 this.add(getTopButton(eastTopButton, 100, 35, 27, 27, "EastTop", Top.EAST), null);
74 this.add(getTopButton(westTopButton, 130, 35, 27, 27, "WestTop", Top.WEST), null);
75 this.add(getTopButton(spheres2TopButton, 160, 35, 27, 27, "Spheres2Top", Top.SPHERES2), null);
76 this.add(getDayButton(boardDayButton, 40, 65, 27, 27, "BoardDay", Day.BOARD), null);
77 this.add(getDayButton(diamondDayButton, 70, 65, 27, 27, "DiamondDay", Day.DIAMOND), null);
78 this.add(getDayButton(triangleDayButton, 100, 65, 27, 27, "TriangleDay", Day.TRIANGLE), null);
79 this.add(getDayButton(triangleInvDayButton, 130, 65, 27, 27, "TriangleInvDay", Day.TRIANGLE_INV), null);
80 this.add(getDayButton(squareDayButton, 160, 65, 27, 27, "SquareDay", Day.SQUARE), null);
81 this.add(getDayButton(circleDayButton, 160, 95, 27, 27, "CircleDay", Day.CIRCLE), null);
82 this.add(getMoorButton(mooringTopButton, 40, 95, 27, 27, "MooringTop"), null);
83 }
84
85 public void clearSelections() {
86 topButtons.clearSelection();
87 alTop.actionPerformed(null);
88 panelCol.clearSelections();
89 }
90
91 public void enableAll(boolean state) {
92 for (JRadioButton button : tops.values()) {
93 button.setEnabled(state);
94 }
95 for (JRadioButton button : days.values()) {
96 button.setEnabled(state);
97 }
98 mooringTopButton.setEnabled(state);
99 }
100
101 private JRadioButton getTopButton(JRadioButton button, int x, int y, int w, int h, String tip, Top top) {
102 button.setBounds(new Rectangle(x, y, w, h));
103 button.setBorder(BorderFactory.createLineBorder(Color.magenta, 2));
104 button.setToolTipText(Messages.getString(tip));
105 button.addActionListener(alTop);
106 topButtons.add(button);
107 tops.put(top, button);
108 return button;
109 }
110
111 private JRadioButton getDayButton(JRadioButton button, int x, int y, int w, int h, String tip, Day day) {
112 button.setBounds(new Rectangle(x, y, w, h));
113 button.setBorder(BorderFactory.createLineBorder(Color.magenta, 2));
114 button.setToolTipText(Messages.getString(tip));
115 button.addActionListener(alTop);
116 topButtons.add(button);
117 days.put(day, button);
118 return button;
119 }
120
121 private JRadioButton getMoorButton(JRadioButton button, int x, int y, int w, int h, String tip) {
122 button.setBounds(new Rectangle(x, y, w, h));
123 button.setBorder(BorderFactory.createLineBorder(Color.magenta, 2));
124 button.setToolTipText(Messages.getString(tip));
125 button.addActionListener(alTop);
126 topButtons.add(button);
127 return button;
128 }
129
130}
Note: See TracBrowser for help on using the repository browser.