OSDN Git Service

設定変える準備を搭載。
[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             int startX = 90;
73
74             Paint framePaint = new Paint();
75             framePaint.setStyle(Paint.Style.STROKE);
76             framePaint.setColor(Color.WHITE);
77             framePaint.setTextSize(24);
78
79             String message = shooting_mode + " REMAIN : " + sd_remain_size  + " ISO : " + iso  + " BATT: ";
80             if (battery_level < 0)
81             {
82                 message = message + "???";
83             }
84             else
85             {
86                 message = message + battery_level + "% ";
87             }
88             message = message + " " + shutter_speed + " " + aperture + "  " + expRev + " : cnt:" + f_ss_Control;
89             canvas.drawText(message, startX, centerY - 50, framePaint);
90             Log.v(TAG, message);
91
92
93             message = "WB: " + whiteBalance + " ";
94             if (focusPoint != null)
95             {
96                 message = message + "FOCUS : [" + focusPoint.x + "," + focusPoint.y + "] ";
97             }
98             if (focus_lock)
99             {
100                 message = message + " (LOCKED)";
101             }
102             if (isDeviceError)
103             {
104                 message = message + " ERROR";
105             }
106             message = message + " [" + focusControlMode + "] ";
107             canvas.drawText(message, startX, centerY, framePaint);
108             Log.v(TAG, message);
109
110
111             message = imageAspect + " " + imageFormat + " " + "[" + filmSimulation + "]" + " ";
112             canvas.drawText(message, startX, centerY + 50, framePaint);
113             Log.v(TAG, message);
114
115         }
116         catch (Exception e)
117         {
118             e.printStackTrace();
119         }
120     }
121
122     /**
123      *   表示エリアの情報を更新する
124      *
125      *
126      */
127     public void drawInformation(IFujiStatus cameraStatus)
128     {
129         focusPoint = cameraStatus.getFocusPoint();
130         sd_remain_size = cameraStatus.getRemainImageSpace();
131         shooting_mode = cameraStatus.getShootingMode();
132         focus_lock = cameraStatus.isFocusLocked();
133         battery_level = cameraStatus.getBatteryLevel();
134         isDeviceError = cameraStatus.isDeviceError();
135         iso = cameraStatus.getIsoSensitivity();
136         shutter_speed = cameraStatus.getShutterSpeed();
137         aperture = cameraStatus.getAperture();
138         expRev = cameraStatus.getExpRev();
139         whiteBalance = cameraStatus.getWhiteBalance();
140         f_ss_Control = cameraStatus.getF_SS_Control();
141         focusControlMode = cameraStatus.getFocusControlMode();
142         imageAspect = cameraStatus.getImageAspect();
143         imageFormat = cameraStatus.getImageFormat();
144         filmSimulation = cameraStatus.getFilmSimulation();
145     }
146
147 }