public class PainterChain
- Object
- PainterChain
ImplementsPainter
A painter chain allows us to chain together several painters to provide a
“layer” effect where each painter only draws one element.
Constructors
public PainterChain(Painter[] chain) | Create a new painter chain which will paint all of the elements in the chain in sequence from 0 to the last element |
public PainterChain(Painter painter) | Create a new painter chain which will paint all of the elements in the chain in sequence from 0 to the last element |
Methods
public static void installGlassPane(Form f, Painter p) | Installs a glass pane on the given form making sure to make it a painter chain only if required by existing painter |
public static void removeGlassPane(Form f, Painter p) | Removes a glass pane from the given form, this is the opposite operation for the install glass pane |
public PainterChain addPainter(Painter p) | Creates a new chain based on the existing chain with the new element added at the end |
public PainterChain prependPainter(Painter p) | Creates a new chain based on the existing chain with the new element added at the beginning |
public void paint(Graphics g, Rectangle rect) | Draws inside the given rectangle clipping area. |
public Painter[] getChain() | Allows us to traverse the painter chain |
Inherited methods
Constructor details
PainterChain
public PainterChain(Painter[] chain)Create a new painter chain which will paint all of the elements in the chain
in sequence from 0 to the last element
Parameters
chainPainter[]- the chain of components in the painter
PainterChain
public PainterChain(Painter painter)Create a new painter chain which will paint all of the elements in the chain
in sequence from 0 to the last element
Parameters
painterPainter- the chain first Painter
Method details
installGlassPane
public static void installGlassPane(Form f, Painter p)Installs a glass pane on the given form making sure to make it a painter
chain only if required by existing painter
Parameters
fForm- form on which to install the chain
pPainter- painter to install
removeGlassPane
public static void removeGlassPane(Form f, Painter p)Removes a glass pane from the given form, this is the opposite operation for the
install glass pane
Parameters
fForm- form from which to remove the chain
pPainter- painter to remove
addPainter
public PainterChain addPainter(Painter p)Creates a new chain based on the existing chain with the new element added
at the end
Parameters
pPainter- new painter
Returns
new chain element
prependPainter
public PainterChain prependPainter(Painter p)Creates a new chain based on the existing chain with the new element added
at the beginning
Parameters
pPainter- new painter
Returns
new chain element
paint
public void paint(Graphics g, Rectangle rect)Draws inside the given rectangle clipping area.
Parameters
gGraphics- the
Graphicsobject rectRectangle- the given rectangle cliping area
getChain
public Painter[] getChain()Allows us to traverse the painter chain
Returns
the internal painter chain