Chart FX for Java 6.5

SoftwareFX.ChartFX
Class GradientBackground

java.lang.Object
  extended by SoftwareFX.ChartFX.GradientBackground
All Implemented Interfaces:
IAdornment

public final class GradientBackground
extends java.lang.Object
implements IAdornment

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.

In Chart FX, background gradients can be applied to 2 rectangular areas in the chart area: The chart's inside background and the main background. Chart FX allows horizontal, vertical, diagonal and radial gradients when applying gradient fills to either of these areas of the chart.

When applied to the chart background, gradients can help you achieve a superior visual effect for your desktop and web applications.

Creating the GradientBackground Object

In order to add a gradient background to your chart, you will need to create an instance of the GradientBackground object. Once an object has been created, you may assign the desired attributes to create the gradient. Below is a small example of creating the GradientBackground object and attribute assignment:

GradientBackground myGradient = new GradientBackground(GradientType.BACKWARD_DIAGONAL);
myGradient.setColor(0, java.awt.Color.red);
myGradient.setColor(1, java.awt.Color.blue);
myGradient.setPosition(0, 0);
myGradient.setPosition(1, 1);
chart1.setBackObject(myGradient);


Nested Class Summary
static class GradientBackground.ColorCollection
          Provides access to the ColorCollection object.
static class GradientBackground.FloatCollection
          Provides access to the FloatCollection object.
 
Constructor Summary
GradientBackground()
           
