Class BaseRenderSettings

java.lang.Object
com.levigo.jadice.web.shared.model.settings.AbstractListenableRenderSettings
com.levigo.jadice.web.shared.model.settings.BaseRenderSettings
All Implemented Interfaces:
RenderSettings

public class BaseRenderSettings extends AbstractListenableRenderSettings
Encapsulates the rendering configuration for the whole document.

Provides PageRenderSettings to override rendering configuration for specific pages.

  • Field Details

  • Constructor Details

    • BaseRenderSettings

      public BaseRenderSettings()
  • Method Details

    • setDefaults

      protected void setDefaults()
      Description copied from class: AbstractListenableRenderSettings
      Initializes additional settings.
      Specified by:
      setDefaults in class AbstractListenableRenderSettings
    • setDocumentLayerEnabled

      public void setDocumentLayerEnabled(DocumentLayer layer, boolean value)
      Sets a flag whether document layer of given class should be rendered or not.
      Parameters:
      layer - Document layer.
      value - Flag
    • enableAllLayers

      public void enableAllLayers()

      Enables the rendering of all standard layers provided by the DocumentLayer class and explicit disabled layers (defined by a call of setDocumentLayerEnabled(DocumentLayer, boolean) with a false boolean parameter).

      Standard layers provided by the DocumentLayer class are:

      Other customized layers, will not be enabled by a call of this method. To enable customized layers the usage of setDocumentLayerEnabled(DocumentLayer, boolean) is advised.

    • disableAllLayers

      public void disableAllLayers()

      Disables the rendering of all standard layers provided by the DocumentLayer class and explicit enabled layers (defined by a call of setDocumentLayerEnabled(DocumentLayer, boolean) with a true boolean parameter).

      Standard layers provided by the DocumentLayer class are:

      Other customized layers, will not be disabled by a call of this method. To disable customized layers the usage of setDocumentLayerEnabled(DocumentLayer, boolean) is advised.

    • isDocumentLayerEnabled

      public boolean isDocumentLayerEnabled(DocumentLayer layer)
      Returns whether the given layer will be rendered (true if to be rendered, false if not enabled).
      Parameters:
      layer - The document layer to check the enabling state for.
      Returns:
      Indicator whether the layer class should be rendered or not.
    • getOrderedAndActiveLayers

      public List<DocumentLayer> getOrderedAndActiveLayers(Collection<DocumentLayer> candidateLayers)
      Returns a collection of candidate layers in an ordering suitable for rendering. This entails
      Parameters:
      candidateLayers - The layers to check whether they are active and to return in their predefined order.
      Returns:
      Collection of filtered and ordered layers. It is not guaranteed, that the given candidateLayers collection is changed by this method, but it is also not assured that the returned collection is the same instance as the candidateLayers collection.
    • getZoomFactor

      public float getZoomFactor()
    • getRotation

      public BaseRenderSettings.Rotation getRotation()
    • setDeviceResolution

      public void setDeviceResolution(Integer resolution)
      Sets the device deviceResolution.
      Parameters:
      resolution - the deviceResolution to be configured.
    • getDeviceResolution

      public int getDeviceResolution()
      Returns the currently configured device resolution.
      Returns:
      the device resolution that is currently used.
    • setZoom

      public void setZoom(float zoom)
    • setRotation

      public void setRotation(BaseRenderSettings.Rotation r)
    • calcBounds

      public Dimension calcBounds(Page page)
      Calculates the Dimensions of the Page included the zoom level and Rotation
      Parameters:
      page - Page to calc the Bounds
      Returns:
      the Dimensions to draw
    • calcDeviceBounds

      public Dimension calcDeviceBounds(Page page)
      Calculates the Dimensions of the Page included the zoom level and Rotation and the device ratio
      Parameters:
      page - Page to calc the Bounds
      Returns:
      the Dimensions to draw
    • calcBounds

      public Dimension calcBounds(int pageWidth, int pageHeight)
      Calculates the Dimensions of the Page included the zoom level and Rotation
      Parameters:
      pageWidth - real PageWidth
      pageHeight - real PageHeight
      Returns:
      the Dimensions to draw
    • baseToDevice

      public int baseToDevice(int value)
      Utility method: convert base units to device units and apply zoom factor
      Parameters:
      value - value in base units
      Returns:
      value in device units, zoomed
    • baseToDevice

      public double baseToDevice(double value)
      Utility method: convert base units to device units and apply zoom factor
      Parameters:
      value - value in base units
      Returns:
      value in device units, zoomed
    • deviceToBase

      public int deviceToBase(int value)
      Utility method: convert device units to base units and unapply zoom factor
      Parameters:
      value - value in device units
      Returns:
      value in base units, de-zoomed
    • deviceToBase

      public double deviceToBase(double value)
      Utility method: convert device units to base units and unapply zoom factor
      Parameters:
      value - value in device units
      Returns:
      value in base units, de-zoomed
    • update

      public void update(String propertyName, RenderSettings other, Object... details)
      Overwrites the current render settings with the given one.
      Parameters:
      propertyName - the name of the property to update. Update supported properties have unique property identifier provided by the specific render settings implementation.
      other - the processing setting which provide the new property value. Therefore, the other processing setting have to be of the same type as this instance.
      details - (optional) if some describing details are necessary to do a specific update, the details parameter will transport this information
    • createSnapshot

      public RenderSettings createSnapshot()
    • getAffineTransform

      public AffineTransform getAffineTransform()
      Gets the affine transform for this render context, useful for converting from document to device space. Considers zoom factor and rotation. If the transform encompasses a rotational component, the rotation will use the origin as its center. Therefore, the target bounding box may occupy any quadrant of the target coordinate system, unless further transformation is applied to the transform returned by this method.

      WARN: Does not work with rotation!

      Returns:
      AffineTransform
    • getAffineTransform

      public AffineTransform getAffineTransform(Dimension2D srcSize)
      Gets the affine transform for this render setting, useful for converting from document to device space. Considers zoom factor and rotation. If the transform encompasses a rotational component, the rotation will use an origin calculated from the given source size, so that the result of the rendering lies within the first quadrant (in screen coordinates, i.e. 0/0 at the top/left).
      Parameters:
      srcSize - the size of the object to be rendered in source (document) coordinates.
      Returns:
      AffineTransform
    • getInverseTransform

      public AffineTransform getInverseTransform(Dimension2D pageSize)
      Gets the inverse affine transform for this render context, useful for converting from device to document space. Considers zoom factor and rotation.
      Parameters:
      pageSize - the pages size in base units
      Returns:
      AffineTransform
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

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

      public String convertToKey()
      Converts the fields of this class to a String key that can be used to cache tiles in the client side TileCache.
      Returns:
      the key
    • getLayers

      public Set<DocumentLayer> getLayers()
      only for serialization
      Returns:
      the layers
    • getDefaultLayerStateEnabled

      public Boolean getDefaultLayerStateEnabled()
      only for serialization
      Returns:
      whether the default layer state is enabled or not
    • setDefaultLayerStateEnabled

      public void setDefaultLayerStateEnabled(Boolean defaultLayerStateEnabled)
      only for serialization
      Parameters:
      defaultLayerStateEnabled - whether the default layer state is enabled or not