Revision 213 trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/Attributes.java
Attributes.java | ||
---|---|---|
28 | 28 |
import java.awt.print.Paper; |
29 | 29 |
import java.text.NumberFormat; |
30 | 30 |
|
31 |
import javax.crypto.Mac; |
|
31 | 32 |
import javax.print.attribute.HashPrintRequestAttributeSet; |
32 | 33 |
import javax.print.attribute.PrintRequestAttributeSet; |
33 | 34 |
import javax.print.attribute.standard.Copies; |
... | ... | |
40 | 41 |
import javax.print.attribute.standard.Sides; |
41 | 42 |
|
42 | 43 |
import org.gvsig.andami.PluginServices; |
44 |
import org.gvsig.app.extension.LayoutExtension; |
|
43 | 45 |
import org.gvsig.compat.CompatLocator; |
44 | 46 |
import org.gvsig.compat.print.PrintAttributes; |
45 | 47 |
import org.gvsig.fmap.mapcontext.MapContext; |
... | ... | |
50 | 52 |
import org.gvsig.tools.persistence.PersistentState; |
51 | 53 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
52 | 54 |
import org.gvsig.utils.XMLEntity; |
55 |
import org.slf4j.Logger; |
|
56 |
import org.slf4j.LoggerFactory; |
|
53 | 57 |
|
54 | 58 |
/** |
55 | 59 |
* Attributes of Layout. |
... | ... | |
76 | 80 |
// public static final String WIDTHXHEIGHT_FIELD = "widthXHeight"; |
77 | 81 |
public static final String SIZEINUNITS_FIELD = "sizeInUnits"; |
78 | 82 |
public static final String ISLANDSEL_FIELD = "isLandSel"; |
79 |
|
|
80 |
/** |
|
81 |
* Array of doubles containg the change factro from <b>CENTIMETERS</b> to |
|
82 |
* KILOMETERS, METERS, CENTIMETERS, MILLIMETERS, MILES, YARDS, FEET, INCHES, |
|
83 |
* DECIMAL DEGREES |
|
84 |
*/ |
|
85 |
/* |
|
86 |
* Do not alter the order and the values of this array, if you need append |
|
87 |
* values. |
|
88 |
*/ |
|
89 |
public static final double[] CHANGE = { 100000, 100, 1, 0.1, 160934.4, |
|
90 |
91.44, 30.48, 2.54, 8.983152841195214E-6 }; |
|
91 | 83 |
public static final String DEGREES = "Grados"; |
92 |
/* |
|
93 |
* Do not alter the order and the values of this array, if you need append |
|
94 |
* values. |
|
95 |
*/ |
|
96 |
public static final double[] UNIT = { 0.0000025, 0.0025, 0.25, 2.5, |
|
97 |
0.0000025, 0.025, 0.025, 0.25, 8.8E-7 }; |
|
98 | 84 |
public static final int HIGH = 0; |
99 | 85 |
public static final int NORMAL = 1; |
100 | 86 |
public static final int DRAFT = 2; |
... | ... | |
145 | 131 |
new HashPrintRequestAttributeSet(); |
146 | 132 |
private MediaSizeName m_type = MediaSizeName.ISO_A4; |
147 | 133 |
private OrientationRequested m_Orientation; |
148 |
private double m_TypeUnit = CHANGE[2]; // CENTIMETROS; |
|
134 |
/** |
|
135 |
* Change factor from configured map unit (m_selTypeUnit) to centimeters |
|
136 |
*/ |
|
137 |
private double m_TypeUnit = 190.0d*MapContext.getDistanceTrans2Meter()[2]; // [2] = Centimeters |
|
149 | 138 |
private String m_NameUnit; |
139 |
/** |
|
140 |
* Horizontal space between grid lines, measured in the configured map unit (m_selTypeUnit) |
|
141 |
*/ |
|
150 | 142 |
private Double m_numX = null; |
143 |
/** |
|
144 |
* Vertical space between grid lines, measured in the configured map unit (m_selTypeUnit) |
|
145 |
*/ |
|
151 | 146 |
private Double m_numY = null; |
152 | 147 |
private double m_unitX = 0; |
153 | 148 |
private double m_unitY = 0; |
154 | 149 |
private boolean hasmargin; |
155 | 150 |
private int m_resolutionSel = NORMAL; |
156 | 151 |
private int m_typeSel = PRINT; |
152 |
/** |
|
153 |
* The selected unit (km, cm, etc) for this layout. It defaults to centimeters |
|
154 |
* |
|
155 |
* @see {@link MapContext#getDistanceNames()} |
|
156 |
* @see {@link MapContext#getDistanceTrans2Meter()} |
|
157 |
*/ |
|
157 | 158 |
private int m_selTypeUnit = 2; |
158 | 159 |
|
159 | 160 |
/** |
... | ... | |
251 | 252 |
} |
252 | 253 |
|
253 | 254 |
/** |
254 |
* This field does not know about orientation. |
|
255 |
* It's value is the same for portrait and landscape |
|
255 |
* Paper size, measured in centimeters. |
|
256 |
* This field does not know about orientation,its value is the same |
|
257 |
* for portrait and landscape. |
|
256 | 258 |
* |
259 |
* Note that this size is always measured in centimeters, regardless |
|
260 |
* the selected unit for the page. However, the user should be always |
|
261 |
* presented measures in the selected unit. |
|
262 |
* |
|
263 |
* @see #getSelTypeUnit() |
|
264 |
* @see #setUnit(int) |
|
265 |
* |
|
257 | 266 |
* @return |
258 | 267 |
*/ |
259 | 268 |
public Size getPaperSize() { |
... | ... | |
932 | 941 |
|
933 | 942 |
|
934 | 943 |
/** |
935 |
* Retunrs the type of units is in use. |
|
944 |
* Returns the type of units is in use (cm, mm, km, etc), codified as |
|
945 |
* a position in the array returned by {@link MapContext#getDistanceNames()} |
|
946 |
* |
|
947 |
* @see #setUnit(int) |
|
948 |
* @see MapContext#getDistanceNames() |
|
949 |
* @see MapContext#getDistanceTrans2Meter() |
|
950 |
* @see MapContext#getDistanceAbbr() |
|
951 |
* @see MapContext#getDistancePosition(String) |
|
952 |
* @see MapContext#getDistancePosition(String) |
|
953 |
|
|
936 | 954 |
* |
937 | 955 |
* @return Type of units. |
938 | 956 |
*/ |
... | ... | |
941 | 959 |
} |
942 | 960 |
|
943 | 961 |
/** |
944 |
* Returns the name of units. |
|
962 |
* Returns the name of the selected units. |
|
963 |
* @see #getSelTypeUnit() |
|
945 | 964 |
* |
946 | 965 |
* @return String Name of units. |
947 | 966 |
*/ |
... | ... | |
955 | 974 |
* |
956 | 975 |
* @param sel |
957 | 976 |
* Type of unit. |
977 |
* @see #getSelTypeUnit() |
|
958 | 978 |
*/ |
959 | 979 |
public void setUnit(int sel) { |
980 |
Logger logger = LoggerFactory |
|
981 |
.getLogger(LayoutExtension.class); |
|
982 |
logger.debug("setUnit: "+sel); |
|
960 | 983 |
m_selTypeUnit = sel; |
961 |
m_TypeUnit = CHANGE[sel];
|
|
984 |
m_TypeUnit = 100.0d*MapContext.getDistanceTrans2Meter()[sel];
|
|
962 | 985 |
m_NameUnit = |
963 | 986 |
PluginServices.getText(this, MapContext.getDistanceNames()[sel]); |
964 |
m_numX = m_numY = new Double(UNIT[sel]);
|
|
987 |
m_numX = m_numY = new Double(0.25/m_TypeUnit); // 0.25 cm / unit_to_cm
|
|
965 | 988 |
} |
966 | 989 |
|
967 | 990 |
/** |
... | ... | |
1024 | 1047 |
*/ |
1025 | 1048 |
public double getPixXCm(Rectangle2D rect) { |
1026 | 1049 |
double value = m_sizePaper.getAncho(); |
1027 |
double cm = CHANGE[2];
|
|
1050 |
double cm = 100.0d*MapContext.getDistanceTrans2Meter()[2];
|
|
1028 | 1051 |
double unidades = 0; |
1029 | 1052 |
unidades = ((rect.getMaxX() - rect.getMinX()) / ((value / cm))); |
1030 | 1053 |
return unidades; |
Also available in: Unified diff