public abstract class Barcode extends JComponent implements Printable
JComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
protected int |
barHeight |
protected int |
barWidth |
protected String |
data |
protected boolean |
drawingQuietSection |
protected boolean |
drawingText |
protected String |
label |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTNO_SUCH_PAGE, PAGE_EXISTSABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Modifier | Constructor and Description |
|---|---|
protected |
Barcode(String data) |
| Modifier and Type | Method and Description |
|---|---|
protected String |
beautify(String s) |
protected abstract Module |
calculateChecksum() |
protected int |
calculateMinimumBarHeight(int resolution) |
void |
draw(Graphics2D g,
int x,
int y)
Renders this
Barcode at the specified location in
the specified Graphics2D context. |
protected abstract Dimension |
draw(Output output,
int x,
int y,
int barWidth,
int barHeight) |
protected int |
drawModule(Module module,
Output output,
int x,
int y,
int barWidth,
int barHeight) |
protected abstract Module[] |
encodeData() |
Rectangle |
getBounds()
From
JComponent. |
Rectangle |
getBounds(Rectangle rv)
From
JComponent. |
String |
getData()
Returns the data that the barcode is coding for.
|
int |
getHeight()
From
JComponent. |
String |
getLabel()
Returns the text that will be displayed underneath the barcode (if requested).
|
Dimension |
getMaximumSize()
From
JComponent. |
Dimension |
getMinimumSize()
From
JComponent. |
protected abstract Module |
getPostAmble() |
protected abstract Module |
getPreAmble() |
Dimension |
getPreferredSize()
From
JComponent. |
protected int |
getResolution() |
Dimension |
getSize()
From
JComponent. |
int |
getWidth()
From
JComponent. |
int |
getX()
From
JComponent. |
int |
getY()
From
JComponent. |
boolean |
isDrawingQuietSection()
Indicates whether the barcode is drawing leading and trailing white space/quiet area.
|
boolean |
isDrawingText()
Indicates whether the barcode is drawing a text label underneath the barcode or not.
|
void |
output(Output output) |
protected void |
paintComponent(Graphics g)
From
JComponent. |
int |
print(Graphics g,
PageFormat pageFormat,
int pageIndex) |
void |
setBarHeight(int barHeight)
Sets the desired height for the bars in the barcode (in pixels).
|
void |
setBarWidth(int barWidth)
Sets the desired bar width for the barcode.
|
void |
setDrawingQuietSection(boolean drawingQuietSection)
Indicates whether the leading and trailing white space should be rendered.
|
void |
setDrawingText(boolean drawingText)
Indicates whether the barcode data should be shown as a string underneath the
barcode or not.
|
void |
setFont(Font font)
Sets the font to use when drawing the barcode data string underneath the barcode.
|
void |
setLabel(String label)
Sets the human readable text to be displayed underneath the barcode.
|
void |
setResolution(int resolution)
Sets the desired output resolution for the barcode.
|
String |
toString() |
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUIadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycleprotected String data
protected String label
protected boolean drawingText
protected boolean drawingQuietSection
protected int barWidth
protected int barHeight
protected Barcode(String data) throws BarcodeException
BarcodeExceptionpublic String getData()
public void setFont(Font font)
setFont in class JComponentfont - The font to usepublic void setDrawingText(boolean drawingText)
drawingText - True if the text should be shown, false if notpublic boolean isDrawingText()
public void setDrawingQuietSection(boolean drawingQuietSection)
drawingQuietSection - True if the quiet area/white space should be shown, false if notpublic boolean isDrawingQuietSection()
public void setBarWidth(int barWidth)
barWidth - The desired width of the thinnest bar in pixelspublic void setBarHeight(int barHeight)
barHeight - The desired height of the barcode bars in pixelspublic void setResolution(int resolution)
resolution - The desired output resolution (in dots per inch)public int getX()
JComponent.getX in class JComponentpublic int getY()
JComponent.getY in class JComponentpublic int getWidth()
JComponent.getWidth in class JComponentpublic int getHeight()
JComponent.getHeight in class JComponentpublic Rectangle getBounds()
JComponent.public Rectangle getBounds(Rectangle rv)
JComponent.getBounds in class JComponentrv - The rectangle to set the bounds onpublic Dimension getPreferredSize()
JComponent.getPreferredSize in class JComponentpublic Dimension getMinimumSize()
JComponent.getMinimumSize in class JComponentpublic Dimension getMaximumSize()
JComponent.getMaximumSize in class JComponentpublic Dimension getSize()
JComponent.public void draw(Graphics2D g, int x, int y) throws OutputException
Barcode at the specified location in
the specified Graphics2D context.
The origin of the layout is placed at x, y. Rendering may touch
any point within getBounds() of this position. This
leaves the g2 unchanged.g - The graphics contextx - The horizontal value of the upper left co-ordinate of the bounding boxy - The vertical value of the upper left co-ordinate of the bounding boxOutputExceptionpublic void output(Output output) throws OutputException
OutputExceptionprotected abstract Module[] encodeData()
protected abstract Module calculateChecksum()
protected abstract Module getPreAmble()
protected abstract Module getPostAmble()
protected abstract Dimension draw(Output output, int x, int y, int barWidth, int barHeight) throws OutputException
OutputExceptionpublic String getLabel()
public void setLabel(String label)
label - the human readable barcode textgetLabel()protected int calculateMinimumBarHeight(int resolution)
protected void paintComponent(Graphics g)
JComponent.paintComponent in class JComponentg - The graphics to paint the component ontoprotected int getResolution()
protected int drawModule(Module module, Output output, int x, int y, int barWidth, int barHeight) throws OutputException
OutputExceptionpublic int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException
print in interface PrintablePrinterExceptionCopyright © 2003-2013 barbecue.sourceforge.net. All Rights Reserved.