public DrawTableShape getDrawable(TableShape<?,?> shape) { return new DrawTableShape(shape); }
public void draw(Graphics2D graphics) { Drawable d = getGroupShape(graphics); if (d != null) { d.draw(graphics); TableShape<?,?> ts = getShape(); DrawPaint drawPaint = DrawFactory.getInstance(graphics).getPaint(ts); final int rows = ts.getNumberOfRows(); continue; graphics.setStroke(getStroke(stroke)); Paint linePaint = drawPaint.getPaint(graphics, stroke.getPaint()); graphics.setPaint(linePaint); drawContent(graphics);
/** * Format the table and apply the specified Line to all cell boundaries, * both outside and inside. * An empty args parameter removes the affected border. * * @param args a varargs array possible containing {@link Double} (width), * {@link LineCompound}, {@link Color}, {@link LineDash} */ public void setAllBorders(Object... args) { TableShape<?,?> table = getShape(); final int rows = table.getNumberOfRows(); final int cols = table.getNumberOfColumns(); BorderEdge edges[] = { BorderEdge.top, BorderEdge.left, null, null }; for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { edges[2] = (col == cols - 1) ? BorderEdge.right : null; edges[3] = (row == rows - 1) ? BorderEdge.bottom : null; setEdges(table.getCell(row, col), edges, args); } } }
public void drawContent(Graphics2D graphics) { Drawable d = getGroupShape(graphics); if (d != null) { d.drawContent(graphics); return; } TableShape<?,?> ts = getShape(); DrawFactory df = DrawFactory.getInstance(graphics); final int rows = ts.getNumberOfRows(); final int cols = ts.getNumberOfColumns(); for (int row=0; row<rows; row++) { for (int col=0; col<cols; col++) { TableCell<?,?> tc = ts.getCell(row, col); if (tc != null) { DrawTextShape dts = df.getDrawable(tc); dts.drawContent(graphics); } } } }
DrawTableShape dts = new DrawTableShape(table1); dts.setAllBorders(1.0, Color.black); dts.setOutsideBorders(4.0);
static void create1stTable(HSLFSlide slide) { //six rows, two columns HSLFTable table1 = slide.createTable(6, 2); for (int i = 0; i < txt1.length; i++) { for (int j = 0; j < txt1[i].length; j++) { HSLFTableCell cell = table1.getCell(i, j); HSLFTextRun rt = cell.getTextParagraphs().get(0).getTextRuns().get(0); rt.setFontFamily("Arial"); rt.setFontSize(10d); if(i == 0){ cell.getFill().setForegroundColor(new Color(227, 227, 227)); } else { rt.setBold(true); } cell.setVerticalAlignment(VerticalAlignment.MIDDLE); cell.setHorizontalCentered(true); cell.setText(txt1[i][j]); } } DrawTableShape dts1 = new DrawTableShape(table1); dts1.setAllBorders(1.0, Color.black); table1.setColumnWidth(0, 300); table1.setColumnWidth(1, 150); int pgWidth = slide.getSlideShow().getPageSize().width; table1.moveTo((pgWidth - table1.getAnchor().getWidth())/2., 100.); }
table2.setRowHeight(1, 70); DrawTableShape dts2 = new DrawTableShape(table2); dts2.setOutsideBorders(Color.black, 1.0);
public void applyTransform(Graphics2D graphics) { Drawable d = getGroupShape(graphics); if (d != null) { d.applyTransform(graphics); } else { super.applyTransform(graphics); } }
public void drawContent(Graphics2D graphics) { Drawable d = getGroupShape(graphics); if (d != null) { d.drawContent(graphics); return; } TableShape<?,?> ts = getShape(); DrawFactory df = DrawFactory.getInstance(graphics); final int rows = ts.getNumberOfRows(); final int cols = ts.getNumberOfColumns(); for (int row=0; row<rows; row++) { for (int col=0; col<cols; col++) { TableCell<?,?> tc = ts.getCell(row, col); if (tc != null) { DrawTextShape dts = df.getDrawable(tc); dts.drawContent(graphics); } } } }
public void applyTransform(Graphics2D graphics) { Drawable d = getGroupShape(graphics); if (d != null) { d.applyTransform(graphics); } else { super.applyTransform(graphics); } }
public void draw(Graphics2D graphics) { Drawable d = getGroupShape(graphics); if (d != null) { d.draw(graphics); TableShape<?,?> ts = getShape(); DrawPaint drawPaint = DrawFactory.getInstance(graphics).getPaint(ts); final int rows = ts.getNumberOfRows(); continue; graphics.setStroke(getStroke(stroke)); Paint linePaint = drawPaint.getPaint(graphics, stroke.getPaint()); graphics.setPaint(linePaint); drawContent(graphics);
/** * Format the inside border using the specified Line object * An empty args parameter removes the affected border. * * @param args a varargs array possible containing {@link Double} (width), * {@link LineCompound}, {@link Color}, {@link LineDash} */ public void setInsideBorders(Object... args) { if (args.length == 0) return; TableShape<?,?> table = getShape(); final int rows = table.getNumberOfRows(); final int cols = table.getNumberOfColumns(); BorderEdge edges[] = new BorderEdge[2]; for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { edges[0] = (col > 0 && col < cols - 1) ? BorderEdge.right : null; edges[1] = (row > 0 && row < rows - 1) ? BorderEdge.bottom : null; setEdges(table.getCell(row, col), edges, args); } } }
public DrawTableShape getDrawable(TableShape<?,?> shape) { return new DrawTableShape(shape); }
/** * Format the outside border using the specified Line object * An empty args parameter removes the affected border. * * @param args a varargs array possible containing {@link Double} (width), * {@link LineCompound}, {@link Color}, {@link LineDash} */ public void setOutsideBorders(Object... args){ if (args.length == 0) return; TableShape<?,?> table = getShape(); final int rows = table.getNumberOfRows(); final int cols = table.getNumberOfColumns(); BorderEdge edges[] = new BorderEdge[4]; for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { edges[0] = (col == 0) ? BorderEdge.left : null; edges[1] = (col == cols - 1) ? BorderEdge.right : null; edges[2] = (row == 0) ? BorderEdge.top : null; edges[3] = (row == rows - 1) ? BorderEdge.bottom : null; setEdges(table.getCell(row, col), edges, args); } } }
/** * Format the inside border using the specified Line object * An empty args parameter removes the affected border. * * @param args a varargs array possible containing {@link Double} (width), * {@link LineCompound}, {@link Color}, {@link LineDash} */ public void setInsideBorders(Object... args) { if (args.length == 0) return; TableShape<?,?> table = getShape(); final int rows = table.getNumberOfRows(); final int cols = table.getNumberOfColumns(); BorderEdge edges[] = new BorderEdge[2]; for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { edges[0] = (col > 0 && col < cols - 1) ? BorderEdge.right : null; edges[1] = (row > 0 && row < rows - 1) ? BorderEdge.bottom : null; setEdges(table.getCell(row, col), edges, args); } } }
/** * Format the table and apply the specified Line to all cell boundaries, * both outside and inside. * An empty args parameter removes the affected border. * * @param args a varargs array possible containing {@link Double} (width), * {@link LineCompound}, {@link Color}, {@link LineDash} */ public void setAllBorders(Object... args) { TableShape<?,?> table = getShape(); final int rows = table.getNumberOfRows(); final int cols = table.getNumberOfColumns(); BorderEdge edges[] = { BorderEdge.top, BorderEdge.left, null, null }; for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { edges[2] = (col == cols - 1) ? BorderEdge.right : null; edges[3] = (row == rows - 1) ? BorderEdge.bottom : null; setEdges(table.getCell(row, col), edges, args); } } }
/** * Format the outside border using the specified Line object * An empty args parameter removes the affected border. * * @param args a varargs array possible containing {@link Double} (width), * {@link LineCompound}, {@link Color}, {@link LineDash} */ public void setOutsideBorders(Object... args){ if (args.length == 0) return; TableShape<?,?> table = getShape(); final int rows = table.getNumberOfRows(); final int cols = table.getNumberOfColumns(); BorderEdge edges[] = new BorderEdge[4]; for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { edges[0] = (col == 0) ? BorderEdge.left : null; edges[1] = (col == cols - 1) ? BorderEdge.right : null; edges[2] = (row == 0) ? BorderEdge.top : null; edges[3] = (row == rows - 1) ? BorderEdge.bottom : null; setEdges(table.getCell(row, col), edges, args); } } }