1 /*
   2  * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.javafx.iio;
  27 
  28 /**
  29  * A class containing a limited number of relatively important metadata fields.
  30  * A <code>null</code>-valued field indicates that the metadata field has not
  31  * been set.
  32  */
  33 public class ImageMetadata {
  34     /**
  35      * The image gamma.
  36      */
  37     public final Float gamma;
  38 
  39     /**
  40      * <code>true</code> if smaller values represent darker shades.
  41      */
  42     public final Boolean blackIsZero;
  43 
  44     /**
  45      * A palette index to be used as a background.
  46      */
  47     public final Integer backgroundIndex;
  48 
  49     /**
  50      * An RGB color to be used as a background.
  51      */
  52     public final Integer backgroundColor;
  53 
  54     /**
  55      * The amount of time to wait (in milliseconds) before continuing
  56      * to process the data stream.
  57      */
  58     public final Integer delayTime;
  59 
  60     /**
  61      * The amount of times to loop the animation, zero or null if the animation
  62      * should loop endlessly.
  63      */
  64     public final Integer loopCount;
  65 
  66     /**
  67      * A palette index to be used for transparent pixels.
  68      */
  69     public final Integer transparentIndex;
  70 
  71     /**
  72      * The width of of the image.
  73      */
  74     public final Integer imageWidth;
  75 
  76     /**
  77      * The height of the image.
  78      */
  79     public final Integer imageHeight;
  80 
  81     /**
  82      * The X offset of the image relative to the screen origin.
  83      * Note: This is applicable to GIF image only.
  84      */
  85     public final Integer imageLeftPosition;
  86 
  87     /**
  88      * The Y offset of the image relative to the screen origin.
  89      * Note: This is applicable to GIF image only.
  90      */
  91     public final Integer imageTopPosition;
  92 
  93     /**
  94      * The disposal method for the image.
  95      * Note: This is applicable to GIF image only.
  96      */
  97     public final Integer disposalMethod;
  98 
  99     /**
 100      *
 101      * @param gamma the image gamma
 102      * @param blackIsZero whether smaller values represent darker shades
 103      * @param backgroundIndex a palette index to use as background
 104      * @param backgroundColor the color to be used as background.
 105      * The color format, in Integer, is packed as ARGB with 8 bits per channel.
 106      * @param delayTime the amount of time to pause at the current image
 107      * (milliseconds).
 108      * @param loopCount the amount of times to loop the animation
 109      * (zero for infinite loop).
 110      * @param transparentIndex a palette index to be used as transparency.
 111      */
 112     public ImageMetadata(Float gamma, Boolean blackIsZero,
 113             Integer backgroundIndex, Integer backgroundColor,
 114             Integer transparentIndex, Integer delayTime, Integer loopCount,
 115             Integer imageWidth, Integer imageHeight,
 116             Integer imageLeftPosition, Integer imageTopPosition,
 117             Integer disposalMethod) {
 118         this.gamma = gamma;
 119         this.blackIsZero = blackIsZero;
 120         this.backgroundIndex = backgroundIndex;
 121         this.backgroundColor = backgroundColor;
 122         this.transparentIndex = transparentIndex;
 123         this.delayTime = delayTime;
 124         this.loopCount = loopCount;
 125         this.imageWidth = imageWidth;
 126         this.imageHeight = imageHeight;
 127         this.imageLeftPosition = imageLeftPosition;
 128         this.imageTopPosition = imageTopPosition;
 129         this.disposalMethod = disposalMethod;
 130     }
 131 
 132     @Override
 133     public String toString() {
 134         StringBuffer sb = new StringBuffer("["+getClass().getName());
 135         if (gamma != null) {
 136             sb.append(" gamma: " + gamma);
 137         }
 138         if (blackIsZero != null) {
 139             sb.append(" blackIsZero: " + blackIsZero);
 140         }
 141         if (backgroundIndex != null) {
 142             sb.append(" backgroundIndex: " + backgroundIndex);
 143         }
 144         if (backgroundColor != null) {
 145             sb.append(" backgroundColor: " + backgroundColor);
 146         }
 147         if (delayTime != null) {
 148             sb.append(" delayTime: " + delayTime);
 149         }
 150         if (loopCount != null) {
 151             sb.append(" loopCount: " + loopCount);
 152         }
 153         if (transparentIndex != null) {
 154             sb.append(" transparentIndex: " + transparentIndex);
 155         }
 156         if (imageWidth != null) {
 157             sb.append(" imageWidth: " + imageWidth);
 158         }
 159         if (imageHeight != null) {
 160             sb.append(" imageHeight: " + imageHeight);
 161         }
 162         if (imageLeftPosition != null) {
 163             sb.append(" imageLeftPosition: " + imageLeftPosition);
 164         }
 165         if (imageTopPosition != null) {
 166             sb.append(" imageTopPosition: " + imageTopPosition);
 167         }
 168         if (disposalMethod != null) {
 169             sb.append(" disposalMethod: " + disposalMethod);
 170         }
 171         sb.append("]");
 172         return sb.toString();
 173     }
 174 }