Class TLcdWMSProxyGXYPainter

java.lang.Object
com.luciad.view.gxy.ALcdGXYPainter
com.luciad.wms.client.gxy.TLcdWMSProxyGXYPainter
All Implemented Interfaces:
ILcdCloneable, ILcdPropertyChangeSource, ILcdGXYPainter, ILcdGXYPainterProvider, Serializable, Cloneable

public class TLcdWMSProxyGXYPainter extends ALcdGXYPainter
A painter for ALcdWMSProxy objects.

When painting, the ALcdWMSProxy object is used to connect and retrieve the necessary raster data from the WMS. This raster data is decoded through ImageIO to obtain an image. The resulting image is then put in an ILcdRaster, and rendered through a ALcdRasterPainter to support reprojection. The ALcdRasterPainter to which is delegated can be configured through setDelegateRasterPainter(com.luciad.format.raster.ALcdRasterPainter) and getDelegateRasterPainter().

This painter reprojects the data from the WMS if necessary. The painter automatically determines a reference that is supported by all layers in the GetMap request and that is similar to the world reference of the view. The resulting image is then be warped to match the current world reference.

If a map is requested which contains WMS layers without a common reference, the painter uses multiple requests with different references and then paints the result as one image. It should be noted that using layers with incompatible references will generally be slower because multiple maps have to be retrieved.

A WMS can optionally define a limit on the map width and height in pixels. This painter automatically detects whether the size of the view exceeds those limits. If positive, a map will be requested that matches the maximum width and / or height while still maintaining the original aspect ratio, and image scaling will be applied to match the resulting map with the view.

This painter supports requesting images from the WMS with an extended view port (setBorderFactor(double)). When the map is panned only slightly the painter checks if the previous requested image can be reused. This results in less requests to the WMS.

