mirror of https://github.com/apache/poi.git
replace usage of all deprecated CellStyle.BORDER_* constants with BorderStyle.*
update PropertyTemplate functions to require enum instead of short borderType git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ss_border_property_template@1747868 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ba1446c4f7
commit
a0e1e136b1
|
@ -23,13 +23,14 @@ import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
import org.apache.poi.ss.usermodel.BorderStyle;
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
import org.apache.poi.ss.usermodel.CellStyle;
|
|
||||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.ss.util.PropertyTemplate;
|
import org.apache.poi.ss.util.PropertyTemplate;
|
||||||
|
import org.apache.poi.ss.util.PropertyTemplate.Extent;
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
|
||||||
|
@ -66,29 +67,21 @@ public class DrawingBorders {
|
||||||
|
|
||||||
// draw borders (three 3x3 grids)
|
// draw borders (three 3x3 grids)
|
||||||
PropertyTemplate pt = new PropertyTemplate();
|
PropertyTemplate pt = new PropertyTemplate();
|
||||||
|
|
||||||
// #1) these borders will all be medium in default color
|
// #1) these borders will all be medium in default color
|
||||||
pt.drawBorders(new CellRangeAddress(1, 3, 1, 3),
|
pt.drawBorders(new CellRangeAddress(1, 3, 1, 3), BorderStyle.MEDIUM, Extent.ALL);
|
||||||
CellStyle.BORDER_MEDIUM, PropertyTemplate.Extent.ALL);
|
|
||||||
// #2) these cells will have medium outside borders and thin inside borders
|
// #2) these cells will have medium outside borders and thin inside borders
|
||||||
pt.drawBorders(new CellRangeAddress(5, 7, 1, 3),
|
pt.drawBorders(new CellRangeAddress(5, 7, 1, 3), BorderStyle.MEDIUM, Extent.OUTSIDE);
|
||||||
CellStyle.BORDER_MEDIUM, PropertyTemplate.Extent.OUTSIDE);
|
pt.drawBorders(new CellRangeAddress(5, 7, 1, 3), BorderStyle.THIN, Extent.INSIDE);
|
||||||
pt.drawBorders(new CellRangeAddress(5, 7, 1, 3), CellStyle.BORDER_THIN,
|
|
||||||
PropertyTemplate.Extent.INSIDE);
|
|
||||||
// #3) these cells will all be medium weight with different colors for the
|
// #3) these cells will all be medium weight with different colors for the
|
||||||
// outside, inside horizontal, and inside vertical borders. The center
|
// outside, inside horizontal, and inside vertical borders. The center
|
||||||
// cell will have no borders.
|
// cell will have no borders.
|
||||||
pt.drawBorders(new CellRangeAddress(9, 11, 1, 3),
|
pt.drawBorders(new CellRangeAddress(9, 11, 1, 3), BorderStyle.MEDIUM, IndexedColors.RED.getIndex(), Extent.OUTSIDE);
|
||||||
CellStyle.BORDER_MEDIUM, IndexedColors.RED.getIndex(),
|
pt.drawBorders(new CellRangeAddress(9, 11, 1, 3), BorderStyle.MEDIUM, IndexedColors.BLUE.getIndex(), Extent.INSIDE_VERTICAL);
|
||||||
PropertyTemplate.Extent.OUTSIDE);
|
pt.drawBorders(new CellRangeAddress(9, 11, 1, 3), BorderStyle.MEDIUM, IndexedColors.GREEN.getIndex(), Extent.INSIDE_HORIZONTAL);
|
||||||
pt.drawBorders(new CellRangeAddress(9, 11, 1, 3),
|
pt.drawBorders(new CellRangeAddress(10, 10, 2, 2), BorderStyle.NONE, Extent.ALL);
|
||||||
CellStyle.BORDER_MEDIUM, IndexedColors.BLUE.getIndex(),
|
|
||||||
PropertyTemplate.Extent.INSIDE_VERTICAL);
|
|
||||||
pt.drawBorders(new CellRangeAddress(9, 11, 1, 3),
|
|
||||||
CellStyle.BORDER_MEDIUM, IndexedColors.GREEN.getIndex(),
|
|
||||||
PropertyTemplate.Extent.INSIDE_HORIZONTAL);
|
|
||||||
pt.drawBorders(new CellRangeAddress(10, 10, 2, 2),
|
|
||||||
CellStyle.BORDER_NONE,
|
|
||||||
PropertyTemplate.Extent.ALL);
|
|
||||||
|
|
||||||
// apply borders to sheet
|
// apply borders to sheet
|
||||||
pt.applyBorders(sh1);
|
pt.applyBorders(sh1);
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
import org.apache.poi.ss.SpreadsheetVersion;
|
import org.apache.poi.ss.SpreadsheetVersion;
|
||||||
|
import org.apache.poi.ss.usermodel.BorderStyle;
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
import org.apache.poi.ss.usermodel.CellStyle;
|
import org.apache.poi.ss.usermodel.CellStyle;
|
||||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||||
|
@ -167,8 +168,7 @@ public final class PropertyTemplate {
|
||||||
* - {@link PropertyTemplate.Extent} of the borders to be
|
* - {@link PropertyTemplate.Extent} of the borders to be
|
||||||
* applied.
|
* applied.
|
||||||
*/
|
*/
|
||||||
public void drawBorders(CellRangeAddress range, short borderType,
|
public void drawBorders(CellRangeAddress range, BorderStyle borderType, Extent extent) {
|
||||||
Extent extent) {
|
|
||||||
switch (extent) {
|
switch (extent) {
|
||||||
case NONE:
|
case NONE:
|
||||||
removeBorders(range);
|
removeBorders(range);
|
||||||
|
@ -235,10 +235,10 @@ public final class PropertyTemplate {
|
||||||
* - {@link PropertyTemplate.Extent} of the borders to be
|
* - {@link PropertyTemplate.Extent} of the borders to be
|
||||||
* applied.
|
* applied.
|
||||||
*/
|
*/
|
||||||
public void drawBorders(CellRangeAddress range, short borderType,
|
public void drawBorders(CellRangeAddress range, BorderStyle borderType,
|
||||||
short color, Extent extent) {
|
short color, Extent extent) {
|
||||||
drawBorders(range, borderType, extent);
|
drawBorders(range, borderType, extent);
|
||||||
if (borderType != CellStyle.BORDER_NONE) {
|
if (borderType != BorderStyle.NONE) {
|
||||||
drawBorderColors(range, color, extent);
|
drawBorderColors(range, color, extent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,13 +255,13 @@ public final class PropertyTemplate {
|
||||||
* - Type of border to draw. Use BORDER_XXX constants in
|
* - Type of border to draw. Use BORDER_XXX constants in
|
||||||
* {@link CellStyle}.
|
* {@link CellStyle}.
|
||||||
*/
|
*/
|
||||||
private void drawTopBorder(CellRangeAddress range, short borderType) {
|
private void drawTopBorder(CellRangeAddress range, BorderStyle borderType) {
|
||||||
int row = range.getFirstRow();
|
int row = range.getFirstRow();
|
||||||
int firstCol = range.getFirstColumn();
|
int firstCol = range.getFirstColumn();
|
||||||
int lastCol = range.getLastColumn();
|
int lastCol = range.getLastColumn();
|
||||||
for (int i = firstCol; i <= lastCol; i++) {
|
for (int i = firstCol; i <= lastCol; i++) {
|
||||||
addProperty(row, i, CellUtil.BORDER_TOP, borderType);
|
addProperty(row, i, CellUtil.BORDER_TOP, borderType);
|
||||||
if (borderType == CellStyle.BORDER_NONE && row > 0) {
|
if (borderType == BorderStyle.NONE && row > 0) {
|
||||||
addProperty(row - 1, i, CellUtil.BORDER_BOTTOM, borderType);
|
addProperty(row - 1, i, CellUtil.BORDER_BOTTOM, borderType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,13 +279,13 @@ public final class PropertyTemplate {
|
||||||
* - Type of border to draw. Use BORDER_XXX constants in
|
* - Type of border to draw. Use BORDER_XXX constants in
|
||||||
* {@link CellStyle}.
|
* {@link CellStyle}.
|
||||||
*/
|
*/
|
||||||
private void drawBottomBorder(CellRangeAddress range, short borderType) {
|
private void drawBottomBorder(CellRangeAddress range, BorderStyle borderType) {
|
||||||
int row = range.getLastRow();
|
int row = range.getLastRow();
|
||||||
int firstCol = range.getFirstColumn();
|
int firstCol = range.getFirstColumn();
|
||||||
int lastCol = range.getLastColumn();
|
int lastCol = range.getLastColumn();
|
||||||
for (int i = firstCol; i <= lastCol; i++) {
|
for (int i = firstCol; i <= lastCol; i++) {
|
||||||
addProperty(row, i, CellUtil.BORDER_BOTTOM, borderType);
|
addProperty(row, i, CellUtil.BORDER_BOTTOM, borderType);
|
||||||
if (borderType == CellStyle.BORDER_NONE
|
if (borderType == BorderStyle.NONE
|
||||||
&& row < SpreadsheetVersion.EXCEL2007.getMaxRows() - 1) {
|
&& row < SpreadsheetVersion.EXCEL2007.getMaxRows() - 1) {
|
||||||
addProperty(row + 1, i, CellUtil.BORDER_TOP, borderType);
|
addProperty(row + 1, i, CellUtil.BORDER_TOP, borderType);
|
||||||
}
|
}
|
||||||
|
@ -304,13 +304,13 @@ public final class PropertyTemplate {
|
||||||
* - Type of border to draw. Use BORDER_XXX constants in
|
* - Type of border to draw. Use BORDER_XXX constants in
|
||||||
* {@link CellStyle}.
|
* {@link CellStyle}.
|
||||||
*/
|
*/
|
||||||
private void drawLeftBorder(CellRangeAddress range, short borderType) {
|
private void drawLeftBorder(CellRangeAddress range, BorderStyle borderType) {
|
||||||
int firstRow = range.getFirstRow();
|
int firstRow = range.getFirstRow();
|
||||||
int lastRow = range.getLastRow();
|
int lastRow = range.getLastRow();
|
||||||
int col = range.getFirstColumn();
|
int col = range.getFirstColumn();
|
||||||
for (int i = firstRow; i <= lastRow; i++) {
|
for (int i = firstRow; i <= lastRow; i++) {
|
||||||
addProperty(i, col, CellUtil.BORDER_LEFT, borderType);
|
addProperty(i, col, CellUtil.BORDER_LEFT, borderType);
|
||||||
if (borderType == CellStyle.BORDER_NONE && col > 0) {
|
if (borderType == BorderStyle.NONE && col > 0) {
|
||||||
addProperty(i, col - 1, CellUtil.BORDER_RIGHT, borderType);
|
addProperty(i, col - 1, CellUtil.BORDER_RIGHT, borderType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -328,13 +328,13 @@ public final class PropertyTemplate {
|
||||||
* - Type of border to draw. Use BORDER_XXX constants in
|
* - Type of border to draw. Use BORDER_XXX constants in
|
||||||
* {@link CellStyle}.
|
* {@link CellStyle}.
|
||||||
*/
|
*/
|
||||||
private void drawRightBorder(CellRangeAddress range, short borderType) {
|
private void drawRightBorder(CellRangeAddress range, BorderStyle borderType) {
|
||||||
int firstRow = range.getFirstRow();
|
int firstRow = range.getFirstRow();
|
||||||
int lastRow = range.getLastRow();
|
int lastRow = range.getLastRow();
|
||||||
int col = range.getLastColumn();
|
int col = range.getLastColumn();
|
||||||
for (int i = firstRow; i <= lastRow; i++) {
|
for (int i = firstRow; i <= lastRow; i++) {
|
||||||
addProperty(i, col, CellUtil.BORDER_RIGHT, borderType);
|
addProperty(i, col, CellUtil.BORDER_RIGHT, borderType);
|
||||||
if (borderType == CellStyle.BORDER_NONE
|
if (borderType == BorderStyle.NONE
|
||||||
&& col < SpreadsheetVersion.EXCEL2007.getMaxColumns() - 1) {
|
&& col < SpreadsheetVersion.EXCEL2007.getMaxColumns() - 1) {
|
||||||
addProperty(i, col + 1, CellUtil.BORDER_LEFT, borderType);
|
addProperty(i, col + 1, CellUtil.BORDER_LEFT, borderType);
|
||||||
}
|
}
|
||||||
|
@ -361,8 +361,7 @@ public final class PropertyTemplate {
|
||||||
* <li>CellBorder.Extent.VERTICAL</li>
|
* <li>CellBorder.Extent.VERTICAL</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
private void drawOutsideBorders(CellRangeAddress range, short borderType,
|
private void drawOutsideBorders(CellRangeAddress range, BorderStyle borderType, Extent extent) {
|
||||||
Extent extent) {
|
|
||||||
switch (extent) {
|
switch (extent) {
|
||||||
case ALL:
|
case ALL:
|
||||||
case HORIZONTAL:
|
case HORIZONTAL:
|
||||||
|
@ -401,8 +400,7 @@ public final class PropertyTemplate {
|
||||||
* <li>CellBorder.Extent.INSIDE</li>
|
* <li>CellBorder.Extent.INSIDE</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
private void drawHorizontalBorders(CellRangeAddress range, short borderType,
|
private void drawHorizontalBorders(CellRangeAddress range, BorderStyle borderType, Extent extent) {
|
||||||
Extent extent) {
|
|
||||||
switch (extent) {
|
switch (extent) {
|
||||||
case ALL:
|
case ALL:
|
||||||
case INSIDE:
|
case INSIDE:
|
||||||
|
@ -411,8 +409,7 @@ public final class PropertyTemplate {
|
||||||
int firstCol = range.getFirstColumn();
|
int firstCol = range.getFirstColumn();
|
||||||
int lastCol = range.getLastColumn();
|
int lastCol = range.getLastColumn();
|
||||||
for (int i = firstRow; i <= lastRow; i++) {
|
for (int i = firstRow; i <= lastRow; i++) {
|
||||||
CellRangeAddress row = new CellRangeAddress(i, i, firstCol,
|
CellRangeAddress row = new CellRangeAddress(i, i, firstCol, lastCol);
|
||||||
lastCol);
|
|
||||||
if (extent == Extent.ALL || i > firstRow) {
|
if (extent == Extent.ALL || i > firstRow) {
|
||||||
drawTopBorder(row, borderType);
|
drawTopBorder(row, borderType);
|
||||||
}
|
}
|
||||||
|
@ -446,8 +443,7 @@ public final class PropertyTemplate {
|
||||||
* <li>CellBorder.Extent.INSIDE</li>
|
* <li>CellBorder.Extent.INSIDE</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
private void drawVerticalBorders(CellRangeAddress range, short borderType,
|
private void drawVerticalBorders(CellRangeAddress range, BorderStyle borderType, Extent extent) {
|
||||||
Extent extent) {
|
|
||||||
switch (extent) {
|
switch (extent) {
|
||||||
case ALL:
|
case ALL:
|
||||||
case INSIDE:
|
case INSIDE:
|
||||||
|
@ -533,8 +529,7 @@ public final class PropertyTemplate {
|
||||||
* - {@link PropertyTemplate.Extent} of the borders for which
|
* - {@link PropertyTemplate.Extent} of the borders for which
|
||||||
* colors are set.
|
* colors are set.
|
||||||
*/
|
*/
|
||||||
public void drawBorderColors(CellRangeAddress range, short color,
|
public void drawBorderColors(CellRangeAddress range, short color, Extent extent) {
|
||||||
Extent extent) {
|
|
||||||
switch (extent) {
|
switch (extent) {
|
||||||
case NONE:
|
case NONE:
|
||||||
removeBorderColors(range);
|
removeBorderColors(range);
|
||||||
|
@ -600,9 +595,9 @@ public final class PropertyTemplate {
|
||||||
int firstCol = range.getFirstColumn();
|
int firstCol = range.getFirstColumn();
|
||||||
int lastCol = range.getLastColumn();
|
int lastCol = range.getLastColumn();
|
||||||
for (int i = firstCol; i <= lastCol; i++) {
|
for (int i = firstCol; i <= lastCol; i++) {
|
||||||
if (getTemplateProperty(row, i, CellUtil.BORDER_TOP) == 0) {
|
// if BORDER_TOP is not set on PropertyTemplate, make a thin border so that there's something to color
|
||||||
drawTopBorder(new CellRangeAddress(row, row, i, i),
|
if (getTemplateProperty(row, i, CellUtil.BORDER_TOP) == null) {
|
||||||
CellStyle.BORDER_THIN);
|
drawTopBorder(new CellRangeAddress(row, row, i, i), BorderStyle.THIN);
|
||||||
}
|
}
|
||||||
addProperty(row, i, CellUtil.TOP_BORDER_COLOR, color);
|
addProperty(row, i, CellUtil.TOP_BORDER_COLOR, color);
|
||||||
}
|
}
|
||||||
|
@ -625,9 +620,9 @@ public final class PropertyTemplate {
|
||||||
int firstCol = range.getFirstColumn();
|
int firstCol = range.getFirstColumn();
|
||||||
int lastCol = range.getLastColumn();
|
int lastCol = range.getLastColumn();
|
||||||
for (int i = firstCol; i <= lastCol; i++) {
|
for (int i = firstCol; i <= lastCol; i++) {
|
||||||
if (getTemplateProperty(row, i, CellUtil.BORDER_BOTTOM) == 0) {
|
// if BORDER_BOTTOM is not set on PropertyTemplate, make a thin border so that there's something to color
|
||||||
drawBottomBorder(new CellRangeAddress(row, row, i, i),
|
if (getTemplateProperty(row, i, CellUtil.BORDER_BOTTOM) == null) {
|
||||||
CellStyle.BORDER_THIN);
|
drawBottomBorder(new CellRangeAddress(row, row, i, i), BorderStyle.THIN);
|
||||||
}
|
}
|
||||||
addProperty(row, i, CellUtil.BOTTOM_BORDER_COLOR, color);
|
addProperty(row, i, CellUtil.BOTTOM_BORDER_COLOR, color);
|
||||||
}
|
}
|
||||||
|
@ -650,9 +645,9 @@ public final class PropertyTemplate {
|
||||||
int lastRow = range.getLastRow();
|
int lastRow = range.getLastRow();
|
||||||
int col = range.getFirstColumn();
|
int col = range.getFirstColumn();
|
||||||
for (int i = firstRow; i <= lastRow; i++) {
|
for (int i = firstRow; i <= lastRow; i++) {
|
||||||
if (getTemplateProperty(i, col, CellUtil.BORDER_LEFT) == 0) {
|
// if BORDER_LEFT is not set on PropertyTemplate, make a thin border so that there's something to color
|
||||||
drawLeftBorder(new CellRangeAddress(i, i, col, col),
|
if (getTemplateProperty(i, col, CellUtil.BORDER_LEFT) == null) {
|
||||||
CellStyle.BORDER_THIN);
|
drawLeftBorder(new CellRangeAddress(i, i, col, col), BorderStyle.THIN);
|
||||||
}
|
}
|
||||||
addProperty(i, col, CellUtil.LEFT_BORDER_COLOR, color);
|
addProperty(i, col, CellUtil.LEFT_BORDER_COLOR, color);
|
||||||
}
|
}
|
||||||
|
@ -676,9 +671,9 @@ public final class PropertyTemplate {
|
||||||
int lastRow = range.getLastRow();
|
int lastRow = range.getLastRow();
|
||||||
int col = range.getLastColumn();
|
int col = range.getLastColumn();
|
||||||
for (int i = firstRow; i <= lastRow; i++) {
|
for (int i = firstRow; i <= lastRow; i++) {
|
||||||
if (getTemplateProperty(i, col, CellUtil.BORDER_RIGHT) == 0) {
|
// if BORDER_RIGHT is not set on PropertyTemplate, make a thin border so that there's something to color
|
||||||
drawRightBorder(new CellRangeAddress(i, i, col, col),
|
if (getTemplateProperty(i, col, CellUtil.BORDER_RIGHT) == null) {
|
||||||
CellStyle.BORDER_THIN);
|
drawRightBorder(new CellRangeAddress(i, i, col, col), BorderStyle.THIN);
|
||||||
}
|
}
|
||||||
addProperty(i, col, CellUtil.RIGHT_BORDER_COLOR, color);
|
addProperty(i, col, CellUtil.RIGHT_BORDER_COLOR, color);
|
||||||
}
|
}
|
||||||
|
@ -704,8 +699,7 @@ public final class PropertyTemplate {
|
||||||
* <li>CellBorder.Extent.VERTICAL</li>
|
* <li>CellBorder.Extent.VERTICAL</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
private void drawOutsideBorderColors(CellRangeAddress range, short color,
|
private void drawOutsideBorderColors(CellRangeAddress range, short color, Extent extent) {
|
||||||
Extent extent) {
|
|
||||||
switch (extent) {
|
switch (extent) {
|
||||||
case ALL:
|
case ALL:
|
||||||
case HORIZONTAL:
|
case HORIZONTAL:
|
||||||
|
@ -744,8 +738,7 @@ public final class PropertyTemplate {
|
||||||
* <li>CellBorder.Extent.INSIDE</li>
|
* <li>CellBorder.Extent.INSIDE</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
private void drawHorizontalBorderColors(CellRangeAddress range, short color,
|
private void drawHorizontalBorderColors(CellRangeAddress range, short color, Extent extent) {
|
||||||
Extent extent) {
|
|
||||||
switch (extent) {
|
switch (extent) {
|
||||||
case ALL:
|
case ALL:
|
||||||
case INSIDE:
|
case INSIDE:
|
||||||
|
@ -754,8 +747,7 @@ public final class PropertyTemplate {
|
||||||
int firstCol = range.getFirstColumn();
|
int firstCol = range.getFirstColumn();
|
||||||
int lastCol = range.getLastColumn();
|
int lastCol = range.getLastColumn();
|
||||||
for (int i = firstRow; i <= lastRow; i++) {
|
for (int i = firstRow; i <= lastRow; i++) {
|
||||||
CellRangeAddress row = new CellRangeAddress(i, i, firstCol,
|
CellRangeAddress row = new CellRangeAddress(i, i, firstCol, lastCol);
|
||||||
lastCol);
|
|
||||||
if (extent == Extent.ALL || i > firstRow) {
|
if (extent == Extent.ALL || i > firstRow) {
|
||||||
drawTopBorderColor(row, color);
|
drawTopBorderColor(row, color);
|
||||||
}
|
}
|
||||||
|
@ -789,8 +781,7 @@ public final class PropertyTemplate {
|
||||||
* <li>CellBorder.Extent.INSIDE</li>
|
* <li>CellBorder.Extent.INSIDE</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
private void drawVerticalBorderColors(CellRangeAddress range, short color,
|
private void drawVerticalBorderColors(CellRangeAddress range, short color, Extent extent) {
|
||||||
Extent extent) {
|
|
||||||
switch (extent) {
|
switch (extent) {
|
||||||
case ALL:
|
case ALL:
|
||||||
case INSIDE:
|
case INSIDE:
|
||||||
|
@ -843,13 +834,13 @@ public final class PropertyTemplate {
|
||||||
* @param property
|
* @param property
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
private void addProperty(int row, int col, String property, short value) {
|
private void addProperty(int row, int col, String property, Object value) {
|
||||||
CellAddress cell = new CellAddress(row, col);
|
CellAddress cell = new CellAddress(row, col);
|
||||||
Map<String, Object> cellProperties = _propertyTemplate.get(cell);
|
Map<String, Object> cellProperties = _propertyTemplate.get(cell);
|
||||||
if (cellProperties == null) {
|
if (cellProperties == null) {
|
||||||
cellProperties = new HashMap<String, Object>();
|
cellProperties = new HashMap<String, Object>();
|
||||||
}
|
}
|
||||||
cellProperties.put(property, Short.valueOf(value));
|
cellProperties.put(property, value);
|
||||||
_propertyTemplate.put(cell, cellProperties);
|
_propertyTemplate.put(cell, cellProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -875,7 +866,7 @@ public final class PropertyTemplate {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the number of borders assigned to a cell
|
* Retrieves the number of borders assigned to a cell (a value between 0 and 4
|
||||||
*
|
*
|
||||||
* @param cell
|
* @param cell
|
||||||
*/
|
*/
|
||||||
|
@ -886,16 +877,10 @@ public final class PropertyTemplate {
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (String property : cellProperties.keySet()) {
|
if (cellProperties.containsKey(CellUtil.BORDER_TOP)) count++;
|
||||||
if (property.equals(CellUtil.BORDER_TOP))
|
if (cellProperties.containsKey(CellUtil.BORDER_LEFT)) count++;
|
||||||
count += 1;
|
if (cellProperties.containsKey(CellUtil.BORDER_RIGHT)) count++;
|
||||||
if (property.equals(CellUtil.BORDER_BOTTOM))
|
if (cellProperties.containsKey(CellUtil.BORDER_BOTTOM)) count++;
|
||||||
count += 1;
|
|
||||||
if (property.equals(CellUtil.BORDER_LEFT))
|
|
||||||
count += 1;
|
|
||||||
if (property.equals(CellUtil.BORDER_RIGHT))
|
|
||||||
count += 1;
|
|
||||||
}
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -921,16 +906,10 @@ public final class PropertyTemplate {
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (String property : cellProperties.keySet()) {
|
if (cellProperties.containsKey(CellUtil.TOP_BORDER_COLOR)) count++;
|
||||||
if (property.equals(CellUtil.TOP_BORDER_COLOR))
|
if (cellProperties.containsKey(CellUtil.LEFT_BORDER_COLOR)) count++;
|
||||||
count += 1;
|
if (cellProperties.containsKey(CellUtil.RIGHT_BORDER_COLOR)) count++;
|
||||||
if (property.equals(CellUtil.BOTTOM_BORDER_COLOR))
|
if (cellProperties.containsKey(CellUtil.BOTTOM_BORDER_COLOR)) count++;
|
||||||
count += 1;
|
|
||||||
if (property.equals(CellUtil.LEFT_BORDER_COLOR))
|
|
||||||
count += 1;
|
|
||||||
if (property.equals(CellUtil.RIGHT_BORDER_COLOR))
|
|
||||||
count += 1;
|
|
||||||
}
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -950,16 +929,12 @@ public final class PropertyTemplate {
|
||||||
* @param cell
|
* @param cell
|
||||||
* @param property
|
* @param property
|
||||||
*/
|
*/
|
||||||
public short getTemplateProperty(CellAddress cell, String property) {
|
public Object getTemplateProperty(CellAddress cell, String property) {
|
||||||
short value = 0;
|
|
||||||
Map<String, Object> cellProperties = _propertyTemplate.get(cell);
|
Map<String, Object> cellProperties = _propertyTemplate.get(cell);
|
||||||
if (cellProperties != null) {
|
if (cellProperties != null) {
|
||||||
Object obj = cellProperties.get(property);
|
return cellProperties.get(property);
|
||||||
if (obj != null) {
|
|
||||||
value = getShort(obj);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return value;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -969,21 +944,7 @@ public final class PropertyTemplate {
|
||||||
* @param col
|
* @param col
|
||||||
* @param property
|
* @param property
|
||||||
*/
|
*/
|
||||||
public short getTemplateProperty(int row, int col, String property) {
|
public Object getTemplateProperty(int row, int col, String property) {
|
||||||
return getTemplateProperty(new CellAddress(row, col), property);
|
return getTemplateProperty(new CellAddress(row, col), property);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a Short object to a short value or 0 if the object is not a
|
|
||||||
* Short
|
|
||||||
*
|
|
||||||
* @param value
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private static short getShort(Object value) {
|
|
||||||
if (value instanceof Short) {
|
|
||||||
return ((Short) value).shortValue();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,13 +43,13 @@ public final class TestPropertyTemplate {
|
||||||
CellRangeAddress a1 = new CellRangeAddress(0, 0, 0, 0);
|
CellRangeAddress a1 = new CellRangeAddress(0, 0, 0, 0);
|
||||||
PropertyTemplate pt = new PropertyTemplate();
|
PropertyTemplate pt = new PropertyTemplate();
|
||||||
|
|
||||||
pt.drawBorders(a1, CellStyle.BORDER_THIN, Extent.TOP);
|
pt.drawBorders(a1, BorderStyle.THIN, Extent.TOP);
|
||||||
assertEquals(1, pt.getNumBorders(0, 0));
|
assertEquals(1, pt.getNumBorders(0, 0));
|
||||||
|
|
||||||
pt.drawBorders(a1, CellStyle.BORDER_MEDIUM, Extent.BOTTOM);
|
pt.drawBorders(a1, BorderStyle.MEDIUM, Extent.BOTTOM);
|
||||||
assertEquals(2, pt.getNumBorders(0, 0));
|
assertEquals(2, pt.getNumBorders(0, 0));
|
||||||
|
|
||||||
pt.drawBorders(a1, CellStyle.BORDER_MEDIUM, Extent.NONE);
|
pt.drawBorders(a1, BorderStyle.MEDIUM, Extent.NONE);
|
||||||
assertEquals(0, pt.getNumBorders(0, 0));
|
assertEquals(0, pt.getNumBorders(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,10 +73,10 @@ public final class TestPropertyTemplate {
|
||||||
CellRangeAddress a1 = new CellRangeAddress(0, 0, 0, 0);
|
CellRangeAddress a1 = new CellRangeAddress(0, 0, 0, 0);
|
||||||
PropertyTemplate pt = new PropertyTemplate();
|
PropertyTemplate pt = new PropertyTemplate();
|
||||||
|
|
||||||
pt.drawBorders(a1, CellStyle.BORDER_THIN, Extent.TOP);
|
pt.drawBorders(a1, BorderStyle.THIN, Extent.TOP);
|
||||||
assertThin(pt.getTemplateProperty(0, 0, CellUtil.BORDER_TOP));
|
assertThin(pt.getTemplateProperty(0, 0, CellUtil.BORDER_TOP));
|
||||||
|
|
||||||
pt.drawBorders(a1, CellStyle.BORDER_MEDIUM, Extent.BOTTOM);
|
pt.drawBorders(a1, BorderStyle.MEDIUM, Extent.BOTTOM);
|
||||||
assertMedium(pt.getTemplateProperty(0, 0, CellUtil.BORDER_BOTTOM));
|
assertMedium(pt.getTemplateProperty(0, 0, CellUtil.BORDER_BOTTOM));
|
||||||
|
|
||||||
pt.drawBorderColors(a1, IndexedColors.RED.getIndex(), Extent.TOP);
|
pt.drawBorderColors(a1, IndexedColors.RED.getIndex(), Extent.TOP);
|
||||||
|
@ -91,7 +91,7 @@ public final class TestPropertyTemplate {
|
||||||
CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
|
CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
|
||||||
PropertyTemplate pt = new PropertyTemplate();
|
PropertyTemplate pt = new PropertyTemplate();
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_THIN, Extent.ALL);
|
pt.drawBorders(a1c3, BorderStyle.THIN, Extent.ALL);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
for (int j = 0; j <= 2; j++) {
|
for (int j = 0; j <= 2; j++) {
|
||||||
assertEquals(4, pt.getNumBorders(i, j));
|
assertEquals(4, pt.getNumBorders(i, j));
|
||||||
|
@ -102,7 +102,7 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM, Extent.OUTSIDE);
|
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.OUTSIDE);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
for (int j = 0; j <= 2; j++) {
|
for (int j = 0; j <= 2; j++) {
|
||||||
assertEquals(4, pt.getNumBorders(i, j));
|
assertEquals(4, pt.getNumBorders(i, j));
|
||||||
|
@ -161,14 +161,14 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
for (int j = 0; j <= 2; j++) {
|
for (int j = 0; j <= 2; j++) {
|
||||||
assertEquals(0, pt.getNumBorders(i, j));
|
assertEquals(0, pt.getNumBorders(i, j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM, Extent.TOP);
|
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.TOP);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
for (int j = 0; j <= 2; j++) {
|
for (int j = 0; j <= 2; j++) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
|
@ -180,8 +180,8 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM, Extent.BOTTOM);
|
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.BOTTOM);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
for (int j = 0; j <= 2; j++) {
|
for (int j = 0; j <= 2; j++) {
|
||||||
if (i == 2) {
|
if (i == 2) {
|
||||||
|
@ -193,8 +193,8 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM, Extent.LEFT);
|
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.LEFT);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
for (int j = 0; j <= 2; j++) {
|
for (int j = 0; j <= 2; j++) {
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
|
@ -206,8 +206,8 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM, Extent.RIGHT);
|
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.RIGHT);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
for (int j = 0; j <= 2; j++) {
|
for (int j = 0; j <= 2; j++) {
|
||||||
if (j == 2) {
|
if (j == 2) {
|
||||||
|
@ -219,8 +219,8 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM, Extent.HORIZONTAL);
|
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.HORIZONTAL);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
for (int j = 0; j <= 2; j++) {
|
for (int j = 0; j <= 2; j++) {
|
||||||
assertEquals(2, pt.getNumBorders(i, j));
|
assertEquals(2, pt.getNumBorders(i, j));
|
||||||
|
@ -229,8 +229,8 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM, Extent.INSIDE_HORIZONTAL);
|
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.INSIDE_HORIZONTAL);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
for (int j = 0; j <= 2; j++) {
|
for (int j = 0; j <= 2; j++) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
|
@ -247,8 +247,8 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM, Extent.OUTSIDE_HORIZONTAL);
|
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.OUTSIDE_HORIZONTAL);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
for (int j = 0; j <= 2; j++) {
|
for (int j = 0; j <= 2; j++) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
|
@ -263,8 +263,8 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM, Extent.VERTICAL);
|
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.VERTICAL);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
for (int j = 0; j <= 2; j++) {
|
for (int j = 0; j <= 2; j++) {
|
||||||
assertEquals(2, pt.getNumBorders(i, j));
|
assertEquals(2, pt.getNumBorders(i, j));
|
||||||
|
@ -273,8 +273,8 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM, Extent.INSIDE_VERTICAL);
|
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.INSIDE_VERTICAL);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
for (int j = 0; j <= 2; j++) {
|
for (int j = 0; j <= 2; j++) {
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
|
@ -291,8 +291,8 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM, Extent.OUTSIDE_VERTICAL);
|
pt.drawBorders(a1c3, BorderStyle.MEDIUM, Extent.OUTSIDE_VERTICAL);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
for (int j = 0; j <= 2; j++) {
|
for (int j = 0; j <= 2; j++) {
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
|
@ -316,8 +316,10 @@ public final class TestPropertyTemplate {
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.RED.getIndex(), Extent.ALL);
|
pt.drawBorderColors(a1c3, IndexedColors.RED.getIndex(), Extent.ALL);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
for (int j = 0; j <= 2; j++) {
|
for (int j = 0; j <= 2; j++) {
|
||||||
assertEquals(4, pt.getNumBorders(i, j));
|
CellAddress addr = new CellAddress(i, j);
|
||||||
assertEquals(4, pt.getNumBorderColors(i, j));
|
String msg = addr.formatAsString();
|
||||||
|
assertEquals(msg, 4, pt.getNumBorders(i, j));
|
||||||
|
assertEquals(msg, 4, pt.getNumBorderColors(i, j));
|
||||||
assertRed(pt.getTemplateProperty(i, j, CellUtil.TOP_BORDER_COLOR));
|
assertRed(pt.getTemplateProperty(i, j, CellUtil.TOP_BORDER_COLOR));
|
||||||
assertRed(pt.getTemplateProperty(i, j, CellUtil.BOTTOM_BORDER_COLOR));
|
assertRed(pt.getTemplateProperty(i, j, CellUtil.BOTTOM_BORDER_COLOR));
|
||||||
assertRed(pt.getTemplateProperty(i, j, CellUtil.LEFT_BORDER_COLOR));
|
assertRed(pt.getTemplateProperty(i, j, CellUtil.LEFT_BORDER_COLOR));
|
||||||
|
@ -385,7 +387,7 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
for (int j = 0; j <= 2; j++) {
|
for (int j = 0; j <= 2; j++) {
|
||||||
|
@ -408,7 +410,7 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.BOTTOM);
|
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.BOTTOM);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
|
@ -424,7 +426,7 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.LEFT);
|
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.LEFT);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
|
@ -440,7 +442,7 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.RIGHT);
|
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.RIGHT);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
|
@ -456,7 +458,7 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.HORIZONTAL);
|
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.HORIZONTAL);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
|
@ -468,7 +470,7 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.INSIDE_HORIZONTAL);
|
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.INSIDE_HORIZONTAL);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
|
@ -490,7 +492,7 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.OUTSIDE_HORIZONTAL);
|
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.OUTSIDE_HORIZONTAL);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
|
@ -510,7 +512,7 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.VERTICAL);
|
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.VERTICAL);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
|
@ -522,7 +524,7 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.INSIDE_VERTICAL);
|
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.INSIDE_VERTICAL);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
|
@ -544,7 +546,7 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), Extent.NONE);
|
||||||
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.OUTSIDE_VERTICAL);
|
pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), Extent.OUTSIDE_VERTICAL);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
|
@ -570,7 +572,7 @@ public final class TestPropertyTemplate {
|
||||||
CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
|
CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
|
||||||
PropertyTemplate pt = new PropertyTemplate();
|
PropertyTemplate pt = new PropertyTemplate();
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM, IndexedColors.RED.getIndex(), Extent.ALL);
|
pt.drawBorders(a1c3, BorderStyle.MEDIUM, IndexedColors.RED.getIndex(), Extent.ALL);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
for (int j = 0; j <= 2; j++) {
|
for (int j = 0; j <= 2; j++) {
|
||||||
assertEquals(4, pt.getNumBorders(i, j));
|
assertEquals(4, pt.getNumBorders(i, j));
|
||||||
|
@ -586,8 +588,8 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, Extent.NONE);
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_NONE, IndexedColors.RED.getIndex(), Extent.ALL);
|
pt.drawBorders(a1c3, BorderStyle.NONE, IndexedColors.RED.getIndex(), Extent.ALL);
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 2; i++) {
|
||||||
for (int j = 0; j <= 2; j++) {
|
for (int j = 0; j <= 2; j++) {
|
||||||
assertEquals(4, pt.getNumBorders(i, j));
|
assertEquals(4, pt.getNumBorders(i, j));
|
||||||
|
@ -608,7 +610,7 @@ public final class TestPropertyTemplate {
|
||||||
Workbook wb = new HSSFWorkbook();
|
Workbook wb = new HSSFWorkbook();
|
||||||
Sheet sheet = wb.createSheet();
|
Sheet sheet = wb.createSheet();
|
||||||
|
|
||||||
pt.drawBorders(a1c3, CellStyle.BORDER_THIN, IndexedColors.RED.getIndex(), Extent.ALL);
|
pt.drawBorders(a1c3, BorderStyle.THIN, IndexedColors.RED.getIndex(), Extent.ALL);
|
||||||
pt.applyBorders(sheet);
|
pt.applyBorders(sheet);
|
||||||
|
|
||||||
for (Row row: sheet) {
|
for (Row row: sheet) {
|
||||||
|
@ -629,7 +631,7 @@ public final class TestPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(b2, CellStyle.BORDER_NONE, Extent.ALL);
|
pt.drawBorders(b2, BorderStyle.NONE, Extent.ALL);
|
||||||
pt.applyBorders(sheet);
|
pt.applyBorders(sheet);
|
||||||
|
|
||||||
for (Row row: sheet) {
|
for (Row row: sheet) {
|
||||||
|
@ -668,34 +670,41 @@ public final class TestPropertyTemplate {
|
||||||
// helper functions to make sure template properties were set correctly
|
// helper functions to make sure template properties were set correctly
|
||||||
|
|
||||||
//////// Border Styles ///////////
|
//////// Border Styles ///////////
|
||||||
private static void assertNone(short actual) {
|
private static void assertNone(Object actual) {
|
||||||
assertNone(BorderStyle.valueOf(actual));
|
assertNone((BorderStyle) actual);
|
||||||
}
|
}
|
||||||
private static void assertNone(BorderStyle actual) {
|
private static void assertNone(BorderStyle actual) {
|
||||||
assertEquals(BorderStyle.NONE, actual);
|
assertEquals(BorderStyle.NONE, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertThin(short actual) {
|
private static void assertThin(Object actual) {
|
||||||
assertThin(BorderStyle.valueOf(actual));
|
assertThin((BorderStyle) actual);
|
||||||
}
|
}
|
||||||
private static void assertThin(BorderStyle actual) {
|
private static void assertThin(BorderStyle actual) {
|
||||||
assertEquals(BorderStyle.THIN, actual);
|
assertEquals(BorderStyle.THIN, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertMedium(short actual) {
|
private static void assertMedium(Object actual) {
|
||||||
assertMedium(BorderStyle.valueOf(actual));
|
assertMedium((BorderStyle) actual);
|
||||||
}
|
}
|
||||||
private static void assertMedium(BorderStyle actual) {
|
private static void assertMedium(BorderStyle actual) {
|
||||||
assertEquals(BorderStyle.MEDIUM, actual);
|
assertEquals(BorderStyle.MEDIUM, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////// Border Colors ///////////
|
//////// Border Colors (use IndexedColor codes, for now ///////////
|
||||||
private static void assertRed(short actualIndexedColor) {
|
private static void assertRed(Object actual) {
|
||||||
IndexedColors actualColor = IndexedColors.fromInt(actualIndexedColor);
|
IndexedColors actualColor = IndexedColors.fromInt((Short) actual);
|
||||||
assertEquals(IndexedColors.RED, actualColor);
|
assertRed(actualColor);
|
||||||
}
|
}
|
||||||
private static void assertBlue(short actualIndexedColor) {
|
private static void assertRed(IndexedColors actual) {
|
||||||
IndexedColors actualColor = IndexedColors.fromInt(actualIndexedColor);
|
assertEquals(IndexedColors.RED, actual);
|
||||||
assertEquals(IndexedColors.BLUE, actualColor);
|
}
|
||||||
|
|
||||||
|
private static void assertBlue(Object actual) {
|
||||||
|
IndexedColors actualColor = IndexedColors.fromInt((Short) actual);
|
||||||
|
assertBlue(actualColor);
|
||||||
|
}
|
||||||
|
private static void assertBlue(IndexedColors actual) {
|
||||||
|
assertEquals(IndexedColors.BLUE, actual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue