Skip to content

Commit c0a9b6e

Browse files
committed
Move color constants from Color to ColorConstants class
DEVSIX-1527
1 parent 126f872 commit c0a9b6e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+885
-790
lines changed

barcodes/src/test/java/com/itextpdf/barcodes/Barcode128Test.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ This file is part of the iText (R) project.
4343
package com.itextpdf.barcodes;
4444

4545
import com.itextpdf.kernel.PdfException;
46-
import com.itextpdf.kernel.color.Color;
46+
import com.itextpdf.kernel.color.ColorConstants;
4747
import com.itextpdf.kernel.pdf.PdfDocument;
4848
import com.itextpdf.kernel.pdf.PdfPage;
4949
import com.itextpdf.kernel.pdf.PdfReader;
@@ -84,7 +84,7 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti
8484
barcode.setCode("9781935182610");
8585

8686
barcode.setTextAlignment(Barcode1D.ALIGN_LEFT);
87-
barcode.placeBarcode(canvas, Color.BLACK, Color.BLACK);
87+
barcode.placeBarcode(canvas, ColorConstants.BLACK, ColorConstants.BLACK);
8888

8989
document.close();
9090

@@ -105,7 +105,7 @@ public void barcode02Test() throws IOException, PdfException, InterruptedExcepti
105105
barcode.setCode("9781935182610");
106106

107107
barcode.setTextAlignment(Barcode1D.ALIGN_LEFT);
108-
barcode.placeBarcode(canvas, Color.BLACK, Color.BLACK);
108+
barcode.placeBarcode(canvas, ColorConstants.BLACK, ColorConstants.BLACK);
109109

110110
document.close();
111111

barcodes/src/test/java/com/itextpdf/barcodes/Barcode39Test.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ This file is part of the iText (R) project.
4444

4545
import com.itextpdf.io.source.ByteArrayOutputStream;
4646
import com.itextpdf.kernel.PdfException;
47-
import com.itextpdf.kernel.color.Color;
47+
import com.itextpdf.kernel.color.ColorConstants;
4848
import com.itextpdf.kernel.pdf.PdfDocument;
4949
import com.itextpdf.kernel.pdf.PdfPage;
5050
import com.itextpdf.kernel.pdf.PdfReader;
@@ -83,7 +83,7 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti
8383
barcode.setCode("9781935182610");
8484

8585
barcode.setTextAlignment(Barcode1D.ALIGN_LEFT);
86-
barcode.placeBarcode(canvas, Color.BLACK, Color.BLACK);
86+
barcode.placeBarcode(canvas, ColorConstants.BLACK, ColorConstants.BLACK);
8787

8888
document.close();
8989

@@ -102,7 +102,7 @@ public void barcode02Test() throws IOException, PdfException, InterruptedExcepti
102102
barcode.setCode("9781935182610");
103103

104104
barcode.setTextAlignment(Barcode1D.ALIGN_LEFT);
105-
barcode.placeBarcode(canvas, Color.BLACK, Color.BLACK);
105+
barcode.placeBarcode(canvas, ColorConstants.BLACK, ColorConstants.BLACK);
106106

107107
document.close();
108108

barcodes/src/test/java/com/itextpdf/barcodes/BarcodeDataMatrixTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ This file is part of the iText (R) project.
4444

4545

4646
import com.itextpdf.kernel.PdfException;
47-
import com.itextpdf.kernel.color.Color;
47+
import com.itextpdf.kernel.color.ColorConstants;
4848
import com.itextpdf.kernel.pdf.PdfDocument;
4949
import com.itextpdf.kernel.pdf.PdfPage;
5050
import com.itextpdf.kernel.pdf.PdfWriter;
@@ -81,7 +81,7 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti
8181
PdfCanvas canvas = new PdfCanvas(page);
8282
BarcodeDataMatrix barcode = new BarcodeDataMatrix();
8383
barcode.setCode("AAAAAAAAAA;BBBBAAAA3;00028;BBBAA05;AAAA;AAAAAA;1234567;AQWXSZ;JEAN;;;;7894561;AQWXSZ;GEO;;;;1;1;1;1;0;0;1;0;1;0;0;0;1;0;1;0;0;0;0;0;0;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1");
84-
barcode.placeBarcode(canvas, Color.GREEN, 5);
84+
barcode.placeBarcode(canvas, ColorConstants.GREEN, 5);
8585
document.close();
8686

