Any object that has an SFX
property can use a texture. Set the
following properties of the SFX
object, when you use a texture:
Texture
-- The image to display.
TextureDisplayMode
-- How the image fits the area: whether
it is stretched to fill the area or is repeated to fill the area.
When you use a texture, you must specify an image that is displayed as the texture, in one of the following ways:
As a URL -- Call setTextureURL
to specify the URL where the image is
As an Image file -- Call setTextureImage
to specify the image
file itself. The image is not saved with the XML for the graph, so must
ensure that the image is available where the saved graph is available. Call
setTextureImage
separately from restoring a graph from XML.
If you do not provide an image, then the graph logs an error message and uses the background color instead of a texture.
The following code specifies a texture for the plot area of a graph. This code assumes that
you have a graph that is named myGraph
.
// get the SFX object for the plot area SFX plotAreaSFX = myGraph.getPlotArea().getSFX(); // set the image to use plotAreaSFX.setTextureImageURL("http://myServer.myCompany.com/images/bubbles.gif"); // specify that the image should repeat plotAreaSFX.setTextureDisplayMode(BaseGraphComponent.TDM_TILED); // put the texture into effect plotAreaSFX.setFillType(BaseGraphComponent.FT_TEXTURE);