/[classpath]/classpath/javax/imageio/ImageWriter.java
ViewVC logotype

Diff of /classpath/javax/imageio/ImageWriter.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by mkoch, Tue Oct 5 07:07:53 2004 UTC revision 1.3 by mkoch, Tue Oct 5 10:27:03 2004 UTC
# Line 38  exception statement from your version. * Line 38  exception statement from your version. *
38    
39  package javax.imageio;  package javax.imageio;
40    
41    import java.awt.Dimension;
42    import java.io.IOException;
43  import java.util.Iterator;  import java.util.Iterator;
44  import java.util.List;  import java.util.List;
45  import java.util.Locale;  import java.util.Locale;
# Line 51  import javax.imageio.spi.ImageWriterSpi; Line 53  import javax.imageio.spi.ImageWriterSpi;
53  public abstract class ImageWriter  public abstract class ImageWriter
54    implements ImageTranscoder    implements ImageTranscoder
55  {  {
56      private boolean aborted;
57      
58    protected Locale[] availableLocales;    protected Locale[] availableLocales;
59    protected Locale locale;    protected Locale locale;
60    protected ImageWriterSpi originatingProvider;    protected ImageWriterSpi originatingProvider;
# Line 64  public abstract class ImageWriter Line 68  public abstract class ImageWriter
68      this.originatingProvider = originatingProvider;      this.originatingProvider = originatingProvider;
69    }    }
70    
71      private void checkOutputSet()
72      {
73        if (output == null)
74          throw new IllegalStateException("no output set");
75      }
76      
77      public void abort()
78      {
79        aborted = true;
80      }
81    
82      protected boolean abortRequested()
83      {
84        return aborted;
85      }
86    
87    public void addIIOWriteProgressListener(IIOWriteProgressListener listener)    public void addIIOWriteProgressListener(IIOWriteProgressListener listener)
88    {    {
89      if (listener == null)      if (listener == null)
# Line 80  public abstract class ImageWriter Line 100  public abstract class ImageWriter
100      warningListeners.add(listener);      warningListeners.add(listener);
101    }    }
102    
103      public boolean canInsertEmpty(int imageIndex)
104        throws IOException
105      {
106        checkOutputSet();
107        return false;
108      }
109    
110      public boolean canInsertImage(int imageIndex)
111        throws IOException
112      {
113        checkOutputSet();
114        return false;
115      }
116    
117      public boolean canRemoveImage(int imageIndex)
118        throws IOException
119      {
120        checkOutputSet();
121        return false;
122      }
123    
124      public boolean canReplaceImageMetadata(int imageIndex)
125        throws IOException
126      {
127        checkOutputSet();
128        return false;
129      }
130    
131      public boolean canReplacePixels(int imageIndex)
132        throws IOException
133      {
134        checkOutputSet();
135        return false;
136      }
137    
138      public boolean canReplaceStreamMetadata()
139        throws IOException
140      {
141        checkOutputSet();
142        return false;
143      }
144    
145      public boolean canWriteEmpty()
146        throws IOException
147      {
148        checkOutputSet();
149        return false;
150      }
151    
152      public boolean canWriteRasters()
153      {
154        return false;
155      }
156    
157      public boolean canWriteSequence()
158      {
159        return false;
160      }
161    
162      protected void clearAbortRequest()
163      {
164        aborted = false;
165      }
166      
167      public void dispose()
168      {
169        // The default implementation is empty. Subclasses have to overwrite it.
170      }
171      
172    public Locale[] getAvailableLocales()    public Locale[] getAvailableLocales()
173    {    {
174      return availableLocales;      return availableLocales;
# Line 89  public abstract class ImageWriter Line 178  public abstract class ImageWriter
178    
179    public abstract IIOMetadata getDefaultStreamMetadata (ImageWriteParam param);    public abstract IIOMetadata getDefaultStreamMetadata (ImageWriteParam param);
180    
181      public ImageWriteParam getDefaultWriteParam()
182      {
183        return new ImageWriteParam(getLocale());
184      }
185    
186    public Locale getLocale()    public Locale getLocale()
187    {    {
188      return locale;      return locale;
189    }    }
190    
191      public int getNumThumbnailsSupported (ImageTypeSpecifier imageType, ImageWriteParam param,
192                                            IIOMetadata streamMetadata, IIOMetadata imageMetadata)
193      {
194        return 0;
195      }
196    
197    public ImageWriterSpi getOriginatingProvider()    public ImageWriterSpi getOriginatingProvider()
198    {    {
199      return originatingProvider;      return originatingProvider;
200    }    }
201    
202      public Object getOutput()
203      {
204        return output;
205      }
206    
207      public Dimension[] getPreferredThumbnailSizes (ImageTypeSpecifier imageType,
208                                                     ImageWriteParam param,
209                                                     IIOMetadata streamMetadata,
210                                                     IIOMetadata imageMetadata)
211      {
212        return null;
213      }
214    
215    protected void processImageComplete()    protected void processImageComplete()
216    {    {
217      Iterator it = progressListeners.iterator();      Iterator it = progressListeners.iterator();
# Line 212  public abstract class ImageWriter Line 325  public abstract class ImageWriter
325            
326      warningListeners.remove(listener);      warningListeners.remove(listener);
327    }    }
328      
329      public void reset()
330      {
331        setOutput(null);
332        setLocale(null);
333        removeAllIIOWriteWarningListeners();
334        removeAllIIOWriteProgressListeners();
335        clearAbortRequest();
336      }
337      
338      public void setLocale(Locale locale)
339      {
340        if (locale != null)
341          {
342            // Check if its a valid locale.
343            boolean found = false;
344    
345            if (availableLocales != null)
346              for (int i = availableLocales.length - 1; i >= 0; --i)
347                if (availableLocales[i].equals(locale))
348                  found = true;
349    
350            if (! found)
351              throw new IllegalArgumentException("looale not available");
352          }
353    
354        this.locale = locale;
355      }
356    
357      public void setOutput(Object output)
358      {
359        if (output != null)
360          {
361            // Check if its a valid output object.
362            boolean found = false;
363            Class[] types = null;
364    
365            if (originatingProvider != null)
366              types = originatingProvider.getOutputTypes();
367            
368            if (types != null)
369              for (int i = types.length - 1; i >= 0; --i)
370                if (types[i].equals(output.getClass()))
371                  found = true;
372    
373            if (! found)
374              throw new IllegalArgumentException("output type not available");
375          }
376    
377        this.output = output;
378      }
379  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26