svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.mapcontext / org.gvsig.fmap.mapcontext.api / src / main / java / org / gvsig / fmap / mapcontext / rendering / symbols / CartographicSupport.java @ 40559
History | View | Annotate | Download (5.75 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40559 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | 40559 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * of the License, or (at your option) any later version.
|
10 | *
|
||
11 | * This program 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
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | 40559 | jjdelcerro | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | * MA 02110-1301, USA.
|
||
20 | 40435 | jjdelcerro | *
|
21 | 40559 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | package org.gvsig.fmap.mapcontext.rendering.symbols; |
||
25 | |||
26 | import org.gvsig.fmap.geom.Geometry; |
||
27 | import org.gvsig.fmap.mapcontext.ViewPort; |
||
28 | |||
29 | /**
|
||
30 | * <p>This interface enables Cartographic support for those graphical elements that require
|
||
31 | * additional runtime information rather than the feature itself geometric definitions.<br></p>
|
||
32 | *
|
||
33 | * <p>It allows to realworld's measure units dimensioning.<br></p>
|
||
34 | *
|
||
35 | * <p>It also supplies a toolkit to perform operations with centralized static methods.
|
||
36 | * @see CartographicSupportToolkit inner class' methods<br></p>
|
||
37 | *
|
||
38 | * @author jaume dominguez faus - jaume.dominguez@iver.es
|
||
39 | */
|
||
40 | public interface CartographicSupport { |
||
41 | public static final int WORLD = 0; |
||
42 | public static final int PAPER = 1; |
||
43 | |||
44 | /**
|
||
45 | * Defines the unit used to express measures. It is the position of the unit in the <b>MapContext.NAMES</b> array.
|
||
46 | * @param unitIndex, the index of the unit in the MapContext.NAMES array
|
||
47 | */
|
||
48 | public abstract void setUnit(int unitIndex); |
||
49 | /**
|
||
50 | * Returns the unit used to express measures. It is the position of the unit in the <b>MapContext.NAMES</b> array.
|
||
51 | * @returns an <b>int</b> with the index of the unit in the MapContext.NAMES array, or -1 if the size is specified in pixel
|
||
52 | */
|
||
53 | public abstract int getUnit(); |
||
54 | |||
55 | /**
|
||
56 | * Returns the <b>Reference System</b> used to draw the elements of the image.<br>
|
||
57 | * <p>
|
||
58 | * The elements have to be scaled to <b>pixel</b> when the image is bein drawn in
|
||
59 | * order to compose the map. The elements of the map may define its size in
|
||
60 | * other units than pixel.<br>
|
||
61 | * </p>
|
||
62 | * <p><b>CartographicSupport</b> enables the elements to define the size in
|
||
63 | * measure units but these units may refer to different reference system. Two
|
||
64 | * kinds of Reference Systems are allowed in this context: <b>CartographicSupport.WORLD</b>,
|
||
65 | * and <b>CartographicSupport.PAPER</b>.
|
||
66 | * <br></p>
|
||
67 | * <p>
|
||
68 | * Depending on which <b>Reference System</b> is used the unit used by this element
|
||
69 | * refers to distances in the real world (then they are map's CRS-dependant)
|
||
70 | * or screen or printer output (then they are output DPI-dependant)<br>
|
||
71 | * </p>
|
||
72 | * <p>
|
||
73 | * In case the unit used is <b>pixel</b> then the reference system does not
|
||
74 | * have any effect since the source unit is the same than the target unit.
|
||
75 | * <br>
|
||
76 | * </p>
|
||
77 | * @return
|
||
78 | */
|
||
79 | public abstract int getReferenceSystem(); |
||
80 | |||
81 | /**
|
||
82 | * Sets the <b>Reference System</b> that defines how this units have to be
|
||
83 | * handled. Possible values are:
|
||
84 | * <ol>
|
||
85 | * <li><b>CartographySupport.WORLD</b>: Defines that the unit values refer
|
||
86 | * to distances in the world. So, the size of the element displayed <b>depends
|
||
87 | * directly on the scale and CRS</b> used by the map. The size of the elements
|
||
88 | * defined to use CartographicSupport.WORLD will match exactly to their
|
||
89 | * actual size in the real world.</li>
|
||
90 | * <li><b>CartographySupport.PAPER</b>: Defines that the unit values refer
|
||
91 | * to the length that the element will have regardless where it appears. If
|
||
92 | * ReferenceSystem is <b>CartographySupport.PAPER</b>, and the length is (e.g.)
|
||
93 | * millimeters the element will be displayed with the <b>same</b> amount of
|
||
94 | * millimeters of length whether in the <b>screen</b> or the <b>printer</b>
|
||
95 | * (screen DPI and printer DPI must be correctly configured).</li>
|
||
96 | * </ol>
|
||
97 | */
|
||
98 | public abstract void setReferenceSystem(int referenceSystem); |
||
99 | |||
100 | /**
|
||
101 | * Computes and sets the size (in pixels) of the cartographic element according
|
||
102 | * to the current rendering context (output dpi, map scale, map units) and the
|
||
103 | * symbol cartgraphic settings (unit, size, and unit reference system).
|
||
104 | *
|
||
105 | * @param viewPort, the ViewPort containing the symbol.
|
||
106 | * @param dpi, current output dpi (screen or printer)
|
||
107 | * @param shp, used only for MultiShapeSymbols in order to discriminate the internal symbol to be applied
|
||
108 | * @return a double containing the previous defined size
|
||
109 | */
|
||
110 | public abstract double toCartographicSize(ViewPort viewPort, double dpi, Geometry geom); |
||
111 | |||
112 | /**
|
||
113 | * Sets the size of the cartographic element in pixels.
|
||
114 | *
|
||
115 | * @param cartographicSize, the size in pixels of the element
|
||
116 | * @param shp, used only for MultiShapeSymbols in order to discriminate the internal symbol to be applied
|
||
117 | */
|
||
118 | public abstract void setCartographicSize(double cartographicSize, Geometry geom); |
||
119 | |||
120 | /**
|
||
121 | * Gets the size (in pixels) of the cartographic element according
|
||
122 | * to the current rendering context (output dpi, map scale, map units) and the
|
||
123 | * symbol cartgraphic settings (unit, size, and unit reference system).
|
||
124 | * @param viewPort
|
||
125 | * @param dpi
|
||
126 | * @param shp
|
||
127 | * @return double containing the size in [screen/printer] pixels for the current symbol
|
||
128 | */
|
||
129 | public abstract double getCartographicSize(ViewPort viewPort, double dpi, Geometry geom); |
||
130 | |||
131 | |||
132 | } |