~ubuntu-branches/debian/stretch/insubstantial/stretch

« back to all changes in this revision

Viewing changes to substance/src/main/java/org/pushingpixels/substance/internal/contrib/randelshofer/quaqua/colorchooser/QuaquaColorPreviewPanel.java

  • Committer: Package Import Robot
  • Author(s): Felix Natter
  • Date: 2016-01-18 20:58:45 UTC
  • Revision ID: package-import@ubuntu.com-20160118205845-crbmrkda61qsi5qa
Tags: upstream-7.3+dfsg2
ImportĀ upstreamĀ versionĀ 7.3+dfsg2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * @(#)QuaquaColorPreviewPanel.java  1.2  2005-12-18
 
3
 *
 
4
 * Copyright (c) 2005 Werner Randelshofer
 
5
 * Staldenmattweg 2, Immensee, CH-6405, Switzerland.
 
6
 * All rights reserved.
 
7
 *
 
8
 * This software is the confidential and proprietary information of
 
9
 * Werner Randelshofer. ("Confidential Information").  You shall not
 
10
 * disclose such Confidential Information and shall use it only in
 
11
 * accordance with the terms of the license agreement you entered into
 
12
 * with Werner Randelshofer.
 
13
 */
 
14
 
 
15
package org.pushingpixels.substance.internal.contrib.randelshofer.quaqua.colorchooser;
 
16
 
 
17
import java.awt.*;
 
18
import java.awt.event.*;
 
19
import javax.swing.*;
 
20
import javax.swing.plaf.*;
 
21
 
 
22
import org.pushingpixels.substance.internal.contrib.randelshofer.quaqua.*;
 
23
 
 
24
/**
 
25
 * QuaquaColorPreviewPanel.
 
26
 *
 
27
 * @author  Werner Randelshofer
 
28
 * @version 1.2 2005-12-18 Tweaked insets.
 
29
 * <br>1.1 2005-09-20 Added tooltip. This is not what the native 
 
30
 * NSColorPicker does, but it is very useful.
 
31
 * <br>1.0  30 March 2005  Created.
 
32
 */
 
33
public class QuaquaColorPreviewPanel extends JPanel implements UIResource {
 
34
    private final static Color previewBorderColor = new Color(0x949494);
 
35
    private final static Color previewBackgroundColor = new Color(0xffffff);
 
36
    /** Creates new form. */
 
37
    public QuaquaColorPreviewPanel() {
 
38
        initComponents();
 
39
        setBorder(new VisualMargin(3,0,3,0));
 
40
        setToolTipText("on"); // set dummy text, to switch tooltip on
 
41
    }
 
42
    
 
43
    @Override
 
44
    public void paintComponent(Graphics g) {
 
45
        Insets insets = getInsets();
 
46
        int x = insets.left;
 
47
        int y = insets.top;
 
48
        int w = getWidth() - insets.left - insets.right;
 
49
        int h = getHeight() - insets.top - insets.bottom;
 
50
        g.setColor(previewBackgroundColor);
 
51
        g.fillRect(x+1,y+1,w-2,h-2);
 
52
        g.setColor(previewBorderColor);
 
53
        g.drawRect(x,y,w-1,h-1);
 
54
        g.setColor(getForeground());
 
55
        g.fillRect(x+2,y+2,w-4,h-4);
 
56
    }
 
57
    
 
58
    @Override
 
59
    public String getToolTipText(MouseEvent evt) {
 
60
        Color color = getForeground();
 
61
        return (color == null) ? null : color.getRed()+", "+ color.getGreen() + ", " + color.getBlue();
 
62
    }
 
63
    
 
64
    /** This method is called from within the constructor to
 
65
     * initialize the form.
 
66
     * WARNING: Do NOT modify this code. The content of this method is
 
67
     * always regenerated by the Form Editor.
 
68
     */
 
69
    private void initComponents() {//GEN-BEGIN:initComponents
 
70
 
 
71
        setLayout(new java.awt.BorderLayout());
 
72
 
 
73
        setPreferredSize(new java.awt.Dimension(26, 26));
 
74
    }//GEN-END:initComponents
 
75
    
 
76
    
 
77
    // Variables declaration - do not modify//GEN-BEGIN:variables
 
78
    // End of variables declaration//GEN-END:variables
 
79
    
 
80
}