OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 17 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17 Rev 180
Line 26... Line 26...
26
 
26
 
27
import javax.imageio.ImageIO;
27
import javax.imageio.ImageIO;
28
 
28
 
29
import org.jdom.Element;
29
import org.jdom.Element;
30
 
30
 
31
abstract class BytesProducer {
31
public abstract class BytesProducer {
32
 
32
 
33
    /**
33
    /**
34
     * The data of an image to put in <code>frame</code>.
34
     * The data of an image to put in <code>frame</code>.
35
     * 
35
     * 
36
     * @param frame the frame where this image will be put.
36
     * @param frame the frame where this image will be put.
37
     * @return the corresponding bytes.
37
     * @return the corresponding bytes.
38
     */
38
     */
39
    abstract byte[] getBytes(ODFrame<?> frame);
39
    public abstract byte[] getBytes(ODFrame<?> frame);
40
 
40
 
41
    /**
41
    /**
42
     * The format of the data returned by {@link #getBytes(Element)}.
42
     * The format of the data returned by {@link #getBytes(Element)}.
43
     * 
43
     * 
44
     * @return the name of the format, <code>null</code> if unknown, eg "png".
44
     * @return the name of the format, <code>null</code> if unknown, eg "png".
45
     */
45
     */
46
    abstract String getFormat();
46
    public abstract String getFormat();
47
 
47
 
48
    // *** concrete subclasses
48
    // *** concrete subclasses
49
 
49
 
50
    // a no-op Producer
50
    // a no-op Producer
51
    static final class ByteArrayProducer extends BytesProducer {
51
    static public final class ByteArrayProducer extends BytesProducer {
52
 
52
 
53
        private final byte[] data;
53
        private final byte[] data;
54
        private final boolean keepRatio;
54
        private final boolean keepRatio;
55
 
55
 
56
        public ByteArrayProducer(byte[] data) {
56
        public ByteArrayProducer(byte[] data) {
Line 102... Line 102...
102
            return null;
102
            return null;
103
        }
103
        }
104
    }
104
    }
105
 
105
 
106
    // will generate a new png image (and can also keep ratio)
106
    // will generate a new png image (and can also keep ratio)
107
    static final class ImageProducer extends BytesProducer {
107
    static public final class ImageProducer extends BytesProducer {
108
 
108
 
109
        private final Image img;
109
        private final Image img;
110
        private final boolean keepRatio;
110
        private final boolean keepRatio;
111
 
111
 
112
        public ImageProducer(Image img, boolean keepRatio) {
112
        public ImageProducer(Image img, boolean keepRatio) {