OSDN Git Service

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