コード例 #1
0
 /*
  * (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;
 }
コード例 #2
0
 @Override
 public Component getTableCellRendererComponent(
     javax.swing.JTable table,
     Object value,
     boolean isSelected,
     boolean hasFocus,
     int row,
     int column) {
   Component obj =
       super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
   setHorizontalAlignment(SwingConstants.CENTER);
   if (isSelected) {
     obj.setBackground(new Color(200, 200, 218));
   } else {
     obj.setBackground(null);
   }
   PositionStockInfoBean pos = model.getRowBean(row);
   if (column == 0) {
     String is = pos.getIs_ready_close();
     if (is.equals("y")) {
       obj.setBackground(new Color(254, 142, 133));
     } else {
       obj.setForeground(null);
     }
   }
   return obj;
 }
コード例 #3
0
    /**
     * @see
     *     javax.swing.table.DefaultTableCellRenderer#getTableCellRendererComponent(javax.swing.JTable,
     *     java.lang.Object, boolean, boolean, int, int)
     */
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      if (!useTableColors && (isSelected || hasFocus)) {
        SeaGlassLookAndFeel.setSelectedUI(
            (SeaGlassLabelUI) SeaGlassLookAndFeel.getUIOfType(getUI(), SeaGlassLabelUI.class),
            isSelected,
            hasFocus,
            table.isEnabled(),
            false);
      } else {
        SeaGlassLookAndFeel.resetSelectedUI();
      }

      Component comp =
          super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
      // System.out.println("row = " + row + ", opaque = " + isOpaque());
      if (row % 2 == 0) {
        comp.setBackground(alternateColor);
        setBackground(alternateColor);
      } else {
        comp.setBackground(table.getBackground());
        setBackground(table.getBackground());
      }

      setIcon(null);
      Class columnClass = table.getColumnClass(column);

      configureValue(value, columnClass);

      return this;
    }
コード例 #4
0
        public void apply(java.awt.Component c, javax.swing.JTable table, int row, int column) {

          DataColors colors = new DataColors();
          int colorIdx = -1;
          if (project.isColoring()) {
            if ((column == project.getColoringIndex())) {
              MetaDataItem dataitem = (MetaDataItem) getGrid().GetTag(row)[1];
              colorIdx = dataitem.getColoringLevel();

              // if (column == 0) {
              c.setBackground(colors.getColor(colorIdx));
              // } else {
              // c.setForeground(colors.getColor(colorIdx));
              // }
            }
          }
          if (project.getSourceType().type == DataCreatorType.DATA_TYPE_OPCAT_PROJECT) {
            DataAbstractItem item = (DataAbstractItem) getGrid().GetTag(row)[1];
            Role role = (Role) getGrid().GetTag(row)[0];

            colorIdx = item.getColoringLevel(role.getOntology());

            if (colorIdx != -1) {
              if (column == 0) {
                c.setBackground(colors.getColor(colorIdx));
              }
            }
          }
        }
コード例 #5
0
 @Override
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   Component c =
       super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
   if ((Integer) value > 0) c.setBackground(Color.GREEN);
   else c.setBackground(Color.WHITE);
   return this;
 }
コード例 #6
0
 public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
   Component c = super.prepareRenderer(renderer, row, column);
   if (!isRowSelected(row)) {
     c.setBackground(getBackground());
     int modelRow = convertRowIndexToModel(row);
     Integer vacio = (Integer) getModel().getValueAt(modelRow, 5); // 5 = chofer
     if (vacio == null) c.setBackground(new Color(255, 153, 153));
   }
   return c;
 }
