ilog.cpl.graph.background
Class IlpDefaultBackgroundSupport

java.lang.Object
  extended by ilog.cpl.graph.background.IlpDefaultBackgroundSupport
All Implemented Interfaces:
IlpBackgroundSupport

public class IlpDefaultBackgroundSupport
extends Object
implements IlpBackgroundSupport

Default implementation of the IlpBackgroundSupport.

Since:
JViews 7.5

Field Summary
protected  Map backgroundFactories
          Contains a mapping of extensions (xml, png) to instances of IlpBackgroundFactory.
protected  PropertyChangeListener backgroundPropertyListener
          Listener that handles the property changes in the IlpBackground instances.
protected  List backgrounds
          A List with IlpBackground instances.
protected  List backgroundURLs
          A List with URL instances.
protected  ilog.cpl.graph.background.internal.IlpBackgroundBatchingSupport batchingSupport
          Used to provide batching of background properties.
protected  List readOnlyBackgrounds
          A read-only version of the IlpBackground instances List.
protected  List readOnlyBackgroundURLs
          A read-only version of the URL instances List.
protected  IlpViewsView view
          The view currently attached to this background support.
 
Constructor Summary
IlpDefaultBackgroundSupport()
          Initializes the needed structures.
 
Method Summary
 void addBackground(URL backgroundURL)
          IlpBackgroundSupport implementation.
 void addBackground(URL backgroundURL, IlpBackground background)
          Adds the background specified in the URL using the the provided IlpBackground as the last background.
 void addBackground(URL backgroundURL, IlpBackground background, int index)
          IlpBackgroundSupport implementation.
 void addBackground(URL backgroundURL, int index)
          IlpBackgroundSupport implementation.
 void addBackgroundListener(IlpBackgroundListener listener)
          IlpBackgroundSupport implementation.
 void addBackgrounds(List backgroundURLs)
          IlpBackgroundSupport implementation.
 IlpBackground createBackground(URL backgroundURL)
          It uses the registered IlpBackgroundFactorys to create the IlpBackground instance.
 IlpBackgroundFactory getBackgroundFactory(String extension)
          Returns the background factory that is registered for the given extension.
 IlpBackground getBackgroundInstance(URL backgroundURL)
          IlpBackgroundSupport implementation.
 List getBackgroundInstances()
          Returns a read-only List of IlpBackground instances in the same order as they were indexed.
 List getBackgrounds()
          IlpBackgroundSupport implementation.
protected  int getLargestLayerIndex(List layers)
          Returns the largest layer index within the given List of IlvManagerLayers.
 IlvManager getManager()
          Returns the IlvManager of the attached view.
protected  int getManagerLayerIndex(IlpBackground background, int backgroundIndex)
          Returns the IlvManagerLayer index that should be used by provided IlpBackground as its insertion index.
 IlvManagerView getManagerView()
          Returns the IlvManagerView of the attached view.
protected  int getNextAvailableIndex()
          Returns the index that is after the index of the last IlvManagerLayer that is used to represent a background.
protected  int getSmallestLayerIndex(List layers)
          Returns the smallest layer index within the given List of IlvManagerLayers.
 IlpViewsView getView()
          IlpBackgroundSupport implementation.
protected  void handleBackgroundCreation(IlpBackground background, URL backgroundURL, int backgroundIndex, int backgroundManagerLayerIndex)
          Should handle the creation the internal structures of the IlpBackground.
protected  void handleBackgroundDisposal(IlpBackground background)
          Should handle the act of disposing the IlpBackground internal structures.
 boolean isVisible(URL backgroundURL)
          Returns if the background identified by the provided URL is visible or not.
 void moveBackground(URL backgroundURL, int index)
          IlpBackgroundSupport implementation.
protected  void registerBackgroundFactories()
          Registers all known background types.
 void registerBackgroundFactory(String extension, IlpBackgroundFactory factory)
          IlpBackgroundSupport implementation.
 void reloadBackground(URL backgroundURL)
          IlpBackgroundSupport implementation.
 void reloadBackgrounds()
          IlpBackgroundSupport implementation.
 void removeBackground(URL backgroundURL)
          IlpBackgroundSupport implementation.
 void removeBackgroundListener(IlpBackgroundListener listener)
          IlpBackgroundSupport implementation.
 void removeBackgrounds()
          IlpBackgroundSupport implementation.
 void setBackgrounds(List backgroundURLs)
          Replaces the current backgrounds with the ones provided in the List URL instances.
 void setView(IlpViewsView view)
          IlpBackgroundSupport implementation.
 void setVisible(URL backgroundURL, boolean visible)
          Sets if the background identified by the provided URL is visible or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

