Chart FX 7 for Java Server

com.softwarefx.chartfx.server.adornments
Class ImageBackground

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

public class ImageBackground
extends Object
implements IBackgroundAdornment

Provides access to the ImageBackground object.

The ImageBackground Class is used to set an image for the background of a chart. Developers may render an image either in the Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)or in the Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)of the Chart.

In order to add a image background to your chart, you will need to create an instance of the ImageBackground Class . Once an object has been created, you may assign the desired attributes to configure the image. such as setMode(com.softwarefx.chartfx.server.adornments.ImageMode) and setBackColor(java.awt.Color). Below is a small example of creating the ImageBackground object:

javax.swing.ImageIcon ico = new javax.swing.ImageIcon(application.getRealPath("/Images") + "/mypic.gif");
java.awt.Image img = ico.getImage();
ImageBackground ib = new ImageBackground();
ib.setBackColor(new java.awt.Color(70, 109, 225));
ib.setMode(ImageMode.CENTER);
ib.setImage(img);
chart1.setBackground(ib);

Use the Chart.setBackColor(java.awt.Color) property of the ImageBackground Class to set a background color for images using transparency. Alternativelly, you can use the Chart.setPlotAreaColor(java.awt.Color)and BackColor properties of the Chart. The setMode(com.softwarefx.chartfx.server.adornments.ImageMode) property is used to get or set the rendering style for the background image. Use the setImage(java.awt.Image) property to configure the picture file to be used for the ImageBackground.

Below is a chart where two images have been configured for the Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment)and the Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment):

Important Note : To set the image background of a chart in your applications, you must reference the Adornments assembly in your project.


Constructor Summary
ImageBackground()
           
ImageBackground(Image image)
           
ImageBackground(String path)
           
 
Method Summary
 void draw(Graphics2D g, Rectangle r, Color clrExternal)
          Draws a Chart FX ImageBackground on a selected device context.
 Color getBackColor()
          Gets the BackColor.
 Image getImage()
          Gets the Image.
 ImageMode getMode()
          Gets the Mode.
 void setBackColor(Color value)
          Sets the background color when an ImageBackground object uses a picture with transparency.
 void setImage(Image value)
          Sets a image for the ImageBackground object.
 void setMode(ImageMode value)
          Sets the rendering style for the image used as the ImageBackground.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageBackground

public ImageBackground()

ImageBackground

public ImageBackground(Image image)

ImageBackground

public ImageBackground(String path)
Method Detail

draw

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

Draws a Chart FX ImageBackground on a selected device context.

Remarks:
  • This method allows you to draw a ImageBackground 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 border.
    clrExternal - The external color for the Image Background.
    See Also:
    SimpleBorder.draw(java.awt.Graphics2D, java.awt.Rectangle, java.awt.Color), SolidBackground.draw(java.awt.Graphics2D, java.awt.Rectangle, java.awt.Color), ImageBorder.draw(java.awt.Graphics2D, java.awt.Rectangle, java.awt.Color), SimpleBorder, GradientBackground, SolidBackground, ImageBorder

    getBackColor

    public Color getBackColor()

    Gets the BackColor. For more detail see setBackColor(java.awt.Color).


    getImage

    public Image getImage()

    Gets the Image. For more detail see setImage(java.awt.Image).


    getMode

    public ImageMode getMode()

    Gets the Mode. For more detail see setMode(com.softwarefx.chartfx.server.adornments.ImageMode).


    setBackColor

    public void setBackColor(Color value)

    Sets the background color when an ImageBackground object uses a picture with transparency.

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

  • Alternativelly, you can use the Chart.setPlotAreaColor(java.awt.Color)and Chart.setBackColor(java.awt.Color)properties of the Chart.

  • Below, the BackColor is set to Yellow:

  • See Also:
    setImage(java.awt.Image), Chart.setPlotAreaColor(java.awt.Color), Chart.setBackColor(java.awt.Color), setMode(com.softwarefx.chartfx.server.adornments.ImageMode), Chart

    setImage

    public void setImage(Image value)

    Sets a image for the ImageBackground object.

    Remarks:
  • To make the background image viewable, the Chart.setPlotAreaColor(java.awt.Color) of the Chart has to be transparent (default).

  • You may need to adjust the AxisSectionBase.setTextColor(java.awt.Color) and Chart.setFont(java.awt.Font) within the Chartwhen using this property to make the chart readable.

  • For more information regarding the Image type, please refer to the Java API Documentation.

  • An image has been set as the Chart.setBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment) for the chart below:

  • See Also:
    Chart.setPlotAreaColor(java.awt.Color), AxisSectionBase.setTextColor(java.awt.Color), Chart.setFont(java.awt.Font), Chart.setFont(java.awt.Font), Chart.setPlotAreaBackground(com.softwarefx.chartfx.server.adornments.IBackgroundAdornment), GradientBackground

    setMode

    public void setMode(ImageMode value)

    Sets the rendering style for the image used as the ImageBackground.

    Remarks:
  • This property is used to set the style for the picture configured with the setImage(java.awt.Image) property.

  • Below is an ImageBackground with the "Watermark" mode and setBackColor(java.awt.Color) set to MediumAquamarine:

    Alternatively, this is an ImageBackground with the "Tile" mode:

    Finally, this is an ImageBackground with the "Center" mode and setBackColor(java.awt.Color) set to MediumAquamarine:

  • See Also:
    setImage(java.awt.Image), setBackColor(java.awt.Color)

    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.