OSDN Git Service

initial.
[gokigen/Gr2Control.git] / app / src / main / java / net / osdn / gokigen / gr2control / camera / ricohgr2 / operation / RicohGr2CameraFocusControl.java
1 package net.osdn.gokigen.gr2control.camera.ricohgr2.operation;
2
3 import android.graphics.PointF;
4 import android.support.annotation.NonNull;
5 import android.util.Log;
6 import android.view.MotionEvent;
7
8 import net.osdn.gokigen.gr2control.camera.IFocusingControl;
9 import net.osdn.gokigen.gr2control.camera.ricohgr2.operation.takepicture.RicohGr2AutoFocusControl;
10 import net.osdn.gokigen.gr2control.liveview.IAutoFocusFrameDisplay;
11 import net.osdn.gokigen.gr2control.liveview.IIndicatorControl;
12
13 /**
14  *
15  *
16  */
17 public class RicohGr2CameraFocusControl implements IFocusingControl
18 {
19     private final String TAG = toString();
20     private final RicohGr2AutoFocusControl afControl;
21     private final IAutoFocusFrameDisplay frameDisplay;
22
23     /**
24      *
25      *
26      */
27     public RicohGr2CameraFocusControl(@NonNull final IAutoFocusFrameDisplay frameDisplayer, @NonNull final IIndicatorControl indicator)
28     {
29         this.frameDisplay = frameDisplayer;
30         this.afControl = new RicohGr2AutoFocusControl(frameDisplayer, indicator);
31     }
32
33     /**
34      *
35      *
36      */
37     @Override
38     public boolean driveAutoFocus(MotionEvent motionEvent)
39     {
40         Log.v(TAG, "driveAutoFocus()");
41         if (motionEvent.getAction() != MotionEvent.ACTION_DOWN)
42         {
43             return (false);
44         }
45         try
46         {
47             PointF point = frameDisplay.getPointWithEvent(motionEvent);
48             if (frameDisplay.isContainsPoint(point))
49             {
50                 afControl.lockAutoFocus(point);
51             }
52         }
53         catch (Exception e)
54         {
55             e.printStackTrace();
56         }
57         return (false);
58     }
59
60     /**
61      *
62      *
63      */
64     @Override
65     public void unlockAutoFocus()
66     {
67         afControl.unlockAutoFocus();
68     }
69 }