Package com.itextpdf.forms.form.renderer
Class CheckBoxRenderer
- java.lang.Object
-
- com.itextpdf.layout.renderer.AbstractRenderer
-
- com.itextpdf.layout.renderer.BlockRenderer
-
- com.itextpdf.forms.form.renderer.AbstractFormFieldRenderer
-
- com.itextpdf.forms.form.renderer.CheckBoxRenderer
-
- All Implemented Interfaces:
IPropertyContainer
,IRenderer
public class CheckBoxRenderer extends AbstractFormFieldRenderer
TheAbstractFormFieldRenderer
implementation for checkboxes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
CheckBoxRenderer.FlatParagraphRenderer
A flat renderer for the checkbox.
-
Field Summary
Fields Modifier and Type Field Description static float
DEFAULT_BORDER_WIDTH
private static float
DEFAULT_SIZE
-
Fields inherited from class com.itextpdf.forms.form.renderer.AbstractFormFieldRenderer
flatRenderer
-
Fields inherited from class com.itextpdf.layout.renderer.AbstractRenderer
childRenderers, EPS, flushed, INF, isLastRendererForModelElement, modelElement, occupiedArea, OVERLAP_EPSILON, parent, positionedRenderers, properties
-
-
Constructor Summary
Constructors Constructor Description CheckBoxRenderer(CheckBox modelElement)
Creates a newCheckBoxRenderer
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
adjustFieldLayout(LayoutContext layoutContext)
Adjusts the field layout.protected void
applyAcroField(DrawContext drawContext)
Applies the AcroField widget.protected Rectangle
applyBorderBox(Rectangle rect, Border[] borders, boolean reverse)
Applies the given border box (borders) on the given rectangleprotected Rectangle
applyPaddings(Rectangle rect, UnitValue[] paddings, boolean reverse)
Applies given paddings to the given rectangle.ICheckBoxRenderingStrategy
createCheckBoxRenderStrategy()
creates a ICheckBoxRenderingStrategy based on the current settings.IRenderer
createFlatRenderer()
Creates a flat renderer for the checkbox.void
drawBackground(DrawContext drawContext)
Draws a background layer if it is defined by a keyProperty.BACKGROUND
in either the layout element or thisIRenderer
itself.void
drawBorder(DrawContext drawContext)
Performs the drawing operation for the border of this renderer, if defined by theProperty.BORDER_TOP
,Property.BORDER_RIGHT
,Property.BORDER_BOTTOM
andProperty.BORDER_LEFT
values in either the layout element or thisIRenderer
itself.CheckBoxType
getCheckBoxType()
Gets the checkBoxType.IRenderer
getNextRenderer()
Gets a new instance of this class to be used as a next renderer, after this renderer is used, ifIRenderer.layout(LayoutContext)
is called more than once.RenderingMode
getRenderingMode()
Gets the rendering mode of the checkbox.boolean
isBoxChecked()
Defines whether the box is checked or not.protected boolean
isLayoutBasedOnFlatRenderer()
Determines, whether the layout is based in the renderer itself or flat renderer.-
Methods inherited from class com.itextpdf.forms.form.renderer.AbstractFormFieldRenderer
applyAccessibilityProperties, draw, drawChildren, getConformance, getDefaultValue, getLang, getMinMaxWidth, getModelId, isFlatten, isRendererFit, layout, writeAcroFormFieldLangAttribute
-
Methods inherited from class com.itextpdf.layout.renderer.BlockRenderer
applyRotationLayout, applyVerticalAlignment, beginRotationIfApplied, createOverflowRenderer, createRotationTransformInsideOccupiedArea, createSplitRenderer, endRotationIfApplied, getMinMaxWidth, getOccupiedAreaBBox, getResolvedFont
-
Methods inherited from class com.itextpdf.layout.renderer.AbstractRenderer
addAllProperties, addChild, alignChildHorizontally, allowLastYLineRecursiveExtraction, applyAbsolutePosition, applyAction, applyBorderBox, applyDestination, applyDestinationsAndAnnotation, applyLinkAnnotation, applyMargins, applyMargins, applyPaddings, applyRelativePositioningTranslation, beginElementOpacityApplying, beginTransformationIfApplied, calculateAbsolutePdfBBox, calculateBBox, calculateShiftToPositionBBoxOfPointsAt, clipBackgroundArea, clipBackgroundArea, clipBorderArea, createXObject, deleteOwnProperty, deleteProperty, endElementOpacityApplying, endTransformationIfApplied, getBackgroundArea, getBorderAreaBBox, getBorderRadii, getBorders, getChildRenderers, getDefaultProperty, getFirstYLineRecursively, getInnerAreaBBox, getLastYLineRecursively, getMargins, getModelElement, getOccupiedArea, getOwnProperties, getOwnProperty, getPaddings, getParent, getProperty, getProperty, getPropertyAsBoolean, getPropertyAsColor, getPropertyAsFloat, getPropertyAsFloat, getPropertyAsFont, getPropertyAsInteger, getPropertyAsTransparentColor, getPropertyAsUnitValue, hasAbsoluteUnitValue, hasOwnOrModelProperty, hasOwnProperty, hasProperty, hasRelativeUnitValue, initElementAreas, isAbsolutePosition, isBorderBoxSizing, isFirstOnRootArea, isFixedLayout, isFlushed, isKeepTogether, isNotFittingHeight, isNotFittingLayoutArea, isNotFittingWidth, isOverflowFit, isOverflowProperty, isOverflowProperty, isOverflowProperty, isPositioned, isRelativePosition, isStaticLayout, move, rectangleToPointsList, retrieveHeight, retrieveMaxHeight, retrieveMaxWidth, retrieveMinHeight, retrieveMinWidth, retrieveResolvedDeclaredHeight, retrieveUnitValue, retrieveUnitValue, retrieveWidth, setBorders, setMinMaxWidthBasedOnFixedWidth, setParent, setProperty, toString, transformPoints, updateHeight, updateHeightsOnSplit, updateMaxHeight, updateMinHeight, updateWidth
-
-
-
-
Field Detail
-
DEFAULT_BORDER_WIDTH
public static final float DEFAULT_BORDER_WIDTH
- See Also:
- Constant Field Values
-
DEFAULT_SIZE
private static final float DEFAULT_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CheckBoxRenderer
public CheckBoxRenderer(CheckBox modelElement)
Creates a newCheckBoxRenderer
instance.- Parameters:
modelElement
- the model element
-
-
Method Detail
-
getNextRenderer
public IRenderer getNextRenderer()
Gets a new instance of this class to be used as a next renderer, after this renderer is used, ifIRenderer.layout(LayoutContext)
is called more than once.- Returns:
- new renderer instance
-
getRenderingMode
public RenderingMode getRenderingMode()
Gets the rendering mode of the checkbox.- Returns:
- the rendering mode of the checkbox
-
getCheckBoxType
public CheckBoxType getCheckBoxType()
Gets the checkBoxType.- Returns:
- the checkBoxType
-
createCheckBoxRenderStrategy
public ICheckBoxRenderingStrategy createCheckBoxRenderStrategy()
creates a ICheckBoxRenderingStrategy based on the current settings.- Returns:
- the ICheckBoxRenderingStrategy
-
drawBackground
public void drawBackground(DrawContext drawContext)
Draws a background layer if it is defined by a keyProperty.BACKGROUND
in either the layout element or thisIRenderer
itself.- Overrides:
drawBackground
in classAbstractRenderer
- Parameters:
drawContext
- the context (canvas, document, etc) of this drawing operation.
-
drawBorder
public void drawBorder(DrawContext drawContext)
Performs the drawing operation for the border of this renderer, if defined by theProperty.BORDER_TOP
,Property.BORDER_RIGHT
,Property.BORDER_BOTTOM
andProperty.BORDER_LEFT
values in either the layout element or thisIRenderer
itself.- Overrides:
drawBorder
in classAbstractRenderer
- Parameters:
drawContext
- the context (canvas, document, etc.) of this drawing operation
-
applyBorderBox
protected Rectangle applyBorderBox(Rectangle rect, Border[] borders, boolean reverse)
Applies the given border box (borders) on the given rectangle- Overrides:
applyBorderBox
in classAbstractRenderer
- Parameters:
rect
- a rectangle paddings will be applied on.borders
- theborders
to be applied on the given rectanglereverse
- indicates whether the border box will be applied inside (in case of false) or outside (in case of false) the rectangle.- Returns:
- a
border box
of the renderer
-
isBoxChecked
public boolean isBoxChecked()
Defines whether the box is checked or not.- Returns:
- the default value of the checkbox field
-
adjustFieldLayout
protected void adjustFieldLayout(LayoutContext layoutContext)
Adjusts the field layout.- Specified by:
adjustFieldLayout
in classAbstractFormFieldRenderer
- Parameters:
layoutContext
- layout context
-
applyPaddings
protected Rectangle applyPaddings(Rectangle rect, UnitValue[] paddings, boolean reverse)
Applies given paddings to the given rectangle.Checkboxes don't support setting of paddings as they are always centered. So that this method returns the rectangle as is.
- Overrides:
applyPaddings
in classAbstractRenderer
- Parameters:
rect
- a rectangle paddings will be applied on.paddings
- the paddings to be applied on the given rectanglereverse
- indicates whether paddings will be applied inside (in case of false) or outside (in case of true) the rectangle.- Returns:
- The rectangle NOT modified by the paddings.
-
createFlatRenderer
public IRenderer createFlatRenderer()
Creates a flat renderer for the checkbox.- Specified by:
createFlatRenderer
in classAbstractFormFieldRenderer
- Returns:
- an IRenderer object for the flat renderer
-
applyAcroField
protected void applyAcroField(DrawContext drawContext)
Applies the AcroField widget.- Specified by:
applyAcroField
in classAbstractFormFieldRenderer
- Parameters:
drawContext
- the draw context
-
isLayoutBasedOnFlatRenderer
protected boolean isLayoutBasedOnFlatRenderer()
Determines, whether the layout is based in the renderer itself or flat renderer.- Overrides:
isLayoutBasedOnFlatRenderer
in classAbstractFormFieldRenderer
- Returns:
true
if layout is based on flat renderer, false otherwise.
-
-