コード例 #7
0
ファイル: JValueTable.java プロジェクト: GoldenGnu/jeveassets
  @Override
  public Component prepareRenderer(
      final TableCellRenderer renderer, final int row, final int column) {
    Component component = super.prepareRenderer(renderer, row, column);
    boolean isSelected = isCellSelected(row, column);
    Value value = tableModel.getElementAt(row);
    String columnName =
        (String) this.getTableHeader().getColumnModel().getColumn(column).getHeaderValue();
    Object object = getValueAt(row, column);
    boolean string;
    if (object instanceof String) {
      string = true;
    } else {
      string = false;
    }

    // UGrand Total
    if (value.isGrandTotal()) {
      if (!isSelected) {
        component.setBackground(new Color(230, 230, 230));
      } else {
        component.setBackground(this.getSelectionBackground().darker());
      }
      return component;
    }
    // Best Asset: none
    if (string
        && TabsValues.get().none().equals(value.getBestAssetName())
        && columnName.equals(ValueTableFormat.BEST_ASSET_NAME.getColumnName())) {
      Font font = component.getFont();
      component.setFont(new Font(font.getName(), Font.ITALIC, font.getSize()));
    }
    // Best Module: none
    if (string
        && TabsValues.get().none().equals(value.getBestModuleName())
        && columnName.equals(ValueTableFormat.BEST_MODULE_NAME.getColumnName())) {
      Font font = component.getFont();
      component.setFont(new Font(font.getName(), Font.ITALIC, font.getSize()));
    }
    // Best Ship (Fitted): none
    if (string
        && TabsValues.get().none().equals(value.getBestShipFittedName())
        && columnName.equals(ValueTableFormat.BEST_SHIP_FITTED_NAME.getColumnName())) {
      Font font = component.getFont();
      component.setFont(new Font(font.getName(), Font.ITALIC, font.getSize()));
    }
    // Best Ship: none
    if (string
        && TabsValues.get().none().equals(value.getBestShipName())
        && columnName.equals(ValueTableFormat.BEST_SHIP_NAME.getColumnName())) {
      Font font = component.getFont();
      component.setFont(new Font(font.getName(), Font.ITALIC, font.getSize()));
    }
    return component;
  }
コード例 #8
0
 @Override
 public Component prepareRenderer(TableCellRenderer tcr, int row, int column) {
   Component c = super.prepareRenderer(tcr, row, column);
   if (isRowSelected(row)) {
     c.setForeground(getSelectionForeground());
     c.setBackground(getSelectionBackground());
   } else {
     c.setForeground(getForeground());
     c.setBackground(row % 2 == 0 ? EVEN_COLOR : getBackground());
   }
   return c;
 }
コード例 #9
0
 /** Shades alternate rows in different colors. */
 @Override
 public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
   Component c = super.prepareRenderer(renderer, row, column);
   if (!isCellSelected(row, column)) {
     c.setBackground(colorForRow(row));
     c.setForeground(UIManager.getColor("Table.foreground"));
   } else {
     c.setBackground(UIManager.getColor("Table.selectionBackground"));
     c.setForeground(UIManager.getColor("Table.selectionForeground"));
   }
   return c;
 }
コード例 #10
0
ファイル: FeatureTable.java プロジェクト: AbeelLab/genomeview
    public Component getTableCellRendererComponent(
        JTable tbl, Object v, boolean isSelected, boolean isFocused, int row, int col) {
      this.setForeground(Color.DARK_GRAY);
      Component c = super.getTableCellRendererComponent(tbl, v, isSelected, isFocused, row, col);

      Feature f = (Feature) v;
      setText(FeatureUtils.displayName(f));
      if (tbl.getSelectionModel().isSelectedIndex(row)) {
        c.setBackground(new Color((float) 0.7, (float) 0.7, (float) 1.0));
      } else {
        c.setBackground(Color.white);
      }

      return c;
    }
