/** * Draws a horizontal line. * * @param canvas the canvas to draw on * @param leftX the left x coordinate * @param rightX the right x coordindate * @param y the y coordinate */ public void drawLine(PdfContentByte canvas, float leftX, float rightX, float y) { float w; if (getPercentage() < 0) w = -getPercentage(); else w = (rightX - leftX) * getPercentage() / 100.0f; float s; switch (getAlignment()) { case Element.ALIGN_LEFT: s = 0; break; case Element.ALIGN_RIGHT: s = rightX - leftX - w; break; default: s = (rightX - leftX - w) / 2; break; } canvas.setLineWidth(getLineWidth()); if (getLineColor() != null) canvas.setColorStroke(getLineColor()); canvas.moveTo(s + leftX, y + offset); canvas.lineTo(s + w + leftX, y + offset); canvas.stroke(); }
/** * @see cljpdf.text.pdf.draw.DrawInterface#draw(cljpdf.text.pdf.PdfContentByte, float, float, * float, float, float) */ public void draw(PdfContentByte canvas, float llx, float lly, float urx, float ury, float y) { canvas.saveState(); drawLine(canvas, llx, urx, y); canvas.restoreState(); }