You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2016/06/11 07:00:41 UTC
svn commit: r1747852 [2/3] - in
/poi/branches/ss_border_property_template/src:
examples/src/org/apache/poi/ss/examples/DrawingBorders.java
java/org/apache/poi/ss/util/PropertyTemplate.java
testcases/org/apache/poi/ss/util/TestPropertyTemplate.java
Modified: poi/branches/ss_border_property_template/src/testcases/org/apache/poi/ss/util/TestPropertyTemplate.java
URL: http://svn.apache.org/viewvc/poi/branches/ss_border_property_template/src/testcases/org/apache/poi/ss/util/TestPropertyTemplate.java?rev=1747852&r1=1747851&r2=1747852&view=diff
==============================================================================
--- poi/branches/ss_border_property_template/src/testcases/org/apache/poi/ss/util/TestPropertyTemplate.java (original)
+++ poi/branches/ss_border_property_template/src/testcases/org/apache/poi/ss/util/TestPropertyTemplate.java Sat Jun 11 07:00:40 2016
@@ -1,910 +1,910 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.ss.util;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-
-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.CellStyle;
-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.junit.Test;
-
-/**
- * Tests Spreadsheet PropertyTemplate
- *
- * @see org.apache.poi.ss.util.PropertyTemplate
- */
-public final class TestPropertyTemplate {
- @Test
- public void getNumBorders() throws IOException {
- CellRangeAddress a1 = new CellRangeAddress(0, 0, 0, 0);
- PropertyTemplate pt = new PropertyTemplate();
- pt.drawBorders(a1, CellStyle.BORDER_THIN, Extent.TOP);
- assertEquals(1, pt.getNumBorders(0, 0));
- pt.drawBorders(a1, CellStyle.BORDER_MEDIUM, Extent.BOTTOM);
- assertEquals(2, pt.getNumBorders(0, 0));
- pt.drawBorders(a1, CellStyle.BORDER_MEDIUM, Extent.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();
- pt.drawBorderColors(a1, IndexedColors.RED.getIndex(), Extent.TOP);
- assertEquals(1, pt.getNumBorderColors(0, 0));
- pt.drawBorderColors(a1, IndexedColors.RED.getIndex(), Extent.BOTTOM);
- assertEquals(2, pt.getNumBorderColors(0, 0));
- pt.drawBorderColors(a1, IndexedColors.RED.getIndex(), Extent.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();
- pt.drawBorders(a1, CellStyle.BORDER_THIN, Extent.TOP);
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(0, 0, CellUtil.BORDER_TOP));
- pt.drawBorders(a1, CellStyle.BORDER_MEDIUM, Extent.BOTTOM);
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(0, 0, CellUtil.BORDER_BOTTOM));
- pt.drawBorderColors(a1, IndexedColors.RED.getIndex(), Extent.TOP);
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(0, 0, CellUtil.TOP_BORDER_COLOR));
- pt.drawBorderColors(a1, IndexedColors.BLUE.getIndex(), Extent.BOTTOM);
- assertEquals(IndexedColors.BLUE.getIndex(),
- 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();
- pt.drawBorders(a1c3, CellStyle.BORDER_THIN,
- PropertyTemplate.Extent.ALL);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- assertEquals(4, pt.getNumBorders(i, j));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
- PropertyTemplate.Extent.OUTSIDE);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- assertEquals(4, pt.getNumBorders(i, j));
- if (i == 0) {
- if (j == 0) {
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_TOP));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_BOTTOM));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_LEFT));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_RIGHT));
- } else if (j == 2) {
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_TOP));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_BOTTOM));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_LEFT));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_RIGHT));
- } else {
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_TOP));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_BOTTOM));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_LEFT));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_RIGHT));
- }
- } else if (i == 2) {
- if (j == 0) {
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_TOP));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_BOTTOM));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_LEFT));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_RIGHT));
- } else if (j == 2) {
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_TOP));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_BOTTOM));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_LEFT));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_RIGHT));
- } else {
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_TOP));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_BOTTOM));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_LEFT));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_RIGHT));
- }
- } else {
- if (j == 0) {
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_TOP));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_BOTTOM));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_LEFT));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_RIGHT));
- } else if (j == 2) {
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_TOP));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_BOTTOM));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_LEFT));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_RIGHT));
- } else {
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_TOP));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_BOTTOM));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_LEFT));
- assertEquals(CellStyle.BORDER_THIN,
- pt.getTemplateProperty(i, j,
- CellUtil.BORDER_RIGHT));
- }
- }
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- assertEquals(0, pt.getNumBorders(i, j));
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
- PropertyTemplate.Extent.TOP);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- if (i == 0) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
- } else {
- assertEquals(0, pt.getNumBorders(i, j));
- }
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
- PropertyTemplate.Extent.BOTTOM);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- if (i == 2) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(CellStyle.BORDER_MEDIUM, pt
- .getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
- } else {
- assertEquals(0, pt.getNumBorders(i, j));
- }
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
- PropertyTemplate.Extent.LEFT);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- if (j == 0) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
- } else {
- assertEquals(0, pt.getNumBorders(i, j));
- }
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
- PropertyTemplate.Extent.RIGHT);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- if (j == 2) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(CellStyle.BORDER_MEDIUM, pt
- .getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
- } else {
- assertEquals(0, pt.getNumBorders(i, j));
- }
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
- PropertyTemplate.Extent.HORIZONTAL);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- assertEquals(2, pt.getNumBorders(i, j));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
- PropertyTemplate.Extent.INSIDE_HORIZONTAL);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- if (i == 0) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(CellStyle.BORDER_MEDIUM, pt
- .getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
- } else if (i == 2) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
- } else {
- assertEquals(2, pt.getNumBorders(i, j));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
- assertEquals(CellStyle.BORDER_MEDIUM, pt
- .getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
- }
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
- PropertyTemplate.Extent.OUTSIDE_HORIZONTAL);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- if (i == 0) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
- } else if (i == 2) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(CellStyle.BORDER_MEDIUM, pt
- .getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
- } else {
- assertEquals(0, pt.getNumBorders(i, j));
- }
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
- PropertyTemplate.Extent.VERTICAL);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- assertEquals(2, pt.getNumBorders(i, j));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
- PropertyTemplate.Extent.INSIDE_VERTICAL);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- if (j == 0) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(CellStyle.BORDER_MEDIUM, pt
- .getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
- } else if (j == 2) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
- } else {
- assertEquals(2, pt.getNumBorders(i, j));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
- assertEquals(CellStyle.BORDER_MEDIUM, pt
- .getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
- }
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
- PropertyTemplate.Extent.OUTSIDE_VERTICAL);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- if (j == 0) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
- } else if (j == 2) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(CellStyle.BORDER_MEDIUM, pt
- .getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
- } else {
- assertEquals(0, pt.getNumBorders(i, j));
- }
- }
- }
- }
-
- @Test
- public void drawBorderColors() throws IOException {
- CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
- PropertyTemplate pt = new PropertyTemplate();
- pt.drawBorderColors(a1c3, IndexedColors.RED.getIndex(),
- PropertyTemplate.Extent.ALL);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- assertEquals(4, pt.getNumBorders(i, j));
- assertEquals(4, pt.getNumBorderColors(i, j));
- assertEquals(IndexedColors.RED.getIndex(), pt
- .getTemplateProperty(i, j, CellUtil.TOP_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.BOTTOM_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(), pt
- .getTemplateProperty(i, j, CellUtil.LEFT_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.RIGHT_BORDER_COLOR));
- }
- }
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
- PropertyTemplate.Extent.OUTSIDE);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- assertEquals(4, pt.getNumBorders(i, j));
- assertEquals(4, pt.getNumBorderColors(i, j));
- if (i == 0) {
- if (j == 0) {
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.TOP_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.BOTTOM_BORDER_COLOR));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.LEFT_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.RIGHT_BORDER_COLOR));
- } else if (j == 2) {
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.TOP_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.BOTTOM_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.LEFT_BORDER_COLOR));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.RIGHT_BORDER_COLOR));
- } else {
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.TOP_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.BOTTOM_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.LEFT_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.RIGHT_BORDER_COLOR));
- }
- } else if (i == 2) {
- if (j == 0) {
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.TOP_BORDER_COLOR));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.BOTTOM_BORDER_COLOR));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.LEFT_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.RIGHT_BORDER_COLOR));
- } else if (j == 2) {
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.TOP_BORDER_COLOR));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.BOTTOM_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.LEFT_BORDER_COLOR));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.RIGHT_BORDER_COLOR));
- } else {
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.TOP_BORDER_COLOR));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.BOTTOM_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.LEFT_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.RIGHT_BORDER_COLOR));
- }
- } else {
- if (j == 0) {
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.TOP_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.BOTTOM_BORDER_COLOR));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.LEFT_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.RIGHT_BORDER_COLOR));
- } else if (j == 2) {
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.TOP_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.BOTTOM_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.LEFT_BORDER_COLOR));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.RIGHT_BORDER_COLOR));
- } else {
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.TOP_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.BOTTOM_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.LEFT_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.RIGHT_BORDER_COLOR));
- }
- }
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
- PropertyTemplate.Extent.NONE);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- assertEquals(0, pt.getNumBorders(i, j));
- assertEquals(0, pt.getNumBorderColors(i, j));
- }
- }
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
- PropertyTemplate.Extent.TOP);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- if (i == 0) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(1, pt.getNumBorderColors(i, j));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.TOP_BORDER_COLOR));
- } else {
- assertEquals(0, pt.getNumBorders(i, j));
- assertEquals(0, pt.getNumBorderColors(i, j));
- }
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
- PropertyTemplate.Extent.BOTTOM);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- if (i == 2) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(1, pt.getNumBorderColors(i, j));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.BOTTOM_BORDER_COLOR));
- } else {
- assertEquals(0, pt.getNumBorders(i, j));
- assertEquals(0, pt.getNumBorderColors(i, j));
- }
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
- PropertyTemplate.Extent.LEFT);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- if (j == 0) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(1, pt.getNumBorderColors(i, j));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.LEFT_BORDER_COLOR));
- } else {
- assertEquals(0, pt.getNumBorders(i, j));
- assertEquals(0, pt.getNumBorderColors(i, j));
- }
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
- PropertyTemplate.Extent.RIGHT);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- if (j == 2) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(1, pt.getNumBorderColors(i, j));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.RIGHT_BORDER_COLOR));
- } else {
- assertEquals(0, pt.getNumBorders(i, j));
- assertEquals(0, pt.getNumBorderColors(i, j));
- }
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
- PropertyTemplate.Extent.HORIZONTAL);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- assertEquals(2, pt.getNumBorders(i, j));
- assertEquals(2, pt.getNumBorderColors(i, j));
- assertEquals(IndexedColors.BLUE.getIndex(), pt
- .getTemplateProperty(i, j, CellUtil.TOP_BORDER_COLOR));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.BOTTOM_BORDER_COLOR));
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
- PropertyTemplate.Extent.INSIDE_HORIZONTAL);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- if (i == 0) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(1, pt.getNumBorderColors(i, j));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.BOTTOM_BORDER_COLOR));
- } else if (i == 2) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(1, pt.getNumBorderColors(i, j));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.TOP_BORDER_COLOR));
- } else {
- assertEquals(2, pt.getNumBorders(i, j));
- assertEquals(2, pt.getNumBorderColors(i, j));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.TOP_BORDER_COLOR));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.BOTTOM_BORDER_COLOR));
- }
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
- PropertyTemplate.Extent.OUTSIDE_HORIZONTAL);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- if (i == 0) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(1, pt.getNumBorderColors(i, j));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.TOP_BORDER_COLOR));
- } else if (i == 2) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(1, pt.getNumBorderColors(i, j));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.BOTTOM_BORDER_COLOR));
- } else {
- assertEquals(0, pt.getNumBorders(i, j));
- assertEquals(0, pt.getNumBorderColors(i, j));
- }
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
- PropertyTemplate.Extent.VERTICAL);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- assertEquals(2, pt.getNumBorders(i, j));
- assertEquals(2, pt.getNumBorderColors(i, j));
- assertEquals(IndexedColors.BLUE.getIndex(), pt
- .getTemplateProperty(i, j, CellUtil.LEFT_BORDER_COLOR));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.RIGHT_BORDER_COLOR));
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
- PropertyTemplate.Extent.INSIDE_VERTICAL);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- if (j == 0) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(1, pt.getNumBorderColors(i, j));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.RIGHT_BORDER_COLOR));
- } else if (j == 2) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(1, pt.getNumBorderColors(i, j));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.LEFT_BORDER_COLOR));
- } else {
- assertEquals(2, pt.getNumBorders(i, j));
- assertEquals(2, pt.getNumBorderColors(i, j));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.LEFT_BORDER_COLOR));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.RIGHT_BORDER_COLOR));
- }
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
- PropertyTemplate.Extent.NONE);
- pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
- PropertyTemplate.Extent.OUTSIDE_VERTICAL);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- if (j == 0) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(1, pt.getNumBorderColors(i, j));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.LEFT_BORDER_COLOR));
- } else if (j == 2) {
- assertEquals(1, pt.getNumBorders(i, j));
- assertEquals(1, pt.getNumBorderColors(i, j));
- assertEquals(IndexedColors.BLUE.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.RIGHT_BORDER_COLOR));
- } else {
- assertEquals(0, pt.getNumBorders(i, j));
- assertEquals(0, pt.getNumBorderColors(i, j));
- }
- }
- }
- }
-
- @Test
- public void drawBordersWithColors() throws IOException {
- CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
- PropertyTemplate pt = new PropertyTemplate();
-
- pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM, IndexedColors.RED.getIndex(), Extent.ALL);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- assertEquals(4, pt.getNumBorders(i, j));
- assertEquals(4, pt.getNumBorderColors(i, j));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
- assertEquals(CellStyle.BORDER_MEDIUM,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
- assertEquals(IndexedColors.RED.getIndex(), pt
- .getTemplateProperty(i, j, CellUtil.TOP_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.BOTTOM_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(), pt
- .getTemplateProperty(i, j, CellUtil.LEFT_BORDER_COLOR));
- assertEquals(IndexedColors.RED.getIndex(),
- pt.getTemplateProperty(i, j,
- CellUtil.RIGHT_BORDER_COLOR));
- }
- }
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE, Extent.NONE);
- pt.drawBorders(a1c3, CellStyle.BORDER_NONE, IndexedColors.RED.getIndex(), Extent.ALL);
- for (int i = 0; i <= 2; i++) {
- for (int j = 0; j <= 2; j++) {
- assertEquals(4, pt.getNumBorders(i, j));
- assertEquals(0, pt.getNumBorderColors(i, j));
- assertEquals(CellStyle.BORDER_NONE,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
- assertEquals(CellStyle.BORDER_NONE,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
- assertEquals(CellStyle.BORDER_NONE,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
- assertEquals(CellStyle.BORDER_NONE,
- pt.getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
- }
- }
- }
-
- @Test
- 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();
- Workbook wb = new HSSFWorkbook();
- Sheet sheet = wb.createSheet();
-
- pt.drawBorders(a1c3, CellStyle.BORDER_THIN, IndexedColors.RED.getIndex(), Extent.ALL);
- pt.applyBorders(sheet);
-
- for (Row row: sheet) {
- for (Cell cell: row) {
- CellStyle cs = cell.getCellStyle();
- assertEquals(BorderStyle.THIN, cs.getBorderTop());
- assertEquals(IndexedColors.RED.getIndex(), cs.getTopBorderColor());
- assertEquals(BorderStyle.THIN, cs.getBorderBottom());
- assertEquals(IndexedColors.RED.getIndex(), cs.getBottomBorderColor());
- assertEquals(BorderStyle.THIN, cs.getBorderLeft());
- assertEquals(IndexedColors.RED.getIndex(), cs.getLeftBorderColor());
- assertEquals(BorderStyle.THIN, cs.getBorderRight());
- assertEquals(IndexedColors.RED.getIndex(), cs.getRightBorderColor());
- }
- }
-
- pt.drawBorders(b2, CellStyle.BORDER_NONE, Extent.ALL);
- pt.applyBorders(sheet);
-
- for (Row row: sheet) {
- for (Cell cell: row) {
- CellStyle cs = cell.getCellStyle();
- if (cell.getColumnIndex() != 1 || row.getRowNum() == 0) {
- assertEquals(BorderStyle.THIN, cs.getBorderTop());
- assertEquals(IndexedColors.RED.getIndex(), cs.getTopBorderColor());
- } else {
- assertEquals(BorderStyle.NONE, cs.getBorderTop());
- }
- if (cell.getColumnIndex() != 1 || row.getRowNum() == 2) {
- assertEquals(BorderStyle.THIN, cs.getBorderBottom());
- assertEquals(IndexedColors.RED.getIndex(), cs.getBottomBorderColor());
- } else {
- assertEquals(BorderStyle.NONE, cs.getBorderBottom());
- }
- if (cell.getColumnIndex() == 0 || row.getRowNum() != 1) {
- assertEquals(BorderStyle.THIN, cs.getBorderLeft());
- assertEquals(IndexedColors.RED.getIndex(), cs.getLeftBorderColor());
- } else {
- assertEquals(BorderStyle.NONE, cs.getBorderLeft());
- }
- if (cell.getColumnIndex() == 2 || row.getRowNum() != 1) {
- assertEquals(BorderStyle.THIN, cs.getBorderRight());
- assertEquals(IndexedColors.RED.getIndex(), cs.getRightBorderColor());
- } else {
- assertEquals(BorderStyle.NONE, cs.getBorderRight());
- }
- }
- }
-
- wb.close();
- }
-}
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.ss.util;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+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.CellStyle;
+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.junit.Test;
+
+/**
+ * Tests Spreadsheet PropertyTemplate
+ *
+ * @see org.apache.poi.ss.util.PropertyTemplate
+ */
+public final class TestPropertyTemplate {
+ @Test
+ public void getNumBorders() throws IOException {
+ CellRangeAddress a1 = new CellRangeAddress(0, 0, 0, 0);
+ PropertyTemplate pt = new PropertyTemplate();
+ pt.drawBorders(a1, CellStyle.BORDER_THIN, Extent.TOP);
+ assertEquals(1, pt.getNumBorders(0, 0));
+ pt.drawBorders(a1, CellStyle.BORDER_MEDIUM, Extent.BOTTOM);
+ assertEquals(2, pt.getNumBorders(0, 0));
+ pt.drawBorders(a1, CellStyle.BORDER_MEDIUM, Extent.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();
+ pt.drawBorderColors(a1, IndexedColors.RED.getIndex(), Extent.TOP);
+ assertEquals(1, pt.getNumBorderColors(0, 0));
+ pt.drawBorderColors(a1, IndexedColors.RED.getIndex(), Extent.BOTTOM);
+ assertEquals(2, pt.getNumBorderColors(0, 0));
+ pt.drawBorderColors(a1, IndexedColors.RED.getIndex(), Extent.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();
+ pt.drawBorders(a1, CellStyle.BORDER_THIN, Extent.TOP);
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(0, 0, CellUtil.BORDER_TOP));
+ pt.drawBorders(a1, CellStyle.BORDER_MEDIUM, Extent.BOTTOM);
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(0, 0, CellUtil.BORDER_BOTTOM));
+ pt.drawBorderColors(a1, IndexedColors.RED.getIndex(), Extent.TOP);
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(0, 0, CellUtil.TOP_BORDER_COLOR));
+ pt.drawBorderColors(a1, IndexedColors.BLUE.getIndex(), Extent.BOTTOM);
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ 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();
+ pt.drawBorders(a1c3, CellStyle.BORDER_THIN,
+ PropertyTemplate.Extent.ALL);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ assertEquals(4, pt.getNumBorders(i, j));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
+ PropertyTemplate.Extent.OUTSIDE);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ assertEquals(4, pt.getNumBorders(i, j));
+ if (i == 0) {
+ if (j == 0) {
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_TOP));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_BOTTOM));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_LEFT));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_RIGHT));
+ } else if (j == 2) {
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_TOP));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_BOTTOM));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_LEFT));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_RIGHT));
+ } else {
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_TOP));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_BOTTOM));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_LEFT));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_RIGHT));
+ }
+ } else if (i == 2) {
+ if (j == 0) {
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_TOP));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_BOTTOM));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_LEFT));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_RIGHT));
+ } else if (j == 2) {
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_TOP));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_BOTTOM));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_LEFT));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_RIGHT));
+ } else {
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_TOP));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_BOTTOM));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_LEFT));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_RIGHT));
+ }
+ } else {
+ if (j == 0) {
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_TOP));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_BOTTOM));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_LEFT));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_RIGHT));
+ } else if (j == 2) {
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_TOP));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_BOTTOM));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_LEFT));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_RIGHT));
+ } else {
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_TOP));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_BOTTOM));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_LEFT));
+ assertEquals(CellStyle.BORDER_THIN,
+ pt.getTemplateProperty(i, j,
+ CellUtil.BORDER_RIGHT));
+ }
+ }
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ assertEquals(0, pt.getNumBorders(i, j));
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
+ PropertyTemplate.Extent.TOP);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ if (i == 0) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
+ } else {
+ assertEquals(0, pt.getNumBorders(i, j));
+ }
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
+ PropertyTemplate.Extent.BOTTOM);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ if (i == 2) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(CellStyle.BORDER_MEDIUM, pt
+ .getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
+ } else {
+ assertEquals(0, pt.getNumBorders(i, j));
+ }
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
+ PropertyTemplate.Extent.LEFT);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ if (j == 0) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
+ } else {
+ assertEquals(0, pt.getNumBorders(i, j));
+ }
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
+ PropertyTemplate.Extent.RIGHT);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ if (j == 2) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(CellStyle.BORDER_MEDIUM, pt
+ .getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
+ } else {
+ assertEquals(0, pt.getNumBorders(i, j));
+ }
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
+ PropertyTemplate.Extent.HORIZONTAL);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ assertEquals(2, pt.getNumBorders(i, j));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
+ PropertyTemplate.Extent.INSIDE_HORIZONTAL);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ if (i == 0) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(CellStyle.BORDER_MEDIUM, pt
+ .getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
+ } else if (i == 2) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
+ } else {
+ assertEquals(2, pt.getNumBorders(i, j));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
+ assertEquals(CellStyle.BORDER_MEDIUM, pt
+ .getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
+ }
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
+ PropertyTemplate.Extent.OUTSIDE_HORIZONTAL);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ if (i == 0) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
+ } else if (i == 2) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(CellStyle.BORDER_MEDIUM, pt
+ .getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
+ } else {
+ assertEquals(0, pt.getNumBorders(i, j));
+ }
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
+ PropertyTemplate.Extent.VERTICAL);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ assertEquals(2, pt.getNumBorders(i, j));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
+ PropertyTemplate.Extent.INSIDE_VERTICAL);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ if (j == 0) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(CellStyle.BORDER_MEDIUM, pt
+ .getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
+ } else if (j == 2) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
+ } else {
+ assertEquals(2, pt.getNumBorders(i, j));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
+ assertEquals(CellStyle.BORDER_MEDIUM, pt
+ .getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
+ }
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorders(a1c3, CellStyle.BORDER_MEDIUM,
+ PropertyTemplate.Extent.OUTSIDE_VERTICAL);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ if (j == 0) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(CellStyle.BORDER_MEDIUM,
+ pt.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
+ } else if (j == 2) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(CellStyle.BORDER_MEDIUM, pt
+ .getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
+ } else {
+ assertEquals(0, pt.getNumBorders(i, j));
+ }
+ }
+ }
+ }
+
+ @Test
+ public void drawBorderColors() throws IOException {
+ CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
+ PropertyTemplate pt = new PropertyTemplate();
+ pt.drawBorderColors(a1c3, IndexedColors.RED.getIndex(),
+ PropertyTemplate.Extent.ALL);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ assertEquals(4, pt.getNumBorders(i, j));
+ assertEquals(4, pt.getNumBorderColors(i, j));
+ assertEquals(IndexedColors.RED.getIndex(), pt
+ .getTemplateProperty(i, j, CellUtil.TOP_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.BOTTOM_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(), pt
+ .getTemplateProperty(i, j, CellUtil.LEFT_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.RIGHT_BORDER_COLOR));
+ }
+ }
+ pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
+ PropertyTemplate.Extent.OUTSIDE);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ assertEquals(4, pt.getNumBorders(i, j));
+ assertEquals(4, pt.getNumBorderColors(i, j));
+ if (i == 0) {
+ if (j == 0) {
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.TOP_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.BOTTOM_BORDER_COLOR));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.LEFT_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.RIGHT_BORDER_COLOR));
+ } else if (j == 2) {
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.TOP_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.BOTTOM_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.LEFT_BORDER_COLOR));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.RIGHT_BORDER_COLOR));
+ } else {
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.TOP_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.BOTTOM_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.LEFT_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.RIGHT_BORDER_COLOR));
+ }
+ } else if (i == 2) {
+ if (j == 0) {
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.TOP_BORDER_COLOR));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.BOTTOM_BORDER_COLOR));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.LEFT_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.RIGHT_BORDER_COLOR));
+ } else if (j == 2) {
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.TOP_BORDER_COLOR));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.BOTTOM_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.LEFT_BORDER_COLOR));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.RIGHT_BORDER_COLOR));
+ } else {
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.TOP_BORDER_COLOR));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.BOTTOM_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.LEFT_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.RIGHT_BORDER_COLOR));
+ }
+ } else {
+ if (j == 0) {
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.TOP_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.BOTTOM_BORDER_COLOR));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.LEFT_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.RIGHT_BORDER_COLOR));
+ } else if (j == 2) {
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.TOP_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.BOTTOM_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.LEFT_BORDER_COLOR));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.RIGHT_BORDER_COLOR));
+ } else {
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.TOP_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.BOTTOM_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.LEFT_BORDER_COLOR));
+ assertEquals(IndexedColors.RED.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.RIGHT_BORDER_COLOR));
+ }
+ }
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
+ PropertyTemplate.Extent.NONE);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ assertEquals(0, pt.getNumBorders(i, j));
+ assertEquals(0, pt.getNumBorderColors(i, j));
+ }
+ }
+ pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
+ PropertyTemplate.Extent.TOP);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ if (i == 0) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(1, pt.getNumBorderColors(i, j));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.TOP_BORDER_COLOR));
+ } else {
+ assertEquals(0, pt.getNumBorders(i, j));
+ assertEquals(0, pt.getNumBorderColors(i, j));
+ }
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
+ PropertyTemplate.Extent.BOTTOM);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ if (i == 2) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(1, pt.getNumBorderColors(i, j));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.BOTTOM_BORDER_COLOR));
+ } else {
+ assertEquals(0, pt.getNumBorders(i, j));
+ assertEquals(0, pt.getNumBorderColors(i, j));
+ }
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
+ PropertyTemplate.Extent.LEFT);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ if (j == 0) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(1, pt.getNumBorderColors(i, j));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.LEFT_BORDER_COLOR));
+ } else {
+ assertEquals(0, pt.getNumBorders(i, j));
+ assertEquals(0, pt.getNumBorderColors(i, j));
+ }
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
+ PropertyTemplate.Extent.RIGHT);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ if (j == 2) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(1, pt.getNumBorderColors(i, j));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.RIGHT_BORDER_COLOR));
+ } else {
+ assertEquals(0, pt.getNumBorders(i, j));
+ assertEquals(0, pt.getNumBorderColors(i, j));
+ }
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
+ PropertyTemplate.Extent.HORIZONTAL);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ assertEquals(2, pt.getNumBorders(i, j));
+ assertEquals(2, pt.getNumBorderColors(i, j));
+ assertEquals(IndexedColors.BLUE.getIndex(), pt
+ .getTemplateProperty(i, j, CellUtil.TOP_BORDER_COLOR));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.BOTTOM_BORDER_COLOR));
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
+ PropertyTemplate.Extent.INSIDE_HORIZONTAL);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ if (i == 0) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(1, pt.getNumBorderColors(i, j));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.BOTTOM_BORDER_COLOR));
+ } else if (i == 2) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(1, pt.getNumBorderColors(i, j));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.TOP_BORDER_COLOR));
+ } else {
+ assertEquals(2, pt.getNumBorders(i, j));
+ assertEquals(2, pt.getNumBorderColors(i, j));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.TOP_BORDER_COLOR));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.BOTTOM_BORDER_COLOR));
+ }
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
+ PropertyTemplate.Extent.OUTSIDE_HORIZONTAL);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ if (i == 0) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(1, pt.getNumBorderColors(i, j));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.TOP_BORDER_COLOR));
+ } else if (i == 2) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(1, pt.getNumBorderColors(i, j));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.BOTTOM_BORDER_COLOR));
+ } else {
+ assertEquals(0, pt.getNumBorders(i, j));
+ assertEquals(0, pt.getNumBorderColors(i, j));
+ }
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
+ PropertyTemplate.Extent.VERTICAL);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ assertEquals(2, pt.getNumBorders(i, j));
+ assertEquals(2, pt.getNumBorderColors(i, j));
+ assertEquals(IndexedColors.BLUE.getIndex(), pt
+ .getTemplateProperty(i, j, CellUtil.LEFT_BORDER_COLOR));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.RIGHT_BORDER_COLOR));
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorderColors(a1c3, IndexedColors.BLUE.getIndex(),
+ PropertyTemplate.Extent.INSIDE_VERTICAL);
+ for (int i = 0; i <= 2; i++) {
+ for (int j = 0; j <= 2; j++) {
+ if (j == 0) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(1, pt.getNumBorderColors(i, j));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.RIGHT_BORDER_COLOR));
+ } else if (j == 2) {
+ assertEquals(1, pt.getNumBorders(i, j));
+ assertEquals(1, pt.getNumBorderColors(i, j));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.LEFT_BORDER_COLOR));
+ } else {
+ assertEquals(2, pt.getNumBorders(i, j));
+ assertEquals(2, pt.getNumBorderColors(i, j));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.LEFT_BORDER_COLOR));
+ assertEquals(IndexedColors.BLUE.getIndex(),
+ pt.getTemplateProperty(i, j,
+ CellUtil.RIGHT_BORDER_COLOR));
+ }
+ }
+ }
+ pt.drawBorders(a1c3, CellStyle.BORDER_NONE,
+ PropertyTemplate.Extent.NONE);
+ pt.drawBorderColors(a1c3, IndexedColors.AUTOMATIC.getIndex(),
[... 135 lines stripped ...]
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org