コード例 #11
0
  private static Pair<Image, Point> createDragImage(
      final Tree tree, final Component c, Point dragOrigin, boolean adjustToPathUnderDragOrigin) {
    if (c instanceof JComponent) {
      ((JComponent) c).setOpaque(true);
    }

    c.setForeground(tree.getForeground());
    c.setBackground(tree.getBackground());
    c.setFont(tree.getFont());
    c.setSize(c.getPreferredSize());
    final BufferedImage image =
        new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = (Graphics2D) image.getGraphics();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
    c.paint(g2);
    g2.dispose();

    Point point = new Point(-image.getWidth(null) / 2, -image.getHeight(null) / 2);

    if (adjustToPathUnderDragOrigin) {
      TreePath path = tree.getPathForLocation(dragOrigin.x, dragOrigin.y);
      if (path != null) {
        Rectangle bounds = tree.getPathBounds(path);
        point = new Point(bounds.x - dragOrigin.x, bounds.y - dragOrigin.y);
      }
    }

    return new Pair<Image, Point>(image, point);
  }
コード例 #12
0
  public Component prepareRenderer(
      final TableCellRenderer renderer, final int rowIndex, final int colIndex) {
    final Component c = super.prepareRenderer(renderer, rowIndex, colIndex);

    if (isCellSelected(rowIndex, colIndex)) {
      c.setBackground(new Color(0xd1, 0xe0, 0xff));
    } else {
      if (rowIndex % 2 != 0) {
        c.setBackground(new Color(0xf0, 0xf5, 0xff));
      } else {
        c.setBackground(getBackground());
      }
    }

    return c;
  }
コード例 #13
0
  public SimpleTextAttributes applyHighlighters(
      @NotNull Component rendererComponent,
      int row,
      int column,
      String text,
      boolean hasFocus,
      final boolean selected) {
    VcsLogHighlighter.VcsCommitStyle style = getStyle(row, column, text, hasFocus, selected);

    assert style.getBackground() != null
        && style.getForeground() != null
        && style.getTextStyle() != null;

    rendererComponent.setBackground(style.getBackground());
    rendererComponent.setForeground(style.getForeground());

    switch (style.getTextStyle()) {
      case BOLD:
        return SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
      case ITALIC:
        return SimpleTextAttributes.REGULAR_ITALIC_ATTRIBUTES;
      default:
    }
    return SimpleTextAttributes.REGULAR_ATTRIBUTES;
  }
コード例 #14
0
ファイル: GeneralRenderer.java プロジェクト: jkulesza/jabref
 @Override
 public Component getTableCellRendererComponent(
     JTable table, Object o, boolean isSelected, boolean hasFocus, int row, int column) {
   if (selBackground == null) {
     return super.getTableCellRendererComponent(table, o, isSelected, hasFocus, row, column);
   } else {
     Component c =
         super.getTableCellRendererComponent(table, o, isSelected, hasFocus, row, column);
     if (isSelected) {
       c.setBackground(selBackground);
     } else {
       c.setBackground(background);
     }
     return c;
   }
 }
コード例 #15
0
ファイル: ResultsPane.java プロジェクト: adrianpike/wwscc
    public Component getTableCellRendererComponent(
        JTable t, Object o, boolean is, boolean hf, int r, int c) {
      Component cell = super.getTableCellRendererComponent(t, o, is, hf, r, c);

      EventResultModel m = (EventResultModel) t.getModel();
      String s = (String) m.getValueAt(r, 1);
      if (s.equals(match)) {
        cell.setFont(bold);
        cell.setBackground(mygray);
      } else {
        cell.setFont(regular);
        cell.setBackground(Color.WHITE);
      }

      return cell;
    }
