skip to main content
Charts > Programmer's documentation > Developing with the JViews Charts SDK > Displaying an image > The IlvImageDecoration class
 
The IlvImageDecoration class
The IlvImageDecoration is a predefined decoration class that displays an image within the plotting area of a chart.
An image can be drawn according to three different modes:
*TILED: The image is drawn as a replicated pattern in the plot area.
*SCALED: The image is scaled so that it fills the plot area.
*ANCHORED: The image is drawn at a fixed position.
The predefined position for the ANCHORED mode is defined as one of the javax.swing.Swing Constants compass directions.
These directions are:
*CENTER
*NORTH
*NORTH_EAST
*EAST
*SOUTH_EAST
*SOUTH
*SOUTH_WEST
*WEST
*NORTH_WEST
Here is an example of code that creates and adds a SCALED image decoration to a chart:
IlvChart chart = ...;
    try {
        java.net.URL url = new File("logo.gif").toURL();
        // The last parameter is taken into account only in ANCHORED mode.
        IlvImageDecoration deco = new                         IlvImageDecoration(url,IlvImageDecoration.SCALED, 0);
        chart.addDecoration(deco);
    } catch (java.net.MalformedURLException e) {
        e.printStackTrace();
    }
NOTE To preserve the image during serialization, you must use the IlvImageDecoration constructor that takes a java.net.URL as the location of the image. Other constructors do not preserve the image.
The following table shows the properties of the IlvImageDecoration class.
 
Property
Methods
Default Value
Drawing mode.
getMode
 
Image location.
getAnchor
setAnchor
SwingConstants.CENTER
Drawing order relative to the drawing of the graphical representations of data and to other decorations.
getDrawOrder
setDrawOrder
IlvChart.DRAW_BELOW
Visibility.
isVisible
setVisible
true
Drawing mode
The drawing mode property is initialized at construction time. It must be one of the TILED, SCALED or ANCHORED IlvImageDecoration constants. If the latter is used, a predefined position must also be specified by means of the anchor property.
Image anchor
When using the ANCHORED drawing mode, the image location within the plot area must be specified either at construction time or by means of the setAnchor method. By default, an anchored image is drawn at the center of the plotting area.
Drawing order
You can control the drawing order of the image decoration with respect to the charts representation and to other decorations. This drawing order is defined by the drawOrder property. See Decorations for more information on ordering decorations.

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.