8787
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"));
@@ -96,7 +96,7 @@ public void barcode02Test() throws IOException, PdfException, InterruptedExcepti
9696
PdfPage page1 = document.addNewPage();
9797
PdfCanvas canvas = new PdfCanvas(page1);
9898
BarcodeDataMatrix barcode2 = new BarcodeDataMatrix("дима", "UTF-8");
99-
barcode2.placeBarcode(canvas, Color.GREEN, 10);
99+
barcode2.placeBarcode(canvas, ColorConstants.GREEN, 10);
100100
document.close();
101101

102102
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"));
@@ -115,7 +115,7 @@ public void barcode03Test() throws IOException, PdfException, InterruptedExcepti
115115
barcode3.setWidth(36);
116116
barcode3.setHeight(12);
117117
barcode3.setCode("AbcdFFghijklmnopqrstuWXSQ");
118-
barcode3.placeBarcode(canvas, Color.BLACK, 10);
118+
barcode3.placeBarcode(canvas, ColorConstants.BLACK, 10);
119119
document.close();
120120

121121
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"));
@@ -134,7 +134,7 @@ public void barcode04Test() throws IOException, PdfException, InterruptedExcepti
134134
barcode3.setWidth(36);
135135
barcode3.setHeight(12);
136136
barcode3.setCode("01AbcdefgAbcdefg123451231231234");
137-
barcode3.placeBarcode(canvas, Color.BLACK, 10);
137+
barcode3.placeBarcode(canvas, ColorConstants.BLACK, 10);
138138
document.close();
139139

140140
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"));
@@ -153,7 +153,7 @@ public void barcode05Test() throws IOException, PdfException, InterruptedExcepti
153153
barcode3.setWidth(40);
154154
barcode3.setHeight(40);
155155
barcode3.setCode("aaabbbcccdddAAABBBAAABBaaabbbcccdddaaa");
156-
barcode3.placeBarcode(canvas, Color.BLACK, 10);
156+
barcode3.placeBarcode(canvas, ColorConstants.BLACK, 10);
157157
document.close();
158158

159159
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"));
@@ -172,7 +172,7 @@ public void barcode06Test() throws IOException, PdfException, InterruptedExcepti
172172
barcode3.setWidth(36);
173173
barcode3.setHeight(12);
174174
barcode3.setCode(">>>\r>>>THIS VERY TEXT>>\r>");
175-
barcode3.placeBarcode(canvas, Color.BLACK, 10);
175+
barcode3.placeBarcode(canvas, ColorConstants.BLACK, 10);
176176
document.close();
177177

178178
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"));

barcodes/src/test/java/com/itextpdf/barcodes/BarcodeEANTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ This file is part of the iText (R) project.
4343
package com.itextpdf.barcodes;
4444

4545
import com.itextpdf.kernel.PdfException;
46-
import com.itextpdf.kernel.color.Color;
46+
import com.itextpdf.kernel.color.ColorConstants;
4747
import com.itextpdf.kernel.pdf.PdfDocument;
4848
import com.itextpdf.kernel.pdf.PdfPage;
4949
import com.itextpdf.kernel.pdf.PdfReader;
@@ -84,7 +84,7 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti
8484
barcode.setCode("9781935182610");
8585

8686
barcode.setTextAlignment(Barcode1D.ALIGN_LEFT);
87-
barcode.placeBarcode(canvas, Color.BLACK, Color.BLACK);
87+
barcode.placeBarcode(canvas, ColorConstants.BLACK, ColorConstants.BLACK);
8888

8989
document.close();
9090

@@ -105,7 +105,7 @@ public void barcode02Test() throws IOException, PdfException, InterruptedExcepti
105105
barcode.setCode("97819351");
106106

107107
barcode.setTextAlignment(Barcode1D.ALIGN_LEFT);
108-
barcode.placeBarcode(canvas, Color.BLACK, Color.BLACK);
108+
barcode.placeBarcode(canvas, ColorConstants.BLACK, ColorConstants.BLACK);
109109

110110
document.close();
111111

@@ -129,7 +129,7 @@ public void barcode03Test() throws IOException, PdfException, InterruptedExcepti
129129
codeSUPP.setCode("55999");
130130
codeSUPP.setBaseline(-2);
131131
BarcodeEANSUPP eanSupp = new BarcodeEANSUPP(codeEAN, codeSUPP);
132-
eanSupp.placeBarcode(canvas, null, Color.BLUE);
132+
eanSupp.placeBarcode(canvas, null, ColorConstants.BLUE);
133133

