Package org.wicketstuff.gchart
Class DataCell
- java.lang.Object
-
- org.wicketstuff.gchart.DataCell
-
- All Implemented Interfaces:
Serializable,IClusterable,Jsonable
public class DataCell extends Object implements IClusterable, Jsonable
Cell object for data values with more features.- Author:
- Dieter Tremel
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JSONFunctioncreateExplicitJsDate(Calendar cal)Convert a Calendar object to a JavaScriptDate()call that generates the same value.static JSONFunctioncreateJsDate(Calendar cal)Convert a Calendar object to a JavaScriptDate()call that generates the same value.static JSONFunctioncreateJsDate(Date date)Convert a Date object to a JavaScriptDate()call that generates the same value.FormatgetFormat()StringgetFormatted()Return the formatted value.static ObjectgetJsValue(Object val)Create a representation of a Java object suitable for a put operation to aJSONObject.Map<String,Object>getProperties()ObjectgetValue()voidsetFormat(Format format)Format used for calculating the value to a String used for rendering offin JavaScript.voidsetFormatted(String formatted)voidsetValue(Object value)com.github.openjson.JSONObjecttoJSON()Create the JSON serialization of the instance.
-
-
-
Method Detail
-
getValue
public Object getValue()
-
setValue
public void setValue(Object value)
-
getFormat
public Format getFormat()
-
setFormat
public void setFormat(Format format)
Format used for calculating the value to a String used for rendering offin JavaScript.- Parameters:
format- The format to applied if the formatted value of the instance is null. For Number this can be a DecimalFormat, for Dates for instance a SimpleDateFormat.
-
getFormatted
public String getFormatted()
Return the formatted value. If this is null, null is also returned and there should be no rendering offin JavaScript. In this case format conversion is done by Google chart lib. See thereforChart.getLocale(). IfgetFormat()is not null and the formatted field is null, the format is applied to the value. If formatted field is not null this is returned without change, so a single DataCell can override the Formatter.- Returns:
- Field formatted if field format is null. If field format is not null and field formatted is null, the format is applied to the value and the result is returned.
-
setFormatted
public void setFormatted(String formatted)
-
toJSON
public com.github.openjson.JSONObject toJSON()
Description copied from interface:JsonableCreate the JSON serialization of the instance.
-
getJsValue
public static Object getJsValue(Object val)
Create a representation of a Java object suitable for a put operation to aJSONObject. For simple types like String and Number the object is returned unmodified.Booleans are rendered as String
"true"or"false"Dates or Calendars are rendered as JsonFunction
"Date()"by use ofcreateJsDate(java.util.Calendar).TimeOfDayare rendered as JSONArray by use ofTimeOfDay.getTimeOfDayArray().- Parameters:
val- The object to convert to.- Returns:
- JSON compatible wrapping of the value or the value itself for simple types.
-
createExplicitJsDate
public static JSONFunction createExplicitJsDate(Calendar cal)
Convert a Calendar object to a JavaScriptDate()call that generates the same value. Return as a human readable JsonFunction (new Date(year, month[, day[, hour[, minutes[, seconds[, milliseconds]]]]])) for rendering in JSONObjects.- Parameters:
cal- Calender value to render.- Returns:
- JavaScript Date function for the value.
-
createJsDate
public static JSONFunction createJsDate(Calendar cal)
Convert a Calendar object to a JavaScriptDate()call that generates the same value. Return as a JsonFunction(new Date(value);) (milliseconds since epoch) for rendering in JSONObjects .- Parameters:
cal- Calender value to render.- Returns:
- JavaScript Date function for the value.
-
createJsDate
public static JSONFunction createJsDate(Date date)
Convert a Date object to a JavaScriptDate()call that generates the same value. Return as a JsonFunction(new Date(value);)(milliseconds since epoch) for rendering in JSONObjects.- Parameters:
date- Date value to render.- Returns:
- JavaScript Date function for the value.
-
-