view

protected IlpViewsView view
The view currently attached to this background support.


batchingSupport

protected ilog.cpl.graph.background.internal.IlpBackgroundBatchingSupport batchingSupport
Used to provide batching of background properties.

Internal method or field: do not use!

backgroundFactories

protected Map backgroundFactories
Contains a mapping of extensions (xml, png) to instances of IlpBackgroundFactory.

Internal method or field: do not use!

backgroundURLs

protected List backgroundURLs
A List with URL instances. This List has the same index as the List of IlpBackgrounds.


readOnlyBackgroundURLs

protected List readOnlyBackgroundURLs
A read-only version of the URL instances List.

Internal method or field: do not use!

backgrounds

protected List backgrounds
A List with IlpBackground instances. This List has the same index as the List of URLs.

Internal method or field: do not use!

readOnlyBackgrounds

protected List readOnlyBackgrounds
A read-only version of the IlpBackground instances List.

Internal method or field: do not use!

backgroundPropertyListener

protected PropertyChangeListener backgroundPropertyListener
Listener that handles the property changes in the IlpBackground instances.

Internal method or field: do not use!
Constructor Detail

IlpDefaultBackgroundSupport

public IlpDefaultBackgroundSupport()
Initializes the needed structures.

Method Detail

addBackground

public void addBackground(URL backgroundURL,
                          int index)
                   throws IlpBackgroundHandlingException
IlpBackgroundSupport implementation.

Specified by:
addBackground in interface IlpBackgroundSupport
Parameters:
backgroundURL - the URL of the background to be added
index - the index where to add the background
Throws:
IlpBackgroundHandlingException - in case a problem occurs when adding background for the provided URL at the given index.
See Also:
IlpBackgroundSupport.addBackground(java.net.URL, int)

addBackground

public void addBackground(URL backgroundURL)
                   throws IlpBackgroundHandlingException
IlpBackgroundSupport implementation.

Specified by:
addBackground in interface IlpBackgroundSupport
Parameters:
backgroundURL - the URL of the background to be added
Throws:
IlpBackgroundHandlingException - in case a problem occurs when adding background for the provided URL.
See Also:
IlpBackgroundSupport.addBackground(java.net.URL)

addBackground

public void addBackground(URL backgroundURL,
                          IlpBackground background,
                          int index)
                   throws IlpBackgroundHandlingException
IlpBackgroundSupport implementation.

Specified by:
addBackground in interface IlpBackgroundSupport
Parameters:
backgroundURL - the URL of the background to be added
background - the IlpBackground instance to be used
index - the index where to add the background
Throws:
IlpBackgroundHandlingException - in case a problem occurs when adding background for the provided URL and IlpBackground.
See Also:
IlpBackgroundSupport.addBackground(java.net.URL, ilog.cpl.graph.background.IlpBackground, int)

addBackgrounds

public void addBackgrounds(List backgroundURLs)
                    throws IlpBackgroundHandlingException
IlpBackgroundSupport implementation.

Specified by:
addBackgrounds in interface IlpBackgroundSupport
Parameters:
backgroundURLs - a List of URL instances
Throws:
IlpBackgroundHandlingException - in case a problem occurs when adding all the backgrounds.
See Also:
IlpBackgroundSupport.addBackgrounds(java.util.List)

removeBackground

public void removeBackground(URL backgroundURL)
                      throws IlpBackgroundHandlingException
IlpBackgroundSupport implementation.

Specified by:
removeBackground in interface IlpBackgroundSupport
Parameters:
backgroundURL - the URL of the background of interest
Throws:
IlpBackgroundHandlingException - in case a problem occurs when removing the IlpBackground associated with the provide URL.
See Also:
IlpBackgroundSupport.removeBackground(java.net.URL)

reloadBackground

public void reloadBackground(URL backgroundURL)
                      throws IlpBackgroundHandlingException
IlpBackgroundSupport implementation.

Specified by:
reloadBackground in interface IlpBackgroundSupport
Parameters:
backgroundURL - the URL that points to a given background.
Throws:
IlpBackgroundHandlingException - in case a problem occurs when reloading the provided URL.
See Also:
IlpBackgroundSupport.reloadBackground(java.net.URL)

getBackgrounds

public List getBackgrounds()
IlpBackgroundSupport implementation.

