root / org.gvsig.legend.aggregate / trunk / org.gvsig.legend.aggregate / org.gvsig.legend.aggregate.lib / org.gvsig.legend.aggregate.lib.impl / src / main / java / org / gvsig / legend / aggregate / lib / impl / DefaultAggregateLegendManager.java @ 1848
History | View | Annotate | Download (3.66 KB)
1 |
/* gvSIG. Desktop Geographic Information System.
|
---|---|
2 |
*
|
3 |
* Copyright ? 2007-2015 gvSIG Association
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
18 |
* MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
package org.gvsig.legend.aggregate.lib.impl; |
24 |
|
25 |
import java.util.Collection; |
26 |
import java.util.HashMap; |
27 |
import java.util.Map; |
28 |
import org.gvsig.fmap.mapcontext.rendering.symbols.styles.ILabelStyle; |
29 |
import org.gvsig.legend.aggregate.lib.api.AggregateLegend; |
30 |
import org.gvsig.legend.aggregate.lib.api.AggregateLegendManager; |
31 |
import org.gvsig.legend.aggregate.lib.api.Operation; |
32 |
import org.gvsig.legend.aggregate.lib.impl.operation.AvgOperation; |
33 |
import org.gvsig.legend.aggregate.lib.impl.operation.CountOperation; |
34 |
import org.gvsig.legend.aggregate.lib.impl.operation.MaxOperation; |
35 |
import org.gvsig.legend.aggregate.lib.impl.operation.MinOperation; |
36 |
import org.gvsig.legend.aggregate.lib.impl.operation.SumOperation; |
37 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.SimpleLabelStyle; |
38 |
|
39 |
|
40 |
public class DefaultAggregateLegendManager implements AggregateLegendManager { |
41 |
|
42 |
private ILabelStyle defaultLabelStyle = null; |
43 |
private Map<String,Operation> operations; |
44 |
private Operation defaultOperation = null; |
45 |
|
46 |
public DefaultAggregateLegendManager() {
|
47 |
this.defaultLabelStyle = new SimpleLabelStyle(); |
48 |
this.addOperation(new CountOperation()); |
49 |
this.addOperation(new MinOperation()); |
50 |
this.addOperation(new MaxOperation()); |
51 |
this.addOperation(new AvgOperation()); |
52 |
this.addOperation(new SumOperation()); |
53 |
} |
54 |
|
55 |
@Override
|
56 |
public AggregateLegend createAggregateLegend() {
|
57 |
return new DefaultAggregateLegend(); |
58 |
} |
59 |
|
60 |
@Override
|
61 |
public Class<? extends AggregateLegend> getLegendClass() { |
62 |
return DefaultAggregateLegend.class;
|
63 |
} |
64 |
|
65 |
@Override
|
66 |
public ILabelStyle getDefaultLabelStyle() {
|
67 |
return this.defaultLabelStyle; |
68 |
} |
69 |
|
70 |
@Override
|
71 |
public void setDefaultLabelStyle(ILabelStyle defaultLabelStyle) { |
72 |
this.defaultLabelStyle = defaultLabelStyle;
|
73 |
} |
74 |
|
75 |
@Override
|
76 |
public void addOperation(Operation operation) { |
77 |
if( this.operations == null ) { |
78 |
this.operations = new HashMap<>(); |
79 |
} |
80 |
if( this.operations.isEmpty() ) { |
81 |
this.defaultOperation = operation;
|
82 |
} |
83 |
this.operations.put(operation.getName(),operation);
|
84 |
} |
85 |
|
86 |
@Override
|
87 |
public Collection<Operation> getOperations() { |
88 |
if( this.operations == null ) { |
89 |
this.operations = new HashMap<>(); |
90 |
} |
91 |
return this.operations.values(); |
92 |
} |
93 |
|
94 |
@Override
|
95 |
public Operation getDefaultOperation() { |
96 |
return this.defaultOperation; |
97 |
} |
98 |
|
99 |
@Override
|
100 |
public Operation createOperation(String name) { |
101 |
Operation op = this.operations.get(name); |
102 |
if( op == null ) { |
103 |
throw new IllegalArgumentException("Can't locate operation '"+name+"'."); |
104 |
} |
105 |
return op.clone();
|
106 |
} |
107 |
|
108 |
|
109 |
} |