Changeset 27017 in osm for applications/editors/josm
- Timestamp:
- 2011-11-05T20:21:16+01:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/smed/plugs/oseam/src/oseam
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelLit.java
r27008 r27017 46 46 int idx = visibilities.get(vis); 47 47 if (idx == visibilityBox.getSelectedIndex()) 48 dlg.mark.set LightVisibility(vis);48 dlg.mark.setVisibility(vis); 49 49 } 50 50 } -
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelSectors.java
r27000 r27017 1 1 package oseam.panels; 2 2 3 import java.awt.*; 3 4 import java.awt.event.*; 4 import java.util.ArrayList;5 5 6 6 import javax.swing.*; 7 import javax.swing.table.*; 7 8 8 9 import oseam.dialogs.OSeaMAction; 9 10 import oseam.seamarks.*; 11 import oseam.seamarks.SeaMark.*; 10 12 11 public class PanelSectors extends J Frame{13 public class PanelSectors extends JPanel { 12 14 13 15 private OSeaMAction dlg; 14 public JPanel panel; 15 public JButton minusButton; 16 public JButton plusButton; 17 public JTable table; 18 private JScrollPane tablePane; 19 private ActionListener alMinusButton; 20 private ActionListener alPlusButton; 16 private TableModel model; 17 private JTable table; 18 private JFrame frame; 19 20 // public JPanel panel; 21 // public JButton minusButton; 22 // public JButton plusButton; 23 // private JScrollPane tablePane; 24 // private ActionListener alMinusButton; 25 // private ActionListener alPlusButton; 21 26 22 27 public PanelSectors(OSeaMAction dia) { 23 super("Sector Table");24 28 dlg = dia; 25 lights = new ArrayList<Object[]>(); 26 lights.add(new Object[]{null, null, null, null, null, null, null, null, null, null, null, null}); 27 panel = new JPanel(); 28 this.setSize(700, 100); 29 panel.setBounds(0, 0, 700, 512); 30 this.getContentPane().add(panel); 31 table = new JTable(); 32 tablePane = new JScrollPane(table); 33 tablePane.setBounds(40, 0, 660, 34); 34 panel.setLayout(null); 35 panel.add(tablePane); 36 37 alMinusButton = new ActionListener() { 38 public void actionPerformed(java.awt.event.ActionEvent e) { 39 deleteSector(2); 40 } 41 }; 42 minusButton = new JButton(new ImageIcon(getClass().getResource("/images/MinusButton.png"))); 43 minusButton.setBounds(0, 0, 32, 34); 44 minusButton.addActionListener(alMinusButton); 45 panel.add(minusButton); 46 47 alPlusButton = new ActionListener() { 48 public void actionPerformed(java.awt.event.ActionEvent e) { 49 addSector(2); 50 } 51 }; 52 plusButton = new JButton(new ImageIcon(getClass().getResource("/images/PlusButton.png"))); 53 plusButton.setBounds(0, 34, 32, 34); 54 plusButton.addActionListener(alPlusButton); 55 panel.add(plusButton); 29 model = new SectorTable(); 30 table = new JTable(model); 31 table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 32 frame = new JFrame("Sector Table"); 33 frame.getContentPane().add(new JScrollPane(table)); 34 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 56 35 } 57 36 58 public int getSectorCount() { 59 return getRowCount(); 37 private class SectorTable extends AbstractTableModel { 38 39 private String[] headings = { "Sector", "Colour", "Character", "Group", "Period", "Height", "Range", "Visibility", "Start", "End" }; 40 41 public SectorTable() { 60 42 } 61 43 62 public void addSector(int idx) { 63 lights.add(idx, new Object[]{null, null, null, null, null, null, null, null, null, null, null, null}); 64 tablePane.setSize(660, ((getRowCount() * 16) + 18)); 65 if (getRowCount() > 3) { 66 this.setSize(700, ((getRowCount() * 16) + 40)); 67 } else { 68 this.setSize(700, 100); 69 } 70 // light.fireTableRowsInserted(idx, idx); 44 public String getColumnName(int col) { 45 return headings[col]; 71 46 } 72 47 73 public void deleteSector(int idx) { 74 lights.remove(idx); 75 tablePane.setSize(660, ((getRowCount() * 16) + 18)); 76 if (getRowCount() > 3) { 77 this.setSize(700, ((getRowCount() * 16) + 40)); 78 } else { 79 this.setSize(700, 100); 80 } 81 // light.fireTableRowsDeleted(idx, idx); 48 public int getColumnCount() { 49 return headings.length; 82 50 } 83 51 84 private String[] columns = { "Sector", "Start", "End", "Colour", 85 "Character", "Group", "Period", "Height", "Range", "Visibility" }; 86 private ArrayList<Object[]> lights; 87 88 private String getColumnName(int col) { 89 return columns[col].toString(); 52 public int getRowCount() { 53 return dlg.mark.getSectorCount() - 1; 90 54 } 91 55 92 p rivate int getColumnCount() {93 return columns.length;56 public boolean isCellEditable(int row, int col) { 57 return (col > 0); 94 58 } 95 59 96 private int getRowCount() { 97 return lights.size()-1; 60 public Class getColumnClass(int col) { 61 switch (col) { 62 case 1: 63 return Col.class; 64 case 7: 65 return Vis.class; 66 default: 67 return String.class; 68 } 98 69 } 99 100 private Object getValueAt(int row, int col) { 101 if (col == 0) { 102 return row+1; 103 } else { 104 return ((Object[])lights.get(row+1))[col+1]; 70 71 public Object getValueAt(int row, int col) { 72 switch (col) { 73 case 1: 74 return (dlg.mark.getColour(Ent.LIGHT, row)); 75 case 2: 76 return (dlg.mark.getLightChar(row)); 77 case 3: 78 return (dlg.mark.getLightGroup(row)); 79 case 4: 80 return (dlg.mark.getLightPeriod(row)); 81 case 5: 82 return (dlg.mark.getLightHeight(row)); 83 case 6: 84 return (dlg.mark.getLightRange(row)); 85 case 7: 86 return (dlg.mark.getVisibility(row)); 87 case 8: 88 return (dlg.mark.getLightSector1(row)); 89 case 9: 90 return (dlg.mark.getLightSector2(row)); 91 default: 92 return null; 105 93 } 106 94 } 107 95 108 private boolean isCellEditable(int row, int col) { 109 return (col > 0); 96 public void setValueAt(Object value, int row, int col) { 97 switch (col) { 98 case 1: 99 dlg.mark.setColour(Ent.LIGHT, row, (SeaMark.Col)value); 100 case 2: 101 dlg.mark.setLightChar(row, (SeaMark.Chr)value); 102 case 7: 103 dlg.mark.setVisibility(row, (SeaMark.Vis)value); 104 default: 105 dlg.mark.setLightSector2(row, (String)value); 106 } 110 107 } 111 112 private void setValueAt(Object value, int row, int col) {113 ((Object[])lights.get(row+1))[col+1] = value;114 }115 116 108 } 109 /* 110 * panel = new JPanel(); 111 * this.setSize(700, 100); 112 * panel.setBounds(0, 0, 700, 512); 113 * this.getContentPane().add(panel); 114 * table = new JTable(); 115 * tablePane = new JScrollPane(table); 116 * tablePane.setBounds(40, 0, 660, 34); 117 * panel.setLayout(null); 118 * panel.add(tablePane); 119 * 120 * alMinusButton = new ActionListener() { 121 * public void actionPerformed(java.awt.event.ActionEvent e) { deleteSector(2); } }; 122 * minusButton = new JButton(new 123 * ImageIcon(getClass().getResource("/images/MinusButton.png"))); 124 * minusButton.setBounds(0, 0, 32, 34); 125 * minusButton.addActionListener(alMinusButton); panel.add(minusButton); 126 * 127 * alPlusButton = new ActionListener() { public void 128 * actionPerformed(java.awt.event.ActionEvent e) { addSector(2); } }; 129 * plusButton = new JButton(new 130 * ImageIcon(getClass().getResource("/images/PlusButton.png"))); 131 * plusButton.setBounds(0, 34, 32, 34); 132 * plusButton.addActionListener(alPlusButton); panel.add(plusButton); } 133 * 134 * public int getSectorCount() { return getRowCount(); } 135 * 136 * public void addSector(int idx) { lights.add(idx, new Object[]{null, null, 137 * null, null, null, null, null, null, null, null, null, null}); 138 * tablePane.setSize(660, ((getRowCount() * 16) + 18)); if (getRowCount() > 3) 139 * { this.setSize(700, ((getRowCount() * 16) + 40)); } else { 140 * this.setSize(700, 100); } // light.fireTableRowsInserted(idx, idx); } 141 * 142 * public void deleteSector(int idx) { lights.remove(idx); 143 * tablePane.setSize(660, ((getRowCount() * 16) + 18)); if (getRowCount() > 3) 144 * { this.setSize(700, ((getRowCount() * 16) + 40)); } else { 145 * this.setSize(700, 100); } // light.fireTableRowsDeleted(idx, idx); } 146 * 147 * private ArrayList<Object[]> lights; 148 * 149 */ 150 } -
applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/seamarks/SeaMark.java
r27008 r27017 31 31 32 32 public enum Reg { 33 A, B, C 34 } 35 33 A, B, C, R, X 34 } 35 36 public static final EnumMap<Reg, String> RegSTR = new EnumMap<Reg, String>(Reg.class); 37 static { 38 RegSTR.put(Reg.A, "iala-a"); 39 RegSTR.put(Reg.B, "iala-b"); 40 RegSTR.put(Reg.C, "cevni"); 41 RegSTR.put(Reg.R, "riwr"); 42 RegSTR.put(Reg.X, "other"); 43 } 44 36 45 private Reg region = Reg.A; 37 46 … … 317 326 private ArrayList<Col> topColour = new ArrayList<Col>(); 318 327 private ArrayList<Col> lightColour = new ArrayList<Col>(); 328 329 public int getSectorCount() { 330 return lightColour.size(); 331 } 319 332 320 333 public Col getColour(Ent ent, int i) { … … 773 786 } 774 787 775 private Vis lightVisibility = Vis.UNKNOWN;788 private ArrayList<Vis> lightVisibility = new ArrayList<Vis>(); 776 789 777 public Vis get LightVisibility() {778 return lightVisibility ;779 } 780 781 public void set LightVisibility(Vis vis) {782 lightVisibility = vis;790 public Vis getVisibility(int i) { 791 return lightVisibility.get(i); 792 } 793 794 public void setVisibility(int i, Vis vis) { 795 lightVisibility.set(i, vis); 783 796 } 784 797 … … 794 807 795 808 public enum Lit { 796 UNKNOWN, VERT, HORIZ, UPPER, LOWER, REAR, FRONT, AERO, AIROBS,797 FOGDET, FLOOD, STRIP, SUBS, SPOT, MOIRE, EMERG, BEAR798 } 799 800 public static final Map<EnumSet<Lit>, String> Lit MAP= new HashMap<EnumSet<Lit>, String>();809 UNKNOWN, VERT, HORIZ, DIR, UPPER, LOWER, LEAD, REAR, FRONT, 810 AERO, AIROBS, FOGDET, FLOOD, STRIP, SUBS, SPOT, MOIRE, EMERG, BEAR 811 } 812 813 public static final Map<EnumSet<Lit>, String> LitSTR = new HashMap<EnumSet<Lit>, String>(); 801 814 static { 802 Lit MAP.put(EnumSet.of(Lit.UNKNOWN), "");815 LitSTR.put(EnumSet.of(Lit.VERT), "vertical"); 803 816 } 804 817 … … 1218 1231 1219 1232 public boolean isValid() { 1233 dlg.manager.showVisualMessage(""); 1220 1234 switch (getObject()) { 1221 1235 case BCNCAR: … … 1253 1267 return true; 1254 1268 default: 1269 dlg.manager.showVisualMessage("Seamark not recognised"); 1255 1270 return false; 1256 1271 } 1272 dlg.manager.showVisualMessage("Seamark not recognised"); 1257 1273 return false; 1258 1274 }
Note:
See TracChangeset
for help on using the changeset viewer.