45 |
import java.net.URL; |
import java.net.URL; |
46 |
import java.text.DecimalFormat; |
import java.text.DecimalFormat; |
47 |
import java.util.ArrayList; |
import java.util.ArrayList; |
48 |
|
import java.util.Collections; |
49 |
import java.util.List; |
import java.util.List; |
50 |
import java.util.Map; |
import java.util.Map; |
51 |
import java.util.Set; |
import java.util.Set; |
85 |
import org.opengis.feature.type.AttributeDescriptor; |
import org.opengis.feature.type.AttributeDescriptor; |
86 |
import org.opengis.feature.type.GeometryDescriptor; |
import org.opengis.feature.type.GeometryDescriptor; |
87 |
import org.opengis.feature.type.Name; |
import org.opengis.feature.type.Name; |
88 |
|
import org.opengis.filter.FilterFactory2; |
89 |
import org.opengis.parameter.GeneralParameterValue; |
import org.opengis.parameter.GeneralParameterValue; |
90 |
|
|
91 |
|
import schmitzm.geotools.FilterUtil; |
92 |
import schmitzm.geotools.JTSUtil; |
import schmitzm.geotools.JTSUtil; |
93 |
import schmitzm.geotools.feature.FeatureUtil; |
import schmitzm.geotools.feature.FeatureUtil; |
94 |
import schmitzm.geotools.styling.StylingUtil; |
import schmitzm.geotools.styling.StylingUtil; |
118 |
private static final SAXBuilder SAX_BUILDER = new SAXBuilder(); |
private static final SAXBuilder SAX_BUILDER = new SAXBuilder(); |
119 |
private static final XMLOutputter XML_OUTPUTTER = new XMLOutputter(); |
private static final XMLOutputter XML_OUTPUTTER = new XMLOutputter(); |
120 |
|
|
121 |
|
/** |
122 |
|
* Is appended to the name of a rule, this rule shall not be shown in the |
123 |
|
* legend |
124 |
|
*/ |
125 |
|
public final static String HIDE_IN_LAYER_LEGEND_HINT = "HIDE_IN_LEGEND"; |
126 |
|
|
127 |
/** URL for Atlas XML schema */ |
/** URL for Atlas XML schema */ |
128 |
public static final String AMLURI = "http://www.wikisquare.de/AtlasML"; |
public static final String AMLURI = "http://www.wikisquare.de/AtlasML"; |
129 |
/** Name of the XML Element for the attribute meta data map */ |
/** Name of the XML Element for the attribute meta data map */ |
136 |
public static final String ELEM_NAME_RASTERLEGEND = "rasterLegendItem"; |
public static final String ELEM_NAME_RASTERLEGEND = "rasterLegendItem"; |
137 |
/** Name of the XML Element for a translation */ |
/** Name of the XML Element for a translation */ |
138 |
public static final String ELEM_NAME_TRANSLATION = "translation"; |
public static final String ELEM_NAME_TRANSLATION = "translation"; |
139 |
|
private static FilterFactory2 ff = FilterUtil.FILTER_FAC2; |
140 |
|
|
141 |
/** |
/** |
142 |
* Creates a Geotools {@link MapLayer} from an object. If the object is a |
* Creates a Geotools {@link MapLayer} from an object. If the object is a |
935 |
} |
} |
936 |
|
|
937 |
/** |
/** |
|
* *If appended to the name of a rule, this rule shall not be shown in the |
|
|
* legend |
|
|
*/ |
|
|
public final static String HIDE_IN_LAYER_LEGEND_HINT = "HIDE_IN_LEGEND"; |
|
|
|
|
|
/** |
|
938 |
* Creates a {@link JPanel} that shows a legend for a list of |
* Creates a {@link JPanel} that shows a legend for a list of |
939 |
* {@link FeatureTypeStyle}s and a targeted featureType |
* {@link FeatureTypeStyle}s and a targeted featureType |
940 |
* |
* |
941 |
* @param style |
* @param style |
942 |
* The Style to presented in this legend |
* The Style to presented in this legend |
943 |
* @param featureType |
* @param featureType |
944 |
* If this a legend for Point, Polygon or Line? |
* If this a legend for Point, Polygon or Line? Or ANY or NONE? |
945 |
* |
* |
946 |
* @author <a href="mailto:[email protected]">Stefan Alfons Tzeggai</a> |
* @author <a href="mailto:[email protected]">Stefan Alfons Tzeggai</a> |
947 |
*/ |
*/ |
955 |
return new JPanel(); |
return new JPanel(); |
956 |
} |
} |
957 |
|
|
|
final List<FeatureTypeStyle> list = style.featureTypeStyles(); |
|
|
|
|
958 |
final JPanel panel = new JPanel(new MigLayout("wrap 2", "[]:3:[]")); |
final JPanel panel = new JPanel(new MigLayout("wrap 2", "[]:3:[]")); |
|
|
|
959 |
if (style == null) { |
if (style == null) { |
960 |
// No Style => no legend |
// No Style => no legend |
961 |
return panel; |
return panel; |
962 |
} |
} |
963 |
|
|
964 |
for (final FeatureTypeStyle ftStyle : list) { |
// Reversing the list, because a point that is painted above a polygon |
965 |
|
// should be higher in the list. |
966 |
|
final List<FeatureTypeStyle> ftsList = style.featureTypeStyles(); |
967 |
|
Collections.reverse(ftsList); |
968 |
|
for (final FeatureTypeStyle ftStyle : ftsList) { |
969 |
|
|
970 |
|
// // Try to import the FeatureType into an AtlasStyler RuleList to |
971 |
|
// // determine whether this RL is actually disabled. |
972 |
|
// StylingUtil.sldToString(ftStyle).contains(RL_DISABLED_FILTER.toString()) |
973 |
|
// return; |
974 |
|
|
975 |
// One child-node for every rule |
// One child-node for every rule |
976 |
final List<Rule> rules = ftStyle.rules(); |
final List<Rule> rules = ftStyle.rules(); |
978 |
|
|
979 |
// Check if this RULE shall actually appear in the legend |
// Check if this RULE shall actually appear in the legend |
980 |
if (rule.getName() != null |
if (rule.getName() != null |
981 |
&& rule.getName().endsWith(HIDE_IN_LAYER_LEGEND_HINT)) |
&& rule.getName().contains(HIDE_IN_LAYER_LEGEND_HINT)) |
982 |
continue; |
continue; |
983 |
|
|
984 |
/** |
/** |
1191 |
throw new RuntimeException("need a reader..."); |
throw new RuntimeException("need a reader..."); |
1192 |
// |
// |
1193 |
|
|
1194 |
final GridCoverage2D cov = (GridCoverage2D) aReader |
final GridCoverage2D cov = aReader |
1195 |
.read(new GeneralParameterValue[] { readGG }); |
.read(new GeneralParameterValue[] { readGG }); |
1196 |
colorModel = cov.getRenderedImage().getColorModel(); |
colorModel = cov.getRenderedImage().getColorModel(); |
1197 |
} |
} |