drawingattributes.java
来自「OpenMap是一个基于JavaBeansTM的开发工具包。利用OpenMap你」· Java 代码 · 共 1,803 行 · 第 1/5 页
JAVA
1,803 行
// textPaint = // PropUtils.parseColorFromProperties( // props, realPrefix + textPaintProperty, // textPaint); fillPaint = PropUtils.parseColorFromProperties(props, realPrefix + fillPaintProperty, fillPaint); matted = PropUtils.booleanFromProperties(props, realPrefix + mattedProperty, matted); pointRadius = PropUtils.intFromProperties(props, realPrefix + PointRadiusProperty, pointRadius); pointOval = PropUtils.booleanFromProperties(props, realPrefix + PointOvalProperty, pointOval); float lineWidth; boolean basicStrokeDefined = false; if (stroke != null && stroke instanceof BasicStroke) { basicStrokeDefined = true; } lineWidth = PropUtils.floatFromProperties(props, realPrefix + lineWidthProperty, (basicStrokeDefined ? ((BasicStroke) stroke).getLineWidth() : defaultLineWidth)); baseScale = PropUtils.floatFromProperties(props, realPrefix + baseScaleProperty, baseScale); // Look for a dash pattern properties to come up with a stroke String dPattern = props.getProperty(realPrefix + dashPatternProperty); if (basicStrokeDefined && dPattern != null && !dPattern.equals("")) { float dashPhase; float[] lineDash; // OK, it exists, come up with a stroke. try { StringTokenizer t = new StringTokenizer(dPattern); int arraySize = t.countTokens(); lineDash = new float[arraySize]; int dashCount = 0; while (t.hasMoreTokens()) { String segment = t.nextToken(); lineDash[dashCount++] = Float.parseFloat(segment); if (Debug.debugging("drawingattributes")) { Debug.output("read " + segment); } } } catch (NoSuchElementException nsee) { Debug.error("DrawingAttributes.init: dash pattern attributes wrong - should be dashPattern=(number pixels on) (number pixels off)"); lineDash = null; } catch (NumberFormatException nfe) { Debug.error("DrawingAttributes.init: Number format exception for dashPattern"); lineDash = null; } catch (NullPointerException npe) { Debug.error("DrawingAttributes.init: Caught null pointer exception - probably resulting from non-float number format exception for dashPattern"); lineDash = null; } if (lineDash == null) { if (basicStrokeDefined) { lineDash = ((BasicStroke) stroke).getDashArray(); } else { lineDash = new float[2]; lineDash[0] = defaultDashLength; lineDash[1] = defaultDashLength; } } int dashCount = 0; for (int x = 0; x < lineDash.length; x++) { dashCount += lineDash[x]; } if (dashCount == 0) { lineDash = null; } String dPhase = props.getProperty(realPrefix + dashPhaseProperty); if (dPhase != null && !dPhase.equals("")) { try { dashPhase = Float.valueOf(dPhase).floatValue(); } catch (NumberFormatException nfe) { Debug.error("DrawingAttributes.init: Number format exception for dashPhase"); dashPhase = defaultDashPhase; } } else { if (basicStrokeDefined) { dashPhase = ((BasicStroke) stroke).getDashPhase(); } else { dashPhase = defaultDashPhase; } } setStroke(new BasicStroke(lineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, lineDash, dashPhase)); } else if (basicStrokeDefined) { setStroke(new BasicStroke(lineWidth)); } // OK, Fill pattern next... fPattern = props.getProperty(realPrefix + fillPatternProperty); if (fPattern != null && !fPattern.equals("")) { try { URL textureImageURL = PropUtils.getResourceOrFileOrURL(this, fPattern); if (textureImageURL != null) { BufferedImage bi = BufferedImageHelper.getBufferedImage(textureImageURL, 0, 0, -1, -1); fillPattern = new TexturePaint(bi, new Rectangle(0, 0, bi.getWidth(), bi.getHeight())); } } catch (MalformedURLException murle) { Debug.error("DrawingAttributes.init: bad texture URL - \n " + realPrefix + fillPatternProperty); fillPattern = null; } catch (InterruptedException ie) { Debug.error("DrawingAttributes.init: bad problems getting texture URL - \n" + ie); fillPattern = null; } } } /** * PropertyConsumer method, to fill in a Properties object, reflecting the * current values of the layer. If the layer has a propertyPrefix set, the * property keys should have that prefix plus a separating '.' prepended to * each propery key it uses for configuration. * * @param props a Properties object to load the PropertyConsumer properties * into. If props equals null, then a new Properties object should be * created. * @return Properties object containing PropertyConsumer property values. If * getList was not null, this should equal getList. Otherwise, it * should be the Properties object created by the PropertyConsumer. */ public Properties getProperties(Properties props) { if (props == null) { props = new Properties(); } String prefix = PropUtils.getScopedPropertyPrefix(this); if (linePaint instanceof Color) { props.put(prefix + linePaintProperty, PropUtils.getProperty((Color) linePaint)); } // if (textPaint instanceof Color) { // props.put(prefix + textPaintProperty, // PropUtils.getProperty((Color)textPaint)); // } if (fillPaint instanceof Color) { props.put(prefix + fillPaintProperty, PropUtils.getProperty((Color) fillPaint)); } if (selectPaint instanceof Color) { props.put(prefix + selectPaintProperty, PropUtils.getProperty((Color) selectPaint)); } if (mattingPaint instanceof Color) { props.put(prefix + mattingPaintProperty, PropUtils.getProperty((Color) mattingPaint)); } props.put(prefix + PointRadiusProperty, Integer.toString(pointRadius)); props.put(prefix + PointOvalProperty, new Boolean(pointOval).toString()); props.put(prefix + fillPatternProperty, (fPattern == null ? "" : fPattern)); Stroke bs = getStroke(); if (bs == null) { bs = new BasicStroke(); } if (bs instanceof BasicStroke) { props.put(prefix + lineWidthProperty, Float.toString(((BasicStroke) bs).getLineWidth())); float[] fa = ((BasicStroke) bs).getDashArray(); if (fa != null) { StringBuffer dp = new StringBuffer(); for (int i = 0; i < fa.length; i++) { dp.append(" " + Float.toString(fa[i])); } props.put(prefix + dashPatternProperty, dp.toString()); props.put(prefix + dashPhaseProperty, Float.toString(((BasicStroke) bs).getDashPhase())); } else { props.put(prefix + dashPatternProperty, ""); props.put(prefix + dashPhaseProperty, ""); } } if (baseScale != NONE) { props.put(prefix + baseScaleProperty, Float.toString(baseScale)); } props.put(prefix + mattedProperty, new Boolean(matted).toString()); return props; } /** * Method to fill in a Properties object with values reflecting the * properties able to be set on this PropertyConsumer. The key for each * property should be the raw property name (without a prefix) with a value * that is a String that describes what the property key represents, along * with any other information about the property that would be helpful * (range, default value, etc.). * * @param list a Properties object to load the PropertyConsumer properties * into. If getList equals null, then a new Properties object should * be created. * @return Properties object containing PropertyConsumer property values. If * getList was not null, this should equal getList. Otherwise, it * should be the Properties object created by the PropertyConsumer. */ public Properties getPropertyInfo(Properties list) { if (list == null) { list = new Properties(); } String interString; interString = i18n.get(DrawingAttributes.class, linePaintProperty, I18n.TOOLTIP, "Edge color for graphics."); list.put(linePaintProperty, interString); interString = i18n.get(DrawingAttributes.class, linePaintProperty, linePaintProperty); list.put(linePaintProperty + LabelEditorProperty, interString); list.put(linePaintProperty + ScopedEditorProperty, "com.bbn.openmap.util.propertyEditor.ColorPropertyEditor"); // list.put(textPaintProperty, "Text color for graphics."); // list.put(textPaintProperty + ScopedEditorProperty, // "com.bbn.openmap.util.propertyEditor.ColorPropertyEditor"); interString = i18n.get(DrawingAttributes.class, fillPaintProperty, I18n.TOOLTIP, "Fill color for graphics."); list.put(fillPaintProperty, interString); interString = i18n.get(DrawingAttributes.class, fillPaintProperty, fillPaintProperty); list.put(fillPaintProperty + LabelEditorProperty, interString); list.put(fillPaintProperty + ScopedEditorProperty, "com.bbn.openmap.util.propertyEditor.ColorPropertyEditor"); interString = i18n.get(DrawingAttributes.class, selectPaintProperty, I18n.TOOLTIP, "Selected edge color for graphics."); list.put(selectPaintProperty, interString); interString = i18n.get(DrawingAttributes.class, selectPaintProperty, selectPaintProperty); list.put(selectPaintProperty + LabelEditorProperty, interString); list.put(selectPaintProperty + ScopedEditorProperty, "com.bbn.openmap.util.propertyEditor.ColorPropertyEditor"); interString = i18n.get(DrawingAttributes.class, mattingPaintProperty, I18n.TOOLTIP, "Matting edge color for graphics."); list.put(mattingPaintProperty, interString); interString = i18n.get(DrawingAttributes.class, mattingPaintProperty, mattingPaintProperty); list.put(mattingPaintProperty + LabelEditorProperty, interString); list.put(mattingPaintProperty + ScopedEditorProperty, "com.bbn.openmap.util.propertyEditor.ColorPropertyEditor"); interString = i18n.get(DrawingAttributes.class, fillPatternProperty, I18n.TOOLTIP, "Image file to use for fill pattern for graphics (optional)."); list.put(fillPatternProperty, interString); interString = i18n.get(DrawingAttributes.class, fillPatternProperty, fillPatternProperty); list.put(fillPatternProperty + LabelEditorProperty, interString); list.put(fillPatternProperty + ScopedEditorProperty, "com.bbn.openmap.util.propertyEditor.FUPropertyEditor"); interString = i18n.get(DrawingAttributes.class, lineWidthProperty, I18n.TOOLTIP, "Line width for edges of graphics"); list.put(lineWidthProperty, interString); interString = i18n.get(DrawingAttributes.class, lineWidthProperty, lineWidthProperty); list.put(lineWidthProperty + LabelEditorProperty, interString); // list.put(dashPatternProperty, "<HTML><BODY>Line dash // pattern, represented by<br>space separated numbers<br> (on // off on ...)</BODY></HTML>"); interString = i18n.get(DrawingAttributes.class, dashPatternProperty, I18n.TOOLTIP, "Line dash pattern, represented by space separated numbers (on off on ...)"); list.put(dashPatternProperty, interString); interString = i18n.get(DrawingAttributes.class, dashPatternProperty, dashPatternProperty); list.put(dashPatternProperty + LabelEditorProperty, interString); interString = i18n.get(DrawingAttributes.class, dashPhaseProperty, I18n.TOOLTIP, "Phase for dash pattern (Default is 0)"); list.put(dashPhaseProperty, interString); interString = i18n.get(DrawingAttributes.class, dashPhaseProperty, dashPhaseProperty); list.put(dashPhaseProperty + LabelEditorProperty, interString); interString = i18n.get(DrawingAttributes.class, baseScaleProperty, I18n.TOOLTIP, "<HTML><BODY>Scale which should be used as the base scale for the <br>patterns and line width. If set, size of pattern and <br>widths will be adjusted to the map scale</BODY></HTML>"); list.put(baseScaleProperty, interString); interString = i18n.get(DrawingAttributes.class, baseScaleProperty, baseScaleProperty); list.put(baseScaleProperty + LabelEditorProperty, interString); interString = i18n.get(DrawingAttributes.class, mattedProperty, I18n.TOOLTIP, "Flag to enable a thin black matting to be drawn around graphics."); list.put(mattedProperty, interString); interString = i18n.get(DrawingAttributes.class, mattedProperty, mattedProperty); list.put(mattedProperty + LabelEditorProperty, interString); list.put(mattedProperty + ScopedEditorProperty, "com.bbn.openmap.util.propertyEditor.OnOffPropertyEditor"); interString = i18n.get(DrawingAttributes.class, PointRadiusProperty, I18n.TOOLTIP, "Pixel radius of point obje
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?