Java Code Examples for com.intellij.util.ui.UIUtil#getLabelFont()
The following examples show how to use
com.intellij.util.ui.UIUtil#getLabelFont() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DesktopAlertImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull public JTextPane configureMessagePaneUi(@Nonnull JTextPane messageComponent, @Nullable String message, @Nullable UIUtil.FontSize fontSize) { UIUtil.FontSize fixedFontSize = fontSize == null ? UIUtil.FontSize.NORMAL : fontSize; messageComponent.setFont(UIUtil.getLabelFont(fixedFontSize)); if (BasicHTML.isHTMLString(message)) { HTMLEditorKit editorKit = new HTMLEditorKit(); Font font = UIUtil.getLabelFont(fixedFontSize); editorKit.getStyleSheet().addRule(UIUtil.displayPropertiesToCSS(font, UIUtil.getLabelForeground())); messageComponent.setEditorKit(editorKit); messageComponent.setContentType(UIUtil.HTML_MIME); } messageComponent.setText(message); messageComponent.setEditable(false); if (messageComponent.getCaret() != null) { messageComponent.setCaretPosition(0); } messageComponent.setBackground(UIUtil.getOptionPaneBackground()); messageComponent.setForeground(UIUtil.getLabelForeground()); return messageComponent; }
Example 2
Source File: HorizontalLabeledIcon.java From consulo with Apache License 2.0 | 6 votes |
private int getTextWidth() { if (myStrings != null) { int width = 0; Font font = UIUtil.getLabelFont(); FontMetrics fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics(font); for (int i = 0; i < myStrings.length; i++) { String string = myStrings[i]; if (myMnemonic != null && i == myStrings.length-1) { string += " "+myMnemonic; } width = Math.max(width, fontMetrics.stringWidth(string)); } return width; } else { return 0; } }
Example 3
Source File: PluginsTableRenderer.java From consulo with Apache License 2.0 | 6 votes |
public PluginsTableRenderer(PluginDescriptor pluginDescriptor, boolean availableRender) { myPluginDescriptor = pluginDescriptor; final Font smallFont; if (SystemInfo.isMac) { smallFont = UIUtil.getLabelFont(UIUtil.FontSize.MINI); } else { smallFont = UIUtil.getLabelFont().deriveFont(Math.max(UISettings.getInstance().getFontSize() - JBUI.scale(3), JBUI.scaleFontSize(10))); } myName.setFont(UIUtil.getLabelFont().deriveFont(UISettings.getInstance().getFontSize())); myStatus.setFont(smallFont); myCategory.setFont(smallFont); myDownloads.setFont(smallFont); myStatus.setText(""); myCategory.setText(""); myLastUpdated.setFont(smallFont); if (!availableRender || !(pluginDescriptor instanceof PluginNode)) { myPanel.remove(myRightPanel); } myPanel.setBorder(UIUtil.isJreHiDPI(myPanel) ? JBUI.Borders.empty(4, 3) : JBUI.Borders.empty(2, 3)); }
Example 4
Source File: Messages.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static JTextPane configureMessagePaneUi(@Nonnull JTextPane messageComponent, @Nullable String message, @Nullable UIUtil.FontSize fontSize) { UIUtil.FontSize fixedFontSize = fontSize == null ? UIUtil.FontSize.NORMAL : fontSize; messageComponent.setFont(UIUtil.getLabelFont(fixedFontSize)); if (BasicHTML.isHTMLString(message)) { HTMLEditorKit editorKit = new HTMLEditorKit(); Font font = UIUtil.getLabelFont(fixedFontSize); editorKit.getStyleSheet().addRule(UIUtil.displayPropertiesToCSS(font, UIUtil.getLabelForeground())); messageComponent.setEditorKit(editorKit); messageComponent.setContentType(UIUtil.HTML_MIME); } messageComponent.setText(message); messageComponent.setEditable(false); if (messageComponent.getCaret() != null) { messageComponent.setCaretPosition(0); } if (UIUtil.isUnderNimbusLookAndFeel()) { messageComponent.setOpaque(false); messageComponent.setBackground(UIUtil.TRANSPARENT_COLOR); } else { messageComponent.setBackground(UIUtil.getOptionPaneBackground()); } messageComponent.setForeground(UIUtil.getLabelForeground()); return messageComponent; }
Example 5
Source File: ContentRootPanel.java From consulo with Apache License 2.0 | 5 votes |
protected JComponent createFolderGroupComponent(String title, ContentFolder[] folders, Color foregroundColor, @Nonnull ContentFolderTypeProvider editor) { final JPanel panel = new JPanel(new GridLayoutManager(folders.length, 3, new Insets(1, 17, 0, 2), 0, 1)); panel.setOpaque(false); for (int idx = 0; idx < folders.length; idx++) { final ContentFolder folder = folders[idx]; final int verticalPolicy = idx == folders.length - 1 ? GridConstraints.SIZEPOLICY_CAN_GROW : GridConstraints.SIZEPOLICY_FIXED; panel.add(createFolderComponent(folder, foregroundColor), new GridConstraints(idx, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_CAN_SHRINK, verticalPolicy, null, null, null)); panel.add(createFolderChangeOptionsComponent(folder, editor), new GridConstraints(idx, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, verticalPolicy, null, null, null)); panel.add(createFolderDeleteComponent(folder, editor), new GridConstraints(idx, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, verticalPolicy, null, null, null)); } final JLabel titleLabel = new JLabel(title); final Font labelFont = UIUtil.getLabelFont(); titleLabel.setFont(labelFont.deriveFont(Font.BOLD)); titleLabel.setOpaque(false); titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0)); registerTextComponent(titleLabel, foregroundColor); final JPanel groupPanel = new JPanel(new BorderLayout()); groupPanel.setOpaque(false); groupPanel.add(titleLabel, BorderLayout.NORTH); groupPanel.add(panel, BorderLayout.CENTER); return groupPanel; }
Example 6
Source File: LibraryTreeRenderer.java From consulo with Apache License 2.0 | 5 votes |
@Override public Font getFont() { Font font = super.getFont(); if (font == null) { font = UIUtil.getLabelFont(); } return font; }
Example 7
Source File: HorizontalLabeledIcon.java From consulo with Apache License 2.0 | 5 votes |
private int getTextHeight() { if (myStrings != null) { Font font = UIUtil.getLabelFont(); FontMetrics fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics(font); return fontMetrics.getHeight() * myStrings.length; } else { return 0; } }
Example 8
Source File: HorizontalLabeledIcon.java From consulo with Apache License 2.0 | 5 votes |
public void paintIcon(Component c, Graphics g, int x, int y) { // Draw icon int height = getIconHeight(); int iconHeight = myIcon.getIconHeight(); if (height > iconHeight) { myIcon.paintIcon(c, g, x, y + (height - iconHeight) / 2); } else { myIcon.paintIcon(c, g, x, y); } // Draw text if (myStrings != null) { Font font = UIUtil.getLabelFont(); FontMetrics fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics(font); g.setFont(fontMetrics.getFont()); g.setColor(UIUtil.getLabelForeground()); x += myIcon.getIconWidth() + 5; y += (height - getTextHeight()) / 2 + fontMetrics.getHeight() - fontMetrics.getDescent(); for (int i = 0; i < myStrings.length; i++) { String string = myStrings[i]; g.drawString(string, x, y); y += fontMetrics.getHeight(); } if (myMnemonic != null) { g.setColor(UIUtil.getInactiveTextColor()); int offset = fontMetrics.stringWidth(myStrings[myStrings.length-1]+" "); y -= fontMetrics.getHeight(); g.drawString(myMnemonic, x + offset, y); } } }
Example 9
Source File: DesktopStripeButton.java From consulo with Apache License 2.0 | 5 votes |
@Override public void updateUI() { setUI(DesktopStripeButtonUI.createUI(this)); Font font = UIUtil.getLabelFont(UIUtil.FontSize.SMALL); setFont(font); // update text if localize was changed updateText(); }
Example 10
Source File: ParameterInfoComponent.java From consulo with Apache License 2.0 | 5 votes |
ParameterInfoComponent(Object[] objects, Editor editor, @Nonnull ParameterInfoHandler handler, boolean requestFocus, boolean allowSwitchLabel) { super(new BorderLayout()); myRequestFocus = requestFocus; if (!ApplicationManager.getApplication().isUnitTestMode() && !ApplicationManager.getApplication().isHeadlessEnvironment()) { JComponent editorComponent = editor.getComponent(); JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane(); myWidthLimit = layeredPane.getWidth(); } NORMAL_FONT = editor != null && Registry.is("parameter.info.editor.font") ? editor.getColorsScheme().getFont(EditorFontType.PLAIN) : UIUtil.getLabelFont(); BOLD_FONT = editor != null && Registry.is("parameter.info.editor.font") ? editor.getColorsScheme().getFont(EditorFontType.BOLD) : NORMAL_FONT.deriveFont(Font.BOLD); myObjects = objects; setBackground(BACKGROUND); myHandler = handler; myMainPanel = new JPanel(new GridBagLayout()); setPanels(); if (myRequestFocus) { AccessibleContextUtil.setName(this, "Parameter Info. Press TAB to navigate through each element. Press ESC to close."); } final JScrollPane pane = ScrollPaneFactory.createScrollPane(myMainPanel, true); add(pane, BorderLayout.CENTER); myAllowSwitchLabel = allowSwitchLabel && !(editor instanceof EditorWindow); setShortcutLabel(); myCurrentParameterIndex = -1; }
Example 11
Source File: mxUtils.java From consulo with Apache License 2.0 | 4 votes |
/** * */ public static Font getFont(Map<String, Object> style) { return UIUtil.getLabelFont(); }
Example 12
Source File: MultiIconSimpleColoredComponent.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
@NotNull private Font getBaseFont() { Font font = getFont(); if (font == null) font = UIUtil.getLabelFont(); return font; }
Example 13
Source File: AbstractNavBarUI.java From consulo with Apache License 2.0 | 4 votes |
@Override public Font getElementFont(NavBarItem navBarItem) { Font font = UIUtil.getLabelFont(); return UISettings.getInstance().getUseSmallLabelsOnTabs() ? SMALL.derive(font) : font; }
Example 14
Source File: FontUtil.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull public static String getHtmlWithFonts(@Nonnull String input) { Font font = UIUtil.getLabelFont(); return getHtmlWithFonts(input, font.getStyle(), font); }
Example 15
Source File: PluginManagerColumnInfo.java From consulo with Apache License 2.0 | 4 votes |
protected static Font getNameFont() { return UIUtil.getLabelFont(); }
Example 16
Source File: RectanglePainter.java From consulo with Apache License 2.0 | 4 votes |
public static Font getFont() { return UIUtil.getLabelFont(); }
Example 17
Source File: SimpleColoredComponent.java From consulo with Apache License 2.0 | 4 votes |
/** * Returns the index of text fragment at the specified X offset. * * @param x the offset * @return the index of the fragment, {@link #FRAGMENT_ICON} if the icon is at the offset, or -1 if nothing is there. */ public int findFragmentAt(int x) { int curX = myIpad.left; if (myIcon != null && !myIconOnTheRight) { final int iconRight = myIcon.getIconWidth() + myIconTextGap; if (x < iconRight) { return FRAGMENT_ICON; } curX += iconRight; } Font font = getFont(); if (font == null) { font = UIUtil.getLabelFont(); } int baseSize = font.getSize(); boolean wasSmaller = false; for (int i = 0; i < myAttributes.size(); i++) { SimpleTextAttributes attributes = myAttributes.get(i); boolean isSmaller = attributes.isSmaller(); if (font.getStyle() != attributes.getFontStyle() || isSmaller != wasSmaller) { // derive font only if it is necessary font = font.deriveFont(attributes.getFontStyle(), isSmaller ? UIUtil.getFontSize(UIUtil.FontSize.SMALL) : baseSize); } wasSmaller = isSmaller; final int curWidth = computeStringWidth(myFragments.get(i), font); if (x >= curX && x < curX + curWidth) { return i; } curX += curWidth; final int fragmentPadding = myFragmentPadding.get(i); if (fragmentPadding > 0 && curX < fragmentPadding) { curX = fragmentPadding; } } if (myIcon != null && myIconOnTheRight) { curX += myIconTextGap; if (x >= curX && x < curX + myIcon.getIconWidth()) { return FRAGMENT_ICON; } } return -1; }
Example 18
Source File: SimpleColoredComponent.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull public final synchronized Dimension computePreferredSize(final boolean mainTextOnly) { // Calculate width int width = myIpad.left; if (myIcon != null) { width += myIcon.getIconWidth() + myIconTextGap; } final Insets borderInsets = myBorder != null ? myBorder.getBorderInsets(this) : new Insets(0, 0, 0, 0); width += borderInsets.left; Font font = getFont(); if (font == null) { font = UIUtil.getLabelFont(); } LOG.assertTrue(font != null); width += computeTextWidth(font, mainTextOnly); width += myIpad.right + borderInsets.right; // Calculate height int height = myIpad.top + myIpad.bottom; final FontMetrics metrics = getFontMetrics(font); int textHeight = metrics.getHeight(); textHeight += borderInsets.top + borderInsets.bottom; if (myIcon != null) { height += Math.max(myIcon.getIconHeight(), textHeight); } else { height += textHeight; } // Take into account that the component itself can have a border final Insets insets = getInsets(); if (insets != null) { width += insets.left + insets.right; height += insets.top + insets.bottom; } return new Dimension(width, height); }
Example 19
Source File: TabLabel.java From consulo with Apache License 2.0 | 4 votes |
private SimpleColoredComponent createLabel(final JBTabsImpl tabs) { SimpleColoredComponent label = new SimpleColoredComponent() { @Override protected boolean shouldDrawMacShadow() { return SystemInfo.isMac || UIUtil.isUnderDarcula(); } @Override protected boolean shouldDrawDimmed() { return myTabs.getSelectedInfo() != myInfo || myTabs.useBoldLabels(); } @Override public Font getFont() { if (isFontSet() || !myTabs.useSmallLabels()) { return super.getFont(); } return UIUtil.getLabelFont(UIUtil.FontSize.SMALL); } @Override protected void doPaint(Graphics2D g) { if (UISettings.getInstance().HIDE_TABS_IF_NEED || tabs.getTabsPosition() == JBTabsPosition.left || tabs.getTabsPosition() == JBTabsPosition.right) { super.doPaint(g); return; } Rectangle clip = getVisibleRect(); if (getPreferredSize().width <= clip.width) { super.doPaint(g); return; } int dimSize = 30; int dimStep = 2; Composite oldComposite = g.getComposite(); Shape oldClip = g.getClip(); try { g.setClip(clip.x, clip.y, Math.max(0, clip.width - dimSize), clip.height); super.doPaint(g); for (int x = clip.x + clip.width - dimSize; x < clip.x + clip.width; x += dimStep) { g.setClip(x, clip.y, dimStep, clip.height); g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1 - ((float)x - (clip.x + clip.width - dimSize)) / dimSize)); super.doPaint(g); } } finally { g.setComposite(oldComposite); g.setClip(oldClip); } } }; label.setOpaque(false); label.setBorder(null); label.setIconTextGap(tabs.isEditorTabs() ? (!UISettings.getInstance().HIDE_TABS_IF_NEED ? JBUI.scale(4) : JBUI.scale(2)) : new JLabel().getIconTextGap()); label.setIconOpaque(false); label.setIpad(JBUI.emptyInsets()); return label; }
Example 20
Source File: MultiIconSimpleColoredComponent.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
@NotNull private Font getBaseFont() { Font font = getFont(); if (font == null) font = UIUtil.getLabelFont(); return font; }