ilog.views.maps.theme
Class IlvMapStyleController

java.lang.Object
  extended by ilog.views.maps.theme.IlvMapStyleController
All Implemented Interfaces:
TransformerListener, IlvPersistentObject, EventListener

public class IlvMapStyleController
extends Object
implements IlvPersistentObject, TransformerListener

IlvMapStyleController is used to manage the association of a set of IlvMapStyle and IlvMapLayer objects. Each style is used for a specific layer with a given scale range. This class also provides a TransformerListener that can affect the style in an IlvMapLayer corresponding to a given scale.

Since:
JViews 7.5

Constructor Summary
IlvMapStyleController()
          Creates an empty style controller.
IlvMapStyleController(IlvInputStream stream)
          Reads an IlvMapStyleController object from an IlvInputStream.
 
Method Summary
 void addDynamicStyleListener(DynamicStyleListener listener)
          Adds a theme listener.
 void addTheme(double scale, IlvMapLayer layer, String name)
          Adds an IlvMapStyle/IlvMapLayer association that is controlled by a scale.
 void addTheme(IlvMapLayer layer, IlvMapDynamicStyle theme)
          Adds an IlvMapStyle/IlvMapLayer association that is controlled by a scale.
static String formatScale(String prefix, double unsurscale)
          Formats the scale.
 IlvMapStyle getStyle(IlvMapLayer layer, double scale)
          Retrieves the style registered for the given layer that matches a given scale.
 IlvMapDynamicStyle getTheme(IlvMapLayer layer, double scale)
          Retrieves the IlvMapDynamicStyle object registered for a given layer that matches a specific scale.
 IlvMapDynamicStyle[] getThemes(IlvMapLayer layer)
          Returns the array of IlvMapDynamicStyle objects associated with a given layer.
 IlvManagerView getView()
          Retrieves the view associated with this IlvMapStyleController.
 void removeDynamicStyleListener(DynamicStyleListener listener)
          Removes a theme listener.
 void removeTheme(IlvMapLayer layer, IlvMapDynamicStyle style)
          Removes a given style from the controller.
 void setThemes(IlvMapLayer layer, IlvMapDynamicStyle[] themesArray)
          Sets the dynamic styles for a given layer.
 void setView(IlvManagerView view)
          Sets a view to this IlvMapStyleController object.
 String toString()
          Returns a string representation of this object.
 void transformerChanged(TransformerChangedEvent event)
          Implements TransformerListener.
 void updateCurrentTheme()
          This method is called by the transformer listener.
 void updateTheme(IlvManagerView v, IlvMapLayer l)
          Sets the layer style for the current scale of a view.
 void write(IlvOutputStream stream)
          Writes the attributes of a persistent object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IlvMapStyleController

public IlvMapStyleController()
Creates an empty style controller.


IlvMapStyleController

public IlvMapStyleController(IlvInputStream stream)
                      throws IlvReadFileException
Reads an IlvMapStyleController object from an IlvInputStream.

Parameters:
stream - The stream to read from.
Throws:
IlvReadFileException - if there is a problem reading from stream.
Method Detail

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object

formatScale

public static String formatScale(String prefix,
                                 double unsurscale)
Formats the scale.

Parameters:
prefix - This parameter is usually "1/".
unsurscale - The scale.
Returns:
The formatted scale that will be used for the display.

write

public void write(IlvOutputStream stream)
           throws IOException
Writes the attributes of a persistent object.

Specified by:
write in interface IlvPersistentObject
Parameters:
stream - the output stream
Throws:
IOException - thrown when an exception occurs during the write operation for this object.
See Also:
IlvPersistentObject.write(ilog.views.io.IlvOutputStream)

addTheme

public void addTheme(IlvMapLayer layer,
                     IlvMapDynamicStyle theme)
Adds an IlvMapStyle/IlvMapLayer association that is controlled by a scale.

Parameters:
layer - The layer on which the style will be applied with regard to the scale.
theme - A dynamic style attached to the layer.
Since:
JViews 7.5

setThemes

public void setThemes(IlvMapLayer layer,
                      IlvMapDynamicStyle[] themesArray)
Sets the dynamic styles for a given layer. This method first clears the previous themes.

Parameters:
layer - The layer on which the style will be applied with regard to the scale.
themesArray - A dynamic style array attached to the layer.
Since:
JViews 7.5

addTheme

public void addTheme(double scale,
                     IlvMapLayer layer,
                     String name)
Adds an IlvMapStyle/IlvMapLayer association that is controlled by a scale.

Parameters:
scale - The scale to add a theme to.
layer - The layer on which the style will be applied with regard to the scale.
name - The name of the style;

removeTheme

public void removeTheme(IlvMapLayer layer,
                        IlvMapDynamicStyle style)
Removes a given style from the controller.

Parameters:
layer - The IlvMapLayer object.
style - The style to be removed.

addDynamicStyleListener

public void addDynamicStyleListener(DynamicStyleListener listener)
Adds a theme listener.

Parameters:
listener - The theme listener to add.

removeDynamicStyleListener

public void removeDynamicStyleListener(DynamicStyleListener listener)
Removes a theme listener.

Parameters:
listener - The theme listener to remove.

getView

public IlvManagerView getView()
Retrieves the view associated with this IlvMapStyleController.

Returns:
The associated view, if there is one.

setView

public void setView(IlvManagerView view)
Sets a view to this IlvMapStyleController object. A TransformerListener is added to the view to activate the registered IlvMapDynamicStyle when the scale changes.

Parameters:
view - The view to associate.

getThemes

public IlvMapDynamicStyle[] getThemes(IlvMapLayer layer)
Returns the array of IlvMapDynamicStyle objects associated with a given layer.

Parameters:
layer - The layer which the styles are associated with.
Returns:
The array of styles associated with the layer.

getTheme

public IlvMapDynamicStyle getTheme(IlvMapLayer layer,
                                   double scale)
Retrieves the IlvMapDynamicStyle object registered for a given layer that matches a specific scale.

Parameters:
layer - The layer to retrieve the style for.
scale - The scale to retrieve the style for.
Returns:
The active style for scale.

getStyle

public IlvMapStyle getStyle(IlvMapLayer layer,
                            double scale)
Retrieves the style registered for the given layer that matches a given scale. If no style has been registered for this scale, the default style is returned.

Parameters:
layer - The layer to check for registered styles.
scale - The scale to match.
Returns:
The style registered for layer at scale.

transformerChanged

public void transformerChanged(TransformerChangedEvent event)
Implements TransformerListener.

Specified by:
transformerChanged in interface TransformerListener
Parameters:
event - The TransformerChangedEvent event.

updateCurrentTheme

public void updateCurrentTheme()
This method is called by the transformer listener. It changes the styles in the corresponding layers if needed.


updateTheme

public void updateTheme(IlvManagerView v,
                        IlvMapLayer l)
Sets the layer style for the current scale of a view.

Parameters:
v - The view to retrieve the scale from.
l - The layer whose style will be changed.


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