* @see org.apache.poi.ss.util.BorderPropertyTemplate
*/
public final class TestBorderPropertyTemplate {
+ private static final short RED = IndexedColors.RED.getIndex();
+ private static final short GREEN = IndexedColors.GREEN.getIndex();
+ private static final short BLUE = IndexedColors.BLUE.getIndex();
+ private static final short AUTOMATIC = IndexedColors.AUTOMATIC.getIndex();
+
@Test
public void getNumBorders() throws IOException {
CellRangeAddress a1a1 = new CellRangeAddress(0, 0, 0, 0); //A1:A1
BorderPropertyTemplate pt = new BorderPropertyTemplate();
- pt.drawBorderColors(a1a1, IndexedColors.RED.getIndex(), BorderExtent.TOP);
+ pt.drawBorderColors(a1a1, RED, BorderExtent.TOP);
assertEquals(1, pt.getNumBorderColors(a1));
- pt.drawBorderColors(a1a1, IndexedColors.RED.getIndex(), BorderExtent.BOTTOM);
+ pt.drawBorderColors(a1a1, RED, BorderExtent.BOTTOM);
assertEquals(2, pt.getNumBorderColors(a1));
- pt.drawBorderColors(a1a1, IndexedColors.RED.getIndex(), BorderExtent.NONE);
+ pt.drawBorderColors(a1a1, RED, BorderExtent.NONE);
assertEquals(0, pt.getNumBorderColors(a1));
}
pt.drawBorders(a1a1, BorderStyle.MEDIUM, BorderExtent.BOTTOM);
assertMedium(pt.getTemplateProperty(a1, CellUtil.BORDER_BOTTOM));
- pt.drawBorderColors(a1a1, IndexedColors.RED.getIndex(), BorderExtent.TOP);
+ pt.drawBorderColors(a1a1, RED, BorderExtent.TOP);
assertRed(pt.getTemplateProperty(a1, CellUtil.TOP_BORDER_COLOR));
- pt.drawBorderColors(a1a1, IndexedColors.BLUE.getIndex(), BorderExtent.BOTTOM);
+ pt.drawBorderColors(a1a1, BLUE, BorderExtent.BOTTOM);
assertBlue(pt.getTemplateProperty(a1, CellUtil.BOTTOM_BORDER_COLOR));
}
CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
BorderPropertyTemplate pt = new BorderPropertyTemplate();
- pt.drawBorderColors(a1c3, IndexedColors.RED.getIndex(), BorderExtent.ALL);
+ pt.drawBorderColors(a1c3, RED, BorderExtent.ALL);
for (int i = 0; i <= 2; i++) {
for (int j = 0; j <= 2; j++) {
CellAddress addr = new CellAddress(i, j);
}
}
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.OUTSIDE);
+ pt.drawBorderColors(a1c3, BLUE, BorderExtent.OUTSIDE);
for (int i = 0; i <= 2; i++) {
for (int j = 0; j <= 2; j++) {
CellAddress addr = new CellAddress(i, j);
}
}
- pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
+ pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
for (int i = 0; i <= 2; i++) {
for (int j = 0; j <= 2; j++) {
CellAddress addr = new CellAddress(i, j);
}
}
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.TOP);
+ pt.drawBorderColors(a1c3, BLUE, BorderExtent.TOP);
for (int i = 0; i <= 2; i++) {
for (int j = 0; j <= 2; j++) {
CellAddress addr = new CellAddress(i, j);
}
}
- pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.BOTTOM);
+ pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
+ pt.drawBorderColors(a1c3, BLUE, BorderExtent.BOTTOM);
for (int i = 0; i <= 2; i++) {
for (int j = 0; j <= 2; j++) {
CellAddress addr = new CellAddress(i, j);
}
}
- pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.LEFT);
+ pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
+ pt.drawBorderColors(a1c3, BLUE, BorderExtent.LEFT);
for (int i = 0; i <= 2; i++) {
for (int j = 0; j <= 2; j++) {
CellAddress addr = new CellAddress(i, j);
}
}
- pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.RIGHT);
+ pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
+ pt.drawBorderColors(a1c3, BLUE, BorderExtent.RIGHT);
for (int i = 0; i <= 2; i++) {
for (int j = 0; j <= 2; j++) {
CellAddress addr = new CellAddress(i, j);
}
}
- pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.HORIZONTAL);
+ pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
+ pt.drawBorderColors(a1c3, BLUE, BorderExtent.HORIZONTAL);
for (int i = 0; i <= 2; i++) {
for (int j = 0; j <= 2; j++) {
CellAddress addr = new CellAddress(i, j);
}
}
- pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.INSIDE_HORIZONTAL);
+ pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
+ pt.drawBorderColors(a1c3, BLUE, BorderExtent.INSIDE_HORIZONTAL);
for (int i = 0; i <= 2; i++) {
for (int j = 0; j <= 2; j++) {
CellAddress addr = new CellAddress(i, j);
}
}
- pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.OUTSIDE_HORIZONTAL);
+ pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
+ pt.drawBorderColors(a1c3, BLUE, BorderExtent.OUTSIDE_HORIZONTAL);
for (int i = 0; i <= 2; i++) {
for (int j = 0; j <= 2; j++) {
CellAddress addr = new CellAddress(i, j);
}
}
- pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.VERTICAL);
+ pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
+ pt.drawBorderColors(a1c3, BLUE, BorderExtent.VERTICAL);
for (int i = 0; i <= 2; i++) {
for (int j = 0; j <= 2; j++) {
CellAddress addr = new CellAddress(i, j);
}
}
- pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.INSIDE_VERTICAL);
+ pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
+ pt.drawBorderColors(a1c3, BLUE, BorderExtent.INSIDE_VERTICAL);
for (int i = 0; i <= 2; i++) {
for (int j = 0; j <= 2; j++) {
CellAddress addr = new CellAddress(i, j);
}
}
- pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(), BorderExtent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(), BorderExtent.OUTSIDE_VERTICAL);
+ pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
+ pt.drawBorderColors(a1c3, BLUE, BorderExtent.OUTSIDE_VERTICAL);
for (int i = 0; i <= 2; i++) {
for (int j = 0; j <= 2; j++) {
CellAddress addr = new CellAddress(i, j);
CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
BorderPropertyTemplate pt = new BorderPropertyTemplate();
- pt.drawBorders(a1c3, BorderStyle.MEDIUM, IndexedColors.RED.getIndex(), BorderExtent.ALL);
+ pt.drawBorders(a1c3, BorderStyle.MEDIUM, RED, BorderExtent.ALL);
for (int i = 0; i <= 2; i++) {
for (int j = 0; j <= 2; j++) {
CellAddress addr = new CellAddress(i, j);
}
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
- pt.drawBorders(a1c3, BorderStyle.NONE, IndexedColors.RED.getIndex(), BorderExtent.ALL);
+ pt.drawBorders(a1c3, BorderStyle.NONE, RED, BorderExtent.ALL);
for (int i = 0; i <= 2; i++) {
for (int j = 0; j <= 2; j++) {
CellAddress addr = new CellAddress(i, j);
Workbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet();
- pt.drawBorders(a1c3, BorderStyle.THIN, IndexedColors.RED.getIndex(), BorderExtent.ALL);
+ pt.drawBorders(a1c3, BorderStyle.THIN, RED, BorderExtent.ALL);
pt.applyBorders(sheet);
for (Row row: sheet) {