OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 17 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17 Rev 182
Line 1... Line 1...
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
9
 * language governing permissions and limitations under the License.
Line 29... Line 29...
29
import javax.swing.JComponent;
29
import javax.swing.JComponent;
30
import javax.swing.JFrame;
30
import javax.swing.JFrame;
31
 
31
 
32
public class Spots extends JComponent implements Runnable {
32
public class Spots extends JComponent implements Runnable {
33
 
33
 
-
 
34
    // Allow to disable (more than 10% CPU on x2go VM (java itself + x2goagent))
-
 
35
    static public final String START_SLEEPING_PROP_NAME = Spots.class.getSimpleName() + ".startSleeping";
-
 
36
    static final boolean START_SLEEPING = Boolean.getBoolean(START_SLEEPING_PROP_NAME);
-
 
37
 
34
    static int width = 256;
38
    static int width = 256;
35
    static int height = 48;
39
    static int height = 48;
36
 
40
 
37
    private int x;
41
    private int x;
38
    private int y;
42
    private int y;
Line 66... Line 70...
66
    private int ua[];
70
    private int ua[];
67
    private int va[];
71
    private int va[];
68
 
72
 
69
    private Image onScreenImage;
73
    private Image onScreenImage;
70
    private MemoryImageSource imageSource;
74
    private MemoryImageSource imageSource;
71
    private long sleeptime = DEFAULT_SLEEPTIME;
75
    private long sleeptime;
72
    private static final int DEFAULT_SLEEPTIME = 20;
76
    private static final int DEFAULT_SLEEPTIME = 20;
-
 
77
    private static final int STOP_SLEEPTIME = 60 * 60 * 1000;
73
 
78
 
74
    public static void main(String[] args) {
79
    public static void main(String[] args) {
75
        JFrame f = new JFrame();
80
        JFrame f = new JFrame();
76
        final Spots blob1 = new Spots();
81
        final Spots blob1 = new Spots();
77
        blob1.setPreferredSize(new Dimension(width, height));
82
        blob1.setPreferredSize(new Dimension(width, height));
Line 83... Line 88...
83
        f.setVisible(true);
88
        f.setVisible(true);
84
 
89
 
85
    }
90
    }
86
 
91
 
87
    public Spots() {
92
    public Spots() {
-
 
93
        this(START_SLEEPING, true);
-
 
94
    }
88
 
95
 
-
 
96
    public Spots(final boolean startSleeping, final boolean addMouseListener) {
-
 
97
        this.sleeptime = startSleeping ? STOP_SLEEPTIME : DEFAULT_SLEEPTIME;
89
        ga = true;
98
        ga = true;
90
 
99
 
91
        pixles = new int[width * height];
100
        pixles = new int[width * height];
92
        ua = new int[0x10100];
101
        ua = new int[0x10100];
93
        va = new int[4146];
102
        va = new int[4146];
94
        setPreferredSize(new Dimension(width, height));
103
        setPreferredSize(new Dimension(width, height));
95
        setMinimumSize(new Dimension(width, height));
104
        setMinimumSize(new Dimension(width, height));
96
        setMaximumSize(new Dimension(width, height));
105
        setMaximumSize(new Dimension(width, height));
-
 
106
        if (addMouseListener) {
97
        this.addMouseListener(new MouseAdapter() {
107
            this.addMouseListener(new MouseAdapter() {
98
 
-
 
-
 
108
                @Override
99
            public void mouseClicked(MouseEvent e) {
109
                public void mouseClicked(MouseEvent e) {
100
 
-
 
101
                if (sleeptime == DEFAULT_SLEEPTIME) {
110
                    if (sleeptime == DEFAULT_SLEEPTIME) {
102
                    // Redessine un fois par heure
111
                        // Redessine un fois par heure
103
                    sleeptime = 60 * 60 * 1000;
112
                        sleeptime = STOP_SLEEPTIME;
104
                } else {
113
                    } else {
105
                    sleeptime = DEFAULT_SLEEPTIME;
114
                        sleeptime = DEFAULT_SLEEPTIME;
106
                    updateThread.interrupt();
115
                        updateThread.interrupt();
107
                }
116
                    }
108
            }
117
                }
109
 
-
 
110
        });
118
            });
111
    }
119
        }
-
 
120
    }
112
 
121
 
113
    public void init() {
122
    public void init() {
114
        setBackground(Color.black);
123
        setBackground(Color.black);
115
        ColorModel colorModel = new DirectColorModel(32, 0xff0000, 0x00ff00, 0x0000FF, 0);
124
        ColorModel colorModel = new DirectColorModel(32, 0xff0000, 0x00ff00, 0x0000FF, 0);
116
 
125