Chart FX 7 for Java Server

com.softwarefx.chartfx.server.adornments
Class GradientBackground

java.lang.Object
  extended by com.softwarefx.chartfx.server.adornments.GradientBackground
All Implemented Interfaces:
IBackgroundAdornment

public class GradientBackground
extends Object
implements IBackgroundAdornment

Provides access to the GradientBackground object.

As opposed to marker gradients, background gradients are used for cosmetic purposes only. In other words, background gradients are only used to enhance the chart's visual appearance and have no direct relation to the data contained in the chart. When applied to the chart background, gradients can help you achieve a superior visual effect for your desktop and web applications.

In Chart FX, background gradients can be applied to two rectangular areas in the chart area: The chart's inside background (Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)i.e.,Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)) and the main background (i.e., Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)). Chart FX allows horizontal, vertical, diagonal and radial gradients when applying gradient fills to either of these areas of the chart.

To set the gradient colors, you can use the getColors(), setColorFrom(java.awt.Color) and setColorTo(java.awt.Color) properties. When creating two color gradients, you can control the gradient brush using the getFactor() and getPosition() properties. The getPosition() property allows you to specify where each color will start and stop in a multicolor gradient background.

Creating the GradientBackground Object

GradientBackground myGradient = new GradientBackground(GradientType.BACKWARD_DIAGONAL);
myGradient.getColors().add(new java.awt.Color(70, 109, 225));
myGradient.getColors().add(new java.awt.Color(245, 245, 220));
myGradient.getColors().add(new java.awt.Color(70, 109, 225));
myGradient.getPosition().add(0f);
myGradient.getPosition().add(0.9f);
myGradient.getPosition().add(1.0f);
chart1.setBackground(myGradient);


Nested Class Summary
static class GradientBackground.ColorCollection
          Provides access to the ColorCollection Class.
static class GradientBackground.FloatCollection
          Provides access to the FloatCollection Class.
 
Constructor Summary
GradientBackground()
           
GradientBackground(GradientType type)
           
 
Method Summary
 void draw(Graphics2D g, Rectangle r, Color clrExternal)
          Draws a Chart FX GradientBackground on a selected device context.
 float getAngle()
          Gets the Angle.
 Color getColorFrom()
          Gets the ColorFrom.
 GradientBackground.ColorCollection getColors()
          Sets the colors to be used for a gradient background.
 Color getColorTo()
          Gets the ColorTo.
 int getEffectArea()
          Gets the EffectArea.
 GradientBackground.FloatCollection getFactor()
          Specifies the percentages of the starting color and the ending color to use at the corresponding position for two color gradients.
 GradientBackground.FloatCollection getPosition()
          Gives access to a collection that allows you to specify positions along the gradient background to correspond with color and factor attributes.
 GradientType getType()
          Gets the Type.
 void setAngle(float value)
          Sets the gradient angle when using the 'Angled' gradient background.
 void setColorFrom(Color value)
          Sets the beginning color of a gradient.
 void setColorTo(Color value)
          Ending color of a gradient.
 void setEffectArea(int value)
          Sets a value indicating the percentage of chart area affected by a GradientBackground.
 void setType(GradientType value)
          Sets the style of the gradient for a selected gradient background.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GradientBackground

public GradientBackground()

GradientBackground

public GradientBackground(GradientType type)
Method Detail

draw

public void draw(Graphics2D g,
                 Rectangle r,
                 Color clrExternal)

Draws a Chart FX GradientBackground on a selected device context.

