| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
package com.drew.metadata.gif; |
| 22 |
|
| 23 |
import com.drew.lang.annotations.NotNull; |
| 24 |
import com.drew.metadata.Directory; |
| 25 |
|
| 26 |
import java.util.HashMap; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
@SuppressWarnings("WeakerAccess") |
| 33 |
public class GifControlDirectory extends Directory |
| 34 |
{ |
| 35 |
public static final int TAG_DELAY = 1; |
| 36 |
public static final int TAG_DISPOSAL_METHOD = 2; |
| 37 |
public static final int TAG_USER_INPUT_FLAG = 3; |
| 38 |
public static final int TAG_TRANSPARENT_COLOR_FLAG = 4; |
| 39 |
public static final int TAG_TRANSPARENT_COLOR_INDEX = 5; |
| 40 |
|
| 41 |
@NotNull |
| 42 |
private static final HashMap<Integer, String> _tagNameMap = new HashMap<Integer, String>(); |
| 43 |
|
| 44 |
static |
| 45 |
{ |
| 46 |
_tagNameMap.put(TAG_DELAY, "Delay"); |
| 47 |
_tagNameMap.put(TAG_DISPOSAL_METHOD, "Disposal Method"); |
| 48 |
_tagNameMap.put(TAG_USER_INPUT_FLAG, "User Input Flag"); |
| 49 |
_tagNameMap.put(TAG_TRANSPARENT_COLOR_FLAG, "Transparent Color Flag"); |
| 50 |
_tagNameMap.put(TAG_TRANSPARENT_COLOR_INDEX, "Transparent Color Index"); |
| 51 |
} |
| 52 |
|
| 53 |
public GifControlDirectory() |
| 54 |
{ |
| 55 |
this.setDescriptor(new GifControlDescriptor(this)); |
| 56 |
} |
| 57 |
|
| 58 |
@Override |
| 59 |
@NotNull |
| 60 |
public String getName() |
| 61 |
{ |
| 62 |
return "GIF Control"; |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
@NotNull |
| 69 |
public DisposalMethod getDisposalMethod() { |
| 70 |
return (DisposalMethod) getObject(TAG_DISPOSAL_METHOD); |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
public boolean isTransparent() { |
| 77 |
Boolean transparent = getBooleanObject(TAG_TRANSPARENT_COLOR_FLAG); |
| 78 |
return transparent != null && transparent; |
| 79 |
} |
| 80 |
|
| 81 |
@Override |
| 82 |
@NotNull |
| 83 |
protected HashMap<Integer, String> getTagNameMap() |
| 84 |
{ |
| 85 |
return _tagNameMap; |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
public enum DisposalMethod { |
| 93 |
NOT_SPECIFIED, |
| 94 |
DO_NOT_DISPOSE, |
| 95 |
RESTORE_TO_BACKGROUND_COLOR, |
| 96 |
RESTORE_TO_PREVIOUS, |
| 97 |
TO_BE_DEFINED, |
| 98 |
INVALID; |
| 99 |
|
| 100 |
public static DisposalMethod typeOf(int value) { |
| 101 |
switch (value) { |
| 102 |
case 0: return NOT_SPECIFIED; |
| 103 |
case 1: return DO_NOT_DISPOSE; |
| 104 |
case 2: return RESTORE_TO_BACKGROUND_COLOR; |
| 105 |
case 3: return RESTORE_TO_PREVIOUS; |
| 106 |
case 4: |
| 107 |
case 5: |
| 108 |
case 6: |
| 109 |
case 7: return TO_BE_DEFINED; |
| 110 |
default: return INVALID; |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
@Override |
| 115 |
public String toString() { |
| 116 |
switch (this) { |
| 117 |
case DO_NOT_DISPOSE: |
| 118 |
return "Don't Dispose"; |
| 119 |
case INVALID: |
| 120 |
return "Invalid value"; |
| 121 |
case NOT_SPECIFIED: |
| 122 |
return "Not Specified"; |
| 123 |
case RESTORE_TO_BACKGROUND_COLOR: |
| 124 |
return "Restore to Background Color"; |
| 125 |
case RESTORE_TO_PREVIOUS: |
| 126 |
return "Restore to Previous"; |
| 127 |
case TO_BE_DEFINED: |
| 128 |
return "To Be Defined"; |
| 129 |
default: |
| 130 |
return super.toString(); |
| 131 |
} |
| 132 |
} |
| 133 |
} |
| 134 |
} |