Changeset 27017 in osm for applications


Ignore:
Timestamp:
2011-11-05T20:21:16+01:00 (13 years ago)
Author:
malcolmh
Message:

save

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  
    4646                                int idx = visibilities.get(vis);
    4747                                if (idx == visibilityBox.getSelectedIndex())
    48                                         dlg.mark.setLightVisibility(vis);
     48                                        dlg.mark.setVisibility(vis);
    4949                        }
    5050                }
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelSectors.java

    r27000 r27017  
    11package oseam.panels;
    22
     3import java.awt.*;
    34import java.awt.event.*;
    4 import java.util.ArrayList;
    55
    66import javax.swing.*;
     7import javax.swing.table.*;
    78
    89import oseam.dialogs.OSeaMAction;
    910import oseam.seamarks.*;
     11import oseam.seamarks.SeaMark.*;
    1012
    11 public class PanelSectors extends JFrame {
     13public class PanelSectors extends JPanel {
    1214
    1315        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;
    2126
    2227        public PanelSectors(OSeaMAction dia) {
    23                 super("Sector Table");
    2428                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);
    5635        }
    5736
    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() {
    6042        }
    6143
    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];
    7146        }
    7247
    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;
    8250        }
    8351
    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;
    9054        }
    9155
    92         private int getColumnCount() {
    93                 return columns.length;
     56        public boolean isCellEditable(int row, int col) {
     57                return (col > 0);
    9458        }
    9559
    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                }
    9869        }
    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;
    10593                }
    10694        }
    10795
    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                }
    110107        }
    111 
    112         private void setValueAt(Object value, int row, int col) {
    113                 ((Object[])lights.get(row+1))[col+1] = value;
    114         }
    115        
    116108}
     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  
    3131
    3232        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       
    3645        private Reg region = Reg.A;
    3746
     
    317326        private ArrayList<Col> topColour = new ArrayList<Col>();
    318327        private ArrayList<Col> lightColour = new ArrayList<Col>();
     328       
     329        public int getSectorCount() {
     330                return lightColour.size();
     331        }
    319332
    320333        public Col getColour(Ent ent, int i) {
     
    773786        }
    774787       
    775         private Vis lightVisibility = Vis.UNKNOWN;
     788        private ArrayList<Vis> lightVisibility = new ArrayList<Vis>();
    776789       
    777         public Vis getLightVisibility() {
    778                 return lightVisibility;
    779         }
    780 
    781         public void setLightVisibility(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);
    783796        }
    784797       
     
    794807       
    795808        public enum Lit {
    796                 UNKNOWN, VERT, HORIZ, UPPER, LOWER, REAR, FRONT, AERO, AIROBS,
    797                 FOGDET, FLOOD, STRIP, SUBS, SPOT, MOIRE, EMERG, BEAR
    798         }
    799 
    800         public static final Map<EnumSet<Lit>, String> LitMAP = 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>();
    801814        static {
    802                 LitMAP.put(EnumSet.of(Lit.UNKNOWN), "");
     815                LitSTR.put(EnumSet.of(Lit.VERT), "vertical");
    803816        }
    804817
     
    12181231
    12191232        public boolean isValid() {
     1233                dlg.manager.showVisualMessage("");
    12201234                switch (getObject()) {
    12211235                case BCNCAR:
     
    12531267                        return true;
    12541268                default:
     1269                        dlg.manager.showVisualMessage("Seamark not recognised");
    12551270                        return false;
    12561271                }
     1272                dlg.manager.showVisualMessage("Seamark not recognised");
    12571273                return false;
    12581274        }
Note: See TracChangeset for help on using the changeset viewer.