001 /**
002 * Copyright (c) 2009, Piet Blok
003 * All rights reserved.
004 *
005 * Redistribution and use in source and binary forms, with or without
006 * modification, are permitted provided that the following conditions
007 * are met:
008 *
009 * * Redistributions of source code must retain the above copyright
010 * notice, this list of conditions and the following disclaimer.
011 * * Redistributions in binary form must reproduce the above
012 * copyright notice, this list of conditions and the following
013 * disclaimer in the documentation and/or other materials provided
014 * with the distribution.
015 * * Neither the name of the copyright holder nor the names of the
016 * contributors may be used to endorse or promote products derived
017 * from this software without specific prior written permission.
018 *
019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
020 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
021 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
022 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
023 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
024 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
025 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
026 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
027 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
028 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
029 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
030 */
031
032 package org.pbjar.jxlayer.plaf.ext.transform;
033
034 import java.awt.Dimension;
035 import java.awt.Graphics;
036 import java.awt.geom.AffineTransform;
037
038 import javax.swing.event.ChangeListener;
039
040 import org.jdesktop.jxlayer.JXLayer;
041 import org.pbjar.jxlayer.plaf.ext.TransformUI;
042
043 /**
044 * The {@link TransformModel} interface specifies the methods the
045 * {@link TransformUI} will use to interrogate a transformation model.
046 *
047 * @author Piet Blok
048 */
049 public interface TransformModel {
050
051 /**
052 * Add a {@link ChangeListener} that will be notified when the internal
053 * state of this model changes.
054 *
055 * @param listener
056 * a {@link ChangeListener}
057 * @see #removeChangeListener(ChangeListener)
058 */
059 public abstract void addChangeListener(ChangeListener listener);
060
061 /**
062 * Get a preferred {@link AffineTransform}. This method will typically be
063 * invoked by programs that calculate a preferred size.
064 * <p>
065 * The {@code size} argument will be used to compute anchor values for some
066 * types of transformations. If the {@code size} argument is {@code null} a
067 * value of (0,0) is used for the anchor.
068 * </p>
069 *
070 * @param size
071 * a {@link Dimension} instance to be used for an anchor or
072 * {@code null}
073 * @param layer
074 * the {@link JXLayer}.
075 * @return a {@link AffineTransform} instance or {@code null}
076 */
077 public abstract AffineTransform getPreferredTransform(Dimension size,
078 JXLayer<?> layer);
079
080 /**
081 * Get a {@link AffineTransform}. This method will typically be invoked by
082 * programs that are about to prepare a {@link Graphics} object.
083 *
084 * @param layer
085 * the {@link JXLayer}
086 *
087 * @return a {@link AffineTransform} or {@code null}
088 */
089 public abstract AffineTransform getTransform(JXLayer<?> layer);
090
091 /**
092 * Remove a {@link ChangeListener}.
093 *
094 * @param listener
095 * a {@link ChangeListener}
096 * @see #addChangeListener(ChangeListener)
097 */
098 public abstract void removeChangeListener(ChangeListener listener);
099
100 }