Ignore:
Timestamp:
2011-06-12T15:00:52+02: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

    r26124 r26128  
    7878                                                panelSector.setLocation(450, 0);
    7979                                        }
    80                                         if (dlg.mark.light.getRowCount() == 1) {
    81                                                 dlg.mark.light.addSector(1);
    82                                                 dlg.mark.light.setSectored(true);
     80                                        if (panelSector.getSectorCount() == 0) {
     81                                                panelSector.addSector(1);
     82                                                panelSector.light.setSectored(true);
    8383                                        }
    8484                                        panelSector.setVisible(true);
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/panels/PanelSectors.java

    r26124 r26128  
    77import javax.swing.JTable;
    88import javax.swing.JButton;
     9import javax.swing.table.AbstractTableModel;
     10
     11import java.awt.event.ActionListener;
    912
    1013import oseam.seamarks.Light;
     
    1619        public JButton plusButton;
    1720        public JTable table;
     21        public Light light;
     22        private JScrollPane tablePane;
     23        private ActionListener alMinusButton;
     24        private ActionListener alPlusButton;
    1825       
    19         public PanelSectors(Light light) {
     26        public PanelSectors(Light lit) {
    2027                super("Sector Table");
     28                light = lit;
    2129                panel = new JPanel();
    2230                this.setSize(700, 100);
    2331                panel.setBounds(0, 0, 700, 512);
    2432                this.getContentPane().add(panel);
     33                table = new JTable(light);
     34                tablePane = new JScrollPane(table);
     35                tablePane.setBounds(40, 0, 660, 34);
     36                panel.setLayout(null);
     37                panel.add(tablePane);
     38               
     39                alMinusButton = new ActionListener() {
     40                        public void actionPerformed(java.awt.event.ActionEvent e) {
     41                                deleteSector(2);
     42                        }
     43                };
    2544                minusButton = new JButton(new ImageIcon(getClass().getResource("/images/MinusButton.png")));
    2645                minusButton.setBounds(0, 0, 32, 34);
     46                minusButton.addActionListener(alMinusButton);
     47                panel.add(minusButton);
     48               
     49                alPlusButton = new ActionListener() {
     50                        public void actionPerformed(java.awt.event.ActionEvent e) {
     51                                addSector(2);
     52                        }
     53                };
    2754                plusButton = new JButton(new ImageIcon(getClass().getResource("/images/PlusButton.png")));
    2855                plusButton.setBounds(0, 34, 32, 34);
    29                 table = new JTable(light);
    30                 JScrollPane tablePane = new JScrollPane(table);
    31                 tablePane.setBounds(40, 0, 660, 34);
    32                 panel.setLayout(null);
    33                 panel.add(minusButton);
     56                plusButton.addActionListener(alPlusButton);
    3457                panel.add(plusButton);
    35                 panel.add(tablePane);
    3658        }
     59       
     60        public int getSectorCount() {
     61                return light.getRowCount();
     62        }
     63       
     64        public void addSector(int idx) {
     65                light.addSector(idx);
     66                tablePane.setSize(660, ((light.getRowCount() * 16) + 18));
     67                if (light.getRowCount() > 3) {
     68                        this.setSize(700, ((light.getRowCount() * 16) + 40));
     69                } else {
     70                        this.setSize(700, 100);
     71                }
     72                light.fireTableRowsInserted(idx, idx);
     73        }
     74       
     75        public void deleteSector(int idx) {
     76                light.deleteSector(idx);
     77                tablePane.setSize(660, ((light.getRowCount() * 16) + 18));
     78                if (light.getRowCount() > 3) {
     79                        this.setSize(700, ((light.getRowCount() * 16) + 40));
     80                } else {
     81                        this.setSize(700, 100);
     82                }
     83                light.fireTableRowsDeleted(idx, idx);
     84        }
     85       
    3786}
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/seamarks/Light.java

    r26124 r26128  
    2222       
    2323        public Light(OSeaMAction dia) {
    24                 super();
    2524                dlg = dia;
    2625                lights = new ArrayList<Object[]>();
    27                 lights.add(new Object[12]);
     26                lights.add(new Object[]{null, null, null, null, null, null, null, null, null, null, null, null});
    2827        }
    2928
     
    8180        public void setSectored(boolean sectored) {
    8281                Sectored = sectored;
    83                 if (sectored) {
    84                         setLightColour(0, Col.UNKNOWN);
    85                 } else {
    86                         setLightChar(0, Chr.UNKNOWN);
    87                         setLightColour(0, Col.UNKNOWN);
    88                         setLightGroup(0, "");
    89                         setHeight(0, "");
    90                         setRange(0, "");
    91                         setBearing1(0, "");
    92                         setBearing2(0, "");
    93                         setVisibility(0, Vis.UNKNOWN);
    94                 }
    9582        }
    9683
Note: See TracChangeset for help on using the changeset viewer.