Debian Codegraph @

src/com/drew/metadata/ico/IcoDescriptor.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.ico;
23
24 import com.drew.lang.annotations.NotNull;
25 import com.drew.lang.annotations.Nullable;
26 import com.drew.metadata.TagDescriptor;
27
28 import static com.drew.metadata.ico.IcoDirectory.*;
29
30 /**
31 * @author Drew Noakes https://drewnoakes.com
32 */
33 @SuppressWarnings("WeakerAccess")
34 public class IcoDescriptor extends TagDescriptor<IcoDirectory>
35 {
36 public IcoDescriptor(@NotNull IcoDirectory directory)
37 {
38 super(directory);
39 }
40
41 @Override
42 public String getDescription(int tagType)
43 {
44 switch (tagType) {
45 case TAG_IMAGE_TYPE:
46 return getImageTypeDescription();
47 case TAG_IMAGE_WIDTH:
48 return getImageWidthDescription();
49 case TAG_IMAGE_HEIGHT:
50 return getImageHeightDescription();
51 case TAG_COLOUR_PALETTE_SIZE:
52 return getColourPaletteSizeDescription();
53 default:
54 return super.getDescription(tagType);
55 }
56 }
57
58 @Nullable
59 public String getImageTypeDescription()
60 {
61 return getIndexedDescription(TAG_IMAGE_TYPE, 1, "Icon", "Cursor");
62 }
63
64 @Nullable
65 public String getImageWidthDescription()
66 {
67 Integer width = _directory.getInteger(TAG_IMAGE_WIDTH);
68 if (width == null)
69 return null;
70 return (width == 0 ? 256 : width) + " pixels";
71 }
72
73 @Nullable
74 public String getImageHeightDescription()
75 {
76 Integer width = _directory.getInteger(TAG_IMAGE_HEIGHT);
77 if (width == null)
78 return null;
79 return (width == 0 ? 256 : width) + " pixels";
80 }
81
82 @Nullable
83 public String getColourPaletteSizeDescription()
84 {
85 Integer size = _directory.getInteger(TAG_COLOUR_PALETTE_SIZE);
86 if (size == null)
87 return null;
88 return size == 0 ? "No palette" : size + " colour" + (size == 1 ? "" : "s");
89 }
90 }