コード例 #16
0
ファイル: CellColoring.java プロジェクト: ironste78/z-monitor
 /**
  * *****************************************************************************************************
  */
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
   String columnName = new ConvertImpl().removeHtmlTags(table.getModel().getColumnName(col));
   String sub = "";
   String sub2 = "";
   try {
     sub = columnName.substring(0, 9);
     sub2 = columnName.substring(0, 4);
   } catch (Exception e) {
   }
   Component comp =
       super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
   setHorizontalAlignment(SwingConstants.CENTER);
   if (sub.equals("Time (ms)")
       || columnName.equals("GTS")
       || columnName.equals("LQI")
       || columnName.equals("RSSI")
       || columnName.equals("CRC")
       || columnName.equals("Header Length")
       || columnName.equals("Channel")
       || columnName.equals("Code")
       || columnName.equals("Cheksum")
       || sub.equals("MAC Heade")
       || columnName.equals("Type")) comp.setBackground(new Color(194, 223, 255));
   else if (columnName.equals("DispatchID")
       || columnName.equals("Length")
       || sub.equals("Frame con")
       || sub2.equals("Sequ")
       || sub.equals("Destinati")
       || sub2.equals("Sour")
       || sub.equals("Super fra")
       || columnName.equals("FCS")
       || sub2.equals("Dest")
       || columnName.equals("Dest.PAN")
       || sub2.equals("Src.")) comp.setBackground(new Color(240, 239, 239));
   else if (columnName.equals("Dispatch")
       || columnName.equals("Encoding")
       || sub.equals("Next head")
       || columnName.equals("Hop limit")
       || sub2.equals("6LoW")
       || columnName.equals("Context")
       || sub.equals("Traffic c")) comp.setBackground(new Color(204, 251, 93));
   else if (columnName.equals("Payload") || columnName.equals("Frame"))
     comp.setBackground(new Color(255, 200, 0));
   else comp.setBackground(Color.WHITE);
   return comp;
 }
コード例 #17
0
      /*
       * (non-Javadoc)
       *
       * @see javax.swing.table.DefaultTableCellRenderer#
       * getTableCellRendererComponent(javax.swing.JTable,
       * java.lang.Object, boolean, boolean, int, int)
       */
      public Component getTableCellRendererComponent(
          JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        Component comp =
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

        Color bgColor = getTableHeader().getBackground();

        if (isSelected)
          comp.setBackground(
              new Color(bgColor.getRed() - 10, bgColor.getGreen() - 10, bgColor.getBlue() - 10));
        else comp.setBackground(bgColor);

        ((JLabel) comp).setText((value == null) ? "" : value.toString());
        ((JLabel) comp).setBorder(UIManager.getBorder("TableHeader.cellBorder"));

        return comp;
      }
コード例 #18
0
ファイル: UILib.java プロジェクト: iadgov/GRASSMARLIN
 /**
  * Sets the foreground and background color for a component and all components contained within
  * it.
  *
  * @param c the parent component of the component subtree to set
  * @param back the background color to set
  * @param fore the foreground color to set
  */
 public static void setColor(Component c, Color back, Color fore) {
   c.setBackground(back);
   c.setForeground(fore);
   if (c instanceof Container) {
     Container con = (Container) c;
     for (int i = 0; i < con.getComponentCount(); ++i) setColor(con.getComponent(i), back, fore);
   }
 }
コード例 #19
0
ファイル: TitledPanel.java プロジェクト: sjroot/framework
 public Component add(Component comp, int index) {
   if (getComponentCount() < 2) {
     ensureHeaderIsAdded();
     setOpaque(comp, true);
     comp.setBackground(Color.WHITE);
     return super.add(comp, index);
   } else return comp;
 }
コード例 #20
0
 public void setBGColor(Object fieldComponent, Object color) {
   if (fieldComponent instanceof Component) {
     Component comp = (Component) fieldComponent;
     comp.setBackground((Color) color);
   } else {
     Err.error("getBGColor(), got a " + fieldComponent.getClass().getName());
   }
 }
コード例 #21
0
  public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
    Component component = super.prepareRenderer(renderer, row, column);
    Color defaultBackgroundColor = Colors.WHITE.getColor();

    MarginExpandablePanel marginExpandablePanel = (MarginExpandablePanel) component;

    if (marginExpandablePanel.getComponentCount() > 0) {
      Component nestedComponent = marginExpandablePanel.getComponent(0);
      nestedComponent.setForeground(ColorUtils.getContrastingColor(defaultBackgroundColor));
      nestedComponent.setBackground(defaultBackgroundColor);
    }

    component.setForeground(ColorUtils.getContrastingColor(defaultBackgroundColor));
    component.setBackground(defaultBackgroundColor);

    return component;
  }
