Changeset 24872 in osm for applications
- Timestamp:
- 2010-12-25T10:07:38+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/smed/plugs/oseam/src/oseam
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelChan.java
r24870 r24872 28 28 29 29 private OSeaMAction dlg; 30 private boolean region; 31 private ButtonGroup catButtons = null; 30 private ButtonGroup catButtons = new ButtonGroup(); 32 31 public JRadioButton portButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PortButton.png"))); 33 32 public JRadioButton stbdButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/StbdButton.png"))); … … 35 34 public JRadioButton prefStbdButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PrefStbdButton.png"))); 36 35 public JRadioButton safeWaterButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SafeWaterButton.png"))); 37 private ActionListener alCat = null; 36 private ActionListener alCat = new ActionListener() { 37 public void actionPerformed(java.awt.event.ActionEvent e) { 38 if (portButton.isSelected()) { 39 if (!(dlg.mark instanceof MarkLat) || (dlg.mark.getCategory() != Cat.LAT_PORT)) 40 dlg.mark = new MarkLat(dlg); 41 dlg.mark.setCategory(Cat.LAT_PORT); 42 if (dlg.mark.getRegion() == SeaMark.IALA_A) { 43 dlg.mark.setColour(Col.RED); 44 panelPort.regionAButton.doClick(); 45 } else { 46 dlg.mark.setColour(Col.GREEN); 47 panelPort.regionBButton.doClick(); 48 } 49 portButton.setBorderPainted(true); 50 panelPort.setVisible(true); 51 } else { 52 portButton.setBorderPainted(false); 53 panelPort.setVisible(false); 54 panelPort.clearSelections(); 55 } 56 if (stbdButton.isSelected()) { 57 if (!(dlg.mark instanceof MarkLat) || (dlg.mark.getCategory() != Cat.LAT_STBD)) 58 dlg.mark = new MarkLat(dlg); 59 dlg.mark.setCategory(Cat.LAT_STBD); 60 if (dlg.mark.getRegion() == SeaMark.IALA_A) { 61 dlg.mark.setColour(Col.GREEN); 62 panelStbd.regionAButton.doClick(); 63 } else { 64 dlg.mark.setColour(Col.RED); 65 panelStbd.regionBButton.doClick(); 66 } 67 stbdButton.setBorderPainted(true); 68 panelStbd.setVisible(true); 69 } else { 70 stbdButton.setBorderPainted(false); 71 panelStbd.setVisible(false); 72 panelStbd.clearSelections(); 73 } 74 if (prefPortButton.isSelected()) { 75 if (!(dlg.mark instanceof MarkLat) || (dlg.mark.getCategory() != Cat.LAT_PREF_PORT)) 76 dlg.mark = new MarkLat(dlg); 77 dlg.mark.setCategory(Cat.LAT_PREF_PORT); 78 if (dlg.mark.getRegion() == SeaMark.IALA_A) { 79 dlg.mark.setColour(Col.RED_GREEN_RED); 80 panelPrefPort.regionAButton.doClick(); 81 } else { 82 dlg.mark.setColour(Col.GREEN_RED_GREEN); 83 panelPrefPort.regionBButton.doClick(); 84 } 85 prefPortButton.setBorderPainted(true); 86 panelPrefPort.setVisible(true); 87 } else { 88 prefPortButton.setBorderPainted(false); 89 panelPrefPort.setVisible(false); 90 panelPrefPort.clearSelections(); 91 } 92 if (prefStbdButton.isSelected()) { 93 if (!(dlg.mark instanceof MarkLat) || (dlg.mark.getCategory() != Cat.LAT_PREF_STBD)) 94 dlg.mark = new MarkLat(dlg); 95 dlg.mark.setCategory(Cat.LAT_PREF_STBD); 96 if (dlg.mark.getRegion() == SeaMark.IALA_A) { 97 dlg.mark.setColour(Col.GREEN_RED_GREEN); 98 panelPrefStbd.regionAButton.doClick(); 99 } else { 100 dlg.mark.setColour(Col.RED_GREEN_RED); 101 panelPrefStbd.regionBButton.doClick(); 102 } 103 prefStbdButton.setBorderPainted(true); 104 panelPrefStbd.setVisible(true); 105 } else { 106 prefStbdButton.setBorderPainted(false); 107 panelPrefStbd.setVisible(false); 108 panelPrefStbd.clearSelections(); 109 } 110 if (safeWaterButton.isSelected()) { 111 if (!(dlg.mark instanceof MarkSaw)) 112 dlg.mark = new MarkSaw(dlg); 113 dlg.mark.setColour(Col.RED_WHITE); 114 safeWaterButton.setBorderPainted(true); 115 panelSafeWater.setVisible(true); 116 } else { 117 safeWaterButton.setBorderPainted(false); 118 panelSafeWater.setVisible(false); 119 panelSafeWater.clearSelections(); 120 } 121 if (dlg.mark != null) 122 dlg.mark.paintSign(); 123 } 124 }; 125 38 126 public PanelPort panelPort = null; 39 127 public PanelStbd panelStbd = null; … … 65 153 this.add(panelPrefStbd, null); 66 154 this.add(panelSafeWater, null); 67 this.add(getButton(portButton, 0, 0, 52, 32, "PortTip"), null); 68 this.add(getButton(stbdButton, 0, 32, 52, 32, "StbdTip"), null); 69 this.add(getButton(prefPortButton, 0, 64, 52, 32, "PrefPortTip"), null); 70 this.add(getButton(prefStbdButton, 0, 96, 52, 32, "PrefStbdTip"), null); 71 this.add(getButton(safeWaterButton, 0, 128, 52, 32, "SafeWaterTip"), null); 72 catButtons = new ButtonGroup(); 73 catButtons.add(portButton); 74 catButtons.add(stbdButton); 75 catButtons.add(prefPortButton); 76 catButtons.add(prefStbdButton); 77 catButtons.add(safeWaterButton); 78 alCat = new ActionListener() { 79 public void actionPerformed(java.awt.event.ActionEvent e) { 80 if (portButton.isSelected()) { 81 if (!(dlg.mark instanceof MarkLat) || (dlg.mark.getCategory() != Cat.LAT_PORT)) 82 dlg.mark = new MarkLat(dlg); 83 dlg.mark.setCategory(Cat.LAT_PORT); 84 if (dlg.mark.getRegion() == SeaMark.IALA_A) { 85 dlg.mark.setColour(Col.RED); 86 panelPort.regionAButton.doClick(); 87 } else { 88 dlg.mark.setColour(Col.GREEN); 89 panelPort.regionBButton.doClick(); 90 } 91 portButton.setBorderPainted(true); 92 panelPort.setVisible(true); 93 } else { 94 portButton.setBorderPainted(false); 95 panelPort.setVisible(false); 96 panelPort.clearSelections(); 97 } 98 if (stbdButton.isSelected()) { 99 if (!(dlg.mark instanceof MarkLat) || (dlg.mark.getCategory() != Cat.LAT_STBD)) 100 dlg.mark = new MarkLat(dlg); 101 dlg.mark.setCategory(Cat.LAT_STBD); 102 if (dlg.mark.getRegion() == SeaMark.IALA_A) { 103 dlg.mark.setColour(Col.GREEN); 104 panelStbd.regionAButton.doClick(); 105 } else { 106 dlg.mark.setColour(Col.RED); 107 panelStbd.regionBButton.doClick(); 108 } 109 stbdButton.setBorderPainted(true); 110 panelStbd.setVisible(true); 111 } else { 112 stbdButton.setBorderPainted(false); 113 panelStbd.setVisible(false); 114 panelStbd.clearSelections(); 115 } 116 if (prefPortButton.isSelected()) { 117 if (!(dlg.mark instanceof MarkLat) || (dlg.mark.getCategory() != Cat.LAT_PREF_PORT)) 118 dlg.mark = new MarkLat(dlg); 119 dlg.mark.setCategory(Cat.LAT_PREF_PORT); 120 if (dlg.mark.getRegion() == SeaMark.IALA_A) { 121 dlg.mark.setColour(Col.RED_GREEN_RED); 122 panelPrefPort.regionAButton.doClick(); 123 } else { 124 dlg.mark.setColour(Col.GREEN_RED_GREEN); 125 panelPrefPort.regionBButton.doClick(); 126 } 127 prefPortButton.setBorderPainted(true); 128 panelPrefPort.setVisible(true); 129 } else { 130 prefPortButton.setBorderPainted(false); 131 panelPrefPort.setVisible(false); 132 panelPrefPort.clearSelections(); 133 } 134 if (prefStbdButton.isSelected()) { 135 if (!(dlg.mark instanceof MarkLat) || (dlg.mark.getCategory() != Cat.LAT_PREF_STBD)) 136 dlg.mark = new MarkLat(dlg); 137 dlg.mark.setCategory(Cat.LAT_PREF_STBD); 138 if (dlg.mark.getRegion() == SeaMark.IALA_A) { 139 dlg.mark.setColour(Col.GREEN_RED_GREEN); 140 panelPrefStbd.regionAButton.doClick(); 141 } else { 142 dlg.mark.setColour(Col.RED_GREEN_RED); 143 panelPrefStbd.regionBButton.doClick(); 144 } 145 prefStbdButton.setBorderPainted(true); 146 panelPrefStbd.setVisible(true); 147 } else { 148 prefStbdButton.setBorderPainted(false); 149 panelPrefStbd.setVisible(false); 150 panelPrefStbd.clearSelections(); 151 } 152 if (safeWaterButton.isSelected()) { 153 if (!(dlg.mark instanceof MarkSaw)) 154 dlg.mark = new MarkSaw(dlg); 155 dlg.mark.setColour(Col.RED_WHITE); 156 safeWaterButton.setBorderPainted(true); 157 panelSafeWater.setVisible(true); 158 } else { 159 safeWaterButton.setBorderPainted(false); 160 panelSafeWater.setVisible(false); 161 panelSafeWater.clearSelections(); 162 } 163 if (dlg.mark != null) 164 dlg.mark.paintSign(); 165 } 166 }; 167 portButton.addActionListener(alCat); 168 stbdButton.addActionListener(alCat); 169 prefPortButton.addActionListener(alCat); 170 prefStbdButton.addActionListener(alCat); 171 safeWaterButton.addActionListener(alCat); 155 this.add(getCatButton(portButton, 0, 0, 52, 32, "PortTip"), null); 156 this.add(getCatButton(stbdButton, 0, 32, 52, 32, "StbdTip"), null); 157 this.add(getCatButton(prefPortButton, 0, 64, 52, 32, "PrefPortTip"), null); 158 this.add(getCatButton(prefStbdButton, 0, 96, 52, 32, "PrefStbdTip"), null); 159 this.add(getCatButton(safeWaterButton, 0, 128, 52, 32, "SafeWaterTip"), null); 172 160 } 173 161 … … 182 170 } 183 171 184 private JRadioButton get Button(JRadioButton button, int x, int y, int w, int h, String tip) {172 private JRadioButton getCatButton(JRadioButton button, int x, int y, int w, int h, String tip) { 185 173 button.setBounds(new Rectangle(x, y, w, h)); 186 174 button.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 187 175 button.setToolTipText(Messages.getString(tip)); 176 button.addActionListener(alCat); 177 catButtons.add(button); 188 178 return button; 189 179 } -
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelHaz.java
r24870 r24872 20 20 21 21 import java.awt.event.ActionListener; 22 import java.util.EnumMap; 23 import java.util.Iterator; 22 24 23 25 public class PanelHaz extends JPanel { 24 26 25 27 private OSeaMAction dlg; 26 private ButtonGroup catButtons = n ull;28 private ButtonGroup catButtons = new ButtonGroup(); 27 29 public JRadioButton northButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardNButton.png"))); 28 30 public JRadioButton southButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardSButton.png"))); … … 30 32 public JRadioButton westButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardWButton.png"))); 31 33 public JRadioButton isolButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/IsolButton.png"))); 32 private ActionListener alCat = null; 34 private ActionListener alCat = new ActionListener() { 35 public void actionPerformed(java.awt.event.ActionEvent e) { 36 if (northButton.isSelected()) { 37 if (!(dlg.mark instanceof MarkCard)) { 38 dlg.mark = new MarkCard(dlg); 39 alShape.actionPerformed(null); 40 } 41 dlg.mark.setCategory(Cat.CARD_NORTH); 42 dlg.mark.setColour(Col.BLACK_YELLOW); 43 dlg.panelMain.panelTop.northTopButton.doClick(); 44 dlg.panelMain.panelTop.panelCol.blackButton.doClick(); 45 northButton.setBorderPainted(true); 46 } else { 47 northButton.setBorderPainted(false); 48 } 49 if (southButton.isSelected()) { 50 if (!(dlg.mark instanceof MarkCard)) { 51 dlg.mark = new MarkCard(dlg); 52 alShape.actionPerformed(null); 53 } 54 dlg.mark.setCategory(Cat.CARD_SOUTH); 55 dlg.mark.setColour(Col.YELLOW_BLACK); 56 dlg.panelMain.panelTop.southTopButton.doClick(); 57 dlg.panelMain.panelTop.panelCol.blackButton.doClick(); 58 southButton.setBorderPainted(true); 59 } else { 60 southButton.setBorderPainted(false); 61 } 62 if (eastButton.isSelected()) { 63 if (!(dlg.mark instanceof MarkCard)) { 64 dlg.mark = new MarkCard(dlg); 65 alShape.actionPerformed(null); 66 } 67 dlg.mark.setCategory(Cat.CARD_EAST); 68 dlg.mark.setColour(Col.BLACK_YELLOW_BLACK); 69 dlg.panelMain.panelTop.eastTopButton.doClick(); 70 dlg.panelMain.panelTop.panelCol.blackButton.doClick(); 71 eastButton.setBorderPainted(true); 72 } else { 73 eastButton.setBorderPainted(false); 74 } 75 if (westButton.isSelected()) { 76 if (!(dlg.mark instanceof MarkCard)) { 77 dlg.mark = new MarkCard(dlg); 78 alShape.actionPerformed(null); 79 } 80 dlg.mark.setCategory(Cat.CARD_WEST); 81 dlg.mark.setColour(Col.YELLOW_BLACK_YELLOW); 82 dlg.panelMain.panelTop.westTopButton.doClick(); 83 dlg.panelMain.panelTop.panelCol.blackButton.doClick(); 84 westButton.setBorderPainted(true); 85 } else { 86 westButton.setBorderPainted(false); 87 } 88 if (isolButton.isSelected()) { 89 if (!(dlg.mark instanceof MarkIsol)) { 90 dlg.mark = new MarkIsol(dlg); 91 alShape.actionPerformed(null); 92 } 93 dlg.mark.setColour(Col.BLACK_RED_BLACK); 94 dlg.panelMain.panelTop.spheres2TopButton.doClick(); 95 dlg.panelMain.panelTop.panelCol.blackButton.doClick(); 96 isolButton.setBorderPainted(true); 97 } else { 98 isolButton.setBorderPainted(false); 99 } 100 if (dlg.mark != null) 101 dlg.mark.paintSign(); 102 } 103 }; 33 104 34 private ButtonGroup shapeButtons = n ull;105 private ButtonGroup shapeButtons = new ButtonGroup(); 35 106 public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 36 107 public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); … … 38 109 public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png"))); 39 110 public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png"))); 40 private ActionListener alShape = null; 111 private EnumMap<Shp, JRadioButton> shapes = new EnumMap<Shp, JRadioButton>(Shp.class); 112 private ActionListener alShape = new ActionListener() { 113 public void actionPerformed(java.awt.event.ActionEvent e) { 114 Iterator<Shp> it = shapes.keySet().iterator(); 115 while (it.hasNext()) { 116 Shp shp = it.next(); 117 JRadioButton button = shapes.get(shp); 118 if (button.isSelected()) { 119 dlg.mark.setShape(shp); 120 button.setBorderPainted(true); 121 } else 122 button.setBorderPainted(false); 123 } 124 if (dlg.mark != null) 125 dlg.mark.paintSign(); 126 } 127 }; 41 128 42 129 public PanelHaz(OSeaMAction dia) { 43 130 dlg = dia; 44 131 this.setLayout(null); 45 this.add(getButton(northButton, 0, 0, 52, 32, "NorthTip"), null); 46 this.add(getButton(southButton, 0, 32, 52, 32, "SouthTip"), null); 47 this.add(getButton(eastButton, 0, 64, 52, 32, "EastTip"), null); 48 this.add(getButton(westButton, 0, 96, 52, 32, "WestTip"), null); 49 this.add(getButton(isolButton, 0, 128, 52, 32, "IsolTip"), null); 50 catButtons = new ButtonGroup(); 51 catButtons.add(northButton); 52 catButtons.add(southButton); 53 catButtons.add(eastButton); 54 catButtons.add(westButton); 55 catButtons.add(isolButton); 56 alCat = new ActionListener() { 57 public void actionPerformed(java.awt.event.ActionEvent e) { 58 if (northButton.isSelected()) { 59 if (!(dlg.mark instanceof MarkCard)) { 60 dlg.mark = new MarkCard(dlg); 61 alShape.actionPerformed(null); 62 } 63 dlg.mark.setCategory(Cat.CARD_NORTH); 64 dlg.mark.setColour(Col.BLACK_YELLOW); 65 dlg.panelMain.panelTop.northTopButton.doClick(); 66 dlg.panelMain.panelTop.panelCol.blackButton.doClick(); 67 northButton.setBorderPainted(true); 68 } else { 69 northButton.setBorderPainted(false); 70 } 71 if (southButton.isSelected()) { 72 if (!(dlg.mark instanceof MarkCard)) { 73 dlg.mark = new MarkCard(dlg); 74 alShape.actionPerformed(null); 75 } 76 dlg.mark.setCategory(Cat.CARD_SOUTH); 77 dlg.mark.setColour(Col.YELLOW_BLACK); 78 dlg.panelMain.panelTop.southTopButton.doClick(); 79 dlg.panelMain.panelTop.panelCol.blackButton.doClick(); 80 southButton.setBorderPainted(true); 81 } else { 82 southButton.setBorderPainted(false); 83 } 84 if (eastButton.isSelected()) { 85 if (!(dlg.mark instanceof MarkCard)) { 86 dlg.mark = new MarkCard(dlg); 87 alShape.actionPerformed(null); 88 } 89 dlg.mark.setCategory(Cat.CARD_EAST); 90 dlg.mark.setColour(Col.BLACK_YELLOW_BLACK); 91 dlg.panelMain.panelTop.eastTopButton.doClick(); 92 dlg.panelMain.panelTop.panelCol.blackButton.doClick(); 93 eastButton.setBorderPainted(true); 94 } else { 95 eastButton.setBorderPainted(false); 96 } 97 if (westButton.isSelected()) { 98 if (!(dlg.mark instanceof MarkCard)) { 99 dlg.mark = new MarkCard(dlg); 100 alShape.actionPerformed(null); 101 } 102 dlg.mark.setCategory(Cat.CARD_WEST); 103 dlg.mark.setColour(Col.YELLOW_BLACK_YELLOW); 104 dlg.panelMain.panelTop.westTopButton.doClick(); 105 dlg.panelMain.panelTop.panelCol.blackButton.doClick(); 106 westButton.setBorderPainted(true); 107 } else { 108 westButton.setBorderPainted(false); 109 } 110 if (isolButton.isSelected()) { 111 if (!(dlg.mark instanceof MarkIsol)) { 112 dlg.mark = new MarkIsol(dlg); 113 alShape.actionPerformed(null); 114 } 115 dlg.mark.setColour(Col.BLACK_RED_BLACK); 116 dlg.panelMain.panelTop.spheres2TopButton.doClick(); 117 dlg.panelMain.panelTop.panelCol.blackButton.doClick(); 118 isolButton.setBorderPainted(true); 119 } else { 120 isolButton.setBorderPainted(false); 121 } 122 if (dlg.mark != null) 123 dlg.mark.paintSign(); 124 } 125 }; 126 northButton.addActionListener(alCat); 127 southButton.addActionListener(alCat); 128 eastButton.addActionListener(alCat); 129 westButton.addActionListener(alCat); 130 isolButton.addActionListener(alCat); 132 this.add(getCatButton(northButton, 0, 0, 52, 32, "NorthTip"), null); 133 this.add(getCatButton(southButton, 0, 32, 52, 32, "SouthTip"), null); 134 this.add(getCatButton(eastButton, 0, 64, 52, 32, "EastTip"), null); 135 this.add(getCatButton(westButton, 0, 96, 52, 32, "WestTip"), null); 136 this.add(getCatButton(isolButton, 0, 128, 52, 32, "IsolTip"), null); 131 137 132 this.add(getButton(pillarButton, 55, 0, 34, 32, "PillarTip"), null); 133 this.add(getButton(sparButton, 55, 32, 34, 32, "SparTip"), null); 134 this.add(getButton(floatButton, 55, 64, 34, 32, "FloatTip"), null); 135 this.add(getButton(beaconButton, 55, 96, 34, 32, "BeaconTip"), null); 136 this.add(getButton(towerButton, 55, 128, 34, 32, "TowerTip"), null); 137 shapeButtons = new ButtonGroup(); 138 shapeButtons.add(pillarButton); 139 shapeButtons.add(sparButton); 140 shapeButtons.add(floatButton); 141 shapeButtons.add(beaconButton); 142 shapeButtons.add(towerButton); 143 alShape = new ActionListener() { 144 public void actionPerformed(java.awt.event.ActionEvent e) { 145 if (pillarButton.isSelected()) { 146 pillarButton.setBorderPainted(true); 147 dlg.mark.setShape(Shp.PILLAR); 148 } else { 149 pillarButton.setBorderPainted(false); 150 } 151 if (sparButton.isSelected()) { 152 sparButton.setBorderPainted(true); 153 dlg.mark.setShape(Shp.SPAR); 154 } else { 155 sparButton.setBorderPainted(false); 156 } 157 if (floatButton.isSelected()) { 158 floatButton.setBorderPainted(true); 159 dlg.mark.setShape(Shp.FLOAT); 160 } else { 161 floatButton.setBorderPainted(false); 162 } 163 if (beaconButton.isSelected()) { 164 beaconButton.setBorderPainted(true); 165 dlg.mark.setShape(Shp.BEACON); 166 } else { 167 beaconButton.setBorderPainted(false); 168 } 169 if (towerButton.isSelected()) { 170 towerButton.setBorderPainted(true); 171 dlg.mark.setShape(Shp.TOWER); 172 } else { 173 towerButton.setBorderPainted(false); 174 } 175 if (dlg.mark != null) 176 dlg.mark.paintSign(); 177 } 178 }; 179 pillarButton.addActionListener(alShape); 180 sparButton.addActionListener(alShape); 181 floatButton.addActionListener(alShape); 182 beaconButton.addActionListener(alShape); 183 towerButton.addActionListener(alShape); 138 this.add(getShapeButton(pillarButton, 55, 0, 34, 32, "PillarTip", Shp.PILLAR), null); 139 this.add(getShapeButton(sparButton, 55, 32, 34, 32, "SparTip", Shp.SPAR), null); 140 this.add(getShapeButton(floatButton, 55, 64, 34, 32, "FloatTip", Shp.FLOAT), null); 141 this.add(getShapeButton(beaconButton, 55, 96, 34, 32, "BeaconTip", Shp.BEACON), null); 142 this.add(getShapeButton(towerButton, 55, 128, 34, 32, "TowerTip", Shp.TOWER), null); 184 143 } 185 144 … … 191 150 } 192 151 193 private JRadioButton get Button(JRadioButton button, int x, int y, int w, int h, String tip) {152 private JRadioButton getCatButton(JRadioButton button, int x, int y, int w, int h, String tip) { 194 153 button.setBounds(new Rectangle(x, y, w, h)); 195 154 button.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 196 155 button.setToolTipText(Messages.getString(tip)); 156 button.addActionListener(alCat); 157 catButtons.add(button); 158 return button; 159 } 160 161 private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp) { 162 button.setBounds(new Rectangle(x, y, w, h)); 163 button.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 164 button.setToolTipText(Messages.getString(tip)); 165 button.addActionListener(alShape); 166 shapeButtons.add(button); 167 shapes.put(shp, button); 197 168 return button; 198 169 } -
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelPort.java
r24870 r24872 24 24 import java.awt.Cursor; 25 25 import java.awt.event.ActionListener; 26 import java.util.EnumMap; 27 import java.util.Iterator; 26 28 27 29 public class PanelPort extends JPanel { 28 30 29 31 private OSeaMAction dlg; 30 private ButtonGroup regionButtons = n ull;32 private ButtonGroup regionButtons = new ButtonGroup(); 31 33 public JRadioButton regionAButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionAButton.png"))); 32 34 public JRadioButton regionBButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionBButton.png"))); 33 private ButtonGroup shapeButtons = null; 35 private ActionListener alRegion = new ActionListener() { 36 public void actionPerformed(java.awt.event.ActionEvent e) { 37 regionAButton.setBorderPainted(regionAButton.isSelected()); 38 regionBButton.setBorderPainted(regionBButton.isSelected()); 39 dlg.mark.paintSign(); 40 } 41 }; 42 private ButtonGroup shapeButtons = new ButtonGroup(); 34 43 public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 35 44 public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); … … 39 48 public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png"))); 40 49 public JRadioButton perchButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PerchPButton.png"))); 41 private ActionListener alShape = null; 50 private EnumMap<Shp, JRadioButton> shapes = new EnumMap<Shp, JRadioButton>(Shp.class); 51 private ActionListener alShape = new ActionListener() { 52 public void actionPerformed(java.awt.event.ActionEvent e) { 53 Iterator<Shp> it = shapes.keySet().iterator(); 54 while (it.hasNext()) { 55 Shp shp = it.next(); 56 JRadioButton button = shapes.get(shp); 57 if (button.isSelected()) { 58 dlg.mark.setShape(shp); 59 button.setBorderPainted(true); 60 } else 61 button.setBorderPainted(false); 62 } 63 if (dlg.mark != null) 64 dlg.mark.paintSign(); 65 } 66 }; 42 67 43 68 public PanelPort(OSeaMAction dia) { 44 69 dlg = dia; 45 70 this.setLayout(null); 46 this.add(getButton(regionAButton, 0, 2, 34, 30, "RegionATip"), null); 47 this.add(getButton(regionBButton, 0, 32, 34, 30, "RegionBTip"), null); 48 this.add(getButton(pillarButton, 0, 64, 34, 32, "PillarTip"), null); 49 this.add(getButton(sparButton, 0, 96, 34, 32, "SparTip"), null); 50 this.add(getButton(canButton, 0, 128, 34, 32, "CanTip"), null); 51 this.add(getButton(floatButton, 35, 0, 34, 32, "FloatTip"), null); 52 this.add(getButton(beaconButton, 35, 32, 34, 32, "BeaconTip"), null); 53 this.add(getButton(towerButton, 35, 64, 34, 32, "TowerTip"), null); 54 this.add(getButton(perchButton, 35, 96, 34, 32, "PerchTip"), null); 55 56 regionButtons = new ButtonGroup(); 57 regionButtons.add(regionAButton); 58 regionButtons.add(regionBButton); 59 ActionListener alRegion = new ActionListener() { 60 public void actionPerformed(java.awt.event.ActionEvent e) { 61 regionAButton.setBorderPainted(regionAButton.isSelected()); 62 regionBButton.setBorderPainted(regionBButton.isSelected()); 63 dlg.mark.paintSign(); 64 } 65 }; 66 regionAButton.addActionListener(alRegion); 67 regionBButton.addActionListener(alRegion); 68 69 shapeButtons = new ButtonGroup(); 70 shapeButtons.add(pillarButton); 71 shapeButtons.add(sparButton); 72 shapeButtons.add(canButton); 73 shapeButtons.add(floatButton); 74 shapeButtons.add(beaconButton); 75 shapeButtons.add(towerButton); 76 shapeButtons.add(perchButton); 77 alShape = new ActionListener() { 78 public void actionPerformed(java.awt.event.ActionEvent e) { 79 if (pillarButton.isSelected()) { 80 dlg.mark.setShape(Shp.PILLAR); 81 pillarButton.setBorderPainted(true); 82 } else { 83 pillarButton.setBorderPainted(false); 84 } 85 if (sparButton.isSelected()) { 86 dlg.mark.setShape(Shp.SPAR); 87 sparButton.setBorderPainted(true); 88 } else { 89 sparButton.setBorderPainted(false); 90 } 91 if (canButton.isSelected()) { 92 dlg.mark.setShape(Shp.CAN); 93 canButton.setBorderPainted(true); 94 } else { 95 canButton.setBorderPainted(false); 96 } 97 if (floatButton.isSelected()) { 98 dlg.mark.setShape(Shp.FLOAT); 99 floatButton.setBorderPainted(true); 100 } else { 101 floatButton.setBorderPainted(false); 102 } 103 if (beaconButton.isSelected()) { 104 dlg.mark.setShape(Shp.BEACON); 105 beaconButton.setBorderPainted(true); 106 } else { 107 beaconButton.setBorderPainted(false); 108 } 109 if (towerButton.isSelected()) { 110 dlg.mark.setShape(Shp.TOWER); 111 towerButton.setBorderPainted(true); 112 } else { 113 towerButton.setBorderPainted(false); 114 } 115 if (perchButton.isSelected()) { 116 dlg.mark.setShape(Shp.PERCH); 117 perchButton.setBorderPainted(true); 118 } else { 119 perchButton.setBorderPainted(false); 120 } 121 if (dlg.mark != null) 122 dlg.mark.paintSign(); 123 } 124 }; 125 pillarButton.addActionListener(alShape); 126 sparButton.addActionListener(alShape); 127 canButton.addActionListener(alShape); 128 floatButton.addActionListener(alShape); 129 beaconButton.addActionListener(alShape); 130 towerButton.addActionListener(alShape); 131 perchButton.addActionListener(alShape); 71 this.add(getRegionButton(regionAButton, 0, 2, 34, 30, "RegionATip"), null); 72 this.add(getRegionButton(regionBButton, 0, 32, 34, 30, "RegionBTip"), null); 73 this.add(getShapeButton(pillarButton, 0, 64, 34, 32, "PillarTip", Shp.PILLAR), null); 74 this.add(getShapeButton(sparButton, 0, 96, 34, 32, "SparTip", Shp.SPAR), null); 75 this.add(getShapeButton(canButton, 0, 128, 34, 32, "CanTip", Shp.CAN), null); 76 this.add(getShapeButton(floatButton, 35, 0, 34, 32, "FloatTip", Shp.FLOAT), null); 77 this.add(getShapeButton(beaconButton, 35, 32, 34, 32, "BeaconTip", Shp.BEACON), null); 78 this.add(getShapeButton(towerButton, 35, 64, 34, 32, "TowerTip", Shp.TOWER), null); 79 this.add(getShapeButton(perchButton, 35, 96, 34, 32, "PerchTip", Shp.PERCH), null); 132 80 } 133 81 … … 137 85 } 138 86 139 private JRadioButton get Button(JRadioButton button, int x, int y, int w, int h, String tip) {87 private JRadioButton getRegionButton(JRadioButton button, int x, int y, int w, int h, String tip) { 140 88 button.setBounds(new Rectangle(x, y, w, h)); 141 89 button.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 142 90 button.setToolTipText(Messages.getString(tip)); 91 button.addActionListener(alRegion); 92 regionButtons.add(button); 93 return button; 94 } 95 96 private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp) { 97 button.setBounds(new Rectangle(x, y, w, h)); 98 button.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 99 button.setToolTipText(Messages.getString(tip)); 100 button.addActionListener(alShape); 101 shapeButtons.add(button); 102 shapes.put(shp, button); 143 103 return button; 144 104 } -
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelPrefPort.java
r24870 r24872 23 23 import java.awt.Cursor; 24 24 import java.awt.event.ActionListener; 25 import java.util.EnumMap; 26 import java.util.Iterator; 25 27 26 28 public class PanelPrefPort extends JPanel { 27 29 28 30 private OSeaMAction dlg; 29 private ButtonGroup regionButtons = n ull;31 private ButtonGroup regionButtons = new ButtonGroup(); 30 32 public JRadioButton regionAButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionAButton.png"))); 31 33 public JRadioButton regionBButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionBButton.png"))); 32 private ButtonGroup shapeButtons = null; 34 private ActionListener alRegion = new ActionListener() { 35 public void actionPerformed(java.awt.event.ActionEvent e) { 36 regionAButton.setBorderPainted(regionAButton.isSelected()); 37 regionBButton.setBorderPainted(regionBButton.isSelected()); 38 dlg.mark.paintSign(); 39 } 40 }; 41 private ButtonGroup shapeButtons = new ButtonGroup(); 33 42 public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 34 43 public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); … … 37 46 public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png"))); 38 47 public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png"))); 39 private ActionListener alShape = null; 48 private EnumMap<Shp, JRadioButton> shapes = new EnumMap<Shp, JRadioButton>(Shp.class); 49 private ActionListener alShape = new ActionListener() { 50 public void actionPerformed(java.awt.event.ActionEvent e) { 51 Iterator<Shp> it = shapes.keySet().iterator(); 52 while (it.hasNext()) { 53 Shp shp = it.next(); 54 JRadioButton button = shapes.get(shp); 55 if (button.isSelected()) { 56 dlg.mark.setShape(shp); 57 button.setBorderPainted(true); 58 } else 59 button.setBorderPainted(false); 60 } 61 if (dlg.mark != null) 62 dlg.mark.paintSign(); 63 } 64 }; 40 65 41 66 public PanelPrefPort(OSeaMAction dia) { 42 67 dlg = dia; 43 68 this.setLayout(null); 44 this.add(getButton(regionAButton, 0, 2, 34, 30, "RegionATip"), null); 45 this.add(getButton(regionBButton, 0, 32, 34, 30, "RegionBTip"), null); 46 this.add(getButton(pillarButton, 0, 64, 34, 32, "PillarTip"), null); 47 this.add(getButton(sparButton, 0, 96, 34, 32, "SparTip"), null); 48 this.add(getButton(canButton, 0, 128, 34, 32, "CanTip"), null); 49 this.add(getButton(floatButton, 35, 0, 34, 32, "FloatTip"), null); 50 this.add(getButton(beaconButton, 35, 32, 34, 32, "BeaconTip"), null); 51 this.add(getButton(towerButton, 35, 64, 34, 32, "TowerTip"), null); 52 53 regionButtons = new ButtonGroup(); 54 regionButtons.add(regionAButton); 55 regionButtons.add(regionBButton); 56 ActionListener alRegion = new ActionListener() { 57 public void actionPerformed(java.awt.event.ActionEvent e) { 58 regionAButton.setBorderPainted(regionAButton.isSelected()); 59 regionBButton.setBorderPainted(regionBButton.isSelected()); 60 dlg.mark.paintSign(); 61 } 62 }; 63 regionAButton.addActionListener(alRegion); 64 regionBButton.addActionListener(alRegion); 65 66 shapeButtons = new ButtonGroup(); 67 shapeButtons.add(pillarButton); 68 shapeButtons.add(sparButton); 69 shapeButtons.add(canButton); 70 shapeButtons.add(floatButton); 71 shapeButtons.add(beaconButton); 72 shapeButtons.add(towerButton); 73 alShape = new ActionListener() { 74 public void actionPerformed(java.awt.event.ActionEvent e) { 75 if (pillarButton.isSelected()) { 76 dlg.mark.setShape(Shp.PILLAR); 77 pillarButton.setBorderPainted(true); 78 } else { 79 pillarButton.setBorderPainted(false); 80 } 81 if (sparButton.isSelected()) { 82 dlg.mark.setShape(Shp.SPAR); 83 sparButton.setBorderPainted(true); 84 } else { 85 sparButton.setBorderPainted(false); 86 } 87 if (canButton.isSelected()) { 88 dlg.mark.setShape(Shp.CAN); 89 canButton.setBorderPainted(true); 90 } else { 91 canButton.setBorderPainted(false); 92 } 93 if (floatButton.isSelected()) { 94 dlg.mark.setShape(Shp.FLOAT); 95 floatButton.setBorderPainted(true); 96 } else { 97 floatButton.setBorderPainted(false); 98 } 99 if (beaconButton.isSelected()) { 100 dlg.mark.setShape(Shp.BEACON); 101 beaconButton.setBorderPainted(true); 102 } else { 103 beaconButton.setBorderPainted(false); 104 } 105 if (towerButton.isSelected()) { 106 dlg.mark.setShape(Shp.TOWER); 107 towerButton.setBorderPainted(true); 108 } else { 109 towerButton.setBorderPainted(false); 110 } 111 if (dlg.mark != null) 112 dlg.mark.paintSign(); 113 } 114 }; 115 pillarButton.addActionListener(alShape); 116 sparButton.addActionListener(alShape); 117 canButton.addActionListener(alShape); 118 floatButton.addActionListener(alShape); 119 beaconButton.addActionListener(alShape); 120 towerButton.addActionListener(alShape); 69 this.add(getRegionButton(regionAButton, 0, 2, 34, 30, "RegionATip"), null); 70 this.add(getRegionButton(regionBButton, 0, 32, 34, 30, "RegionBTip"), null); 71 this.add(getShapeButton(pillarButton, 0, 64, 34, 32, "PillarTip", Shp.PILLAR), null); 72 this.add(getShapeButton(sparButton, 0, 96, 34, 32, "SparTip", Shp.SPAR), null); 73 this.add(getShapeButton(canButton, 0, 128, 34, 32, "CanTip", Shp.CAN), null); 74 this.add(getShapeButton(floatButton, 35, 0, 34, 32, "FloatTip", Shp.FLOAT), null); 75 this.add(getShapeButton(beaconButton, 35, 32, 34, 32, "BeaconTip", Shp.BEACON), null); 76 this.add(getShapeButton(towerButton, 35, 64, 34, 32, "TowerTip", Shp.TOWER), null); 121 77 } 122 78 … … 126 82 } 127 83 128 private JRadioButton get Button(JRadioButton button, int x, int y, int w, int h, String tip) {84 private JRadioButton getRegionButton(JRadioButton button, int x, int y, int w, int h, String tip) { 129 85 button.setBounds(new Rectangle(x, y, w, h)); 130 86 button.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 131 87 button.setToolTipText(Messages.getString(tip)); 88 button.addActionListener(alRegion); 89 regionButtons.add(button); 90 return button; 91 } 92 93 private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp) { 94 button.setBounds(new Rectangle(x, y, w, h)); 95 button.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 96 button.setToolTipText(Messages.getString(tip)); 97 button.addActionListener(alShape); 98 shapeButtons.add(button); 99 shapes.put(shp, button); 132 100 return button; 133 101 } -
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelPrefStbd.java
r24870 r24872 23 23 import java.awt.Cursor; 24 24 import java.awt.event.ActionListener; 25 import java.util.EnumMap; 26 import java.util.Iterator; 25 27 26 28 public class PanelPrefStbd extends JPanel { 27 29 28 30 private OSeaMAction dlg; 29 private ButtonGroup regionButtons = n ull;31 private ButtonGroup regionButtons = new ButtonGroup(); 30 32 public JRadioButton regionAButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionAButton.png"))); 31 33 public JRadioButton regionBButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionBButton.png"))); 32 private ButtonGroup shapeButtons = null; 34 private ActionListener alRegion = new ActionListener() { 35 public void actionPerformed(java.awt.event.ActionEvent e) { 36 regionAButton.setBorderPainted(regionAButton.isSelected()); 37 regionBButton.setBorderPainted(regionBButton.isSelected()); 38 dlg.mark.paintSign(); 39 } 40 }; 41 private ButtonGroup shapeButtons = new ButtonGroup(); 33 42 public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 34 43 public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); … … 37 46 public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png"))); 38 47 public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png"))); 39 private ActionListener alShape = null; 48 private EnumMap<Shp, JRadioButton> shapes = new EnumMap<Shp, JRadioButton>(Shp.class); 49 private ActionListener alShape = new ActionListener() { 50 public void actionPerformed(java.awt.event.ActionEvent e) { 51 Iterator<Shp> it = shapes.keySet().iterator(); 52 while (it.hasNext()) { 53 Shp shp = it.next(); 54 JRadioButton button = shapes.get(shp); 55 if (button.isSelected()) { 56 dlg.mark.setShape(shp); 57 button.setBorderPainted(true); 58 } else 59 button.setBorderPainted(false); 60 } 61 if (dlg.mark != null) 62 dlg.mark.paintSign(); 63 } 64 }; 40 65 41 66 public PanelPrefStbd(OSeaMAction dia) { 42 67 dlg = dia; 43 68 this.setLayout(null); 44 this.add(get Button(regionAButton, 0, 2, 34, 30, "RegionATip"), null);45 this.add(get Button(regionBButton, 0, 32, 34, 30, "RegionBTip"), null);46 this.add(get Button(pillarButton, 0, 64, 34, 32, "PillarTip"), null);47 this.add(get Button(sparButton, 0, 96, 34, 32, "SparTip"), null);48 this.add(get Button(coneButton, 0, 128, 34, 32, "ConeTip"), null);49 this.add(get Button(floatButton, 35, 0, 34, 32, "FloatTip"), null);50 this.add(get Button(beaconButton, 35, 32, 34, 32, "BeaconTip"), null);51 this.add(get Button(towerButton, 35, 64, 34, 32, "TowerTip"), null);69 this.add(getRegionButton(regionAButton, 0, 2, 34, 30, "RegionATip"), null); 70 this.add(getRegionButton(regionBButton, 0, 32, 34, 30, "RegionBTip"), null); 71 this.add(getShapeButton(pillarButton, 0, 64, 34, 32, "PillarTip", Shp.PILLAR), null); 72 this.add(getShapeButton(sparButton, 0, 96, 34, 32, "SparTip", Shp.SPAR), null); 73 this.add(getShapeButton(coneButton, 0, 128, 34, 32, "ConeTip", Shp.CONE), null); 74 this.add(getShapeButton(floatButton, 35, 0, 34, 32, "FloatTip", Shp.FLOAT), null); 75 this.add(getShapeButton(beaconButton, 35, 32, 34, 32, "BeaconTip", Shp.BEACON), null); 76 this.add(getShapeButton(towerButton, 35, 64, 34, 32, "TowerTip", Shp.TOWER), null); 52 77 53 regionButtons = new ButtonGroup();54 regionButtons.add(regionAButton);55 regionButtons.add(regionBButton);56 ActionListener alRegion = new ActionListener() {57 public void actionPerformed(java.awt.event.ActionEvent e) {58 regionAButton.setBorderPainted(regionAButton.isSelected());59 regionBButton.setBorderPainted(regionBButton.isSelected());60 dlg.mark.paintSign();61 }62 };63 regionAButton.addActionListener(alRegion);64 regionBButton.addActionListener(alRegion);65 66 shapeButtons = new ButtonGroup();67 shapeButtons.add(pillarButton);68 shapeButtons.add(sparButton);69 shapeButtons.add(coneButton);70 shapeButtons.add(floatButton);71 shapeButtons.add(beaconButton);72 shapeButtons.add(towerButton);73 alShape = new ActionListener() {74 public void actionPerformed(java.awt.event.ActionEvent e) {75 if (pillarButton.isSelected()) {76 dlg.mark.setShape(Shp.PILLAR);77 pillarButton.setBorderPainted(true);78 } else {79 pillarButton.setBorderPainted(false);80 }81 if (sparButton.isSelected()) {82 dlg.mark.setShape(Shp.SPAR);83 sparButton.setBorderPainted(true);84 } else {85 sparButton.setBorderPainted(false);86 }87 if (coneButton.isSelected()) {88 dlg.mark.setShape(Shp.CONE);89 coneButton.setBorderPainted(true);90 } else {91 coneButton.setBorderPainted(false);92 }93 if (floatButton.isSelected()) {94 dlg.mark.setShape(Shp.FLOAT);95 floatButton.setBorderPainted(true);96 } else {97 floatButton.setBorderPainted(false);98 }99 if (beaconButton.isSelected()) {100 dlg.mark.setShape(Shp.BEACON);101 beaconButton.setBorderPainted(true);102 } else {103 beaconButton.setBorderPainted(false);104 }105 if (towerButton.isSelected()) {106 dlg.mark.setShape(Shp.TOWER);107 towerButton.setBorderPainted(true);108 } else {109 towerButton.setBorderPainted(false);110 }111 if (dlg.mark != null)112 dlg.mark.paintSign();113 }114 };115 pillarButton.addActionListener(alShape);116 sparButton.addActionListener(alShape);117 coneButton.addActionListener(alShape);118 floatButton.addActionListener(alShape);119 beaconButton.addActionListener(alShape);120 towerButton.addActionListener(alShape);121 78 } 122 79 … … 126 83 } 127 84 128 private JRadioButton get Button(JRadioButton button, int x, int y, int w, int h, String tip) {85 private JRadioButton getRegionButton(JRadioButton button, int x, int y, int w, int h, String tip) { 129 86 button.setBounds(new Rectangle(x, y, w, h)); 130 87 button.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 131 88 button.setToolTipText(Messages.getString(tip)); 89 button.addActionListener(alRegion); 90 regionButtons.add(button); 91 return button; 92 } 93 94 private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp) { 95 button.setBounds(new Rectangle(x, y, w, h)); 96 button.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 97 button.setToolTipText(Messages.getString(tip)); 98 button.addActionListener(alShape); 99 shapeButtons.add(button); 100 shapes.put(shp, button); 132 101 return button; 133 102 } -
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelSafeWater.java
r24839 r24872 23 23 import java.awt.Cursor; 24 24 import java.awt.event.ActionListener; 25 import java.util.EnumMap; 26 import java.util.Iterator; 25 27 26 28 public class PanelSafeWater extends JPanel { 27 29 28 30 private OSeaMAction dlg; 29 private ButtonGroup shapeButtons = null; 30 private JRadioButton pillarButton = null; 31 private JRadioButton sparButton = null; 32 private JRadioButton sphereButton = null; 33 private JRadioButton barrelButton = null; 34 private JRadioButton floatButton = null; 35 private ActionListener alShape = null; 31 private ButtonGroup shapeButtons = new ButtonGroup(); 32 private JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 33 private JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); 34 private JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png"))); 35 private JRadioButton barrelButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BarrelButton.png"))); 36 private JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png"))); 37 private EnumMap<Shp, JRadioButton> shapes = new EnumMap<Shp, JRadioButton>(Shp.class); 38 private ActionListener alShape = new ActionListener() { 39 public void actionPerformed(java.awt.event.ActionEvent e) { 40 Iterator<Shp> it = shapes.keySet().iterator(); 41 while (it.hasNext()) { 42 Shp shp = it.next(); 43 JRadioButton button = shapes.get(shp); 44 if (button.isSelected()) { 45 dlg.mark.setShape(shp); 46 button.setBorderPainted(true); 47 } else 48 button.setBorderPainted(false); 49 } 50 if (dlg.mark != null) 51 dlg.mark.paintSign(); 52 } 53 }; 36 54 37 55 public PanelSafeWater(OSeaMAction dia) { 38 56 dlg = dia; 39 57 this.setLayout(null); 40 this.add(getPillarButton(), null); 41 this.add(getSparButton(), null); 42 this.add(getSphereButton(), null); 43 this.add(getBarrelButton(), null); 44 this.add(getFloatButton(), null); 45 46 shapeButtons = new ButtonGroup(); 47 shapeButtons.add(pillarButton); 48 shapeButtons.add(sparButton); 49 shapeButtons.add(sphereButton); 50 shapeButtons.add(barrelButton); 51 shapeButtons.add(floatButton); 52 alShape = new ActionListener() { 53 public void actionPerformed(java.awt.event.ActionEvent e) { 54 if (pillarButton.isSelected()) { 55 dlg.mark.setShape(Shp.PILLAR); 56 pillarButton.setBorderPainted(true); 57 } else { 58 pillarButton.setBorderPainted(false); 59 } 60 if (sparButton.isSelected()) { 61 dlg.mark.setShape(Shp.SPAR); 62 sparButton.setBorderPainted(true); 63 } else { 64 sparButton.setBorderPainted(false); 65 } 66 if (sphereButton.isSelected()) { 67 dlg.mark.setShape(Shp.SPHERE); 68 sphereButton.setBorderPainted(true); 69 } else { 70 sphereButton.setBorderPainted(false); 71 } 72 if (barrelButton.isSelected()) { 73 dlg.mark.setShape(Shp.BARREL); 74 barrelButton.setBorderPainted(true); 75 } else { 76 barrelButton.setBorderPainted(false); 77 } 78 if (floatButton.isSelected()) { 79 dlg.mark.setShape(Shp.FLOAT); 80 floatButton.setBorderPainted(true); 81 } else { 82 floatButton.setBorderPainted(false); 83 } 84 if (dlg.mark != null) 85 dlg.mark.paintSign(); 86 } 87 }; 88 pillarButton.addActionListener(alShape); 89 sparButton.addActionListener(alShape); 90 sphereButton.addActionListener(alShape); 91 barrelButton.addActionListener(alShape); 92 floatButton.addActionListener(alShape); 58 this.add(getShapeButton(pillarButton, 0, 0, 34, 32, "PillarTip", Shp.PILLAR), null); 59 this.add(getShapeButton(sparButton, 0, 32, 34, 32, "SparTip", Shp.SPAR), null); 60 this.add(getShapeButton(sphereButton, 0, 64, 34, 32, "SphereTip", Shp.SPHERE), null); 61 this.add(getShapeButton(barrelButton, 0, 96, 34, 32, "BarrelTip", Shp.BARREL), null); 62 this.add(getShapeButton(floatButton, 0, 128, 34, 32, "FloatTip", Shp.FLOAT), null); 93 63 } 94 64 … … 98 68 } 99 69 100 private JRadioButton getPillarButton() { 101 if (pillarButton == null) { 102 pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 103 pillarButton.setBounds(new Rectangle(0, 0, 34, 32)); 104 pillarButton.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 105 pillarButton.setToolTipText(Messages.getString("PillarTip")); 106 } 107 return pillarButton; 108 } 109 110 private JRadioButton getSparButton() { 111 if (sparButton == null) { 112 sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); 113 sparButton.setBounds(new Rectangle(0, 32, 34, 32)); 114 sparButton.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 115 sparButton.setToolTipText(Messages.getString("SparTip")); 116 } 117 return sparButton; 118 } 119 120 private JRadioButton getSphereButton() { 121 if (sphereButton == null) { 122 sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png"))); 123 sphereButton.setBounds(new Rectangle(0, 64, 34, 32)); 124 sphereButton.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 125 sphereButton.setToolTipText(Messages.getString("SphereTip")); 126 } 127 return sphereButton; 128 } 129 130 private JRadioButton getBarrelButton() { 131 if (barrelButton == null) { 132 barrelButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BarrelButton.png"))); 133 barrelButton.setBounds(new Rectangle(0, 96, 34, 32)); 134 barrelButton.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 135 barrelButton.setToolTipText(Messages.getString("BarrelTip")); 136 } 137 return barrelButton; 138 } 139 140 private JRadioButton getFloatButton() { 141 if (floatButton == null) { 142 floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png"))); 143 floatButton.setBounds(new Rectangle(0, 128, 34, 32)); 144 floatButton.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 145 floatButton.setToolTipText(Messages.getString("FloatTip")); 146 } 147 return floatButton; 70 private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp) { 71 button.setBounds(new Rectangle(x, y, w, h)); 72 button.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 73 button.setToolTipText(Messages.getString(tip)); 74 button.addActionListener(alShape); 75 shapeButtons.add(button); 76 shapes.put(shp, button); 77 return button; 148 78 } 149 79 -
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelStbd.java
r24870 r24872 23 23 import java.awt.Cursor; 24 24 import java.awt.event.ActionListener; 25 import java.util.EnumMap; 26 import java.util.Iterator; 25 27 26 28 public class PanelStbd extends JPanel { 27 29 28 30 private OSeaMAction dlg; 29 private ButtonGroup regionButtons = n ull;31 private ButtonGroup regionButtons = new ButtonGroup(); 30 32 public JRadioButton regionAButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionAButton.png"))); 31 33 public JRadioButton regionBButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/RegionBButton.png"))); 32 private ButtonGroup shapeButtons = null; 34 private ActionListener alRegion = new ActionListener() { 35 public void actionPerformed(java.awt.event.ActionEvent e) { 36 regionAButton.setBorderPainted(regionAButton.isSelected()); 37 regionBButton.setBorderPainted(regionBButton.isSelected()); 38 dlg.mark.paintSign(); 39 } 40 }; 41 private ButtonGroup shapeButtons = new ButtonGroup(); 33 42 public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 34 43 public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); … … 38 47 public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png"))); 39 48 public JRadioButton perchButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PerchSButton.png"))); 40 private ActionListener alShape = null; 49 private EnumMap<Shp, JRadioButton> shapes = new EnumMap<Shp, JRadioButton>(Shp.class); 50 private ActionListener alShape = new ActionListener() { 51 public void actionPerformed(java.awt.event.ActionEvent e) { 52 Iterator<Shp> it = shapes.keySet().iterator(); 53 while (it.hasNext()) { 54 Shp shp = it.next(); 55 JRadioButton button = shapes.get(shp); 56 if (button.isSelected()) { 57 dlg.mark.setShape(shp); 58 button.setBorderPainted(true); 59 } else 60 button.setBorderPainted(false); 61 } 62 if (dlg.mark != null) 63 dlg.mark.paintSign(); 64 } 65 }; 41 66 42 67 public PanelStbd(OSeaMAction dia) { 43 68 dlg = dia; 44 69 this.setLayout(null); 45 this.add(getButton(regionAButton, 0, 2, 34, 30, "RegionATip"), null); 46 this.add(getButton(regionBButton, 0, 32, 34, 30, "RegionBTip"), null); 47 this.add(getButton(pillarButton, 0, 64, 34, 32, "PillarTip"), null); 48 this.add(getButton(sparButton, 0, 96, 34, 32, "SparTip"), null); 49 this.add(getButton(coneButton, 0, 128, 34, 32, "ConeTip"), null); 50 this.add(getButton(floatButton, 35, 0, 34, 32, "FloatTip"), null); 51 this.add(getButton(beaconButton, 35, 32, 34, 32, "BeaconTip"), null); 52 this.add(getButton(towerButton, 35, 64, 34, 32, "TowerTip"), null); 53 this.add(getButton(perchButton, 35, 96, 34, 32, "PerchTip"), null); 54 55 regionButtons = new ButtonGroup(); 56 regionButtons.add(regionAButton); 57 regionButtons.add(regionBButton); 58 ActionListener alRegion = new ActionListener() { 59 public void actionPerformed(java.awt.event.ActionEvent e) { 60 regionAButton.setBorderPainted(regionAButton.isSelected()); 61 regionBButton.setBorderPainted(regionBButton.isSelected()); 62 dlg.mark.paintSign(); 63 } 64 }; 65 regionAButton.addActionListener(alRegion); 66 regionBButton.addActionListener(alRegion); 67 68 shapeButtons = new ButtonGroup(); 69 shapeButtons.add(pillarButton); 70 shapeButtons.add(sparButton); 71 shapeButtons.add(coneButton); 72 shapeButtons.add(floatButton); 73 shapeButtons.add(beaconButton); 74 shapeButtons.add(towerButton); 75 shapeButtons.add(perchButton); 76 alShape = new ActionListener() { 77 public void actionPerformed(java.awt.event.ActionEvent e) { 78 if (pillarButton.isSelected()) { 79 dlg.mark.setShape(Shp.PILLAR); 80 pillarButton.setBorderPainted(true); 81 } else { 82 pillarButton.setBorderPainted(false); 83 } 84 if (sparButton.isSelected()) { 85 dlg.mark.setShape(Shp.SPAR); 86 sparButton.setBorderPainted(true); 87 } else { 88 sparButton.setBorderPainted(false); 89 } 90 if (coneButton.isSelected()) { 91 dlg.mark.setShape(Shp.CONE); 92 coneButton.setBorderPainted(true); 93 } else { 94 coneButton.setBorderPainted(false); 95 } 96 if (floatButton.isSelected()) { 97 dlg.mark.setShape(Shp.FLOAT); 98 floatButton.setBorderPainted(true); 99 } else { 100 floatButton.setBorderPainted(false); 101 } 102 if (beaconButton.isSelected()) { 103 dlg.mark.setShape(Shp.BEACON); 104 beaconButton.setBorderPainted(true); 105 } else { 106 beaconButton.setBorderPainted(false); 107 } 108 if (towerButton.isSelected()) { 109 dlg.mark.setShape(Shp.TOWER); 110 towerButton.setBorderPainted(true); 111 } else { 112 towerButton.setBorderPainted(false); 113 } 114 if (perchButton.isSelected()) { 115 dlg.mark.setShape(Shp.PERCH); 116 perchButton.setBorderPainted(true); 117 } else { 118 perchButton.setBorderPainted(false); 119 } 120 if (dlg.mark != null) 121 dlg.mark.paintSign(); 122 } 123 }; 124 pillarButton.addActionListener(alShape); 125 sparButton.addActionListener(alShape); 126 coneButton.addActionListener(alShape); 127 floatButton.addActionListener(alShape); 128 beaconButton.addActionListener(alShape); 129 towerButton.addActionListener(alShape); 130 perchButton.addActionListener(alShape); 70 this.add(getRegionButton(regionAButton, 0, 2, 34, 30, "RegionATip"), null); 71 this.add(getRegionButton(regionBButton, 0, 32, 34, 30, "RegionBTip"), null); 72 this.add(getShapeButton(pillarButton, 0, 64, 34, 32, "PillarTip", Shp.PILLAR), null); 73 this.add(getShapeButton(sparButton, 0, 96, 34, 32, "SparTip", Shp.SPAR), null); 74 this.add(getShapeButton(coneButton, 0, 128, 34, 32, "ConeTip", Shp.CONE), null); 75 this.add(getShapeButton(floatButton, 35, 0, 34, 32, "FloatTip", Shp.FLOAT), null); 76 this.add(getShapeButton(beaconButton, 35, 32, 34, 32, "BeaconTip", Shp.BEACON), null); 77 this.add(getShapeButton(towerButton, 35, 64, 34, 32, "TowerTip", Shp.TOWER), null); 78 this.add(getShapeButton(perchButton, 35, 96, 34, 32, "PerchTip", Shp.PERCH), null); 131 79 } 132 80 … … 136 84 } 137 85 138 private JRadioButton get Button(JRadioButton button, int x, int y, int w, int h, String tip) {86 private JRadioButton getRegionButton(JRadioButton button, int x, int y, int w, int h, String tip) { 139 87 button.setBounds(new Rectangle(x, y, w, h)); 140 88 button.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 141 89 button.setToolTipText(Messages.getString(tip)); 90 button.addActionListener(alRegion); 91 regionButtons.add(button); 92 return button; 93 } 94 95 private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp) { 96 button.setBounds(new Rectangle(x, y, w, h)); 97 button.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 98 button.setToolTipText(Messages.getString(tip)); 99 button.addActionListener(alShape); 100 shapeButtons.add(button); 101 shapes.put(shp, button); 142 102 return button; 143 103 } -
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/seamarks/SeaMark.java
r24870 r24872 101 101 102 102 public enum Top { 103 UNKNOWN, X_SHAPE, CAN, CONE104 } 105 106 private boolean TopMark = false;103 NONE, CAN, CONE, SPHERE, X_SHAPE, NORTH, SOUTH, EAST, WEST, SPHERES2, BOARD, DIAMOND, TRIANGLE, TRIANGLE_INV, SQUARE, MOORING 104 } 105 106 private Top TopMark = Top.NONE; 107 107 108 108 public boolean hasTopMark() { 109 return TopMark;110 } 111 112 public void setTopMark( boolean topMark) {113 TopMark = top Mark;109 return (TopMark != Top.NONE); 110 } 111 112 public void setTopMark(Top top) { 113 TopMark = top; 114 114 } 115 115
Note:
See TracChangeset
for help on using the changeset viewer.