當前位置: 首頁>>代碼示例>>Java>>正文


Java UIUtil.getDecoratedRowColor方法代碼示例

本文整理匯總了Java中com.intellij.util.ui.UIUtil.getDecoratedRowColor方法的典型用法代碼示例。如果您正苦於以下問題:Java UIUtil.getDecoratedRowColor方法的具體用法?Java UIUtil.getDecoratedRowColor怎麽用?Java UIUtil.getDecoratedRowColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.util.ui.UIUtil的用法示例。


在下文中一共展示了UIUtil.getDecoratedRowColor方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getListCellRendererComponent

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
public Component getListCellRendererComponent(JList list,
                                              Object value,
                                              int index,
                                              boolean isSelected,
                                              boolean cellHasFocus) {
  if (value instanceof RepoPackage) {
    RepoPackage repoPackage = (RepoPackage) value;
    String name = repoPackage.getName();
    if (myCurrentlyInstalling.contains(name)) {
      final String colorCode = UIUtil.isUnderDarcula() ? "589df6" : "0000FF";
      name = "<html><body>" + repoPackage.getName() + " <font color=\"#" + colorCode + "\">(installing)</font></body></html>";
    }
    myNameLabel.setText(name);
    myRepositoryLabel.setText(repoPackage.getRepoUrl());
    Component orig = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    final Color fg = orig.getForeground();
    myNameLabel.setForeground(myInstalledPackages.contains(name) ? PlatformColors.BLUE : fg);
  }
  myRepositoryLabel.setForeground(JBColor.GRAY);

  final Color bg;
  if (isSelected) {
    bg = UIUtil.getListSelectionBackground();
  }
  else {
    bg = index % 2 == 1 ? UIUtil.getListBackground() : UIUtil.getDecoratedRowColor();
  }
  myPanel.setBackground(bg);
  myNameLabel.setBackground(bg);
  myRepositoryLabel.setBackground(bg);
  return myPanel;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:34,代碼來源:ManagePackagesDialog.java

示例2: paintRow

import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
protected void paintRow(final Graphics g,
                        final Rectangle clipBounds,
                        final Insets insets,
                        final Rectangle bounds,
                        final TreePath path,
                        final int row,
                        final boolean isExpanded,
                        final boolean hasBeenExpanded,
                        final boolean isLeaf) {
  final int containerWidth = tree.getParent() instanceof JViewport ? tree.getParent().getWidth() : tree.getWidth();
  final int xOffset = tree.getParent() instanceof JViewport ? ((JViewport)tree.getParent()).getViewPosition().x : 0;

  if (path != null && myWideSelection) {
    boolean selected = tree.isPathSelected(path);
    Graphics2D rowGraphics = (Graphics2D)g.create();
    rowGraphics.setClip(clipBounds);

    final Object sourceList = tree.getClientProperty(SOURCE_LIST_CLIENT_PROPERTY);
    Color background = tree.getBackground();

    if ((row % 2) == 0 && Boolean.TRUE.equals(tree.getClientProperty(STRIPED_CLIENT_PROPERTY))) {
      background = UIUtil.getDecoratedRowColor();
    }

    if (sourceList != null && (Boolean)sourceList) {
      if (selected) {
        if (tree.hasFocus()) {
          LIST_FOCUSED_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height);
        }
        else {
          LIST_SELECTION_BACKGROUND_PAINTER.paintBorder(tree, rowGraphics, xOffset, bounds.y, containerWidth, bounds.height);
        }
      }
      else if (myWideSelectionCondition.value(row)) {
        rowGraphics.setColor(background);
        rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height);
      }
    }
    else {
      if (selected && (UIUtil.isUnderAquaBasedLookAndFeel() || UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF())) {
        Color bg = UIUtil.getTreeSelectionBackground(tree.hasFocus() || Boolean.TRUE.equals(tree.getClientProperty(TREE_TABLE_TREE_KEY)));

        if (myWideSelectionCondition.value(row)) {
          rowGraphics.setColor(bg);
          rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height);
        }
      }
    }

    if (shouldPaintExpandControl(path, row, isExpanded, hasBeenExpanded, isLeaf)) {
      paintExpandControl(rowGraphics, bounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
    }

    super.paintRow(rowGraphics, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
    rowGraphics.dispose();
  }
  else {
    super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:62,代碼來源:WideSelectionTreeUI.java


注:本文中的com.intellij.util.ui.UIUtil.getDecoratedRowColor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。