Changeset 24871 in osm for applications/editors/josm/plugins/smed/plugs/oseam/src
- Timestamp:
- 2010-12-24T22:11:19+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelCol.java
r24870 r24871 13 13 import javax.swing.JRadioButton; 14 14 15 16 15 import java.util.EnumMap; 17 16 import java.util.Iterator; … … 23 22 24 23 private OSeaMAction dlg; 25 private ButtonGroup colourButtons = n ull;24 private ButtonGroup colourButtons = new ButtonGroup(); 26 25 public JRadioButton offButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/OffButton.png"))); 27 26 public JRadioButton whiteButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/WhiteButton.png"))); … … 34 33 public JRadioButton violetButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/VioletButton.png"))); 35 34 public JRadioButton blackButton = new JRadioButton(new ImageIcon(getClass().getResource("/images/BlackButton.png"))); 36 private ActionListener alColour = null;37 35 private EnumMap<Col, JRadioButton> colours = new EnumMap<Col, JRadioButton>(Col.class); 36 private ActionListener alColour = new ActionListener() { 37 public void actionPerformed(java.awt.event.ActionEvent e) { 38 Iterator<Col> it = colours.keySet().iterator(); 39 while (it.hasNext()) { 40 Col col = it.next(); 41 JRadioButton button = colours.get(col); 42 if (button.isSelected()) { 43 button.setBorderPainted(true); 44 } else 45 button.setBorderPainted(false); 46 } 47 } 48 }; 38 49 39 50 public PanelCol(OSeaMAction dia) { 40 51 dlg = dia; 41 52 this.setLayout(null); 42 this.add(getButton(offButton, 0, 0, 34, 16, "No colour", Col.UNKNOWN), null); 43 this.add(getButton(whiteButton, 0, 16, 34, 16, "White", Col.WHITE), null); 44 this.add(getButton(redButton, 0, 32, 34, 16, "Red", Col.RED), null); 45 this.add(getButton(orangeButton, 0, 48, 34, 16, "Orange", Col.ORANGE), null); 46 this.add(getButton(amberButton, 0, 64, 34, 16, "Amber", Col.AMBER), null); 47 this.add(getButton(yellowButton, 0, 80, 34, 16, "Yellow", Col.YELLOW), null); 48 this.add(getButton(greenButton, 0, 96, 34, 16, "Green", Col.GREEN), null); 49 this.add(getButton(blueButton, 0, 112, 34, 16, "Blue", Col.BLUE), null); 50 this.add(getButton(violetButton, 0, 128, 34, 16, "Violet", Col.VIOLET), null); 51 this.add(getButton(blackButton, 0, 144, 34, 16, "Black", Col.BLACK), null); 52 colourButtons = new ButtonGroup(); 53 colourButtons.add(offButton); 54 colourButtons.add(whiteButton); 55 colourButtons.add(redButton); 56 colourButtons.add(orangeButton); 57 colourButtons.add(amberButton); 58 colourButtons.add(yellowButton); 59 colourButtons.add(greenButton); 60 colourButtons.add(blueButton); 61 colourButtons.add(violetButton); 62 colourButtons.add(blackButton); 63 alColour = new ActionListener() { 64 public void actionPerformed(java.awt.event.ActionEvent e) { 65 Iterator<Col> it = colours.keySet().iterator(); 66 while (it.hasNext()) { 67 Col col = it.next(); 68 JRadioButton button = colours.get(col); 69 if (button.isSelected()) { 70 switch (col) { 71 case UNKNOWN: { 72 break; 73 } 74 } 75 button.setBorderPainted(true); 76 } else button.setBorderPainted(false); 77 } 78 /* offButton.setBorderPainted(offButton.isSelected()); 79 whiteButton.setBorderPainted(whiteButton.isSelected()); 80 redButton.setBorderPainted(redButton.isSelected()); 81 orangeButton.setBorderPainted(orangeButton.isSelected()); 82 amberButton.setBorderPainted(amberButton.isSelected()); 83 yellowButton.setBorderPainted(yellowButton.isSelected()); 84 greenButton.setBorderPainted(greenButton.isSelected()); 85 blueButton.setBorderPainted(blueButton.isSelected()); 86 violetButton.setBorderPainted(violetButton.isSelected()); 87 blackButton.setBorderPainted(blackButton.isSelected()); 88 */ } 89 }; 90 offButton.addActionListener(alColour); 91 whiteButton.addActionListener(alColour); 92 redButton.addActionListener(alColour); 93 orangeButton.addActionListener(alColour); 94 amberButton.addActionListener(alColour); 95 yellowButton.addActionListener(alColour); 96 greenButton.addActionListener(alColour); 97 blueButton.addActionListener(alColour); 98 violetButton.addActionListener(alColour); 99 blackButton.addActionListener(alColour); 53 this.add(getColButton(offButton, 0, 0, 34, 16, "No colour", Col.UNKNOWN), null); 54 this.add(getColButton(whiteButton, 0, 16, 34, 16, "White", Col.WHITE), null); 55 this.add(getColButton(redButton, 0, 32, 34, 16, "Red", Col.RED), null); 56 this.add(getColButton(orangeButton, 0, 48, 34, 16, "Orange", Col.ORANGE), null); 57 this.add(getColButton(amberButton, 0, 64, 34, 16, "Amber", Col.AMBER), null); 58 this.add(getColButton(yellowButton, 0, 80, 34, 16, "Yellow", Col.YELLOW), null); 59 this.add(getColButton(greenButton, 0, 96, 34, 16, "Green", Col.GREEN), null); 60 this.add(getColButton(blueButton, 0, 112, 34, 16, "Blue", Col.BLUE), null); 61 this.add(getColButton(violetButton, 0, 128, 34, 16, "Violet", Col.VIOLET), null); 62 this.add(getColButton(blackButton, 0, 144, 34, 16, "Black", Col.BLACK), null); 100 63 } 101 64 102 65 public void clearSelections() { 103 66 colourButtons.clearSelection(); 104 alColour.actionPerformed(null);67 offButton.doClick(); 105 68 } 106 69 107 private JRadioButton get Button(JRadioButton button, int x, int y, int w, int h, String tip, Col col) {70 private JRadioButton getColButton(JRadioButton button, int x, int y, int w, int h, String tip, Col col) { 108 71 button.setBounds(new Rectangle(x, y, w, h)); 109 72 button.setBorder(BorderFactory.createLineBorder(Color.magenta, 2)); 110 73 button.setToolTipText(tr(tip)); 74 button.addActionListener(alColour); 111 75 colours.put(col, button); 76 colourButtons.add(button); 112 77 return button; 113 78 }
Note:
See TracChangeset
for help on using the changeset viewer.