]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/function/RotatePhoto.java
Version 9, February 2010
[GpsPrune.git] / tim / prune / function / RotatePhoto.java
1 package tim.prune.function;
2
3 import tim.prune.App;
4 import tim.prune.DataSubscriber;
5 import tim.prune.GenericFunction;
6 import tim.prune.I18nManager;
7 import tim.prune.UpdateMessageBroker;
8 import tim.prune.data.Photo;
9 import tim.prune.undo.UndoRotatePhoto;
10
11 /**
12  * Class to provide the function to rotate a photo
13  * either clockwise or anticlockwise
14  */
15 public class RotatePhoto extends GenericFunction
16 {
17         /** Direction of rotation */
18         private boolean _direction = true;
19
20         /**
21          * Constructor
22          * @param inApp application object for callback
23          * @param inDir true for clockwise, false for anticlockwise
24          */
25         public RotatePhoto(App inApp, boolean inDir)
26         {
27                 super(inApp);
28                 _direction = inDir;
29         }
30
31         /** Get the name key */
32         public String getNameKey() {
33                 return _direction?"function.rotatephotoright":"function.rotatephotoleft";
34         }
35
36         /**
37          * Begin the function
38          */
39         public void begin()
40         {
41                 Photo photo = _app.getTrackInfo().getCurrentPhoto();
42                 if (photo != null)
43                 {
44                         UndoRotatePhoto undo = new UndoRotatePhoto(photo, _direction);
45                         photo.rotate(_direction);
46                         UpdateMessageBroker.informSubscribers(DataSubscriber.PHOTOS_MODIFIED);
47                         _app.completeFunction(undo, I18nManager.getText("confirm.rotatephoto"));
48                 }
49         }
50 }