Java Code Examples for com.sun.swingset3.utilities.Utilities#deriveColorHSB()

The following examples show how to use com.sun.swingset3.utilities.Utilities#deriveColorHSB() . 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: DemoPanel.java    From littleluck with Apache License 2.0 6 votes vote down vote up
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g.create();
    Dimension size = getSize();

    Color textColor = Utilities.deriveColorHSB(getBackground(), 0, 0, -.3f);
    Color dotColor = Utilities.deriveColorHSB(textColor, 0, .2f, -.08f);
    g2.setColor(textColor);
    g2.setFont(UIManager.getFont("Label.font").deriveFont(32f));
    FontMetrics metrics = g2.getFontMetrics();
    Rectangle2D rect = metrics.getStringBounds(message, g2);
    Rectangle2D dotRect = metrics.getStringBounds(".", g2);
    float x = (float) (size.width - (rect.getWidth() + 3 * dotRect.getWidth())) / 2;
    float y = (float) (size.height - rect.getHeight()) / 2;
    g2.drawString(message, x, y);
    int tri = getTriState();
    float dx = 0;
    for (int i = 0; i < 3; i++) {
        g2.setColor(animator.isRunning() && i == tri ?
                dotColor :
                textColor);
        g2.drawString(".", x + (float) (rect.getWidth() + dx), y);
        dx += dotRect.getWidth();
    }
}
 
Example 2
Source File: DemoPanel.java    From littleluck with Apache License 2.0 6 votes vote down vote up
private void applyDefaults() {
    setBorder(new RoundedTitleBorder(demoName,
            UIManager.getColor(SwingSet3.TITLE_GRADIENT_COLOR1_KEY),
            UIManager.getColor(SwingSet3.TITLE_GRADIENT_COLOR2_KEY)));

    setFont(UIManager.getFont(SwingSet3.TITLE_FONT_KEY));
    Color bg = Utilities.deriveColorHSB(
            UIManager.getColor("Panel.background"), 0, 0, -.06f);
    setBackground(bg);
    setForeground(UIManager.getColor(SwingSet3.TITLE_FOREGROUND_KEY));
    if (demoPanel != null) {
        demoPanel.setBackground(Utilities.deriveColorHSB(bg, 0, 0, .04f));
    }
    if (descriptionArea != null) {
        descriptionArea.setBackground(bg);
    }
}
 
Example 3
Source File: CodeViewer.java    From littleluck with Apache License 2.0 6 votes vote down vote up
public Component getListCellRendererComponent(JList list,
        Object value,
        int index,
        boolean isSelected,
        boolean cellHasFocus) {
    
    JLabel renderer = (JLabel)((ListCellRenderer)delegate).getListCellRendererComponent(list,
            value, index, isSelected, cellHasFocus);
    
    int count = snippetMap.getSnippetCountForSet((String)value);
    
    Color foreground = renderer.getForeground();
    Color countForeground = Utilities.deriveColorHSB(foreground, 
            0, 0, isSelected? .5f : .4f);
    
    String text = "<html><font color=\"" +
            Utilities.getHTMLColorString(foreground) + "\">" + value + 
            "</font>" +
            "<font color=\"" +
            Utilities.getHTMLColorString(countForeground) + "\">" +
            (count > 0? " (" + count + (count > 1? " snippets)" : " snippet)") : "") +
            "</font></html>";

    renderer.setText(text);
    return renderer;
}
 
Example 4
Source File: DemoPanel.java    From beautyeye with Apache License 2.0 6 votes vote down vote up
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g.create();
    Dimension size = getSize();

    Color textColor = Utilities.deriveColorHSB(getBackground(), 0, 0, -.3f);
    Color dotColor = Utilities.deriveColorHSB(textColor, 0, .2f, -.08f);
    g2.setColor(textColor);
    g2.setFont(UIManager.getFont("Label.font").deriveFont(32f));
    FontMetrics metrics = g2.getFontMetrics();
    Rectangle2D rect = metrics.getStringBounds(message, g2);
    Rectangle2D dotRect = metrics.getStringBounds(".", g2);
    float x = (float) (size.width - (rect.getWidth() + 3 * dotRect.getWidth())) / 2;
    float y = (float) (size.height - rect.getHeight()) / 2;
    g2.drawString(message, x, y);
    int tri = getTriState();
    float dx = 0;
    for (int i = 0; i < 3; i++) {
        g2.setColor(animator.isRunning() && i == tri ?
                dotColor :
                textColor);
        g2.drawString(".", x + (float) (rect.getWidth() + dx), y);
        dx += dotRect.getWidth();
    }
}
 
Example 5
Source File: DemoPanel.java    From beautyeye with Apache License 2.0 6 votes vote down vote up
private void applyDefaults() {
    setBorder(new RoundedTitleBorder(demoName,
            UIManager.getColor(SwingSet3.TITLE_GRADIENT_COLOR1_KEY),
            UIManager.getColor(SwingSet3.TITLE_GRADIENT_COLOR2_KEY)));

    setFont(UIManager.getFont(SwingSet3.TITLE_FONT_KEY));
    Color bg = Utilities.deriveColorHSB(
            UIManager.getColor("Panel.background"), 0, 0, -.06f);
    setBackground(bg);
    setForeground(UIManager.getColor(SwingSet3.TITLE_FOREGROUND_KEY));
    if (demoPanel != null) {
        demoPanel.setBackground(Utilities.deriveColorHSB(bg, 0, 0, .04f));
    }
    if (descriptionArea != null) {
        descriptionArea.setBackground(bg);
    }
}
 
Example 6
Source File: CodeViewer.java    From beautyeye with Apache License 2.0 6 votes vote down vote up
public Component getListCellRendererComponent(JList list,
        Object value,
        int index,
        boolean isSelected,
        boolean cellHasFocus) {
    
    JLabel renderer = (JLabel)((ListCellRenderer)delegate).getListCellRendererComponent(list,
            value, index, isSelected, cellHasFocus);
    
    int count = snippetMap.getSnippetCountForSet((String)value);
    
    Color foreground = renderer.getForeground();
    Color countForeground = Utilities.deriveColorHSB(foreground, 
            0, 0, isSelected? .5f : .4f);
    
    String text = "<html><font color=\"" +
            Utilities.getHTMLColorString(foreground) + "\">" + value + 
            "</font>" +
            "<font color=\"" +
            Utilities.getHTMLColorString(countForeground) + "\">" +
            (count > 0? " (" + count + (count > 1? " snippets)" : " snippet)") : "") +
            "</font></html>";

    renderer.setText(text);
    return renderer;
}
 
Example 7
Source File: CodeViewer.java    From Darcula with Apache License 2.0 6 votes vote down vote up
public Component getListCellRendererComponent(JList list,
        Object value,
        int index,
        boolean isSelected,
        boolean cellHasFocus) {
    
    JLabel renderer = (JLabel)((ListCellRenderer)delegate).getListCellRendererComponent(list,
            value, index, isSelected, cellHasFocus);
    
    int count = snippetMap.getSnippetCountForSet((String)value);
    
    Color foreground = renderer.getForeground();
    Color countForeground = Utilities.deriveColorHSB(foreground, 
            0, 0, isSelected? .5f : .4f);
    
    String text = "<html><font color=\"" +
            Utilities.getHTMLColorString(foreground) + "\">" + value + 
            "</font>" +
            "<font color=\"" +
            Utilities.getHTMLColorString(countForeground) + "\">" +
            (count > 0? " (" + count + (count > 1? " snippets)" : " snippet)") : "") +
            "</font></html>";

    renderer.setText(text);
    return renderer;
}