|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent net.sourceforge.jbarcodebean.JBarcodeBean
public class JBarcodeBean
JFC Swing-compatible JavaBeans TM component that renders barcodes in a variety of different formats.
[skip over license and copyright]
LICENSE INFORMATION
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY of FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
See http://www.gnu.org/licenses/lgpl.html.
JBarcodeBean employs the Strategy design pattern*
to abstract the encoding algorithm. The
codeType
property can be set to any class that implements the BarcodeStrategy
interface to determine how the code
property is encoded.
This version of JBarcodeBean is bundled with the following concrete implementations
of BarcodeStrategy
:
Code128
Code39
Code39_2to1
ExtendedCode39
ExtendedCode39_2to1
Interleaved25
Interleaved25_2to1
Codabar
Codabar_2to1
MSI
Ean8
Ean13
*See "Design Patterns Elements of Reusable Object-Oriented Software", Erich Gamma et al. for more information about design patterns.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
static int |
ALIGN_CENTER
Constant indicating that the barcode should be centered along the x-axis. |
static int |
ALIGN_LEFT
Constant indicating that the barcode should be left aligned along the x-axis. |
static int |
ALIGN_RIGHT
Constant indicating that the barcode should be right aligned along the x-axis. |
static int |
LABEL_BOTTOM
Constant indicating that the human readable barcode text should be printed at the bottom of the barcode. |
static int |
LABEL_NONE
Constant indicating that the human readable barcode text should not be printed at all. |
static int |
LABEL_TOP
Constant indicating that the human readable barcode text should be printed at the top of the barcode. |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JBarcodeBean()
Parameterless constructor. |
|
JBarcodeBean(java.lang.String code,
BarcodeStrategy codeType)
Contructor that allows an initial barcode and code type to be specified. |
Method Summary | |
---|---|
java.awt.image.BufferedImage |
draw(java.awt.image.BufferedImage image)
Draws the current barcode into the given image and returns it. |
javax.accessibility.AccessibleContext |
getAccessibleContext()
Returns a simple subclass of AccessibleContext. |
double |
getAngleDegrees()
Accessor method for the angleDegrees property, which determines the angle (from horizontal) at which the barcode is rendered. |
java.awt.Color |
getBackground()
Accessor method for the background property, which determines the control background color (the space around the barcode, and behind the text caption). |
java.awt.Color |
getBarcodeBackground()
Accessor method for the barcodeBackground property, which determines the color of the spaces between the bars in the barcode (typically white). |
int |
getBarcodeHeight()
Accessor method for the barcodeHeight property, which determines the height of the barcode (excluding caption text) in pixels. |
javax.swing.border.Border |
getBorder()
Accessor methor for the border property. |
java.lang.String |
getCode()
Accessor method for the code property, which is the text encoded in the barcode. |
BarcodeStrategy |
getCodeType()
Accessor method for the codeType property, which is the barcode type. |
java.awt.Font |
getFont()
Accessor method for the font property. |
java.awt.Color |
getForeground()
Accessor method for the foreground property, which determines the color of the bars and caption text (typically black). |
int |
getHorizontalAlignment()
Returns the alignment of the barcode along the X axis. |
int |
getLabelPosition()
Returns the label position of the human readable barcode text. |
java.awt.Dimension |
getMinimumSize()
Accessor method for minimumSize property. |
int |
getNarrowestBarWidth()
Accessor method for the narrowestBarWidth property, which determines the width (in pixels) of the narrowest bar in the barcode. |
java.awt.Dimension |
getPreferredSize()
Accessor method for the preferredSize property. |
static java.lang.String |
getVersion()
Returns the version of this JBarcodeBean implementation. |
boolean |
isCheckDigit()
Accessor method for the checkDigit property, which determines whether a check digit is encoded in the barcode. |
boolean |
isFocusTraversable()
Always returns false, as this control cannot receive focus. |
boolean |
isOpaque()
Always returns true, as this component renders its entire drawing area. |
boolean |
isShowText()
Deprecated. As of 1.2.0, replaced by getLabelPosition() .
This will return true if label position is LABEL_BOTTOM
and false otherwise. |
java.awt.Dimension |
minimumSize()
Deprecated. Use getMinimumSize() . |
protected void |
paintComponent(java.awt.Graphics graphics)
Component paint method. |
protected java.lang.String |
paramString()
Always returns the value of the code property. |
java.awt.Dimension |
preferredSize()
Deprecated. Use getPreferredSize() . |
void |
setAngleDegrees(double angleDegrees)
Mutator method for the angleDegrees property, which determines the angle (from horizontal) at which the barcode is rendered. |
void |
setBackground(java.awt.Color c)
Mutator method for the background property, which determines the control background color (the space around the barcode, and behind the text caption). |
void |
setBarcodeBackground(java.awt.Color barcodeBackground)
Mutator method for the barcodeBackground property, which determines the color of the spaces between the bars in the barcode (typically white). |
void |
setBarcodeHeight(int barcodeHeight)
Mutator method for the barcodeHeight property, which determines the height of the barcode (excluding caption text) in pixels. |
void |
setBorder(javax.swing.border.Border border)
Mutator methor for the border property. |
void |
setCheckDigit(boolean checkDigit)
Mutator method for the checkDigit property, which determines whether a check digit is encoded in the barcode. |
void |
setCode(java.lang.String code)
Mutator method for the code property, which is the text encoded in the barcode. |
void |
setCodeType(BarcodeStrategy codeType)
Mutator method for the codeType property, which is the barcode type. |
void |
setFont(java.awt.Font font)
Mutator method for the font property. |
void |
setForeground(java.awt.Color c)
Mutator method for the foreground property, which determines the color of the bars and caption text (typically black). |
void |
setHorizontalAlignment(int horizontalAlignment)
Sets the alignment of the barcode along the X axis. |
void |
setLabelPosition(int labelPosition)
Sets the label position of the human readable bacode text. |
void |
setMinimumSize(java.awt.Dimension minimumSize)
Mutator method for the minimumSize property. |
void |
setNarrowestBarWidth(int narrowestBarWidth)
Mutator method for the narrowestBarWidth property, which determines the width (in pixels) of the narrowest bar in the barcode. |
void |
setPreferredSize(java.awt.Dimension preferredSize)
Mutator method for the preferredSize property. |
void |
setShowText(boolean showText)
Deprecated. As of 1.2.0, replaced by setLabelPosition(int) . When
setting this property to true the label position will be set to
LABEL_BOTTOM , setting the property to false will set
the label position to LABEL_NONE . |
java.lang.String |
toString()
Always returns the value of the code property. |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, 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, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI |
Methods inherited from class java.awt.Container |
---|
add, 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, paintComponents, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, 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, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, 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, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int ALIGN_LEFT
public static final int ALIGN_CENTER
public static final int ALIGN_RIGHT
public static final int LABEL_TOP
public static final int LABEL_BOTTOM
public static final int LABEL_NONE
Constructor Detail |
---|
public JBarcodeBean(java.lang.String code, BarcodeStrategy codeType)
Contructor that allows an initial barcode and code type to be specified.
code
- The text to encode.codeType
- The type of barcode.public JBarcodeBean()
Parameterless constructor. Creates a JBarcodeBean object with default property values, so that the bean will render as a typical barcode when initially added to a GUI with a GUI Builder.
Defaulat values are:
code = "1234"
codeType = new Code39()
Code39
Method Detail |
---|
public double getAngleDegrees()
public void setAngleDegrees(double angleDegrees)
public boolean isShowText()
getLabelPosition()
.
This will return true if label position is LABEL_BOTTOM
and false otherwise.
public void setShowText(boolean showText)
setLabelPosition(int)
. When
setting this property to true the label position will be set to
LABEL_BOTTOM
, setting the property to false will set
the label position to LABEL_NONE
.
public boolean isOpaque()
isOpaque
in class javax.swing.JComponent
public java.awt.Color getForeground()
getForeground
in class java.awt.Component
public void setForeground(java.awt.Color c)
setForeground
in class javax.swing.JComponent
public java.awt.Color getBackground()
barcodeBackground
property
(which is the color of the spaces between the bars in the barcode).
getBackground
in class java.awt.Component
public void setBackground(java.awt.Color c)
barcodeBackground
property
(which is the color of the spaces between the bars in the barcode).
setBackground
in class javax.swing.JComponent
public java.awt.Color getBarcodeBackground()
setBackground(java.awt.Color)
public void setBarcodeBackground(java.awt.Color barcodeBackground)
setBackground(java.awt.Color)
public javax.swing.border.Border getBorder()
getBorder
in class javax.swing.JComponent
public void setBorder(javax.swing.border.Border border)
setBorder
in class javax.swing.JComponent
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
public void setPreferredSize(java.awt.Dimension preferredSize)
setPreferredSize
in class javax.swing.JComponent
public java.awt.Dimension preferredSize()
getPreferredSize()
.
preferredSize
in class java.awt.Container
public java.awt.Dimension getMinimumSize()
getMinimumSize
in class javax.swing.JComponent
public void setMinimumSize(java.awt.Dimension minimumSize)
setMinimumSize
in class javax.swing.JComponent
public java.awt.Dimension minimumSize()
getMinimumSize()
.
minimumSize
in class java.awt.Container
public java.awt.Font getFont()
getFont
in interface java.awt.MenuContainer
getFont
in class java.awt.Component
public void setFont(java.awt.Font font)
setFont
in class javax.swing.JComponent
public int getBarcodeHeight()
public void setBarcodeHeight(int barcodeHeight)
public int getNarrowestBarWidth()
public void setNarrowestBarWidth(int narrowestBarWidth)
public boolean isFocusTraversable()
isFocusTraversable
in class java.awt.Component
protected java.lang.String paramString()
code
property.
paramString
in class javax.swing.JComponent
public java.lang.String toString()
code
property.
toString
in class java.awt.Component
public java.lang.String getCode()
public void setCode(java.lang.String code)
public BarcodeStrategy getCodeType()
public void setCodeType(BarcodeStrategy codeType)
public boolean isCheckDigit()
public void setCheckDigit(boolean checkDigit)
protected void paintComponent(java.awt.Graphics graphics)
paintComponent
in class javax.swing.JComponent
public javax.accessibility.AccessibleContext getAccessibleContext()
getAccessibleContext
in interface javax.accessibility.Accessible
getAccessibleContext
in class javax.swing.JComponent
public static java.lang.String getVersion()
public java.awt.image.BufferedImage draw(java.awt.image.BufferedImage image)
image
- The image the barcode will be drawn into or
null
if a new image should be created using the preferred
size of the barcode.
public int getHorizontalAlignment()
ALIGN_LEFT
, ALIGN_RIGHT
,
ALIGN_CENTER
setHorizontalAlignment(int)
public void setHorizontalAlignment(int horizontalAlignment)
horizontalAlignment
- One of the following constants :
ALIGN_LEFT
, ALIGN_RIGHT
,
ALIGN_CENTER
(the default)getHorizontalAlignment()
public int getLabelPosition()
LABEL_BOTTOM
, LABEL_TOP
or
LABEL_NONE
.setLabelPosition(int)
public void setLabelPosition(int labelPosition)
labelPosition
- One of the following constants:
LABEL_BOTTOM
, LABEL_TOP
or LABEL_NONE
.getLabelPosition()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |