Painters are a sort of user interface delegate for drawing foregrounds and backgrounds. SwingX includes some built-in painters:
Java class name:AlphaPainter |
SwingXBuilder node: alphaPainter |
Attribute |
Expected Type |
alpha |
float |
|---|---|
painters |
ArrayList<Painter> or Painter[] |
Java class name:BusyPainter |
SwingXBuilder node: busyPainter |
Attribute |
Expected Type |
barLength |
float |
barWidth |
float |
baseColor |
Color |
Java class name:CapsulePainter |
SwingXBuilder node: capsulePainter |
Attribute |
Expected Type |
portion |
CapsulePainter.Portion |
Java class name:CheckerboardPainter |
SwingXBuilder node: checkerboardPainter |
Attribute |
Expected Type |
squareSize |
float |
lightPaint |
Color |
darkPaint |
Color |
Java class name:ImagePainter |
SwingXBuilder node: imagePainter |
Attribute |
Expected Type |
image |
BufferedImage |
url |
URL |
style |
AbstractAreaPainter.Style |
horizontal |
AbstractLayoutPainter.HorizontalAlignment |
vertical |
AbstractLayoutPainter.VerticalAlignment |
Java class name:ImagePainter |
SwingXBuilder node: imagePainter |
Attribute |
Expected Type |
width |
integer |
height |
integer |
rounded |
boolean |
roundHeight |
integer |
roundWidth |
integer |
fillPaint |
Color |
Java class name:PinstripePainter |
SwingXBuilder node: pinstripePainter |
Attribute |
Expected Type |
paint |
Paint |
angle |
double |
stripeWidth |
double |
spacing |
double |
Java class name:MattePainter |
SwingXBuilder node: mattePainter |
Attribute |
Expected Type |
paint |
Paint |
paintStretched |
boolean |
Java class name:TextPainter |
SwingXBuilder node: textPainter |
Attribute |
Expected Type |
font |
Font |
text |
String |
paint |
Paint |
Java class name:GlossPainter |
SwingXBuilder node: glossPainter |
Attribute |
Expected Type |
position |
GlossPainter.GlossPosition |
paint |
Paint |
CompoundPainter, as its name indicates, is a collection of other Painters. Order is important. CompoundPainters build from back to front. Here is an example of a CompoundPainter:
comp = swing.compoundPainter(clipPreserved:true) {
rectanglePainter(borderWidth:3f, borderPaint:Color.BLACK,
areaEffects:new GlowPathEffect(), roundHeight:40, roundWidth:40,
insets: [3,3,3,3], paintStretched:true,style:AbstractAreaPainter.Style.FILLED,
fillPaint:grad)
pinstripePainter(paint:[204,0,0,36] as Color,angle:45, stripeWidth:8, spacing:8)
}
|
AlphaPainter is a CompoundPainter as well, adding an alpha value to a collection of Painters. CompoundPainter can take the painters attribute or you can enumerate the painters inside the closure.