mirror of https://github.com/apache/poi.git
rename drawBorders(..., short color, ...) to drawColoredBorders to make it obvious that method changes border line style and color
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ss_border_property_template@1748074 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8bf2ebf453
commit
286e650c2a
|
@ -86,10 +86,10 @@ public class DrawingBorders {
|
||||||
// #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(b10d12, BorderStyle.MEDIUM, red, BorderExtent.OUTSIDE);
|
pt.drawColoredBorders(b10d12, BorderStyle.MEDIUM, red, BorderExtent.OUTSIDE);
|
||||||
pt.drawBorders(b10d12, BorderStyle.MEDIUM, blue, BorderExtent.INSIDE_VERTICAL);
|
pt.drawColoredBorders(b10d12, BorderStyle.MEDIUM, blue, BorderExtent.INSIDE_VERTICAL);
|
||||||
pt.drawBorders(b10d12, BorderStyle.MEDIUM, green, BorderExtent.INSIDE_HORIZONTAL);
|
pt.drawColoredBorders(b10d12, BorderStyle.MEDIUM, green, BorderExtent.INSIDE_HORIZONTAL);
|
||||||
pt.drawBorders(c11, BorderStyle.NONE, BorderExtent.ALL);
|
pt.drawBorders(c11, BorderStyle.NONE, BorderExtent.ALL);
|
||||||
|
|
||||||
// apply borders to sheet
|
// apply borders to sheet
|
||||||
pt.applyBorders(sh1);
|
pt.applyBorders(sh1);
|
||||||
|
|
|
@ -293,7 +293,7 @@ public final class BorderPropertyTemplate {
|
||||||
* @param extent BorderExtent of the borders to be applied.
|
* @param extent BorderExtent of the borders to be applied.
|
||||||
* @since 3.15 beta 2
|
* @since 3.15 beta 2
|
||||||
*/
|
*/
|
||||||
public void drawBorders(CellRangeAddress range, BorderStyle borderType, short color, BorderExtent extent) {
|
public void drawColoredBorders(CellRangeAddress range, BorderStyle borderType, short color, BorderExtent extent) {
|
||||||
drawBorders(range, borderType, extent);
|
drawBorders(range, borderType, extent);
|
||||||
if (borderType != BorderStyle.NONE) {
|
if (borderType != BorderStyle.NONE) {
|
||||||
drawBorderColors(range, color, extent);
|
drawBorderColors(range, color, extent);
|
||||||
|
@ -518,8 +518,8 @@ public final class BorderPropertyTemplate {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies the drawn borders to a Sheet. The borders that are applied are
|
* Applies the drawn borders to a Sheet. The borders that are applied are
|
||||||
* the ones that have been drawn by the {@link #drawBorders} and
|
* the ones that have been drawn by {@link #drawColoredBorders}, {@link #drawBorders} and
|
||||||
* {@link #drawBorderColors} methods.
|
* {@link #drawBorderColors}.
|
||||||
* The same border property template can be applied to multiple sheets
|
* The same border property template can be applied to multiple sheets
|
||||||
* from the same or different workbooks.
|
* from the same or different workbooks.
|
||||||
*
|
*
|
||||||
|
|
|
@ -40,7 +40,6 @@ import org.junit.Test;
|
||||||
*/
|
*/
|
||||||
public final class TestBorderPropertyTemplate {
|
public final class TestBorderPropertyTemplate {
|
||||||
private static final short RED = IndexedColors.RED.getIndex();
|
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 BLUE = IndexedColors.BLUE.getIndex();
|
||||||
private static final short AUTOMATIC = IndexedColors.AUTOMATIC.getIndex();
|
private static final short AUTOMATIC = IndexedColors.AUTOMATIC.getIndex();
|
||||||
|
|
||||||
|
@ -50,7 +49,7 @@ public final class TestBorderPropertyTemplate {
|
||||||
CellAddress a1 = new CellAddress(0, 0); //A1
|
CellAddress a1 = new CellAddress(0, 0); //A1
|
||||||
|
|
||||||
BorderPropertyTemplate pt1 = new BorderPropertyTemplate();
|
BorderPropertyTemplate pt1 = new BorderPropertyTemplate();
|
||||||
pt1.drawBorders(a1a1, BorderStyle.THIN, RED, BorderExtent.TOP);
|
pt1.drawColoredBorders(a1a1, BorderStyle.THIN, RED, BorderExtent.TOP);
|
||||||
|
|
||||||
// check to make sure borders were copied
|
// check to make sure borders were copied
|
||||||
BorderPropertyTemplate pt2 = new BorderPropertyTemplate(pt1);
|
BorderPropertyTemplate pt2 = new BorderPropertyTemplate(pt1);
|
||||||
|
@ -60,14 +59,14 @@ public final class TestBorderPropertyTemplate {
|
||||||
|
|
||||||
// Changes to original template should not affect copied template.
|
// Changes to original template should not affect copied template.
|
||||||
assertEquals(1, pt2.getNumBorders(a1));
|
assertEquals(1, pt2.getNumBorders(a1));
|
||||||
pt1.drawBorders(a1a1, BorderStyle.THIN, RED, BorderExtent.LEFT);
|
pt1.drawColoredBorders(a1a1, BorderStyle.THIN, RED, BorderExtent.LEFT);
|
||||||
assertEquals(1, pt2.getNumBorders(a1));
|
assertEquals(1, pt2.getNumBorders(a1));
|
||||||
assertNull(pt2.getTemplateProperty(a1, CellUtil.BORDER_LEFT));
|
assertNull(pt2.getTemplateProperty(a1, CellUtil.BORDER_LEFT));
|
||||||
assertNull(pt2.getTemplateProperty(a1, CellUtil.LEFT_BORDER_COLOR));
|
assertNull(pt2.getTemplateProperty(a1, CellUtil.LEFT_BORDER_COLOR));
|
||||||
|
|
||||||
// Changes to copied template should not affect original template
|
// Changes to copied template should not affect original template
|
||||||
assertEquals(2, pt1.getNumBorders(a1));
|
assertEquals(2, pt1.getNumBorders(a1));
|
||||||
pt2.drawBorders(a1a1, BorderStyle.THIN, RED, BorderExtent.RIGHT);
|
pt2.drawColoredBorders(a1a1, BorderStyle.THIN, RED, BorderExtent.RIGHT);
|
||||||
assertEquals(2, pt1.getNumBorders(a1));
|
assertEquals(2, pt1.getNumBorders(a1));
|
||||||
assertNull(pt1.getTemplateProperty(a1, CellUtil.BORDER_RIGHT));
|
assertNull(pt1.getTemplateProperty(a1, CellUtil.BORDER_RIGHT));
|
||||||
assertNull(pt1.getTemplateProperty(a1, CellUtil.RIGHT_BORDER_COLOR));
|
assertNull(pt1.getTemplateProperty(a1, CellUtil.RIGHT_BORDER_COLOR));
|
||||||
|
@ -442,7 +441,7 @@ public final class TestBorderPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
pt.drawColoredBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.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++) {
|
||||||
CellAddress addr = new CellAddress(i, j);
|
CellAddress addr = new CellAddress(i, j);
|
||||||
|
@ -466,7 +465,7 @@ public final class TestBorderPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
pt.drawColoredBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
||||||
pt.drawBorderColors(a1c3, BLUE, BorderExtent.BOTTOM);
|
pt.drawBorderColors(a1c3, BLUE, BorderExtent.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++) {
|
||||||
|
@ -482,7 +481,7 @@ public final class TestBorderPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
pt.drawColoredBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
||||||
pt.drawBorderColors(a1c3, BLUE, BorderExtent.LEFT);
|
pt.drawBorderColors(a1c3, BLUE, BorderExtent.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++) {
|
||||||
|
@ -498,7 +497,7 @@ public final class TestBorderPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
pt.drawColoredBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
||||||
pt.drawBorderColors(a1c3, BLUE, BorderExtent.RIGHT);
|
pt.drawBorderColors(a1c3, BLUE, BorderExtent.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++) {
|
||||||
|
@ -514,7 +513,7 @@ public final class TestBorderPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
pt.drawColoredBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
||||||
pt.drawBorderColors(a1c3, BLUE, BorderExtent.HORIZONTAL);
|
pt.drawBorderColors(a1c3, BLUE, BorderExtent.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++) {
|
||||||
|
@ -526,7 +525,7 @@ public final class TestBorderPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
pt.drawColoredBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
||||||
pt.drawBorderColors(a1c3, BLUE, BorderExtent.INSIDE_HORIZONTAL);
|
pt.drawBorderColors(a1c3, BLUE, BorderExtent.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++) {
|
||||||
|
@ -548,7 +547,7 @@ public final class TestBorderPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
pt.drawColoredBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
||||||
pt.drawBorderColors(a1c3, BLUE, BorderExtent.OUTSIDE_HORIZONTAL);
|
pt.drawBorderColors(a1c3, BLUE, BorderExtent.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++) {
|
||||||
|
@ -568,7 +567,7 @@ public final class TestBorderPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
pt.drawColoredBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
||||||
pt.drawBorderColors(a1c3, BLUE, BorderExtent.VERTICAL);
|
pt.drawBorderColors(a1c3, BLUE, BorderExtent.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++) {
|
||||||
|
@ -580,7 +579,7 @@ public final class TestBorderPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
pt.drawColoredBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
||||||
pt.drawBorderColors(a1c3, BLUE, BorderExtent.INSIDE_VERTICAL);
|
pt.drawBorderColors(a1c3, BLUE, BorderExtent.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++) {
|
||||||
|
@ -602,7 +601,7 @@ public final class TestBorderPropertyTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
pt.drawColoredBorders(a1c3, BorderStyle.NONE, AUTOMATIC, BorderExtent.NONE);
|
||||||
pt.drawBorderColors(a1c3, BLUE, BorderExtent.OUTSIDE_VERTICAL);
|
pt.drawBorderColors(a1c3, BLUE, BorderExtent.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++) {
|
||||||
|
@ -628,7 +627,7 @@ public final class TestBorderPropertyTemplate {
|
||||||
CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
|
CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
|
||||||
BorderPropertyTemplate pt = new BorderPropertyTemplate();
|
BorderPropertyTemplate pt = new BorderPropertyTemplate();
|
||||||
|
|
||||||
pt.drawBorders(a1c3, BorderStyle.MEDIUM, RED, BorderExtent.ALL);
|
pt.drawColoredBorders(a1c3, BorderStyle.MEDIUM, RED, BorderExtent.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++) {
|
||||||
CellAddress addr = new CellAddress(i, j);
|
CellAddress addr = new CellAddress(i, j);
|
||||||
|
@ -646,7 +645,7 @@ public final class TestBorderPropertyTemplate {
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
pt.drawBorders(a1c3, BorderStyle.NONE, BorderExtent.NONE);
|
||||||
pt.drawBorders(a1c3, BorderStyle.NONE, RED, BorderExtent.ALL);
|
pt.drawColoredBorders(a1c3, BorderStyle.NONE, RED, BorderExtent.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++) {
|
||||||
CellAddress addr = new CellAddress(i, j);
|
CellAddress addr = new CellAddress(i, j);
|
||||||
|
@ -668,7 +667,7 @@ public final class TestBorderPropertyTemplate {
|
||||||
Workbook wb = new HSSFWorkbook();
|
Workbook wb = new HSSFWorkbook();
|
||||||
Sheet sheet = wb.createSheet();
|
Sheet sheet = wb.createSheet();
|
||||||
|
|
||||||
pt.drawBorders(a1c3, BorderStyle.THIN, RED, BorderExtent.ALL);
|
pt.drawColoredBorders(a1c3, BorderStyle.THIN, RED, BorderExtent.ALL);
|
||||||
pt.applyBorders(sheet);
|
pt.applyBorders(sheet);
|
||||||
|
|
||||||
for (Row row: sheet) {
|
for (Row row: sheet) {
|
||||||
|
|
Loading…
Reference in New Issue