Exemple #1
0
 public static BufferedImage scaleImage(BufferedImage bi, double scale) {
   int w1 = (int) (Math.round(scale * bi.getWidth()));
   int h1 = (int) (Math.round(scale * bi.getHeight()));
   BufferedImage image = new BufferedImage(w1, h1, BufferedImage.TYPE_INT_RGB);
   Graphics2D g2 = image.createGraphics();
   g2.setRenderingHint(
       RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
   g2.setPaint(Color.white);
   g2.fillRect(0, 0, w1, h1);
   g2.drawImage(bi, 0, 0, w1, h1, null); // this);
   g2.dispose();
   return image;
 }
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      String text;
      Color color;

      if (value instanceof VirtualFile) {
        VirtualFile root = (VirtualFile) value;
        int readableRow =
            ScrollingUtil.getReadableRow(table, Math.round(myUi.getTable().getRowHeight() * 0.5f));
        if (row < readableRow) {
          text = "";
        } else if (row == 0
            || !value.equals(table.getModel().getValueAt(row - 1, column))
            || readableRow == row) {
          text = root.getName();
        } else {
          text = "";
        }
        color = getRootBackgroundColor(root, myUi.getColorManager());
      } else {
        text = null;
        color = UIUtil.getTableBackground(isSelected);
      }

      myColor = color;
      Color background =
          ((VcsLogGraphTable) table)
              .getStyle(row, column, text, hasFocus, isSelected)
              .getBackground();
      assert background != null;
      myBorderColor = background;
      setForeground(UIUtil.getTableForeground(false));

      if (myUi.isShowRootNames()) {
        setText(text);
        isNarrow = false;
      } else {
        setText("");
        isNarrow = true;
      }

      return this;
    }