OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
132 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.ui.light;
15
 
16
import org.openconcerto.utils.io.HTMLable;
17
 
18
import java.util.ArrayList;
19
import java.util.List;
20
 
21
import net.minidev.json.JSONObject;
22
 
23
public class LightUIStrippedImageLine extends LightUILine implements HTMLable {
24
 
25
    private static final long serialVersionUID = 4132718509484530455L;
26
    private List<LightUIImage> images = new ArrayList<LightUIImage>(0);
27
 
28
    public LightUIStrippedImageLine(final List<LightUIImage> images) {
29
        super();
30
        this.images = images;
31
        for (LightUIImage image : images) {
32
            this.addChild(image);
33
        }
34
    }
35
 
36
    public LightUIStrippedImageLine(final JSONObject json) {
37
        super(json);
38
    }
39
 
40
    public LightUIStrippedImageLine(final LightUIStrippedImageLine line) {
41
        super(line);
42
    }
43
 
44
    @Override
45
    protected void copy(LightUIElement element) {
46
        super.copy(element);
47
 
48
        if (!(element instanceof LightUIStrippedImageLine)) {
49
            throw new InvalidClassException(this.getClassName(), element.getClassName(), element.getId());
50
        }
51
 
52
        final LightUIStrippedImageLine line = (LightUIStrippedImageLine) element;
53
        this.images = line.images;
54
    }
55
 
56
    @Override
57
    public String getHTML() {
58
        StringBuilder b = new StringBuilder();
59
        for (LightUIImage image : this.images) {
60
            b.append("<img src=\"");
61
            b.append(image.getValue());
62
            b.append("\" ");
63
            if (image.getWidth() != null) {
64
                b.append("width=\"");
65
                b.append(image.getWidth());
66
                b.append("\" ");
67
            }
68
            if (image.getHeight() != null) {
69
                b.append("height=\"");
70
                b.append(image.getHeight());
71
                b.append("\" ");
72
            }
73
            if (this.getElementMargin() != null && this.getElementMargin() > 0) {
74
                b.append("style=\"margin:");
75
                b.append(this.getElementMargin());
76
                b.append("px \" ");
77
            }
78
            b.append("/> ");
79
        }
80
        return b.toString();
81
    }
82
}