/
MImage.java
153 lines (129 loc) · 3.38 KB
/
MImage.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*******************************************************************************
* Copyright (c) 2017 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Obeo - initial API and implementation
*
*******************************************************************************/
package org.obeonetwork.m2doc.element;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.eclipse.emf.common.util.URI;
/**
* An image that can be returned by services.
*
* @author <a href="mailto:yvan.lussaud@obeo.fr">Yvan Lussaud</a>
*/
public interface MImage extends MElement {
/**
* An empty {@link MImage}.
*/
// CHECKSTYLE:OFF
MImage EMPTY = new MImage() {
/**
* The empty {@link URI}.
*/
private final URI uri = URI.createURI("");
@Override
public void setWidth(int width) {
// nothing to do here
}
@Override
public void setHeight(int height) {
// nothing to do here
}
@Override
public void setConserveRatio(boolean conserveRatio) {
// nothing to do here
}
@Override
public int getWidth() {
return 0;
}
@Override
public URI getURI() {
return uri;
}
@Override
public PictureType getType() {
return PictureType.JPG;
}
@Override
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(new byte[] {});
}
@Override
public int getHeight() {
return 0;
}
@Override
public boolean conserveRatio() {
return false;
}
};
// CHECKSTYLE:ON
/**
* Gets the image width.
*
* @return the image width
*/
int getWidth();
/**
* Sets the image width.
*
* @param width
* the image width
*/
void setWidth(int width);
/**
* Gets the image height.
*
* @return the image height
*/
int getHeight();
/**
* Sets the image height.
*
* @param height
* the image height
*/
void setHeight(int height);
/**
* Tells if we conserve aspect ratio.
*
* @return <code>true</code> if we conserve aspect ratio, <code>false</code> otherwise
*/
boolean conserveRatio();
/**
* Sets the aspect ratio.
*
* @param conserveRatio
* <code>true</code> to conserve the {@link #getRatio() aspect ration}, <code>false</code> otherwise
*/
void setConserveRatio(boolean conserveRatio);
/**
* Gets the {@link URI}.
*
* @return the {@link URI}
*/
URI getURI();
/**
* Gets the {@link InputStream}.
*
* @return the {@link InputStream}
* @throws IOException
* if the {@link InputStream} can't be created.
*/
InputStream getInputStream() throws IOException;
/**
* Gets the {@link PictureType}.
*
* @return the type the {@link PictureType}.
*/
PictureType getType();
}