コード例 #22
0
    public AwtPopupWrapper(Popup popup) {
      myPopup = popup;

      if (SystemInfo.isMac && UIUtil.isUnderAquaLookAndFeel()) {
        final Component c =
            (Component) ReflectionUtil.getField(Popup.class, myPopup, Component.class, "component");
        c.setBackground(UIUtil.getPanelBackground());
      }
    }
コード例 #23
0
 public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) {
   ListCellRenderer renderer = comboBox.getRenderer();
   Component c;
   Dimension d;
   c =
       renderer.getListCellRendererComponent(
           listBox, comboBox.getSelectedItem(), -1, false, false);
   c.setFont(comboBox.getFont());
   if (comboBox.isEnabled()) {
     c.setForeground(comboBox.getForeground());
     c.setBackground(comboBox.getBackground());
   } else {
     c.setForeground(UIManager.getColor("ComboBox.disabledForeground"));
     c.setBackground(UIManager.getColor("ComboBox.disabledBackground"));
   }
   d = c.getPreferredSize();
   currentValuePane.paintComponent(g, c, comboBox, bounds.x, bounds.y, bounds.width, d.height);
 }
コード例 #24
0
 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;
 }
コード例 #25
0
 // Implementation of TableCellRenderer interface
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   TableCellRenderer rend = super.getCellRenderer(row, column);
   Component c =
       rend.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
   c.setBackground(getBack(isSelected, hasFocus, row, column));
   c.setForeground(getFore(isSelected, hasFocus, row, column));
   return c;
 }
コード例 #26
0
ファイル: Util.java プロジェクト: opencadc/apps
 public static void recursiveSetBackground(Component comp, Color color) {
   if (comp instanceof JToolBar || comp instanceof JButton) return;
   comp.setBackground(color);
   if (comp instanceof Container) {
     Container cc = (Container) comp;
     for (int i = 0; i < cc.getComponentCount(); i++)
       recursiveSetBackground(cc.getComponent(i), color);
   }
 }
コード例 #27
0
 @Override
 public void setBackground(Color color) {
   super.setBackground(color);
   for (Component c : this.getComponents()) {
     if (c instanceof DataPanel) {
       c.setBackground(color);
     }
   }
 }
コード例 #28
0
ファイル: MapDemo.java プロジェクト: wenzhucjy/tomcat_source
 @Override
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   Component cell =
       super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
   cell.setBackground(Color.WHITE);
   if (row > 0) {
     Color color = null;
     boolean primary = ((Boolean) table.getValueAt(row, 5)).booleanValue();
     boolean proxy = ((Boolean) table.getValueAt(row, 6)).booleanValue();
     boolean backup = ((Boolean) table.getValueAt(row, 7)).booleanValue();
     if (primary) color = Color.GREEN;
     else if (proxy) color = Color.RED;
     else if (backup) color = Color.BLUE;
     if (color != null) cell.setBackground(color);
   }
   return cell;
 }
コード例 #29
0
 public void run() {
   while (true) {
     synchronized (semaphore) {
       try {
         semaphore.wait();
       } catch (InterruptedException ex) {
       }
     }
     Color origColor = c.getBackground();
     for (int i = 0; i < flashCount; i++) {
       c.setBackground(flashColor);
       try {
         Thread.currentThread().sleep(100);
       } catch (Exception ex) {
       }
       c.setBackground(origColor);
     }
   }
 }
コード例 #30
0
  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

    if (!(value instanceof Component)) return null;

    if (isSelected) ((Component) value).setBackground(new Color(205, 235, 139));

    return (Component) value;
  }