01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2003-2006, Geotools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.renderer.style;
17:
18: /**
19: * Base class for resolved styles. Styles are resolved according a particular rendering context.
20: * The base class make no assumption about the output device (AWT, SWT, <i>etc.</i>). However, a
21: * particular output device may need to be choosen for concrete subclasses, for example {@link
22: * Style2D} for targeting <A HREF="http://java.sun.com/products/java-media/2D/">Java2D</A>.
23: *
24: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/render/src/main/java/org/geotools/renderer/style/Style.java $
25: * @version $Id: Style.java 20874 2006-08-07 10:00:01Z jgarnett $
26: */
27: public abstract class Style {
28: /** Maximum scale at which the geometry has to be painted with this style */
29: protected double maxScale = Double.POSITIVE_INFINITY;
30:
31: /** Minimum scale at which the geometry has to be painted with this style */
32: protected double minScale = 0;
33:
34: /**
35: * Gets the maximum scale at which the geometry has to be painted with this style (inclusive)
36: *
37: * @return - the maximum painting scale
38: */
39: public double getMaxScale() {
40: return this .maxScale;
41: }
42:
43: /**
44: * Gets the minimum scale at which the geometry has to be painted with this style (inclusive)
45: *
46: * @return - the minimum painting scale
47: */
48: public double getMinScale() {
49: return this .minScale;
50: }
51:
52: /**
53: * Sets minimum and maximum scale, and performs integrity checks on these value (will throw
54: * and IllegalArgumentException in minScale > maxScale)
55: *
56: * @param minScale
57: * @param maxScale
58: *
59: * @throws IllegalArgumentException DOCUMENT ME!
60: */
61: public void setMinMaxScale(double minScale, double maxScale) {
62: if (minScale > maxScale) {
63: throw new IllegalArgumentException(
64: "Max scale must be bigger than min scale");
65: }
66:
67: this .minScale = minScale;
68: this .maxScale = maxScale;
69: }
70:
71: /**
72: * Checks whethere the style should be used for painting at scale <code>scale</scale>
73: *
74: * @param scale The scale queried
75: *
76: * @return True if <code>scale</code> is whithin the scale range of this style (false
77: * otherwise)
78: */
79: public boolean isScaleInRange(double scale) {
80: return (scale >= minScale) && (scale <= maxScale);
81: }
82: }
|