/** * Adds a border (complete or partially) to the current path.. * * @param rectangle a <CODE>Rectangle</CODE> */ public void Rectangle(Rectangle rectangle) { // the coordinates of the border are retrieved float x1 = rectangle.Left; float y1 = rectangle.Bottom; float x2 = rectangle.Right; float y2 = rectangle.Top; // the backgroundcolor is set BaseColor background = rectangle.BackgroundColor; if (background != null) { SaveState(); SetColorFill(background); Rectangle(x1, y1, x2 - x1, y2 - y1); Fill(); RestoreState(); } // if the element hasn't got any borders, nothing is added if (! rectangle.HasBorders()) { return; } // if any of the individual border colors are set // we draw the borders all around using the // different colors if (rectangle.UseVariableBorders) { VariableRectangle(rectangle); } else { // the width is set to the width of the element if (rectangle.BorderWidth != iTextSharp.text.Rectangle.UNDEFINED) { SetLineWidth(rectangle.BorderWidth); } // the color is set to the color of the element BaseColor color = rectangle.BorderColor; if (color != null) { SetColorStroke(color); } // if the box is a rectangle, it is added as a rectangle if (rectangle.HasBorder(iTextSharp.text.Rectangle.BOX)) { this.Rectangle(x1, y1, x2 - x1, y2 - y1); } // if the border isn't a rectangle, the different sides are added apart else { if (rectangle.HasBorder(iTextSharp.text.Rectangle.RIGHT_BORDER)) { MoveTo(x2, y1); LineTo(x2, y2); } if (rectangle.HasBorder(iTextSharp.text.Rectangle.LEFT_BORDER)) { MoveTo(x1, y1); LineTo(x1, y2); } if (rectangle.HasBorder(iTextSharp.text.Rectangle.BOTTOM_BORDER)) { MoveTo(x1, y1); LineTo(x2, y1); } if (rectangle.HasBorder(iTextSharp.text.Rectangle.TOP_BORDER)) { MoveTo(x1, y2); LineTo(x2, y2); } } Stroke(); if (color != null) { ResetRGBColorStroke(); } } }