use of au.org.ala.legend.LegendObject in project spatial-portal by AtlasOfLivingAustralia.
the class LayerLegendGeneralComposer method updateAnimationDiv.
private void updateAnimationDiv() {
if (dblAnimationSeconds == null) {
return;
}
Query q = mapLayer.getSpeciesQuery();
if (q instanceof BiocacheQuery) {
Integer firstYear = mapLayer.getFirstYear();
Integer lastYear = mapLayer.getLastYear();
if (firstYear == null) {
try {
LegendObject lo = q.getLegend(StringConstants.OCCURRENCE_YEAR);
if (lo != null && lo.getMinMax().length > 0) {
firstYear = (int) lo.getMinMax()[0];
lastYear = (int) lo.getMinMax()[1];
mapLayer.setFirstYear(firstYear);
mapLayer.setLastYear(lastYear);
}
} catch (Exception e) {
// this will fail if there are no records
}
}
Integer step = mapLayer.getAnimationStep();
if (step != null) {
intAnimationStep.setValue(step);
}
Double interval = mapLayer.getAnimationInterval();
if (interval != null) {
dblAnimationSeconds.setValue(interval);
}
if (firstYear != null && firstYear < lastYear) {
intAnimationYearStart.setValue(firstYear);
intAnimationYearEnd.setValue(lastYear);
divAnimation.setVisible(true);
}
}
}
use of au.org.ala.legend.LegendObject in project spatial-portal by AtlasOfLivingAustralia.
the class LayerLegendGeneralComposer method showPointsColourModeLegend.
void showPointsColourModeLegend() {
// remove all
while (!legendHtml.getChildren().isEmpty()) {
legendHtml.removeChild(legendHtml.getFirstChild());
}
// put any parameters into map
Map map = new HashMap();
map.put(StringConstants.QUERY, query);
map.put(StringConstants.LAYER, mapLayer);
map.put(StringConstants.READONLY, StringConstants.TRUE);
String colourmode = cbColour.getSelectedItem().getValue();
if (!StringConstants.GRID.equals(mapLayer.getColourMode()) && query.getLegend(colourmode) != null && query.getLegend(colourmode).getCategoryNameOrder() != null) {
map.put("checkmarks", StringConstants.TRUE);
}
try {
LegendObject lo = query.getLegend(colourmode);
if (lo != null) {
mapLayer.setLegendObject(lo);
}
} catch (Exception e) {
LOGGER.error("querying layer legend for: " + query.getFullQ(false), e);
}
map.put(StringConstants.COLOURMODE, colourmode);
try {
Executions.createComponents("/WEB-INF/zul/legend/LayerLegendClassification.zul", legendHtml, map);
} catch (Exception e) {
LOGGER.error("attempting to open classification legend: " + legendHtml, e);
}
}
use of au.org.ala.legend.LegendObject in project spatial-portal by AtlasOfLivingAustralia.
the class ClassificationLegend method setupForBiocacheNumber.
private void setupForBiocacheNumber(String facetString, String facetName, boolean integer) {
String h = facetString;
isNumber = true;
intContinous = integer;
legendFacets = new HashMap<String, String>();
LegendObject lo = mapLayer.getLegendObject();
if (lo != null) {
// enable sliders
divContinous.setVisible(!disableselection);
gMinValue = minValue = lo.getMinMax()[0];
gMaxValue = maxValue = lo.getMinMax()[1];
if (intContinous) {
sliderMax = Math.min(sliderMax, (int) (gMaxValue - gMinValue));
}
try {
if (facet != null) {
// count OR and test for null
boolean nulls = h.contains("-(" + facetName + ":") || h.contains("-" + facetName + ":");
int countOr = h.split(" OR ").length;
if (countOr == 1 || (nulls && countOr == 2)) {
minValue = facet.getMin();
maxValue = facet.getMax();
if (Double.isInfinite(minValue)) {
minValue = gMinValue;
}
if (Double.isInfinite(maxValue)) {
maxValue = gMaxValue;
}
}
dunknown.setChecked(nulls);
}
} catch (Exception e) {
LOGGER.error("error seting up numerical listing", e);
}
// update text in legend lines
for (int j = 0; j < legendLines.size(); j++) {
String label = legendLines.get(j)[0];
if (label.charAt(0) == '-') {
legendFacets.put(StringConstants.UNKNOWN, legendLines.get(j)[0]);
legendLines.get(j)[0] = StringConstants.UNKNOWN;
} else {
String s = legendLines.get(j)[0];
String[] ss = s.substring(s.indexOf('[')).replace("[", "").replace("]", "").replace(StringConstants.DATE_TIME_END_OF_YEAR, "").replace(StringConstants.DATE_TIME_BEGINNING_OF_YEAR, "").split(" TO ");
float[] cutoffs = lo.getNumericLegend().getCutoffFloats();
float[] cutoffMins = lo.getNumericLegend().getCutoffMinFloats();
String range, strFacet;
if (ss.length > 1) {
if ("*".equals(ss[0])) {
if (intContinous) {
if (cutoffs.length > 1) {
range = String.format(">= %d and < %d", (int) cutoffMins[0], (int) cutoffMins[1]);
} else {
range = String.format(">= %d and <= %d", (int) cutoffMins[0], (int) cutoffs[0]);
}
if (StringConstants.OCCURRENCE_YEAR.equals(colourmode) || StringConstants.OCCURRENCE_YEAR_DECADE.equals(colourmode) || StringConstants.DECADE.equals(colourmode)) {
String minyear = String.valueOf((int) cutoffMins[0]);
while (minyear.length() < 4) {
minyear = "0" + minyear;
}
strFacet = "" + facetName + ":[" + minyear + "-01-01T00:00:00Z TO " + (int) cutoffs[0] + "-12-31T00:00:00Z]";
} else {
strFacet = "" + facetName + ":[" + (int) cutoffMins[0] + " TO " + (int) cutoffs[0] + "]";
}
} else {
if (cutoffs.length > 1) {
range = String.format(">= %.2f and < %.2f", cutoffMins[0], cutoffMins[1]);
} else {
range = String.format(">= %.2f and <= %.2f", cutoffMins[0], cutoffs[0]);
}
strFacet = "" + facetName + ":[" + cutoffMins[0] + " TO " + cutoffs[0] + "]";
}
} else if ("*".equals(ss[1])) {
if (intContinous) {
range = String.format("<= %d", (int) gMaxValue);
if (StringConstants.OCCURRENCE_YEAR.equals(colourmode) || StringConstants.OCCURRENCE_YEAR_DECADE.equals(colourmode) || StringConstants.DECADE.equals(colourmode)) {
String minyear = String.valueOf((int) cutoffMins[cutoffMins.length - 1]);
while (minyear.length() < 4) {
minyear = "0" + minyear;
}
strFacet = "" + facetName + ":[" + minyear + "-01-01T00:00:00Z TO " + (int) gMaxValue + "-12-31T00:00:00Z]";
} else {
strFacet = "" + facetName + ":[" + (int) cutoffMins[cutoffMins.length - 1] + " TO " + (int) gMaxValue + "]";
}
} else {
range = String.format("<= %.2f", gMaxValue);
strFacet = "" + facetName + ":[" + cutoffMins[cutoffMins.length - 1] + " TO " + gMaxValue + "]";
}
} else {
double v = Double.parseDouble(ss[1]);
int pos = 0;
while (v > cutoffs[pos]) {
pos++;
}
if (intContinous) {
if (pos + 1 < cutoffs.length) {
range = String.format("< %d", (int) cutoffMins[pos + 1]);
} else {
range = String.format("<= %d", (int) cutoffs[pos]);
}
if (StringConstants.OCCURRENCE_YEAR.equals(colourmode) || StringConstants.OCCURRENCE_YEAR_DECADE.equals(colourmode) || StringConstants.DECADE.equals(colourmode)) {
String minyear = String.valueOf((int) cutoffMins[pos]);
while (minyear.length() < 4) {
minyear = "0" + minyear;
}
strFacet = "" + facetName + ":[" + minyear + "-01-01T00:00:00Z TO " + (int) cutoffs[pos] + "-12-31T00:00:00Z]";
} else {
strFacet = "" + facetName + ":[" + (int) cutoffMins[pos] + " TO " + (int) cutoffs[pos] + "]";
}
} else {
if (pos + 1 < cutoffs.length) {
range = String.format("< %.2f", cutoffMins[pos + 1]);
} else {
range = String.format("<= %.2f", cutoffs[pos]);
}
strFacet = "" + facetName + ":[" + cutoffMins[pos] + " TO " + cutoffs[pos] + "]";
}
}
legendLines.get(j)[0] = range;
legendFacets.put(range, strFacet);
}
}
}
}
}
Aggregations