Revision 922939ec
Added by Andreas Müller over 6 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/media/MediaUtils.java | ||
---|---|---|
28 | 28 |
* |
29 | 29 |
* |
30 | 30 |
*/ |
31 |
public static MediaRepresentation findBestMatchingRepresentation(Media media, Class<? extends MediaRepresentationPart> representationPartType, Integer size, Integer height, Integer widthOrDuration, String[] mimeTypes){ |
|
31 |
public static MediaRepresentation findBestMatchingRepresentation(Media media, |
|
32 |
Class<? extends MediaRepresentationPart> representationPartType, Integer size, Integer height, |
|
33 |
Integer widthOrDuration, String[] mimeTypes){ |
|
32 | 34 |
// find best matching representations of each media |
33 | 35 |
SortedMap<Integer, MediaRepresentation> prefRepresentations |
34 |
= filterAndOrderMediaRepresentations(media.getRepresentations(), null, mimeTypes, size, widthOrDuration, height); |
|
36 |
= filterAndOrderMediaRepresentations(media.getRepresentations(), null, mimeTypes, |
|
37 |
size, widthOrDuration, height); |
|
35 | 38 |
try { |
36 | 39 |
// take first one and remove all other representations |
37 | 40 |
MediaRepresentation prefOne = prefRepresentations.get(prefRepresentations.firstKey()); |
... | ... | |
165 | 168 |
candidateRepresentations.addAll(media.getRepresentations()); |
166 | 169 |
|
167 | 170 |
SortedMap<Integer, MediaRepresentation> prefRepresentations |
168 |
= filterAndOrderMediaRepresentations(candidateRepresentations, representationPartType, mimeTypes, size, widthOrDuration, height); |
|
171 |
= filterAndOrderMediaRepresentations(candidateRepresentations, representationPartType, |
|
172 |
mimeTypes, size, widthOrDuration, height); |
|
169 | 173 |
try { |
170 | 174 |
if(prefRepresentations.size() > 0){ |
171 | 175 |
// Media.representations is a set |
... | ... | |
177 | 181 |
logger.debug(nse); |
178 | 182 |
/* IGNORE */ |
179 | 183 |
} |
180 |
|
|
181 | 184 |
} |
182 | 185 |
} |
183 | 186 |
else{ |
... | ... | |
295 | 298 |
int sizeOfPart = part.getSize(); |
296 | 299 |
int distance = sizeOfPart - size; |
297 | 300 |
if (distance < 0) { |
298 |
distance*= -1; |
|
301 |
distance *= -1;
|
|
299 | 302 |
} |
300 | 303 |
dwa += distance; |
301 | 304 |
} |
Also available in: Unified diff
cleanup