Debian Codegraph @

src/com/drew/metadata/exif/PanasonicRawDistortionDescriptor.java

raw symbols SCIP
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;
23
24 import com.drew.lang.Rational;
25 import com.drew.lang.annotations.NotNull;
26 import com.drew.lang.annotations.Nullable;
27 import com.drew.metadata.TagDescriptor;
28
29 import static com.drew.metadata.exif.PanasonicRawDistortionDirectory.*;
30
31 /**
32 * Provides human-readable string representations of tag values stored in a {@link PanasonicRawDistortionDirectory}.
33 *
34 * @author Kevin Mott https://github.com/kwhopper
35 * @author Drew Noakes https://drewnoakes.com
36 */
37 @SuppressWarnings("WeakerAccess")
38 public class PanasonicRawDistortionDescriptor extends TagDescriptor<PanasonicRawDistortionDirectory>
39 {
40 public PanasonicRawDistortionDescriptor(@NotNull PanasonicRawDistortionDirectory directory)
41 {
42 super(directory);
43 }
44
45 @Override
46 @Nullable
47 public String getDescription(int tagType)
48 {
49 switch (tagType) {
50 case TagDistortionParam02:
51 return getDistortionParam02Description();
52 case TagDistortionParam04:
53 return getDistortionParam04Description();
54 case TagDistortionScale:
55 return getDistortionScaleDescription();
56 case TagDistortionCorrection:
57 return getDistortionCorrectionDescription();
58 case TagDistortionParam08:
59 return getDistortionParam08Description();
60 case TagDistortionParam09:
61 return getDistortionParam09Description();
62 case TagDistortionParam11:
63 return getDistortionParam11Description();
64 default:
65 return super.getDescription(tagType);
66 }
67 }
68
69 @Nullable
70 public String getDistortionParam02Description()
71 {
72 Integer value = _directory.getInteger(TagDistortionParam02);
73 if (value == null)
74 return null;
75
76 return new Rational(value, 32678).toString();
77 }
78
79 @Nullable
80 public String getDistortionParam04Description()
81 {
82 Integer value = _directory.getInteger(TagDistortionParam04);
83 if (value == null)
84 return null;
85
86 return new Rational(value, 32678).toString();
87 }
88
89 @Nullable
90 public String getDistortionScaleDescription()
91 {
92 Integer value = _directory.getInteger(TagDistortionScale);
93 if (value == null)
94 return null;
95
96 //return (1 / (1 + value / 32768)).toString();
97 return Integer.toString(1 / (1 + value / 32768));
98 }
99
100 @Nullable
101 public String getDistortionCorrectionDescription()
102 {
103 Integer value = _directory.getInteger(TagDistortionCorrection);
104 if (value == null)
105 return null;
106
107 // (have seen the upper 4 bits set for GF5 and GX1, giving a value of -4095 - PH)
108 int mask = 0x000f;
109 switch (value & mask)
110 {
111 case 0:
112 return "Off";
113 case 1:
114 return "On";
115 default:
116 return "Unknown (" + value + ")";
117 }
118 }
119
120 @Nullable
121 public String getDistortionParam08Description()
122 {
123 Integer value = _directory.getInteger(TagDistortionParam08);
124 if (value == null)
125 return null;
126
127 return new Rational(value, 32678).toString();
128 }
129
130 @Nullable
131 public String getDistortionParam09Description()
132 {
133 Integer value = _directory.getInteger(TagDistortionParam09);
134 if (value == null)
135 return null;
136
137 return new Rational(value, 32678).toString();
138 }
139
140 @Nullable
141 public String getDistortionParam11Description()
142 {
143 Integer value = _directory.getInteger(TagDistortionParam11);
144 if (value == null)
145 return null;
146
147 return new Rational(value, 32678).toString();
148 }
149 }