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