001: /*
002: * uDig - User Friendly Desktop Internet GIS client http://udig.refractions.net (C) 2004,
003: * Refractions Research Inc. This library is free software; you can redistribute it and/or modify it
004: * under the terms of the GNU Lesser General Public License as published by the Free Software
005: * Foundation; version 2.1 of the License. This library is distributed in the hope that it will be
006: * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
007: * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
008: */
009: package net.refractions.udig.style.sld.internal;
010:
011: import java.awt.Color;
012:
013: import org.eclipse.swt.SWT;
014: import org.eclipse.ui.IMemento;
015: import org.geotools.styling.Style;
016: import org.geotools.styling.StyleBuilder;
017: import org.geotools.styling.Symbolizer;
018:
019: /**
020: * Seems to be a mess of defaults?
021: *
022: * @author jgarnett
023: * @since 0.6.0
024: */
025: public class SymbolizerContent {
026: //
027: /** <code>ID</code> field */
028: public static final String ID = "net.refractions.udig.style.sld.symbolizer"; //$NON-NLS-1$
029:
030: static final String TAG_TYPE = "featureType"; //$NON-NLS-1$
031: static final String TAG_LABEL = "text_label"; //$NON-NLS-1$
032: static final String TAG_FONT = "text_font"; //$NON-NLS-1$
033: static final String TAG_HALO = "text_halo"; //$NON-NLS-1$
034:
035: /** <code>DEFAULT_LINE_COLOR</code> field */
036: public static final Color DEFAULT_LINE_COLOR = Color.BLUE;
037: /** <code>DEFAULT_LINE_WIDTH</code> field */
038: public static final int DEFAULT_LINE_WIDTH = 1;
039: /** <code>DEFAULT_LINE_OPACITY</code> field */
040: public static final float DEFAULT_LINE_OPACITY = 1.0f;
041: /** <code>DEFAULT_LINE_LINEJOIN</code> field */
042: public static final String DEFAULT_LINE_LINEJOIN = "mitre"; //$NON-NLS-1$
043: /** <code>DEFAULT_LINE_LINECAP</code> field */
044: public static final String DEFAULT_LINE_LINECAP = "butt"; //$NON-NLS-1$
045:
046: /** <code>DEFAULT_FILL_COLOR</code> field */
047: public static final Color DEFAULT_FILL_COLOR = Color.GREEN;
048: /** <code>DEFAULT_BORDER_COLOR</code> field */
049: public static final Color DEFAULT_BORDER_COLOR = Color.BLACK;
050: /** <code>DEFAULT_BORDER_WIDTH</code> field */
051: public static final int DEFAULT_BORDER_WIDTH = 1;
052: /** <code>DEFAULT_POLY_BORDER_OPACITY</code> field */
053: public static final float DEFAULT_POLY_BORDER_OPACITY = 1.0f;
054: /** <code>DEFAULT_POLY_FILL_OPACITY</code> field */
055: public static final float DEFAULT_POLY_FILL_OPACITY = 1.0f;
056:
057: /** <code>DEFAULT_MARKER_COLOR</code> field */
058: public static final Color DEFAULT_MARKER_COLOR = Color.RED;
059: /** <code>DEFAULT_MARKER_WIDTH</code> field */
060: public static final int DEFAULT_MARKER_WIDTH = 1;
061: /** <code>DEFAULT_MARKER_TYPE</code> field */
062: public static final String DEFAULT_MARKER_TYPE = StyleBuilder.MARK_CIRCLE;
063: /** <code>DEFAULT_MARKER_BORDER_OPACITY</code> field */
064: public static final float DEFAULT_MARKER_BORDER_OPACITY = 1.0f;
065: /** <code>DEFAULT_MARKER_OPACITY</code> field */
066: public static final float DEFAULT_MARKER_OPACITY = 1.0f;
067:
068: /** <code>DEFAULT_OPACITY</code> field */
069: public static final float DEFAULT_OPACITY = 1.0f;
070:
071: /** <code>DEFAULT_FONT_COLOR</code> field */
072: public static final Color DEFAULT_FONT_COLOR = Color.BLACK;
073: /** <code>DEFAULT_FONT_FACE</code> field */
074: public static final String DEFAULT_FONT_FACE = "Arial"; //$NON-NLS-1$
075: /** <code>DEFAULT_FONT_SIZE</code> field */
076: public static final int DEFAULT_FONT_SIZE = 10;
077: /** <code>DEFAULT_FONT_STYLE</code> field */
078: public static final int DEFAULT_FONT_STYLE = SWT.NORMAL;
079: /** <code>DEFAULT_HALO_COLOR</code> field */
080: public static final Color DEFAULT_HALO_COLOR = Color.GREEN;
081: /** <code>DEFAULT_HALO_OPACITY</code> field */
082: public static final float DEFAULT_HALO_OPACITY = 1.0f;
083: /** <code>DEFAULT_HALO_WIDTH</code> field */
084: public static final float DEFAULT_HALO_WIDTH = 1.0f;
085:
086: Class symbolizer;
087:
088: <T extends Symbolizer> SymbolizerContent(Class<T> symbolizer) {
089: this .symbolizer = symbolizer;
090: }
091:
092: /**
093: * Can we save this symbolizer?
094: *
095: * @param sym
096: * @return true if this TYPE manages the provided symbolizer
097: */
098: final boolean isManaged(Symbolizer sym) {
099: return symbolizer.isInstance(sym);
100: }
101:
102: /**
103: * Save provided symbolizer to the momento?
104: * <p>
105: * This delegates the actual saving to various content managers like SldPolygonContentManager.
106: * </p>
107: *
108: * @param momento
109: * @param sym
110: */
111: void save(IMemento momento, Symbolizer sym) {
112: // momento.putInteger(TAG_TYPE, this.ordinal());
113: }
114:
115: /**
116: * Load previously saved symbolizer from a momento?
117: * <p>
118: * This delegates the actual load to various content managers like SldPolygonContentManager.
119: * </p>
120: *
121: * @param momento
122: * @return Symbolizer
123: */
124: public Symbolizer load(IMemento momento) {
125: return null; // could not handle
126: }
127:
128: /**
129: * Create the default Style (w/ Symbolizer for this thing)
130: *
131: * @return a style with some defaults set
132: */
133: public Style defaultStyle() {
134: return null;
135: }
136: }
|