/** * Sets the maximum image dimensions, used to control scaling of loaded * images. This scaling is enforced immediately upon loading of the image. * @param width the maximum width of images (-1 for no limit) * @param height the maximum height of images (-1 for no limit) */ public void setMaxImageDimensions(int width, int height) { if ( m_images == null ) m_images = new ImageFactory(); m_images.setMaxImageDimensions(width, height); }
waitForImage(image); addImage(imageLocation, image); } else { int id = ++nextTrackerID; LoadMapEntry entry = (LoadMapEntry)loadMap.get(imageLocation); if ( tracker.checkID(entry.id, true) ) { addImage(imageLocation, entry.image); loadMap.remove(imageLocation); tracker.removeImage(entry.image, entry.id);
/** * Returns the image factory used by this renderer. * @return the image factory */ public ImageFactory getImageFactory() { if ( m_images == null ) m_images = new ImageFactory(); return m_images; }
/** * Get the image to include in the label for the given VisualItem. * @param item the item to get an image for * @return the image for the item, or null for no image */ protected Image getImage(VisualItem item) { String imageLoc = getImageLocation(item); return ( imageLoc == null ? null : m_images.getImage(imageLoc) ); }
/** * Create a new ImageFactory. This instance will scale loaded images * if they exceed the threshold arguments. * @param maxImageWidth the maximum width of input images * (-1 means no limit) * @param maxImageHeight the maximum height of input images * (-1 means no limit) */ public ImageFactory(int maxImageWidth, int maxImageHeight) { setMaxImageDimensions(maxImageWidth, maxImageHeight); }
/** * Adds an image associated with a location string to this factory's cache. * The image will be scaled as dictated by this current factory settings. * * @param location the location string uniquely identifying the image * @param image the actual image * @return the final image added to the cache. This may be a scaled version * of the original input image. */ public Image addImage(String location, Image image) { if ( m_maxImageWidth > -1 || m_maxImageHeight > -1 ) { image = getScaledImage(image); image.getWidth(null); // trigger image load } imageCache.put(location, image); return image; }
/** * Set the data field for image locations. The value stored * in the data field should be a URL, a file within the current classpath, * a file on the filesystem, or null for no image. If the * <code>imageField</code> parameter is null, no images at all will be * drawn. * @param imageField the data field for image locations, or null for * no images */ public void setImageField(String imageField) { if ( imageField != null ) m_images = new ImageFactory(); m_imageName = imageField; }
/** * <p>Pre-loads images for use in a visualization. Images to load are * determined by taking objects from the given iterator and retrieving * the value of the specified field. The items in the iterator must * be instances of the {@link prefuse.data.Tuple} class.</p> * * <p>Images are loaded in the order specified by the iterator until the * the iterator is empty or the maximum image cache size is met. Thus * higher priority images should appear sooner in the iteration.</p> * * @param iter an Iterator of {@link prefuse.data.Tuple} instances * @param field the data field that contains the image location */ public void preloadImages(Iterator iter, String field) { boolean sync = m_asynch; m_asynch = false; String loc; while ( iter.hasNext() && imageCache.size() <= m_imageCacheSize ) { // get the string describing the image location Tuple t = (Tuple)iter.next(); loc = t.getString(field); if ( loc != null ) { getImage(loc); } } m_asynch = sync; }