コード例 #1
0
  /**
   * 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);
    }
  }
コード例 #2
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);
   CellSpan span = grid.getSpanModel().getSpanOver(row, column);
   rendererPane.paintComponent(
       g,
       rendererComp,
       grid,
       cellBounds.x,
       cellBounds.y,
       cellBounds.width,
       cellBounds.height,
       true);
 }
 protected void doPaintTooltipImage(
     Component rComponent, Rectangle cellBounds, Graphics2D g, KeyType key) {
   myRendererPane.paintComponent(
       g, rComponent, myComponent, 0, 0, cellBounds.width, cellBounds.height, true);
 }