134134
document.close();
135135

barcodes/src/test/java/com/itextpdf/barcodes/BarcodeInter25Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ This file is part of the iText (R) project.
4444

4545

4646
import com.itextpdf.kernel.PdfException;
47-
import com.itextpdf.kernel.color.Color;
47+
import com.itextpdf.kernel.color.ColorConstants;
4848
import com.itextpdf.kernel.pdf.PdfDocument;
4949
import com.itextpdf.kernel.pdf.PdfPage;
5050
import com.itextpdf.kernel.pdf.PdfWriter;
@@ -84,7 +84,7 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti
8484
barcode.setGenerateChecksum(true);
8585
barcode.setCode("41-1200076041-001");
8686
barcode.setTextAlignment(Barcode1D.ALIGN_CENTER);
87-
barcode.placeBarcode(canvas, Color.BLUE, Color.GREEN);
87+
barcode.placeBarcode(canvas, ColorConstants.BLUE, ColorConstants.GREEN);
8888
document.close();
8989

9090
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"));

barcodes/src/test/java/com/itextpdf/barcodes/BarcodePDF417Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ This file is part of the iText (R) project.
4343
package com.itextpdf.barcodes;
4444

4545
import com.itextpdf.kernel.PdfException;
46-
import com.itextpdf.kernel.color.Color;
46+
import com.itextpdf.kernel.color.ColorConstants;
4747
import com.itextpdf.kernel.pdf.PdfDocument;
4848
import com.itextpdf.kernel.pdf.PdfPage;
4949
import com.itextpdf.kernel.pdf.PdfReader;
@@ -143,7 +143,7 @@ private PdfFormXObject createMacroBarcodePart(PdfDocument document, String text,
143143

144144
pf.setCode(text);
145145

146-
return pf.createFormXObject(Color.BLACK, mw, mh, document);
146+
return pf.createFormXObject(ColorConstants.BLACK, mw, mh, document);
147147
}
148148

149149
}

barcodes/src/test/java/com/itextpdf/barcodes/BarcodeQRCodeTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ This file is part of the iText (R) project.
4545
import com.itextpdf.barcodes.qrcode.EncodeHintType;
4646
import com.itextpdf.barcodes.qrcode.ErrorCorrectionLevel;
4747
import com.itextpdf.kernel.PdfException;
48-
import com.itextpdf.kernel.color.Color;
48+
import com.itextpdf.kernel.color.ColorConstants;
4949
import com.itextpdf.kernel.pdf.PdfDocument;
5050
import com.itextpdf.kernel.pdf.PdfPage;
5151
import com.itextpdf.kernel.pdf.PdfWriter;
@@ -55,7 +55,6 @@ This file is part of the iText (R) project.
5555
import com.itextpdf.test.annotations.type.IntegrationTest;
5656

5757
import java.io.IOException;
58-
import java.io.InterruptedIOException;
5958
import java.util.HashMap;
6059
import java.util.Map;
6160

@@ -87,7 +86,7 @@ public void barcode01Test() throws IOException, PdfException, InterruptedExcepti
8786
Map<EncodeHintType, Object> hints = new HashMap<>();
8887
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
8988
BarcodeQRCode barcode = new BarcodeQRCode("some specific text 239214 hello world");
90-
barcode.placeBarcode(canvas, Color.GRAY, 12);
89+
barcode.placeBarcode(canvas, ColorConstants.GRAY, 12);
9190
document.close();
9291

9392
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"));
@@ -104,7 +103,7 @@ public void barcode02Test() throws IOException, PdfException, InterruptedExcepti
104103
Map<EncodeHintType, Object> hints = new HashMap<>();
105104
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
106105
BarcodeQRCode barcode1 = new BarcodeQRCode("дима", hints);
107-
barcode1.placeBarcode(canvas, Color.GRAY, 12);
106+
barcode1.placeBarcode(canvas, ColorConstants.GRAY, 12);
108107
document.close();
109108
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"));
110109
}
@@ -121,7 +120,7 @@ public void barcodeVersioningTest() throws IOException, PdfException, Interrupte
121120
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
122121
hints.put(EncodeHintType.MIN_VERSION_NR, i);
123122
BarcodeQRCode barcode1 = new BarcodeQRCode("дима", hints);
124-
barcode1.placeBarcode(canvas, Color.GRAY, 3);
123+
barcode1.placeBarcode(canvas, ColorConstants.GRAY, 3);
125124
}
126125
document.close();
127126
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + filename, sourceFolder + "cmp_" + filename, destinationFolder, "diff_"));

