Example #1
0
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      try {
        // managing colors
        if (isSelected) {
          this.setBackground(table.getSelectionBackground());
          this.setForeground(table.getSelectionForeground());
        } else {
          this.setBackground(table.getSelectionForeground());
          this.setForeground(Color.BLACK);
        }

        OWLDescription desc = (OWLDescription) value;
        desc.accept(myVisitor);
        String str = myVisitor.result();
        myVisitor.reset();

        this.setText(str);
        // System.out.println( this.getText() );
      } catch (Exception e) {
        e.printStackTrace();
      }

      return this;
    }
Example #2
0
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    if (isSelected) {
      setForeground(table.getSelectionForeground());
      setBackground(table.getSelectionBackground());
    } else {
      setForeground(table.getForeground());
      setBackground(table.getBackground());
    }

    String label = "";

    if (value instanceof Integer) {
      int val = ((Integer) value).intValue();

      if (val < 0 || val > 127) {
        label = "";
      } else {
        label = Integer.toString(val);
      }
    }

    this.setText(label);
    return this;
  }
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean cellHasFocus, int row, int col) {

    Color colour = (Color) value;

    int red = colour.getRed();
    int green = colour.getGreen();
    int blue = colour.getBlue();

    if (isSelected) {
      setBackground(table.getSelectionBackground());
      setForeground(table.getSelectionForeground());
    } else {
      setBackground(table.getBackground());
      setForeground(table.getForeground());
    }

    icon.setColour(colour);
    setIcon(icon);

    text.append(" [").append(red).append(",").append(green).append(",").append(blue).append("]");

    setText(text.toString());
    text.setLength(0);

    return this;
  }
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   if (row < tv.getRowData().size()) {
     Vector line = (Vector) tv.getRowData().get(row);
     if (value != null) {
       setText(value.toString());
     }
     this.setOpaque(true);
     String searchStr = tv.getSearchString();
     String ceilStr = (String) line.get(column);
     boolean found =
         (searchStr != null
             && searchStr.length() > 0
             && ceilStr.toUpperCase().indexOf(searchStr.toUpperCase()) >= 0);
     Color backColor =
         (row % 2 == 0 && !isSelected)
             ? found ? searchBackColor : stripColor
             : (isSelected
                 ? table.getSelectionBackground()
                 : found ? searchBackColor : table.getBackground());
     Color foreColor =
         isSelected
             ? found ? searchStringColor : table.getSelectionForeground()
             : found ? searchStringColor : table.getForeground();
     setBackground(backColor);
     setForeground(foreColor);
   }
   return this;
 }
Example #5
0
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean isFocused, int row, int col) {

      if (isSelected) {
        setBackground(table.getSelectionBackground());
        setForeground(table.getSelectionForeground());
      } else {
        setForeground(table.getForeground());
        if (row % 2 == 0) {
          setBackground(EVEN_COLOR);
        } else {
          setBackground(ODD_COLOR);
        }
      }

      if (value != null && value instanceof String) {

        String pubType = (String) value;

        if (pubType.equals(IInfoModel.PUBLISHED_TYPE_GLOBAL)) {
          setIcon(WEB_ICON);
        } else {
          setIcon(HOME_ICON);
        }
        this.setText("");

      } else {
        setIcon(null);
        this.setText(value == null ? "" : value.toString());
      }
      return this;
    }
Example #6
0
  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    textLabel.setFont(table.getFont());
    textLabel.setText(Objects.toString(value, ""));
    textLabel.setBorder(hasFocus ? focusCellHighlightBorder : noFocusBorder);

    FontMetrics fm = table.getFontMetrics(table.getFont());
    Insets i = textLabel.getInsets();
    int swidth =
        iconLabel.getPreferredSize().width + fm.stringWidth(textLabel.getText()) + i.left + i.right;
    int cwidth = table.getColumnModel().getColumn(column).getWidth();
    dim.width = swidth > cwidth ? cwidth : swidth;

    if (isSelected) {
      textLabel.setOpaque(true);
      textLabel.setForeground(table.getSelectionForeground());
      textLabel.setBackground(table.getSelectionBackground());
      iconLabel.setIcon(sicon);
    } else {
      textLabel.setOpaque(false);
      textLabel.setForeground(table.getForeground());
      textLabel.setBackground(table.getBackground());
      iconLabel.setIcon(nicon);
    }
    return panel;
  }
