make these classes more discoverable/searchable using more specific names
rename PropertyTemplate to BorderPropertyTemplate rename Extent to BorderExtent git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ss_border_property_template@1747884 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cea8cc65a3
commit
16fb41d5f1
@ -29,8 +29,8 @@ import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.util.PropertyTemplate;
|
||||
import org.apache.poi.ss.util.PropertyTemplate.Extent;
|
||||
import org.apache.poi.ss.util.BorderPropertyTemplate;
|
||||
import org.apache.poi.ss.util.BorderPropertyTemplate.BorderExtent;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
@ -66,22 +66,22 @@ public class DrawingBorders {
|
||||
c.setCellValue("Colored Borders");
|
||||
|
||||
// draw borders (three 3x3 grids)
|
||||
PropertyTemplate pt = new PropertyTemplate();
|
||||
BorderPropertyTemplate pt = new BorderPropertyTemplate();
|
||||
|
||||
// #1) these borders will all be medium in default color
|
||||
pt.drawBorders(new CellRangeAddress(1, 3, 1, 3), BorderStyle.MEDIUM, Extent.ALL);
|
||||
pt.drawBorders(new CellRangeAddress(1, 3, 1, 3), BorderStyle.MEDIUM, BorderExtent.ALL);
|
||||
|
||||
// #2) these cells will have medium outside borders and thin inside borders
|
||||
pt.drawBorders(new CellRangeAddress(5, 7, 1, 3), BorderStyle.MEDIUM, Extent.OUTSIDE);
|
||||
pt.drawBorders(new CellRangeAddress(5, 7, 1, 3), BorderStyle.THIN, Extent.INSIDE);
|
||||
pt.drawBorders(new CellRangeAddress(5, 7, 1, 3), BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
|
||||
pt.drawBorders(new CellRangeAddress(5, 7, 1, 3), BorderStyle.THIN, BorderExtent.INSIDE);
|
||||
|
||||
// #3) these cells will all be medium weight with different colors for the
|
||||
// outside, inside horizontal, and inside vertical borders. The center
|
||||
// cell will have no borders.
|
||||
pt.drawBorders(new CellRangeAddress(9, 11, 1, 3), BorderStyle.MEDIUM, IndexedColors.RED.getIndex(), Extent.OUTSIDE);
|
||||
pt.drawBorders(new CellRangeAddress(9, 11, 1, 3), BorderStyle.MEDIUM, IndexedColors.BLUE.getIndex(), Extent.INSIDE_VERTICAL);
|
||||
pt.drawBorders(new CellRangeAddress(9, 11, 1, 3), BorderStyle.MEDIUM, IndexedColors.GREEN.getIndex(), Extent.INSIDE_HORIZONTAL);
|
||||
pt.drawBorders(new CellRangeAddress(10, 10, 2, 2), BorderStyle.NONE, Extent.ALL);
|
||||
pt.drawBorders(new CellRangeAddress(9, 11, 1, 3), BorderStyle.MEDIUM, IndexedColors.RED.getIndex(), BorderExtent.OUTSIDE);
|
||||
pt.drawBorders(new CellRangeAddress(9, 11, 1, 3), BorderStyle.MEDIUM, IndexedColors.BLUE.getIndex(), BorderExtent.INSIDE_VERTICAL);
|
||||
pt.drawBorders(new CellRangeAddress(9, 11, 1, 3), BorderStyle.MEDIUM, IndexedColors.GREEN.getIndex(), BorderExtent.INSIDE_HORIZONTAL);
|
||||
pt.drawBorders(new CellRangeAddress(10, 10, 2, 2), BorderStyle.NONE, BorderExtent.ALL);
|
||||
|
||||
// apply borders to sheet
|
||||
pt.applyBorders(sh1);
|
||||
|
@ -31,35 +31,37 @@ import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.util.Beta;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* A PropertyTemplate is a template that can be applied to any sheet in
|
||||
* A BorderPropertyTemplate is a template that can be applied to any sheet in
|
||||
* a project. It contains all the border type and color attributes needed to
|
||||
* draw all the borders for a single sheet. That template can be applied to any
|
||||
* sheet in any workbook.
|
||||
*
|
||||
* This class requires the full spreadsheet to be in memory so
|
||||
* {@link SWorkbook} Spreadsheets are not supported. The same
|
||||
* PropertyTemplate can, however, be applied to both
|
||||
* BorderPropertyTemplate can, however, be applied to both
|
||||
* {@link org.apache.poi.hssf.usermodel.HSSFWorkbook}, and Workbook objects
|
||||
* if necessary. Portions of the border that fall outside the max range of the
|
||||
* {@link HSSFWorkbook} sheet are ignored.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* This would replace {@link RegionUtil}.
|
||||
* This may be merged with {@link RegionUtil} in the future.
|
||||
* </p>
|
||||
*/
|
||||
public final class PropertyTemplate {
|
||||
@Beta
|
||||
public final class BorderPropertyTemplate {
|
||||
|
||||
/**
|
||||
* Provides various extents of the properties being added to the template
|
||||
* Note that the Border Extent differs from a BorderStyle. A BorderStyle
|
||||
* Note that the Border BorderExtent differs from a BorderStyle. A BorderStyle
|
||||
* refers to the border around a single cell while a BorderExtent refers to
|
||||
* borders around and through an area of cells.
|
||||
*/
|
||||
public enum Extent {
|
||||
public enum BorderExtent {
|
||||
/**
|
||||
* No properties defined. This can be used to remove existing
|
||||
* properties.
|
||||
@ -168,20 +170,21 @@ public final class PropertyTemplate {
|
||||
properties.add(CellUtil.BORDER_RIGHT);
|
||||
BORDER_DIRECTION_PROPERTY_NAMES = Collections.unmodifiableSet(properties);
|
||||
}
|
||||
|
||||
// this must be greater than or equal to the workbooks used in #applyBorders
|
||||
private static final SpreadsheetVersion _ss = SpreadsheetVersion.EXCEL2007;
|
||||
|
||||
/**
|
||||
* This is a list of cell properties for one shot application to a range of
|
||||
* cells at a later time.
|
||||
*/
|
||||
private final Map<CellAddress, Map<String, Object>> _propertyTemplate;
|
||||
private final SpreadsheetVersion _ss;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public PropertyTemplate() {
|
||||
public BorderPropertyTemplate() {
|
||||
_propertyTemplate = new HashMap<CellAddress, Map<String, Object>>();
|
||||
_ss = SpreadsheetVersion.EXCEL2007;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -191,23 +194,23 @@ public final class PropertyTemplate {
|
||||
*
|
||||
* @param range range of cells on which borders are drawn.
|
||||
* @param borderType Type of border to draw.
|
||||
* @param extent Extent of the borders to be applied.
|
||||
* @param extent BorderExtent of the borders to be applied.
|
||||
*/
|
||||
public void drawBorders(CellRangeAddress range, BorderStyle borderType, Extent extent) {
|
||||
public void drawBorders(CellRangeAddress range, BorderStyle borderType, BorderExtent extent) {
|
||||
switch (extent) {
|
||||
case NONE:
|
||||
removeBorders(range);
|
||||
break;
|
||||
case ALL:
|
||||
drawHorizontalBorders(range, borderType, Extent.ALL);
|
||||
drawVerticalBorders(range, borderType, Extent.ALL);
|
||||
drawHorizontalBorders(range, borderType, BorderExtent.ALL);
|
||||
drawVerticalBorders(range, borderType, BorderExtent.ALL);
|
||||
break;
|
||||
case INSIDE:
|
||||
drawHorizontalBorders(range, borderType, Extent.INSIDE);
|
||||
drawVerticalBorders(range, borderType, Extent.INSIDE);
|
||||
drawHorizontalBorders(range, borderType, BorderExtent.INSIDE);
|
||||
drawVerticalBorders(range, borderType, BorderExtent.INSIDE);
|
||||
break;
|
||||
case OUTSIDE:
|
||||
drawOutsideBorders(range, borderType, Extent.ALL);
|
||||
drawOutsideBorders(range, borderType, BorderExtent.ALL);
|
||||
break;
|
||||
case TOP:
|
||||
drawTopBorder(range, borderType);
|
||||
@ -222,22 +225,22 @@ public final class PropertyTemplate {
|
||||
drawRightBorder(range, borderType);
|
||||
break;
|
||||
case HORIZONTAL:
|
||||
drawHorizontalBorders(range, borderType, Extent.ALL);
|
||||
drawHorizontalBorders(range, borderType, BorderExtent.ALL);
|
||||
break;
|
||||
case INSIDE_HORIZONTAL:
|
||||
drawHorizontalBorders(range, borderType, Extent.INSIDE);
|
||||
drawHorizontalBorders(range, borderType, BorderExtent.INSIDE);
|
||||
break;
|
||||
case OUTSIDE_HORIZONTAL:
|
||||
drawOutsideBorders(range, borderType, Extent.HORIZONTAL);
|
||||
drawOutsideBorders(range, borderType, BorderExtent.HORIZONTAL);
|
||||
break;
|
||||
case VERTICAL:
|
||||
drawVerticalBorders(range, borderType, Extent.ALL);
|
||||
drawVerticalBorders(range, borderType, BorderExtent.ALL);
|
||||
break;
|
||||
case INSIDE_VERTICAL:
|
||||
drawVerticalBorders(range, borderType, Extent.INSIDE);
|
||||
drawVerticalBorders(range, borderType, BorderExtent.INSIDE);
|
||||
break;
|
||||
case OUTSIDE_VERTICAL:
|
||||
drawOutsideBorders(range, borderType, Extent.VERTICAL);
|
||||
drawOutsideBorders(range, borderType, BorderExtent.VERTICAL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -250,9 +253,9 @@ public final class PropertyTemplate {
|
||||
* @param range range of cells on which borders are drawn.
|
||||
* @param borderType Type of border to draw.
|
||||
* @param color Color index from {@link IndexedColors} used to draw the borders.
|
||||
* @param extent Extent of the borders to be applied.
|
||||
* @param extent BorderExtent of the borders to be applied.
|
||||
*/
|
||||
public void drawBorders(CellRangeAddress range, BorderStyle borderType, short color, Extent extent) {
|
||||
public void drawBorders(CellRangeAddress range, BorderStyle borderType, short color, BorderExtent extent) {
|
||||
drawBorders(range, borderType, extent);
|
||||
if (borderType != BorderStyle.NONE) {
|
||||
drawBorderColors(range, color, extent);
|
||||
@ -350,30 +353,30 @@ public final class PropertyTemplate {
|
||||
*
|
||||
* @param range range of cells on which borders are drawn.
|
||||
* @param borderType Type of border to draw.
|
||||
* @param extent Extent of the borders to be applied. Valid Values are:
|
||||
* @param extent BorderExtent of the borders to be applied. Valid Values are:
|
||||
* <ul>
|
||||
* <li>Extent.ALL</li>
|
||||
* <li>Extent.HORIZONTAL</li>
|
||||
* <li>Extent.VERTICAL</li>
|
||||
* </ul>
|
||||
*/
|
||||
private void drawOutsideBorders(CellRangeAddress range, BorderStyle borderType, Extent extent) {
|
||||
private void drawOutsideBorders(CellRangeAddress range, BorderStyle borderType, BorderExtent extent) {
|
||||
switch (extent) {
|
||||
case ALL:
|
||||
case HORIZONTAL:
|
||||
case VERTICAL:
|
||||
if (extent == Extent.ALL || extent == Extent.HORIZONTAL) {
|
||||
if (extent == BorderExtent.ALL || extent == BorderExtent.HORIZONTAL) {
|
||||
drawTopBorder(range, borderType);
|
||||
drawBottomBorder(range, borderType);
|
||||
}
|
||||
if (extent == Extent.ALL || extent == Extent.VERTICAL) {
|
||||
if (extent == BorderExtent.ALL || extent == BorderExtent.VERTICAL) {
|
||||
drawLeftBorder(range, borderType);
|
||||
drawRightBorder(range, borderType);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Unsupported PropertyTemplate.Extent, valid Extents are ALL, HORIZONTAL, and VERTICAL");
|
||||
"Illegal BorderExtent. Allowed: ALL, HORIZONTAL, and VERTICAL");
|
||||
}
|
||||
}
|
||||
|
||||
@ -384,13 +387,13 @@ public final class PropertyTemplate {
|
||||
*
|
||||
* @param range range of cells on which borders are drawn.
|
||||
* @param borderType Type of border to draw.
|
||||
* @param extent Extent of the borders to be applied. Valid Values are:
|
||||
* @param extent BorderExtent of the borders to be applied. Valid Values are:
|
||||
* <ul>
|
||||
* <li>Extent.ALL</li>
|
||||
* <li>Extent.INSIDE</li>
|
||||
* </ul>
|
||||
*/
|
||||
private void drawHorizontalBorders(CellRangeAddress range, BorderStyle borderType, Extent extent) {
|
||||
private void drawHorizontalBorders(CellRangeAddress range, BorderStyle borderType, BorderExtent extent) {
|
||||
switch (extent) {
|
||||
case ALL:
|
||||
case INSIDE:
|
||||
@ -400,17 +403,16 @@ public final class PropertyTemplate {
|
||||
int lastCol = range.getLastColumn();
|
||||
for (int i = firstRow; i <= lastRow; i++) {
|
||||
CellRangeAddress row = new CellRangeAddress(i, i, firstCol, lastCol);
|
||||
if (extent == Extent.ALL || i > firstRow) {
|
||||
if (extent == BorderExtent.ALL || i > firstRow) {
|
||||
drawTopBorder(row, borderType);
|
||||
}
|
||||
if (extent == Extent.ALL || i < lastRow) {
|
||||
if (extent == BorderExtent.ALL || i < lastRow) {
|
||||
drawBottomBorder(row, borderType);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Unsupported PropertyTemplate.Extent, valid Extents are ALL and INSIDE");
|
||||
throw new IllegalArgumentException("Illegal BorderExtent. Allowed: ALL and INSIDE");
|
||||
}
|
||||
}
|
||||
|
||||
@ -421,13 +423,13 @@ public final class PropertyTemplate {
|
||||
*
|
||||
* @param range range of cells on which borders are drawn.
|
||||
* @param borderType Type of border to draw.
|
||||
* @param extent Extent of the borders to be applied. Valid Values are:
|
||||
* @param extent BorderExtent of the borders to be applied. Valid Values are:
|
||||
* <ul>
|
||||
* <li>Extent.ALL</li>
|
||||
* <li>Extent.INSIDE</li>
|
||||
* </ul>
|
||||
*/
|
||||
private void drawVerticalBorders(CellRangeAddress range, BorderStyle borderType, Extent extent) {
|
||||
private void drawVerticalBorders(CellRangeAddress range, BorderStyle borderType, BorderExtent extent) {
|
||||
switch (extent) {
|
||||
case ALL:
|
||||
case INSIDE:
|
||||
@ -437,22 +439,21 @@ public final class PropertyTemplate {
|
||||
int lastCol = range.getLastColumn();
|
||||
for (int i = firstCol; i <= lastCol; i++) {
|
||||
CellRangeAddress row = new CellRangeAddress(firstRow, lastRow, i, i);
|
||||
if (extent == Extent.ALL || i > firstCol) {
|
||||
if (extent == BorderExtent.ALL || i > firstCol) {
|
||||
drawLeftBorder(row, borderType);
|
||||
}
|
||||
if (extent == Extent.ALL || i < lastCol) {
|
||||
if (extent == BorderExtent.ALL || i < lastCol) {
|
||||
drawRightBorder(row, borderType);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Unsupported PropertyTemplate.Extent, valid Extents are ALL and INSIDE");
|
||||
throw new IllegalArgumentException("Illegal BorderExtent. Allowed: ALL and INSIDE");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all border properties from this PropertyTemplate for the
|
||||
* Removes all border properties from this BorderPropertyTemplate for the
|
||||
* specified range.
|
||||
*
|
||||
* @param range - range of cells to remove borders.
|
||||
@ -502,23 +503,23 @@ public final class PropertyTemplate {
|
||||
*
|
||||
* @param range range of cells on which colors are set.
|
||||
* @param color Color index from {@link IndexedColors} used to draw the borders.
|
||||
* @param extent Extent of the borders for which colors are set.
|
||||
* @param extent BorderExtent of the borders for which colors are set.
|
||||
*/
|
||||
public void drawBorderColors(CellRangeAddress range, short color, Extent extent) {
|
||||
public void drawBorderColors(CellRangeAddress range, short color, BorderExtent extent) {
|
||||
switch (extent) {
|
||||
case NONE:
|
||||
removeBorderColors(range);
|
||||
break;
|
||||
case ALL:
|
||||
drawHorizontalBorderColors(range, color, Extent.ALL);
|
||||
drawVerticalBorderColors(range, color, Extent.ALL);
|
||||
drawHorizontalBorderColors(range, color, BorderExtent.ALL);
|
||||
drawVerticalBorderColors(range, color, BorderExtent.ALL);
|
||||
break;
|
||||
case INSIDE:
|
||||
drawHorizontalBorderColors(range, color, Extent.INSIDE);
|
||||
drawVerticalBorderColors(range, color, Extent.INSIDE);
|
||||
drawHorizontalBorderColors(range, color, BorderExtent.INSIDE);
|
||||
drawVerticalBorderColors(range, color, BorderExtent.INSIDE);
|
||||
break;
|
||||
case OUTSIDE:
|
||||
drawOutsideBorderColors(range, color, Extent.ALL);
|
||||
drawOutsideBorderColors(range, color, BorderExtent.ALL);
|
||||
break;
|
||||
case TOP:
|
||||
drawTopBorderColor(range, color);
|
||||
@ -533,22 +534,22 @@ public final class PropertyTemplate {
|
||||
drawRightBorderColor(range, color);
|
||||
break;
|
||||
case HORIZONTAL:
|
||||
drawHorizontalBorderColors(range, color, Extent.ALL);
|
||||
drawHorizontalBorderColors(range, color, BorderExtent.ALL);
|
||||
break;
|
||||
case INSIDE_HORIZONTAL:
|
||||
drawHorizontalBorderColors(range, color, Extent.INSIDE);
|
||||
drawHorizontalBorderColors(range, color, BorderExtent.INSIDE);
|
||||
break;
|
||||
case OUTSIDE_HORIZONTAL:
|
||||
drawOutsideBorderColors(range, color, Extent.HORIZONTAL);
|
||||
drawOutsideBorderColors(range, color, BorderExtent.HORIZONTAL);
|
||||
break;
|
||||
case VERTICAL:
|
||||
drawVerticalBorderColors(range, color, Extent.ALL);
|
||||
drawVerticalBorderColors(range, color, BorderExtent.ALL);
|
||||
break;
|
||||
case INSIDE_VERTICAL:
|
||||
drawVerticalBorderColors(range, color, Extent.INSIDE);
|
||||
drawVerticalBorderColors(range, color, BorderExtent.INSIDE);
|
||||
break;
|
||||
case OUTSIDE_VERTICAL:
|
||||
drawOutsideBorderColors(range, color, Extent.VERTICAL);
|
||||
drawOutsideBorderColors(range, color, BorderExtent.VERTICAL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -566,7 +567,7 @@ public final class PropertyTemplate {
|
||||
int firstCol = range.getFirstColumn();
|
||||
int lastCol = range.getLastColumn();
|
||||
for (int i = firstCol; i <= lastCol; i++) {
|
||||
// if BORDER_TOP is not set on PropertyTemplate, make a thin border so that there's something to color
|
||||
// if BORDER_TOP is not set on BorderPropertyTemplate, make a thin border so that there's something to color
|
||||
if (getTemplateProperty(row, i, CellUtil.BORDER_TOP) == null) {
|
||||
drawTopBorder(new CellRangeAddress(row, row, i, i), BorderStyle.THIN);
|
||||
}
|
||||
@ -587,7 +588,7 @@ public final class PropertyTemplate {
|
||||
int firstCol = range.getFirstColumn();
|
||||
int lastCol = range.getLastColumn();
|
||||
for (int i = firstCol; i <= lastCol; i++) {
|
||||
// if BORDER_BOTTOM is not set on PropertyTemplate, make a thin border so that there's something to color
|
||||
// if BORDER_BOTTOM is not set on BorderPropertyTemplate, make a thin border so that there's something to color
|
||||
if (getTemplateProperty(row, i, CellUtil.BORDER_BOTTOM) == null) {
|
||||
drawBottomBorder(new CellRangeAddress(row, row, i, i), BorderStyle.THIN);
|
||||
}
|
||||
@ -608,7 +609,7 @@ public final class PropertyTemplate {
|
||||
int lastRow = range.getLastRow();
|
||||
int col = range.getFirstColumn();
|
||||
for (int i = firstRow; i <= lastRow; i++) {
|
||||
// if BORDER_LEFT is not set on PropertyTemplate, make a thin border so that there's something to color
|
||||
// if BORDER_LEFT is not set on BorderPropertyTemplate, make a thin border so that there's something to color
|
||||
if (getTemplateProperty(i, col, CellUtil.BORDER_LEFT) == null) {
|
||||
drawLeftBorder(new CellRangeAddress(i, i, col, col), BorderStyle.THIN);
|
||||
}
|
||||
@ -630,7 +631,7 @@ public final class PropertyTemplate {
|
||||
int lastRow = range.getLastRow();
|
||||
int col = range.getLastColumn();
|
||||
for (int i = firstRow; i <= lastRow; i++) {
|
||||
// if BORDER_RIGHT is not set on PropertyTemplate, make a thin border so that there's something to color
|
||||
// if BORDER_RIGHT is not set on BorderPropertyTemplate, make a thin border so that there's something to color
|
||||
if (getTemplateProperty(i, col, CellUtil.BORDER_RIGHT) == null) {
|
||||
drawRightBorder(new CellRangeAddress(i, i, col, col), BorderStyle.THIN);
|
||||
}
|
||||
@ -645,30 +646,30 @@ public final class PropertyTemplate {
|
||||
*
|
||||
* @param range range of cells on which colors are set.
|
||||
* @param color Color index from {@link IndexedColors} used to draw the borders.
|
||||
* @param extent Extent of the borders for which colors are set. Valid Values are:
|
||||
* @param extent BorderExtent of the borders for which colors are set. Valid Values are:
|
||||
* <ul>
|
||||
* <li>Extent.ALL</li>
|
||||
* <li>Extent.HORIZONTAL</li>
|
||||
* <li>Extent.VERTICAL</li>
|
||||
* </ul>
|
||||
*/
|
||||
private void drawOutsideBorderColors(CellRangeAddress range, short color, Extent extent) {
|
||||
private void drawOutsideBorderColors(CellRangeAddress range, short color, BorderExtent extent) {
|
||||
switch (extent) {
|
||||
case ALL:
|
||||
case HORIZONTAL:
|
||||
case VERTICAL:
|
||||
if (extent == Extent.ALL || extent == Extent.HORIZONTAL) {
|
||||
if (extent == BorderExtent.ALL || extent == BorderExtent.HORIZONTAL) {
|
||||
drawTopBorderColor(range, color);
|
||||
drawBottomBorderColor(range, color);
|
||||
}
|
||||
if (extent == Extent.ALL || extent == Extent.VERTICAL) {
|
||||
if (extent == BorderExtent.ALL || extent == BorderExtent.VERTICAL) {
|
||||
drawLeftBorderColor(range, color);
|
||||
drawRightBorderColor(range, color);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Unsupported PropertyTemplate.Extent, valid Extents are ALL, HORIZONTAL, and VERTICAL");
|
||||
"Illegal BorderExtent. Allowed: ALL, HORIZONTAL, and VERTICAL");
|
||||
}
|
||||
}
|
||||
|
||||
@ -679,13 +680,13 @@ public final class PropertyTemplate {
|
||||
*
|
||||
* @param range range of cells on which colors are set.
|
||||
* @param color Color index from {@link IndexedColors} used to draw the borders.
|
||||
* @param extent Extent of the borders for which colors are set. Valid Values are:
|
||||
* @param extent BorderExtent of the borders for which colors are set. Valid Values are:
|
||||
* <ul>
|
||||
* <li>Extent.ALL</li>
|
||||
* <li>Extent.INSIDE</li>
|
||||
* </ul>
|
||||
*/
|
||||
private void drawHorizontalBorderColors(CellRangeAddress range, short color, Extent extent) {
|
||||
private void drawHorizontalBorderColors(CellRangeAddress range, short color, BorderExtent extent) {
|
||||
switch (extent) {
|
||||
case ALL:
|
||||
case INSIDE:
|
||||
@ -695,17 +696,16 @@ public final class PropertyTemplate {
|
||||
int lastCol = range.getLastColumn();
|
||||
for (int i = firstRow; i <= lastRow; i++) {
|
||||
CellRangeAddress row = new CellRangeAddress(i, i, firstCol, lastCol);
|
||||
if (extent == Extent.ALL || i > firstRow) {
|
||||
if (extent == BorderExtent.ALL || i > firstRow) {
|
||||
drawTopBorderColor(row, color);
|
||||
}
|
||||
if (extent == Extent.ALL || i < lastRow) {
|
||||
if (extent == BorderExtent.ALL || i < lastRow) {
|
||||
drawBottomBorderColor(row, color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Unsupported PropertyTemplate.Extent, valid Extents are ALL and INSIDE");
|
||||
throw new IllegalArgumentException("Illegal BorderExtent. Allowed: ALL and INSIDE");
|
||||
}
|
||||
}
|
||||
|
||||
@ -716,13 +716,13 @@ public final class PropertyTemplate {
|
||||
*
|
||||
* @param range range of cells on which colors are set.
|
||||
* @param color Color index from {@link IndexedColors} used to draw the borders.
|
||||
* @param extent Extent of the borders for which colors are set. Valid Values are:
|
||||
* @param extent BorderExtent of the borders for which colors are set. Valid Values are:
|
||||
* <ul>
|
||||
* <li>Extent.ALL</li>
|
||||
* <li>Extent.INSIDE</li>
|
||||
* </ul>
|
||||
*/
|
||||
private void drawVerticalBorderColors(CellRangeAddress range, short color, Extent extent) {
|
||||
private void drawVerticalBorderColors(CellRangeAddress range, short color, BorderExtent extent) {
|
||||
switch (extent) {
|
||||
case ALL:
|
||||
case INSIDE:
|
||||
@ -732,22 +732,21 @@ public final class PropertyTemplate {
|
||||
int lastCol = range.getLastColumn();
|
||||
for (int i = firstCol; i <= lastCol; i++) {
|
||||
CellRangeAddress row = new CellRangeAddress(firstRow, lastRow, i, i);
|
||||
if (extent == Extent.ALL || i > firstCol) {
|
||||
if (extent == BorderExtent.ALL || i > firstCol) {
|
||||
drawLeftBorderColor(row, color);
|
||||
}
|
||||
if (extent == Extent.ALL || i < lastCol) {
|
||||
if (extent == BorderExtent.ALL || i < lastCol) {
|
||||
drawRightBorderColor(row, color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Unsupported PropertyTemplate.Extent, valid Extents are ALL and INSIDE");
|
||||
throw new IllegalArgumentException("Illegal BorderExtent. Allowed: ALL and INSIDE");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all border properties from this PropertyTemplate for the
|
||||
* Removes all border properties from this BorderPropertyTemplate for the
|
||||
* specified range.
|
||||
*
|
||||
* @param range - range of cells to remove borders.
|
||||
@ -765,7 +764,7 @@ public final class PropertyTemplate {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a property to this PropertyTemplate for a given cell
|
||||
* Adds a property to this BorderPropertyTemplate for a given cell
|
||||
*
|
||||
* @param row
|
||||
* @param col
|
||||
@ -783,7 +782,7 @@ public final class PropertyTemplate {
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a set of properties from this PropertyTemplate for a
|
||||
* Removes a set of properties from this BorderPropertyTemplate for a
|
||||
* given cell
|
||||
*
|
||||
* @param row the row index of the cell to remove properties from
|
@ -29,69 +29,69 @@ import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.util.PropertyTemplate.Extent;
|
||||
import org.apache.poi.ss.util.BorderPropertyTemplate.BorderExtent;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests Spreadsheet PropertyTemplate
|
||||
* Tests Spreadsheet BorderPropertyTemplate
|
||||
*
|
||||
* @see org.apache.poi.ss.util.PropertyTemplate
|
||||
* @see org.apache.poi.ss.util.BorderPropertyTemplate
|
||||
*/
|
||||
public final class TestPropertyTemplate {
|
||||
public final class TestBorderPropertyTemplate {
|
||||
@Test
|
||||
public void getNumBorders() throws IOException {
|
||||
CellRangeAddress a1 = new CellRangeAddress(0, 0, 0, 0);
|
||||
PropertyTemplate pt = new PropertyTemplate();
|
||||
BorderPropertyTemplate pt = new BorderPropertyTemplate();
|
||||
|
||||
pt.drawBorders(a1, BorderStyle.THIN, Extent.TOP);
|
||||
pt.drawBorders(a1, BorderStyle.THIN, BorderExtent.TOP);
|
||||
assertEquals(1, pt.getNumBorders(0, 0));
|
||||
|
||||
pt.drawBorders(a1, BorderStyle.MEDIUM, Extent.BOTTOM);
|
||||
pt.drawBorders(a1, BorderStyle.MEDIUM, BorderExtent.BOTTOM);
|
||||
assertEquals(2, pt.getNumBorders(0, 0));
|
||||
|
||||
pt.drawBorders(a1, BorderStyle.MEDIUM, Extent.NONE);
|
||||
pt.drawBorders(a1, BorderStyle.MEDIUM, BorderExtent.NONE);
|
||||
assertEquals(0, pt.getNumBorders(0, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNumBorderColors() throws IOException {
|
||||
CellRangeAddress a1 = new CellRangeAddress(0, 0, 0, 0);
|
||||
PropertyTemplate pt = new PropertyTemplate();
|
||||
BorderPropertyTemplate pt = new BorderPropertyTemplate();
|
||||
|
||||
pt.drawBorderColors(a1, IndexedColors.RED.getIndex(), Extent.TOP);
|
||||
pt.drawBorderColors(a1, IndexedColors.RED.getIndex(), BorderExtent.TOP);
|
||||
assertEquals(1, pt.getNumBorderColors(0, 0));
|
||||
|
||||
pt.drawBorderColors(a1, IndexedColors.RED.getIndex(), Extent.BOTTOM);
|
||||
pt.drawBorderColors(a1, IndexedColors.RED.getIndex(), BorderExtent.BOTTOM);
|
||||
assertEquals(2, pt.getNumBorderColors(0, 0));
|
||||
|
||||
pt.drawBorderColors(a1, IndexedColors.RED.getIndex(), Extent.NONE);
|
||||
pt.drawBorderColors(a1, IndexedColors.RED.getIndex(), BorderExtent.NONE);
|
||||
assertEquals(0, pt.getNumBorderColors(0, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTemplateProperties() throws IOException {
|
||||
CellRangeAddress a1 = new CellRangeAddress(0, 0, 0, 0);
|
||||
PropertyTemplate pt = new PropertyTemplate();
|
||||
BorderPropertyTemplate pt = new BorderPropertyTemplate();
|
||||
|
||||
pt.drawBorders(a1, BorderStyle.THIN, Extent.TOP);
|
||||
pt.drawBorders(a1, BorderStyle.THIN, BorderExtent.TOP);
|
||||
assertThin(pt.getTemplateProperty(0, 0, CellUtil.BORDER_TOP));
|
||||
|
||||
pt.drawBorders(a1, BorderStyle.MEDIUM, Extent.BOTTOM);
|
||||
pt.drawBorders(a1, BorderStyle.MEDIUM, BorderExtent.BOTTOM);
|
||||
assertMedium(pt.getTemplateProperty(0, 0, CellUtil.BORDER_BOTTOM));
|
||||
|
||||
pt.drawBorderColors(a1, IndexedColors.RED.getIndex(), Extent.TOP);
|
||||
pt.drawBorderColors(a1, IndexedColors.RED.getIndex(), BorderExtent.TOP);
|
||||
assertRed(pt.getTemplateProperty(0, 0, CellUtil.TOP_BORDER_COLOR));
|
||||
|
||||
pt.drawBorderColors(a1, IndexedColors.BLUE.getIndex(), Extent.BOTTOM);
|
||||
pt.drawBorderColors(a1, IndexedColors.BLUE.getIndex(), BorderExtent.BOTTOM);
|
||||
assertBlue(pt.getTemplateProperty(0, 0, CellUtil.BOTTOM_BORDER_COLOR));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drawBorders() throws IOException {
|
||||
CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
|
||||
PropertyTemplate pt = new PropertyTemplate();
|
||||
BorderPropertyTemplate pt = new BorderPropertyTemplate();
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.THIN, Extent.ALL);
|
||||
pt.drawBorders(a1c3, BorderStyle.THIN, BorderExtent.ALL);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
assertEquals(4, pt.getNumBorders(i, j));
|
||||
@ -102,7 +102,7 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.OUTSIDE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, BorderExtent.OUTSIDE);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
assertEquals(4, pt.getNumBorders(i, j));
|
||||
@ -161,14 +161,14 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
assertEquals(0, pt.getNumBorders(i, j));
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.TOP);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, BorderExtent.TOP);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
if (i == 0) {
|
||||
@ -180,8 +180,8 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.BOTTOM);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, BorderExtent.BOTTOM);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
if (i == 2) {
|
||||
@ -193,8 +193,8 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.LEFT);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, BorderExtent.LEFT);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
if (j == 0) {
|
||||
@ -206,8 +206,8 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.RIGHT);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, BorderExtent.RIGHT);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
if (j == 2) {
|
||||
@ -219,8 +219,8 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.HORIZONTAL);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, BorderExtent.HORIZONTAL);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
assertEquals(2, pt.getNumBorders(i, j));
|
||||
@ -229,8 +229,8 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.INSIDE_HORIZONTAL);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, BorderExtent.INSIDE_HORIZONTAL);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
if (i == 0) {
|
||||
@ -247,8 +247,8 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.OUTSIDE_HORIZONTAL);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, BorderExtent.OUTSIDE_HORIZONTAL);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
if (i == 0) {
|
||||
@ -263,8 +263,8 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.VERTICAL);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, BorderExtent.VERTICAL);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
assertEquals(2, pt.getNumBorders(i, j));
|
||||
@ -273,8 +273,8 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.INSIDE_VERTICAL);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, BorderExtent.INSIDE_VERTICAL);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
if (j == 0) {
|
||||
@ -291,8 +291,8 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.OUTSIDE_VERTICAL);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, BorderExtent.OUTSIDE_VERTICAL);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
if (j == 0) {
|
||||
@ -311,9 +311,9 @@ public final class TestPropertyTemplate {
|
||||
@Test
|
||||
public void drawBorderColors() throws IOException {
|
||||
CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
|
||||
PropertyTemplate pt = new PropertyTemplate();
|
||||
BorderPropertyTemplate pt = new BorderPropertyTemplate();
|
||||
|
||||
pt.drawBorderColors(a1c3, IndexedColors.RED.getIndex(), Extent.ALL);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.RED.getIndex(), BorderExtent.ALL);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
CellAddress addr = new CellAddress(i, j);
|
||||
@ -327,7 +327,7 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.OUTSIDE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.OUTSIDE);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
assertEquals(4, pt.getNumBorders(i, j));
|
||||
@ -387,8 +387,8 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
assertEquals(0, pt.getNumBorders(i, j));
|
||||
@ -396,7 +396,7 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.TOP);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.TOP);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
if (i == 0) {
|
||||
@ -410,9 +410,9 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.BOTTOM);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.BOTTOM);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
if (i == 2) {
|
||||
@ -426,9 +426,9 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.LEFT);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.LEFT);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
if (j == 0) {
|
||||
@ -442,9 +442,9 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.RIGHT);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.RIGHT);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
if (j == 2) {
|
||||
@ -458,9 +458,9 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.HORIZONTAL);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.HORIZONTAL);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
assertEquals(2, pt.getNumBorders(i, j));
|
||||
@ -470,9 +470,9 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.INSIDE_HORIZONTAL);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.INSIDE_HORIZONTAL);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
if (i == 0) {
|
||||
@ -492,9 +492,9 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.OUTSIDE_HORIZONTAL);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.OUTSIDE_HORIZONTAL);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
if (i == 0) {
|
||||
@ -512,9 +512,9 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.VERTICAL);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.VERTICAL);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
assertEquals(2, pt.getNumBorders(i, j));
|
||||
@ -524,9 +524,9 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.INSIDE_VERTICAL);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.INSIDE_VERTICAL);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
if (j == 0) {
|
||||
@ -546,9 +546,9 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.OUTSIDE_VERTICAL);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
|
||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.OUTSIDE_VERTICAL);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
if (j == 0) {
|
||||
@ -570,9 +570,9 @@ public final class TestPropertyTemplate {
|
||||
@Test
|
||||
public void drawBordersWithColors() throws IOException {
|
||||
CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
|
||||
PropertyTemplate pt = new PropertyTemplate();
|
||||
BorderPropertyTemplate pt = new BorderPropertyTemplate();
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, IndexedColors.RED.getIndex(), Extent.ALL);
|
||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, IndexedColors.RED.getIndex(), BorderExtent.ALL);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
assertEquals(4, pt.getNumBorders(i, j));
|
||||
@ -588,8 +588,8 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, IndexedColors.RED.getIndex(), Extent.ALL);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||
pt.drawBorders(a1c3, BorderStyle.NONE, IndexedColors.RED.getIndex(), BorderExtent.ALL);
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
for (int j = 0; j <= 2; j++) {
|
||||
assertEquals(4, pt.getNumBorders(i, j));
|
||||
@ -606,11 +606,11 @@ public final class TestPropertyTemplate {
|
||||
public void applyBorders() throws IOException {
|
||||
CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
|
||||
CellRangeAddress b2 = new CellRangeAddress(1, 1, 1, 1);
|
||||
PropertyTemplate pt = new PropertyTemplate();
|
||||
BorderPropertyTemplate pt = new BorderPropertyTemplate();
|
||||
Workbook wb = new HSSFWorkbook();
|
||||
Sheet sheet = wb.createSheet();
|
||||
|
||||
pt.drawBorders(a1c3, BorderStyle.THIN, IndexedColors.RED.getIndex(), Extent.ALL);
|
||||
pt.drawBorders(a1c3, BorderStyle.THIN, IndexedColors.RED.getIndex(), BorderExtent.ALL);
|
||||
pt.applyBorders(sheet);
|
||||
|
||||
for (Row row: sheet) {
|
||||
@ -631,7 +631,7 @@ public final class TestPropertyTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
pt.drawBorders(b2, BorderStyle.NONE, Extent.ALL);
|
||||
pt.drawBorders(b2, BorderStyle.NONE, BorderExtent.ALL);
|
||||
pt.applyBorders(sheet);
|
||||
|
||||
for (Row row: sheet) {
|
Loading…
Reference in New Issue
Block a user