909 |
|
|
910 |
final List<FeatureTypeStyle> list = style.featureTypeStyles(); |
final List<FeatureTypeStyle> list = style.featureTypeStyles(); |
911 |
|
|
912 |
final JPanel panel = new JPanel(new MigLayout("wrap 2","[]:3:[]")); |
final JPanel panel = new JPanel(new MigLayout("wrap 2", "[]:3:[]")); |
913 |
|
|
914 |
if (style == null) { |
if (style == null) { |
915 |
// No Style => no legend |
// No Style => no legend |
937 |
final ImageIcon legendIcon = new ImageIcon(imageForRule); |
final ImageIcon legendIcon = new ImageIcon(imageForRule); |
938 |
|
|
939 |
final JLabel iconLabel = new JLabel(legendIcon); |
final JLabel iconLabel = new JLabel(legendIcon); |
940 |
panel.add(iconLabel,"sgx1"); |
panel.add(iconLabel, "sgx1"); |
941 |
// hbox.setAlignmentX(0f); |
// hbox.setAlignmentX(0f); |
942 |
// hbox.add(iconLabel); |
// hbox.add(iconLabel); |
943 |
// hbox.add(Box.createHorizontalStrut(3)); |
// hbox.add(Box.createHorizontalStrut(3)); |
944 |
|
|
945 |
final Translation labelT = new Translation(); |
final Translation labelT = new Translation(); |
946 |
labelT.fromOneLine(rule.getDescription().getTitle()); |
labelT.fromOneLine(rule.getDescription().getTitle()); |
947 |
final JLabel classTitleLabel = new JLabel(labelT.toString()); |
final JLabel classTitleLabel = new JLabel(labelT.toString()); |
948 |
|
|
949 |
panel.add(classTitleLabel,"sgx2"); |
panel.add(classTitleLabel, "sgx2"); |
950 |
classTitleLabel.setLabelFor(iconLabel); |
classTitleLabel.setLabelFor(iconLabel); |
951 |
} |
} |
952 |
} |
} |
1000 |
// **************************************************************************** |
// **************************************************************************** |
1001 |
final BufferedImage buffImage = new BufferedImage(iconWidth, |
final BufferedImage buffImage = new BufferedImage(iconWidth, |
1002 |
iconHeight, BufferedImage.TYPE_INT_ARGB); |
iconHeight, BufferedImage.TYPE_INT_ARGB); |
1003 |
|
|
1004 |
final Graphics2D graphics = buffImage.createGraphics(); |
final Graphics2D graphics = buffImage.createGraphics(); |
1005 |
|
|
1006 |
if (colorModel != null) { |
if (colorModel != null) { |
1007 |
// The colors come from the ColorModel! |
// The colors come from the ColorModel! |
1008 |
|
|
1009 |
try { |
try { |
1010 |
Object inData = null; |
Object inData = null; |
1011 |
switch (colorModel.getTransferType()) { |
switch (colorModel.getTransferType()) { |
1075 |
} |
} |
1076 |
|
|
1077 |
final JLabel iconLabel = new JLabel(new ImageIcon(buffImage)); |
final JLabel iconLabel = new JLabel(new ImageIcon(buffImage)); |
1078 |
// hbox.setAlignmentX(0f); |
// hbox.setAlignmentX(0f); |
1079 |
panel.add(iconLabel,"sgx1"); |
panel.add(iconLabel, "sgx1"); |
1080 |
// hbox.add(Box.createHorizontalStrut(3)); |
// hbox.add(Box.createHorizontalStrut(3)); |
1081 |
|
|
1082 |
final Translation labelT = rasterLegendData.get(rValue); |
final Translation labelT = rasterLegendData.get(rValue); |
1083 |
final JLabel classTitleLabel = new JLabel(labelT.toString()); |
final JLabel classTitleLabel = new JLabel(labelT.toString()); |
1084 |
panel.add(classTitleLabel,"sgx2" + (rasterLegendData.getPaintGaps()? ", gapy 0 3":"")); |
panel.add(classTitleLabel, "sgx2" |
1085 |
|
+ (rasterLegendData.getPaintGaps() ? ", gapy 0 3" : "")); |
1086 |
classTitleLabel.setLabelFor(iconLabel); |
classTitleLabel.setLabelFor(iconLabel); |
1087 |
|
|
1088 |
// box.add(hbox); |
// box.add(hbox); |
1089 |
|
|
1090 |
if (rasterLegendData.getPaintGaps()) { |
if (rasterLegendData.getPaintGaps()) { |
1091 |
iconLabel |
iconLabel |
1145 |
public static boolean isStyleable( |
public static boolean isStyleable( |
1146 |
final StyledRasterInterface<?> styledRaster) { |
final StyledRasterInterface<?> styledRaster) { |
1147 |
final ColorModel colorModel = getColorModel(styledRaster); |
final ColorModel colorModel = getColorModel(styledRaster); |
1148 |
|
|
1149 |
LOGGER.info("The colormodel of " + styledRaster.getTitle() + " is " |
// LOGGER.info("The colormodel of " + styledRaster.getTitle() + " is " |
1150 |
+ colorModel.getClass().getSimpleName()); |
// + colorModel != null ? colorModel.getClass().getSimpleName() : "NULL"); |
1151 |
|
|
1152 |
if (colorModel == null) |
if (colorModel == null) |
1153 |
return true; |
return true; |
1155 |
return true; |
return true; |
1156 |
return false; |
return false; |
1157 |
} |
} |
1158 |
|
|
1159 |
|
/** |
1160 |
|
* Set the given Style as the Style of the {@link MapLayer}, unless the |
1161 |
|
* styles are the same (not comparing selection stuff). If the |
1162 |
|
* {@link MapLayer}s {@link Style} is changed, the selection FTS is kept.<br/> |
1163 |
|
* Remember {@link MapLayer#setStyle(Style)} triggers an event leading to a |
1164 |
|
* repaint, so only use it when needed. |
1165 |
|
* |
1166 |
|
* @return <code>true</code> if the {@link MapLayer}'s {@link Style} has been changed. |
1167 |
|
*/ |
1168 |
|
public static boolean updateMapLayerStyleIfChangedAndKeepSelection(MapLayer mapLayer, |
1169 |
|
Style style2) { |
1170 |
|
|
1171 |
|
Style mapLayerStyleCleaned = StylingUtil |
1172 |
|
.removeSelectionFeatureTypeStyle(mapLayer.getStyle()); |
1173 |
|
|
1174 |
|
Style newStyleCleaned = StylingUtil.removeSelectionFeatureTypeStyle(style2); |
1175 |
|
|
1176 |
|
if (StylingUtil.isStyleDifferent(mapLayerStyleCleaned, |
1177 |
|
newStyleCleaned)) { |
1178 |
|
|
1179 |
|
// They are different when compared without SELECTION FTS! |
1180 |
|
|
1181 |
|
// Now let's copy any SELECTION FTS to the now style |
1182 |
|
FeatureTypeStyle selectionFeatureTypeStyle = StylingUtil.getSelectionFeatureTypeStyle( mapLayer.getStyle() ); |
1183 |
|
if (selectionFeatureTypeStyle != null) { |
1184 |
|
newStyleCleaned.featureTypeStyles().add(selectionFeatureTypeStyle); |
1185 |
|
// newStyleCleaned is not so clean anymore... We just alled a selcetion FTS |
1186 |
|
} |
1187 |
|
|
1188 |
|
mapLayer.setStyle(newStyleCleaned); |
1189 |
|
|
1190 |
|
return true; |
1191 |
|
|
1192 |
|
} else { |
1193 |
|
return false; |
1194 |
|
} |
1195 |
|
} |
1196 |
|
|
1197 |
} |
} |