Example #7
0
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean isFocused, int row, int col) {

      if (isSelected) {
        setBackground(table.getSelectionBackground());
        setForeground(table.getSelectionForeground());
      } else {
        setForeground(table.getForeground());
        if (row % 2 == 0) {
          setBackground(EVEN_COLOR);
        } else {
          setBackground(ODD_COLOR);
        }
      }

      if (value != null && value instanceof Boolean) {

        Boolean imported = (Boolean) value;

        if (imported.booleanValue()) {
          this.setIcon(FLAG_ICON);
        } else {
          this.setIcon(null);
        }
        this.setText("");

      } else {
        setIcon(null);
        this.setText(value == null ? "" : value.toString());
      }
      return this;
    }
 @Override
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   if (isSelected) {
     setForeground(table.getSelectionForeground());
     setBackground(table.getSelectionBackground());
   } else {
     setForeground(table.getForeground());
     setBackground(table.getBackground());
   }
   setFont(table.getFont());
   if (hasFocus) {
     setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
     if (table.isCellEditable(row, column)) {
       setForeground(UIManager.getColor("Table.focusCellForeground"));
       setBackground(UIManager.getColor("Table.focusCellBackground"));
     }
   } else {
     setBorder(new EmptyBorder(1, 2, 1, 2));
   }
   if (value != null) {
     setText(value.toString());
   } else {
     setText("");
   }
   adjustRowHeight(table, row, column);
   return this;
 }
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      if (isSelected) {
        renderButton.setForeground(table.getSelectionForeground());
        renderButton.setBackground(table.getSelectionBackground());
      } else {
        renderButton.setForeground(table.getForeground());
        renderButton.setBackground(UIManager.getColor("Button.background"));
      }

      renderButton.setFocusPainted(hasFocus);

      if (value == null) {
        renderButton.setText("");
        renderButton.setIcon(null);
      } else if (value instanceof Icon) {
        renderButton.setText("");
        renderButton.setIcon((Icon) value);
      } else {
        renderButton.setText(value.toString());
        renderButton.setIcon(null);
      }
      return renderButton;
    }
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

    if (value != null) {
      DateFormat df = new SimpleDateFormat(DATETIME_FORMAT);
      df.setTimeZone(TimeZone.getDefault());
      setText(df.format((Long) value));
    } else setText("");

    setHorizontalAlignment(JLabel.LEFT);
    TableModel model = table.getModel();

    boolean valuesDiffer =
        model instanceof DesignTableModel ? ((DesignTableModel) model).isValuesDiffer(row) : false;
    if (valuesDiffer && !isSelected) {
      setForeground(table.getForeground());
      setBackground(DesignPanel.DIFFER_NO_FOCUS_COLOR);
    } else if (isSelected) {
      setForeground(table.getSelectionForeground());
      setBackground(table.getSelectionBackground());
    } else {
      setForeground(table.getForeground());
      setBackground(table.getBackground());
    }

    return this;
  }
 /*
  * (non-Javadoc)
  *
  * @see org.protege.editor.owl.ui.renderer.OWLCellRenderer#
  * getTableCellRendererComponent(javax.swing.JTable, java.lang.Object,
  * boolean, boolean, int, int)
  */
 @Override
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   Component comp;
   objectToRender = value;
   if (objectToRender instanceof OWLAxiomChange) {
     value = ((OWLOntologyChange) objectToRender).getAxiom();
   } else if (objectToRender instanceof OWLAxiomChange) {
     value = ((ImportChange) objectToRender).getImportDeclaration();
   } else if (objectToRender instanceof AddOntologyAnnotation) {
     value = ((AddOntologyAnnotation) objectToRender).getAnnotation();
   } else if (objectToRender instanceof RemoveOntologyAnnotation) {
     value = ((RemoveOntologyAnnotation) objectToRender).getAnnotation();
   } else {
     // do nothing
   }
   if (value instanceof String) {
     comp =
         defaultTableCellRenderer.getTableCellRendererComponent(
             table, value, isSelected, hasFocus, row, column);
   } else {
     comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
   }
   if (isSelected) {
     comp.setForeground(table.getSelectionForeground());
     comp.setBackground(table.getSelectionBackground());
   } else {
     comp.setForeground(table.getForeground());
     comp.setBackground(table.getBackground());
   }
   return comp;
 }
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    setOpaque(true);
    setFont(plainFont);
    // setBorder(new EmptyBorder(10, 10, 10, 6));

    if (isSelected) {
      setForeground(table.getSelectionForeground());
      setBackground(table.getSelectionBackground());
    } else {
      setForeground(table.getForeground());
      setBackground(table.getBackground());
    }

    if (table.getModel() instanceof FeedTableModel) {
      FeedTableModel rsstm = (FeedTableModel) table.getModel();
      TableColumn col = table.getColumnModel().getColumn(column);
      if (!rsstm.isItemAtRowRead(row)) setFont(boldFont);
      if (col.getHeaderValue() == FeedTableModel.READ) {
        if (rsstm.isItemAtRowRead(row)) setIcon(readItemIcon);
        else setIcon(unreadItemIcon);
      } else setIcon(null);

    } else if (table.getModel() instanceof WeblogTableModel) {
      WeblogTableModel btm = (WeblogTableModel) table.getModel();
      if (column == 0) {
        // is the modified column on the TableModel null?
        if (btm.getValueAt(row, WeblogTableModel.MODIFIED_COL) == null) setIcon(postIcon);
        else setIcon(uPostIcon);
      } else setIcon(null);
    }

    if (value instanceof FeedItem) {
      setText(((FeedItem) value).getTitle());
      return this;
    } else if (value instanceof Boolean) {
      setText("");
      setHorizontalAlignment(SwingConstants.CENTER);
      return this;
    } else if (value instanceof Integer) {
      Integer val = (Integer) value;
      setHorizontalAlignment(SwingConstants.CENTER);
      setText(val.intValue() + "");
      return this;
    } else if (value instanceof Date) {
      Date d = (Date) value;
      setText(df.format(d));
      if ((table.getModel() instanceof WeblogTableModel) && (column == WeblogTableModel.DATE_COL)) {
        if (expireDate != null && d.before(expireDate)) setForeground(Color.red);
      }

      return this;
    }

    setHorizontalAlignment(SwingConstants.LEFT);
    // setToolTipText(value.toString());
    if (value == null) setText("");
    else setText(value.toString());
    return this;
  }
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   final Color color = UIUtil.getTableFocusCellBackground();
   Component component;
   T t = (T) value;
   try {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, table.getSelectionBackground());
     component =
         super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
     setText(t != null ? getItemText(t) : "");
     if (component instanceof JLabel) {
       ((JLabel) component).setBorder(noFocusBorder);
     }
   } finally {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, color);
   }
   final MyTableModel model = (MyTableModel) table.getModel();
   component.setEnabled(
       ElementsChooser.this.isEnabled()
           && (myColorUnmarkedElements ? model.isElementMarked(row) : true));
   final ElementProperties properties = myElementToPropertiesMap.get(t);
   if (component instanceof JLabel) {
     final Icon icon =
         properties != null ? properties.getIcon() : t != null ? getItemIcon(t) : null;
     JLabel label = (JLabel) component;
     label.setIcon(icon);
     label.setDisabledIcon(icon);
   }
   component.setForeground(
       properties != null && properties.getColor() != null
           ? properties.getColor()
           : (isSelected ? table.getSelectionForeground() : table.getForeground()));
   return component;
 }
