Revision 43326 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/main/java/org/gvsig/symbology/fmap/mapcontext/rendering/legend/impl/SingleSymbolLegend.java
SingleSymbolLegend.java | ||
---|---|---|
12 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | 14 |
* GNU General Public License for more details. |
15 |
* |
|
15 |
|
|
16 | 16 |
* You should have received a copy of the GNU General Public License |
17 | 17 |
* along with this program; if not, write to the Free Software |
18 | 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
... | ... | |
32 | 32 |
import org.gvsig.fmap.mapcontext.rendering.legend.ISingleSymbolLegend; |
33 | 33 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.SymbolLegendEvent; |
34 | 34 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
35 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol; |
|
36 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.MultiShapeSymbol; |
|
37 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol; |
|
38 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol; |
|
39 | 35 |
import org.gvsig.tools.ToolsLocator; |
40 | 36 |
import org.gvsig.tools.dynobject.DynStruct; |
41 | 37 |
import org.gvsig.tools.persistence.PersistenceManager; |
... | ... | |
48 | 44 |
/** |
49 | 45 |
* Implements a legend composed by single symbols. |
50 | 46 |
* |
51 |
* @author Vicente Caballero Navarro |
|
52 |
* @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team |
|
53 | 47 |
*/ |
54 | 48 |
public class SingleSymbolLegend extends AbstractVectorialLegend implements |
55 | 49 |
ISingleSymbolLegend { |
... | ... | |
80 | 74 |
} |
81 | 75 |
|
82 | 76 |
|
77 |
@Override |
|
83 | 78 |
public void setDefaultSymbol(ISymbol s) { |
84 |
if (s == null) throw new NullPointerException("Default symbol cannot be null"); |
|
79 |
if (s == null) { |
|
80 |
throw new NullPointerException("Default symbol cannot be null"); |
|
81 |
} |
|
85 | 82 |
ISymbol old = defaultSymbol; |
86 | 83 |
defaultSymbol = s; |
87 | 84 |
fireDefaultSymbolChangedEvent(new SymbolLegendEvent(old, s)); |
... | ... | |
92 | 89 |
return defaultSymbol; |
93 | 90 |
} |
94 | 91 |
|
92 |
@Override |
|
95 | 93 |
public ISymbol getDefaultSymbol() { |
96 | 94 |
if(defaultSymbol==null) { |
97 | 95 |
defaultSymbol = getSymbolManager().createSymbol(shapeType); |
... | ... | |
101 | 99 |
|
102 | 100 |
|
103 | 101 |
|
102 |
@Override |
|
104 | 103 |
public int getShapeType() { |
105 | 104 |
return shapeType; |
106 | 105 |
} |
107 | 106 |
|
107 |
@Override |
|
108 | 108 |
public void setShapeType(int shapeType) { |
109 | 109 |
if (this.shapeType != shapeType) { |
110 | 110 |
if(defaultSymbol==null || defaultSymbol.getSymbolType()!=shapeType){ |
... | ... | |
114 | 114 |
} |
115 | 115 |
} |
116 | 116 |
|
117 |
@Override |
|
117 | 118 |
public ISymbol getSymbolByFeature(Feature feat) { |
118 | 119 |
return getDefaultSymbol(); |
119 | 120 |
} |
120 | 121 |
|
122 |
@Override |
|
121 | 123 |
public void useDefaultSymbol(boolean b) { |
122 | 124 |
LOG.warn("TODO: SingleSymbolLegend.useDefaultSymbol"); |
123 | 125 |
} |
... | ... | |
126 | 128 |
return new String[0]; |
127 | 129 |
} |
128 | 130 |
|
131 |
@Override |
|
129 | 132 |
public boolean isUseDefaultSymbol() { |
130 | 133 |
return true; |
131 | 134 |
|
... | ... | |
136 | 139 |
return getClass().getName(); |
137 | 140 |
} |
138 | 141 |
|
142 |
@Override |
|
139 | 143 |
public boolean isSuitableForShapeType(int shapeType) { |
140 | 144 |
return getShapeType() == shapeType; |
141 | 145 |
} |
... | ... | |
145 | 149 |
LOG.warn("TODO: SingleSymbolLegend.useDefaultSymbol"); |
146 | 150 |
} |
147 | 151 |
|
152 |
@Override |
|
148 | 153 |
protected String[] getRequiredFeatureAttributeNames( |
149 | 154 |
FeatureStore featureStore) throws DataException { |
150 | 155 |
// We only need the default Geometry to draw |
151 |
return new String[] { featureStore |
|
152 |
.getDefaultFeatureType().getDefaultGeometryAttributeName() }; |
|
156 |
return new String[] { featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName() }; |
|
153 | 157 |
} |
154 | 158 |
|
159 |
@Override |
|
155 | 160 |
public Object clone() throws CloneNotSupportedException { |
156 | 161 |
SingleSymbolLegend clone = (SingleSymbolLegend) super.clone(); |
157 | 162 |
|
... | ... | |
163 | 168 |
return clone; |
164 | 169 |
} |
165 | 170 |
|
171 |
@Override |
|
166 | 172 |
public void loadFromState(PersistentState state) |
167 | 173 |
throws PersistenceException { |
168 |
// Set parent properties |
|
169 | 174 |
super.loadFromState(state); |
170 |
// LOG.warn("FIXME: SingleSymbolLegend.loadFromState"); |
|
171 | 175 |
} |
172 | 176 |
|
177 |
@Override |
|
173 | 178 |
public void saveToState(PersistentState state) throws PersistenceException { |
174 |
// Save parent properties |
|
175 | 179 |
super.saveToState(state); |
176 |
// LOG.warn("FIXME: SingleSymbolLegend.saveToState"); |
|
177 | 180 |
} |
178 | 181 |
|
179 | 182 |
public static class RegisterPersistence implements Callable { |
180 | 183 |
|
184 |
@Override |
|
181 | 185 |
public Object call() throws Exception { |
182 | 186 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
183 | 187 |
if( manager.getDefinition(SINGLE_SYMBOL_PERSISTENCE_DEFINITION_NAME)==null ) { |
... | ... | |
198 | 202 |
|
199 | 203 |
public static class RegisterLegend implements Callable { |
200 | 204 |
|
205 |
@Override |
|
201 | 206 |
public Object call() throws Exception { |
202 | 207 |
MapContextManager manager = MapContextLocator.getMapContextManager(); |
203 | 208 |
|
Also available in: Unified diff