Package org.krysalis.barcode4j.impl
Class DefaultCanvasLogicHandler
java.lang.Object
org.krysalis.barcode4j.impl.DefaultCanvasLogicHandler
- All Implemented Interfaces:
BarcodeLogicHandler,ClassicBarcodeLogicHandler
- Direct Known Subclasses:
ITF14CanvasLogicHandler
Default Logic Handler implementation for painting on a Canvas.
- Version:
- $Id: DefaultCanvasLogicHandler.java,v 1.10 2009-03-11 10:42:15 jmaerki Exp $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AbstractBarcodeBeanthe barcode beanprotected Canvasthe canvas to paint onprotected BarcodeDimensionthe barcode dimensions -
Constructor Summary
ConstructorsConstructorDescriptionDefaultCanvasLogicHandler(AbstractBarcodeBean bcBean, Canvas canvas) Main constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBar(boolean black, int width) This method indicates a new bar to be painted.voidThis is always the last method called.voidThis method indicates the end of a previously started bar group.protected doubleReturns the start X position of the bars.protected doubleReturns the start Y position of the bars.protected doubleReturns the vertical text baseline position.voidstartBarcode(String msg, String formattedMsg) This is always the first method called.voidstartBarGroup(BarGroup type, String submsg) This method is called when a new group of bars is about to start.
-
Field Details
-
bcBean
the barcode bean -
canvas
the canvas to paint on -
dimensions
the barcode dimensions
-
-
Constructor Details
-
DefaultCanvasLogicHandler
Main constructor.- Parameters:
bcBean- the barcode implementation classcanvas- the canvas to paint to
-
-
Method Details
-
getStartX
protected double getStartX()Returns the start X position of the bars.- Returns:
- the start X position of the bars.
-
getStartY
protected double getStartY()Returns the start Y position of the bars.- Returns:
- the start Y position of the bars.
-
startBarcode
This is always the first method called. It is called to inform the logic handler that a new barcode is about to be painted.- Specified by:
startBarcodein interfaceBarcodeLogicHandler- Parameters:
msg- full message to be encodedformattedMsg- message as it is to be presented in the human-readable part
-
endBarcode
public void endBarcode()This is always the last method called. It is called to inform the logic handler that the generation of barcode logic has stopped.- Specified by:
endBarcodein interfaceBarcodeLogicHandler
-
startBarGroup
This method is called when a new group of bars is about to start. A group of bars may be generated by a character (or group of characters) of the message to be encoded or by a start/end control group.- Specified by:
startBarGroupin interfaceClassicBarcodeLogicHandler- Parameters:
type- a constant indicating the type of group. The meaning of the integer values is implementation-dependant.submsg- In case of parts of the message to be encoded this parameter holds the character or characters being encoded.
-
addBar
public void addBar(boolean black, int width) This method indicates a new bar to be painted.- Specified by:
addBarin interfaceClassicBarcodeLogicHandler- Parameters:
black- True if the bar is to be painted black, False if white/transparentwidth- logical weight of the bar. Concrete implementations are free to define this to be height or width. For example, 1 may be interpreted as "narrow bar", 2 as "wide bar" for certain barcodes. While other barcodes might define 1 to be "short bar", 2 as "tall bar". Also, this should not be confused with the effective painting width, or the actual physical size of the bar.
-
endBarGroup
public void endBarGroup()This method indicates the end of a previously started bar group. The method calls to startBarGroup and endBarGroup form a stack.- Specified by:
endBarGroupin interfaceClassicBarcodeLogicHandler
-
getTextBaselinePosition
protected double getTextBaselinePosition()Returns the vertical text baseline position.- Returns:
- the vertical text baseline position
-