Example #14
0
    public Component getTableCellRendererComponent(
        JTable table, Object color, boolean isSelected, boolean hasFocus, int row, int column) {
      final String text = ((JButton) color).getText();
      setText(text);

      final Icon icon = ((JButton) color).getIcon();
      setIcon(icon);

      if (isSelected) {
        setForeground(table.getSelectionForeground());
        setBackground(table.getSelectionBackground());
      } else {
        setForeground(Color.black);
        setBackground(Color.white);
        if (row % 2 == 0) {
          // setBackground( new Color( 156, 207, 255 ) );
        }
      }

      if (isBordered) {
        if (isSelected) {
          if (selectedBorder == null) {
            selectedBorder =
                BorderFactory.createMatteBorder(2, 5, 2, 5, table.getSelectionBackground());
          }
          setBorder(selectedBorder);
        } else {
          if (unselectedBorder == null) {
            unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5, table.getBackground());
          }
          setBorder(unselectedBorder);
        }
      }
      return this;
    }
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   final Color color = UIUtil.getTableFocusCellBackground();
   Component component;
   final Module module = value instanceof Module ? (Module) value : null;
   try {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, table.getSelectionBackground());
     component =
         super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
     if (module != null) {
       setText(
           module.getName()
               + " ("
               + FileUtil.toSystemDependentName(module.getModuleFilePath())
               + ")");
     }
     if (component instanceof JLabel) {
       ((JLabel) component).setBorder(noFocusBorder);
     }
   } finally {
     UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, color);
   }
   component.setEnabled(ProcessedModulesTable.this.isEnabled());
   if (component instanceof JLabel) {
     final Icon icon = module != null ? ModuleType.get(module).getIcon() : null;
     JLabel label = (JLabel) component;
     label.setIcon(icon);
     label.setDisabledIcon(icon);
   }
   component.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
   return component;
 }
  /**
   * Returns the default table cell renderer.
   *
   * @param table the <code>JTable</code>
   * @param value the value to assign to the cell at <code>[row, column]</code>
   * @param isSelected true if cell is selected
   * @param hasFocus true if cell has focus
   * @param row the row of the cell to render
   * @param column the column of the cell to render
   * @return the default table cell renderer
   */
  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    if (isSelected) {
      this.setBackground(table.getSelectionBackground());
      this.setForeground(table.getSelectionForeground());

    } else {
      this.setBackground(table.getBackground());
      this.setForeground(table.getForeground());
    }

    this.setEnabled(table.isEnabled());
    this.setFont(table.getFont());

    if (value instanceof CEMSystemActivity) {
      CEMSystemActivity activity = (CEMSystemActivity) value;
      int state = activity.getState();
      this.setText(activity.getText());
      if (state == CEMEntry.STATUS_ACCEPTED_INT || state == CEMEntry.STATUS_PENDING_INT) {
        Color backgroundColor = table.getBackground();
        if (state == CEMEntry.STATUS_ACCEPTED_INT) {
          backgroundColor = this.colorAccepted;
        } else if (state == CEMEntry.STATUS_PENDING_INT) {
          backgroundColor = this.colorPending;
        }
        if (isSelected) {
          this.setBackground(backgroundColor.darker());
        } else {
          this.setBackground(backgroundColor);
        }
      }
    }
    return (this);
  }
