Class TLcdGXYHatchedFillStyle

java.lang.Object
com.luciad.view.gxy.TLcdGXYHatchedFillStyle
All Implemented Interfaces:
ILcdCloneable, ILcdGXYPainterStyle, Serializable, Cloneable

public class TLcdGXYHatchedFillStyle extends Object implements ILcdGXYPainterStyle, ILcdCloneable

ILcdGXYPainterStyle that fills areas by hatching them with a given line width and color.

How the hatched fill looks.

For performance reasons, a pattern is created by drawing one line in every necessary direction (horizontal, vertical, slash or back slash) on top of the background color (if background is enabled). This pattern is then tiled to fill the required area.

If you only intend to use this style for solid fills, it is better to use TLcdGXYPainterColorStyle for performance reasons.

Example code:

// Init painter modes
ALcdGXYAreaPainter painter = ...;
painter.setMode( ALcdGXYAreaPainter.OUTLINED_FILLED );
painter.setSelectionMode( ALcdGXYAreaPainter.OUTLINED_FILLED );
// Create fill style
painter.setFillStyle( new TLcdGXYHatchedFillStyle(
EnumSet.of( TLcdGXYHatchedFillStyle.Pattern.SLASH ), Color.ORANGE, Color.ORANGE.brighter() ) );
// Create matching line style
TLcdG2DLineStyle lineStyle = new TLcdG2DLineStyle();
lineStyle.setColor( Color.ORANGE.darker() );
lineStyle.setSelectionColor( Color.ORANGE );
lineStyle.setLineWidth( 2 );
lineStyle.setSelectionLineWidth( 2 );
lineStyle.setAntiAliasing( true );
painter.setLineStyle( lineStyle );
Since:
10.0
See Also:
  • Constructor Details Link icon

    • TLcdGXYHatchedFillStyle Link icon

      public TLcdGXYHatchedFillStyle()
      Creates a new TLcdGXYHatchedFillStyle with default values for all properties.
    • TLcdGXYHatchedFillStyle Link icon

      public TLcdGXYHatchedFillStyle(EnumSet<TLcdGXYHatchedFillStyle.Pattern> aPattern, Color aLineColor)
      Creates a new TLcdGXYHatchedFillStyle.
      Parameters:
      aPattern - The pattern set, used for both regular and selection mode.
      aLineColor - The color for painting shapes in their normal (unselected) mode.
    • TLcdGXYHatchedFillStyle Link icon

      public TLcdGXYHatchedFillStyle(EnumSet<TLcdGXYHatchedFillStyle.Pattern> aPattern, Color aLineColor, Color aSelectionLineColor)
      Creates a new TLcdGXYHatchedFillStyle.
      Parameters:
      aPattern - The pattern set, used for both regular and selection mode.
      aLineColor - The color for painting shapes in their normal (unselected) mode.
      aSelectionLineColor - The color for painting shapes in their selected mode.
  • Method Details Link icon

    • addPropertyChangeListener Link icon

      public void addPropertyChangeListener(PropertyChangeListener aListener)
      Adds the given listener to the list of listeners, so that it will receive property change events.
      Parameters:
      aListener - The listener to add.
    • addPropertyChangeListener Link icon

      public void addPropertyChangeListener(String aProperty, PropertyChangeListener aListener)
      Adds the given listener to the list of listeners, so that it will receive notifications about changes in aProperty.
      Parameters:
      aProperty - The property to watch for changes.
      aListener - The listener to add.
    • removePropertyChangeListener Link icon

      public void removePropertyChangeListener(PropertyChangeListener aListener)
      Removes the given listener so that it no longer receives property change events.
      Parameters:
      aListener - The listener to remove.
    • removePropertyChangeListener Link icon

      public void removePropertyChangeListener(String aProperty, PropertyChangeListener aListener)
      Removes the given listener for the given property, so that it no longer receives those change events.
      Parameters:
      aProperty - The property to stop listening to.
      aListener - The listener to remove.
    • firePropertyChange Link icon

      protected void firePropertyChange(String aProperty, Object aOldValue, Object aNewValue)
      Fires the given event to the associated listeners.
      Parameters:
      aProperty - The property that was changed.
      aOldValue - The old value.
      aNewValue - The new value.
    • getPattern Link icon

      Returns the fill pattern.
      Returns:
      the fill pattern.
    • setPattern Link icon

      public void setPattern(EnumSet<TLcdGXYHatchedFillStyle.Pattern> aPattern)
      Sets the filling pattern.
      Parameters:
      aPattern - An enum set of the defined Patterns, for example
      EnumSet.of( Pattern.HORIZONTAL, Pattern.VERTICAL )
    • getSelectionPattern Link icon

      public EnumSet<TLcdGXYHatchedFillStyle.Pattern> getSelectionPattern()
      Returns the fill pattern for selection mode.
      Returns:
      the fill pattern for selection mode.
    • setSelectionPattern Link icon

      public void setSelectionPattern(EnumSet<TLcdGXYHatchedFillStyle.Pattern> aSelectionPattern)
      Sets the filling pattern for selection mode.
      Parameters:
      aSelectionPattern - An enum set of the defined Patterns, for example
      EnumSet.of( Pattern.HORIZONTAL, Pattern.VERTICAL )
    • getPatternSize Link icon

      public Dimension getPatternSize()
      Returns the pattern size.
      Returns:
      the pattern size.
    • setPatternSize Link icon

      public void setPatternSize(Dimension aPatternSize)

      Sets the pixel size of the filling pattern. The pattern is created by drawing one line in every necessary direction (horizontal, vertical, slash or back slash). This pattern is then tiled to fill the required area. Changing the size of this pattern allows to define the spacing between adjacent lines. Defining a non-square pattern size for slanted patterns (slash and back slash) allows to change the angle of the slanted lines. For example a slash pattern with a pattern size of 20x10 results in 26.6 degree lines (Math.atan(10/20)).

      Width and height must be strictly larger than twice (line width + 2), where line width is the largest of the selection or regular line width. The values should be small for performance reasons, for example 10x10 or 20x10 pixels.

      After the dimension is set, the instance must not be changed anymore.

      Parameters:
      aPatternSize - The new pattern size.
    • getLineWidth Link icon

      public int getLineWidth()
      Returns the line width.
      Returns:
      the line width.
    • setLineWidth Link icon

      public void setLineWidth(int aLineWidth)
      Sets the line width for filling shapes in their normal (unselected) mode.
      Parameters:
      aLineWidth - The line width in pixels.
    • getSelectionLineWidth Link icon

      public int getSelectionLineWidth()
      Returns the selection line width.
      Returns:
      the selection line width.
    • setSelectionLineWidth Link icon

      public void setSelectionLineWidth(int aSelectionLineWidth)
      Sets the line width for filling shapes in their selected mode.
      Parameters:
      aSelectionLineWidth - The selection line width in pixels.
    • getLineColor Link icon

      public Color getLineColor()
      Returns the line color.
      Returns:
      the line color.
    • setLineColor Link icon

      public void setLineColor(Color aLineColor)
      Sets the line color for filling shapes in their normal (unselected) mode.
      Parameters:
      aLineColor - The line color
    • getSelectionLineColor Link icon

      public Color getSelectionLineColor()
      Returns the selection line color.
      Returns:
      the selection line color.
    • setSelectionLineColor Link icon

      public void setSelectionLineColor(Color aSelectionLineColor)

      Sets the line color for filling shapes in their selected mode.

      Note that the ILcdGXYPainter should paint its objects filled when selected for this property to have effect, e.g.

      ALcdGXYAreaPainter painter = ...;
      painter.setSelectionMode( ALcdGXYAreaPainter.OUTLINED_FILLED );
      painter.setFillStyle( new TLcdGXYHatchedFillStyle() );

      Parameters:
      aSelectionLineColor - The color of the line when painting objects in their selected state.
    • getBackgroundPaint Link icon

      public Paint getBackgroundPaint()
      Returns the background paint.
      Returns:
      the background paint.
    • setBackgroundPaint Link icon

      public void setBackgroundPaint(Paint aBackgroundPaint)

      Sets the background paint (e.g. a Color). Only applicable if the fill pattern contains TLcdGXYHatchedFillStyle.Pattern.BACKGROUND.

      In combination with Paint's other than a simple Color (e.g. a GradientPaint), one should realize that a (small) pattern is tiled to fill the desired area. As a result it is for example not possible to have a gradient that extends from the top to the bottom of the view.

      Parameters:
      aBackgroundPaint - The paint to fill the background with, in regular (unselected) mode.
    • getSelectionBackgroundPaint Link icon

      public Paint getSelectionBackgroundPaint()
      Returns the selection background paint.
      Returns:
      the selection background paint.
    • setSelectionBackgroundPaint Link icon

      public void setSelectionBackgroundPaint(Paint aSelectionBackgroundPaint)

      Sets the selection background paint (e.g. a Color). Only applicable if the fill pattern contains TLcdGXYHatchedFillStyle.Pattern.BACKGROUND. See setBackgroundPaint(java.awt.Paint) for more details.

      Parameters:
      aSelectionBackgroundPaint - The paint to fill the background with, in selected mode.
    • isAntiAliasing Link icon

      public boolean isAntiAliasing()
      Returns true if anti aliasing is enabled, false otherwise.
      Returns:
      true if anti aliasing is enabled, false otherwise.
    • setAntiAliasing Link icon

      public void setAntiAliasing(boolean aAntiAliasing)
      Sets the anti aliasing property. Anti-aliasing yields smoother results.
      Parameters:
      aAntiAliasing - True to enable anti-aliasing, false otherwise.
    • setupGraphics Link icon

      public void setupGraphics(Graphics aGraphics, Object aObject, int aMode, ILcdGXYContext aGXYContext)
      Description copied from interface: ILcdGXYPainterStyle
      Set up aGraphics before painting aObject. For example, if (aMode & ILcdGXYPainter.SELECTED) != 0, you may want to call aGraphics.setColor(Color.red) for instance, to see the selected representation of a aObject in red.
      Specified by:
      setupGraphics in interface ILcdGXYPainterStyle
      Parameters:
      aGraphics - the Graphics to set up.
      aObject - the Object to paint.
      aMode - the painting mode to consider (defined in ILcdGXYPainter).
      aGXYContext - the ILcdGXYContext to consider.
      See Also:
    • asIcon Link icon

      public ILcdIcon asIcon()

      Returns this style as a tileable icon. The resulting icon will have the same size as the pattern size. When changing the style instance after having created an icon, the icon will not change. I.e. the changes to the style are not applied to the icon.

      Returns:
      this style as an icon.
    • clone Link icon

      public Object clone()
      Description copied from interface: ILcdCloneable

      Makes Object.clone() public.

      When for example extending from java.lang.Object, it can be implemented like this:
      public Object clone() {
      try {
      return super.clone();
      } catch ( CloneNotSupportedException e ) {
      // Cannot happen: extends from Object and implements Cloneable (see also Object.clone)
      throw new RuntimeException( e );
      }
      }
      Specified by:
      clone in interface ILcdCloneable
      Overrides:
      clone in class Object
      See Also: