01: package org.cougaar.core.qos.frame.visualizer;
02:
03: import java.awt.*;
04:
05: /**
06: * Created by IntelliJ IDEA.
07: * User: mwalczak
08: * Date: May 2, 2005
09: * Time: 1:08:34 PM
10: * To change this template use File | Settings | File Templates.
11: */
12: public class ContainerLabelRenderer extends LabelRenderer {
13:
14: public ContainerLabelRenderer(String rendererName, double xoff,
15: double yoff) {
16: this (rendererName, xoff, yoff, null, null);
17: }
18:
19: public ContainerLabelRenderer(String rendererName, double xoff,
20: double yoff, Font font) {
21: this (rendererName, xoff, yoff, font, null);
22: }
23:
24: public ContainerLabelRenderer(String rendererName, double xoff,
25: double yoff, Paint paint) {
26: this (rendererName, xoff, yoff, null, paint);
27: }
28:
29: public ContainerLabelRenderer(String rendererName, double xoff,
30: double yoff, Font font, Paint paint) {
31: super (rendererName, xoff, yoff, font, paint);
32: }
33:
34: public void drawLabel(Graphics2D g2, ShapeGraphic shapeGraphic) {
35: if (shapeGraphic == null || shapeGraphic.getLabel() == null)
36: return;
37: Shape shape = shapeGraphic.getShape();
38: if (shape == null)
39: return;
40: if (paint != null)
41: g2.setPaint(paint);
42: if (font != null)
43: g2.setFont(font);
44:
45: int size = ((ShapeContainer) shapeGraphic).getNumChildren();
46: Rectangle r = shape.getBounds();
47: g2.drawString(shapeGraphic.getLabel() + " (" + size + ")",
48: (int) (r.x + xoffset), (int) (r.y + yoffset));
49: }
50: }
|