private JComponent createLogo() { NonOpaquePanel panel = new NonOpaquePanel(new BorderLayout()); ApplicationInfoEx app = ApplicationInfoEx.getInstanceEx(); JLabel logo = new JLabel(IconLoader.getIcon(app.getWelcomeScreenLogoUrl())); logo.setBorder(JBUI.Borders.empty(30, 0, 10, 0)); logo.setHorizontalAlignment(SwingConstants.CENTER); panel.add(logo, BorderLayout.NORTH); JLabel appName = new JLabel(ApplicationNamesInfo.getInstance().getFullProductName()); Font font = getProductFont(); appName.setForeground(JBColor.foreground()); appName.setFont(font.deriveFont(JBUI.scale(36f)).deriveFont(Font.PLAIN)); appName.setHorizontalAlignment(SwingConstants.CENTER); String appVersion = "Version " + app.getFullVersion(); if (app.isEAP() && app.getBuild().getBuildNumber() < Integer.MAX_VALUE) { appVersion += " (" + app.getBuild().asString() + ")"; } JLabel version = new JLabel(appVersion); version.setFont(getProductFont().deriveFont(JBUI.scale(16f))); version.setHorizontalAlignment(SwingConstants.CENTER); version.setForeground(Gray._128); panel.add(appName); panel.add(version, BorderLayout.SOUTH); panel.setBorder(JBUI.Borders.emptyBottom(20)); return panel; }
private Font getProductFont() { String name = "/fonts/Roboto-Light.ttf"; URL url = AppUIUtil.class.getResource(name); if (url == null) { Logger.getInstance(AppUIUtil.class).warn("Resource missing: " + name); } else { try { InputStream is = url.openStream(); try { return Font.createFont(Font.TRUETYPE_FONT, is); } finally { is.close(); } } catch (Throwable t) { Logger.getInstance(AppUIUtil.class).warn("Cannot load font: " + url, t); } } return UIUtil.getLabelFont(); }
private void doPaint(Graphics g) { GraphicsUtil.setupAntialiasing(g); final boolean isEmpty = getIcon() == null && StringUtil.isEmpty(getText()); final Dimension size = getSize(); if (isSmallVariant()) { final Graphics2D g2 = (Graphics2D) g; g2.setColor(UIUtil.getControlColor()); final int w = getWidth(); final int h = getHeight(); if (getModel().isArmed() && getModel().isPressed()) { g2.setPaint( new GradientPaint( 0, 0, UIUtil.getControlColor(), 0, h, ColorUtil.shift(UIUtil.getControlColor(), 0.8))); } else { g2.setPaint( new GradientPaint( 0, 0, ColorUtil.shift(UIUtil.getControlColor(), 1.1), 0, h, ColorUtil.shift(UIUtil.getControlColor(), 0.9))); } g2.fillRect(2, 0, w - 2, h); GraphicsUtil.setupAntialiasing(g2); if (!myMouseInside) { g2.setPaint( new GradientPaint( 0, 0, UIUtil.getBorderColor(), 0, h, UIUtil.getBorderColor().darker())); // g2.setColor(UIUtil.getBorderColor()); } else { g2.setPaint( new GradientPaint( 0, 0, UIUtil.getBorderColor().darker(), 0, h, UIUtil.getBorderColor().darker().darker())); } g2.drawRect(2, 0, w - 3, h - 1); final Icon icon = getIcon(); int x = 7; if (icon != null) { icon.paintIcon(null, g, x, (size.height - icon.getIconHeight()) / 2); x += icon.getIconWidth() + 3; } if (!StringUtil.isEmpty(getText())) { final Font font = getFont(); g2.setFont(font); g2.setColor(UIManager.getColor("Panel.foreground")); g2.drawString(getText(), x, (size.height + font.getSize()) / 2 - 1); } } else { super.paintComponent(g); } final Insets insets = super.getInsets(); final Icon icon = isEnabled() ? ARROW_ICON : DISABLED_ARROW_ICON; final int x; if (isEmpty) { x = (size.width - icon.getIconWidth()) / 2; } else { if (isSmallVariant()) { x = size.width - icon.getIconWidth() - insets.right + 1; } else { x = size.width - icon.getIconWidth() - insets.right + (UIUtil.isUnderNimbusLookAndFeel() ? -3 : 2); } } if (UIUtil.isUnderDarcula()) { g.setXORMode(new Color(208, 188, 159)); } icon.paintIcon(null, g, x, (size.height - icon.getIconHeight()) / 2); g.setPaintMode(); }