net.jalbum.filterManager
Class FilterManager

java.lang.Object
  extended by net.jalbum.filterManager.FilterRenderer
      extended by net.jalbum.filterManager.FilterManager
All Implemented Interfaces:
FilterManagerInterface

public class FilterManager
extends FilterRenderer
implements FilterManagerInterface

The FilterManager handles several JAlbumImageFilter being applied to a specific image. Internally a FilterList is used to store the filters. When applying the filters to the image, it first goes through the FilterList and selects all filters which are supposed to be applied before rescaling the image to its final size. This includes all prescaleOnly- Filters but also all filters which are prescaleAndPostscale-filters. The filters are applied in the order they were added to the FilterList. Then it asked the FilterManagerFriend to rescale the image according to the specifications set by the user in the settings section. All the remaining postscale-filters are then applied to the rescaled image in the order they were added to the FilterList. The FilterManager also caches the image along the way at 4 different production stages: the original image which is handed to him, the image with all prescale filters applied to it, the scaled image without any postscaleOnly filters applied and the final image with all filters applied to it.

When a new filter is added, it is not added to the FilterList immediately. First a user interface of the filter will be rendered for the user to decide whether or not to actually add and also to change some settings for the filter. Usually the user interface of the filter already provides a rought preview of how the image will look like in the end. This preview includes all filters which will be added before the new filter and the new filter itself. If the filter is a postscaleOnly-filter the preview image will be pretty much like the resulting image. But the filter can also draw additional elements on the user interface, which will not be visible in the final image. If the filter is a prescale filter and there are other filters already applied which are only postscale filters, the preview on the user interface of the filter will not be correct, as image the filter uses does not have the postscale filters applied to it. Therefore the final image might be quite different. A real preview of how the image will look like when all the filters are applied at there according stage, can be seen when the user presses the "Preview"-Button. On this preview there are also no elements which only the user interface of the filter will show.

When undo is pressed by the user, the position variable in the FilterList is counted one down. That means that the undone filter is still there, but it is not applied anymore. When the user then presses redo, the position variable is counted up one, so that the previously undone filter is now part of the applied filters again.

The FilterManager also gives out information about the filter. Those information include: name of the filter, name of the author, version, description of the filter and optional a short help text and a section "other" where the filter author can give out any other information, which might be important/interesting to know. All of the texts can be displayed as html.

See Also:
JAlbumImageFilter, FilterList, FilterManagerFriend

Constructor Summary
FilterManager(FilterManagerFriend friend)
           
 
Method Summary
 void addFilter(JAlbumImageFilter filter)
           
protected  void applyFilter()
           
 void cancel()
           
 java.awt.Cursor getCursor()
           
 javax.swing.JPanel getFilterControls()
           
 javax.swing.JPanel getFilterManagerControls()
           
 JAlbumImageFilter getNewFilter()
           
 boolean isRedoPossible()
           
 boolean isUndoPossible()
           
 java.awt.image.BufferedImage redo()
           
 java.awt.image.BufferedImage renderImage(java.awt.image.BufferedImage bi)
           
 java.awt.image.BufferedImage renderImage(java.awt.image.BufferedImage bi, boolean scaleImage)
           
protected  java.awt.image.BufferedImage renderPreview()
           
protected  java.awt.image.BufferedImage scaleImage(java.awt.image.BufferedImage bi)
           
 void setCursor(java.awt.Cursor cursor)
           
 void setGUIImage(java.awt.image.BufferedImage bi)
           
 java.awt.image.BufferedImage setImage(java.awt.image.BufferedImage bi, FilterList filterList)
           
 java.awt.image.BufferedImage undo()
           
 
Methods inherited from class net.jalbum.filterManager.FilterRenderer
applyPostscaleFilters, applyPrescaleFilters, cloneBufferedImage, filterListHasPostscaleFilters, filterListHasPrescaleFilters, getFilterList, getPostscaleFilteredSize, getPrescaleFilteredSize, hasFiltersInList, setFilterList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.jalbum.filterManager.FilterManagerInterface
cloneBufferedImage
 

Constructor Detail

FilterManager

public FilterManager(FilterManagerFriend friend)
Method Detail

setImage

public java.awt.image.BufferedImage setImage(java.awt.image.BufferedImage bi,
                                             FilterList filterList)

addFilter

public void addFilter(JAlbumImageFilter filter)

setGUIImage

public void setGUIImage(java.awt.image.BufferedImage bi)
Specified by:
setGUIImage in interface FilterManagerInterface

renderImage

public java.awt.image.BufferedImage renderImage(java.awt.image.BufferedImage bi)
Overrides:
renderImage in class FilterRenderer

renderImage

public java.awt.image.BufferedImage renderImage(java.awt.image.BufferedImage bi,
                                                boolean scaleImage)

scaleImage

protected java.awt.image.BufferedImage scaleImage(java.awt.image.BufferedImage bi)

isUndoPossible

public boolean isUndoPossible()

undo

public java.awt.image.BufferedImage undo()

isRedoPossible

public boolean isRedoPossible()

redo

public java.awt.image.BufferedImage redo()

renderPreview

protected java.awt.image.BufferedImage renderPreview()

getFilterControls

public javax.swing.JPanel getFilterControls()

getFilterManagerControls

public javax.swing.JPanel getFilterManagerControls()

setCursor

public void setCursor(java.awt.Cursor cursor)
Specified by:
setCursor in interface FilterManagerInterface

getCursor

public java.awt.Cursor getCursor()
Specified by:
getCursor in interface FilterManagerInterface

applyFilter

protected void applyFilter()

cancel

public void cancel()

getNewFilter

public JAlbumImageFilter getNewFilter()