Changeset 32767 in osm for applications/editors/josm/plugins/smed/src/panels/PanelHaz.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/PanelHaz.java
r30738 r32767 1 1 package panels; 2 2 3 import java.awt.event.*; 4 import java.awt.*; 5 6 import javax.swing.*; 7 8 import java.util.*; 3 import java.awt.Rectangle; 4 import java.awt.event.ActionEvent; 5 import java.awt.event.ActionListener; 6 import java.util.EnumMap; 7 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; 13 import javax.swing.JToggleButton; 9 14 10 15 import messages.Messages; 16 import seamarks.SeaMark; 17 import seamarks.SeaMark.Att; 18 import seamarks.SeaMark.Cat; 19 import seamarks.SeaMark.Col; 20 import seamarks.SeaMark.Grp; 21 import seamarks.SeaMark.Obj; 22 import seamarks.SeaMark.Pat; 23 import seamarks.SeaMark.Shp; 24 import seamarks.SeaMark.Top; 11 25 import smed.SmedAction; 12 import seamarks.SeaMark;13 import seamarks.SeaMark.*;14 26 15 27 public class PanelHaz extends JPanel { 16 28 17 private SmedAction dlg; 18 public ButtonGroup catButtons = new ButtonGroup(); 19 public JRadioButton northButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardNButton.png"))); 20 public JRadioButton southButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardSButton.png"))); 21 public JRadioButton eastButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardEButton.png"))); 22 public JRadioButton westButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardWButton.png"))); 23 public JRadioButton isolButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/IsolButton.png"))); 24 private ActionListener alCat = new ActionListener() { 25 public void actionPerformed(java.awt.event.ActionEvent e) { 26 SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP); 27 if (northButton.isSelected()) { 28 SmedAction.panelMain.mark.setCategory(Cat.CAM_NORTH); 29 SmedAction.panelMain.mark.setObjColour(Col.BLACK); 30 SmedAction.panelMain.mark.addObjColour(Col.YELLOW); 31 northButton.setBorderPainted(true); 32 } else { 33 northButton.setBorderPainted(false); 34 } 35 if (southButton.isSelected()) { 36 SmedAction.panelMain.mark.setCategory(Cat.CAM_SOUTH); 37 SmedAction.panelMain.mark.setObjColour(Col.YELLOW); 38 SmedAction.panelMain.mark.addObjColour(Col.BLACK); 39 southButton.setBorderPainted(true); 40 } else { 41 southButton.setBorderPainted(false); 42 } 43 if (eastButton.isSelected()) { 44 SmedAction.panelMain.mark.setCategory(Cat.CAM_EAST); 45 SmedAction.panelMain.mark.setObjColour(Col.BLACK); 46 SmedAction.panelMain.mark.addObjColour(Col.YELLOW); 47 SmedAction.panelMain.mark.addObjColour(Col.BLACK); 48 eastButton.setBorderPainted(true); 49 } else { 50 eastButton.setBorderPainted(false); 51 } 52 if (westButton.isSelected()) { 53 SmedAction.panelMain.mark.setCategory(Cat.CAM_WEST); 54 SmedAction.panelMain.mark.setObjColour(Col.YELLOW); 55 SmedAction.panelMain.mark.addObjColour(Col.BLACK); 56 SmedAction.panelMain.mark.addObjColour(Col.YELLOW); 57 westButton.setBorderPainted(true); 58 } else { 59 westButton.setBorderPainted(false); 60 } 61 if (isolButton.isSelected()) { 62 SmedAction.panelMain.mark.setCategory(Cat.NOCAT); 63 SmedAction.panelMain.mark.setObjColour(Col.BLACK); 64 SmedAction.panelMain.mark.addObjColour(Col.RED); 65 SmedAction.panelMain.mark.addObjColour(Col.BLACK); 66 isolButton.setBorderPainted(true); 67 } else { 68 isolButton.setBorderPainted(false); 69 } 70 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid()); 71 lightButton.setVisible(SmedAction.panelMain.mark.testValid()); 72 SmedAction.panelMain.panelMore.syncPanel(); 73 } 74 }; 75 private ButtonGroup shapeButtons = new ButtonGroup(); 76 public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 77 public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); 78 public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png"))); 79 public JRadioButton canButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanButton.png"))); 80 public JRadioButton coneButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeButton.png"))); 81 public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png"))); 82 public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png"))); 83 public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png"))); 84 public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class); 85 public EnumMap<Shp, Obj> carObjects = new EnumMap<>(Shp.class); 86 public EnumMap<Shp, Obj> isdObjects = new EnumMap<>(Shp.class); 87 private ActionListener alShape = new ActionListener() { 88 public void actionPerformed(java.awt.event.ActionEvent e) { 89 for (Shp shp : shapes.keySet()) { 90 JRadioButton button = shapes.get(shp); 91 if (button.isSelected()) { 92 SmedAction.panelMain.mark.setShape(shp); 93 if (isolButton.isSelected()) 94 SmedAction.panelMain.mark.setObject(isdObjects.get(shp)); 95 else 96 SmedAction.panelMain.mark.setObject(carObjects.get(shp)); 97 button.setBorderPainted(true); 98 } else 99 button.setBorderPainted(false); 100 } 101 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid()); 102 lightButton.setVisible(SmedAction.panelMain.mark.testValid()); 103 } 104 }; 105 public JToggleButton topmarkButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/HazTopButton.png"))); 106 private ActionListener alTop = new ActionListener() { 107 public void actionPerformed(java.awt.event.ActionEvent e) { 108 if (topmarkButton.isSelected()) { 109 SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT); 110 SmedAction.panelMain.mark.setTopColour(Col.BLACK); 111 switch (SmedAction.panelMain.mark.getCategory()) { 112 case CAM_NORTH: 113 SmedAction.panelMain.mark.setTopmark(Top.NORTH); 114 break; 115 case CAM_SOUTH: 116 SmedAction.panelMain.mark.setTopmark(Top.SOUTH); 117 break; 118 case CAM_EAST: 119 SmedAction.panelMain.mark.setTopmark(Top.EAST); 120 break; 121 case CAM_WEST: 122 SmedAction.panelMain.mark.setTopmark(Top.WEST); 123 break; 124 default: 125 SmedAction.panelMain.mark.setTopmark(Top.SPHERES2); 126 break; 127 } 128 topmarkButton.setBorderPainted(true); 129 } else { 130 SmedAction.panelMain.mark.setTopmark(Top.NOTOP); 131 SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT); 132 SmedAction.panelMain.mark.setTopColour(Col.UNKCOL); 133 topmarkButton.setBorderPainted(false); 134 } 135 SmedAction.panelMain.panelTop.syncPanel(); 136 } 137 }; 138 public JToggleButton lightButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/DefLitButton.png"))); 139 private ActionListener alLit = new ActionListener() { 140 public void actionPerformed(java.awt.event.ActionEvent e) { 141 if (lightButton.isSelected()) { 142 SmedAction.panelMain.mark.setLightAtt(Att.COL, 0, Col.WHITE); 143 switch (SmedAction.panelMain.mark.getCategory()) { 144 case CAM_NORTH: 145 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q"); 146 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, ""); 147 break; 148 case CAM_SOUTH: 149 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q+LFl"); 150 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "6"); 151 break; 152 case CAM_EAST: 153 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q"); 154 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "3"); 155 break; 156 case CAM_WEST: 157 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q"); 158 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "9"); 159 break; 160 default: 161 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Fl"); 162 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "2"); 163 break; 164 } 165 lightButton.setBorderPainted(true); 166 } else { 167 SmedAction.panelMain.mark.clrLight(); 168 lightButton.setBorderPainted(false); 169 } 170 SmedAction.panelMain.panelLit.syncPanel(); 171 } 172 }; 173 174 public PanelHaz(SmedAction dia) { 175 dlg = dia; 176 setLayout(null); 177 add(getCatButton(northButton, 0, 0, 52, 32, "North")); 178 add(getCatButton(southButton, 0, 32, 52, 32, "South")); 179 add(getCatButton(eastButton, 0, 64, 52, 32, "East")); 180 add(getCatButton(westButton, 0, 96, 52, 32, "West")); 181 add(getCatButton(isolButton, 0, 128, 52, 32, "Isol")); 182 183 add(getShapeButton(pillarButton, 55, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYCAR, Obj.BOYISD)); 184 add(getShapeButton(sparButton, 55, 32, 34, 32, "Spar", Shp.SPAR, Obj.BOYCAR, Obj.BOYISD)); 185 add(getShapeButton(canButton, 55, 64, 34, 32, "Can", Shp.CAN, Obj.BOYCAR, Obj.BOYISD)); 186 add(getShapeButton(coneButton, 55, 96, 34, 32, "Cone", Shp.CONI, Obj.BOYCAR, Obj.BOYISD)); 187 add(getShapeButton(sphereButton, 55, 128, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYCAR, Obj.BOYISD)); 188 add(getShapeButton(floatButton, 90, 0, 34, 32, "Float", Shp.FLOAT, Obj.LITFLT, Obj.LITFLT)); 189 add(getShapeButton(beaconButton, 90, 32, 34, 32, "Beacon", Shp.BEACON, Obj.BCNCAR, Obj.BCNISD)); 190 add(getShapeButton(towerButton, 90, 64, 34, 32, "TowerB", Shp.TOWER, Obj.BCNCAR, Obj.BCNISD)); 191 192 topmarkButton.setBounds(new Rectangle(130, 0, 34, 32)); 193 topmarkButton.setToolTipText(Messages.getString("Topmark")); 194 topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder()); 195 topmarkButton.addActionListener(alTop); 196 topmarkButton.setVisible(false); 197 add(topmarkButton); 198 lightButton.setBounds(new Rectangle(130, 32, 34, 32)); 199 lightButton.setToolTipText(Messages.getString("Light")); 200 lightButton.setBorder(BorderFactory.createLoweredBevelBorder()); 201 lightButton.addActionListener(alLit); 202 lightButton.setVisible(false); 203 add(lightButton); 204 } 205 206 public void syncPanel() { 207 northButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_NORTH); 208 southButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_SOUTH); 209 eastButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_EAST); 210 westButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_WEST); 211 isolButton.setBorderPainted(SeaMark.GrpMAP.get(SmedAction.panelMain.mark.getObject()) == Grp.ISD); 212 for (Shp shp : shapes.keySet()) { 213 JRadioButton button = shapes.get(shp); 214 button.setBorderPainted(SmedAction.panelMain.mark.getShape() == shp); 215 } 216 topmarkButton.setBorderPainted(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP); 217 topmarkButton.setSelected(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP); 218 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid()); 219 Boolean lit = (SmedAction.panelMain.mark.getLightAtt(Att.COL, 0) != Col.UNKCOL) && !((String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, 0)).isEmpty(); 220 lightButton.setBorderPainted(lit); 221 lightButton.setSelected(lit); 222 lightButton.setVisible(SmedAction.panelMain.mark.testValid()); 223 } 224 225 private JRadioButton getCatButton(JRadioButton button, int x, int y, int w, int h, String tip) { 226 button.setBounds(new Rectangle(x, y, w, h)); 227 button.setBorder(BorderFactory.createLoweredBevelBorder()); 228 button.setToolTipText(Messages.getString(tip)); 229 button.addActionListener(alCat); 230 catButtons.add(button); 231 return button; 232 } 233 234 private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj car, Obj isd) { 235 button.setBounds(new Rectangle(x, y, w, h)); 236 button.setBorder(BorderFactory.createLoweredBevelBorder()); 237 button.setToolTipText(Messages.getString(tip)); 238 button.addActionListener(alShape); 239 shapeButtons.add(button); 240 shapes.put(shp, button); 241 carObjects.put(shp, car); 242 isdObjects.put(shp, isd); 243 return button; 244 } 29 private SmedAction dlg; 30 public ButtonGroup catButtons = new ButtonGroup(); 31 public JRadioButton northButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardNButton.png"))); 32 public JRadioButton southButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardSButton.png"))); 33 public JRadioButton eastButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardEButton.png"))); 34 public JRadioButton westButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CardWButton.png"))); 35 public JRadioButton isolButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/IsolButton.png"))); 36 private ActionListener alCat = new ActionListener() { 37 @Override 38 public void actionPerformed(ActionEvent e) { 39 SmedAction.panelMain.mark.setObjPattern(Pat.HSTRP); 40 if (northButton.isSelected()) { 41 SmedAction.panelMain.mark.setCategory(Cat.CAM_NORTH); 42 SmedAction.panelMain.mark.setObjColour(Col.BLACK); 43 SmedAction.panelMain.mark.addObjColour(Col.YELLOW); 44 northButton.setBorderPainted(true); 45 } else { 46 northButton.setBorderPainted(false); 47 } 48 if (southButton.isSelected()) { 49 SmedAction.panelMain.mark.setCategory(Cat.CAM_SOUTH); 50 SmedAction.panelMain.mark.setObjColour(Col.YELLOW); 51 SmedAction.panelMain.mark.addObjColour(Col.BLACK); 52 southButton.setBorderPainted(true); 53 } else { 54 southButton.setBorderPainted(false); 55 } 56 if (eastButton.isSelected()) { 57 SmedAction.panelMain.mark.setCategory(Cat.CAM_EAST); 58 SmedAction.panelMain.mark.setObjColour(Col.BLACK); 59 SmedAction.panelMain.mark.addObjColour(Col.YELLOW); 60 SmedAction.panelMain.mark.addObjColour(Col.BLACK); 61 eastButton.setBorderPainted(true); 62 } else { 63 eastButton.setBorderPainted(false); 64 } 65 if (westButton.isSelected()) { 66 SmedAction.panelMain.mark.setCategory(Cat.CAM_WEST); 67 SmedAction.panelMain.mark.setObjColour(Col.YELLOW); 68 SmedAction.panelMain.mark.addObjColour(Col.BLACK); 69 SmedAction.panelMain.mark.addObjColour(Col.YELLOW); 70 westButton.setBorderPainted(true); 71 } else { 72 westButton.setBorderPainted(false); 73 } 74 if (isolButton.isSelected()) { 75 SmedAction.panelMain.mark.setCategory(Cat.NOCAT); 76 SmedAction.panelMain.mark.setObjColour(Col.BLACK); 77 SmedAction.panelMain.mark.addObjColour(Col.RED); 78 SmedAction.panelMain.mark.addObjColour(Col.BLACK); 79 isolButton.setBorderPainted(true); 80 } else { 81 isolButton.setBorderPainted(false); 82 } 83 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid()); 84 lightButton.setVisible(SmedAction.panelMain.mark.testValid()); 85 SmedAction.panelMain.panelMore.syncPanel(); 86 } 87 }; 88 private ButtonGroup shapeButtons = new ButtonGroup(); 89 public JRadioButton pillarButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/PillarButton.png"))); 90 public JRadioButton sparButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SparButton.png"))); 91 public JRadioButton floatButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/FloatButton.png"))); 92 public JRadioButton canButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/CanButton.png"))); 93 public JRadioButton coneButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/ConeButton.png"))); 94 public JRadioButton sphereButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/SphereButton.png"))); 95 public JRadioButton beaconButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BeaconButton.png"))); 96 public JRadioButton towerButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/TowerButton.png"))); 97 public EnumMap<Shp, JRadioButton> shapes = new EnumMap<>(Shp.class); 98 public EnumMap<Shp, Obj> carObjects = new EnumMap<>(Shp.class); 99 public EnumMap<Shp, Obj> isdObjects = new EnumMap<>(Shp.class); 100 private ActionListener alShape = new ActionListener() { 101 @Override 102 public void actionPerformed(ActionEvent e) { 103 for (Shp shp : shapes.keySet()) { 104 JRadioButton button = shapes.get(shp); 105 if (button.isSelected()) { 106 SmedAction.panelMain.mark.setShape(shp); 107 if (isolButton.isSelected()) { 108 SmedAction.panelMain.mark.setObject(isdObjects.get(shp)); 109 } else { 110 SmedAction.panelMain.mark.setObject(carObjects.get(shp)); 111 } 112 button.setBorderPainted(true); 113 } else { 114 button.setBorderPainted(false); 115 } 116 } 117 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid()); 118 lightButton.setVisible(SmedAction.panelMain.mark.testValid()); 119 } 120 }; 121 public JToggleButton topmarkButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/HazTopButton.png"))); 122 private ActionListener alTop = new ActionListener() { 123 @Override 124 public void actionPerformed(ActionEvent e) { 125 if (topmarkButton.isSelected()) { 126 SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT); 127 SmedAction.panelMain.mark.setTopColour(Col.BLACK); 128 switch (SmedAction.panelMain.mark.getCategory()) { 129 case CAM_NORTH: 130 SmedAction.panelMain.mark.setTopmark(Top.NORTH); 131 break; 132 case CAM_SOUTH: 133 SmedAction.panelMain.mark.setTopmark(Top.SOUTH); 134 break; 135 case CAM_EAST: 136 SmedAction.panelMain.mark.setTopmark(Top.EAST); 137 break; 138 case CAM_WEST: 139 SmedAction.panelMain.mark.setTopmark(Top.WEST); 140 break; 141 default: 142 SmedAction.panelMain.mark.setTopmark(Top.SPHERES2); 143 break; 144 } 145 topmarkButton.setBorderPainted(true); 146 } else { 147 SmedAction.panelMain.mark.setTopmark(Top.NOTOP); 148 SmedAction.panelMain.mark.setTopPattern(Pat.NOPAT); 149 SmedAction.panelMain.mark.setTopColour(Col.UNKCOL); 150 topmarkButton.setBorderPainted(false); 151 } 152 SmedAction.panelMain.panelTop.syncPanel(); 153 } 154 }; 155 public JToggleButton lightButton = new JToggleButton(new ImageIcon(getClass().getResource("/images/DefLitButton.png"))); 156 private ActionListener alLit = new ActionListener() { 157 @Override 158 public void actionPerformed(ActionEvent e) { 159 if (lightButton.isSelected()) { 160 SmedAction.panelMain.mark.setLightAtt(Att.COL, 0, Col.WHITE); 161 switch (SmedAction.panelMain.mark.getCategory()) { 162 case CAM_NORTH: 163 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q"); 164 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, ""); 165 break; 166 case CAM_SOUTH: 167 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q+LFl"); 168 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "6"); 169 break; 170 case CAM_EAST: 171 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q"); 172 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "3"); 173 break; 174 case CAM_WEST: 175 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Q"); 176 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "9"); 177 break; 178 default: 179 SmedAction.panelMain.mark.setLightAtt(Att.CHR, 0, "Fl"); 180 SmedAction.panelMain.mark.setLightAtt(Att.GRP, 0, "2"); 181 break; 182 } 183 lightButton.setBorderPainted(true); 184 } else { 185 SmedAction.panelMain.mark.clrLight(); 186 lightButton.setBorderPainted(false); 187 } 188 SmedAction.panelMain.panelLit.syncPanel(); 189 } 190 }; 191 192 public PanelHaz(SmedAction dia) { 193 dlg = dia; 194 setLayout(null); 195 add(getCatButton(northButton, 0, 0, 52, 32, "North")); 196 add(getCatButton(southButton, 0, 32, 52, 32, "South")); 197 add(getCatButton(eastButton, 0, 64, 52, 32, "East")); 198 add(getCatButton(westButton, 0, 96, 52, 32, "West")); 199 add(getCatButton(isolButton, 0, 128, 52, 32, "Isol")); 200 201 add(getShapeButton(pillarButton, 55, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYCAR, Obj.BOYISD)); 202 add(getShapeButton(sparButton, 55, 32, 34, 32, "Spar", Shp.SPAR, Obj.BOYCAR, Obj.BOYISD)); 203 add(getShapeButton(canButton, 55, 64, 34, 32, "Can", Shp.CAN, Obj.BOYCAR, Obj.BOYISD)); 204 add(getShapeButton(coneButton, 55, 96, 34, 32, "Cone", Shp.CONI, Obj.BOYCAR, Obj.BOYISD)); 205 add(getShapeButton(sphereButton, 55, 128, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYCAR, Obj.BOYISD)); 206 add(getShapeButton(floatButton, 90, 0, 34, 32, "Float", Shp.FLOAT, Obj.LITFLT, Obj.LITFLT)); 207 add(getShapeButton(beaconButton, 90, 32, 34, 32, "Beacon", Shp.BEACON, Obj.BCNCAR, Obj.BCNISD)); 208 add(getShapeButton(towerButton, 90, 64, 34, 32, "TowerB", Shp.TOWER, Obj.BCNCAR, Obj.BCNISD)); 209 210 topmarkButton.setBounds(new Rectangle(130, 0, 34, 32)); 211 topmarkButton.setToolTipText(Messages.getString("Topmark")); 212 topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder()); 213 topmarkButton.addActionListener(alTop); 214 topmarkButton.setVisible(false); 215 add(topmarkButton); 216 lightButton.setBounds(new Rectangle(130, 32, 34, 32)); 217 lightButton.setToolTipText(Messages.getString("Light")); 218 lightButton.setBorder(BorderFactory.createLoweredBevelBorder()); 219 lightButton.addActionListener(alLit); 220 lightButton.setVisible(false); 221 add(lightButton); 222 } 223 224 public void syncPanel() { 225 northButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_NORTH); 226 southButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_SOUTH); 227 eastButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_EAST); 228 westButton.setBorderPainted(SmedAction.panelMain.mark.getCategory() == Cat.CAM_WEST); 229 isolButton.setBorderPainted(SeaMark.GrpMAP.get(SmedAction.panelMain.mark.getObject()) == Grp.ISD); 230 for (Shp shp : shapes.keySet()) { 231 JRadioButton button = shapes.get(shp); 232 button.setBorderPainted(SmedAction.panelMain.mark.getShape() == shp); 233 } 234 topmarkButton.setBorderPainted(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP); 235 topmarkButton.setSelected(SmedAction.panelMain.mark.getTopmark() != Top.NOTOP); 236 topmarkButton.setVisible(SmedAction.panelMain.mark.testValid()); 237 Boolean lit = (SmedAction.panelMain.mark.getLightAtt(Att.COL, 0) != Col.UNKCOL) && !((String)SmedAction.panelMain.mark.getLightAtt(Att.CHR, 0)).isEmpty(); 238 lightButton.setBorderPainted(lit); 239 lightButton.setSelected(lit); 240 lightButton.setVisible(SmedAction.panelMain.mark.testValid()); 241 } 242 243 private JRadioButton getCatButton(JRadioButton button, int x, int y, int w, int h, String tip) { 244 button.setBounds(new Rectangle(x, y, w, h)); 245 button.setBorder(BorderFactory.createLoweredBevelBorder()); 246 button.setToolTipText(Messages.getString(tip)); 247 button.addActionListener(alCat); 248 catButtons.add(button); 249 return button; 250 } 251 252 private JRadioButton getShapeButton(JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj car, Obj isd) { 253 button.setBounds(new Rectangle(x, y, w, h)); 254 button.setBorder(BorderFactory.createLoweredBevelBorder()); 255 button.setToolTipText(Messages.getString(tip)); 256 button.addActionListener(alShape); 257 shapeButtons.add(button); 258 shapes.put(shp, button); 259 carObjects.put(shp, car); 260 isdObjects.put(shp, isd); 261 return button; 262 } 245 263 246 264 }
Note:
See TracChangeset
for help on using the changeset viewer.