-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathImage.java
More file actions
executable file
·49 lines (40 loc) · 1005 Bytes
/
Copy pathImage.java
File metadata and controls
executable file
·49 lines (40 loc) · 1005 Bytes
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
package javaforce.webui;
/** Image.
*
* @author pquiring
*/
public class Image extends Component {
private Resource img;
private String api;
private int count;
public Image(Resource img) {
this.img = img;
}
public Image(String api_url) {
this.api = api_url;
}
private String getsrc() {
if (img != null) {
return "/static/" + img.id;
}
if (api != null) {
return "/api/" + api;
}
return "/user/" + getClient().hash + "/" + id + "/" + count;
}
public String html() {
return "<img" + getAttrs() + " src='" + getsrc() + "'>";
}
public void setImage(Resource img) {
this.img = img;
sendEvent("setsrc", new String[] {"src=" + getsrc()});
}
public void setImage(String api_url) {
this.api = api_url;
sendEvent("setsrc", new String[] {"src=" + getsrc()});
}
public void refresh() {
count++;
sendEvent("setsrc", new String[] {"src=" + getsrc()});
}
}