*
*/
public void paintShape(mxGraphics2DCanvas canvas, String text,
mxCellState state, Map<String, Object> style)
{
mxLightweightLabel textRenderer = mxLightweightLabel
.getSharedInstance();
CellRendererPane rendererPane = canvas.getRendererPane();
Rectangle rect = state.getLabelBounds().getRectangle();
Graphics2D g = canvas.getGraphics();
if (textRenderer != null
&& rendererPane != null
&& (g.getClipBounds() == null || g.getClipBounds().intersects(
rect)))
{
double scale = canvas.getScale();
int x = rect.x;
int y = rect.y;
int w = rect.width;
int h = rect.height;
if (!mxUtils.isTrue(style, mxConstants.STYLE_HORIZONTAL, true))
{
g.rotate(-Math.PI / 2, x + w / 2, y + h / 2);
g.translate(w / 2 - h / 2, h / 2 - w / 2);
int tmp = w;
w = h;
h = tmp;
}
// Replaces the linefeeds with BR tags
if (isReplaceHtmlLinefeeds())
{
text = text.replaceAll("\n", "<br>");
}
// Renders the scaled text
textRenderer.setText(createHtmlDocument(style, text,
(int) Math.round(w / state.getView().getScale()),
(int) Math.round(h / state.getView().getScale())));
textRenderer.setFont(mxUtils.getFont(style, canvas.getScale()));
g.scale(scale, scale);
rendererPane.paintComponent(g, textRenderer, rendererPane,
(int) (x / scale) + mxConstants.LABEL_INSET,
(int) (y / scale) + mxConstants.LABEL_INSET,
(int) (w / scale), (int) (h / scale), true);