    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017package org.apache.commons.imaging.formats.gif;
    018
    019import org.apache.commons.imaging.common.ImageMetadata;
    020
    021public class GifImageMetadataItem implements ImageMetadata.ImageMetadataItem {
    022    private static final String NEWLINE = System.getProperty("line.separator");
    023    private final int delay;
    024    private final int leftPosition;
    025    private final int topPosition;
    026    private final DisposalMethod disposalMethod;
    027
    028    GifImageMetadataItem(final int delay, final int leftPosition, final int topPosition, final DisposalMethod disposalMethod) {
    029        this.delay = delay;
    030        this.leftPosition = leftPosition;
    031        this.topPosition = topPosition;
    032        this.disposalMethod = disposalMethod;
    033    }
    034
    035    public int getDelay() {
    036        return delay;
    037    }
    038
    039    public int getLeftPosition() {
    040        return leftPosition;
    041    }
    042
    043    public int getTopPosition() {
    044        return topPosition;
    045    }
    046
    047    public DisposalMethod getDisposalMethod() {
    048        return disposalMethod;
    049    }
    050
    051    @Override
    052    public String toString(String prefix) {
    053        prefix = prefix == null ? "" : prefix;
    054        final StringBuilder result = new StringBuilder();
    055        result.append(String.format("%sDelay: %d%s", prefix, delay, NEWLINE));
    056        result.append(String.format("%sLeft position: %d%s", prefix, leftPosition, NEWLINE));
    057        result.append(String.format("%sTop position: %d%s", prefix, topPosition, NEWLINE));
    058        result.append(String.format("%sDisposal method: %s%s", prefix, disposalMethod, NEWLINE));
    059        return result.toString();
    060    }
    061}