Package edu.cnu.mdi.component
Interface ButtonPainter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Paints the vector contents of a
DrawnButton or DrawnToggleButton.
A painter is deliberately independent of image files. It is given the target button, the drawable bounds inside the button's insets, and an animation frame value. The same painter instance may be shared by many buttons, so implementations should not store per-button mutable drawing state unless they do so carefully.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DimensionThe default drawing canvas used when no explicit size is supplied. -
Method Summary
Modifier and TypeMethodDescriptionvoiddraw(Graphics2D g2, AbstractButton button, Rectangle bounds, long frameCount) Draws the button contents.default DimensionReturns the natural canvas size for buttons using this painter.
-
Field Details
-
DEFAULT_PREFERRED_SIZE
The default drawing canvas used when no explicit size is supplied.
-
-
Method Details
-
draw
Draws the button contents.- Parameters:
g2- the graphics context; the caller owns and disposes this copybutton- the button being paintedbounds- the drawable area inside the button insetsframeCount- the current animation frame, or0for non-animated buttons
-
getPreferredSize
Returns the natural canvas size for buttons using this painter.Override this for non-square or detailed drawings. The returned dimension is copied by the button, so callers may safely return a shared constant.
- Returns:
- the preferred drawing size
-