Exemplo n.º 1
0
  @Override
  public void populateGraphicsContent(Graphics graphics, Dimension canvasSize) {
    if (null == graphics) return;
    if (null != canvasSize) setCanvasSize(canvasSize);

    setWidth(DesignUtil.calculateTableWidth(getGraphics(), getDbModel(), true));
    setHeight(DesignUtil.calculateTableHeight(getGraphics(), getDbModel(), true));
    if (getX() == 0 && getY() == 0) {
      setX(canvasSize.width - (canvasSize.width / 2 - getWidth() / 2));
      setY(DbexDesignConstants.TABLE_LEFT_MARGIN_WIDTH);
    }
    int colStart_X = getX() + 1;
    int colStart_Y = getY() + DesignUtil.calculateCellHeight(getGraphics()) + 2;
    int cellHeight = DesignUtil.calculateCellHeight(getGraphics());
    if (null != columnDbShapes) {
      for (int i = 0; i < columnDbShapes.size(); i++) {
        ColumnDbShape columnDbShape = columnDbShapes.get(i);
        columnDbShape.setX(colStart_X);
        columnDbShape.setY(colStart_Y + (cellHeight * (i)));
        columnDbShape.setWidth(getWidth());
        columnDbShape.setHeight(cellHeight);
        columnDbShape.setGraphics(graphics);
        columnDbShape.populateGraphicsContent(graphics, canvasSize);
      }
    }
  }
Exemplo n.º 2
0
  @Override
  public void drawShape() {
    Graphics2D graphics = (Graphics2D) getGraphics();
    Color oldFg = graphics.getColor();
    Table table = getDbModel();
    if (null != table) {
      Point location = getLocation();
      Dimension size = getSize();
      // draw the border
      graphics.setColor(DbexColorConstants.TABLE_BORDER_COLOR);
      graphics.drawRect(location.x, location.y, size.width, size.height);
      graphics.setColor(DbexColorConstants.COLUMN_NAMES_BG_COLOR);
      graphics.fillRect(location.x + 1, location.y + 1, size.width - 1, size.height - 1);
      // draw the header
      graphics.setColor(DbexColorConstants.TABLE_BORDER_COLOR);
      graphics.drawRect(
          location.x, location.y, size.width, DesignUtil.calculateCellHeight(graphics));
      graphics.setColor(DbexColorConstants.TABLE_HEADER_BG_COLOR);
      graphics.fillRect(
          location.x + 1,
          location.y + 1,
          size.width - 1,
          DesignUtil.calculateCellHeight(graphics) - 1);
      graphics.setColor(DbexColorConstants.TABLE_HEADER_FG_COLOR);
      graphics.drawString(
          table.getModelName(),
          location.x + 2,
          location.y + DesignUtil.calculateCellHeight(graphics) - 4);
      // draw the left margin
      graphics.setColor(DbexColorConstants.TABLE_BORDER_COLOR);
      graphics.drawRect(
          location.x,
          location.y + DesignUtil.calculateCellHeight(graphics),
          DbexDesignConstants.TABLE_LEFT_MARGIN_WIDTH,
          size.height - DesignUtil.calculateCellHeight(graphics));
      graphics.setColor(DbexColorConstants.TABLE_LEFT_MARGIN_BG_COLOR);
      graphics.fillRect(
          location.x + 1,
          location.y + DesignUtil.calculateCellHeight(graphics) + 1,
          DbexDesignConstants.TABLE_LEFT_MARGIN_WIDTH - 1,
          size.height - 1 - DesignUtil.calculateCellHeight(graphics));

      // draw columns
      if (null != columnDbShapes) {
        for (int i = 0; i < columnDbShapes.size(); i++) {
          ColumnDbShape columnDbShape = columnDbShapes.get(i);
          columnDbShape.drawShape();
          if (i < columnDbShapes.size() - 1) {
            graphics.setColor(DbexColorConstants.TABLE_BORDER_COLOR);
            graphics.drawLine(
                columnDbShape.getX() + DbexDesignConstants.TABLE_LEFT_MARGIN_WIDTH + 2,
                columnDbShape.getY() + columnDbShape.getHeight() + 2,
                location.x + size.width,
                columnDbShape.getY() + columnDbShape.getHeight() + 2);
          }
        }
      }
    }
    graphics.setColor(oldFg);
  }