}
}
// Set zoom levels visible
if (uidl.hasAttribute("zoomLevels")) {
ValueMap levelMap = uidl.getMapAttribute("zoomLevels");
if (zoomBar != null) {
for (Anchor lvl : zoomLevels.keySet()) {
zoomBar.remove(lvl);
}
}
zoomLevels.clear();
for (String caption : levelMap.getKeySet()) {
Long time = Long.parseLong(levelMap.getString(caption));
addZoomLevel(caption, time);
}
}
// Set the chart mode
if (uidl.hasAttribute("chartMode")) {
initPlotMode = PlotMode.valueOf(uidl
.getStringAttribute("chartMode"));
if (initStage1Done && initPlotMode != null) {
display.setChartMode(initPlotMode, initDone);
}
}
// Set the graph grid color
if(uidl.hasAttribute("gridColor")) {
String color = uidl.getStringAttribute("gridColor");
if (color == null || color.equals("")) {
initGridColor = null;
} else {
String[] rgba = color.split(";");
initGridColor = "rgba(" + rgba[0] + "," + rgba[1] + ","
+ rgba[2] + "," + rgba[3] + ")";
}
if (initStage1Done) {
display.setGridColor(initGridColor);
}
}
// Initialization stage 1
if(!initStage1Done){
init();
initStage1Done = true;
// Initialization done
} else if(!initDone){
initDone = true;
if (initStartDate != null && initEndDate != null) {
// Request given init date
display.setRange(initStartDate, initEndDate, true, true, false);
browser.setRange(initStartDate, initEndDate);
} else {
// Request the default range
display.setRange(getStartDate(), getEndDate(), true, true, false);
browser.setRange(getStartDate(), getEndDate());
}
fireDateRangeChangedEvent();
}
// Data received
if (uidl.hasAttribute("data")) {
ValueMap map = uidl.getMapAttribute("data");
ValueMap changedDensitiesMap = uidl.getMapAttribute("cdensities");
List<Long> removableRequests = new LinkedList<Long>();
//Check waiting data list
for (Long req : waitingForData.keySet()) {
for (String req2 : map.getKeySet()) {
if (req2.equals(req.toString())) {
VDataListener comp = waitingForData.get(req);
// Get the values.
List<String> values = new ArrayList<String>();
String valuesString = map.getString(req2);
if (valuesString != null && !valuesString.equals("")) {
for (String val : map.getString(req2).split(";")) {
values.add(val);
}
}
List<Float> fvalues = new ArrayList<Float>();
List<Date> dvalues = new ArrayList<Date>();
Integer density = densityMap.get(req);
if (changedDensitiesMap != null) {
/*
* Note: This might throw an exception when using
* hosted mode for an unknown reason. If that
* happens then continue to use the last known
* density which will work as expected.
*/
try {
Integer newDensity = changedDensitiesMap
.getInt(req2);
if (newDensity != null) {
density = newDensity;
}
} catch (Exception e) {