OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 140 Rev 181
Line 13... Line 13...
13
import java.awt.print.PrinterException;
13
import java.awt.print.PrinterException;
14
import java.util.List;
14
import java.util.List;
15
 
15
 
16
import javax.swing.JPanel;
16
import javax.swing.JPanel;
17
 
17
 
18
import org.openconcerto.sql.model.SQLRowAccessor;
-
 
19
 
-
 
20
public class LabelPanel extends JPanel implements Printable {
18
public class LabelPanel extends JPanel implements Printable {
21
 
19
 
22
    private List<? extends SQLRowAccessor> list;
20
    private List<? extends Label> list;
23
    private int lines;
21
    private int lines;
24
    private int columns;
22
    private int columns;
25
    private Boolean[][] mask;
23
    private Boolean[][] mask;
26
    private final Color VERY_LIGHT_GRAY = new Color(230, 230, 230);
24
    private final Color VERY_LIGHT_GRAY = new Color(230, 230, 230);
27
    private LabelRenderer renderer;
25
    private LabelRenderer renderer;
28
    private boolean ignoreMargins = false;
26
    private boolean ignoreMargins = false;
29
    private int topMargin;
27
    private int topMargin;
30
    private int leftMargin;
28
    private int leftMargin;
31
 
29
 
32
    public LabelPanel(List<? extends SQLRowAccessor> list, int l, int c, LabelRenderer labelRenderer) {
30
    public LabelPanel(List<? extends Label> list, int l, int c, LabelRenderer labelRenderer) {
33
        this.list = list;
31
        this.list = list;
34
        this.renderer = labelRenderer;
32
        this.renderer = labelRenderer;
35
        setSizeLayoutSize(l, c);
33
        setSizeLayoutSize(l, c);
36
        this.addMouseListener(new MouseAdapter() {
34
        this.addMouseListener(new MouseAdapter() {
37
            @Override
35
            @Override
Line 46... Line 44...
46
                repaint();
44
                repaint();
47
            }
45
            }
48
        });
46
        });
49
    }
47
    }
50
 
48
 
-
 
49
    public void setList(List<? extends Label> list) {
-
 
50
        this.list = list;
-
 
51
        repaint();
-
 
52
    }
-
 
53
 
51
    private void setSizeLayoutSize(int l, int c) {
54
    private void setSizeLayoutSize(int l, int c) {
52
        this.lines = l;
55
        this.lines = l;
53
        this.columns = c;
56
        this.columns = c;
54
        this.mask = new Boolean[l][c];
57
        this.mask = new Boolean[l][c];
55
        for (int i = 0; i < l; i++) {
58
        for (int i = 0; i < l; i++) {
Line 100... Line 103...
100
                    g.setColor(Color.GRAY);
103
                    g.setColor(Color.GRAY);
101
                    g2.setStroke(dashed);
104
                    g2.setStroke(dashed);
102
                    g.drawRect(x, y, w, h);
105
                    g.drawRect(x, y, w, h);
103
                    // Label
106
                    // Label
104
                    if (rowIndex < list.size()) {
107
                    if (rowIndex < list.size()) {
105
                        SQLRowAccessor row = list.get(rowIndex);
108
                        Label row = list.get(rowIndex);
106
                        renderer.paintLabel(g, row, x, y, w, h, 10f);
109
                        renderer.paintLabel(g, row, x, y, w, h, 10f);
107
                    }
110
                    }
108
                    rowIndex++;
111
                    rowIndex++;
109
                }
112
                }
110
 
113
 
Line 167... Line 170...
167
        int rowIndex = pageIndex * nbLabelPerPage;
170
        int rowIndex = pageIndex * nbLabelPerPage;
168
        for (int i = 0; i < this.lines; i++) {
171
        for (int i = 0; i < this.lines; i++) {
169
            for (int j = 0; j < this.columns; j++) {
172
            for (int j = 0; j < this.columns; j++) {
170
                boolean mask = this.mask[i][j];
173
                boolean mask = this.mask[i][j];
171
                if (!mask && rowIndex < list.size()) {
174
                if (!mask && rowIndex < list.size()) {
172
                    SQLRowAccessor row = list.get(rowIndex);
175
                    Label row = list.get(rowIndex);
173
                    renderer.paintLabel(g, row, j * w + imageableX, i * h + imageableY, w, h, 10f);
176
                    renderer.paintLabel(g, row, j * w + imageableX, i * h + imageableY, w, h, 10f);
174
                }
177
                }
175
                rowIndex++;
178
                rowIndex++;
176
            }
179
            }
177
 
180