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


Java SimpleTextAttributes.derive方法代碼示例

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


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

示例1: getPlainAttributes

import com.intellij.ui.SimpleTextAttributes; //導入方法依賴的package包/類
@Override
protected SimpleTextAttributes getPlainAttributes() {
  SimpleTextAttributes original = super.getPlainAttributes();

  int style = original.getStyle();
  Color color = original.getFgColor();
  boolean custom = false;

  if ("test".equals(myGoal) && MavenRunner.getInstance(myProject).getSettings().isSkipTests()) {
    color = SimpleTextAttributes.GRAYED_ATTRIBUTES.getFgColor();
    style |= SimpleTextAttributes.STYLE_STRIKEOUT;
    custom = true;
  }
  if (myGoal.equals(myMavenProject.getDefaultGoal())) {
    style |= SimpleTextAttributes.STYLE_BOLD;
    custom = true;
  }
  if (custom) return original.derive(style, color, null, null);
  return original;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:MavenProjectsStructure.java

示例2: customizeCellRenderer

import com.intellij.ui.SimpleTextAttributes; //導入方法依賴的package包/類
@Override
public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
  if (value instanceof MasterDetailsComponent.MyNode) {
    final MasterDetailsComponent.MyNode node = (MasterDetailsComponent.MyNode)value;

    final NamedConfigurable namedConfigurable = node.getConfigurable();
    if (namedConfigurable == null) {
      return;
    }

    final String displayName = node.getDisplayName();
    final Icon icon = namedConfigurable.getIcon(expanded);
    setIcon(icon);
    setToolTipText(null);
    setFont(UIUtil.getTreeFont());

    SimpleTextAttributes textAttributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
    if (node.isDisplayInBold()) {
      textAttributes = SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
    }
    else if (namedConfigurable instanceof ProjectStructureElementConfigurable) {
      final ProjectStructureElement projectStructureElement =
        ((ProjectStructureElementConfigurable)namedConfigurable).getProjectStructureElement();
      if (projectStructureElement != null) {
        final ProjectStructureDaemonAnalyzer daemonAnalyzer = myContext.getDaemonAnalyzer();
        final ProjectStructureProblemsHolderImpl problemsHolder = daemonAnalyzer.getProblemsHolder(projectStructureElement);
        if (problemsHolder != null && problemsHolder.containsProblems()) {
          final boolean isUnused = problemsHolder.containsProblems(ProjectStructureProblemType.Severity.UNUSED);
          final boolean haveWarnings = problemsHolder.containsProblems(ProjectStructureProblemType.Severity.WARNING);
          final boolean haveErrors = problemsHolder.containsProblems(ProjectStructureProblemType.Severity.ERROR);
          Color foreground = isUnused ? UIUtil.getInactiveTextColor() : null;
          final int style = haveWarnings || haveErrors ? SimpleTextAttributes.STYLE_WAVED : -1;
          final Color waveColor = haveErrors ? JBColor.RED : haveWarnings ? JBColor.GRAY : null;
          textAttributes = textAttributes.derive(style, foreground, null, waveColor);
          setToolTipText(problemsHolder.composeTooltipMessage());
        }

        append(displayName, textAttributes);
        String description = projectStructureElement.getDescription();
        if (description != null) {
          append(" (" + description + ")", SimpleTextAttributes.GRAY_ATTRIBUTES, false);
        }
        return;
      }
    }
    append(displayName, textAttributes);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:49,代碼來源:ProjectStructureElementRenderer.java

示例3: derive

import com.intellij.ui.SimpleTextAttributes; //導入方法依賴的package包/類
public SimpleTextAttributes derive(final SimpleTextAttributes attributes) {
  return attributes.derive(myFontStyle, attributes.getFgColor(), attributes.getBgColor(), attributes.getWaveColor());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:4,代碼來源:ChangeNodeDecorator.java

示例4: maybeGrayOut

import com.intellij.ui.SimpleTextAttributes; //導入方法依賴的package包/類
private SimpleTextAttributes maybeGrayOut(SimpleTextAttributes attr, boolean greyOut) {
  return greyOut ? attr.derive(attr.getStyle(), Color.gray, attr.getBgColor(), attr.getWaveColor()) : attr;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:4,代碼來源:FocusDebugger.java

示例5: textComponentSpanningWholeRow

import com.intellij.ui.SimpleTextAttributes; //導入方法依賴的package包/類
@NotNull
private static Component textComponentSpanningWholeRow(@NotNull SimpleColoredComponent chunks,
                                                       Color panelBackground,
                                                       Color panelForeground,
                                                       final int column,
                                                       @NotNull final JTable table, int row) {
  final SimpleColoredComponent component = new SimpleColoredComponent() {
    @Override
    protected void doPaint(Graphics2D g) {
      int offset = 0;
      int i = 0;
      final TableColumnModel columnModel = table.getColumnModel();
      while (i < column) {
        offset += columnModel.getColumn(i).getWidth();
        i++;
      }
      g.translate(-offset, 0);

      //if (column == columnModel.getColumnCount()-1) {
      //}
      setSize(getWidth()+offset, getHeight()); // should increase the column width so that selection background will be visible even after offset translation

      super.doPaint(g);

      g.translate(+offset, 0);
    }

    @NotNull
    @Override
    public Dimension getPreferredSize() {
      //return super.getPreferredSize();
      return column == table.getColumnModel().getColumnCount()-1 ? super.getPreferredSize() : new Dimension(0,0);
      // it should span the whole row, so we can't return any specific value here,
      // because otherwise it would be used in the "max width" calculation in com.intellij.find.actions.ShowUsagesAction.calcMaxWidth
    }
  };

  component.setIpad(new Insets(0,0,0,0));
  component.setBorder(null);
  component.setBackground(panelBackground);
  component.setForeground(panelForeground);

  for (SimpleColoredComponent.ColoredIterator iterator = chunks.iterator(); iterator.hasNext(); ) {
    iterator.next();
    String fragment = iterator.getFragment();
    SimpleTextAttributes attributes = iterator.getTextAttributes();
    attributes = attributes.derive(attributes.getStyle(), panelForeground, panelBackground, attributes.getWaveColor());
    component.append(fragment, attributes);
  }

  return component;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:53,代碼來源:ShowUsagesTableCellRenderer.java

示例6: deriveAttributesWithColor

import com.intellij.ui.SimpleTextAttributes; //導入方法依賴的package包/類
private static SimpleTextAttributes deriveAttributesWithColor(SimpleTextAttributes attributes, Color fileBgColor) {
  if (fileBgColor != null) {
    attributes = attributes.derive(-1,null, fileBgColor,null);
  }
  return attributes;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:7,代碼來源:ShowUsagesTableCellRenderer.java


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