[10458] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
| 2 | package org.openstreetmap.josm.gui.layer;
|
---|
| 3 |
|
---|
| 4 | import java.awt.Graphics2D;
|
---|
| 5 |
|
---|
| 6 | import org.openstreetmap.josm.gui.MapView;
|
---|
| 7 | import org.openstreetmap.josm.gui.MapViewState.MapViewRectangle;
|
---|
| 8 |
|
---|
| 9 | /**
|
---|
| 10 | * This class provides layers with access to drawing on the map view.
|
---|
| 11 | * <p>
|
---|
| 12 | * It contains information about the state of the map view.
|
---|
| 13 | * <p>
|
---|
| 14 | * In the future, it may add support for parallel drawing or layer caching.
|
---|
| 15 | * <p>
|
---|
| 16 | * It is intended to be used during {@link MapView#paint(java.awt.Graphics)}
|
---|
| 17 | * @author Michael Zangl
|
---|
| 18 | * @since 10458
|
---|
| 19 | */
|
---|
| 20 | public class MapViewGraphics {
|
---|
| 21 |
|
---|
| 22 | private final Graphics2D graphics;
|
---|
| 23 | private final MapView mapView;
|
---|
| 24 | private final MapViewRectangle clipBounds;
|
---|
| 25 |
|
---|
| 26 | /**
|
---|
| 27 | * Constructs a new {@code MapViewGraphics}.
|
---|
| 28 | * @param mapView map view
|
---|
| 29 | * @param graphics default graphics
|
---|
| 30 | * @param clipBounds clip bounds for this graphics instance
|
---|
| 31 | */
|
---|
| 32 | public MapViewGraphics(MapView mapView, Graphics2D graphics, MapViewRectangle clipBounds) {
|
---|
| 33 | this.mapView = mapView;
|
---|
| 34 | this.graphics = graphics;
|
---|
| 35 | this.clipBounds = clipBounds;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | /**
|
---|
| 39 | * Gets the {@link Graphics2D} you should use to paint on this graphics object. It may already have some data painted on it.
|
---|
| 40 | * You should paint your layer data on this graphics.
|
---|
| 41 | * @return The {@link Graphics2D} instance.
|
---|
| 42 | */
|
---|
| 43 | public Graphics2D getDefaultGraphics() {
|
---|
| 44 | return graphics;
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | /**
|
---|
| 48 | * Gets the {@link MapView} that is the base to this draw call.
|
---|
| 49 | * @return The map view.
|
---|
| 50 | */
|
---|
| 51 | public MapView getMapView() {
|
---|
| 52 | return mapView;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | /**
|
---|
| 56 | * Gets the clip bounds for this graphics instance.
|
---|
| 57 | * @return The clip bounds.
|
---|
| 58 | */
|
---|
| 59 | public MapViewRectangle getClipBounds() {
|
---|
| 60 | return clipBounds;
|
---|
| 61 | }
|
---|
| 62 | }
|
---|