1 | /*
|
---|
2 | * Copyright 2002-2019 Drew Noakes and contributors
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | *
|
---|
16 | * More information about this project is available at:
|
---|
17 | *
|
---|
18 | * https://drewnoakes.com/code/exif/
|
---|
19 | * https://github.com/drewnoakes/metadata-extractor
|
---|
20 | */
|
---|
21 |
|
---|
22 | package com.drew.metadata.exif.makernotes;
|
---|
23 |
|
---|
24 | import com.drew.lang.annotations.NotNull;
|
---|
25 | import com.drew.lang.annotations.Nullable;
|
---|
26 | import com.drew.metadata.StringValue;
|
---|
27 | import com.drew.metadata.TagDescriptor;
|
---|
28 |
|
---|
29 | import java.text.DateFormat;
|
---|
30 | import java.text.DecimalFormat;
|
---|
31 | import java.text.ParseException;
|
---|
32 | import java.text.SimpleDateFormat;
|
---|
33 |
|
---|
34 | import static com.drew.metadata.exif.makernotes.ReconyxHyperFireMakernoteDirectory.*;
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * Provides human-readable string representations of tag values stored in a {@link ReconyxHyperFireMakernoteDirectory}.
|
---|
38 | *
|
---|
39 | * @author Todd West http://cascadescarnivoreproject.blogspot.com
|
---|
40 | */
|
---|
41 | @SuppressWarnings("WeakerAccess")
|
---|
42 | public class ReconyxHyperFireMakernoteDescriptor extends TagDescriptor<ReconyxHyperFireMakernoteDirectory>
|
---|
43 | {
|
---|
44 | public ReconyxHyperFireMakernoteDescriptor(@NotNull ReconyxHyperFireMakernoteDirectory directory)
|
---|
45 | {
|
---|
46 | super(directory);
|
---|
47 | }
|
---|
48 |
|
---|
49 | @Override
|
---|
50 | @Nullable
|
---|
51 | public String getDescription(int tagType)
|
---|
52 | {
|
---|
53 | switch (tagType) {
|
---|
54 | case TAG_MAKERNOTE_VERSION:
|
---|
55 | return String.format("%d", _directory.getInteger(tagType));
|
---|
56 | case TAG_FIRMWARE_VERSION:
|
---|
57 | return _directory.getString(tagType);
|
---|
58 | case TAG_TRIGGER_MODE:
|
---|
59 | return _directory.getString(tagType);
|
---|
60 | case TAG_SEQUENCE:
|
---|
61 | int[] sequence = _directory.getIntArray(tagType);
|
---|
62 | if (sequence == null)
|
---|
63 | return null;
|
---|
64 | return String.format("%d/%d", sequence[0], sequence[1]);
|
---|
65 | case TAG_EVENT_NUMBER:
|
---|
66 | return String.format("%d", _directory.getInteger(tagType));
|
---|
67 | case TAG_MOTION_SENSITIVITY:
|
---|
68 | return String.format("%d", _directory.getInteger(tagType));
|
---|
69 | case TAG_BATTERY_VOLTAGE:
|
---|
70 | Double value = _directory.getDoubleObject(tagType);
|
---|
71 | DecimalFormat formatter = new DecimalFormat("0.000");
|
---|
72 | return value == null ? null : formatter.format(value);
|
---|
73 | case TAG_DATE_TIME_ORIGINAL:
|
---|
74 | String date = _directory.getString(tagType);
|
---|
75 | try {
|
---|
76 | DateFormat parser = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
|
---|
77 | return parser.format(parser.parse(date));
|
---|
78 | } catch (ParseException e) {
|
---|
79 | return null;
|
---|
80 | }
|
---|
81 | case TAG_MOON_PHASE:
|
---|
82 | return getIndexedDescription(tagType, "New", "Waxing Crescent", "First Quarter", "Waxing Gibbous", "Full", "Waning Gibbous", "Last Quarter", "Waning Crescent");
|
---|
83 | case TAG_AMBIENT_TEMPERATURE_FAHRENHEIT:
|
---|
84 | case TAG_AMBIENT_TEMPERATURE:
|
---|
85 | return String.format("%d", _directory.getInteger(tagType));
|
---|
86 | case TAG_SERIAL_NUMBER:
|
---|
87 | // default is UTF_16LE
|
---|
88 | StringValue svalue = _directory.getStringValue(tagType);
|
---|
89 | if(svalue == null)
|
---|
90 | return null;
|
---|
91 | return svalue.toString();
|
---|
92 | case TAG_CONTRAST:
|
---|
93 | case TAG_BRIGHTNESS:
|
---|
94 | case TAG_SHARPNESS:
|
---|
95 | case TAG_SATURATION:
|
---|
96 | return String.format("%d", _directory.getInteger(tagType));
|
---|
97 | case TAG_INFRARED_ILLUMINATOR:
|
---|
98 | return getIndexedDescription(tagType, "Off", "On");
|
---|
99 | case TAG_USER_LABEL:
|
---|
100 | return _directory.getString(tagType);
|
---|
101 | default:
|
---|
102 | return super.getDescription(tagType);
|
---|
103 | }
|
---|
104 | }
|
---|
105 | }
|
---|