Example #17
0
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean isFocused, int row, int col) {

      NLaboImportSummary summary = (NLaboImportSummary) tableModel.getObject(row);

      if (isSelected) {
        this.setBackground(table.getSelectionBackground());
        this.setForeground(table.getSelectionForeground());

      } else {
        if (summary != null && summary.getKarteId() == null) {

          this.setBackground(UNCONSTRAINED_COLOR);

        } else {

          if ((row & (1)) == 0) {
            this.setBackground(EVEN_COLOR);
          } else {
            this.setBackground(ODD_COLOR);
          }
        }

        this.setForeground(table.getForeground());
      }

      if (value != null && value instanceof String) {
        this.setText((String) value);
      } else {
        this.setText(value == null ? "" : value.toString());
      }
      return this;
    }
Example #18
0
 @Override
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
   String str = Objects.toString(value, "");
   if (highlighter.isHighlightableCell(row, column)) {
     setText("<html><u>" + str);
     setForeground(isSelected ? table.getSelectionForeground() : HIGHLIGHT);
     setBackground(isSelected ? table.getSelectionBackground().darker() : table.getBackground());
   } else {
     setText(str);
     setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
     setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
   }
   return this;
 }
Example #19
0
 void greyOutTable() {
   sitesTable.setEnabled(false);
   oldSelectionBackground = sitesTable.getSelectionBackground();
   oldSelectionForeground = sitesTable.getSelectionForeground();
   sitesTable.setSelectionBackground(Color.GRAY);
   sitesTable.setSelectionForeground(Color.DARK_GRAY);
   sitesTable.setForeground(Color.GRAY);
   sitesTable.setBackground(null);
 }
