it = ImageIO.getImageWritersByMIMEType( s ); if ( !it.hasNext( ) ) { throw new ChartException( ChartDeviceExtensionPlugin.ID, ChartException.RENDERING, "exception.no.imagewriter.mimetype", new Object[]{ getMimeType( ) }, ResourceBundle.getBundle( Messages.DEVICE_EXTENSION, getLocale( ) ) ); } } final ImageWriter iw = (ImageWriter) it.next( );  logger.log( ILogger.INFORMATION, Messages.getString( "info.using.imagewriter", getLocale( ) ) + getFormat( ) + iw.getClass( ).getName( ) );   final Object o = ( _oOutputIdentifier instanceof String ) ? new File( (String) _oOutputIdentifier ) : _oOutputIdentifier; try { final ImageOutputStream ios = ImageIO.createImageOutputStream( o ); updateWriterParameters( iw.getDefaultWriteParam( ) );      iw.setOutput( ios ); iw.write( (BufferedImage) _img ); ios.close( ); } catch ( Exception ex ) { throw new ChartException( ChartDeviceExtensionPlugin.ID, ChartException.RENDERING, ex );
	public void after( ) throws ChartException	{		super.after( );		// SEARCH FOR WRITER USING FORMAT		Iterator it = null;		String s = getFormat( );		if ( s != null )		{			it = ImageIO.getImageWritersByFormatName( s );			if ( !it.hasNext( ) )			{				it = null; // GET INTO NEXT CONSTRUCT; SEARCH BY MIME TYPE			}		}		// SEARCH FOR WRITER USING MIME TYPE		if ( it == null )		{			s = getMimeType( );			if ( s == null )			{				throw new ChartException( ChartDeviceExtensionPlugin.ID,						ChartException.RENDERING,						"exception.no.imagewriter.mimetype.and.format",//$NON-NLS-1$						new Object[]{								getMimeType( ),								getFormat( ),								getClass( ).getName( )						},						ResourceBundle.getBundle( Messages.DEVICE_EXTENSION,								getLocale( ) ) );			}			it = ImageIO.getImageWritersByMIMEType( s );			if ( !it.hasNext( ) )			{				throw new ChartException( ChartDeviceExtensionPlugin.ID,						ChartException.RENDERING,						"exception.no.imagewriter.mimetype", //$NON-NLS-1$						new Object[]{							getMimeType( )						},						ResourceBundle.getBundle( Messages.DEVICE_EXTENSION,								getLocale( ) ) );			}		}		final ImageWriter iw = (ImageWriter) it.next( );		logger.log( ILogger.INFORMATION,				Messages.getString( "info.using.imagewriter", getLocale( ) ) //$NON-NLS-1$						+ getFormat( ) + iw.getClass( ).getName( ) );		// WRITE TO SPECIFIC FILE FORMAT		final Object o = ( _oOutputIdentifier instanceof String ) ? new File( (String) _oOutputIdentifier )				: _oOutputIdentifier;		try		{			final ImageOutputStream ios = ImageIO.createImageOutputStream( o );			updateWriterParameters( iw.getDefaultWriteParam( ) ); // SET ANY			// OUTPUT			// FORMAT			// SPECIFIC			// PARAMETERS			// IF NEEDED			iw.setOutput( ios );			iw.write( (BufferedImage) _img );			ios.close( );		}		catch ( Exception ex )		{			throw new ChartException( ChartDeviceExtensionPlugin.ID,					ChartException.RENDERING,					ex );		}		// FLUSH AND RESTORE STATE OF INTERNALLY CREATED IMAGE		if ( !_bImageExternallySpecified )		{			_img.flush( );			_img = null;		}		// ALWAYS DISPOSE THE GRAPHICS CONTEXT THAT WAS CREATED FROM THE IMAGE		_g2d.dispose( );		_g2d = null;	}