Java Code Examples for org.pentaho.reporting.libraries.resourceloader.Resource#getSource()

The following examples show how to use org.pentaho.reporting.libraries.resourceloader.Resource#getSource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultImageReference.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public DefaultImageReference( final Resource imageResource ) throws ResourceException {
  if ( imageResource == null ) {
    throw new NullPointerException();
  }
  final Object o = imageResource.getResource();
  if ( o instanceof Image == false ) {
    throw new ResourceException( "ImageResource does not contain a java.awt.Image object." );
  }
  final ResourceKey resKey = imageResource.getSource();
  final Object identifier = resKey.getIdentifier();
  if ( identifier instanceof URL ) {
    this.url = (URL) identifier;
  }
  this.resourceKey = resKey;
  this.image = (Image) o;
  final WaitingImageObserver obs = new WaitingImageObserver( image );
  obs.waitImageLoaded();
  if ( obs.isError() ) {
    throw new ResourceException( "Failed to load the image. ImageObserver signaled an error." );
  }
  this.width = image.getWidth( null );
  this.height = image.getHeight( null );
}
 
Example 2
Source File: EHResourceFactoryCache.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void put( final Resource resource ) {
  final Object source = new CompoundCacheKey( resource.getSource(), resource.getTargetType() );
  try {
    factoryCache.put( new Element( source, (Object) resource ) );
  } catch ( Exception e ) {
    if ( logger.isDebugEnabled() ) {
      logger.debug( "Failed to store resource for key " + source, e );
    }
    // ignore ... the object is not serializable ..
  }
}
 
Example 3
Source File: EHResourceFactoryCache.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void remove( final Resource resource ) {
  final Object source = new CompoundCacheKey( resource.getSource(), resource.getTargetType() );
  factoryCache.remove( source );
}