"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "core/src/main/java/com/google/zxing/oned/OneDimensionalCodeWriter.java" between
zxing-zxing-3.4.1.tar.gz and zxing-zxing-3.5.0.tar.gz

About: ZXing ("zebra crossing") is a multi-format 1D/2D barcode image processing library implemented in Java, with ports to other languages. Info: Project is in maintenance mode (no active development).

OneDimensionalCodeWriter.java  (zxing-zxing-3.4.1):OneDimensionalCodeWriter.java  (zxing-zxing-3.5.0)
skipping to change at line 36 skipping to change at line 36
import java.util.regex.Pattern; import java.util.regex.Pattern;
/** /**
* <p>Encapsulates functionality and implementation that is common to one-dimens ional barcodes.</p> * <p>Encapsulates functionality and implementation that is common to one-dimens ional barcodes.</p>
* *
* @author dsbnatut@gmail.com (Kazuki Nishiura) * @author dsbnatut@gmail.com (Kazuki Nishiura)
*/ */
public abstract class OneDimensionalCodeWriter implements Writer { public abstract class OneDimensionalCodeWriter implements Writer {
private static final Pattern NUMERIC = Pattern.compile("[0-9]+"); private static final Pattern NUMERIC = Pattern.compile("[0-9]+");
/**
* Encode the contents to boolean array expression of one-dimensional barcode.
* Start code and end code should be included in result, and side margins shou
ld not be included.
*
* @param contents barcode contents to encode
* @return a {@code boolean[]} of horizontal pixels (false = white, true = bla
ck)
*/
public abstract boolean[] encode(String contents);
/**
* Can be overwritten if the encode requires to read the hints map. Otherwise
it defaults to {@code encode}.
* @param contents barcode contents to encode
* @param hints encoding hints
* @return a {@code boolean[]} of horizontal pixels (false = white, true = bla
ck)
*/
protected boolean[] encode(String contents, Map<EncodeHintType,?> hints) {
return encode(contents);
}
@Override @Override
public final BitMatrix encode(String contents, BarcodeFormat format, int width , int height) { public final BitMatrix encode(String contents, BarcodeFormat format, int width , int height) {
return encode(contents, format, width, height, null); return encode(contents, format, width, height, null);
} }
/** /**
* Encode the contents following specified format. * Encode the contents following specified format.
* {@code width} and {@code height} are required size. This method may return bigger size * {@code width} and {@code height} are required size. This method may return bigger size
* {@code BitMatrix} when specified size is too small. The user can set both { @code width} and * {@code BitMatrix} when specified size is too small. The user can set both { @code width} and
* {@code height} to zero to get minimum size barcode. If negative value is se t to {@code width} * {@code height} to zero to get minimum size barcode. If negative value is se t to {@code width}
skipping to change at line 73 skipping to change at line 92
if (supportedFormats != null && !supportedFormats.contains(format)) { if (supportedFormats != null && !supportedFormats.contains(format)) {
throw new IllegalArgumentException("Can only encode " + supportedFormats + throw new IllegalArgumentException("Can only encode " + supportedFormats +
", but got " + format); ", but got " + format);
} }
int sidesMargin = getDefaultMargin(); int sidesMargin = getDefaultMargin();
if (hints != null && hints.containsKey(EncodeHintType.MARGIN)) { if (hints != null && hints.containsKey(EncodeHintType.MARGIN)) {
sidesMargin = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString() ); sidesMargin = Integer.parseInt(hints.get(EncodeHintType.MARGIN).toString() );
} }
boolean[] code = encode(contents); boolean[] code = encode(contents, hints);
return renderResult(code, width, height, sidesMargin); return renderResult(code, width, height, sidesMargin);
} }
protected Collection<BarcodeFormat> getSupportedWriteFormats() { protected Collection<BarcodeFormat> getSupportedWriteFormats() {
return null; return null;
} }
/** /**
* @return a byte array of horizontal pixels (0 = white, 1 = black) * @return a byte array of horizontal pixels (0 = white, 1 = black)
*/ */
skipping to change at line 138 skipping to change at line 157
color = !color; // flip color after each segment color = !color; // flip color after each segment
} }
return numAdded; return numAdded;
} }
public int getDefaultMargin() { public int getDefaultMargin() {
// CodaBar spec requires a side margin to be more than ten times wider than narrow space. // CodaBar spec requires a side margin to be more than ten times wider than narrow space.
// This seems like a decent idea for a default for all formats. // This seems like a decent idea for a default for all formats.
return 10; return 10;
} }
/**
* Encode the contents to boolean array expression of one-dimensional barcode.
* Start code and end code should be included in result, and side margins shou
ld not be included.
*
* @param contents barcode contents to encode
* @return a {@code boolean[]} of horizontal pixels (false = white, true = bla
ck)
*/
public abstract boolean[] encode(String contents);
} }
 End of changes. 3 change blocks. 
12 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)