1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.model.media;
|
11
|
|
12
|
|
13
|
import java.util.Calendar;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
|
17
|
import eu.etaxonomy.cdm.common.MediaMetaData.ImageMetaData;
|
18
|
import eu.etaxonomy.cdm.model.agent.Agent;
|
19
|
|
20
|
import javax.persistence.*;
|
21
|
|
22
|
/**
|
23
|
* @author m.doering
|
24
|
* @version 1.0
|
25
|
* @created 08-Nov-2007 13:06:28
|
26
|
*/
|
27
|
@Entity
|
28
|
public class ImageFile extends MediaRepresentationPart {
|
29
|
static Logger logger = Logger.getLogger(ImageFile.class);
|
30
|
//image height in pixel
|
31
|
private int height;
|
32
|
//image width in pixel
|
33
|
private int width;
|
34
|
|
35
|
public static ImageFile NewInstance(String uri, Integer size){
|
36
|
return new ImageFile(uri, size);
|
37
|
}
|
38
|
|
39
|
public static ImageFile NewInstance(String uri, Integer size, Integer height, Integer width){
|
40
|
return new ImageFile(uri, size, height, width);
|
41
|
}
|
42
|
|
43
|
public static ImageFile NewInstance(String uri, Integer size, ImageMetaData imageMetaData){
|
44
|
return new ImageFile(uri, size, imageMetaData.getHeight(), imageMetaData.getWidth());
|
45
|
}
|
46
|
|
47
|
/**
|
48
|
* Generated an instance of Media that contains one MediaRepresentation consisting of one ImageFile
|
49
|
* @param mimeType the MimeType
|
50
|
* @param suffix the file suffix (e.g. jpg, png, ...
|
51
|
* @param mediaCreated creation date of the media
|
52
|
* @param artist artist that created this media
|
53
|
* @param uri the uri of the image file
|
54
|
* @param size the size of the image file
|
55
|
* @param height the height of the image file
|
56
|
* @param width the width of the image file
|
57
|
* @return
|
58
|
*/
|
59
|
public static Media NewMediaInstance(Calendar mediaCreated, Agent artist, String uri, String mimeType, String suffix, Integer size, Integer height, Integer width){
|
60
|
Media media = Media.NewInstance();
|
61
|
media.setMediaCreated(mediaCreated);
|
62
|
media.setArtist(artist);
|
63
|
MediaRepresentation mediaRepresentation = MediaRepresentation.NewInstance(mimeType, suffix);
|
64
|
media.addRepresentation(mediaRepresentation);
|
65
|
ImageFile image = ImageFile.NewInstance(uri, size, height, size);
|
66
|
mediaRepresentation.addRepresentationPart(image);
|
67
|
return media;
|
68
|
}
|
69
|
|
70
|
|
71
|
|
72
|
|
73
|
protected ImageFile(){
|
74
|
super();
|
75
|
}
|
76
|
|
77
|
protected ImageFile(String uri, Integer size){
|
78
|
super(uri, size);
|
79
|
}
|
80
|
|
81
|
protected ImageFile(String uri, Integer size, Integer height, Integer width){
|
82
|
super(uri, size);
|
83
|
if (height != null){
|
84
|
this.setHeight(height);
|
85
|
}
|
86
|
if (width != null){
|
87
|
this.setWidth(width);
|
88
|
}
|
89
|
}
|
90
|
|
91
|
public int getHeight(){
|
92
|
return this.height;
|
93
|
}
|
94
|
|
95
|
/**
|
96
|
*
|
97
|
* @param height height
|
98
|
*/
|
99
|
public void setHeight(int height){
|
100
|
this.height = height;
|
101
|
}
|
102
|
|
103
|
public int getWidth(){
|
104
|
return this.width;
|
105
|
}
|
106
|
|
107
|
/**
|
108
|
*
|
109
|
* @param width width
|
110
|
*/
|
111
|
public void setWidth(int width){
|
112
|
this.width = width;
|
113
|
}
|
114
|
|
115
|
}
|