package org.apache.poi.xddf.usermodel;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.openxmlformats.schemas.drawingml.x2006.main.CTGradientFillProperties;
@Beta
public class XDDFGradientFillProperties implements XDDFFillProperties {
private CTGradientFillProperties props;
public XDDFGradientFillProperties() {
this(CTGradientFillProperties.Factory.newInstance());
}
protected XDDFGradientFillProperties(CTGradientFillProperties properties) {
this.props = properties;
}
@Internal
public CTGradientFillProperties getXmlObject() {
return props;
}
public Boolean isRotatingWithShape() {
if (props.isSetRotWithShape()) {
return props.getRotWithShape();
} else {
return null;
}
}
public void setRotatingWithShape(Boolean rotating) {
if (rotating == null) {
if (props.isSetRotWithShape()) {
props.unsetRotWithShape();
}
} else {
props.setRotWithShape(rotating);
}
}
public TileFlipMode getTileFlipMode() {
if (props.isSetFlip()) {
return TileFlipMode.valueOf(props.getFlip());
} else {
return null;
}
}
public void setTileFlipMode(TileFlipMode mode) {
if (mode == null) {
if (props.isSetFlip()) {
props.unsetFlip();
}
} else {
props.setFlip(mode.underlying);
}
}
public XDDFGradientStop addGradientStop() {
if (!props.isSetGsLst()) {
props.addNewGsLst();
}
return new XDDFGradientStop(props.getGsLst().addNewGs());
}
public XDDFGradientStop insertGradientStop(int index) {
if (!props.isSetGsLst()) {
props.addNewGsLst();
}
return new XDDFGradientStop(props.getGsLst().insertNewGs(index));
}
public void removeGradientStop(int index) {
if (props.isSetGsLst()) {
props.getGsLst().removeGs(index);
}
}
public XDDFGradientStop getGradientStop(int index) {
if (props.isSetGsLst()) {
return new XDDFGradientStop(props.getGsLst().getGsArray(index));
} else {
return null;
}
}
public List<XDDFGradientStop> getGradientStops() {
if (props.isSetGsLst()) {
return Collections.unmodifiableList(props
.getGsLst()
.getGsList()
.stream()
.map(XDDFGradientStop::new)
.collect(Collectors.toList()));
} else {
return Collections.emptyList();
}
}
public int countGradientStops() {
if (props.isSetGsLst()) {
return props.getGsLst().sizeOfGsArray();
} else {
return 0;
}
}
public XDDFLinearShadeProperties getLinearShadeProperties() {
if (props.isSetLin()) {
return new XDDFLinearShadeProperties(props.getLin());
} else {
return null;
}
}
public void setLinearShadeProperties(XDDFLinearShadeProperties properties) {
if (properties == null) {
if (props.isSetLin()) {
props.unsetLin();
}
} else {
props.setLin(properties.getXmlObject());
}
}
public XDDFPathShadeProperties getPathShadeProperties() {
if (props.isSetPath()) {
return new XDDFPathShadeProperties(props.getPath());
} else {
return null;
}
}
public void setPathShadeProperties(XDDFPathShadeProperties properties) {
if (properties == null) {
if (props.isSetPath()) {
props.unsetPath();
}
} else {
props.setPath(properties.getXmlObject());
}
}
public XDDFRelativeRectangle getTileRectangle() {
if (props.isSetTileRect()) {
return new XDDFRelativeRectangle(props.getTileRect());
} else {
return null;
}
}
public void setTileRectangle(XDDFRelativeRectangle rectangle) {
if (rectangle == null) {
if (props.isSetTileRect()) {
props.unsetTileRect();
}
} else {
props.setTileRect(rectangle.getXmlObject());
}
}
}