tl = new TextLayout(itm.getLine(iLC - i - 1), g2d.getFont(), g2d.getFontRenderContext());
tl = new TextLayout(itm.getLine(iLC - i - 1), g2d.getFont().getAttributes(), g2d.getFontRenderContext());
    private final void showTopValue(IPrimitiveRenderer ipr, Location lo, Label la, boolean bShadow)    {        final Graphics2D g2d = (Graphics2D) ((IDeviceRenderer) ipr).getGraphicsContext();        double dX = lo.getX(), dY = lo.getY();        final FontDefinition fd = la.getCaption().getFont();        //final Color clrShadow = bShadow ? (Color) _sxs.getColor(la.getShadowColor()) : null;        final double dAngleInDegrees = fd.getRotation();        final Color clrText = (Color) _sxs.getColor(la.getCaption().getColor());        final Color clrBackground = (Color) _sxs.getColor((ColorDefinition) la.getBackground());        double dAngleInRadians = ((-dAngleInDegrees * Math.PI) / 180.0);        final ITextMetrics itm = new SwingTextMetrics(_sxs, la);        final double dFW = itm.getFullWidth();        final double dH = itm.getHeight();        final double dD = itm.getDescent();        final double dFH = itm.getFullHeight();        double dXOffset = 0, dW = 0;        final int iLC = itm.getLineCount();        final Insets ins = la.getInsets().scaledInstance(_sxs.getDpiResolution() / 72d);        TextLayout tl;        final HorizontalAlignment ha = la.getCaption().getFont().getAlignment().getHorizontalAlignment();        final boolean bRightAligned = ha.getValue() == HorizontalAlignment.RIGHT;        final boolean bCenterAligned = ha.getValue() == HorizontalAlignment.CENTER;        dX -= dFW / 2;        // HORIZONTAL TEXT        if (dAngleInDegrees == 0)        {            if (bShadow) // RENDER THE SHADOW            {                g2d.setPaint(                	new GradientPaint(                	    new Point2D.Double(dX + 3, (dY - dFH) + 3),                	    (Color) _sxs.getColor(la.getShadowColor()),                 	    new Point2D.Double(dX + 3 + dFW, (dY - dFH) + 3 + dFH),                	    (Color) _sxs.getColor(la.getShadowColor().translucent())             	    )                );                g2d.fill(new Rectangle2D.Double(dX + 3, (dY - dFH) + 3, dFW, dFH));            }            else            {                final Rectangle2D.Double r2d = new Rectangle2D.Double(dX, (dY - dFH), dFW, dFH);                // RENDER THE BACKGROUND                g2d.setColor(clrBackground);                g2d.fill(r2d);                // RENDER THE TEXT                g2d.setColor(clrText);                for (int i = 0; i < itm.getLineCount(); i++)                {                    //tl = new TextLayout(itm.getLine(iLC - i - 1),                    // g2d.getFont(), g2d.getFontRenderContext());                    tl = ((SwingTextMetrics) itm).getLayout(iLC - i - 1);                    if (bRightAligned)                    {                        dW = tl.getBounds().getWidth();                        dXOffset = -ins.getLeft() + dFW - dW - ins.getRight();                    }                    else if (bCenterAligned)                    {                        dW = tl.getBounds().getWidth();                        dXOffset = -ins.getLeft() + (dFW - dW) / 2;                    }                    tl.draw(g2d, (float) (dX + dXOffset + ins.getLeft()), (float) (dY - dD - dH * i - ins.getBottom()));                }                // RENDER THE OUTLINE/BORDER                renderOutline(ipr, la.getOutline(), r2d);            }            //crossHairs(g2d, (int)dX, (int)dY);        }        // DRAW IT AT A POSITIVE ANGLE        else if (dAngleInDegrees > 0 && dAngleInDegrees < 90)        {            double dDeltaX = dFW / 2;            dX += dDeltaX;            g2d.rotate(dAngleInRadians, dX, dY);            if (bShadow) // RENDER THE SHADOW            {                g2d.setPaint(                	new GradientPaint(                	    new Point2D.Double(dX + 3, (dY - dFH) + 3),                	    (Color) _sxs.getColor(la.getShadowColor()),                 	    new Point2D.Double(dX + 3 + dFW, (dY - dFH) + 3 + dFH),                	    (Color) _sxs.getColor(la.getShadowColor().translucent())             	    )                );                g2d.fill(new Rectangle2D.Double(dX + 3, (dY - dFH) + 3, dFW, dFH));            }            else            {                final Rectangle2D.Double r2d = new Rectangle2D.Double(dX, (dY - dFH), dFW, dFH);                // RENDER THE BACKGROUND                g2d.setColor(clrBackground);                g2d.fill(r2d);                // RENDER THE TEXT                g2d.setColor(clrText);                for (int i = 0; i < itm.getLineCount(); i++)                {                    tl = new TextLayout(itm.getLine(iLC - i - 1), g2d.getFont(), g2d.getFontRenderContext());                    if (bRightAligned)                    {                        dW = tl.getBounds().getWidth();                        dXOffset = -ins.getLeft() + dFW - dW - ins.getRight();                    }                    else if (bCenterAligned)                    {                        dW = tl.getBounds().getWidth();                        dXOffset = -ins.getLeft() + (dFW - dW) / 2;                    }                    tl.draw(g2d, (float) (dX + dXOffset + ins.getLeft()), (float) (dY - dD - dH * i - ins.getBottom()));                }                // RENDER THE OUTLINE/BORDER                renderOutline(ipr, la.getOutline(), r2d);            }            // UNDO THE 'ROTATED' STATE OF THE GRAPHICS CONTEXT            g2d.rotate(-dAngleInRadians, dX, dY);            //crossHairs(g2d, (int)dX, (int)dY);        }        // DRAW IT AT A NEGATIVE ANGLE        else if (dAngleInDegrees < 0 && dAngleInDegrees > -90)        {            double dCosTheta = Math.abs(Math.cos(dAngleInRadians));            double dSineTheta = Math.abs(Math.sin(dAngleInRadians));            dX -= dFW / 2 - (dFW - dFW * dCosTheta);            dY -= dFW * dSineTheta;            g2d.rotate(dAngleInRadians, dX, dY);            if (bShadow) // RENDER THE SHADOW            {                g2d.setPaint(                	new GradientPaint(                	    new Point2D.Double(dX + 3, (dY - dFH) + 3),                	    (Color) _sxs.getColor(la.getShadowColor()),                 	    new Point2D.Double(dX + 3 + dFW, (dY - dFH) + 3 + dFH),                	    (Color) _sxs.getColor(la.getShadowColor().translucent())             	    )                );                g2d.fill(new Rectangle2D.Double(dX + 3, (dY - dFH) + 3, dFW, dFH));            }            else            {                final Rectangle2D.Double r2d = new Rectangle2D.Double(dX, dY - dFH, dFW, dFH);                // RENDER THE BACKGROUND                g2d.setColor(clrBackground);                g2d.fill(r2d);                // RENDER THE TEXT                g2d.setColor(clrText);                for (int i = 0; i < itm.getLineCount(); i++)                {                    tl = ((SwingTextMetrics) itm).getLayout(iLC - i - 1);                    if (bRightAligned)                    {                        dW = tl.getBounds().getWidth();                        dXOffset = -ins.getLeft() + dFW - dW - ins.getRight();                    }                    else if (bCenterAligned)                    {                        dW = tl.getBounds().getWidth();                        dXOffset = -ins.getLeft() + (dFW - dW) / 2;                    }                    tl.draw(g2d, (float) (dX + dXOffset + ins.getLeft()), (float) (dY - dD - dH * i - ins.getBottom()));                }                // RENDER THE OUTLINE/BORDER                renderOutline(ipr, la.getOutline(), r2d);            }            // UNDO THE 'ROTATED' STATE OF THE GRAPHICS CONTEXT            g2d.rotate(-dAngleInRadians, dX, dY);            /*             * final RotatedRectangle rr = computePolygon(IConstants.ABOVE, la, lo.getX(), lo.getY());             * g2d.setColor(Color.blue); g2d.draw(rr); final BoundingBox bb = computeBox(IConstants.ABOVE, la,             * lo.getX(), lo.getY()); renderBox(g2d, bb, Color.black, null);             */            //crossHairs(g2d, (int)dX, (int)dY);        }        // VERTICALLY UP        else if (dAngleInDegrees == 90)        {            double dYHalfOffset = (dFH + dH) / 2.0;            double dDeltaX = (dFW + dH) / 2;            dX += dDeltaX;            g2d.rotate(dAngleInRadians, dX, dY);            if (bShadow) // RENDER THE SHADOW            {                g2d.setPaint(                	new GradientPaint(                	    new Point2D.Double(dX + 3, (dY - dYHalfOffset) + 3),                	    (Color) _sxs.getColor(la.getShadowColor()),                 	    new Point2D.Double(dX + 3 + dFW, (dY - dYHalfOffset) + 3 + dFH),                	    (Color) _sxs.getColor(la.getShadowColor().translucent())             	    )                );                g2d.fill(new Rectangle2D.Double(dX + 3, (dY - dYHalfOffset) + 3, dFW, dFH));            }            else            {                final Rectangle2D.Double r2d = new Rectangle2D.Double(dX, dY - dYHalfOffset, dFW, dFH);                // RENDER THE BACKGROUND                g2d.setColor(clrBackground);                g2d.fill(r2d);                // RENDER THE TEXT                g2d.setColor(clrText);                for (int i = 0; i < itm.getLineCount(); i++)                {                    tl = ((SwingTextMetrics) itm).getLayout(i);                    if (bRightAligned)                    {                        dW = tl.getBounds().getWidth();                        dXOffset = -ins.getLeft() + dFW - dW - ins.getRight();                    }                    else if (bCenterAligned)                    {                        dW = tl.getBounds().getWidth();                        dXOffset = -ins.getLeft() + (dFW - dW) / 2;                    }                    tl.draw(g2d, (float) (dX + dXOffset + ins.getLeft()),                        (float) (((dY - dD) - ((itm.getLineCount() - i) * dH - (iLC + 1) * dH / 2)) + ins.getTop()));                }                // RENDER THE OUTLINE/BORDER                renderOutline(ipr, la.getOutline(), r2d);            }            // UNDO THE 'ROTATED' STATE OF THE GRAPHICS CONTEXT            g2d.rotate(-dAngleInRadians, dX, dY);            //crossHairs(g2d, (int)dX, (int)dY);        }        // VERTICALLY DOWN        else if (dAngleInDegrees == -90)        {            double dYHalfOffset = (dFH + dH) / 2.0;            double dDeltaX = (dFW - dH) / 2;            double dDeltaY = dFW;            dX += dDeltaX;            dY -= dDeltaY;            g2d.rotate(dAngleInRadians, dX, dY);            if (bShadow) // RENDER THE SHADOW            {                g2d.setPaint(                	new GradientPaint(                	    new Point2D.Double(dX + 3, (dY - dYHalfOffset) + 3),                	    (Color) _sxs.getColor(la.getShadowColor()),                 	    new Point2D.Double(dX + 3 + dFW, (dY - dYHalfOffset) + 3 + dFH),                	    (Color) _sxs.getColor(la.getShadowColor().translucent())             	    )                );                g2d.fill(new Rectangle2D.Double(dX + 3, (dY - dYHalfOffset) + 3, dFW, dFH));            }            else            {                final Rectangle2D.Double r2d = new Rectangle2D.Double(dX, dY - dYHalfOffset, dFW, dFH);                // RENDER THE BACKGROUND                g2d.setColor(clrBackground);                g2d.fill(r2d);                // RENDER THE TEXT                g2d.setColor(clrText);                for (int i = 0; i < itm.getLineCount(); i++)                {                    tl = ((SwingTextMetrics) itm).getLayout(i);                    if (bRightAligned)                    {                        dW = tl.getBounds().getWidth();                        dXOffset = -ins.getLeft() + dFW - dW - ins.getRight();                    }                    else if (bCenterAligned)                    {                        dW = tl.getBounds().getWidth();                        dXOffset = -ins.getLeft() + (dFW - dW) / 2;                    }                    tl.draw(g2d, (float) (dX + dXOffset + ins.getLeft()),                        (float) (((dY - dD) - ((itm.getLineCount() - i) * dH - (iLC + 1) * dH / 2)) + ins.getTop()));                }                // RENDER THE OUTLINE/BORDER                renderOutline(ipr, la.getOutline(), r2d);            }            // UNDO THE 'ROTATED' STATE OF THE GRAPHICS CONTEXT            g2d.rotate(-dAngleInRadians, dX, dY);            //crossHairs(g2d, (int)dX, (int)dY);        }        itm.dispose();    }