protected void renderBorder(Graphics2D g) {
//        if( false ) {
//            float width = 1.0f;
//            Rectangle2D.Float jrect = deriveBorderDrawingRectangle( width );
//            g.setColor( Color.red );
//            g.setStroke( new BasicStroke(width) );
//            g.draw( jrect );
//            return;
//        }

        Color borderColor = getColor();
        if (borderColor != null) {
            g.setColor(borderColor);
        }

        BorderStyle bs = getBorderStyle();
        if (bs != null) {
            float width = bs.getStrokeWidth();
            if (width > 0.0f && borderColor != null && canDrawBorder) {
                Rectangle2D.Float jrect = deriveBorderDrawingRectangle(width);

                if (bs.isStyleSolid()) {
                    g.setStroke(new BasicStroke(width));
                    g.draw(jrect);
                } else if (bs.isStyleDashed()) {
                    BasicStroke stroke = new BasicStroke(
                            width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER,
                            10.0f, bs.getDashArray(), 0.0f);
                    g.setStroke(stroke);
                    g.draw(jrect);
                } else if (bs.isStyleBeveled()) {
                    jrect = deriveDrawingRectangle();

                    g.setStroke(new BasicStroke(1.0f));
                    Line2D.Double line;

                    // Upper top
                    g.setColor(BorderStyle.LIGHT);
                    line = new Line2D.Double( // Top line
                            jrect.getMinX() + 1.0, jrect.getMaxY() - 1.0, jrect.getMaxX() - 2.0, jrect.getMaxY() - 1.0);
                    g.draw(line);
                    line = new Line2D.Double( // Left line
                            jrect.getMinX() + 1.0f, jrect.getMinY() + 2.0, jrect.getMinX() + 1.0f, jrect.getMaxY() - 1.0);
                    g.draw(line);

                    // Inner top
                    g.setColor(BorderStyle.LIGHTEST);
                    line = new Line2D.Double( // Top line
                            jrect.getMinX() + 2.0, jrect.getMaxY() - 2.0, jrect.getMaxX() - 3.0, jrect.getMaxY() - 2.0);
                    g.draw(line);
                    line = new Line2D.Double( // Left line
                            jrect.getMinX() + 2.0f, jrect.getMinY() + 3.0, jrect.getMinX() + 2.0f, jrect.getMaxY() - 2.0);
                    g.draw(line);

                    // Inner bottom
                    g.setColor(BorderStyle.DARK);
                    line = new Line2D.Double( // Bottom line
                            jrect.getMinX() + 2.0, jrect.getMinY() + 2.0, jrect.getMaxX() - 2.0, jrect.getMinY() + 2.0);
                    g.draw(line);
                    line = new Line2D.Double( // Right line
                            jrect.getMaxX() - 2.0f, jrect.getMinY() + 2.0, jrect.getMaxX() - 2.0f, jrect.getMaxY() - 2.0);
                    g.draw(line);

                    // Lower bottom
                    g.setColor(BorderStyle.DARKEST);
                    line = new Line2D.Double( // Bottom line
                            jrect.getMinX() + 1.0, jrect.getMinY() + 1.0, jrect.getMaxX() - 1.0, jrect.getMinY() + 1.0);
                    g.draw(line);
                    line = new Line2D.Double( // Right line
                            jrect.getMaxX() - 1.0f, jrect.getMinY() + 1.0, jrect.getMaxX() - 1.0f, jrect.getMaxY() - 1.0);
                    g.draw(line);
                } else if (bs.isStyleInset()) {
                    jrect = deriveDrawingRectangle();

                    g.setStroke(new BasicStroke(1.0f));
                    Line2D.Double line;

                    // Upper top
                    g.setColor(BorderStyle.DARK);
                    line = new Line2D.Double( // Top line
                            jrect.getMinX() + 1.0, jrect.getMaxY() - 1.0, jrect.getMaxX() - 1.0, jrect.getMaxY() - 1.0);
                    g.draw(line);
                    line = new Line2D.Double( // Left line
                            jrect.getMinX() + 1.0f, jrect.getMinY() + 1.0, jrect.getMinX() + 1.0f, jrect.getMaxY() - 1.0);
                    g.draw(line);

                    // Inner top
                    g.setColor(BorderStyle.DARKEST);
                    line = new Line2D.Double( // Top line
                            jrect.getMinX() + 2.0, jrect.getMaxY() - 2.0, jrect.getMaxX() - 2.0, jrect.getMaxY() - 2.0);
                    g.draw(line);
                    line = new Line2D.Double( // Left line
                            jrect.getMinX() + 2.0f, jrect.getMinY() + 2.0, jrect.getMinX() + 2.0f, jrect.getMaxY() - 2.0);
                    g.draw(line);

                    // Inner bottom
                    g.setColor(BorderStyle.LIGHTEST);
                    line = new Line2D.Double( // Bottom line
                            jrect.getMinX() + 3.0, jrect.getMinY() + 2.0, jrect.getMaxX() - 2.0, jrect.getMinY() + 2.0);
                    g.draw(line);
                    line = new Line2D.Double( // Right line
                            jrect.getMaxX() - 2.0f, jrect.getMinY() + 2.0, jrect.getMaxX() - 2.0f, jrect.getMaxY() - 3.0);
                    g.draw(line);

                    // Lower bottom
                    g.setColor(BorderStyle.LIGHT);
                    line = new Line2D.Double( // Bottom line
                            jrect.getMinX() + 2.0, jrect.getMinY() + 1.0, jrect.getMaxX() - 1.0, jrect.getMinY() + 1.0);
                    g.draw(line);
                    line = new Line2D.Double( // Right line
                            jrect.getMaxX() - 1.0f, jrect.getMinY() + 1.0, jrect.getMaxX() - 1.0f, jrect.getMaxY() - 2.0);
                    g.draw(line);
                } else if (bs.isStyleUnderline()) {
                    g.setStroke(new BasicStroke(width));
                    Line2D.Double line = new Line2D.Double(
                            jrect.getMinX(), jrect.getMinY(), jrect.getMaxX(), jrect.getMinY());
                    g.draw(line);
                }
            }
        } else {
            Vector borderVector = (Vector) getObject(BORDER_KEY);
            if (borderVector != null) {
                if (borderColor != null) {
                    float horizRadius = 0.0f;
                    float vertRadius = 0.0f;
                    float width = 1.0f;
                    float[] dashArray = null;
                    if (borderVector.size() >= 1)
                        horizRadius = ((Number) borderVector.get(0)).floatValue();
                    if (borderVector.size() >= 2)
                        vertRadius = ((Number) borderVector.get(1)).floatValue();
                    if (borderVector.size() >= 3)
                        width = ((Number) borderVector.get(2)).floatValue();
                    if (borderVector.size() >= 4) {
                        Object dashObj = borderVector.get(3);
                        // I guess some encoders like having fun with us,
                        //  and feed a number when a number-array is appropriate. The problem
                        //  is that for the specific PDF given, apparently no border is to be
                        //  drawn, especially not the hugely thinck one described.  So,
                        //  instead of interpretting the 4th element (Number) into a Vector,
                        //  I'm just not going to do the border if it's the Number.  I know, hack.
                        // The only theory I have is that LinkAnnotation defaults the border
                        //  color to black, when maybe it should be to null, but that could
                        //  change a _lot_ of stuff, so I won't touch it now.
                        if (dashObj instanceof Number) {
                            // Disable border drawing
                            width = 0.0f;
                        } else if (dashObj instanceof Vector) {
                            Vector dashVector = (Vector) borderVector.get(3);
                            int sz = dashVector.size();
                            dashArray = new float[sz];
                            for (int i = 0; i < sz; i++) {
                                Number num = (Number) dashVector.get(i);
                                dashArray[i] = num.floatValue();
                            }
                        }
                    }

                    if (width > 0.0f) {
                        Rectangle2D.Float jrect = deriveBorderDrawingRectangle(width);
                        RoundRectangle2D.Double roundRect = new RoundRectangle2D.Double(
                                jrect.getX(), jrect.getY(), jrect.getWidth(), jrect.getHeight(),
                                horizRadius, vertRadius);
                        BasicStroke stroke = new BasicStroke(
                                width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER,
                                10.0f, dashArray, 0.0f);
                        g.setStroke(stroke);
                        g.draw(roundRect);
                    }
                }
            } else {
                // Draw a solid rectangle, 1 pixel wide
                if (borderColor != null && SUBTYPE_LINK.equals(subtype)) {
                    float width = 1.0f;
                    Rectangle2D.Float jrect = deriveBorderDrawingRectangle(width);
                    g.setStroke(new BasicStroke(width));
                    g.draw(jrect);
                }
            }
        }
    }