Color fromColor = new Color(
Integer.parseInt(colorRules[i][0]),
Integer.parseInt(colorRules[i][1]),
Integer.parseInt(colorRules[i][2]));
ColorMapEntryImpl cme = new ColorMapEntryImpl();
cme.setColor((Expression) builder.literal(fromColor)
.build());
cme.setQuantity((Expression) builder.literal(from)
.build());
cm.addColorMapEntry(cme);
}
ColorMapEntryImpl cme = new ColorMapEntryImpl();
cme.setColor((Expression) builder.literal(toColor).build());
cme.setQuantity((Expression) builder.literal(to).build());
cm.addColorMapEntry(cme);
} catch (NumberFormatException e) {
SLDPlugin.log(e.getMessage(), e);
continue;
}
}
} else {
/*
* in this case we have also the values for the range defined and
* the color rule has to be "v1 r1 g1 b1 v2 r2 g2 b2".
*/
if (colorRules[0].length != 8) {
throw new IOException(
"The colortable can have records of 3 or 8 columns. Check your colortables."); //$NON-NLS-1$
}
for (int i = 0; i < colorRules.length; i++) {
try {
double to = Double.parseDouble(colorRules[i][4]);
Color toColor = new Color(
Integer.parseInt(colorRules[i][5]),
Integer.parseInt(colorRules[i][6]),
Integer.parseInt(colorRules[i][7]));
if (i == 0) {
double from = Double.parseDouble(colorRules[i][0]);
Color fromColor = new Color(
Integer.parseInt(colorRules[i][1]),
Integer.parseInt(colorRules[i][2]),
Integer.parseInt(colorRules[i][3]));
ColorMapEntryImpl cme = new ColorMapEntryImpl();
cme.setColor((Expression) builder.literal(fromColor)
.build());
cme.setQuantity((Expression) builder.literal(from)
.build());
cm.addColorMapEntry(cme);
}
ColorMapEntryImpl cme = new ColorMapEntryImpl();
cme.setColor((Expression) builder.literal(toColor).build());
cme.setQuantity((Expression) builder.literal(to).build());
cm.addColorMapEntry(cme);
} catch (NumberFormatException e) {
SLDPlugin.log(e.getMessage(), e);
continue;
}