Changeset 24873 in osm for applications/editors/josm/plugins/smed
- Timestamp:
- 2010-12-25T10:28:46+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelCol.java
r24871 r24873 73 73 button.setToolTipText(tr(tip)); 74 74 button.addActionListener(alColour); 75 colourButtons.add(button); 75 76 colours.put(col, button); 76 colourButtons.add(button);77 77 return button; 78 78 } -
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelTop.java
r24870 r24873 2 2 3 3 import javax.swing.JPanel; 4 5 import java.awt.Color;6 import java.awt.Dimension;7 import java.awt.Rectangle;8 import java.awt.Font;9 10 4 import javax.swing.BorderFactory; 11 5 import javax.swing.ButtonGroup; 12 6 import javax.swing.ImageIcon; 13 import javax.swing.JLabel;14 import javax.swing.JTextField;15 import javax.swing.JComboBox;16 import javax.swing.JCheckBox;17 7 import javax.swing.JRadioButton; 18 import javax.swing.JButton; 8 9 import java.awt.Color; 10 import java.awt.Rectangle; 11 import java.awt.event.ActionListener; 12 import java.util.EnumMap; 13 import java.util.Iterator; 19 14 20 15 import oseam.Messages; 21 16 import oseam.dialogs.OSeaMAction; 22 23 import java.awt.Cursor; 24 import java.awt.event.ActionListener; 17 import oseam.seamarks.SeaMark.Top; 25 18 26 19 public class PanelTop extends JPanel { … … 28 21 private OSeaMAction dlg; 29 22 public PanelCol panelCol = null; 30 private ButtonGroup topButtons = n ull;23 private ButtonGroup topButtons = new ButtonGroup(); 31 24 public JRadioButton noTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/NoTopButton.png"))); 32 25 public JRadioButton canTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanTopButton.png"))); … … 45 38 public JRadioButton squareDayButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SquareDayButton.png"))); 46 39 public JRadioButton mooringTopButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/MooringTopButton.png"))); 47 ActionListener alTop = null; 40 private EnumMap<Top, JRadioButton> tops = new EnumMap<Top, JRadioButton>(Top.class); 41 private ActionListener alTop = new ActionListener() { 42 public void actionPerformed(java.awt.event.ActionEvent e) { 43 Iterator<Top> it = tops.keySet().iterator(); 44 while (it.hasNext()) { 45 Top top = it.next(); 46 JRadioButton button = tops.get(top); 47 if (button.isSelected()) { 48 button.setBorderPainted(true); 49 } else 50 button.setBorderPainted(false); 51 } 52 } 53 }; 48 54 49 55 public PanelTop(OSeaMAction dia) { … … 53 59 this.setLayout(null); 54 60 this.add(panelCol, null); 55 this.add(getButton(noTopButton, 40, 5, 27, 27, "NoTopTip"), null); 56 this.add(getButton(canTopButton, 70, 5, 27, 27, "CanTopTip"), null); 57 this.add(getButton(coneTopButton, 100, 5, 27, 27, "ConeTopTip"), null); 58 this.add(getButton(sphereTopButton, 130, 5, 27, 27, "SphereTopTip"), null); 59 this.add(getButton(XTopButton, 160, 5, 27, 27, "XTopTip"), null); 60 this.add(getButton(northTopButton, 40, 35, 27, 27, "NorthTopTip"), null); 61 this.add(getButton(southTopButton, 70, 35, 27, 27, "SouthTopTip"), null); 62 this.add(getButton(eastTopButton, 100, 35, 27, 27, "EastTopTip"), null); 63 this.add(getButton(westTopButton, 130, 35, 27, 27, "WestTopTip"), null); 64 this.add(getButton(spheres2TopButton, 160, 35, 27, 27, "Spheres2TopTip"), null); 65 this.add(getButton(boardDayButton, 40, 65, 27, 27, "BoardDayTip"), null); 66 this.add(getButton(diamondDayButton, 70, 65, 27, 27, "DiamondDayTip"), null); 67 this.add(getButton(triangleDayButton, 100, 65, 27, 27, "TriangleDayTip"), null); 68 this.add(getButton(triangleInvDayButton, 130, 65, 27, 27, "TriangleInvDayTip"), null); 69 this.add(getButton(squareDayButton, 160, 65, 27, 27, "SquareDayTip"), null); 70 this.add(getButton(mooringTopButton, 40, 95, 27, 27, "MooringTopTip"), null); 71 topButtons = new ButtonGroup(); 72 topButtons.add(noTopButton); 73 topButtons.add(canTopButton); 74 topButtons.add(coneTopButton); 75 topButtons.add(sphereTopButton); 76 topButtons.add(XTopButton); 77 topButtons.add(northTopButton); 78 topButtons.add(southTopButton); 79 topButtons.add(eastTopButton); 80 topButtons.add(westTopButton); 81 topButtons.add(spheres2TopButton); 82 topButtons.add(boardDayButton); 83 topButtons.add(diamondDayButton); 84 topButtons.add(triangleDayButton); 85 topButtons.add(triangleInvDayButton); 86 topButtons.add(squareDayButton); 87 topButtons.add(mooringTopButton); 88 alTop = new ActionListener() { 89 public void actionPerformed(java.awt.event.ActionEvent e) { 90 noTopButton.setBorderPainted(noTopButton.isSelected()); 91 canTopButton.setBorderPainted(canTopButton.isSelected()); 92 coneTopButton.setBorderPainted(coneTopButton.isSelected()); 93 sphereTopButton.setBorderPainted(sphereTopButton.isSelected()); 94 XTopButton.setBorderPainted(XTopButton.isSelected()); 95 northTopButton.setBorderPainted(northTopButton.isSelected()); 96 southTopButton.setBorderPainted(southTopButton.isSelected()); 97 eastTopButton.setBorderPainted(eastTopButton.isSelected()); 98 westTopButton.setBorderPainted(westTopButton.isSelected()); 99 spheres2TopButton.setBorderPainted(spheres2TopButton.isSelected()); 100 boardDayButton.setBorderPainted(boardDayButton.isSelected()); 101 diamondDayButton.setBorderPainted(diamondDayButton.isSelected()); 102 triangleDayButton.setBorderPainted(triangleDayButton.isSelected()); 103 triangleInvDayButton.setBorderPainted(triangleInvDayButton.isSelected()); 104 squareDayButton.setBorderPainted(squareDayButton.isSelected()); 105 mooringTopButton.setBorderPainted(mooringTopButton.isSelected()); 106 } 107 }; 108 noTopButton.addActionListener(alTop); 109 canTopButton.addActionListener(alTop); 110 coneTopButton.addActionListener(alTop); 111 sphereTopButton.addActionListener(alTop); 112 XTopButton.addActionListener(alTop); 113 northTopButton.addActionListener(alTop); 114 southTopButton.addActionListener(alTop); 115 eastTopButton.addActionListener(alTop); 116 westTopButton.addActionListener(alTop); 117 spheres2TopButton.addActionListener(alTop); 118 boardDayButton.addActionListener(alTop); 119 diamondDayButton.addActionListener(alTop); 120 triangleDayButton.addActionListener(alTop); 121 triangleInvDayButton.addActionListener(alTop); 122 squareDayButton.addActionListener(alTop); 123 mooringTopButton.addActionListener(alTop); 61 this.add(getTopButton(noTopButton, 40, 5, 27, 27, "NoTopTip", Top.NONE), null); 62 this.add(getTopButton(canTopButton, 70, 5, 27, 27, "CanTopTip", Top.CAN), null); 63 this.add(getTopButton(coneTopButton, 100, 5, 27, 27, "ConeTopTip", Top.CONE), null); 64 this.add(getTopButton(sphereTopButton, 130, 5, 27, 27, "SphereTopTip", Top.SPHERE), null); 65 this.add(getTopButton(XTopButton, 160, 5, 27, 27, "XTopTip", Top.X_SHAPE), null); 66 this.add(getTopButton(northTopButton, 40, 35, 27, 27, "NorthTopTip", Top.NORTH), null); 67 this.add(getTopButton(southTopButton, 70, 35, 27, 27, "SouthTopTip", Top.SOUTH), null); 68 this.add(getTopButton(eastTopButton, 100, 35, 27, 27, "EastTopTip", Top.EAST), null); 69 this.add(getTopButton(westTopButton, 130, 35, 27, 27, "WestTopTip", Top.WEST), null); 70 this.add(getTopButton(spheres2TopButton, 160, 35, 27, 27, "Spheres2TopTip", Top.SPHERES2), null); 71 this.add(getTopButton(boardDayButton, 40, 65, 27, 27, "BoardDayTip", Top.BOARD), null); 72 this.add(getTopButton(diamondDayButton, 70, 65, 27, 27, "DiamondDayTip", Top.DIAMOND), null); 73 this.add(getTopButton(triangleDayButton, 100, 65, 27, 27, "TriangleDayTip", Top.TRIANGLE), null); 74 this.add(getTopButton(triangleInvDayButton, 130, 65, 27, 27, "TriangleInvDayTip", Top.TRIANGLE_INV), null); 75 this.add(getTopButton(squareDayButton, 160, 65, 27, 27, "SquareDayTip", Top.SQUARE), null); 76 this.add(getTopButton(mooringTopButton, 40, 95, 27, 27, "MooringTopTip", Top.MOORING), null); 124 77 } 125 78 … … 130 83 } 131 84 132 private JRadioButton get Button(JRadioButton button, int x, int y, int w, int h, String tip) {85 private JRadioButton getTopButton(JRadioButton button, int x, int y, int w, int h, String tip, Top top) { 133 86 button.setBounds(new Rectangle(x, y, w, h)); 134 87 button.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 135 88 button.setToolTipText(Messages.getString(tip)); 89 button.addActionListener(alTop); 90 topButtons.add(button); 91 tops.put(top, button); 136 92 return button; 137 93 }
Note:
See TracChangeset
for help on using the changeset viewer.