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

    • TLcdGXYHatchedFillStyle

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

      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

      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

    • addPropertyChangeListener

      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

      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

      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

      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

      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

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

      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

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

      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

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

      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

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

      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

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

      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

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

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

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

      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

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

      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

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

      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

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

      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

      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

      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

      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: