Last change
on this file since 17318 was 14581, checked in by Don-vip, 5 years ago |
fix recent sonar issues
|
-
Property svn:eol-style
set to
native
|
File size:
1008 bytes
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.animation;
|
---|
3 |
|
---|
4 | import java.awt.Graphics;
|
---|
5 | import java.util.ArrayList;
|
---|
6 | import java.util.List;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * Christmas animation extension. Copied from Icedtea-Web.
|
---|
10 | * @author Jiri Vanek (Red Hat)
|
---|
11 | * @see <a href="http://icedtea.classpath.org/hg/icedtea-web/rev/87d3081ab573">Initial commit</a>
|
---|
12 | * @since 14578
|
---|
13 | */
|
---|
14 | public class ChristmasExtension implements AnimationExtension {
|
---|
15 |
|
---|
16 | private final List<Star> stars = new ArrayList<>(50);
|
---|
17 |
|
---|
18 | @Override
|
---|
19 | public void paint(Graphics g) {
|
---|
20 | stars.forEach(s -> s.paint(g));
|
---|
21 | }
|
---|
22 |
|
---|
23 | @Override
|
---|
24 | public void animate() {
|
---|
25 | stars.forEach(Star::animate);
|
---|
26 | }
|
---|
27 |
|
---|
28 | @Override
|
---|
29 | public final void adjustForSize(int w, int h) {
|
---|
30 | int count = w / (2 * (Star.averageStarWidth + 1));
|
---|
31 | while (stars.size() > count) {
|
---|
32 | stars.remove(stars.size() - 1);
|
---|
33 | }
|
---|
34 | while (stars.size() < count) {
|
---|
35 | stars.add(new Star(w, h));
|
---|
36 | }
|
---|
37 | }
|
---|
38 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.