1 | /* | |
2 | * $Id: BarcodeCodabar.java 4065 2009-09-16 23:09:11Z psoares33 $ | |
3 | * | |
4 | * Copyright 2002-2006 by Paulo Soares. | |
5 | * | |
6 | * The contents of this file are subject to the Mozilla Public License Version 1.1 | |
7 | * (the "License"); you may not use this file except in compliance with the License. | |
8 | * You may obtain a copy of the License at http://www.mozilla.org/MPL/ | |
9 | * | |
10 | * Software distributed under the License is distributed on an "AS IS" basis, | |
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
12 | * for the specific language governing rights and limitations under the License. | |
13 | * | |
14 | * The Original Code is 'iText, a free JAVA-PDF library'. | |
15 | * | |
16 | * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by | |
17 | * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie. | |
18 | * All Rights Reserved. | |
19 | * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer | |
20 | * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved. | |
21 | * | |
22 | * Contributor(s): all the names of the contributors are added in the source code | |
23 | * where applicable. | |
24 | * | |
25 | * Alternatively, the contents of this file may be used under the terms of the | |
26 | * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the | |
27 | * provisions of LGPL are applicable instead of those above. If you wish to | |
28 | * allow use of your version of this file only under the terms of the LGPL | |
29 | * License and not to allow others to use your version of this file under | |
30 | * the MPL, indicate your decision by deleting the provisions above and | |
31 | * replace them with the notice and other provisions required by the LGPL. | |
32 | * If you do not delete the provisions above, a recipient may use your version | |
33 | * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE. | |
34 | * | |
35 | * This library is free software; you can redistribute it and/or modify it | |
36 | * under the terms of the MPL as stated above or under the terms of the GNU | |
37 | * Library General Public License as published by the Free Software Foundation; | |
38 | * either version 2 of the License, or any later version. | |
39 | * | |
40 | * This library is distributed in the hope that it will be useful, but WITHOUT | |
41 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
42 | * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more | |
43 | * details. | |
44 | * | |
45 | * If you didn't download this code from the following link, you should check if | |
46 | * you aren't using an obsolete version: | |
47 | * http://www.lowagie.com/iText/ | |
48 | */ | |
49 | package com.lowagie.text.pdf; | |
50 | ||
51 | import java.awt.Canvas; | |
52 | import java.awt.Color; | |
53 | import java.awt.Image; | |
54 | import java.awt.image.MemoryImageSource; | |
55 | import com.lowagie.text.error_messages.MessageLocalization; | |
56 | ||
57 | import com.lowagie.text.Element; | |
58 | ||
59 | import com.lowagie.text.Rectangle; | |
60 | import com.lowagie.text.ExceptionConverter; | |
61 | ||
62 | /** Implements the code codabar. The default parameters are: | |
63 | * <pre> | |
64 | *x = 0.8f; | |
65 | *n = 2; | |
66 | *font = BaseFont.createFont("Helvetica", "winansi", false); | |
67 | *size = 8; | |
68 | *baseline = size; | |
69 | *barHeight = size * 3; | |
70 | *textAlignment = Element.ALIGN_CENTER; | |
71 | *generateChecksum = false; | |
72 | *checksumText = false; | |
73 | *startStopText = false; | |
74 | * </pre> | |
75 | * | |
76 | * @author Paulo Soares (psoares@consiste.pt) | |
77 | */ | |
78 | public class BarcodeCodabar extends Barcode{ | |
79 | ||
80 | /** | |
81 | * The bars to generate the code. | |
82 | */ | |
83 | private static final byte[][] BARS = | |
84 | { | |
85 | {0, 0, 0, 0, 0, 1, 1}, // 0 | |
86 | {0, 0, 0, 0, 1, 1, 0}, // 1 | |
87 | {0, 0, 0, 1, 0, 0, 1}, // 2 | |
88 | {1, 1, 0, 0, 0, 0, 0}, // 3 | |
89 | {0, 0, 1, 0, 0, 1, 0}, // 4 | |
90 | {1, 0, 0, 0, 0, 1, 0}, // 5 | |
91 | {0, 1, 0, 0, 0, 0, 1}, // 6 | |
92 | {0, 1, 0, 0, 1, 0, 0}, // 7 | |
93 | {0, 1, 1, 0, 0, 0, 0}, // 8 | |
94 | {1, 0, 0, 1, 0, 0, 0}, // 9 | |
95 | {0, 0, 0, 1, 1, 0, 0}, // - | |
96 | {0, 0, 1, 1, 0, 0, 0}, // $ | |
97 | {1, 0, 0, 0, 1, 0, 1}, // : | |
98 | {1, 0, 1, 0, 0, 0, 1}, // / | |
99 | {1, 0, 1, 0, 1, 0, 0}, // . | |
100 | {0, 0, 1, 0, 1, 0, 1}, // + | |
101 | {0, 0, 1, 1, 0, 1, 0}, // a | |
102 | {0, 1, 0, 1, 0, 0, 1}, // b | |
103 | {0, 0, 0, 1, 0, 1, 1}, // c | |
104 | {0, 0, 0, 1, 1, 1, 0} // d | |
105 | }; | |
106 | | |
107 | /** The index chars to <CODE>BARS</CODE>. | |
108 | */ | |
109 | private static final String CHARS = "0123456789-$:/.+ABCD"; | |
110 | | |
111 | private static final int START_STOP_IDX = 16; | |
112 | /** Creates a new BarcodeCodabar. | |
113 | */ | |
114 | public BarcodeCodabar() { | |
115 | try { | |
116 | x = 0.8f; | |
117 | n = 2; | |
118 | font = BaseFont.createFont("Helvetica", "winansi", false); | |
119 | size = 8; | |
120 | baseline = size; | |
121 |
1
1. |
barHeight = size * 3; |
122 | textAlignment = Element.ALIGN_CENTER; | |
123 | generateChecksum = false; | |
124 | checksumText = false; | |
125 | startStopText = false; | |
126 | codeType = CODABAR; | |
127 | } | |
128 | catch (Exception e) { | |
129 | throw new ExceptionConverter(e); | |
130 | } | |
131 | } | |
132 | | |
133 | /** Creates the bars. | |
134 | * @param text the text to create the bars | |
135 | * @return the bars | |
136 | */ | |
137 | public static byte[] getBarsCodabar(String text) { | |
138 | text = text.toUpperCase(); | |
139 | int len = text.length(); | |
140 |
2
1. getBarsCodabar : changed conditional boundary → NO_COVERAGE 2. getBarsCodabar : negated conditional → NO_COVERAGE |
if (len < 2) |
141 | throw new IllegalArgumentException(MessageLocalization.getComposedMessage("codabar.must.have.at.least.a.start.and.stop.character")); | |
142 |
5
1. getBarsCodabar : changed conditional boundary → NO_COVERAGE 2. getBarsCodabar : changed conditional boundary → NO_COVERAGE 3. getBarsCodabar : Replaced integer subtraction with addition → NO_COVERAGE 4. getBarsCodabar : negated conditional → NO_COVERAGE 5. getBarsCodabar : negated conditional → NO_COVERAGE |
if (CHARS.indexOf(text.charAt(0)) < START_STOP_IDX || CHARS.indexOf(text.charAt(len - 1)) < START_STOP_IDX) |
143 | throw new IllegalArgumentException(MessageLocalization.getComposedMessage("codabar.must.have.one.of.abcd.as.start.stop.character")); | |
144 |
2
1. getBarsCodabar : Replaced integer multiplication with division → NO_COVERAGE 2. getBarsCodabar : Replaced integer subtraction with addition → NO_COVERAGE |
byte[] bars = new byte[text.length() * 8 - 1]; |
145 |
3
1. getBarsCodabar : changed conditional boundary → NO_COVERAGE 2. getBarsCodabar : Changed increment from 1 to -1 → NO_COVERAGE 3. getBarsCodabar : negated conditional → NO_COVERAGE |
for (int k = 0; k < len; ++k) { |
146 | int idx = CHARS.indexOf(text.charAt(k)); | |
147 |
7
1. getBarsCodabar : changed conditional boundary → NO_COVERAGE 2. getBarsCodabar : changed conditional boundary → NO_COVERAGE 3. getBarsCodabar : changed conditional boundary → NO_COVERAGE 4. getBarsCodabar : Replaced integer subtraction with addition → NO_COVERAGE 5. getBarsCodabar : negated conditional → NO_COVERAGE 6. getBarsCodabar : negated conditional → NO_COVERAGE 7. getBarsCodabar : negated conditional → NO_COVERAGE |
if (idx >= START_STOP_IDX && k > 0 && k < len - 1) |
148 | throw new IllegalArgumentException(MessageLocalization.getComposedMessage("in.codabar.start.stop.characters.are.only.allowed.at.the.extremes")); | |
149 |
2
1. getBarsCodabar : changed conditional boundary → NO_COVERAGE 2. getBarsCodabar : negated conditional → NO_COVERAGE |
if (idx < 0) |
150 | throw new IllegalArgumentException(MessageLocalization.getComposedMessage("the.character.1.is.illegal.in.codabar", text.charAt(k))); | |
151 |
2
1. getBarsCodabar : Replaced integer multiplication with division → NO_COVERAGE 2. getBarsCodabar : removed call to java/lang/System::arraycopy → NO_COVERAGE |
System.arraycopy(BARS[idx], 0, bars, k * 8, 7); |
152 | } | |
153 |
1
1. getBarsCodabar : mutated return of Object value for com/lowagie/text/pdf/BarcodeCodabar::getBarsCodabar to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return bars; |
154 | } | |
155 | | |
156 | public static String calculateChecksum(String code) { | |
157 |
2
1. calculateChecksum : changed conditional boundary → NO_COVERAGE 2. calculateChecksum : negated conditional → NO_COVERAGE |
if (code.length() < 2) |
158 |
1
1. calculateChecksum : mutated return of Object value for com/lowagie/text/pdf/BarcodeCodabar::calculateChecksum to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return code; |
159 | String text = code.toUpperCase(); | |
160 | int sum = 0; | |
161 | int len = text.length(); | |
162 |
3
1. calculateChecksum : changed conditional boundary → NO_COVERAGE 2. calculateChecksum : Changed increment from 1 to -1 → NO_COVERAGE 3. calculateChecksum : negated conditional → NO_COVERAGE |
for (int k = 0; k < len; ++k) |
163 |
1
1. calculateChecksum : Replaced integer addition with subtraction → NO_COVERAGE |
sum += CHARS.indexOf(text.charAt(k)); |
164 |
4
1. calculateChecksum : Replaced integer addition with subtraction → NO_COVERAGE 2. calculateChecksum : Replaced integer division with multiplication → NO_COVERAGE 3. calculateChecksum : Replaced integer multiplication with division → NO_COVERAGE 4. calculateChecksum : Replaced integer subtraction with addition → NO_COVERAGE |
sum = (sum + 15) / 16 * 16 - sum; |
165 |
3
1. calculateChecksum : Replaced integer subtraction with addition → NO_COVERAGE 2. calculateChecksum : Replaced integer subtraction with addition → NO_COVERAGE 3. calculateChecksum : mutated return of Object value for com/lowagie/text/pdf/BarcodeCodabar::calculateChecksum to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return code.substring(0, len - 1) + CHARS.charAt(sum) + code.substring(len - 1); |
166 | } | |
167 | | |
168 | /** Gets the maximum area that the barcode and the text, if | |
169 | * any, will occupy. The lower left corner is always (0, 0). | |
170 | * @return the size the barcode occupies. | |
171 | */ | |
172 | public Rectangle getBarcodeSize() { | |
173 | float fontX = 0; | |
174 | float fontY = 0; | |
175 | String text = code; | |
176 |
2
1. getBarcodeSize : negated conditional → NO_COVERAGE 2. getBarcodeSize : negated conditional → NO_COVERAGE |
if (generateChecksum && checksumText) |
177 | text = calculateChecksum(code); | |
178 |
1
1. getBarcodeSize : negated conditional → NO_COVERAGE |
if (!startStopText) |
179 |
1
1. getBarcodeSize : Replaced integer subtraction with addition → NO_COVERAGE |
text = text.substring(1, text.length() - 1); |
180 |
1
1. getBarcodeSize : negated conditional → NO_COVERAGE |
if (font != null) { |
181 |
2
1. getBarcodeSize : changed conditional boundary → NO_COVERAGE 2. getBarcodeSize : negated conditional → NO_COVERAGE |
if (baseline > 0) |
182 |
1
1. getBarcodeSize : Replaced float subtraction with addition → NO_COVERAGE |
fontY = baseline - font.getFontDescriptor(BaseFont.DESCENT, size); |
183 | else | |
184 |
2
1. getBarcodeSize : removed negation → NO_COVERAGE 2. getBarcodeSize : Replaced float addition with subtraction → NO_COVERAGE |
fontY = -baseline + size; |
185 |
1
1. getBarcodeSize : negated conditional → NO_COVERAGE |
fontX = font.getWidthPoint(altText != null ? altText : text, size); |
186 | } | |
187 | text = code; | |
188 |
1
1. getBarcodeSize : negated conditional → NO_COVERAGE |
if (generateChecksum) |
189 | text = calculateChecksum(code); | |
190 | byte[] bars = getBarsCodabar(text); | |
191 | int wide = 0; | |
192 | for (byte bar : bars) { | |
193 |
1
1. getBarcodeSize : Replaced integer addition with subtraction → NO_COVERAGE |
wide += bar; |
194 | } | |
195 |
1
1. getBarcodeSize : Replaced integer subtraction with addition → NO_COVERAGE |
int narrow = bars.length - wide; |
196 |
3
1. getBarcodeSize : Replaced float multiplication with division → NO_COVERAGE 2. getBarcodeSize : Replaced float addition with subtraction → NO_COVERAGE 3. getBarcodeSize : Replaced float multiplication with division → NO_COVERAGE |
float fullWidth = x * (narrow + wide * n); |
197 | fullWidth = Math.max(fullWidth, fontX); | |
198 |
1
1. getBarcodeSize : Replaced float addition with subtraction → NO_COVERAGE |
float fullHeight = barHeight + fontY; |
199 |
1
1. getBarcodeSize : mutated return of Object value for com/lowagie/text/pdf/BarcodeCodabar::getBarcodeSize to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Rectangle(fullWidth, fullHeight); |
200 | } | |
201 | | |
202 | /** Places the barcode in a <CODE>PdfContentByte</CODE>. The | |
203 | * barcode is always placed at coordinates (0, 0). Use the | |
204 | * translation matrix to move it elsewhere.<p> | |
205 | * The bars and text are written in the following colors:<p> | |
206 | * <P><TABLE BORDER=1> | |
207 | * <TR> | |
208 | * <TH><P><CODE>barColor</CODE></TH> | |
209 | * <TH><P><CODE>textColor</CODE></TH> | |
210 | * <TH><P>Result</TH> | |
211 | * </TR> | |
212 | * <TR> | |
213 | * <TD><P><CODE>null</CODE></TD> | |
214 | * <TD><P><CODE>null</CODE></TD> | |
215 | * <TD><P>bars and text painted with current fill color</TD> | |
216 | * </TR> | |
217 | * <TR> | |
218 | * <TD><P><CODE>barColor</CODE></TD> | |
219 | * <TD><P><CODE>null</CODE></TD> | |
220 | * <TD><P>bars and text painted with <CODE>barColor</CODE></TD> | |
221 | * </TR> | |
222 | * <TR> | |
223 | * <TD><P><CODE>null</CODE></TD> | |
224 | * <TD><P><CODE>textColor</CODE></TD> | |
225 | * <TD><P>bars painted with current color<br>text painted with <CODE>textColor</CODE></TD> | |
226 | * </TR> | |
227 | * <TR> | |
228 | * <TD><P><CODE>barColor</CODE></TD> | |
229 | * <TD><P><CODE>textColor</CODE></TD> | |
230 | * <TD><P>bars painted with <CODE>barColor</CODE><br>text painted with <CODE>textColor</CODE></TD> | |
231 | * </TR> | |
232 | * </TABLE> | |
233 | * @param cb the <CODE>PdfContentByte</CODE> where the barcode will be placed | |
234 | * @param barColor the color of the bars. It can be <CODE>null</CODE> | |
235 | * @param textColor the color of the text. It can be <CODE>null</CODE> | |
236 | * @return the dimensions the barcode occupies | |
237 | */ | |
238 | public Rectangle placeBarcode(PdfContentByte cb, Color barColor, Color textColor) { | |
239 | String fullCode = code; | |
240 |
2
1. placeBarcode : negated conditional → NO_COVERAGE 2. placeBarcode : negated conditional → NO_COVERAGE |
if (generateChecksum && checksumText) |
241 | fullCode = calculateChecksum(code); | |
242 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
if (!startStopText) |
243 |
1
1. placeBarcode : Replaced integer subtraction with addition → NO_COVERAGE |
fullCode = fullCode.substring(1, fullCode.length() - 1); |
244 | float fontX = 0; | |
245 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
if (font != null) { |
246 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
fontX = font.getWidthPoint(fullCode = altText != null ? altText : fullCode, size); |
247 | } | |
248 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
byte[] bars = getBarsCodabar(generateChecksum ? calculateChecksum(code) : code); |
249 | int wide = 0; | |
250 | for (byte bar1 : bars) { | |
251 |
1
1. placeBarcode : Replaced integer addition with subtraction → NO_COVERAGE |
wide += bar1; |
252 | } | |
253 |
1
1. placeBarcode : Replaced integer subtraction with addition → NO_COVERAGE |
int narrow = bars.length - wide; |
254 |
3
1. placeBarcode : Replaced float multiplication with division → NO_COVERAGE 2. placeBarcode : Replaced float addition with subtraction → NO_COVERAGE 3. placeBarcode : Replaced float multiplication with division → NO_COVERAGE |
float fullWidth = x * (narrow + wide * n); |
255 | float barStartX = 0; | |
256 | float textStartX = 0; | |
257 | switch (textAlignment) { | |
258 | case Element.ALIGN_LEFT: | |
259 | break; | |
260 | case Element.ALIGN_RIGHT: | |
261 |
2
1. placeBarcode : changed conditional boundary → NO_COVERAGE 2. placeBarcode : negated conditional → NO_COVERAGE |
if (fontX > fullWidth) |
262 |
1
1. placeBarcode : Replaced float subtraction with addition → NO_COVERAGE |
barStartX = fontX - fullWidth; |
263 | else | |
264 |
1
1. placeBarcode : Replaced float subtraction with addition → NO_COVERAGE |
textStartX = fullWidth - fontX; |
265 | break; | |
266 | default: | |
267 |
2
1. placeBarcode : changed conditional boundary → NO_COVERAGE 2. placeBarcode : negated conditional → NO_COVERAGE |
if (fontX > fullWidth) |
268 |
2
1. placeBarcode : Replaced float subtraction with addition → NO_COVERAGE 2. placeBarcode : Replaced float division with multiplication → NO_COVERAGE |
barStartX = (fontX - fullWidth) / 2; |
269 | else | |
270 |
2
1. placeBarcode : Replaced float subtraction with addition → NO_COVERAGE 2. placeBarcode : Replaced float division with multiplication → NO_COVERAGE |
textStartX = (fullWidth - fontX) / 2; |
271 | break; | |
272 | } | |
273 | float barStartY = 0; | |
274 | float textStartY = 0; | |
275 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
if (font != null) { |
276 |
2
1. placeBarcode : changed conditional boundary → NO_COVERAGE 2. placeBarcode : negated conditional → NO_COVERAGE |
if (baseline <= 0) |
277 |
1
1. placeBarcode : Replaced float subtraction with addition → NO_COVERAGE |
textStartY = barHeight - baseline; |
278 | else { | |
279 |
1
1. placeBarcode : removed negation → NO_COVERAGE |
textStartY = -font.getFontDescriptor(BaseFont.DESCENT, size); |
280 |
1
1. placeBarcode : Replaced float addition with subtraction → NO_COVERAGE |
barStartY = textStartY + baseline; |
281 | } | |
282 | } | |
283 | boolean print = true; | |
284 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
if (barColor != null) |
285 |
1
1. placeBarcode : removed call to com/lowagie/text/pdf/PdfContentByte::setColorFill → NO_COVERAGE |
cb.setColorFill(barColor); |
286 | for (byte bar : bars) { | |
287 |
2
1. placeBarcode : Replaced float multiplication with division → NO_COVERAGE 2. placeBarcode : negated conditional → NO_COVERAGE |
float w = (bar == 0 ? x : x * n); |
288 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
if (print) |
289 |
2
1. placeBarcode : Replaced float subtraction with addition → NO_COVERAGE 2. placeBarcode : removed call to com/lowagie/text/pdf/PdfContentByte::rectangle → NO_COVERAGE |
cb.rectangle(barStartX, barStartY, w - inkSpreading, barHeight); |
290 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
print = !print; |
291 |
1
1. placeBarcode : Replaced float addition with subtraction → NO_COVERAGE |
barStartX += w; |
292 | } | |
293 |
1
1. placeBarcode : removed call to com/lowagie/text/pdf/PdfContentByte::fill → NO_COVERAGE |
cb.fill(); |
294 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
if (font != null) { |
295 |
1
1. placeBarcode : negated conditional → NO_COVERAGE |
if (textColor != null) |
296 |
1
1. placeBarcode : removed call to com/lowagie/text/pdf/PdfContentByte::setColorFill → NO_COVERAGE |
cb.setColorFill(textColor); |
297 |
1
1. placeBarcode : removed call to com/lowagie/text/pdf/PdfContentByte::beginText → NO_COVERAGE |
cb.beginText(); |
298 |
1
1. placeBarcode : removed call to com/lowagie/text/pdf/PdfContentByte::setFontAndSize → NO_COVERAGE |
cb.setFontAndSize(font, size); |
299 |
1
1. placeBarcode : removed call to com/lowagie/text/pdf/PdfContentByte::setTextMatrix → NO_COVERAGE |
cb.setTextMatrix(textStartX, textStartY); |
300 |
1
1. placeBarcode : removed call to com/lowagie/text/pdf/PdfContentByte::showText → NO_COVERAGE |
cb.showText(fullCode); |
301 |
1
1. placeBarcode : removed call to com/lowagie/text/pdf/PdfContentByte::endText → NO_COVERAGE |
cb.endText(); |
302 | } | |
303 |
1
1. placeBarcode : mutated return of Object value for com/lowagie/text/pdf/BarcodeCodabar::placeBarcode to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return getBarcodeSize(); |
304 | } | |
305 | ||
306 | /** Creates a <CODE>java.awt.Image</CODE>. This image only | |
307 | * contains the bars without any text. | |
308 | * @param foreground the color of the bars | |
309 | * @param background the color of the background | |
310 | * @return the image | |
311 | */ | |
312 | public java.awt.Image createAwtImage(Color foreground, Color background) { | |
313 | int f = foreground.getRGB(); | |
314 | int g = background.getRGB(); | |
315 | Canvas canvas = new Canvas(); | |
316 | ||
317 | String fullCode = code; | |
318 |
2
1. createAwtImage : negated conditional → NO_COVERAGE 2. createAwtImage : negated conditional → NO_COVERAGE |
if (generateChecksum && checksumText) |
319 | fullCode = calculateChecksum(code); | |
320 |
1
1. createAwtImage : negated conditional → NO_COVERAGE |
if (!startStopText) |
321 |
1
1. createAwtImage : Replaced integer subtraction with addition → NO_COVERAGE |
fullCode = fullCode.substring(1, fullCode.length() - 1); |
322 |
1
1. createAwtImage : negated conditional → NO_COVERAGE |
byte[] bars = getBarsCodabar(generateChecksum ? calculateChecksum(code) : code); |
323 | int wide = 0; | |
324 | for (byte bar1 : bars) { | |
325 |
1
1. createAwtImage : Replaced integer addition with subtraction → NO_COVERAGE |
wide += bar1; |
326 | } | |
327 |
1
1. createAwtImage : Replaced integer subtraction with addition → NO_COVERAGE |
int narrow = bars.length - wide; |
328 |
2
1. createAwtImage : Replaced integer multiplication with division → NO_COVERAGE 2. createAwtImage : Replaced integer addition with subtraction → NO_COVERAGE |
int fullWidth = narrow + wide * (int)n; |
329 | boolean print = true; | |
330 | int ptr = 0; | |
331 | int height = (int)barHeight; | |
332 |
1
1. createAwtImage : Replaced integer multiplication with division → NO_COVERAGE |
int[] pix = new int[fullWidth * height]; |
333 | for (byte bar : bars) { | |
334 |
1
1. createAwtImage : negated conditional → NO_COVERAGE |
int w = (bar == 0 ? 1 : (int) n); |
335 | int c = g; | |
336 |
1
1. createAwtImage : negated conditional → NO_COVERAGE |
if (print) |
337 | c = f; | |
338 |
1
1. createAwtImage : negated conditional → NO_COVERAGE |
print = !print; |
339 |
3
1. createAwtImage : changed conditional boundary → NO_COVERAGE 2. createAwtImage : Changed increment from 1 to -1 → NO_COVERAGE 3. createAwtImage : negated conditional → NO_COVERAGE |
for (int j = 0; j < w; ++j) |
340 |
1
1. createAwtImage : Changed increment from 1 to -1 → NO_COVERAGE |
pix[ptr++] = c; |
341 | } | |
342 |
3
1. createAwtImage : changed conditional boundary → NO_COVERAGE 2. createAwtImage : Replaced integer addition with subtraction → NO_COVERAGE 3. createAwtImage : negated conditional → NO_COVERAGE |
for (int k = fullWidth; k < pix.length; k += fullWidth) { |
343 |
1
1. createAwtImage : removed call to java/lang/System::arraycopy → NO_COVERAGE |
System.arraycopy(pix, 0, pix, k, fullWidth); |
344 | } | |
345 | Image img = canvas.createImage(new MemoryImageSource(fullWidth, height, pix, 0, fullWidth)); | |
346 | | |
347 |
1
1. createAwtImage : mutated return of Object value for com/lowagie/text/pdf/BarcodeCodabar::createAwtImage to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return img; |
348 | } | |
349 | } | |
Mutations | ||
121 |
1.1 |
|
140 |
1.1 2.2 |
|
142 |
1.1 2.2 3.3 4.4 5.5 |
|
144 |
1.1 2.2 |
|
145 |
1.1 2.2 3.3 |
|
147 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 |
|
149 |
1.1 2.2 |
|
151 |
1.1 2.2 |
|
153 |
1.1 |
|
157 |
1.1 2.2 |
|
158 |
1.1 |
|
162 |
1.1 2.2 3.3 |
|
163 |
1.1 |
|
164 |
1.1 2.2 3.3 4.4 |
|
165 |
1.1 2.2 3.3 |
|
176 |
1.1 2.2 |
|
178 |
1.1 |
|
179 |
1.1 |
|
180 |
1.1 |
|
181 |
1.1 2.2 |
|
182 |
1.1 |
|
184 |
1.1 2.2 |
|
185 |
1.1 |
|
188 |
1.1 |
|
193 |
1.1 |
|
195 |
1.1 |
|
196 |
1.1 2.2 3.3 |
|
198 |
1.1 |
|
199 |
1.1 |
|
240 |
1.1 2.2 |
|
242 |
1.1 |
|
243 |
1.1 |
|
245 |
1.1 |
|
246 |
1.1 |
|
248 |
1.1 |
|
251 |
1.1 |
|
253 |
1.1 |
|
254 |
1.1 2.2 3.3 |
|
261 |
1.1 2.2 |
|
262 |
1.1 |
|
264 |
1.1 |
|
267 |
1.1 2.2 |
|
268 |
1.1 2.2 |
|
270 |
1.1 2.2 |
|
275 |
1.1 |
|
276 |
1.1 2.2 |
|
277 |
1.1 |
|
279 |
1.1 |
|
280 |
1.1 |
|
284 |
1.1 |
|
285 |
1.1 |
|
287 |
1.1 2.2 |
|
288 |
1.1 |
|
289 |
1.1 2.2 |
|
290 |
1.1 |
|
291 |
1.1 |
|
293 |
1.1 |
|
294 |
1.1 |
|
295 |
1.1 |
|
296 |
1.1 |
|
297 |
1.1 |
|
298 |
1.1 |
|
299 |
1.1 |
|
300 |
1.1 |
|
301 |
1.1 |
|
303 |
1.1 |
|
318 |
1.1 2.2 |
|
320 |
1.1 |
|
321 |
1.1 |
|
322 |
1.1 |
|
325 |
1.1 |
|
327 |
1.1 |
|
328 |
1.1 2.2 |
|
332 |
1.1 |
|
334 |
1.1 |
|
336 |
1.1 |
|
338 |
1.1 |
|
339 |
1.1 2.2 3.3 |
|
340 |
1.1 |
|
342 |
1.1 2.2 3.3 |
|
343 |
1.1 |
|
347 |
1.1 |