Changeset 27027 in osm for applications/editors/josm/plugins
- Timestamp:
- 2011-11-07T19:47:26+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
r27005 r27027 37 37 private ActionListener alCharButton = new ActionListener() { 38 38 public void actionPerformed(java.awt.event.ActionEvent e) { 39 if (noneButton.isSelected()) {40 if (dlg.panelMain.panelLit.panelCol.delButton.isSelected()) {41 dlg.panelMain.lightIcon.setIcon(null);42 }43 } else {44 dlg.panelMain.lightIcon.setIcon(new ImageIcon(getClass().getResource("/images/Light_Green_120.png")));45 }46 39 JToggleButton source = (JToggleButton) e.getSource(); 47 40 EnumSet<Chr> combo = EnumSet.noneOf(Chr.class); … … 71 64 } 72 65 } 66 dlg.mark.setLightAtt(Att.CHR, 0, charBox.getText()); 73 67 } 74 68 }; … … 76 70 public void actionPerformed(java.awt.event.ActionEvent e) { 77 71 String str = charBox.getText(); 72 dlg.mark.setLightAtt(Att.CHR, 0, str); 78 73 EnumSet<Chr> set = EnumSet.noneOf(Chr.class); 79 74 for (EnumSet<Chr> map : SeaMark.ChrMAP.keySet()) { -
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelCol.java
r27023 r27027 42 42 if (dlg.mark != null) { 43 43 if (ent == Ent.LIGHT) { 44 dlg.mark.setLightAtt(Att.COL, col);44 dlg.mark.setLightAtt(Att.COL, 0, col); 45 45 button.setBorderPainted(true); 46 46 } else { -
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelLit.java
r27023 r27027 21 21 private ActionListener alGroup = new ActionListener() { 22 22 public void actionPerformed(java.awt.event.ActionEvent e) { 23 dlg.mark.setLightAtt(Att.GRP, groupBox.getText());23 dlg.mark.setLightAtt(Att.GRP, 0, groupBox.getText()); 24 24 } 25 25 }; … … 28 28 private ActionListener alPeriod = new ActionListener() { 29 29 public void actionPerformed(java.awt.event.ActionEvent e) { 30 dlg.mark.setLightAtt(Att.PER, periodBox.getText());30 dlg.mark.setLightAtt(Att.PER, 0, periodBox.getText()); 31 31 } 32 32 }; … … 35 35 private ActionListener alSequence = new ActionListener() { 36 36 public void actionPerformed(java.awt.event.ActionEvent e) { 37 dlg.mark.setLightAtt(Att.SEQ, sequenceBox.getText());37 dlg.mark.setLightAtt(Att.SEQ, 0, sequenceBox.getText()); 38 38 } 39 39 }; … … 46 46 int idx = visibilities.get(vis); 47 47 if (idx == visibilityBox.getSelectedIndex()) 48 dlg.mark.setLightAtt(Att.VIS, vis);48 dlg.mark.setLightAtt(Att.VIS, 0, vis); 49 49 } 50 50 } … … 54 54 private ActionListener alHeight = new ActionListener() { 55 55 public void actionPerformed(java.awt.event.ActionEvent e) { 56 dlg.mark.setLightAtt(Att.HGT, heightBox.getText());56 dlg.mark.setLightAtt(Att.HGT, 0, heightBox.getText()); 57 57 } 58 58 }; … … 61 61 private ActionListener alRange = new ActionListener() { 62 62 public void actionPerformed(java.awt.event.ActionEvent e) { 63 dlg.mark.setLightAtt(Att.RNG, rangeBox.getText());63 dlg.mark.setLightAtt(Att.RNG, 0, rangeBox.getText()); 64 64 } 65 65 }; … … 68 68 private ActionListener alOrientation = new ActionListener() { 69 69 public void actionPerformed(java.awt.event.ActionEvent e) { 70 dlg.mark.setLightAtt(Att.ORT, orientationBox.getText());70 dlg.mark.setLightAtt(Att.ORT, 0, orientationBox.getText()); 71 71 } 72 72 }; … … 79 79 int idx = categories.get(lit); 80 80 if (idx == categoryBox.getSelectedIndex()) 81 dlg.mark.setLightAtt(Att.LIT, lit);81 dlg.mark.setLightAtt(Att.LIT, 0, lit); 82 82 } 83 83 } … … 91 91 int idx = exhibitions.get(exh); 92 92 if (idx == exhibitionBox.getSelectedIndex()) 93 dlg.mark.setLightAtt(Att.EXH, exh);93 dlg.mark.setLightAtt(Att.EXH, 0, exh); 94 94 } 95 95 } … … 106 106 panelSector = new PanelSectors(dlg); 107 107 } 108 // if (panelSector.getSectorCount() == 0) { 109 // panelSector.addSector(1); 110 // dlg.mark.setSectored(true); 111 // } 108 dlg.mark.setSectored(true); 112 109 panelSector.setVisible(true); 113 110 } else { -
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelSectors.java
r27023 r27027 3 3 import java.awt.*; 4 4 import java.awt.event.*; 5 import java.util.EnumMap; 5 6 6 7 import javax.swing.*; 7 8 import javax.swing.table.*; 8 9 10 import oseam.Messages; 9 11 import oseam.dialogs.OSeaMAction; 10 import oseam.seamarks.*;11 import oseam.seamarks.SeaMark.Att;12 12 import oseam.seamarks.SeaMark.*; 13 13 … … 22 22 private ActionListener alMinusButton = new ActionListener() { 23 23 public void actionPerformed(java.awt.event.ActionEvent e) { 24 deleteSector(0); 24 if ((getSectorCount() > 1) && (table.getSelectedRow() != 0)) 25 deleteSector(table.getSelectedRow()); 25 26 } 26 27 }; … … 28 29 private ActionListener alPlusButton = new ActionListener() { 29 30 public void actionPerformed(java.awt.event.ActionEvent e) { 30 addSector(0); 31 if (table.getSelectedRow() < 0) 32 addSector(table.getRowCount()); 33 else 34 addSector(table.getSelectedRow()+1); 31 35 } 32 36 }; 37 public JComboBox visibilityBox; 38 public EnumMap<Vis, String> visibilities = new EnumMap<Vis, String>(Vis.class); 33 39 34 40 public PanelSectors(OSeaMAction dia) { 35 41 super("Sector Table"); 36 42 dlg = dia; 37 this.setSize( 700, 100);43 this.setSize(800, 100); 38 44 this.setVisible(true); 39 45 this.setAlwaysOnTop(true); 40 46 this.setLocation(450, 0); 41 this.setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE);47 this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); 42 48 this.setLayout(null); 43 49 minusButton = new JButton(new ImageIcon(getClass().getResource("/images/MinusButton.png"))); … … 50 56 this.add(plusButton); 51 57 panel = new JPanel(new BorderLayout()); 52 panel.setBounds(40, 0, 660, 512);58 panel.setBounds(40, 0, 760, 512); 53 59 model = new SectorTable(); 54 60 table = new JTable(model); 55 table.setBounds(0, 0, 660, 34);61 table.setBounds(0, 0, 760, 34); 56 62 panel.add(new JScrollPane(table)); 57 63 this.getContentPane().add(panel); 64 65 TableColumn visColumn = table.getColumnModel().getColumn(11); 66 visibilityBox = new JComboBox(); 67 addVisibItem(Messages.getString("NoneSpecified"), Vis.UNKNOWN); 68 addVisibItem(Messages.getString("Intensified"), Vis.INTEN); 69 addVisibItem(Messages.getString("Unintensified"), Vis.UNINTEN); 70 addVisibItem(Messages.getString("PartiallyObscured"), Vis.PARTOBS); 71 visColumn.setCellEditor(new DefaultCellEditor(visibilityBox)); 58 72 } 59 73 60 74 private class SectorTable extends AbstractTableModel { 61 75 62 private String[] headings = { "Sector", "Colour", "Character", "Group", "Sequence", "Period", "Height", "Range", "Visibility", "Start", "End", "Radius" }; 76 private String[] headings = { "Sector", "Colour", "Character", "Group", "Sequence", "Period", 77 "Start", "End", "Radius", "Height", "Range", "Visibility", "Exhibition", "Category" }; 63 78 64 79 public SectorTable() { … … 78 93 79 94 public boolean isCellEditable(int row, int col) { 80 return ( col > 0);95 return ((col > 0) && (row > 0)); 81 96 } 82 97 … … 84 99 switch (col) { 85 100 case 1: 86 return Col .class;87 case 7:101 return Color.class; 102 case 11: 88 103 return Vis.class; 104 case 12: 105 return Exh.class; 106 case 13: 107 return Lit.class; 89 108 default: 90 109 return String.class; … … 93 112 94 113 public Object getValueAt(int row, int col) { 95 return dlg.mark.getLightAtt(col, row); 114 if (col == 0) 115 return row; 116 else 117 return dlg.mark.getLightAtt(col-1, row); 96 118 } 97 119 98 120 public void setValueAt(Object value, int row, int col) { 99 dlg.mark.setLightAtt(col, row, value); 121 switch (col) { 122 case 4: 123 case 5: 124 case 6: 125 case 7: 126 case 8: 127 case 9: 128 case 13: 129 dlg.mark.setLightAtt(col-1, row, dlg.mark.validDecimal((String)value)); 130 break; 131 case 11: 132 for (Vis vis : visibilities.keySet()) { 133 String str = visibilities.get(vis); 134 if (str.equals(value)) 135 dlg.mark.setLightAtt(Att.VIS, row, vis); 136 } 137 break; 138 default: 139 dlg.mark.setLightAtt(col-1, row, value); 140 } 100 141 } 101 142 } … … 106 147 107 148 public void addSector(int idx) { 108 dlg.mark.addLight Att(Att.COL, Col.UNKNOWN);109 table.setSize( 660, ((table.getRowCount() * 16) + 18));149 dlg.mark.addLight(idx); 150 table.setSize(760, ((table.getRowCount() * 16) + 18)); 110 151 if (table.getRowCount() > 3) { 111 this.setSize( 700, ((table.getRowCount() * 16) + 40));152 this.setSize(800, ((table.getRowCount() * 16) + 40)); 112 153 } else { 113 this.setSize( 700, 100);154 this.setSize(800, 100); 114 155 } 115 156 } 116 157 117 158 public void deleteSector(int idx) { 118 dlg.mark.subLight Att(Att.COL, 0);119 table.setSize( 660, ((table.getRowCount() * 16) + 18));159 dlg.mark.subLight(idx); 160 table.setSize(760, ((table.getRowCount() * 16) + 18)); 120 161 if (table.getRowCount() > 3) { 121 this.setSize( 700, ((table.getRowCount() * 16) + 40));162 this.setSize(800, ((table.getRowCount() * 16) + 40)); 122 163 } else { 123 this.setSize( 700, 100);164 this.setSize(800, 100); 124 165 } 125 166 } 126 167 168 private void addVisibItem(String str, Vis vis) { 169 visibilities.put(vis, str); 170 visibilityBox.addItem(str); 171 } 172 127 173 } -
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/seamarks/SeaMark.java
r27023 r27027 291 291 public static final EnumMap<Col, Color> ColMAP = new EnumMap<Col, Color>(Col.class); 292 292 static { 293 ColMAP.put(Col.UNKNOWN, new Color(0xc0c0c0)); 293 294 ColMAP.put(Col.WHITE, Color.WHITE); 294 295 ColMAP.put(Col.RED, Color.RED); 295 296 ColMAP.put(Col.ORANGE, Color.ORANGE); 296 ColMAP.put(Col.AMBER, new Color(0xf fbf00f));297 ColMAP.put(Col.AMBER, new Color(0xfbf00f)); 297 298 ColMAP.put(Col.YELLOW, Color.YELLOW); 298 299 ColMAP.put(Col.GREEN, Color.GREEN); … … 464 465 } 465 466 466 public static final Map<EnumSet<Vis>, String> VisMAP = new HashMap<EnumSet<Vis>, String>();467 public static final EnumMap<Vis, String> VisSTR = new EnumMap<Vis, String>(Vis.class); 467 468 static { 468 Vis MAP.put(EnumSet.of(Vis.UNKNOWN), "");469 Vis MAP.put(EnumSet.of(Vis.HIGH), "high");470 Vis MAP.put(EnumSet.of(Vis.LOW), "low");471 Vis MAP.put(EnumSet.of(Vis.FAINT), "faint");472 Vis MAP.put(EnumSet.of(Vis.INTEN), "intensified");473 Vis MAP.put(EnumSet.of(Vis.UNINTEN), "unintensified");474 Vis MAP.put(EnumSet.of(Vis.REST), "restricted");475 Vis MAP.put(EnumSet.of(Vis.OBS), "obscured");476 Vis MAP.put(EnumSet.of(Vis.PARTOBS), "part_obscured");469 VisSTR.put(Vis.UNKNOWN, ""); 470 VisSTR.put(Vis.HIGH, "high"); 471 VisSTR.put(Vis.LOW, "low"); 472 VisSTR.put(Vis.FAINT, "faint"); 473 VisSTR.put(Vis.INTEN, "intensified"); 474 VisSTR.put(Vis.UNINTEN, "unintensified"); 475 VisSTR.put(Vis.REST, "restricted"); 476 VisSTR.put(Vis.OBS, "obscured"); 477 VisSTR.put(Vis.PARTOBS, "part_obscured"); 477 478 } 478 479 … … 488 489 489 490 public enum Exh { UNKNOWN, H24, DAY, NIGHT, FOG } 490 public static final Map<EnumSet<Exh>, String> ExhMAP = new HashMap<EnumSet<Exh>, String>(); 491 492 public static final EnumMap<Exh, String> ExhSTR = new EnumMap<Exh, String>(Exh.class); 491 493 static { 492 Exh MAP.put(EnumSet.of(Exh.UNKNOWN), "");493 Exh MAP.put(EnumSet.of(Exh.H24), "24h");494 Exh MAP.put(EnumSet.of(Exh.DAY), "day");495 Exh MAP.put(EnumSet.of(Exh.NIGHT), "night");496 Exh MAP.put(EnumSet.of(Exh.FOG), "fog");494 ExhSTR.put(Exh.UNKNOWN, ""); 495 ExhSTR.put(Exh.H24, "24h"); 496 ExhSTR.put(Exh.DAY, "day"); 497 ExhSTR.put(Exh.NIGHT, "night"); 498 ExhSTR.put(Exh.FOG, "fog"); 497 499 } 498 500 499 public enum Att { COL, CHR, GRP, SEQ, PER, HGT, RNG, VIS, BEG, END, RAD, EXH, LIT, ORT } 501 public enum Att { COL, CHR, GRP, SEQ, PER, BEG, END, RAD, HGT, RNG, VIS, EXH, LIT, ORT } 502 503 public Object[] sector = {Col.UNKNOWN, "", "", "", "", "", "", "", "", "", Vis.UNKNOWN, Exh.UNKNOWN, Lit.UNKNOWN, "" }; 500 504 501 505 private ArrayList<Object[]> sectors = new ArrayList<Object[]>(); … … 504 508 return sectors.size(); 505 509 } 506 510 507 511 public Object getLightAtt(Att att, int i) { 508 512 return getLightAtt(att.ordinal(), i); … … 515 519 } 516 520 517 public void setLightAtt(Att att, Object obj) {518 sectors.clear();519 sectors.add(new Object[14]);520 sectors.get(0)[att.ordinal()] = obj;521 }522 523 521 public void setLightAtt(Att att, int i, Object obj) { 524 522 setLightAtt(att.ordinal(), i, obj); … … 530 528 } 531 529 532 public void addLightAtt(Att att, int i, Object obj) { 530 public void clrLight() { 531 sectors.clear(); 532 sectors.add(sector.clone()); 533 } 534 535 public void addLight(int i) { 533 536 if (sectors.size() >= i) { 534 sectors.add(i, new Object[14]); 535 sectors.get(i)[att.ordinal()] = obj; 536 } 537 } 538 539 public void addLightAtt(Att att, Object obj) { 540 sectors.add(new Object[14]); 541 sectors.get(sectors.size()-1)[att.ordinal()] = obj; 542 } 543 544 public void subLightAtt(Att att, int i) { 537 sectors.add(i, sectors.get(0).clone()); 538 } 539 } 540 541 public void addLight() { 542 sectors.add(sectors.get(0).clone()); 543 } 544 545 public void subLight(int i) { 545 546 if (sectors.size() > i) 546 547 sectors.remove(i); … … 1275 1276 } 1276 1277 } 1278 1279 clrLight(); 1277 1280 1278 1281 if (keys.containsKey("seamark:fog_signal")) { … … 1713 1716 } 1714 1717 } 1718 1719 for (int i = 0; i < sectors.size(); i++) { 1720 String secStr = (i == 0) ? "" : (":" + Integer.toString(i)); 1721 if (sectors.get(i)[0] != Col.UNKNOWN) 1722 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":colour", ColSTR.get(sectors.get(i)[0]))); 1723 if (!((String)sectors.get(i)[1]).isEmpty()) 1724 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":character", (String)sectors.get(i)[1])); 1725 if (!((String)sectors.get(i)[2]).isEmpty()) 1726 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":group", (String)sectors.get(i)[2])); 1727 if (!((String)sectors.get(i)[3]).isEmpty()) 1728 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":sequence", (String)sectors.get(i)[3])); 1729 if (!((String)sectors.get(i)[4]).isEmpty()) 1730 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":period", (String)sectors.get(i)[4])); 1731 if (!((String)sectors.get(i)[5]).isEmpty()) 1732 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":sector_start", (String)sectors.get(i)[5])); 1733 if (!((String)sectors.get(i)[6]).isEmpty()) 1734 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":sector_end", (String)sectors.get(i)[6])); 1735 if (!((String)sectors.get(i)[7]).isEmpty()) 1736 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":radius", (String)sectors.get(i)[7])); 1737 if (!((String)sectors.get(i)[8]).isEmpty()) 1738 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":height", (String)sectors.get(i)[8])); 1739 if (!((String)sectors.get(i)[9]).isEmpty()) 1740 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":range", (String)sectors.get(i)[9])); 1741 if (sectors.get(i)[10] != Vis.UNKNOWN) 1742 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":visibility", VisSTR.get(sectors.get(i)[10]))); 1743 if (sectors.get(i)[11] != Exh.UNKNOWN) 1744 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":exhibition", ExhSTR.get(sectors.get(i)[11]))); 1745 if (sectors.get(i)[12] != Lit.UNKNOWN) 1746 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":category", LitSTR.get(sectors.get(i)[12]))); 1747 if (!((String)sectors.get(i)[13]).isEmpty()) 1748 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:light" + secStr + ":orientation", (String)sectors.get(i)[13])); 1749 } 1750 1715 1751 if (hasFog()) { 1716 1752 Main.main.undoRedo.add(new ChangePropertyCommand(node, "seamark:fog_signal", FogSTR.get(getFogSound())));
Note:
See TracChangeset
for help on using the changeset viewer.