An immutable transient object containing contextual information about
a
. A
should only be
considered valid for the duration
of the method it is passed to. In other words you should not cache
a
that is passed to you and expect it to
remain valid.
| Method from javax.swing.plaf.synth.SynthContext Detail: |
void dispose() {
this.component = null;
this.style = null;
releaseContext(this);
}
|
public JComponent getComponent() {
return component;
}
Returns the hosting component containing the region. |
public int getComponentState() {
return state;
}
Returns the state of the widget, which is a bitmask of the
values defined in SynthConstants. A region will at least
be in one of
ENABLED, MOUSE_OVER, PRESSED
or DISABLED. |
static SynthContext getContext(Class type,
JComponent component,
Region region,
SynthStyle style,
int state) {
contextMap = new HashMap();
SynthContext context = null;
synchronized(contextMap) {
java.util.List instances = (java.util.List)contextMap.get(type);
if (instances != null) {
int size = instances.size();
if (size > 0) {
context = (SynthContext)instances.remove(size - 1);
}
}
}
if (context == null) {
try {
context = (SynthContext)type.newInstance();
} catch (IllegalAccessException iae) {
} catch (InstantiationException ie) {
}
}
context.reset(component, region, style, state);
return context;
}
|
SynthPainter getPainter() {
SynthPainter painter = getStyle().getPainter(this);
if (painter != null) {
return painter;
}
return SynthPainter.NULL_PAINTER;
}
Convenience method to get the Painter from the current SynthStyle.
This will NEVER return null. |
public Region getRegion() {
return region;
}
Returns the Region identifying this state. |
public SynthStyle getStyle() {
return style;
}
Returns the style associated with this Region. |
boolean isSubregion() {
return getRegion().isSubregion();
}
A convenience method for getRegion().isSubregion(). |
static void releaseContext(SynthContext context) {
synchronized(contextMap) {
java.util.List instances = (java.util.List)contextMap.get(
context.getClass());
if (instances == null) {
instances = new ArrayList(5);
contextMap.put(context.getClass(), instances);
}
instances.add(context);
}
}
|
void reset(JComponent component,
Region region,
SynthStyle style,
int state) {
this.component = component;
this.region = region;
this.style = style;
this.state = state;
}
Resets the state of the Context. |
void setComponentState(int state) {
this.state = state;
}
|
void setStyle(SynthStyle style) {
this.style = style;
}
|