File: MeterProgressBar.java

package info (click to toggle)
libjide-oss-java 3.7.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 13,264 kB
  • sloc: java: 89,463; xml: 268; makefile: 35
file content (104 lines) | stat: -rw-r--r-- 2,414 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
 * MeterProgressBar.java
 * 
 * Created on 2007-10-2, 15:01:03
 * 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.jidesoft.swing;

import com.jidesoft.plaf.LookAndFeelFactory;
import com.jidesoft.plaf.UIDefaultsLookup;

import javax.swing.*;

public class MeterProgressBar extends JProgressBar {

    /**
     * @see #getUIClassID
     * @see #writeObject
     */
    private static final String uiClassID = "MeterProgressBarUI";

    public static final String PROPERTY_STYLE = "style";
    public static final int STYLE_PLAIN = 0;
    public static final int STYLE_GRADIENT = 1;

    /**
     * Holds value of property style.
     */
    private int _style = STYLE_GRADIENT;

    public MeterProgressBar() {
        super();
    }

    public MeterProgressBar(int orient) {
        super(orient);
    }

    public MeterProgressBar(int min, int max) {
        super(min, max);
    }

    public MeterProgressBar(int orient, int min, int max) {
        super(orient, min, max);
    }

    public MeterProgressBar(BoundedRangeModel newModel) {
        super(newModel);
    }

    /**
     * Returns a string that specifies the name of the l&f class that renders this component.
     *
     * @return String "MeterProgressBarUI"
     */
    @Override
    public String getUIClassID() {
        return uiClassID;
    }

    /**
     * Resets the UI property to a value from the current look and feel.
     *
     * @see JComponent#updateUI
     */
    @Override
    public void updateUI() {
        if (UIDefaultsLookup.get(uiClassID) == null) {
            LookAndFeelFactory.installJideExtension();
        }
        setUI(UIManager.getUI(this));
    }

    /**
     * Getter for property style.
     *
     * @return Value of property style.
     */
    public int getStyle() {
        return _style;
    }

    /**
     * Setter for property style.
     *
     * @param style New value of property style.
     */
    public void setStyle(int style) {
        if (style == STYLE_PLAIN || style == STYLE_GRADIENT) {
            if (_style != style) {
                int oldValue = _style;
                _style = style;
                firePropertyChange(PROPERTY_STYLE, oldValue, style);
            }
        }
        else {
            throw new IllegalArgumentException("style can be only PLAIN_STYLE or GRADIENT_STYLE");
        }
    }

}