1
|
1 package de.mpg.mpiwg.itgroup.digilib.manipulator.extensions;
|
|
2
|
|
3 import java.io.InputStream;
|
|
4
|
|
5 import org.eclipse.swt.graphics.Image;
|
|
6 import org.eclipse.swt.widgets.Composite;
|
|
7
|
|
8 import de.mpg.mpiwg.itgroup.digilib.digiImage.DigiImageController;
|
|
9 import de.mpg.mpiwg.itgroup.digilib.manipulator.IDigilibImageManipulator;
|
|
10
|
9
|
11 /**
|
|
12 * Abstract class where all Digilib Manipulator extensions shoud be derived from
|
|
13 *
|
|
14 * @author dwinter
|
|
15 *
|
|
16 */
|
1
|
17 public abstract class ManipulatorExtension implements IDigilibImageManipulator {
|
|
18
|
|
19 private String iconOff;
|
|
20 private String iconOn;
|
|
21
|
|
22 private String imagePath;
|
|
23 private String keyword;
|
|
24
|
|
25
|
9
|
26 /* (non-Javadoc)
|
|
27 * @see de.mpg.mpiwg.itgroup.digilib.manipulator.IDigilibImageManipulator#getKeyword()
|
|
28 */
|
1
|
29 public String getKeyword() {
|
|
30 return keyword;
|
|
31 }
|
|
32
|
|
33
|
9
|
34 /* (non-Javadoc)
|
|
35 * @see de.mpg.mpiwg.itgroup.digilib.manipulator.IDigilibImageManipulator#run(de.mpg.mpiwg.itgroup.digilib.digiImage.DigiImageController)
|
|
36 */
|
1
|
37 public void run(DigiImageController dc) {};
|
|
38
|
9
|
39
|
|
40 /**
|
|
41 * Set path to icon. path is path with in classpath
|
|
42 * @param ip
|
|
43 */
|
1
|
44 public void setImagePath(String ip) {
|
|
45 imagePath=ip;
|
|
46
|
|
47 }
|
|
48
|
9
|
49 /**
|
|
50 * @return path to the current icon within the class path
|
|
51 */
|
1
|
52 public String getImagePath() {
|
|
53 return imagePath;
|
|
54
|
|
55 }
|
|
56
|
9
|
57 /**
|
|
58 * @param keyword keyword which identifies the extension, used by
|
|
59 * @see {@link de.mpg.mpiwg.itgroup.digilib.manipulator.DigilibImageManipulatorProvider}.
|
|
60 *
|
|
61 */
|
1
|
62 public void setKeyword(String keyword) {
|
|
63 this.keyword = keyword;
|
|
64 }
|
|
65
|
9
|
66 /* (non-Javadoc)
|
|
67 * @see de.mpg.mpiwg.itgroup.digilib.manipulator.IDigilibImageManipulator#createImage(org.eclipse.swt.widgets.Composite)
|
|
68 */
|
1
|
69 public Image createImage(Composite parent) {
|
|
70 InputStream is = getClass().getResourceAsStream(getImagePath());
|
|
71 Image img = new Image(parent.getDisplay(),is);
|
|
72 return img;
|
|
73 }
|
|
74
|
9
|
75 /**
|
|
76 * Toggle selection state of the navigation icon
|
|
77 */
|
1
|
78 public void toggleIcon(){
|
|
79 if(imagePath.equals(iconOff)){
|
|
80 setImagePath(iconOn);
|
|
81 } else {
|
|
82 setImagePath(iconOff);
|
|
83 }
|
|
84 }
|
|
85
|
9
|
86 /**
|
|
87 * Set icon to off state.
|
|
88 */
|
1
|
89 public void setOffIcon(){
|
|
90 setImagePath(iconOff);
|
|
91 }
|
|
92
|
9
|
93 /**
|
|
94 * Setze die Pfade zu den Icons innerhalb des class path.
|
|
95 * @param iconOff
|
|
96 * @param iconOn
|
|
97 */
|
1
|
98 public void setIconPaths(String iconOff, String iconOn) {
|
|
99 this.iconOff=iconOff;
|
|
100 this.iconOn=iconOn;
|
|
101
|
|
102 }
|
|
103
|
|
104 }
|