Last change
on this file since 10031 was 10031, checked in by Don-vip, 8 years ago |
fix #12654 - Add layer invalidation listener (patch by michael2402)
|
-
Property svn:eol-style
set to
native
|
File size:
1.3 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.layer;
|
---|
3 |
|
---|
4 | import java.util.concurrent.CopyOnWriteArrayList;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * This class implements the invalidation listener mechanism suggested by {@link MapViewPaintable}.
|
---|
8 | *
|
---|
9 | * @author Michael Zangl
|
---|
10 | * @since 10031
|
---|
11 | */
|
---|
12 | public abstract class AbstractMapViewPaintable implements MapViewPaintable {
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * A list of invalidation listeners to call when this layer is invalidated.
|
---|
16 | */
|
---|
17 | private final CopyOnWriteArrayList<PaintableInvalidationListener> invalidationListeners = new CopyOnWriteArrayList<>();
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * Adds a new paintable invalidation listener.
|
---|
21 | * @param l The listener to add.
|
---|
22 | */
|
---|
23 | public void addInvalidationListener(PaintableInvalidationListener l) {
|
---|
24 | invalidationListeners.add(l);
|
---|
25 | }
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * Removes an added paintable invalidation listener.
|
---|
29 | * @param l The listener to remove.
|
---|
30 | */
|
---|
31 | public void removeInvalidationListener(PaintableInvalidationListener l) {
|
---|
32 | invalidationListeners.remove(l);
|
---|
33 | }
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * This needs to be called whenever the content of this view was invalidated.
|
---|
37 | */
|
---|
38 | public void invalidate() {
|
---|
39 | for (PaintableInvalidationListener l : invalidationListeners) {
|
---|
40 | l.paintablInvalidated(new PaintableInvalidationEvent(this));
|
---|
41 | }
|
---|
42 | }
|
---|
43 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.