Class PainterUIResource<T extends JComponent>
- Type Parameters:
T- a subclass of JComponent
- All Implemented Interfaces:
UIResource, Painter<T>
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPainterUIResource(Painter<? super T> p) Creates a new instance of PainterUIResource with the specified delegate painter. -
Method Summary
Modifier and TypeMethodDescriptionvoidpaint(Graphics2D g, T component, int width, int height) Renders to the givenGraphics2Dobject.
-
Field Details
-
p
-
-
Constructor Details
-
PainterUIResource
-
-
Method Details
-
paint
Renders to the given
Graphics2Dobject. Implementations of this method may modify state on theGraphics2D, and are not required to restore that state upon completion. In most cases, it is recommended that the caller pass in a scratch graphics object. TheGraphics2Dmust never be null.State on the graphics object may be honored by the
paintmethod, but may not be. For instance, setting the antialiasing rendering hint on the graphics may or may not be respected by thePainterimplementation.The supplied object parameter acts as an optional configuration argument. For example, it could be of type
Component. APainterthat expected it could then read state from thatComponentand use the state for painting. For example, an implementation may read the backgroundColor and use that.Generally, to enhance reusability, most standard
Painters ignore this parameter. They can thus be reused in any context. Theobjectmay be null. Implementations must not throw a NullPointerException if the object parameter is null.Finally, the
widthandheightarguments specify the width and height that thePaintershould paint into. More specifically, the specified width and height instruct the painter that it should paint fully within this width and height. Any specified clip on thegparam will further constrain the region.For example, suppose I have a
Painterimplementation that draws a gradient. The gradient goes from white to black. It "stretches" to fill the painted region. Thus, if I use thisPainterto paint a 500 x 500 region, the far left would be black, the far right would be white, and a smooth gradient would be painted between. I could then, without modification, reuse thePainterto paint a region that is 20x20 in size. This region would also be black on the left, white on the right, and a smooth gradient painted between.- Specified by:
paintin interfacePainter<T extends JComponent>- Parameters:
g- The Graphics2D to render to. This must not be null.component- an optional configuration parameter. This may be null.width- width of the area to paint.height- height of the area to paint.
-