See Also:
  • Constructor Details

    • TLcdWMSProxyGXYPainter

      public TLcdWMSProxyGXYPainter()
      Creates a new TLcdWMSProxyGXYPainter. By default, the painter uses the current view reference in WMS requests, if this reference is supported by the WMS server. If this is not the case, a fallback reference supported by the WMS server is automatically chosen.
  • Method Details

    • getBorderFactor

      public double getBorderFactor()
      Returns the surplus border factor value used by the WMS proxy painter.
      Returns:
      the surplus border factor value used by the WMS proxy painter.
      Since:
      2018.0
    • setBorderFactor

      public void setBorderFactor(double aBorderFactor)
      Sets the surplus border factor value used to request images from the Web Map Server (WMS).

      The image dimension based on the view size is extended with this surplus border factor in each direction. Using a value of 0.1 for example results in extending the image size with 10% in every direction. The total requested image size is then 44% larger than when no surplus border is being used.

      This allows to reduce the number of WMS requests for small pan operations on the view and can avoid some empty space on the map while waiting for the WMS response.

      Note that the size of the surplus border may be reduced if the requested image size would extend the maximum allowed image size advertised by the WMS.

      The default value of the border factor is 0.0.

      Parameters:
      aBorderFactor - the new surplus border factor value.
      Since:
      2018.0
    • setPreferredMapRequestReference

      public void setPreferredMapRequestReference(ILcdXYWorldReference aPreferredMapRequestReference)
      Sets the preferred reference to be used in WMS map requests. The default value is null, indicating that the current reference of the view is used in WMS map requests. If a reference is set that is not supported by the WMS server, a fallback reference is automatically chosen.
      Parameters:
      aPreferredMapRequestReference - the preferred reference to be used in WMS map requests
      Since:
      2018.0
      See Also:
    • getPreferredMapRequestReference

      public ILcdXYWorldReference getPreferredMapRequestReference()
      Returns the preferred reference to be used in WMS map requests. The default value is null, indicating that the current reference of the view is used in WMS map requests.
      Returns:
      the preferred reference to be used in WMS map requests or null for the default behavior
      Since:
      2018.0
      See Also:
    • setDelegateRasterPainter

      public void setDelegateRasterPainter(ALcdRasterPainter aGXYPainter)
      Sets the ALcdRasterPainter to which the rendering of the raster object is delegated.
      Parameters:
      aGXYPainter - the ALcdRasterPainter to which the rendering of the raster object is delegated.
    • getDelegateRasterPainter

      public ALcdRasterPainter getDelegateRasterPainter()
      Returns the ALcdRasterPainter to which the rendering of the object is delegated.

      By default, an instance of TLcdRasterPainter is used.

      Returns:
      the ALcdRasterPainter to which the rendering of the object is delegated.
    • getTransparency

      public float getTransparency()
      Returns the transparency factor that is applied to painted maps.
      Returns:
      the transparency
      Since:
      2017.0
      See Also:
    • setTransparency

      public void setTransparency(float aTransparency)
      Sets the transparency factor to be applied to painted maps. It is an alpha value between 0 and 1, with 0 being perfectly transparent, and 1 (the default) being perfectly opaque.
      Parameters:
      aTransparency - the transparency
      Since:
      2017.0
    • getBrightness

      public float getBrightness()
      Returns the brightness that is applied to painted maps.
      Returns:
      the brightness
      Since:
      2017.0
      See Also:
    • setBrightness

      public void setBrightness(float aBrightness)
      Sets the brightness that is applied to painted maps. It is a value in [0, 2]. A value of 1 (the default) leaves the brightness unchanged. Values larger than 1 makes the colors brighter, while a value smaller than 1 makes the colors less bright.
      Parameters:
      aBrightness - the brightness
      Since:
      2017.0
    • getContrast

      public float getContrast()
      Returns the contrast that is applied to painted maps.
      Returns:
      the contrast
      Since:
      2017.0
      See Also:
    • setContrast

      public void setContrast(float aContrast)
      Sets the contrast that is applied to painted maps. It is a value in [0, 2]. A value of 1 (the default) leaves the contrast unchanged. A value larger than 1 enhances the contrast of dark colors by making them brighter, while a value smaller than 1 enhances the contrast of bright colors by making them darker.
      Parameters:
      aContrast - the contrast
      Since:
      2017.0
    • isTouched

      public boolean isTouched(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      Description copied from interface: ILcdGXYPainter
      Checks if the representation of the object in the given mode is touched at the location as defined in the supplied context.

      The location that must be taken into account to check whether the representation is touched can be retrieved from the context passed with the methods ILcdGXYContext.getX() and ILcdGXYContext.getY(). If the check is part of an ongoing operation of user interaction, for example, when the mouse is being dragged, the location of the start of the operation can also be taken into account using the methods ILcdGXYContext.getDeltaX() and ILcdGXYContext.getDeltaY(). The context contains the transformations required to convert this location into the equivalent location in model space. Implementations of this interface usually follow either of the following patterns:

      • transform the location of the interaction back to model space and compare the coordinates with the object in model space.
      • transform the location to world space and compare with a world representation of the object. This forces the painter into caching a world representation of the object. Caching a view representation of an object is not very practical as it would have to change whenever the view's scale changes or when it is panned. A world representation of an object only changes when the view's XYWorldReference changes, which happens less frequently.

      As the mode influences the way an object is represented, it must also be taken into account when checking whether that representation is being touched. When the mode contains CREATING, RESHAPING or TRANSLATING which indicate that the object must be represented in a state for an ongoing operation, the location of the start of the operation may be taken into account as mentioned above. The painting result can take into account multiple locations, to respond to, for example, multi-touch input. When the mode contains SELECTED, the painter should also check if the non-selected representation is touched, since these are always painted on top of each other.

      The boundsSFCT is often used to speed up the performance of this method as a location outside these bounds can never touch the representation of the object.

      Note that this method does not give an indication of what part of the object is touched. It is up to the painter implementations to provide methods to make this distinction. The method does also not indicate what sensitivity must be applied when checking if an object is touched. It is up to the implementation to decide what should be the maximum distance between the location given in the context and the closest relevant point or area of the representation of the object.

      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aMode - the mode the object is represented in
      aGXYContext - contains the location of the interaction and the transformations to convert this location into model coordinates
      Returns:
      true if the representation of the object in the given mode is touched by the location as defined in the context passed, false otherwise
      See Also:
    • getObject

      public Object getObject()
      Description copied from interface: ILcdGXYPainter
      Returns the Object for which the representation is currently being handled by this painter.
      Returns:
      the Object for which the representation is currently being handled by this painter.
      See Also:
    • setObject

      public void setObject(Object aObject)
      Description copied from interface: ILcdGXYPainter
      Sets the Object for which the representation shall be handled by this painter.

      Setting the object on the painter may have an effect on the internal state of the painter, for example, the color to use.

      When the object is set to a painter, the context parameter in subsequent calls to methods in this class must contain a layer that contains this object and for which the painter for this object is this painter.

      Parameters:
      aObject - the object for which the representation shall be handled by this painter.
      See Also:
    • boundsSFCT

      public void boundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds a2DEditableBoundsSFCT) throws TLcdNoBoundsException
      Description copied from interface: ILcdGXYPainter
      Sets the supplied bounds (in view coordinates, pixels) so that it encompasses the representation of the object in the given mode taking into account the given context.

      If this method returns without exception the bounds argument must encompass the representation of the object. A point outside the bounds will not be contained within the painted object.

      The bounds returned in this method can be seen as the equivalent in the view space of the bounds in the model space for ILcdBounded objects.

      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aMode - the mode the object is represented in (see class documentation). For example, an object may be represented differently in SELECTED mode compared to DEFAULT mode. The returned bounds of the representation must take this different representation into account.
      aGXYContext - the context for which the representation of the object is painted. It contains amongst others the transformations from model to world and world to view.
      a2DEditableBoundsSFCT - the bounds that must be adapted to encompass the representation of the object in the given mode and context. These bounds must not be taken into account when the method has thrown an exception.
      Throws:
      TLcdNoBoundsException - if no bounds can be determined for the representation of the object. This can happen when the object does not have a representation in the given context, for example when it is located in a part of the world which is not visible in the current view.
      See Also:
    • paint

      public void paint(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      Description copied from interface: ILcdGXYPainter
      Displays the representation of the object in the given mode on the Graphics passed, taking into account the supplied context.

      The visual representation of an object depends on the context. Depending on the context (e.g. is the location covered by the view), an object may or may not have a representation. The context contains:

      • transformations which allow to compute the location in view space of points and bounds given in model, space
      • a pen which can connect points with a line or create arcs around a point,
      • the view for which the object's representation must be painted. This can be useful when the painted object depends on the scale of the view, or the presence of other layers in the view.
      • the current location(s) of the mouse or input device and the last location(s) the mouse or input device was pressed.

      The mode passed in this method indicates what part of the object must be painted, whether it should be painted as selected or not, and whether user interaction (via mouse movements) must be taken into account.

      When the mode passed contains either TRANSLATING, RESHAPING or CREATING, this method is also responsible for interpreting interaction on the representation of an object and modifying the representation of the object accordingly. The painter is not responsible for modifying the object itself, this is done by a corresponding ILcdGXYEditor . Implementations of ILcdGXYPainter and ILcdGXYEditor interfaces must be consistent for an object: the painter must display the result of the user interaction on the object, while the editor is responsible for modifying the object as a result of the user interaction. A good practice to ensure a consistent implementation is to implement both the ILcdGXYPainter and ILcdGXYEditor interfaces in a single class.

      When the mode passed includes SNAPS, the part of the representation which corresponds to the object returned as snap target by the method snapTarget must be painted in order to provide the user with a visual indication of the snap target.

      The Graphics passed in this method can be different from the Graphics returned by a view due to techniques such as double buffering (as applied in Swing). Basic drawing operations must always be performed on the Graphics passed as an argument in this method.

      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aMode - the mode the object is represented in (see class documentation).
      aGXYContext - the ILcdGXYContext the drawing depends on.
    • getFeatureInfoContext

      public TLcdWMSGetFeatureInfoContext getFeatureInfoContext(int aX, int aY, ILcdGXYContext aGXYContext)

      Returns a TLcdWMSGetFeatureInfoContext for the given view coordinate. This context can be used to perform a GetFeatureInfo request, see ALcdWMSProxy#createFeatureInfoInputStream. Before calling this method, the WMS proxy for which to get the GetFeatureInfo context should be set on the painter.

      Parameters:
      aX - the x coordinate (in view coordinates) for which to retrieve a TLcdWMSGetFeatureInfoContext
      aY - the y coordinate (in view coordinates) for which to retrieve a TLcdWMSGetFeatureInfoContext
      aGXYContext - the context.
      Returns:
      a TLcdWMSGetFeatureInfoContext for the given view coordinate or null when the given coordinate lie outside the WMS model bounds.