Remarks:
  • This method allows you to draw a GradientBackground to a selected device context without ever assigning the background to a chart.

  • Parameters:
    g - A Graphics object is associated with a specific device context.
    r - A Rectangle object specifying the desired position and size of the gradient.
    clrExternal - The external color for the gradient.
    See Also:
    getColors(), setColorFrom(java.awt.Color), setColorTo(java.awt.Color), setType(com.softwarefx.chartfx.server.adornments.GradientType), SimpleBorder.draw(java.awt.Graphics2D, java.awt.Rectangle, java.awt.Color), ImageBorder.draw(java.awt.Graphics2D, java.awt.Rectangle, java.awt.Color), ImageBackground.draw(java.awt.Graphics2D, java.awt.Rectangle, java.awt.Color), SolidBackground.draw(java.awt.Graphics2D, java.awt.Rectangle, java.awt.Color), SimpleBorder, ImageBorder, ImageBackground, SolidBackground

    getAngle

    public float getAngle()

    Gets the Angle. For more detail see setAngle(float).


    getColorFrom

    public Color getColorFrom()

    Gets the ColorFrom. For more detail see setColorFrom(java.awt.Color).


    getColorTo

    public Color getColorTo()

    Gets the ColorTo. For more detail see setColorTo(java.awt.Color).


    getColors

    public GradientBackground.ColorCollection getColors()

    Sets the colors to be used for a gradient background.

    Remarks:
  • For more information regarding the Color type, please refer to the Java API Documentation.

  • Below, the gradient colors are set to blue and white:

  • See Also:
    Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment), setColorTo(java.awt.Color), getFactor(), getPosition(), Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment), Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment), Chart

    getEffectArea

    public int getEffectArea()

    Gets the EffectArea. For more detail see setEffectArea(int).


    getFactor

    public GradientBackground.FloatCollection getFactor()

    Specifies the percentages of the starting color and the ending color to use at the corresponding position for two color gradients.

    Remarks:
  • The Factor property is only supported for two color gradients.

  • Each configured Factor of a gradient will have a corresponding getPosition() value.

  • The elements of this array property are a values ranging from 0.0 through 1.0.

  • The chart below depicts the gradient background created with the sample below. Notice how using the factor allows you to control the gradient brush for an even fade:

  • See Also:
    getColors(), getPosition(), Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment), Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment), Chart

    getPosition

    public GradientBackground.FloatCollection getPosition()

    Gives access to a collection that allows you to specify positions along the gradient background to correspond with color and factor attributes.

    Remarks:
  • The range of this array method is represented by values between 0.0 and 1.0; the first position value must be 0.0 and the last position value must be 1.0.

  • For two color gradients, each position value must have a corresponding getFactor() value.

  • Below is a multicolor gradient assigned to the Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment). There are 6 colors in the gradient, therefore, 6 positions must be configured:

  • See Also:
    getColors(), getFactor(), Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment), Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment), Chart

    getType

    public GradientType getType()

    Gets the Type. For more detail see setType(com.softwarefx.chartfx.server.adornments.GradientType).


    setAngle

    public void setAngle(float value)

    Sets the gradient angle when using the 'Angled' gradient background.

    Remarks:
  • The Angle method supports values ranging from 0 to 360 degrees.

  • You must select the 'Angled' type gradient when creating the GradientBackground object in order for this method to take effect.

  • The first chart gradient has been set to 45 degrees:

    The second has been set to 120 degrees:

  • See Also:
    getColors(), getFactor(), Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment), Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment), setType(com.softwarefx.chartfx.server.adornments.GradientType), Chart

    setColorFrom

    public void setColorFrom(Color value)

    Sets the beginning color of a gradient.

    Remarks:
  • This method sets the beginning color of a gradient. You can also set the beginning color of the gradient by utilizing the getColors() method using index zero.

  • See Also:
    getColors(), setColorTo(java.awt.Color), Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment), Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment), Chart

    setColorTo

    public void setColorTo(Color value)

    Ending color of a gradient.

    Remarks:
  • This method sets the ending color of a gradient. You can also set the ending color of the gradient by setting the last index of the getColors() collection.

  • See Also:
    getColors(), setColorFrom(java.awt.Color), Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment), Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment), Chart

    setEffectArea

    public void setEffectArea(int value)

    Sets a value indicating the percentage of chart area affected by a GradientBackground.

    Remarks:
  • This method may be configured to a value between 0 and 100. The default value is 20, indicating that 20 percent of the chart is affected by a gradient background.

  • Specifying 100 indicates the entire chart background should be configured with a GradientBackground.

  • See Also:
    setAngle(float), getColors(), setColorFrom(java.awt.Color), setColorTo(java.awt.Color), getFactor(), getPosition(), setType(com.softwarefx.chartfx.server.adornments.GradientType), draw(java.awt.Graphics2D, java.awt.Rectangle, java.awt.Color)

    setType

    public void setType(GradientType value)

    Sets the style of the gradient for a selected gradient background.

    Remarks:
  • When using the 'Angled' gradient enumeration, you can set the desired angle for the gradient using the setAngle(float) method.

  • Below is a gradient of type "BackwardDiagonal":

    Alternatively, this is a gradient of type "Radial":

    Finally, this is a gradient of type "Vertical":

  • See Also:
    setAngle(float), getColors(), Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment), Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment), Chart

    http://www.softwarefx.com

    2008 Software FX, Inc. All Rights Reserved. Chart FX is a registered trademark of Software FX, Inc
    All other names are trademarks or registered trademarks of their respective owners.