GradientBackground(int type)
           
 
Method Summary
 void draw(java.awt.Graphics2D graphics2D, java.awt.Rectangle r, java.awt.Color clrExternal)
          Used to draw a Chart FX GradientBackground on a selected device context.
 float getAngle()
          Gets the Angle.
 java.awt.Color getColor(int n)
          Deprecated. You should use getColors() instead.
 java.awt.Color getColorFrom()
          Gets the ColorFrom.
 GradientBackground.ColorCollection getColors()
          Gets the Color Collection used for a gradient background.
 java.awt.Color getColorTo()
          Gets the ColorTo.
 GradientBackground.FloatCollection getFactor()
          Specifies the percentages of the starting color and the ending color to use at the corresponding position for two color gradients.
 float getFactor(int n)
          Deprecated. You should use getFactor() instead.
 GradientBackground.FloatCollection getPosition()
          Allows you to specify positions along the gradient background to correspond with color and factor attributes.
 float getPosition(int n)
          Deprecated. You should use getPosition() instead.
 int getType()
          Gets the Type.
 void setAngle(float value)
          Sets the gradient angle when using the 'Angled' gradient background.
 void setColor(int n, java.awt.Color value)
          Deprecated. You should use getColors() instead.
 void setColorFrom(java.awt.Color value)
          Beginning color of a gradient.
 void setColorTo(java.awt.Color value)
          Ending color of a gradient.
 void setFactor(int n, float value)
          Deprecated. You should use getFactor() instead.
 void setPosition(int n, float value)
          Deprecated. You should use getPosition() instead.
 void setType(int 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(int type)
Method Detail

draw

public void draw(java.awt.Graphics2D graphics2D,
                 java.awt.Rectangle r,
                 java.awt.Color clrExternal)

Used to draw 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 GradientBackground object to a chart.

  • The setType(int) property allows you to select on of the supported Chart FX GradientBackground styles.

  • The getColor(int), setColorFrom(java.awt.Color) and setColorTo(java.awt.Color) proerties will allow you to selected the desired colors for the gradient.

  • Parameters:
    graphics2D -
    r - A Rectangle object specifying the desired position and size of the gradient.
    clrExternal - The external color for the gradient.
    See Also:
    getColor(int), setColorFrom(java.awt.Color), setColorTo(java.awt.Color), setType(int), DefaultBorder.draw(java.awt.Graphics2D, java.awt.Rectangle, java.awt.Color), ImageBorder.draw(java.awt.Graphics2D, java.awt.Rectangle, java.awt.Color), DefaultBorder, ImageBorder

    getAngle

    public float getAngle()

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


    getColor

    public java.awt.Color getColor(int n)
    Deprecated. You should use getColors() instead.


    getColorFrom

    public java.awt.Color getColorFrom()

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


    getColors

    public GradientBackground.ColorCollection getColors()

    Gets the Color Collection used for a gradient background.

    See Also:
    getFactor(int), getPosition(int), ChartCore.setBackObject(SoftwareFX.ChartFX.IAdornment), ChartCore.setInsideBackObject(SoftwareFX.ChartFX.IAdornment), Chart

    getColorTo

    public java.awt.Color getColorTo()

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


    getFactor

    public float getFactor(int n)
    Deprecated. You should use getFactor() instead.


    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 (2) color gradients.

  • You must set the ChartCore.setScheme(int) property to Scheme.Gradient in order to use a gradient in your chart.

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

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

  • You may assign gradients to the chart ChartCore.setBackObject(SoftwareFX.ChartFX.IAdornment) and ChartCore.setInsideBackObject(SoftwareFX.ChartFX.IAdornment).

  • 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:
    getColor(int), getPosition(int), ChartCore.setScheme(int), ChartCore.setBackObject(SoftwareFX.ChartFX.IAdornment), ChartCore.setInsideBackObject(SoftwareFX.ChartFX.IAdornment), Chart

    getPosition

    public float getPosition(int n)
    Deprecated. You should use getPosition() instead.


    getPosition

    public GradientBackground.FloatCollection getPosition()

    Allows you to specify positions along the gradient background to correspond with color and factor attributes.

    Remarks:
  • The range of this array property 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(int) value.

  • In multicolor gradients, each position value must have a corresponding getColor(int).

  • You must set the ChartCore.setScheme(int) property to Scheme.Gradient in order to use a gradient in your chart.

  • You may assign gradients to the chart ChartCore.setBackObject(SoftwareFX.ChartFX.IAdornment) and ChartCore.setInsideBackObject(SoftwareFX.ChartFX.IAdornment).

  • Below is a multicolor gradient assigned to the ChartCore.setBackObject(SoftwareFX.ChartFX.IAdornment). There are 6 colors in the gradient, therefore, 6 positions must be configured:

  • See Also:
    getColor(int), getFactor(int), ChartCore.setBackObject(SoftwareFX.ChartFX.IAdornment), ChartCore.setInsideBackObject(SoftwareFX.ChartFX.IAdornment), ChartCore.setScheme(int), Chart

    getType

    public int getType()

    Gets the Type. For more detail see setType(int).


    setAngle

    public void setAngle(float value)

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

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

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

  • You must set the ChartCore.setScheme(int) property to Scheme.Gradient in order to use a gradient in your chart.

  • To set the gradient colors, you can use the getColor(int), setColorFrom(java.awt.Color) and setColorTo(java.awt.Color) properties.

  • When creating two color gradients, you can control the gradient brush using the getFactor(int) and getPosition(int) properties.

  • You may assign gradients to the chart ChartCore.setBackObject(SoftwareFX.ChartFX.IAdornment) and ChartCore.setInsideBackObject(SoftwareFX.ChartFX.IAdornment).

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

    The second has been set to 120 degrees:

  • See Also:
    getColor(int), getFactor(int), getPosition(int), ChartCore.setScheme(int), ChartCore.setBackObject(SoftwareFX.ChartFX.IAdornment), ChartCore.setInsideBackObject(SoftwareFX.ChartFX.IAdornment), setType(int), Chart

    setColor

    public void setColor(int n,
                         java.awt.Color value)
    Deprecated. You should use getColors() instead.


    setColorFrom

    public void setColorFrom(java.awt.Color value)

    Beginning color of a gradient.

    Remarks:
  • This property sets the beginning color of a gradient to be applied to chart BackObject or InsideBackObject. You can also set the beginning color of the gradient by utilizing the Color property using index zero.

  • See Also:
    setAngle(float), getColor(int), setColorTo(java.awt.Color), getFactor(int), getPosition(int), setType(int)

    setColorTo

    public void setColorTo(java.awt.Color value)

    Ending color of a gradient.

    Remarks:
  • This property sets the ending color of a gradient to be applied to chart BackObject or InsideBackObject. You can also set the ending color of the gradient by utilizing the Color property.

  • See Also:
    setAngle(float), getColor(int), setColorFrom(java.awt.Color), getFactor(int), getPosition(int), setType(int)

    setFactor

    public void setFactor(int n,
                          float value)
    Deprecated. You should use getFactor() instead.


    setPosition

    public void setPosition(int n,
                            float value)
    Deprecated. You should use getPosition() instead.


    setType

    public void setType(int value)

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

    Values:
    GradientType : Gradient enumerations.
    ValueDescription
    GradientType.HORIZONTALGradient painted from left to right.
    GradientType.VERTICALGradient painted from top to bottom.
    GradientType.BACKWARD_DIAGONALGradient painted from top right to bottom left.
    GradientType.FORWARD_DIAGONALGradient painted from top left to bottom right.
    GradientType.RADIALGradient painted in a circular manner from outside to inside.
    GradientType.ANGLEDGradient painted using the configured angle value.

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

  • The getColor(int), setColorFrom(java.awt.Color) and setColorTo(java.awt.Color) properties allow you to configure the desired colors for a gradient background.

  • You must set the ChartCore.setScheme(int) property to Scheme.Gradient in order to use a gradient in your chart.

  • You may assign gradients to the chart ChartCore.setBackObject(SoftwareFX.ChartFX.IAdornment) and ChartCore.setInsideBackObject(SoftwareFX.ChartFX.IAdornment).

  • See Also:
    setAngle(float), getColor(int), setColorFrom(java.awt.Color), setColorTo(java.awt.Color), ChartCore.setScheme(int), getFactor(int), getPosition(int), Chart

    http://www.softwarefx.com

    2007 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.