1
|
1 package de.mpg.mpiwg.itgroup.digilib.manipulator.extensions;
|
|
2
|
|
3
|
|
4
|
|
5 import org.eclipse.swt.widgets.Button;
|
|
6 import org.eclipse.swt.widgets.Event;
|
|
7 import org.eclipse.swt.widgets.Listener;
|
|
8 import org.eclipse.swt.widgets.Shell;
|
|
9 import org.eclipse.swt.widgets.Text;
|
|
10 import org.eclipse.swt.widgets.Widget;
|
|
11
|
|
12 import de.mpg.mpiwg.itgroup.digilib.digiImage.DigiImageController;
|
|
13 import de.mpg.mpiwg.itgroup.digilib.manipulator.extensions.dialogs.RotateDialog;
|
|
14 import de.mpg.mpiwg.itgroup.digilib.plugin.editors.DigilibLinkEditorObservable;
|
|
15
|
9
|
16 /**
|
|
17 * Open an dialog for entering the ration angle.
|
|
18 * @author dwinter
|
|
19 *
|
|
20 */
|
1
|
21 public class Rotate extends ManipulatorExtension {
|
|
22
|
|
23 public String iconOff="/de/mpg/mpiwg/itgroup/digilib/icons/greyskin/rotate.png";
|
|
24 public String iconOn="/de/mpg/mpiwg/itgroup/digilib/icons/greyskin/rotate-on.png";
|
|
25
|
|
26
|
|
27 public Rotate() {
|
|
28 setIconPaths(iconOff,iconOn);
|
|
29 setOffIcon();
|
|
30 setKeyword("rotateHorizontal");
|
|
31 }
|
|
32
|
|
33 public void run(final DigiImageController dc) {
|
|
34
|
|
35 //digiImage.hmir();
|
|
36 //toggleIcon();
|
|
37
|
|
38 Listener buttonListener = new Listener() {
|
|
39 int rotateValue=0;
|
|
40 public void handleEvent(Event event) {
|
|
41 Widget wg = event.widget;
|
|
42 if (Button.class.isInstance(wg)){
|
|
43 dc.rotate(rotateValue);
|
|
44 Shell sh = ((Button)wg).getShell();
|
21
|
45 //DigilibLinkEditorObservable.INSTANCE.imageHasChanged(dc.digiImage);
|
1
|
46 setOffIcon();
|
|
47 sh.close();
|
|
48 } else if (Text.class.isInstance(wg)) {
|
|
49 Text txt = (Text)wg;
|
|
50 if (txt.getText()!=null){
|
|
51 String t = txt.getText();
|
|
52 try{
|
|
53 rotateValue=Integer.valueOf(t);
|
|
54 } catch (NumberFormatException e) {
|
|
55 // TODO: handle exception
|
|
56 }
|
|
57 }
|
|
58 }
|
|
59 }
|
|
60 };
|
|
61
|
|
62 RotateDialog rd = new RotateDialog(buttonListener,dc);
|
|
63 rd.open();
|
|
64 }
|
|
65 }
|