Class FLyrDefault

java.lang.Object
org.gvsig.tools.dispose.impl.AbstractDisposable
org.gvsig.fmap.mapcontext.layers.FLyrDefault
All Implemented Interfaces:
ExtendedPropertiesSupport, FLayer, FLayerHidesArea, LayerListener, Projected, org.gvsig.metadata.Metadata, org.gvsig.tools.dispose.Disposable, org.gvsig.tools.dynobject.DynObject, org.gvsig.tools.persistence.Persistent
Direct Known Subclasses:
FLayers, FLyrVect

public abstract class FLyrDefault extends org.gvsig.tools.dispose.impl.AbstractDisposable implements FLayer, FLayerHidesArea, LayerListener

Implementation of the common characteristics of all layers: visibility, activation, name, ...

Represents the definition of a basic layer, implementing FLayer, and new functionality:

  • Supports transparency.
  • Notification of evens produced using this layer.
  • Can have internal virtual layers.
  • Can have a text layer.
  • Supports an strategy for visit its geometries.
  • Can have an image in the TOC (table of contents) associated to the state of this layer.

Each graphical layer will inherit from this class and adapt to its particular logic and model according its nature.

See Also:
  • Field Details

  • Constructor Details

    • FLyrDefault

      public FLyrDefault(org.gvsig.metadata.MetadataContainer metadataContainer)
    • FLyrDefault

      public FLyrDefault()
  • Method Details

    • getProperty

      public Object getProperty(Object key)
      Description copied from interface: ExtendedPropertiesSupport

      Returns a reference to an object (property) associated to this layer.

      For example, you can attach a network definition to key "network" and check if a layer has a network loaded using getAssociatedObject("network") and that it's not null.

      Specified by:
      getProperty in interface ExtendedPropertiesSupport
      Parameters:
      key - the key associated to the property
      Returns:
      null if key is not found
      See Also:
    • setProperty

      public void setProperty(Object key, Object val)
      Description copied from interface: ExtendedPropertiesSupport
      Inserts an object as a property to this layer.
      Specified by:
      setProperty in interface ExtendedPropertiesSupport
      Parameters:
      key - the key associated to the property
      val - the property
      See Also:
    • getExtendedProperties

      public Map getExtendedProperties()
      Description copied from interface: ExtendedPropertiesSupport
      Returns a hash map with all new properties associated to this layer.
      Specified by:
      getExtendedProperties in interface ExtendedPropertiesSupport
      Returns:
      hash table with the added properties
      See Also:
    • setActive

      public void setActive(boolean selected)
      Description copied from interface: FLayer

      Changes the status of this layer to active or inactive.

      One layer is active if is selected in TOC.

      Specified by:
      setActive in interface FLayer
      Parameters:
      selected - the boolean to be set
      See Also:
    • isActive

      public boolean isActive()
      Description copied from interface: FLayer

      Returns if this layer is active or not in TOC.

      One layer is active if is selected in TOC.

      Specified by:
      isActive in interface FLayer
      Returns:
      true if this layer is active; false otherwise
      See Also:
    • setName

      public void setName(String name)
      Description copied from interface: FLayer
      Sets a name to this layer.
      Specified by:
      setName in interface FLayer
      Parameters:
      name - the string that is to be this layer's name
      See Also:
    • getName

      public String getName()
      Description copied from interface: FLayer
      Returns the name of this layer.
      Specified by:
      getName in interface FLayer
      Returns:
      an string with this layer's name
      See Also:
    • load

      public void load() throws LoadLayerException
      Description copied from interface: FLayer

      Executes the initialization operations of this layer. This method is invoked only one time during the life of this layer and just before visualize it.

      Specified by:
      load in interface FLayer
      Throws:
      LoadLayerException - if fails loading the layer.
      See Also:
    • setVisible

      public void setVisible(boolean visibility)
      Description copied from interface: FLayer

      Changes the status of this layer to visible or not.

      One layer is visible if it's check box associated is selected. This means that layer will tried to be painted. If the data associated isn't available, then this property will change to false.

      Specified by:
      setVisible in interface FLayer
      Parameters:
      visibility - the boolean to be set
      See Also:
    • isVisible

      public boolean isVisible()
      Description copied from interface: FLayer

      Returns if this layer is visible and available.

      One layer is visible if it's check box associated is selected. This means that layer will tried to be painted.

      One layer is available if the source of data is on-line.

      It's probably that one layer selected hadn't available it's data, for example in a remote service.

      Specified by:
      isVisible in interface FLayer
      Returns:
      true if this layer is visible and available; false otherwise
      See Also:
    • getParentLayer

      public FLayers getParentLayer()
      Description copied from interface: FLayer
      Returns the parent FLayers node of this layer.
      Specified by:
      getParentLayer in interface FLayer
      Returns:
      the parent of this layer, or null if hasn't parent
      See Also:
    • setParentLayer

      public void setParentLayer(FLayers root)
      Description copied from interface: FLayer
      Inserts the parent FLayers node of the layer.
      Specified by:
      setParentLayer in interface FLayer
      Parameters:
      root - a FLayers object
      See Also:
    • setProjection

      public void setProjection(org.gvsig.crs.projection.lib.Projection proj)
      Inserts the projection to this layer.
      Specified by:
      setProjection in interface FLayer
      Parameters:
      proj - information about the new projection
      See Also:
    • getProjection

      public org.gvsig.crs.projection.lib.Projection getProjection()
      Description copied from interface: Projected

      Returns the current projection.

      Specified by:
      getProjection in interface Projected
      Returns:
      current projection
      See Also:
    • reProject

      public void reProject(org.gvsig.crs.projection.lib.CoordinateTransformation arg0)

      Changes the projection of this layer.

      This method will be overloaded in each kind of layer, according its specific nature.

      Specified by:
      reProject in interface Projected
      Parameters:
      arg0 -
      See Also:
    • getTransparency

      public int getTransparency()
      Returns the transparency level of this layer, in the range 0-255 .
      Returns:
      the transparency level
      See Also:
    • setTransparency

      public void setTransparency(int trans)
      Inserts the transparency level for this layer, the range allowed is 0-255 .
      Parameters:
      trans - the transparency level
      See Also:
    • getMapContext

      public MapContext getMapContext()
      Description copied from interface: FLayer

      Returns a reference to the model of this layer, or null if this layer has no model.

      Specified by:
      getMapContext in interface FLayer
      Returns:
      the model of this layer
    • addLayerListener

      public boolean addLayerListener(LayerListener o)
      Description copied from interface: FLayer
      Adds a LayerListener to the listener list.
      Specified by:
      addLayerListener in interface FLayer
      Parameters:
      o - a layer listener
      Returns:
      true if hasn't been any problem during the insertion of the listener
      See Also:
    • getLayerListeners

      public LayerListener[] getLayerListeners()
      Description copied from interface: FLayer
      Returns all LayerListeners of this layer as an array.
      Specified by:
      getLayerListeners in interface FLayer
      Returns:
      an array with all layer listeners associated to this layer
      See Also:
    • removeLayerListener

      public boolean removeLayerListener(LayerListener o)
      Description copied from interface: FLayer
      Removes the LayerListener argument from this layer.
      Specified by:
      removeLayerListener in interface FLayer
      Parameters:
      o - a layer listener
      Returns:
      true if hasn't been any problem doing this process
      See Also:
    • setCoordTrans

      public void setCoordTrans(org.gvsig.crs.projection.lib.CoordinateTransformation ct)
      Sets transformation coordinates for this layer.
      Specified by:
      setCoordTrans in interface FLayer
      Parameters:
      ct - an object that implements the CoordinateTransformation interface, and with the transformation coordinates
      See Also:
    • getCoordTrans

      public org.gvsig.crs.projection.lib.CoordinateTransformation getCoordTrans()
      Returns the transformation coordinates of this layer.
      Specified by:
      getCoordTrans in interface FLayer
      Returns:
      an object that implements the CoordinateTransformation interface, and with the transformation coordinates
      See Also:
    • wakeUp

      public void wakeUp() throws LoadLayerException

      Method called by FLayers to notify this layer that is going to be added.This previous notification is useful for the layers that need do something before being added. For example, the raster needs reopen a file that could have been closed recently.

      Throws:
      LoadLayerException
    • getMinScale

      public double getMinScale()
      Description copied from interface: FLayer
      Returns the minimum scale visible. Lower scales won't be drawn.
      Specified by:
      getMinScale in interface FLayer
      Returns:
      the minimum scale > 0, -1 if not defined
      See Also:
    • getMaxScale

      public double getMaxScale()
      Description copied from interface: FLayer
      Returns the maximum scale visible. Higher scales won't be drawn.
      Specified by:
      getMaxScale in interface FLayer
      Returns:
      the maximum scale > 0, -1 if not defined
      See Also:
    • setMinScale

      public void setMinScale(double minScale)
      Description copied from interface: FLayer
      Sets the minimum scale visible. Lower scales won't be drawn.
      Specified by:
      setMinScale in interface FLayer
      Parameters:
      minScale - the scale > 0, -1 if not defined
      See Also:
    • setMaxScale

      public void setMaxScale(double maxScale)
      Description copied from interface: FLayer
      Sets the maximum scale visible. Higher scales won't be drawn.
      Specified by:
      setMaxScale in interface FLayer
      Parameters:
      maxScale - the scale > 0, -1 if not defined
      See Also:
    • isWithinScale

      public boolean isWithinScale(double scale)
      Description copied from interface: FLayer

      Returns if the value of scale argument is within the maximum and minimum scale of this layer.

      Specified by:
      isWithinScale in interface FLayer
      Parameters:
      scale - the scale > 0
      Returns:
      true if the scale argument is within the range of scales of this layer; false otherwise
      See Also:
    • setEditing

      public void setEditing(boolean b) throws StartEditionLayerException
      Description copied from interface: FLayer
      Do nothing.
      Specified by:
      setEditing in interface FLayer
      Parameters:
      b -
      Throws:
      StartEditionLayerException
    • callEditionChanged

      protected void callEditionChanged(LayerEvent e)
      Called by some version of the method setEditing(boolean) overwritten. Notifies all listeners associated to this layer, that its edition state has changed.
      Parameters:
      e - a layer event with the name of the property that has changed
      See Also:
    • isEditing

      public boolean isEditing()
      Description copied from interface: FLayer

      Returns if this layer is editable.

      One layer is editable if user can modify its information with graphical tools.

      Specified by:
      isEditing in interface FLayer
      Returns:
      true if this layer is editable; false otherwise
      See Also:
    • getTocImageIcon

      public String getTocImageIcon()
      Description copied from interface: FLayer
      Returns the image icon that will be shown in the TOC next to this layer.
      Specified by:
      getTocImageIcon in interface FLayer
      Returns:
      a String reference to the image icon, or null if there isn't any
    • isInTOC

      public boolean isInTOC()
      Description copied from interface: FLayer

      Returns if this layer appears in the TOC.

      If doesn't appears, remains in the view and in the project.

      Specified by:
      isInTOC in interface FLayer
      Returns:
      true if this layer appears in the TOC; false otherwise
    • setInTOC

      public void setInTOC(boolean b)
      Description copied from interface: FLayer

      Sets that this layer appears or not in the TOC.

      Specified by:
      setInTOC in interface FLayer
      Parameters:
      b - true if appears in the TOC; false otherwise
    • isAvailable

      public boolean isAvailable()
      Description copied from interface: FLayer

      Returns the status of availability of this layer.

      One layer is available if the source of data is on-line.

      Specified by:
      isAvailable in interface FLayer
      Returns:
      true if the source of data is on-line; false otherwise
      See Also:
    • setAvailable

      public void setAvailable(boolean available)
      Description copied from interface: FLayer

      Changes the status of availability of this layer.

      One layer is available if the source of data is on-line.

      Specified by:
      setAvailable in interface FLayer
      Parameters:
      available - the boolean to be set
      See Also:
    • reload

      public void reload() throws ReloadLayerException
      Description copied from interface: FLayer

      Tries recover a layer of a possible error.

      If it has any problem during the load, marks the availability to false and throws an exception.

      Specified by:
      reload in interface FLayer
      Throws:
      ReloadLayerException - if it's thrown a ReadException or an IOException during the load of this layer.
      See Also:
    • getFLayerStatus

      public FLayerStatus getFLayerStatus()
      Description copied from interface: FLayer
      Returns the status of this layer.
      Specified by:
      getFLayerStatus in interface FLayer
      Returns:
      the status stored in a FLayerStatus object
      See Also:
    • setFLayerStatus

      public void setFLayerStatus(FLayerStatus status)
      Description copied from interface: FLayer
      Sets the status of this layer.
      Specified by:
      setFLayerStatus in interface FLayer
      Parameters:
      status - information of the status for this layer
      See Also:
    • isOk

      public boolean isOk()
      Description copied from interface: FLayer

      Returns if this layer hasn't got errors.

      Specified by:
      isOk in interface FLayer
      Returns:
      true if this layer hasn't got errors; false otherwise
    • getNumErrors

      public int getNumErrors()
      Description copied from interface: FLayer
      Returns the number of errors which causes this layer to be in unavailable status.
      Specified by:
      getNumErrors in interface FLayer
      Returns:
      number of errors >= 0
      See Also:
    • getError

      public Throwable getError(int i)
      Description copied from interface: FLayer
      Returns the specified error.
      Specified by:
      getError in interface FLayer
      Parameters:
      i - index of the error >= 0 invalid input: '&'invalid input: '&' invalid input: '<' getNumErrors
      Returns:
      a singular error
      See Also:
    • getErrors

      public List<Throwable> getErrors()
      Description copied from interface: FLayer
      Returns a list with all layer errors.
      Specified by:
      getErrors in interface FLayer
      Returns:
      an ArrayList with the errors
      See Also:
    • addError

      public void addError(Throwable exception)
      Description copied from interface: FLayer
      Adds an error reason that describes this layer's wrong status.
      Specified by:
      addError in interface FLayer
      Parameters:
      exception - a BaseException with the information of the error
      See Also:
    • setError

      public void setError(Throwable ex)
      Specified by:
      setError in interface FLayer
    • visibleRequired

      public boolean visibleRequired()
      Description copied from interface: FLayer
      Returns true if this layer has the visible status enabled.
      Specified by:
      visibleRequired in interface FLayer
      Returns:
      true if visible this layer has the visible status enabled, otherwise false
      See Also:
    • getInfoString

      public String getInfoString()
      Description copied from interface: FLayer
      Returns an string with the information of this layer.
      Specified by:
      getInfoString in interface FLayer
      Returns:
      the string that is to be this component's information
    • isWritable

      public boolean isWritable()
      Description copied from interface: FLayer

      Returns the writing status of this layer.

      One layer is writable if there is a writing driver for this layer.

      Specified by:
      isWritable in interface FLayer
      Returns:
      true if there is a writing driver for this layer; false otherwise
    • cloneLayer

      public FLayer cloneLayer() throws Exception
      Description copied from interface: FLayer

      This method can be used to have a fast cloned layer.

      The implementations should take care of not recreate this layer. Instead of this, is better to use the same source (driver) and deepclone the legend. Exception: the labels aren't deepcloned to avoid memory consumption.

      Note: Labels are memory consuming to speed up layers like PostGIS and so on.

      Specified by:
      cloneLayer in interface FLayer
      Returns:
      a layer that is a clonation of this layer
      Throws:
      Exception - any exception produced during the cloning of this layer.
    • getTocStatusImage

      public Image getTocStatusImage()
      Description copied from interface: FLayer
      Returns the image icon that will be shown in the TOC next to this layer, according its status.
      Specified by:
      getTocStatusImage in interface FLayer
      Returns:
      the image
    • setTocStatusImage

      public void setTocStatusImage(Image tocStatusImage)
      Inserts the image icon that will be shown in the TOC next to this layer, according its status.
      Parameters:
      tocStatusImage - the image
      See Also:
    • newComposedLayer

      public ComposedLayer newComposedLayer()
      Description copied from interface: FLayer

      Returns a new instance of ComposedLayer.

      This allows make a single draw for a group of layers with the same source.

      If this operation isn't applicable for this kind of layer, this method returns null.

      By default this operation is not supported.

      Specified by:
      newComposedLayer in interface FLayer
      Returns:
      a new composed layer or null if not supported
      See Also:
    • allowLinks

      public boolean allowLinks()
      Description copied from interface: FLayer
      Alwais return false
      Specified by:
      allowLinks in interface FLayer
      Returns:
      false
    • getLinkProperties

      public AbstractLinkProperties getLinkProperties()
      Description copied from interface: FLayer
      Alwais return null.
      Specified by:
      getLinkProperties in interface FLayer
      Returns:
      null
    • getLink

      public URI[] getLink(Point2D point, double tolerance) throws org.gvsig.fmap.dal.exception.ReadException
      Description copied from interface: FLayer
      alwais return null
      Specified by:
      getLink in interface FLayer
      Parameters:
      point -
      tolerance -
      Returns:
      null
      Throws:
      org.gvsig.fmap.dal.exception.ReadException
    • addLegendListener

      public void addLegendListener(LegendListener listener)
    • callLegendChanged

      protected void callLegendChanged(LegendChangedEvent e)
      Parameters:
      e -
      See Also:
    • removeLegendListener

      public void removeLegendListener(LegendListener listener)
      Parameters:
      listener -
      See Also:
    • getClassName

      public String getClassName()
    • delegate

      public void delegate(org.gvsig.tools.dynobject.DynObject dynObject)
      Specified by:
      delegate in interface org.gvsig.tools.dynobject.DynObject
    • getDynClass

      public org.gvsig.tools.dynobject.DynClass getDynClass()
      Specified by:
      getDynClass in interface org.gvsig.tools.dynobject.DynObject
    • getDynValue

      public Object getDynValue(String name) throws org.gvsig.tools.dynobject.exception.DynFieldNotFoundException
      Specified by:
      getDynValue in interface org.gvsig.tools.dynobject.DynObject
      Throws:
      org.gvsig.tools.dynobject.exception.DynFieldNotFoundException
    • hasDynValue

      public boolean hasDynValue(String name)
      Specified by:
      hasDynValue in interface org.gvsig.tools.dynobject.DynObject
    • implement

      public void implement(org.gvsig.tools.dynobject.DynClass dynClass)
      Specified by:
      implement in interface org.gvsig.tools.dynobject.DynObject
    • invokeDynMethod

      public Object invokeDynMethod(int code, Object[] args) throws org.gvsig.tools.dynobject.exception.DynMethodException
      Specified by:
      invokeDynMethod in interface org.gvsig.tools.dynobject.DynObject
      Throws:
      org.gvsig.tools.dynobject.exception.DynMethodException
    • invokeDynMethod

      public Object invokeDynMethod(String name, Object[] args) throws org.gvsig.tools.dynobject.exception.DynMethodException
      Specified by:
      invokeDynMethod in interface org.gvsig.tools.dynobject.DynObject
      Throws:
      org.gvsig.tools.dynobject.exception.DynMethodException
    • setDynValue

      public void setDynValue(String name, Object value) throws org.gvsig.tools.dynobject.exception.DynFieldNotFoundException
      Specified by:
      setDynValue in interface org.gvsig.tools.dynobject.DynObject
      Throws:
      org.gvsig.tools.dynobject.exception.DynFieldNotFoundException
    • getDrawVersion

      public long getDrawVersion()
      Specified by:
      getDrawVersion in interface FLayer
    • updateDrawVersion

      protected void updateDrawVersion()
    • updateDrawVersion

      protected void updateDrawVersion(boolean fireEvents)
    • hasChangedForDrawing

      public boolean hasChangedForDrawing(long value)
    • activationChanged

      public void activationChanged(LayerEvent e)
      Description copied from interface: LayerListener

      Called when the activation of a layer has changed.

      Specified by:
      activationChanged in interface LayerListener
      Parameters:
      e - an activation changed layer event object
    • drawValueChanged

      public void drawValueChanged(LayerEvent e)
      Description copied from interface: LayerListener

      Called when a draw value of a layer has changed.

      Specified by:
      drawValueChanged in interface LayerListener
      Parameters:
      e - an edition changed layer event object
    • editionChanged

      public void editionChanged(LayerEvent e)
      Description copied from interface: LayerListener

      Called when the edition of a layer has changed.

      Specified by:
      editionChanged in interface LayerListener
      Parameters:
      e - an edition changed layer event object
    • nameChanged

      public void nameChanged(LayerEvent e)
      Description copied from interface: LayerListener

      Called when the name of a layer has changed.

      Specified by:
      nameChanged in interface LayerListener
      Parameters:
      e - a name changed layer event object
    • visibilityChanged

      public void visibilityChanged(LayerEvent e)
      Description copied from interface: LayerListener

      Called when the visibility of a layer has changed.

      Specified by:
      visibilityChanged in interface LayerListener
      Parameters:
      e - a visibility changed layer event object
    • saveToState

      public void saveToState(org.gvsig.tools.persistence.PersistentState state) throws org.gvsig.tools.persistence.exception.PersistenceException
      Specified by:
      saveToState in interface org.gvsig.tools.persistence.Persistent
      Throws:
      org.gvsig.tools.persistence.exception.PersistenceException
    • loadFromState

      public void loadFromState(org.gvsig.tools.persistence.PersistentState state) throws org.gvsig.tools.persistence.exception.PersistenceException
      Specified by:
      loadFromState in interface org.gvsig.tools.persistence.Persistent
      Throws:
      org.gvsig.tools.persistence.exception.PersistenceException
    • clear

      public void clear()
      Specified by:
      clear in interface org.gvsig.tools.dynobject.DynObject
    • getMetadataName

      public String getMetadataName() throws org.gvsig.metadata.exceptions.MetadataException
      Specified by:
      getMetadataName in interface org.gvsig.metadata.Metadata
      Throws:
      org.gvsig.metadata.exceptions.MetadataException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hidesThisArea

      public boolean hidesThisArea(org.gvsig.fmap.geom.primitive.Envelope area)
      Specified by:
      hidesThisArea in interface FLayerHidesArea
    • isTemporary

      public boolean isTemporary()
      Specified by:
      isTemporary in interface FLayer
    • setTemporary

      public void setTemporary(boolean temporary)
      Specified by:
      setTemporary in interface FLayer
    • getDefaultTolerance

      public int getDefaultTolerance()
      Description copied from interface: FLayer
      Returns layer tolerance in pixels
      Specified by:
      getDefaultTolerance in interface FLayer
      Returns:
      layer tolerance
    • invalidate

      public void invalidate()
      Specified by:
      invalidate in interface FLayer