OSDN Git Service

843fb8e057c631705fc2af137ecd5c83d845b742
[gokigen/FujiCam.git] / app / src / main / java / net / osdn / gokigen / cameratest / camtest / InformationView.java
1 package net.osdn.gokigen.cameratest.camtest;
2
3 import android.content.Context;
4 import android.graphics.Canvas;
5 import android.graphics.Color;
6 import android.graphics.Paint;
7 import android.graphics.Point;
8 import android.util.AttributeSet;
9 import android.util.Log;
10
11 import androidx.appcompat.widget.AppCompatImageView;
12
13 import net.osdn.gokigen.cameratest.fuji.statuses.IFujiStatus;
14
15 public class InformationView extends AppCompatImageView
16 {
17     private final String TAG = toString();
18     private Point focusPoint;
19     private int sd_remain_size;
20     private String shooting_mode;
21     private boolean focus_lock;
22     private boolean isDeviceError;
23     private int battery_level;
24     private int iso = 0;
25     private String shutter_speed = "";
26     private String aperture = "";
27     private String expRev = "";
28     private String whiteBalance = "";
29     private String focusControlMode = "";
30     private String imageAspect = "";
31     private String imageFormat = "";
32     private String filmSimulation = "";
33     private int f_ss_Control = -1;
34
35
36     public InformationView(Context context) {
37         super(context);
38         initComponent(context);
39     }
40
41     public InformationView(Context context, AttributeSet attrs) {
42         super(context, attrs);
43         initComponent(context);
44     }
45
46     public InformationView(Context context, AttributeSet attrs, int defStyleAttr) {
47         super(context, attrs, defStyleAttr);
48         initComponent(context);
49     }
50
51     private void initComponent(Context context) {
52
53     }
54
55     @Override
56     protected void onDraw(Canvas canvas)
57     {
58         super.onDraw(canvas);
59         drawCanvas(canvas);
60     }
61
62     private void drawCanvas(Canvas canvas)
63     {
64         try
65         {
66             // Clears the canvas.
67             canvas.drawARGB(255, 0, 0, 0);
68
69             // Rotates the image.
70             int centerX = canvas.getWidth() / 2;
71             int centerY = canvas.getHeight() / 2;
72
73             Paint framePaint = new Paint();
74             framePaint.setStyle(Paint.Style.STROKE);
75             framePaint.setColor(Color.WHITE);
76
77             String message = shooting_mode + " REMAIN : " + sd_remain_size  + " ISO : " + iso  + " BATT: ";
78             if (battery_level < 0)
79             {
80                 message = message + "???";
81             }
82             else
83             {
84                 message = message + battery_level + "% ";
85             }
86             message = message + " " + shutter_speed + " " + aperture + "  " + expRev + " : cnt:" + f_ss_Control;
87             canvas.drawText(message, centerX, centerY - 50, framePaint);
88             Log.v(TAG, message);
89
90
91             message = "WB: " + whiteBalance + " ";
92             if (focusPoint != null)
93             {
94                 message = message + "FOCUS : [" + focusPoint.x + "," + focusPoint.y + "] ";
95             }
96             if (focus_lock)
97             {
98                 message = message + " (LOCKED)";
99             }
100             if (isDeviceError)
101             {
102                 message = message + " ERROR";
103             }
104             message = message + " [" + focusControlMode + "] ";
105             canvas.drawText(message, centerX, centerY, framePaint);
106             Log.v(TAG, message);
107
108
109             message = imageAspect + " " + imageFormat + " " + "[" + filmSimulation + "]" + " ";
110             canvas.drawText(message, centerX, centerY + 50, framePaint);
111             Log.v(TAG, message);
112
113         }
114         catch (Exception e)
115         {
116             e.printStackTrace();
117         }
118     }
119
120     /**
121      *   表示エリアの情報を更新する
122      *
123      *
124      */
125     public void drawInformation(IFujiStatus cameraStatus)
126     {
127         focusPoint = cameraStatus.getFocusPoint();
128         sd_remain_size = cameraStatus.getRemainImageSpace();
129         shooting_mode = cameraStatus.getShootingMode();
130         focus_lock = cameraStatus.isFocusLocked();
131         battery_level = cameraStatus.getBatteryLevel();
132         isDeviceError = cameraStatus.isDeviceError();
133         iso = cameraStatus.getIsoSensitivity();
134         shutter_speed = cameraStatus.getShutterSpeed();
135         aperture = cameraStatus.getAperture();
136         expRev = cameraStatus.getExpRev();
137         whiteBalance = cameraStatus.getWhiteBalance();
138         f_ss_Control = cameraStatus.getF_SS_Control();
139         focusControlMode = cameraStatus.getFocusControlMode();
140         imageAspect = cameraStatus.getImageAspect();
141         imageFormat = cameraStatus.getImageFormat();
142         filmSimulation = cameraStatus.getFilmSimulation();
143     }
144
145 }