Changeset 27214 in osm for applications/editors/josm/plugins
- Timestamp:
- 2011-12-12T00:02:04+01:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/smed/plugs/oseam/src/oseam
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelChr.java
r27200 r27214 18 18 19 19 private OSeaMAction dlg; 20 public JLabel col1Label = new JLabel(); 21 public JLabel col2Label = new JLabel(); 20 22 public JLabel charLabel = new JLabel(); 21 23 public JTextField charBox = new JTextField(); … … 64 66 } 65 67 } 66 dlg.panelMain.mark.setLightAtt(Att.CHR, 0, charBox.getText()); 68 String str = charBox.getText(); 69 dlg.panelMain.mark.setLightAtt(Att.CHR, 0, str); 70 if (!str.contains("Al")) { 71 col2Label.setBackground(SeaMark.ColMAP.get(dlg.panelMain.mark.getLightAtt(Att.COL, 0))); 72 dlg.panelMain.mark.setLightAtt(Att.ALT, 0, Col.UNKNOWN); 73 } else { 74 col2Label.setBackground(SeaMark.ColMAP.get(dlg.panelMain.mark.getLightAtt(Att.ALT, 0))); 75 } 67 76 } 68 77 }; … … 88 97 } 89 98 } 99 if (!str.contains("Al")) { 100 col2Label.setBackground(SeaMark.ColMAP.get(dlg.panelMain.mark.getLightAtt(Att.COL, 0))); 101 dlg.panelMain.mark.setLightAtt(Att.ALT, 0, Col.UNKNOWN); 102 } else { 103 col2Label.setBackground(SeaMark.ColMAP.get(dlg.panelMain.mark.getLightAtt(Att.ALT, 0))); 104 } 90 105 } 91 106 }; … … 107 122 this.add(getChrButton(interruptedQuickButton, 44, 64, 44, 16, Messages.getString("IQChar"), Chr.IQUICK), null); 108 123 this.add(getChrButton(interruptedVeryQuickButton, 44, 80, 44, 16, Messages.getString("IVQChar"), Chr.IVQUICK),null); 109 this.add(getChrButton(interruptedUltraQuickButton, 44, 96, 44, 16, Messages.getString("IUQChar"), Chr.IUQUICK), 110 null); 124 this.add(getChrButton(interruptedUltraQuickButton, 44, 96, 44, 16, Messages.getString("IUQChar"), Chr.IUQUICK), null); 111 125 charLabel.setBounds(new Rectangle(0, 113, 88, 20)); 112 126 charLabel.setHorizontalAlignment(SwingConstants.CENTER); 113 127 charLabel.setText(Messages.getString("Character")); 114 128 this.add(charLabel, null); 129 col1Label.setBounds(new Rectangle(10, 135, 10, 20)); 130 col1Label.setOpaque(true); 131 this.add(col1Label, null); 132 col2Label.setBounds(new Rectangle(70, 135, 10, 20)); 133 col2Label.setOpaque(true); 134 this.add(col2Label, null); 115 135 charBox.setBounds(new Rectangle(20, 135, 50, 20)); 116 136 charBox.setHorizontalAlignment(SwingConstants.CENTER); … … 129 149 } 130 150 } 151 if (!str.contains("Al")) { 152 col2Label.setBackground(SeaMark.ColMAP.get(dlg.panelMain.mark.getLightAtt(Att.COL, 0))); 153 } else { 154 col2Label.setBackground(SeaMark.ColMAP.get(dlg.panelMain.mark.getLightAtt(Att.ALT, 0))); 155 } 156 col1Label.setBackground(SeaMark.ColMAP.get(dlg.panelMain.mark.getLightAtt(Att.COL, 0))); 131 157 for (Chr chr : buttons.keySet()) { 132 158 JToggleButton button = buttons.get(chr); -
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelCol.java
r27200 r27214 41 41 if (button.isSelected()) { 42 42 if (ent == Ent.LIGHT) { 43 dlg.panelMain.mark.setLightAtt(Att.COL, 0, col); 43 if (((String)dlg.panelMain.mark.getLightAtt(Att.CHR, 0)).contains("Al")) { 44 if (((button == delButton) && (dlg.panelMain.mark.getLightAtt(Att.ALT, 0) == Col.UNKNOWN)) 45 || (dlg.panelMain.mark.getLightAtt(Att.COL, 0) == Col.UNKNOWN)) { 46 dlg.panelMain.mark.setLightAtt(Att.COL, 0, col); 47 dlg.panelMain.panelLit.panelChr.col1Label.setBackground(SeaMark.ColMAP.get(col)); 48 } else { 49 dlg.panelMain.mark.setLightAtt(Att.ALT, 0, col); 50 dlg.panelMain.panelLit.panelChr.col2Label.setBackground(SeaMark.ColMAP.get(col)); 51 } 52 } else { 53 dlg.panelMain.mark.setLightAtt(Att.COL, 0, col); 54 dlg.panelMain.panelLit.panelChr.col1Label.setBackground(SeaMark.ColMAP.get(col)); 55 dlg.panelMain.panelLit.panelChr.col2Label.setBackground(SeaMark.ColMAP.get(col)); 56 } 44 57 button.setBorderPainted(true); 45 58 } else { -
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelLit.java
r27201 r27214 322 322 panelCol.syncPanel(); 323 323 panelChr.syncPanel(); 324 panelSector.syncPanel(); 324 325 } 325 326 -
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelSectors.java
r27201 r27214 10 10 import oseam.Messages; 11 11 import oseam.dialogs.OSeaMAction; 12 import oseam.seamarks.SeaMark; 12 13 import oseam.seamarks.SeaMark.*; 13 14 … … 69 70 70 71 table.setSize(860, ((table.getRowCount() * 16) + 20)); 71 if (table.getRowCount() > 3) {72 this.setSize(900, ((table.getRowCount() * 16) + 42));73 }74 72 75 73 table.setDefaultRenderer(String.class, new CentreRenderer()); … … 179 177 ImageIcon img = colours.get(colour); 180 178 if (img == value) 181 dlg.panelMain.mark.setLightAtt(Att.COL, row, colour); 179 // dlg.panelMain.mark.setLightAtt(Att.COL, row, colour); 180 if (((String)dlg.panelMain.mark.getLightAtt(Att.CHR, row)).contains("Al")) { 181 if (((colour == Col.UNKNOWN) && (dlg.panelMain.mark.getLightAtt(Att.ALT, row) == Col.UNKNOWN)) 182 || (dlg.panelMain.mark.getLightAtt(Att.COL, row) == Col.UNKNOWN)) { 183 dlg.panelMain.mark.setLightAtt(Att.COL, row, colour); 184 } else { 185 dlg.panelMain.mark.setLightAtt(Att.ALT, row, colour); 186 } 187 } else { 188 dlg.panelMain.mark.setLightAtt(Att.COL, row, colour); 189 } 182 190 } 183 191 break; … … 233 241 } 234 242 235 public class ColourCellRenderer extends JLabel implements TableCellRenderer { 243 public class ColourCellRenderer extends JPanel implements TableCellRenderer { 244 private JLabel col1Label; 245 private JLabel col2Label; 236 246 public ColourCellRenderer() { 237 247 super(); 238 setHorizontalAlignment(SwingConstants.CENTER); 239 } 240 public Component getTableCellRendererComponent(JTable table, Object value, 241 boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) { 242 setIcon(colours.get(value)); 248 setLayout(new BorderLayout(0, 0)); 249 col1Label = new JLabel(" "); 250 col1Label.setOpaque(true); 251 add(col1Label, BorderLayout.WEST); 252 col2Label = new JLabel(" "); 253 col2Label.setOpaque(true); 254 add(col2Label, BorderLayout.EAST); 255 } 256 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) { 257 if (!((String)dlg.panelMain.mark.getLightAtt(Att.CHR, rowIndex)).contains("Al")) { 258 col2Label.setBackground(SeaMark.ColMAP.get(dlg.panelMain.mark.getLightAtt(Att.COL, rowIndex))); 259 } else { 260 col2Label.setBackground(SeaMark.ColMAP.get(dlg.panelMain.mark.getLightAtt(Att.ALT, rowIndex))); 261 } 262 col1Label.setBackground(SeaMark.ColMAP.get(dlg.panelMain.mark.getLightAtt(Att.COL, rowIndex))); 243 263 return this; 244 264 } … … 252 272 dlg.panelMain.mark.addLight(idx); 253 273 table.setSize(860, ((table.getRowCount() * 16) + 18)); 274 syncPanel(); 275 } 276 277 public void deleteSector(int idx) { 278 if (idx > 0) { 279 dlg.panelMain.mark.delLight(idx); 280 table.setSize(860, ((table.getRowCount() * 16) + 20)); 281 syncPanel(); 282 } 283 } 284 285 public void syncPanel() { 254 286 if (table.getRowCount() > 3) { 255 287 this.setSize(900, ((table.getRowCount() * 16) + 40)); … … 259 291 } 260 292 261 public void deleteSector(int idx) {262 dlg.panelMain.mark.delLight(idx);263 table.setSize(860, ((table.getRowCount() * 16) + 20));264 if (table.getRowCount() > 3) {265 this.setSize(900, ((table.getRowCount() * 16) + 42));266 } else {267 this.setSize(900, 100);268 }269 }270 271 293 private void addColItem(ImageIcon img, Col col) { 272 294 colours.put(col, img); -
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/seamarks/SeaMark.java
r27203 r27214 57 57 repaint(); 58 58 } 59 60 private String longName = ""; 59 61 60 62 public enum Obj { … … 569 571 570 572 public enum Att { 571 COL, CHR, GRP, SEQ, PER, LIT, BEG, END, RAD, HGT, RNG, VIS, EXH, ORT, MLT 573 COL, CHR, GRP, SEQ, PER, LIT, BEG, END, RAD, HGT, RNG, VIS, EXH, ORT, MLT, ALT 572 574 } 573 575 574 576 public Object[] sector = { Col.UNKNOWN, "", "", "", "", Lit.UNKNOWN, "", "", 575 "", "", "", Vis.UNKNOWN, Exh.UNKNOWN, "", "" };577 "", "", "", Vis.UNKNOWN, Exh.UNKNOWN, "", "", Col.UNKNOWN }; 576 578 577 579 private ArrayList<Object[]> sectors = new ArrayList<Object[]>(); … … 1210 1212 } 1211 1213 } 1214 1215 1216 if (keys.containsKey("seamark:longname")) 1217 longName = keys.get("seamark:longname"); 1218 else 1219 longName = ""; 1212 1220 1213 1221 for (Obj obj : ObjSTR.keySet()) { … … 1460 1468 if (keys.containsKey("seamark:light" + secStr + ":colour")) { 1461 1469 str = keys.get("seamark:light" + secStr + ":colour"); 1470 if (str.contains(";")) { 1471 String strs[] = str.split(";"); 1472 for (Col col : ColSTR.keySet()) 1473 if (ColSTR.get(col).equals(strs[1])) 1474 setLightAtt(Att.ALT, i, col); 1475 str = strs[0]; 1476 } 1462 1477 for (Col col : ColSTR.keySet()) 1463 1478 if (ColSTR.get(col).equals(str)) … … 1965 1980 } 1966 1981 g2.setPaint(Color.BLACK); 1967 if ( getLightAtt(Att.COL, 0) != Col.UNKNOWN) {1982 if ((getLightAtt(Att.COL, 0) != Col.UNKNOWN) || !(((String)getLightAtt(Att.CHR, 0)).isEmpty())) { 1968 1983 if (sectors.size() == 1) { 1969 switch ((Col) getLightAtt(Att.COL, 0)) { 1970 case RED: 1971 g2.drawImage(new ImageIcon(getClass().getResource("/images/Light_Red_120.png")).getImage(), 7, -15, null); 1972 break; 1973 case GREEN: 1974 g2.drawImage(new ImageIcon(getClass().getResource("/images/Light_Green_120.png")).getImage(), 7, -15, null); 1975 break; 1976 case WHITE: 1977 case YELLOW: 1978 g2.drawImage(new ImageIcon(getClass().getResource("/images/Light_White_120.png")).getImage(), 7, -15, null); 1979 break; 1980 default: 1984 if (((String) getLightAtt(Att.CHR, 0)).contains("Al")) { 1981 1985 g2.drawImage(new ImageIcon(getClass().getResource("/images/Light_Magenta_120.png")).getImage(), 7, -15, null); 1986 } else { 1987 switch ((Col) getLightAtt(Att.COL, 0)) { 1988 case RED: 1989 g2.drawImage(new ImageIcon(getClass().getResource("/images/Light_Red_120.png")).getImage(), 7, -15, null); 1990 break; 1991 case GREEN: 1992 g2.drawImage(new ImageIcon(getClass().getResource("/images/Light_Green_120.png")).getImage(), 7, -15, null); 1993 break; 1994 case WHITE: 1995 case YELLOW: 1996 g2.drawImage(new ImageIcon(getClass().getResource("/images/Light_White_120.png")).getImage(), 7, -15, null); 1997 break; 1998 default: 1999 g2.drawImage(new ImageIcon(getClass().getResource("/images/Light_Magenta_120.png")).getImage(), 7, -15, null); 2000 } 1982 2001 } 1983 2002 } … … 1996 2015 c += "(" + (String) getLightAtt(Att.GRP, 0) + ")"; 1997 2016 switch ((Col) getLightAtt(Att.COL, 0)) { 2017 case WHITE: 2018 c += ".W"; 2019 break; 2020 case YELLOW: 2021 c += ".Y"; 2022 break; 1998 2023 case RED: 1999 2024 c += ".R"; … … 2013 2038 case VIOLET: 2014 2039 c += ".Vi"; 2040 break; 2041 } 2042 switch ((Col) getLightAtt(Att.ALT, 0)) { 2043 case WHITE: 2044 c += "W"; 2045 break; 2046 case YELLOW: 2047 c += "Y"; 2048 break; 2049 case RED: 2050 c += "R"; 2051 break; 2052 case GREEN: 2053 c += "G"; 2054 break; 2055 case AMBER: 2056 c += "Am"; 2057 break; 2058 case ORANGE: 2059 c += "Or"; 2060 break; 2061 case BLUE: 2062 c += "Bu"; 2063 break; 2064 case VIOLET: 2065 c += "Vi"; 2015 2066 break; 2016 2067 } … … 2105 2156 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:name", getName())); 2106 2157 2158 if (!longName.isEmpty()) 2159 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:longname", longName)); 2160 2107 2161 String objStr = ObjSTR.get(object); 2108 2162 if (objStr != null) { … … 2166 2220 String secStr = (i == 0) ? "" : (":" + Integer.toString(i)); 2167 2221 if (sectors.get(i)[0] != Col.UNKNOWN) 2168 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":colour", ColSTR.get(sectors.get(i)[0]))); 2222 if ((sectors.get(i)[15] != Col.UNKNOWN) && ((String)sectors.get(i)[1]).contains("Al")) 2223 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":colour", (ColSTR.get(sectors.get(i)[0])) 2224 + ";" + ColSTR.get(sectors.get(i)[15]))); 2225 else 2226 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":colour", ColSTR.get(sectors.get(i)[0]))); 2169 2227 if (!((String) sectors.get(i)[1]).isEmpty()) 2170 2228 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":character", (String) sectors.get(i)[1]));
Note:
See TracChangeset
for help on using the changeset viewer.