001    // License: GPL. For details, see LICENSE file.
002    package org.openstreetmap.josm.data.osm.visitor.paint;
003    
004    import java.awt.Graphics2D;
005    
006    import org.openstreetmap.josm.gui.NavigatableComponent;
007    import org.openstreetmap.josm.tools.CheckParameterUtil;
008    
009    /**
010     * <p>Abstract common superclass for {@link Rendering} implementations.</p>
011     *
012     */
013    public abstract class AbstractMapRenderer implements Rendering {
014    
015        /** the graphics context to which the visitor renders OSM objects */
016        protected Graphics2D g;
017        /** the map viewport - provides projection and hit detection functionality */
018        protected NavigatableComponent nc;
019        /** if true, the paint visitor shall render OSM objects such that they
020         * look inactive. Example: rendering of data in an inactive layer using light gray as color only.
021         */
022        protected boolean isInactiveMode;
023    
024        /**
025         * <p>Creates an abstract paint visitor</p>
026         * 
027         * @param g the graphics context. Must not be null.
028         * @param nc the map viewport. Must not be null.
029         * @param isInactiveMode if true, the paint visitor shall render OSM objects such that they
030         * look inactive. Example: rendering of data in an inactive layer using light gray as color only.
031         * @throws IllegalArgumentException thrown if {@code g} is null
032         * @throws IllegalArgumentException thrown if {@code nc} is null
033         */
034        public AbstractMapRenderer(Graphics2D g, NavigatableComponent nc, boolean isInactiveMode) throws IllegalArgumentException{
035            CheckParameterUtil.ensureParameterNotNull(g);
036            CheckParameterUtil.ensureParameterNotNull(nc);
037            this.g = g;
038            this.nc = nc;
039            this.isInactiveMode = isInactiveMode;
040        }
041    }