Example #20
0
 protected void setColors(JTable table, int row, boolean isSelected) {
   if (!isSelected) {
     setBackground(rowColors[row % rowColors.length]);
     setForeground(table.getForeground());
   } else {
     setBackground(table.getSelectionBackground());
     setForeground(table.getSelectionForeground());
   }
 }
 private static Component setLabelColors(
     final Component label, final JTable table, final boolean isSelected, final int row) {
   if (label instanceof JComponent) {
     ((JComponent) label).setOpaque(true);
   }
   label.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
   label.setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
   return label;
 }
 /** Return the cell's foreground color. */
 protected Color foregroundColor(
     JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
   if (selected) {
     if (hasFocus && table.isCellEditable(row, column)) {
       return UIManager.getColor("Table.focusCellForeground");
     }
     return table.getSelectionForeground();
   }
   return table.getForeground();
 }
Example #23
0
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   if (isSelected) {
     setForeground(table.getSelectionForeground());
     super.setBackground(table.getSelectionBackground());
   } else {
     setForeground(table.getForeground());
     setBackground(table.getBackground());
   }
   setSelectedItem(value);
   return this;
 }
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   if (isSelected) {
     setForeground(table.getSelectionForeground());
     setBackground(table.getSelectionBackground());
   } else {
     setForeground(table.getForeground());
     setBackground(UIManager.getColor("Button.background"));
   }
   setText((value == null) ? "" : value.toString());
   return this;
 }
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   if (isSelected) {
     setForeground(table.getSelectionForeground());
     setBackground(new Color(230, 230, 250));
   } else {
     setForeground(table.getForeground());
     setBackground(new Color(230, 230, 250));
   }
   setIcon(new ImageIcon("Images\\helfer.jpg"));
   return this;
 }
Example #26
0
 /*
  * (non-Javadoc)
  *
  * @see
  * javax.swing.DefaultCellEditor#getTableCellEditorComponent(javax.swing
  * .JTable, java.lang.Object, boolean, int, int)
  */
 @Override
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   if (isSelected) {
     button.setForeground(table.getSelectionForeground());
     button.setBackground(table.getSelectionBackground());
   } else {
     button.setForeground(table.getForeground());
     button.setBackground(table.getBackground());
   }
   return button;
 }
 @Override
 protected void fillPage(
     Page page,
     JTable table,
     Object value,
     boolean isSelected,
     boolean hasFocus,
     int row,
     int column) {
   Color foreground = isSelected ? table.getSelectionForeground() : table.getForeground();
   Color background = isSelected ? table.getSelectionBackground() : table.getBackground();
   renderCellValue(page, value, foreground, background, isSelected);
 }
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      if (value != null) setIcon((Icon) value);

      if (isSelected) {
        setBackground(table.getSelectionBackground());
        setForeground(table.getSelectionForeground());
      } else {
        setBackground(table.getBackground());
        setForeground(table.getForeground());
      }

      return this;
    }
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   if (isSelected) {
     button.setForeground(table.getSelectionForeground());
     button.setBackground(table.getSelectionBackground());
   } else {
     button.setForeground(table.getForeground());
     button.setBackground(table.getBackground());
   }
   label = "Delete";
   eaInt_SeletedRow = row;
   isPushed = true;
   return button;
 }
Example #30
0
 @Override
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   if (isSelected) {
     setForeground(table.getSelectionForeground());
     setBackground(table.getSelectionBackground());
   } else {
     setForeground(table.getForeground());
     setBackground(table.getBackground());
   }
   setFont(table.getFont());
   setText(Objects.toString(value, ""));
   return this;
 }