~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/RGBColorSliderModel.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
 * @(#)RGBColorSliderModel.java  1.0  May 22, 2005
 
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 javax.swing.*;
 
18
/**
 
19
 * A ColorSliderModel for RGB color components (red, green, blue).
 
20
 *
 
21
 * @author  Werner Randelshofer
 
22
 * @version 1.0 May 22, 2005 Created.
 
23
 */
 
24
public class RGBColorSliderModel extends ColorSliderModel {
 
25
    /**
 
26
     * Creates a new instance.
 
27
     */
 
28
    public RGBColorSliderModel() {
 
29
        super(new DefaultBoundedRangeModel[] {
 
30
            new DefaultBoundedRangeModel(255, 0, 0, 255),
 
31
            new DefaultBoundedRangeModel(255, 0, 0, 255),
 
32
            new DefaultBoundedRangeModel(255, 0, 0, 255)
 
33
        });
 
34
    }
 
35
    
 
36
    @Override
 
37
    public int getRGB() {
 
38
        return getRGB(components[0].getValue(), components[1].getValue(), components[2].getValue());
 
39
    }
 
40
    
 
41
    protected int getRGB(int r, int g, int b) {
 
42
        return 0xff000000 | r << 16 | g << 8 | b;
 
43
    }
 
44
    
 
45
    @Override
 
46
    public void setRGB(int rgb) {
 
47
        components[0].setValue((rgb & 0xff0000) >> 16);
 
48
        components[1].setValue((rgb & 0x00ff00) >> 8);
 
49
        components[2].setValue( rgb & 0x0000ff);
 
50
    }
 
51
    
 
52
    @Override
 
53
    public int toRGB(int[] values) {
 
54
        return 0xff000000 | values[0] << 16 | values[1] << 8 | values[2];
 
55
    }
 
56
    
 
57
}