public class JBarcodeBean extends javax.swing.JComponent implements java.io.Serializable, javax.accessibility.Accessible, FormComponent, DBComponent, JspConvertable, MultiLanguage
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 2.1 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.
THIRD PARTY COPYRIGHT
The gifEncode
method of JBarcodeBean,
which allows a barcode to be encoded into a GIF output stream, utilizes
the GifEncoder
class, which is
the copyright of Jef Poskanzer.
GifEncoder is Copyright (C)1996,1998 by Jef Poskanzer. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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
*See "Design Patterns Elements of Reusable Object-Oriented Software", Erich Gamma et al. for more information about design patterns.
javax.swing.JComponent.AccessibleJComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
JBarcodeBean()
Parameterless constructor.
|
JBarcodeBean(java.lang.String code,
BarcodeStrategy codeType)
Contructor that allows an initial barcode and code type to be specified.
|
Modifier and Type | Method and Description |
---|---|
javax.accessibility.AccessibleContext |
getAccessibleContext()
Returns a simple subclass of AccessibleContext.
|
FButton |
getAfterScanInputButton() |
java.lang.String |
getAfterScanInputButtonName() |
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.lang.String[] |
getContentItems() |
java.lang.String |
getContentItemValue(java.lang.String contentItem) |
DBSave |
getDBSave() |
java.lang.Object |
getDBValue() |
DBSave |
getDefaultDBSave() |
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).
|
java.lang.String |
getID() |
java.lang.String |
getLabelText() |
java.awt.Dimension |
getMinimumSize()
Accessor method for minimumSize property.
|
double |
getNarrowestBarWidth()
Accessor method for the narrowestBarWidth property,
which determines the width (in pixels) of the narrowest bar in the barcode.
|
java.util.Properties |
getPackedProperties() |
java.awt.Dimension |
getPreferredSize()
Accessor method for the preferredSize property.
|
java.lang.String[] |
getPropertyNames() |
java.lang.String |
getPropertyValue(java.lang.String propertyName) |
HTMLEventDescriptor[] |
getSupportedHTMLEvents() |
int |
getTypeLimit() |
boolean |
isAllowScanInput() |
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()
Accessor method for the showText property, which
determines whether or not the text caption is visible below the
barcode.
|
void |
jpgEncode(java.io.OutputStream out)
Encodes the barcode into an OutputStream as a GIF image.
|
java.awt.Dimension |
minimumSize()
Deprecated.
Use
getMinimumSize() . |
static java.lang.String |
packProperty(BarcodeStrategy value) |
static java.lang.String |
packProperty(javax.swing.border.Border value) |
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 |
removeAfterScanInputButton() |
void |
setAfterScanInputButton(FButton afterScanInputButton) |
void |
setAfterScanInputButtonName(java.lang.String afterScanInputButtonName) |
void |
setAllowScanInput(boolean bAllowScanInput) |
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 |
setContentItemValue(java.lang.String contentItem,
java.lang.Object value) |
void |
setDBSave(DBSave dbSave) |
void |
setDBValue(java.lang.Object value) |
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 |
setID(java.lang.String id) |
void |
setLabelText(java.lang.String labelText) |
void |
setMinimumSize(java.awt.Dimension minimumSize)
Mutator method for the minimumSize property.
|
void |
setNarrowestBarWidth(double narrowestBarWidth)
Mutator method for the narrowestBarWidth property,
which determines the width (in pixels) of the narrowest bar in the barcode.
|
void |
setPackedProperties(java.util.Properties pros) |
void |
setPreferredSize(java.awt.Dimension preferredSize)
Mutator method for the preferredSize property.
|
void |
setPropertyValue(java.lang.String propertyName,
java.lang.Object value) |
void |
setShowText(boolean showText)
Mutator method for the showText property, which
determines whether or not the text caption is visible below the
barcode.
|
void |
setTypeLimit(int typeLimit) |
java.lang.String |
toString()
Always returns the value of the
code property. |
static javax.swing.border.Border |
unPackBorderProperty(java.lang.String value) |
static BarcodeStrategy |
unPackProperty(java.lang.String str) |
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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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
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, transferFocusDownCycle, validate, validateTree
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, 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, transferFocusBackward, transferFocusUpCycle
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getName, setName
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
public double getAngleDegrees()
public void setAngleDegrees(double angleDegrees)
public boolean isShowText()
public void setShowText(boolean showText)
public boolean isAllowScanInput()
public void setAllowScanInput(boolean bAllowScanInput)
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 FButton getAfterScanInputButton()
public void setAfterScanInputButton(FButton afterScanInputButton)
public java.lang.String getAfterScanInputButtonName()
public void setAfterScanInputButtonName(java.lang.String afterScanInputButtonName)
public void removeAfterScanInputButton()
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 double getNarrowestBarWidth()
public void setNarrowestBarWidth(double 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) throws BarcodeException
BarcodeException
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 java.awt.Component
public void jpgEncode(java.io.OutputStream out) throws java.io.IOException
Encodes the barcode into an OutputStream as a GIF image.
Note: Borders and insets are not rendered, but if these properties are set
on the component, the size of the resulting GIF will be increased accordingly
with blank space around the barcode image the same color as the
barcodeBackground
property.
java.io.IOException
public static java.lang.String packProperty(BarcodeStrategy value)
public static BarcodeStrategy unPackProperty(java.lang.String str)
public static java.lang.String packProperty(javax.swing.border.Border value)
public static javax.swing.border.Border unPackBorderProperty(java.lang.String value)
public int getTypeLimit()
public void setTypeLimit(int typeLimit)
public java.lang.String getID()
getID
in interface FormComponent
public void setID(java.lang.String id)
setID
in interface FormComponent
public java.util.Properties getPackedProperties()
getPackedProperties
in interface FormComponent
public void setPackedProperties(java.util.Properties pros)
setPackedProperties
in interface FormComponent
public void setLabelText(java.lang.String labelText)
public java.lang.String getLabelText()
public HTMLEventDescriptor[] getSupportedHTMLEvents()
getSupportedHTMLEvents
in interface JspConvertable
public java.lang.Object getDBValue()
getDBValue
in interface DBComponent
public void setDBValue(java.lang.Object value)
setDBValue
in interface DBComponent
public DBSave getDefaultDBSave()
getDefaultDBSave
in interface DBComponent
public DBSave getDBSave()
getDBSave
in interface DBComponent
public void setDBSave(DBSave dbSave)
setDBSave
in interface DBComponent
public java.lang.String getContentItemValue(java.lang.String contentItem)
getContentItemValue
in interface MultiLanguage
public java.lang.String[] getContentItems()
getContentItems
in interface MultiLanguage
public java.lang.String[] getPropertyNames()
getPropertyNames
in interface MultiLanguage
public java.lang.String getPropertyValue(java.lang.String propertyName)
getPropertyValue
in interface MultiLanguage
public void setContentItemValue(java.lang.String contentItem, java.lang.Object value)
setContentItemValue
in interface MultiLanguage
public void setPropertyValue(java.lang.String propertyName, java.lang.Object value)
setPropertyValue
in interface MultiLanguage
Copyright ? 2022. All Rights Reserved.