Class ChartContext

    • Constructor Detail

      • ChartContext

        public ChartContext​(NativeObject nativeObject)
        Creates the object with native object instance to be wrapped.
        Parameters:
        nativeObject - native object instance to be wrapped.
    • Method Detail

      • getChart

        public final IsChart getChart()
        Returns the CHARBA chart instance.
        Returns:
        the CHARBA chart instance
      • getType

        public final ContextType getType()
        Returns the type of the context.
        Returns:
        the type of the context
      • setAttributes

        public final <T extends NativeObjectContainer> void setAttributes​(T attributes)
        Sets the additional attributes.
        Type Parameters:
        T - type of native object container to store
        Parameters:
        attributes - additional attributes instance.
      • hasAttributes

        public final boolean hasAttributes()
        Checks if there is any attribute node.
        Returns:
        true if there is an attributes node, otherwise false.
      • getAttributes

        public final <T extends NativeObjectContainer> T getAttributes​(NativeObjectContainerFactory<T> factory)
        Returns the attributes, if exist. It uses a factory instance to create a native object container.
        Type Parameters:
        T - type of native object container to return
        Parameters:
        factory - factory instance to create a native object container.
        Returns:
        java script object used to map the attributes or an empty object if not exist.
      • setAttribute

        public final void setAttribute​(Key key,
                                       double value)
        Sets a custom field to data point.
        Parameters:
        key - key of java script object to set.
        value - value to set.
      • getAttribute

        public final double getAttribute​(Key key,
                                         double defaultValue)
        Returns a custom field value from data point.
        Parameters:
        key - key of java script object to get.
        defaultValue - default value if the property is missing
        Returns:
        custom field value from data point.
      • setAttribute

        public final void setAttribute​(Key key,
                                       boolean value)
        Sets a custom field to data point.
        Parameters:
        key - key of java script object to set.
        value - value to set.
      • getAttribute

        public final boolean getAttribute​(Key key,
                                          boolean defaultValue)
        Returns a custom field value from data point.
        Parameters:
        key - key of java script object to get.
        defaultValue - default value if the property is missing
        Returns:
        custom field value from data point.
      • setAttribute

        public final void setAttribute​(Key key,
                                       int value)
        Sets a custom field to data point.
        Parameters:
        key - key of java script object to set.
        value - value to set.
      • getAttribute

        public final int getAttribute​(Key key,
                                      int defaultValue)
        Returns a custom field value from data point.
        Parameters:
        key - key of java script object to get.
        defaultValue - default value if the property is missing
        Returns:
        custom field value from data point.
      • setAttribute

        public final void setAttribute​(Key key,
                                       String value)
        Sets a custom field to data point.
        Parameters:
        key - key of java script object to set.
        value - value to set.
      • getAttribute

        public final String getAttribute​(Key key,
                                         String defaultValue)
        Returns a custom field value from data point.
        Parameters:
        key - key of java script object to get.
        defaultValue - default value if the property is missing
        Returns:
        custom field value from data point.
      • isConsistent

        protected boolean isConsistent()
        Returns true if the context is consistent.
        Custom context (the plugin ones) should extend it and check if the context is consistent before invoking the callback.
        Returns:
        true if the context is consistent
      • checkIfPropertyIsValid

        protected boolean checkIfPropertyIsValid​(Key property)
        Checks if the key passed as argument is a key already used for other context properties.
        Parameters:
        property - property to use to store a custom attribute
        Returns:
        true if the property can be used to store an attribute.