?? graticulelayer.java
字號:
// **********************************************************************//// <copyright>//// BBN Technologies, a Verizon Company// 10 Moulton Street// Cambridge, MA 02138// (617) 873-8000//// Copyright (C) BBNT Solutions LLC. All rights reserved.//// </copyright>// **********************************************************************//// $Source: /cvs/distapps/openmap/src/openmap/com/bbn/openmap/layer/GraticuleLayer.java,v $// $RCSfile: GraticuleLayer.java,v $// $Revision: 1.7.2.6 $// $Date: 2005/08/09 18:10:43 $// $Author: dietrick $//// **********************************************************************// Modified 28 September 2002 by David N. Allsopp to allow font size// to be changed. See sections commented with 'DNA'.package com.bbn.openmap.layer;import java.awt.Color;import java.awt.Font;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.Properties;import javax.swing.Box;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JPanel;import com.bbn.openmap.Environment;import com.bbn.openmap.I18n;import com.bbn.openmap.LatLonPoint;import com.bbn.openmap.MoreMath;import com.bbn.openmap.event.ProjectionEvent;import com.bbn.openmap.omGraphics.OMGraphic;import com.bbn.openmap.omGraphics.OMGraphicList;import com.bbn.openmap.omGraphics.OMPoly;import com.bbn.openmap.omGraphics.OMText;import com.bbn.openmap.proj.Cylindrical;import com.bbn.openmap.proj.Projection;import com.bbn.openmap.util.Debug;import com.bbn.openmap.util.PaletteHelper;import com.bbn.openmap.util.PropUtils;/** * Layer that draws graticule lines. If the showRuler property is set * to true, then longitude values are displayed on the bottom of the * map, and latitude values are displayed on the left side. If the * show1And5Lines property is true, then 5 degree lines are drawn when * there are <= threshold ten degree latitude or longitude lines, * and 1 degree lines are drawn when there are <= threshold five * degree latitude or longitude degree lines. * * <P> * The openmap.properties file can control the layer with the * following settings: <code><pre> * * * # Show lat / lon spacing labels * graticule.showRuler=true * graticule.show1And5Lines=true * # Controls when the five degree lines and one degree lines kick in * #- when there is less than the threshold of ten degree lat or lon * #lines, five degree lines are drawn. The same relationship is there * #for one to five degree lines. * graticule.threshold=2 * # the color of 10 degree spacing lines (Hex ARGB) * graticule.10DegreeColor=FF000000 * # the color of 5 degree spacing lines (Hex ARGB) * graticule.5DegreeColor=C7009900 * # the color of 1 degree spacing lines (Hex ARGB) * graticule.1DegreeColor=C7003300 * # the color of the equator (Hex ARGB) * graticule.equatorColor=FFFF0000 * # the color of the international dateline (Hex ARGB) * graticule.datelineColor=7F000099 * # the color of the special lines (Hex ARGB) * graticule.specialLineColor=FF000000 * # the color of the labels (Hex ARGB) * graticule.textColor=FF000000 * * * </pre></code> In addition, you can get this layer to work with the * OpenMap viewer by editing your openmap.properties file: <code><pre> * * * # layers * openmap.layers=graticule ... * # class * graticule.class=com.bbn.openmap.layer.GraticuleLayer * # name * graticule.prettyName=Graticule * * * </pre></code> * */public class GraticuleLayer extends OMGraphicHandlerLayer implements ActionListener { protected I18n i18n = Environment.getI18n(); // default to not showing the ruler (mimicing older // GraticuleLayer) protected boolean defaultShowRuler = true; protected boolean defaultShowOneAndFiveLines = true; protected boolean defaultShowBelowOneLines = false; protected int defaultThreshold = 2; /** * Flag for lineType - true is LINETYPE_STRAIGHT, false is * LINETYPE_GREATCIRCLE. */ protected boolean boxy = true; /** * Threshold is the total number of ten lines on the screen before * the five lines appear, and the total number of five lines on * the screen before the one lines appear. */ protected int threshold = defaultThreshold; /** The ten degree latitude and longitude lines, premade. */ protected OMGraphicList tenDegreeLines = null; /** The equator, dateline and meridian lines, premade. */ protected OMGraphicList markerLines = null; private final static int SHOW_TENS = 0; private final static int SHOW_FIVES = 1; private final static int SHOW_ONES = 2; protected boolean showOneAndFiveLines = defaultShowOneAndFiveLines; protected boolean showBelowOneLines = defaultShowBelowOneLines; protected boolean showRuler = defaultShowRuler; // protected Font font = new Font("Helvetica", // java.awt.Font.PLAIN, 10); protected Font font = null; protected int fontSize = 10; // Color variables for different line types protected Color tenDegreeColor = null; protected Color fiveDegreeColor = null; protected Color oneDegreeColor = null; protected Color belowOneDegreeColor = null; protected Color equatorColor = null; protected Color dateLineColor = null; protected Color specialLineColor = null; // Tropic of Cancer, // Capricorn protected Color textColor = null; // Default colors to use, if not specified in the properties. protected String defaultTenDegreeColorString = "000000"; protected String defaultFiveDegreeColorString = "33009900"; protected String defaultOneDegreeColorString = "33003300"; protected String defaultBelowOneDegreeColorString = "9900ff00"; protected String defaultEquatorColorString = "990000"; protected String defaultDateLineColorString = "000099"; protected String defaultSpecialLineColorString = "000000"; protected String defaultTextColorString = "000000"; // property text values public static final String TenDegreeColorProperty = "10DegreeColor"; public static final String FiveDegreeColorProperty = "5DegreeColor"; public static final String OneDegreeColorProperty = "1DegreeColor"; public static final String BelowOneDegreeColorProperty = "Below1DegreeColor"; public static final String EquatorColorProperty = "equatorColor"; public static final String DateLineColorProperty = "datelineColor"; public static final String SpecialLineColorProperty = "specialLineColor"; public static final String TextColorProperty = "textColor"; public static final String ThresholdProperty = "threshold"; public static final String ShowRulerProperty = "showRuler"; public static final String ShowOneAndFiveProperty = "show1And5Lines"; public static final String ShowBelowOneProperty = "showBelow1Lines"; public static final String FontSizeProperty = "fontSize"; //DNA /** * Construct the GraticuleLayer. */ public GraticuleLayer() { // precalculate for boxy boxy = true; setName("Graticule"); } /** * The properties and prefix are managed and decoded here, for the * standard uses of the GraticuleLayer. * * @param prefix string prefix used in the properties file for * this layer. * @param properties the properties set in the properties file. */ public void setProperties(String prefix, java.util.Properties properties) { super.setProperties(prefix, properties); prefix = PropUtils.getScopedPropertyPrefix(prefix); tenDegreeColor = PropUtils.parseColorFromProperties(properties, prefix + TenDegreeColorProperty, defaultTenDegreeColorString); fiveDegreeColor = PropUtils.parseColorFromProperties(properties, prefix + FiveDegreeColorProperty, defaultFiveDegreeColorString); oneDegreeColor = PropUtils.parseColorFromProperties(properties, prefix + OneDegreeColorProperty, defaultOneDegreeColorString); belowOneDegreeColor = PropUtils.parseColorFromProperties(properties, prefix + BelowOneDegreeColorProperty, defaultBelowOneDegreeColorString); equatorColor = PropUtils.parseColorFromProperties(properties, prefix + EquatorColorProperty, defaultEquatorColorString); dateLineColor = PropUtils.parseColorFromProperties(properties, prefix + DateLineColorProperty, defaultDateLineColorString); specialLineColor = PropUtils.parseColorFromProperties(properties, prefix + SpecialLineColorProperty, defaultSpecialLineColorString); textColor = PropUtils.parseColorFromProperties(properties, prefix + TextColorProperty, defaultTextColorString); threshold = PropUtils.intFromProperties(properties, prefix + ThresholdProperty, defaultThreshold); fontSize = PropUtils.intFromProperties(properties, prefix + FontSizeProperty, fontSize); font = new Font("Helvetica", java.awt.Font.PLAIN, fontSize); setShowOneAndFiveLines(PropUtils.booleanFromProperties(properties, prefix + ShowOneAndFiveProperty, defaultShowOneAndFiveLines)); setShowBelowOneLines(PropUtils.booleanFromProperties(properties, prefix + ShowBelowOneProperty, defaultShowBelowOneLines)); setShowRuler(PropUtils.booleanFromProperties(properties, prefix + ShowRulerProperty, defaultShowRuler)); // So they will get re-created. tenDegreeLines = null; markerLines = null; } protected JCheckBox showRulerButton = null; protected JCheckBox show15Button = null; protected JCheckBox showBelow1Button = null; public void setShowOneAndFiveLines(boolean set) { showOneAndFiveLines = set; if (show15Button != null) { show15Button.setSelected(set); } } public void setShowBelowOneLines(boolean set) { showBelowOneLines = set; if (showBelow1Button != null) { showBelow1Button.setSelected(set); } } public boolean getShowOneAndFiveLines() { return showOneAndFiveLines; } public boolean getShowBelowOneLines() { return showBelowOneLines; } public void setShowRuler(boolean set) { showRuler = set; if (showRulerButton != null) { showRulerButton.setSelected(set); } } public boolean getShowRuler() { return showRuler; } /** * The properties and prefix are managed and decoded here, for the * standard uses of the GraticuleLayer. * * @param properties the properties set in the properties file. */ public Properties getProperties(Properties properties) { properties = super.getProperties(properties); String prefix = PropUtils.getScopedPropertyPrefix(this); String colorString; if (tenDegreeColor == null) { colorString = defaultTenDegreeColorString; } else { colorString = Integer.toHexString(tenDegreeColor.getRGB()); } properties.put(prefix + TenDegreeColorProperty, colorString); if (fiveDegreeColor == null) { colorString = defaultFiveDegreeColorString; } else { colorString = Integer.toHexString(fiveDegreeColor.getRGB()); } properties.put(prefix + FiveDegreeColorProperty, colorString); if (oneDegreeColor == null) { colorString = defaultOneDegreeColorString; } else { colorString = Integer.toHexString(oneDegreeColor.getRGB());
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -