public class UIComponent extends Object
The UIComponent contains a platform-dependent object to be used for displaying graphical elements.
Its sole member is a simple Object. The typical usage is:
View) in the UIComponent when a (re)draw is prompted
by the system;UIComponent to the object able draw on it;getComponent() back to the system UI component type
(View) and use it normally, see DefaultBackgroundPainter example below.
public class DefaultBackgroundPainter implements BackgroundPainter {
public void paintBackground(UIComponent uiComponent, Topology tp) {
Graphics2D g2d = (Graphics2D) uiComponent.getComponent();
g2d.setStroke(new BasicStroke(1));
for (Node n : tp.getNodes()) {
double sR = n.getSensingRange();
if (sR > 0) {
g2d.setColor(Color.gray);
g2d.drawOval((int) n.getX() - (int) sR, (int) n.getY() - (int) sR, 2 * (int) sR, 2 * (int) sR);
}
}
}
}
| Constructor and Description |
|---|
UIComponent(Object component)
Creates a
UIComponent by wrapping the provided system Object |
| Modifier and Type | Method and Description |
|---|---|
Object |
getComponent()
Gets the
Object that has been provided upon creation. |
public UIComponent(Object component)
Creates a UIComponent by wrapping the provided system Object
component - the Object to be wrapped