source: osm/applications/editors/josm/plugins/smed/src/panels/PanelTop.java@ 32542

Last change on this file since 32542 was 30738, checked in by donvip, 10 years ago

[josm_plugins] fix java 7 warnings / global usage of try-with-resource

File size: 4.9 KB
Line 
1package panels;
2
3import java.awt.*;
4import java.awt.event.*;
5import javax.swing.*;
6
7import java.util.*;
8
9import messages.Messages;
10import smed.SmedAction;
11import seamarks.SeaMark.*;
12
13public class PanelTop extends JPanel {
14
15 private SmedAction dlg;
16 public PanelPat panelPat = null;
17 private ButtonGroup topButtons = new ButtonGroup();
18 public JRadioButton noTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OffButton.png")));
19 public JRadioButton canTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanTopButton.png")));
20 public JRadioButton coneTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeTopButton.png")));
21 public JRadioButton sphereTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereTopButton.png")));
22 public JRadioButton XTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/XTopButton.png")));
23 public JRadioButton northTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/NorthTopButton.png")));
24 public JRadioButton southTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SouthTopButton.png")));
25 public JRadioButton eastTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/EastTopButton.png")));
26 public JRadioButton westTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/WestTopButton.png")));
27 public JRadioButton spheres2TopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/Spheres2TopButton.png")));
28 public JRadioButton boardDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BoardDayButton.png")));
29 public JRadioButton rhombusDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/DiamondDayButton.png")));
30 public JRadioButton triangleDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TriangleDayButton.png")));
31 public JRadioButton triangleInvDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TriangleInvDayButton.png")));
32 public JRadioButton squareDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SquareDayButton.png")));
33 public JRadioButton circleDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CircleDayButton.png")));
34 private EnumMap<Top, JRadioButton> tops = new EnumMap<>(Top.class);
35 private ActionListener alTop = new ActionListener() {
36 public void actionPerformed(java.awt.event.ActionEvent e) {
37 for (Top top : tops.keySet()) {
38 JRadioButton button = tops.get(top);
39 if (button.isSelected()) {
40 SmedAction.panelMain.mark.setTopmark(top);
41 button.setBorderPainted(true);
42 } else
43 button.setBorderPainted(false);
44 }
45 }
46 };
47
48 public PanelTop(SmedAction dia) {
49 dlg = dia;
50 setLayout(null);
51 panelPat = new PanelPat(dlg, Ent.TOPMARK);
52 panelPat.setBounds(new Rectangle(160, 0, 110, 160));
53 add(panelPat);
54 add(getTopButton(noTopButton, 0, 5, 27, 27, "NoTop", Top.NOTOP));
55 add(getTopButton(canTopButton, 30, 5, 27, 27, "CanTop", Top.CYL));
56 add(getTopButton(coneTopButton, 60, 5, 27, 27, "ConeTop", Top.CONE));
57 add(getTopButton(sphereTopButton, 90, 5, 27, 27, "SphereTop", Top.SPHERE));
58 add(getTopButton(XTopButton, 120, 5, 27, 27, "XTop", Top.X_SHAPE));
59 add(getTopButton(northTopButton, 0, 35, 27, 27, "NorthTop", Top.NORTH));
60 add(getTopButton(southTopButton, 30, 35, 27, 27, "SouthTop", Top.SOUTH));
61 add(getTopButton(eastTopButton, 60, 35, 27, 27, "EastTop", Top.EAST));
62 add(getTopButton(westTopButton, 90, 35, 27, 27, "WestTop", Top.WEST));
63 add(getTopButton(spheres2TopButton, 120, 35, 27, 27, "Spheres2Top", Top.SPHERES2));
64 add(getTopButton(boardDayButton, 0, 65, 27, 27, "BoardDay", Top.BOARD));
65 add(getTopButton(rhombusDayButton, 30, 65, 27, 27, "DiamondDay", Top.RHOMBUS));
66 add(getTopButton(triangleDayButton, 60, 65, 27, 27, "TriangleDay", Top.TRIANGLE));
67 add(getTopButton(triangleInvDayButton, 90, 65, 27, 27, "TriangleInvDay", Top.TRIANGLE_INV));
68 add(getTopButton(squareDayButton, 120, 65, 27, 27, "SquareDay", Top.SQUARE));
69 add(getTopButton(circleDayButton, 120, 95, 27, 27, "CircleDay", Top.CIRCLE));
70 }
71
72 public void enableAll(boolean state) {
73 for (JRadioButton button : tops.values()) {
74 button.setEnabled(state);
75 }
76 }
77
78 public void syncPanel() {
79 for (Top top : tops.keySet()) {
80 JRadioButton button = tops.get(top);
81 if (SmedAction.panelMain.mark.getTopmark() == top) {
82 button.setBorderPainted(true);
83 } else
84 button.setBorderPainted(false);
85 }
86 panelPat.syncPanel();
87 }
88
89 private JRadioButton getTopButton(JRadioButton button, int x, int y, int w, int h, String tip, Top top) {
90 button.setBounds(new Rectangle(x, y, w, h));
91 button.setBorder(BorderFactory.createLoweredBevelBorder());
92 button.setToolTipText(Messages.getString(tip));
93 button.addActionListener(alTop);
94 topButtons.add(button);
95 tops.put(top, button);
96 return button;
97 }
98
99}
Note: See TracBrowser for help on using the repository browser.