Skip to main content

PictureFillOptions Class

Contains picture fill options for chart series.

Declaration

public class PictureFillOptions extends OfficeObject

Remarks

To specify picture fill options for bars or areas of a chart series, pass a PictureFillOptions object to the BarSeriesBase.setPictureFillOptions(value) or AreaSeriesBase.setPictureFillOptions(value) method.

Call the PictureFillOptions(fillMode) constructor to stretch or stack pictures. Call the PictureFillOptions(unitsPerPicture) constructor to stack pictures and scale each picture to the specified number of value axis units.

Note

Picture fill options take effect when the series fill is a picture (PictureFill).

Refer to the following help topic for additional information: Create Standard Charts — Presentation API for Java.

Example: Fill Chart Bars with Stacked Pictures

The following code snippet fills bars of a column chart with the Coin.png image and stacks one image per value axis unit:

import java.io.*;
import java.nio.file.*;
import com.devexpress.docs.office.*;
import com.devexpress.docs.presentation.*;
import com.devexpress.drawing.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Presentation presentation = new Presentation();
             InputStream imageStream = Files.newInputStream(Path.of("Coin.png"))) {
            presentation.getSlides().clear();
            Slide slide = new Slide(SlideLayoutType.BLANK);
            presentation.getSlides().add(slide);

            Chart chart = new Chart();
            chart.setWidth(presentation.getSlideSize().getWidth());
            chart.setHeight(presentation.getSlideSize().getHeight());
            slide.getShapes().add(chart);

            ChartData data = chart.getData();
            data.get(0, "A1").setNumericValue(3);
            data.get(0, "A2").setNumericValue(5);
            data.get(0, "A3").setNumericValue(4);
            data.get(0, "B1").setTextValue("Q1");
            data.get(0, "B2").setTextValue("Q2");
            data.get(0, "B3").setTextValue("Q3");

            BarSeries series = new BarSeries();
            series.setValues(new ChartDataReference(0, "A1", "A3"));
            series.setArguments(new ChartDataReference(0, "B1", "B3"));
            chart.getSeries().add(series);

            // Fill bars with an image and stack one image per value axis unit.
            ChartElement seriesProperties = new ChartElement();
            seriesProperties.setFill(new PictureFill(DXImage.fromStream(imageStream)));
            series.setProperties(seriesProperties);
            series.setPictureFillOptions(new PictureFillOptions(1.0));

            Files.createDirectories(Path.of("output"));
            try (OutputStream output = Files.newOutputStream(Path.of("output", "Chart.pptx"))) {
                presentation.save(output);
            }
        }
    }
}

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.initFields()
com.devexpress.system.JavaObject.memberwiseClone()
com.devexpress.system.JavaObject.toString()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object
JavaObject
OfficeObject
PictureFillOptions
See Also

Constructors

PictureFillOptions(double unitsPerPicture) Constructor

Initializes a new instance of the PictureFillOptions class with the specified number of value axis units per picture.

Declaration

public PictureFillOptions(double unitsPerPicture)

Parameters

Name Type Description
unitsPerPicture double

The number of value axis units that one picture covers.

Exceptions

Type Description
ArgumentOutOfRangeException

Thrown if the unitsPerPicture value is less than or equal to 0 or is infinite.

Remarks

The PictureFillOptions(unitsPerPicture) constructor sets the fill mode to STACK_SCALE.

PictureFillOptions(PictureFillMode fillMode) Constructor

Initializes a new instance of the PictureFillOptions class with the specified fill mode.

Declaration

public PictureFillOptions(PictureFillMode fillMode)

Parameters

Name Type Description
fillMode PictureFillMode

The picture fill mode.

Remarks

The PictureFillOptions(fillMode) constructor sets the number of value axis units per picture to 1. This setting takes effect in the STACK_SCALE mode.

Methods

deepClone() Method

Creates a copy of the picture fill options.

Declaration

public PictureFillOptions deepClone()

Returns

Type Description
PictureFillOptions

A copy of the picture fill options.

getFillMode() Method

Returns the picture fill mode.

Declaration

public PictureFillMode getFillMode()

Returns

Type Description
PictureFillMode

The picture fill mode.

getUnitsPerPicture() Method

Returns the number of value axis units that one picture covers.

Declaration

public double getUnitsPerPicture()

Returns

Type Description
double

The number of value axis units that one picture covers.