Merge from the pain train
[official-gcc.git] / libjava / javax / imageio / IIOParam.java
blob1a59123995ffe2c02414c1c9ed860deb25f303a5
1 /* IIOParam.java --
2 Copyright (C) 2004 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax.imageio;
41 import java.awt.Point;
42 import java.awt.Rectangle;
44 /**
45 * @author Michael Koch (konqueror@gmx.de)
47 public abstract class IIOParam
49 protected IIOParamController controller;
50 protected IIOParamController defaultController;
51 protected Point destinationOffset = new Point(0, 0);
52 protected ImageTypeSpecifier destinationType;
53 protected int[] sourceBands;
54 protected Rectangle sourceRegion;
55 protected int sourceXSubsampling;
56 protected int sourceYSubsampling;
57 protected int subsamplingXOffset;
58 protected int subsamplingYOffset;
60 /**
61 * Initializes an <code>IIOParam</code> object.
63 protected IIOParam()
65 // Do nothing here.
68 public boolean activateController()
70 if (controller == null)
71 return false;
73 return controller.activate(this);
76 public IIOParamController getController()
78 return controller;
81 public IIOParamController getDefaultController()
83 return defaultController;
86 public Point getDestinationOffset()
88 return destinationOffset;
91 public ImageTypeSpecifier getDestinationType()
93 return destinationType;
96 public int[] getSourceBands()
98 return sourceBands;
101 public Rectangle getSourceRegion()
103 return sourceRegion;
106 public int getSourceXSubsampling()
108 return sourceXSubsampling;
111 public int getSourceYSubsampling()
113 return sourceYSubsampling;
116 public int getSubsamplingXOffset()
118 return subsamplingXOffset;
121 public int getSubsamplingYOffset()
123 return subsamplingYOffset;
126 public boolean hasController()
128 return getController() != null;
131 public void setController(IIOParamController controller)
133 this.controller = controller;
136 public void setDestinationOffset(Point destinationOffset)
138 if (destinationOffset == null)
139 throw new IllegalArgumentException("destinationOffset is null");
141 this.destinationOffset = destinationOffset;
144 public void setSourceBands(int[] sourceBands)
146 this.sourceBands = sourceBands;
149 public void setSourceRegion(Rectangle sourceRegion)
151 if (sourceRegion != null
152 && (sourceRegion.x < 0
153 || sourceRegion.y < 0
154 || sourceRegion.width <= 0
155 || sourceRegion.height <= 0))
156 throw new IllegalArgumentException("illegal source region");
158 // FIXME: Throw IllegalStateException.
160 this.sourceRegion = sourceRegion;
163 public void setSourceSubsampling(int sourceXSubsampling, int sourceYSubsampling,
164 int subsamplingXOffset, int subsamplingYOffset)
166 this.sourceXSubsampling = sourceXSubsampling;
167 this.sourceYSubsampling = sourceYSubsampling;
168 this.subsamplingXOffset = subsamplingXOffset;
169 this.subsamplingYOffset = subsamplingYOffset;