/** * Create a new Diva figure that visually represents this icon. The figure will be an instance of * LabelFigure that renders the values of the attributes of the container. * * @return A new CompositeFigure consisting of the label. */ public Figure createFigure() { CompositeFigure result = (CompositeFigure) super.createFigure(); String truncated = _displayString(); // If there is no string to display now, then create a string // with a single blank. if (truncated == null) { truncated = " "; } // NOTE: This violates the Diva MVC architecture! // This attribute is part of the model, and should not have // a reference to this figure. By doing so, it precludes the // possibility of having multiple views on this model. LabelFigure label = new LabelFigure(truncated, _labelFont, 1.0, SwingConstants.CENTER); Rectangle2D backBounds = result.getBackgroundFigure().getBounds(); label.translateTo(backBounds.getCenterX(), backBounds.getCenterY()); result.add(label); _addLiveFigure(label); return result; }