OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 83 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 83 Rev 156
Line 5... Line 5...
5
import java.util.Random;
5
import java.util.Random;
6
 
6
 
7
public class DataModel2D extends DataModel {
7
public class DataModel2D extends DataModel {
8
 
8
 
9
    private String[][] data;
9
    private String[][] data;
10
    private int rowCount;
10
    private final int rowCount;
11
    private int colCount;
11
    private final int colCount;
12
    private List<String> rowLabels = new ArrayList<String>();
12
    private List<String> rowLabels = new ArrayList<>();
13
    private List<String> colLabels = new ArrayList<String>();
13
    private List<String> colLabels = new ArrayList<>();
14
 
14
 
15
    public DataModel2D(int row, int col) {
15
    public DataModel2D(int row, int col) {
16
        this.rowCount = row;
16
        this.rowCount = row;
17
        this.colCount = col;
17
        this.colCount = col;
18
        data = new String[row][col];
18
        data = new String[row][col];
Line 25... Line 25...
25
 
25
 
26
        for (int i = 0; i < row; i++) {
26
        for (int i = 0; i < row; i++) {
27
            this.rowLabels.add(String.valueOf((char) ('A' + i)));
27
            this.rowLabels.add(String.valueOf((char) ('A' + i)));
28
        }
28
        }
29
        for (int i = 0; i < col; i++) {
29
        for (int i = 0; i < col; i++) {
30
            this.colLabels.add(String.valueOf(((1 + i))));
30
            this.colLabels.add(String.valueOf(1 + i));
31
        }
31
        }
32
 
32
 
33
    }
33
    }
34
 
34
 
35
    public String getValue(int row, int col) {
35
    public synchronized String getValue(int row, int col) {
36
        return data[row][col];
36
        return data[row][col];
37
    }
37
    }
38
 
38
 
39
    public void setValue(String value, int row, int col) {
39
    public synchronized void setValue(String value, int row, int col) {
40
        data[row][col] = value;
40
        data[row][col] = value;
41
    }
41
    }
42
 
42
 
43
    public String getColumnLabel(int col) {
43
    public synchronized String getColumnLabel(int col) {
44
        return this.colLabels.get(col);
44
        return this.colLabels.get(col);
45
    }
45
    }
46
 
46
 
47
    public String getRowLabel(int row) {
47
    public synchronized String getRowLabel(int row) {
48
        return this.rowLabels.get(row);
48
        return this.rowLabels.get(row);
49
    }
49
    }
50
 
50
 
51
    public int getRowCount() {
51
    public int getRowCount() {
52
        return rowCount;
52
        return rowCount;