/**
* Map Generator Groovy weather sample
*/
package weather.map.generator;
import weather.data.DataValueWithMetar;
import idea.graphics.map.HtmlImageMapItemsFromInputDataValues;
import idea.map.colorscale.AbstractColorScale;
import idea.map.data.DataValue;
/**
* HTML image map items - construct HTML map items from matrix input data values
* Adds raw METAR into standard HTML tooltips
*
* @author Lumir Vanek, vanek@idea-envi.cz
*
*/
public class MyHtmlImageMapItems extends HtmlImageMapItemsFromInputDataValues
{
/**
* Constructor
*
* @param type Station type - circle, square ...
* @param matrixId ID of the computed matrix that contain data values for Stations
* @param size Size of item in pixels
*/
public MyHtmlImageMapItems(Type type, String matrixId, int size)
{
super(type, matrixId, size);
}
/**
* Get item title
*
* @param dataValue Input data value
* @param colorScale Color scale for converting values to colors
* @return Item title
*/
protected String getTitle(DataValue dataValue, AbstractColorScale colorScale)
{
return "TITLE, '" + dataValue.getCode() + " - " + dataValue.getName() + "'";
}
/**
* Get item content
*
* @param dataValue Input data value
* @param colorScale Color scale for converting values to colors
* @return Item content
*/
protected String getContent(DataValue dataValue, AbstractColorScale colorScale)
{
DataValueWithMetar dataValueWithMetar = (DataValueWithMetar) dataValue;
return "'" +
((dataValue.getValue() != null) ? ("<strong>" + decimalFormat.format(dataValue.getValue()) + " " + colorScale.getUnit() + "</strong>")
:
getNodataText()) +
"<br/>" + dataValueWithMetar.getMetarOrigin().replaceAll("\n", "<br/>") +
"'";
}
}