Class ColumnDeclaration

  • All Implemented Interfaces:
    Jsonable

    public class ColumnDeclaration
    extends Object
    implements Jsonable
    Abstraction of a data column defintion. The more exotic fields like pattern, role and properties are handled by the setters.
    Author:
    Dieter Tremel
    • Constructor Detail

      • ColumnDeclaration

        public ColumnDeclaration​(ColumnType type)
        Default constructor.
        Parameters:
        type - Datatype of column.
      • ColumnDeclaration

        public ColumnDeclaration​(String id,
                                 ColumnType type)
        Default constructor.
        Parameters:
        id - Id of Column.
        type - Datatype of column.
      • ColumnDeclaration

        public ColumnDeclaration​(ColumnType type,
                                 String label)
        Constructor with label as String.
        Parameters:
        type - Datatype of column.
        label - Label for description of column.
      • ColumnDeclaration

        public ColumnDeclaration​(ColumnType type,
                                 IModel<String> labelModel)
        Constructor with label.
        Parameters:
        type - Datatype of column.
        labelModel - Model of Label for description of column.
      • ColumnDeclaration

        public ColumnDeclaration​(String id,
                                 ColumnType type,
                                 IModel<String> labelModel)
        Constructor with label.
        Parameters:
        id - Id of Column.
        type - Datatype of column.
        labelModel - Model of Label for description of column.
      • ColumnDeclaration

        public ColumnDeclaration​(ColumnType type,
                                 ColumnRole role)
        Constructor with role. Example:
        new ColumnDeclaration(ColumnType.STRING, ColumnRole.ANNOTATION);
        Parameters:
        type - Datatype of column.
        role - Role of column.
      • ColumnDeclaration

        public ColumnDeclaration​(String id,
                                 ColumnType type,
                                 ColumnRole role)
        Constructor with role. Example:
        new ColumnDeclaration(ColumnType.STRING, ColumnRole.ANNOTATION);
        Parameters:
        id - Id of Column.
        type - Datatype of column.
        role - Role of column.
    • Method Detail

      • fromJSON

        public static ColumnDeclaration fromJSON​(String json)
        Build an instance from a JSON string for instance as seen in tutorials. For users, that find coding in JSON easier than building nested ChartOptions, this my be an additional offer. Implemented as fromJson(new JSONObject(json));, see fromJSON(com.github.openjson.JSONObject).
        Parameters:
        json - JSON string like {id: 'task', label: 'Employee Name', type: 'string'}
        Returns:
        New instance with data from the JSON String.
      • fromJSON

        public static ColumnDeclaration fromJSON​(com.github.openjson.JSONObject jsonObj)
        Build instance from a JSONobject.
        Parameters:
        jsonObj - JSON object to build ColumnDeclaration from. If this contains "properties" nested, it will try to fill them in the instance.
        Returns:
        New instance with data from the JSONObject.
      • setType

        public void setType​(ColumnType type)
      • getId

        public String getId()
      • setId

        public void setId​(String id)
      • getLabel

        public String getLabel()
      • setLabelModel

        public void setLabelModel​(IModel<String> labelModel)
      • setRole

        public void setRole​(ColumnRole role)
        Set role of column. See Column Roles.
        Parameters:
        role - Role of Column.
      • getPattern

        public String getPattern()
      • setPattern

        public void setPattern​(String pattern)
        Just given for completeness, Google Charts does not use this value at the moment. Use definition of options of axis ticks with value and format or hAxis.format instead to format axis values.
        Parameters:
        pattern - Pattern for Column.
      • toJSON

        public com.github.openjson.JSONObject toJSON()
        Description copied from interface: Jsonable
        Create the JSON serialization of the instance.
        Specified by:
        toJSON in interface Jsonable
        Returns:
        Json object for the instance.