Specified by:
getBackgrounds in interface IlpBackgroundSupport
Returns:
a read-only List of URL instances in the same order as they were indexed
See Also:
IlpBackgroundSupport.getBackgrounds()

removeBackgrounds

public void removeBackgrounds()
                       throws IlpBackgroundHandlingException
IlpBackgroundSupport implementation.

Specified by:
removeBackgrounds in interface IlpBackgroundSupport
Throws:
IlpBackgroundHandlingException - in case a problem occurs when removing all the backgrounds.
See Also:
IlpBackgroundSupport.removeBackgrounds()

getBackgroundFactory

public IlpBackgroundFactory getBackgroundFactory(String extension)
Returns the background factory that is registered for the given extension. Or null if none is registered for the provided extension.

Specified by:
getBackgroundFactory in interface IlpBackgroundSupport
Parameters:
extension - File extension, for instance, gif or svg.
Returns:
Background factory

registerBackgroundFactory

public void registerBackgroundFactory(String extension,
                                      IlpBackgroundFactory factory)
                               throws IlpBackgroundHandlingException
IlpBackgroundSupport implementation.

Specified by:
registerBackgroundFactory in interface IlpBackgroundSupport
Parameters:
extension - the extension that should specified in the form: "gif", "png"...
factory - the IlpBackgroundFactory to be used for the given extension or null
Throws:
IlpBackgroundHandlingException - in case a problem occurs when registering the IlpBackgroundFactory for the given extension.
See Also:
IlpBackgroundSupport.registerBackgroundFactory(java.lang.String, ilog.cpl.graph.background.IlpBackgroundFactory)

setView

public void setView(IlpViewsView view)
             throws IlpBackgroundHandlingException
IlpBackgroundSupport implementation.

Specified by:
setView in interface IlpBackgroundSupport
Parameters:
view - the IlpViewsView of interest.
Throws:
IlpBackgroundHandlingException - in case a problem occurs when setting IlpViewsView.
See Also:
IlpBackgroundSupport.setView(ilog.cpl.graphic.views.IlpViewsView)

getBackgroundInstance

public IlpBackground getBackgroundInstance(URL backgroundURL)
                                    throws IlpBackgroundHandlingException
IlpBackgroundSupport implementation.

It throws an IllegalArgumentException if the URL provided is not known.

Specified by:
getBackgroundInstance in interface IlpBackgroundSupport
Parameters:
backgroundURL - the URL of the background of interest
Returns:
the IlpBackground instance for the provided
Throws:
IlpBackgroundHandlingException - in case a problem occurs when obtaining the IlpBackground instance for the provide URL.

reloadBackgrounds

public void reloadBackgrounds()
                       throws IlpBackgroundHandlingException
IlpBackgroundSupport implementation.

Specified by:
reloadBackgrounds in interface IlpBackgroundSupport
Throws:
IlpBackgroundHandlingException - in case a problem occurs when reloading all the backgrounds.
See Also:
IlpBackgroundSupport.reloadBackgrounds()

moveBackground

public void moveBackground(URL backgroundURL,
                           int index)
                    throws IlpBackgroundHandlingException
IlpBackgroundSupport implementation.

Indices larger than the current background size will be adjusted to reflect the last position in backgrounds list.

This method does not remove nor re-add the background in question. Instead it re-arrange the IlvManagerLayers appropriately.

Specified by:
moveBackground in interface IlpBackgroundSupport
Parameters:
backgroundURL - the URL of the background of interest.
index - the index where the background should now be located.
Throws:
IlpBackgroundHandlingException - in case a problem occurs when moving the background.
See Also:
IlpBackgroundSupport.moveBackground(java.net.URL, int)

getView

public IlpViewsView getView()
IlpBackgroundSupport implementation.

Specified by:
getView in interface IlpBackgroundSupport
Returns:
view the IlpViewsView that this background support is associated with.
See Also:
IlpBackgroundSupport.getView()

addBackgroundListener

public void addBackgroundListener(IlpBackgroundListener listener)
IlpBackgroundSupport implementation.

Specified by:
addBackgroundListener in interface IlpBackgroundSupport
Parameters:
listener - IlpBackgroundListener to be notified of changes.
See Also:
IlpBackgroundSupport.addBackgroundListener(ilog.cpl.graph.background.event.IlpBackgroundListener)

removeBackgroundListener

public void removeBackgroundListener(IlpBackgroundListener listener)
IlpBackgroundSupport implementation.

