/**
   * Paint the component.
   *
   * @param g The graphics context for painting
   * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
   */
  protected void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    fRenderer.paintComponent(g2, fButtonDelegate, this, 0, 0, getWidth(), getHeight(), true);

    ButtonModel model = getModel();
    boolean doOffset = model.isPressed() && model.isArmed();
    int offsetAmount = UIManager.getInt("Button.textShiftOffset");
    double degrees = Math.toRadians(-90);

    if (fRotation == LEFT) {
      int h = getHeight();
      g2.translate(0, h);
      g2.rotate(degrees);
      if (doOffset) {
        g2.translate(-offsetAmount, offsetAmount);
      }

      fRenderer.paintComponent(g2, fLabelDelegate, this, 0, 0, getHeight(), getWidth(), true);
      if (doOffset) {
        g2.translate(offsetAmount, -offsetAmount);
      }
      g2.rotate(-degrees);

      g2.translate(0, -h);
    } else {
      int w = getWidth();
      g2.translate(w, 0);
      g2.rotate(-degrees);
      if (doOffset) {
        g2.translate(offsetAmount, -offsetAmount);
      }
      fRenderer.paintComponent(g2, fLabelDelegate, this, 0, 0, getHeight(), getWidth(), true);
      if (doOffset) {
        g2.translate(-offsetAmount, offsetAmount);
      }
      g2.rotate(degrees);
      g2.translate(-w, 0);
    }
  }
  /** Paint cell at (row, column). */
  protected void paintCell(Graphics g, Rectangle cellBounds, int row, int column) {
    if ((grid.getEditingRow() == row) && (grid.getEditingColumn() == column)) {
      return;
    }

    GridCellRenderer renderer = grid.getCellRenderer(row, column);
    Component rendererComp = grid.prepareRenderer(renderer, row, column);
    rendererPane.paintComponent(
        g,
        rendererComp,
        grid,
        cellBounds.x,
        cellBounds.y,
        cellBounds.width,
        cellBounds.height,
        true);
  }
Ejemplo n.º 3
0
 public static void paintComponent(
     final Graphics graphics,
     final Component component,
     final Container container,
     final int x,
     final int y,
     final int width,
     final int height) {
   Container auxContainer = Utilities.getNotWindowParent(component);
   if (auxContainer instanceof CellRendererPane) {
     if (Utilities.getNotWindowParent(auxContainer) != container) {
       container.add(auxContainer);
     }
   } else {
     auxContainer = new CellRendererPane();
     container.add(auxContainer);
   }
   ((CellRendererPane) auxContainer)
       .paintComponent(graphics, component, container, x, y, width, height, false);
 }
 protected void doPaintTooltipImage(
     Component rComponent, Rectangle cellBounds, Graphics2D g, KeyType key) {
   myRendererPane.paintComponent(
       g, rComponent, myComponent, 0, 0, cellBounds.width, cellBounds.height, true);
 }