Revision e8e82804
Added by Katja Luther over 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaViewLabelProvider.java | ||
---|---|---|
27 | 27 |
import eu.etaxonomy.cdm.model.media.Media; |
28 | 28 |
import eu.etaxonomy.cdm.model.media.MediaRepresentation; |
29 | 29 |
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart; |
30 |
import eu.etaxonomy.cdm.model.media.MediaUtils; |
|
30 | 31 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
31 | 32 |
|
32 | 33 |
/** |
... | ... | |
61 | 62 |
@Override |
62 | 63 |
public Image getImage(Object element) { |
63 | 64 |
Image image = null; |
65 |
int scale = 50; |
|
64 | 66 |
if (element instanceof Media && PreferencesUtil.isShowMediaPreview()){ |
65 | 67 |
Set<MediaRepresentation> representations = ((Media)element).getRepresentations(); |
66 | 68 |
if(representations.iterator().hasNext()){ |
67 |
MediaRepresentation rep = representations.iterator().next();
|
|
68 |
List<MediaRepresentationPart> parts = rep.getParts(); |
|
69 |
MediaRepresentation rep = null;
|
|
70 |
|
|
69 | 71 |
MediaRepresentationPart smallestPart = null; |
72 |
rep = MediaUtils.findBestMatchingRepresentation((Media)element, null, null, scale, scale, null); |
|
73 |
List<MediaRepresentationPart> parts = rep.getParts(); |
|
70 | 74 |
for (MediaRepresentationPart part: parts){ |
71 | 75 |
if (smallestPart != null){ |
72 | 76 |
if (smallestPart.getSize() != null && part.getSize() != null) { |
... | ... | |
79 | 83 |
} |
80 | 84 |
|
81 | 85 |
} |
82 |
URI uri = parts.get(0).getUri();
|
|
86 |
URI uri = smallestPart.getUri();
|
|
83 | 87 |
if (uri == null){ |
84 | 88 |
return null; |
85 | 89 |
} |
... | ... | |
89 | 93 |
image = new Image(Display.getCurrent(), imageStream); |
90 | 94 |
int height = image.getBounds().height; |
91 | 95 |
int width = image.getBounds().width; |
92 |
int scale = 50; |
|
96 |
|
|
93 | 97 |
if (height>width){ |
94 | 98 |
width = width/(height/scale); |
95 | 99 |
height = scale; |
Also available in: Unified diff
use mediaUtils for getting the best matching media representation for mediaViewLabelProvider