Skip to main content

SurfaceOptions Class

Contains settings for a floor or wall of a 3D chart.

Declaration

public class SurfaceOptions extends ChartElementBase

Remarks

Pass a SurfaceOptions object to View3DOptions.setFloor(value), View3DOptions.setBackWall(value), or View3DOptions.setSideWall(value) methods to format the floor or walls of a 3D chart.

Example

Rotate a 3D Chart and Fill the Floor and Back Wall

The following code snippet creates a 3D bar chart, specifies rotation, perspective, and depth, and fills the chart floor and back wall:

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

public class Main {
    public static void main(String[] args) throws Exception {
        try (Presentation presentation = new Presentation()) {
            // Add a blank slide.
            presentation.getSlides().clear();
            Slide slide = new Slide(SlideLayoutType.BLANK);
            presentation.getSlides().add(slide);

            // Insert a chart that fills the slide.
            Chart chart = new Chart();
            chart.setWidth(presentation.getSlideSize().getWidth());
            chart.setHeight(presentation.getSlideSize().getHeight());
            slide.getShapes().add(chart);

            // Add a 3D bar series.
            Bar3DSeries series = new Bar3DSeries();
            series.setArguments(new ChartStringData(List.of("Q1", "Q2", "Q3", "Q4")));
            series.setValues(new ChartNumericData(List.of(12.0, 18.0, 15.0, 21.0)));
            chart.getSeries().add(series);

            // Rotate the chart and specify perspective and depth.
            View3DOptions view3D = new View3DOptions();
            view3D.setXRotation(20);
            view3D.setYRotation(40);
            view3D.setPerspective(60);
            view3D.setDepthPercent(2f);

            // Fill the floor and back wall.
            SurfaceOptions floor = new SurfaceOptions();
            floor.setFill(new SolidFill(Color.getLightGray()));
            view3D.setFloor(floor);
            SurfaceOptions backWall = new SurfaceOptions();
            backWall.setFill(new SolidFill(Color.getAliceBlue()));
            view3D.setBackWall(backWall);
            chart.setView3D(view3D);

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

The following screenshot illustrates the result:

 3D column chart with rotation, perspective, and a filled floor and back wall created with the DevExpress Presentation API for Java

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

SurfaceOptions()

Initializes a new instance of the SurfaceOptions class.

Declaration

public SurfaceOptions()

Methods

deepClone() Method

Creates a copy of the surface settings.

Declaration

public SurfaceOptions deepClone()

Returns

Type Description
SurfaceOptions

A copy of the surface settings.

getFill() Method

Returns the surface fill.

Declaration

public Fill getFill()

Returns

Type Description
Fill

The surface fill, or null if the surface uses the default fill.

getOutlineStyle() Method

Returns surface outline settings.

Declaration

public OutlineStyle getOutlineStyle()

Returns

Type Description
OutlineStyle

Outline settings, or null if the surface uses the default outline.

getThickness() Method

Returns the surface thickness.

Declaration

public int getThickness()

Returns

Type Description
int

The surface thickness.

setFill(Fill value) Method

Sets the surface fill.

Declaration

public void setFill(Fill value)

Parameters

Name Type Description
value Fill

The surface fill, or null to use the default fill.

setOutlineStyle(OutlineStyle value) Method

Sets surface outline settings.

Declaration

public void setOutlineStyle(OutlineStyle value)

Parameters

Name Type Description
value OutlineStyle

Outline settings, or null to use the default outline.

setThickness(int value) Method

Sets the surface thickness.

Declaration

public void setThickness(int value)

Parameters

Name Type Description
value int

The surface thickness.

Exceptions

Type Description
ArgumentOutOfRangeException

Thrown if the value parameter is less than 0 or greater than 100.

Remarks

The value range is from 0 to 100. A new SurfaceOptions object uses 0.