Specified by:
removeBackgroundListener in interface IlpBackgroundSupport
Parameters:
listener - IlpBackgroundListener to be removed.
See Also:
IlpBackgroundSupport.removeBackgroundListener(ilog.cpl.graph.background.event.IlpBackgroundListener)

addBackground

public void addBackground(URL backgroundURL,
                          IlpBackground background)
                   throws IlpBackgroundHandlingException
Adds the background specified in the URL using the the provided IlpBackground as the last background.

Throws:
IlpBackgroundHandlingException
See Also:
IlpBackgroundSupport.addBackground(java.net.URL, ilog.cpl.graph.background.IlpBackground, int)

setBackgrounds

public void setBackgrounds(List backgroundURLs)
                    throws IlpBackgroundHandlingException
Replaces the current backgrounds with the ones provided in the List URL instances.

Parameters:
backgroundURLs - a List of URLs
Throws:
IlpBackgroundHandlingException

getBackgroundInstances

public List getBackgroundInstances()
Returns a read-only List of IlpBackground instances in the same order as they were indexed.

Returns:
a read-only List of IlpBackground instances in the same order as they were indexed.

createBackground

public IlpBackground createBackground(URL backgroundURL)
                               throws IlpBackgroundHandlingException
It uses the registered IlpBackgroundFactorys to create the IlpBackground instance.

Note that the created IlpBackground is not attached to this IlpBackgroundSupport.

Parameters:
backgroundURL - the URL of interest.
Returns:
an instance of IlpBackground that represents the provided URL.
Throws:
IlpBackgroundHandlingException - if a problem occurs.

isVisible

public boolean isVisible(URL backgroundURL)
                  throws IlpBackgroundHandlingException
Returns if the background identified by the provided URL is visible or not.

Parameters:
backgroundURL - the URL of interest
Returns:
true if visible and false otherwise
Throws:
IlpBackgroundHandlingException

setVisible

public void setVisible(URL backgroundURL,
                       boolean visible)
                throws IlpBackgroundHandlingException
Sets if the background identified by the provided URL is visible or not.

Parameters:
backgroundURL - the URL of interest
visible - true if visible and false otherwise
Throws:
IlpBackgroundHandlingException

getManagerLayerIndex

protected int getManagerLayerIndex(IlpBackground background,
                                   int backgroundIndex)
                            throws IlpBackgroundHandlingException
Returns the IlvManagerLayer index that should be used by provided IlpBackground as its insertion index.

The provided index is the index of the background within this background support.

Throws:
IlpBackgroundHandlingException
Internal method or field: do not use!

getNextAvailableIndex

protected int getNextAvailableIndex()
Returns the index that is after the index of the last IlvManagerLayer that is used to represent a background.

Internal method or field: do not use!

getLargestLayerIndex

protected int getLargestLayerIndex(List layers)
Returns the largest layer index within the given List of IlvManagerLayers.

Internal method or field: do not use!

getSmallestLayerIndex

protected int getSmallestLayerIndex(List layers)
Returns the smallest layer index within the given List of IlvManagerLayers.

Internal method or field: do not use!

getManager

public IlvManager getManager()
Returns the IlvManager of the attached view.


getManagerView

public IlvManagerView getManagerView()
Returns the IlvManagerView of the attached view.


registerBackgroundFactories

protected void registerBackgroundFactories()
                                    throws IlpBackgroundHandlingException
Registers all known background types.

Throws:
IlpBackgroundHandlingException
Internal method or field: do not use!

handleBackgroundDisposal

protected void handleBackgroundDisposal(IlpBackground background)
                                 throws IlpBackgroundHandlingException
Should handle the act of disposing the IlpBackground internal structures.

Handles:

  1. Disposing the background
  2. Clean up of all internal references

Parameters:
background - the IlpBackground to be handled.
Throws:
IlpBackgroundHandlingException
Since:
JViews 7.5
Internal method or field: do not use!

handleBackgroundCreation

protected void handleBackgroundCreation(IlpBackground background,
                                        URL backgroundURL,
                                        int backgroundIndex,
                                        int backgroundManagerLayerIndex)
                                 throws IlpBackgroundHandlingException
Should handle the creation the internal structures of the IlpBackground.

Handles:

  1. Creation of background
  2. Creating all internal references

Parameters:
background - the IlpBackground to be handled.
backgroundURL - the URL to be handled.
backgroundIndex - the index of this background within its peers.
backgroundManagerLayerIndex - the IlvManagerLayer index where to insert the given background.
Throws:
IlpBackgroundHandlingException
Internal method or field: do not use!


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.   . All Rights Reserved.