public Resource create( final ResourceManager caller, final ResourceData data, final ResourceKey context ) throws ResourceLoadingException { final long version = data.getVersion( caller ); final Image image = Toolkit.getDefaultToolkit().createImage( data.getResource( caller ) ); return new SimpleResource( data.getKey(), image, Image.class, version ); } }
public Object getResource() { final Document resource = (Document) super.getResource(); return resource.cloneNode( true ); } }
/** * The primary source is also included in this set. The dependencies are given as ResourceKey objects. The keys itself * do not hold any state information. * <p/> * The dependencies do not track deep dependencies. So if Resource A depends on Resource B which depends on Resource * C, then A only knows about B, not C. * * @return */ public ResourceKey[] getDependencies() { return new ResourceKey[] { getSource() }; }
public Resource create( final ResourceManager caller, final ResourceData data, final ResourceKey context ) throws ResourceLoadingException { final long version = data.getVersion( caller ); final Image image = Toolkit.getDefaultToolkit().createImage( data.getResource( caller ) ); return new SimpleResource( data.getKey(), image, Image.class, version ); } }
public Resource create( final ResourceManager caller, final ResourceData data, final ResourceKey context ) throws ResourceLoadingException { final long version = data.getVersion( caller ); final Image image = Toolkit.getDefaultToolkit().createImage( data.getResource( caller ) ); return new SimpleResource( data.getKey(), image, Image.class, version ); } }
public Resource create( final ResourceManager manager, final ResourceData data, final ResourceKey context ) throws ResourceCreationException, ResourceLoadingException { try { final Properties properties = new Properties(); final InputStream stream = data.getResourceAsStream( manager ); try { properties.load( stream ); } finally { stream.close(); } return new SimpleResource( data.getKey(), properties, Properties.class, data.getVersion( manager ) ); } catch ( IOException e ) { throw new ResourceLoadingException( "Failed to load the properties file.", e ); } }
public Resource create( final ResourceManager caller, final ResourceData data, final ResourceKey context ) throws ResourceLoadingException { try { final long version = data.getVersion( caller ); final InputStream stream = data.getResourceAsStream( caller ); try { final WmfFile wmfFile = new WmfFile( stream, -1, -1 ); return new SimpleResource( data.getKey(), wmfFile, DrawableWrapper.class, version ); } finally { stream.close(); } } catch ( IOException e ) { throw new ResourceLoadingException( "Failed to process WMF file", e ); } }
drawable.draw( graphics, new Rectangle2D.Double( 0, 0, bounds.getWidth(), bounds.getHeight() ) ); graphics.dispose(); return new SimpleResource( data.getKey(), bi, Image.class, version ); } catch ( IOException e ) { throw new ResourceLoadingException( "Failed to process SVG file", e );
public Resource create( final ResourceManager caller, final ResourceData data, final ResourceKey context ) throws ResourceLoadingException { try { final long version = data.getVersion( caller ); final InputStream stream = data.getResourceAsStream( caller ); try { final WmfFile wmfFile = new WmfFile( stream, -1, -1 ); final Image image = wmfFile.replay(); return new SimpleResource( data.getKey(), image, Image.class, version ); } finally { stream.close(); } } catch ( IOException e ) { throw new ResourceLoadingException( "Failed to process WMF file", e ); } }
public Resource create( final ResourceManager manager, final ResourceData data, final ResourceKey context ) throws ResourceCreationException, ResourceLoadingException { try { final InputStream in = data.getResourceAsStream( manager ); final ObjectInputStream oin = new ObjectInputStream( in ); try { final Object ob = oin.readObject(); // yes, that will be more generic in the future ... if ( ob instanceof External8BitEncodingData == false ) { throw new ResourceCreationException( "This is no 8Bit Encoding data" ); } final External8BitEncodingData encData = (External8BitEncodingData) ob; final External8BitEncodingCore encCore = new External8BitEncodingCore( encData ); return new SimpleResource( data.getKey(), encCore, getFactoryType(), data.getVersion( manager ) ); } finally { oin.close(); } } catch ( IOException e ) { throw new ResourceLoadingException( "Failed to load resource", e ); } catch ( ClassNotFoundException e ) { throw new ResourceCreationException ( "Missing class definition: Failed to create encoding." ); } }
public Resource create( final ResourceManager caller, final ResourceData data, final ResourceKey context ) throws ResourceCreationException, ResourceLoadingException { final long version = data.getVersion( caller ); final byte[] resource = data.getResource( caller ); final Image image; try { image = createImage( resource ); } catch ( IOException e ) { throw new ResourceCreationException( "Failed to load the image.", e ); } if ( image == null ) { throw new ResourceCreationException( "Failed to load the image. ImageIO#read returned null" ); } return new SimpleResource( data.getKey(), image, Image.class, version ); }
public Resource create( final ResourceManager caller, final ResourceData data, final ResourceKey context ) throws ResourceLoadingException { try { final long version = data.getVersion( caller ); final HeadlessSVGUserAgent userAgent = new HeadlessSVGUserAgent(); final DocumentLoader loader = new DocumentLoader( userAgent ); final ResourceKey key = data.getKey(); URL url = caller.toURL( key ); if ( url == null ) { url = new File( "." ).toURI().toURL(); } final SVGDocument document = (SVGDocument) loader.loadDocument ( url.toURI().toASCIIString(), data.getResourceAsStream( caller ) ); final BridgeContext ctx = new BridgeContext( userAgent, loader ); final GVTBuilder builder = new GVTBuilder(); final GraphicsNode node = builder.build( ctx, document ); return new SimpleResource( data.getKey(), new SVGDrawable( node ), DrawableWrapper.class, version ); } catch ( IOException e ) { throw new ResourceLoadingException( "Failed to process SVG file", e ); } catch ( URISyntaxException e ) { throw new ResourceLoadingException( "Failed to process SVG file", e ); } }
public Resource create( final ResourceManager manager, ResourceData data, final ResourceKey context ) throws ResourceCreationException, ResourceLoadingException { if ( data instanceof CachingResourceBundleData ) { // todo: Friggin' cheap hack final CachingResourceBundleData cachingResourceBundleData = (CachingResourceBundleData) data; data = cachingResourceBundleData.getBackend(); } if ( data instanceof RepositoryResourceBundleData == false ) { data = manager.loadResourceBundle( data.getKey() ); if ( data instanceof CachingResourceBundleData ) { // todo: Friggin' cheap hack 2 final CachingResourceBundleData cachingResourceBundleData = (CachingResourceBundleData) data; data = cachingResourceBundleData.getBackend(); } } if ( data instanceof RepositoryResourceBundleData == false ) { throw new ContentNotRecognizedException( "No valid handler for the given content." ); } final RepositoryResourceBundleData bdata = (RepositoryResourceBundleData) data; final Repository repository = bdata.getRepository(); try { final StaticDocumentBundle bundle = new StaticDocumentBundle( repository, manager, bdata.getBundleKey() ); return new SimpleResource( data.getKey(), bundle, getFactoryType(), data.getVersion( manager ) ); } catch ( ResourceException e ) { throw new ResourceCreationException( "Unable to interpret document-bundle", e ); } }