~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/GrayColorSliderModel.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
 * @(#)GrayColorSliderModel.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 a gray color model (brightness).
 
20
 *
 
21
 * @author  Werner Randelshofer
 
22
 * @version 1.0 May 22, 2005 Created.
 
23
 */
 
24
public class GrayColorSliderModel extends ColorSliderModel {
 
25
    
 
26
    /**
 
27
     * Creates a new instance.
 
28
     */
 
29
    public GrayColorSliderModel() {
 
30
        super(new DefaultBoundedRangeModel[] {
 
31
            new DefaultBoundedRangeModel(0, 0, 0, 100)
 
32
        });
 
33
    }
 
34
    
 
35
    @Override
 
36
    public int getRGB() {
 
37
        int br = (int) (components[0].getValue() * 2.55f);
 
38
        return 0xff000000 | (br << 16) | (br << 8) | (br);
 
39
    }
 
40
    
 
41
    @Override
 
42
    public void setRGB(int rgb) {
 
43
        components[0].setValue((int)
 
44
        (
 
45
        (((rgb & 0xff0000) >> 16) + ((rgb & 0x00ff00) >> 8) + (rgb & 0x0000ff))
 
46
        / 3f / 2.55f
 
47
        )
 
48
        );
 
49
    }
 
50
    
 
51
    @Override
 
52
    public int toRGB(int[] values) {
 
53
        int br = (int) (values[0] * 2.55f);
 
54
        return 0xff000000 | (br << 16) | (br << 8) | (br);
 
55
    }
 
56
}