public void setProperties(String prefix, Properties props) {  propertyChangeSupport = new PropertyChangeSupport(this); setPropertyPrefix(prefix);  if (props == null) { return; }  String realPrefix = PropUtils.getScopedPropertyPrefix(prefix);   linePaint = PropUtils.parseColorFromProperties(props, realPrefix + linePaintProperty, linePaint);  selectPaint = PropUtils.parseColorFromProperties(props, realPrefix + selectPaintProperty, selectPaint);  mattingPaint = PropUtils.parseColorFromProperties(props, realPrefix + mattingPaintProperty, mattingPaint);       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);   String dPattern = props.getProperty(realPrefix + dashPatternProperty); if (basicStrokeDefined && dPattern != null && !dPattern.equals("")) { float dashPhase; float[] lineDash;  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)); }   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; } }
public void setProperties(java.util.Properties props) { setProperties(getPropertyPrefix(), props);
    public void setProperties(String prefix, Properties props) {        propertyChangeSupport = new PropertyChangeSupport(this);        setPropertyPrefix(prefix);        if (props == null) {            return;        }        String realPrefix = PropUtils.getScopedPropertyPrefix(prefix);        //  Set up the drawing attributes.        linePaint =            PropUtils.parseColorFromProperties(props, realPrefix + linePaintProperty,                                                linePaint);                selectPaint =            PropUtils.parseColorFromProperties(props, realPrefix + selectPaintProperty,                                                selectPaint);        mattingPaint =            PropUtils.parseColorFromProperties(props, realPrefix + mattingPaintProperty,                                                mattingPaint);        //      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;            }        }    }