forms/src/main/java/com/itextpdf/forms/fields/PdfFormField.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ This file is part of the iText (R) project.
5555
import com.itextpdf.io.source.RandomAccessSourceFactory;
5656
import com.itextpdf.kernel.PdfException;
5757
import com.itextpdf.kernel.color.Color;
58+
import com.itextpdf.kernel.color.ColorConstants;
5859
import com.itextpdf.kernel.color.DeviceCmyk;
5960
import com.itextpdf.kernel.color.DeviceGray;
6061
import com.itextpdf.kernel.color.DeviceRgb;
@@ -2727,7 +2728,7 @@ protected void drawMultiLineTextAppearance(Rectangle rect, PdfFont font, float f
27272728
continue;
27282729
if (((PdfNumber) ind).getValue() == index) {
27292730
paragraph.setBackgroundColor(new DeviceRgb(10, 36, 106));
2730-
paragraph.setFontColor(Color.LIGHT_GRAY);
2731+
paragraph.setFontColor(ColorConstants.LIGHT_GRAY);
27312732
}
27322733
}
27332734
}
@@ -2769,7 +2770,7 @@ protected void drawBorder(PdfCanvas canvas, PdfFormXObject xObject, float width,
27692770
borderWidth = 0;
27702771
}
27712772
if (borderColor == null) {
2772-
borderColor = Color.BLACK;
2773+
borderColor = ColorConstants.BLACK;
27732774
}
27742775

