| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 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 |
|
| 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 |
} |