27752776
if (backgroundColor != null) {
@@ -3022,7 +3023,7 @@ protected PdfFormXObject drawPushButtonAppearance(float width, float height, Str
30223023

30233024
PdfFormXObject xObject = new PdfFormXObject(new Rectangle(0, 0, width, height));
30243025
if (backgroundColor == null) {
3025-
backgroundColor = Color.LIGHT_GRAY;
3026+
backgroundColor = ColorConstants.LIGHT_GRAY;
30263027
}
30273028
drawBorder(canvas, xObject, width, height);
30283029

@@ -3073,7 +3074,7 @@ protected PdfFormXObject drawPushButtonAppearance(float width, float height, Str
30733074
*/
30743075
protected void drawButton(PdfCanvas canvas, float x, float y, float width, float height, String text, PdfFont font, float fontSize) {
30753076
if (color == null) {
3076-
color = Color.BLACK;
3077+
color = ColorConstants.BLACK;
30773078
}
30783079

30793080
Paragraph paragraph = new Paragraph(text).setFont(font).setFontSize(fontSize).setMargin(0).setMultipliedLeading(1).

kernel/src/main/java/com/itextpdf/kernel/color/Color.java

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,55 +59,94 @@ public class Color implements Serializable {
5959

6060
/**
6161
* Predefined black DeviceRgb color
62+
*
63+
* @deprecated Will be removed in iText 7.1 Use {@link ColorConstants#BLACK} instead.
6264
*/
65+
@Deprecated
6366
public static final Color BLACK = new DeviceRgb(0, 0, 0);
6467
/**
6568
* Predefined blue DeviceRgb color
69+
*
70+
* @deprecated Will be removed in iText 7.1 Use {@link ColorConstants#BLUE} instead.
6671
*/
72+
@Deprecated
6773
public static final Color BLUE = new DeviceRgb(0, 0, 255);
6874
/**
6975
* Predefined cyan DeviceRgb color
76+
*
77+
* @deprecated Will be removed in iText 7.1 Use {@link ColorConstants#CYAN} instead.
7078
*/
79+
@Deprecated
7180
public static final Color CYAN = new DeviceRgb(0, 255, 255);
7281
/**
7382
* Predefined dark gray DeviceRgb color
83+
*
84+
* @deprecated Will be removed in iText 7.1 Use {@link ColorConstants#DARK_GRAY} instead.
7485
*/
86+
@Deprecated
7587
public static final Color DARK_GRAY = new DeviceRgb(64, 64, 64);
7688
/**
7789
* Predefined gray DeviceRgb color
90+
*
91+
* @deprecated Will be removed in iText 7.1 Use {@link ColorConstants#GRAY} instead.
7892
*/
93+
@Deprecated
7994
public static final Color GRAY = new DeviceRgb(128, 128, 128);
8095
/**
8196
* Predefined green DeviceRgb color
97+
*
98+
* @deprecated Will be removed in iText 7.1 Use {@link ColorConstants#GREEN} instead.
8299
*/
100+
@Deprecated
83101
public static final Color GREEN = new DeviceRgb(0, 255, 0);
84102
/**
85103
* Predefined light gray DeviceRgb color
104+
*
105+
* @deprecated Will be removed in iText 7.1 Use {@link ColorConstants#LIGHT_GRAY} instead.
86106
*/
107+
@Deprecated
87108
public static final Color LIGHT_GRAY = new DeviceRgb(192, 192, 192);
88109
/**
89110
* Predefined magenta DeviceRgb color
111+
*
112+
* @deprecated Will be removed in iText 7.1 Use {@link ColorConstants#MAGENTA} instead.
90113
*/
114+
@Deprecated
91115
public static final Color MAGENTA = new DeviceRgb(255, 0, 255);
92116
/**
93117
* Predefined orange DeviceRgb color
118+
*
119+
* @deprecated Will be removed in iText 7.1 Use {@link ColorConstants#ORANGE} instead.
94120
*/
121+
@Deprecated
95122
public static final Color ORANGE = new DeviceRgb(255, 200, 0);
96123
/**
97124
* Predefined pink DeviceRgb color
125+
*
126+
* @deprecated Will be removed in iText 7.1 Use {@link ColorConstants#PINK} instead.
98127
*/
128+
@Deprecated
99129
public static final Color PINK = new DeviceRgb(255, 175, 175);
100130
/**
101131
* Predefined red DeviceRgb color
132+
*
133+
* @deprecated Will be removed in iText 7.1 Use {@link ColorConstants#RED} instead.
102134
*/
135+
@Deprecated
103136
public static final Color RED = new DeviceRgb(255, 0, 0);
104137
/**
105138
* Predefined white DeviceRgb color
139+
*
140+
* @deprecated Will be removed in iText 7.1 Use {@link ColorConstants#WHITE} instead.
106141
*/
142+
@Deprecated
107143
public static final Color WHITE = new DeviceRgb(255, 255, 255);
108144
/**
109145
* Predefined yellow DeviceRgb color
146+
*
147+
* @deprecated Will be removed in iText 7.1 Use {@link ColorConstants#YELLOW} instead.
110148
*/
149+
@Deprecated
111150
public static final Color YELLOW = new DeviceRgb(255, 255, 0);
112151
private static final long serialVersionUID = -6639782922289701126L;
113152

@@ -208,8 +247,8 @@ public static Color makeColor(PdfColorSpace colorSpace, float[] colorValue) {
208247
/**
209248
* Converts {@link com.itextpdf.kernel.color.DeviceCmyk DeviceCmyk} color to
210249
* {@link com.itextpdf.kernel.color.DeviceRgb DeviceRgb} color
211-
* @param cmykColor the DeviceCmyk color which will be converted to DeviceRgb color
212250
*
251+
* @param cmykColor the DeviceCmyk color which will be converted to DeviceRgb color
213252
* @return converted color
214253
*/
215254
public static DeviceRgb convertCmykToRgb(DeviceCmyk cmykColor) {
@@ -227,8 +266,8 @@ public static DeviceRgb convertCmykToRgb(DeviceCmyk cmykColor) {
227266
/**
228267
* Converts {@link com.itextpdf.kernel.color.DeviceRgb DeviceRgb} color to
229268
* {@link com.itextpdf.kernel.color.DeviceCmyk DeviceCmyk} color
230-
* @param rgbColor the DeviceRgb color which will be converted to DeviceCmyk color
231269
*
270+
* @param rgbColor the DeviceRgb color which will be converted to DeviceCmyk color
232271
* @return converted color
233272
*/
234273
public static DeviceCmyk convertRgbToCmyk(DeviceRgb rgbColor) {
@@ -273,6 +312,7 @@ public float[] getColorValue() {
273312

274313
/**
275314
* Sets the color value of the color
315+
*
276316
* @param value new color value
277317
*/
278318
public void setColorValue(float[] value) {

0 commit comments

Comments
 (0)