All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.pepstock.charba.client.items.DatasetItem Maven / Gradle / Ivy

There is a newer version: 6.5-gwt
Show newest version
/**
    Copyright 2017 Andrea "Stock" Stocchero

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

	    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
*/
package org.pepstock.charba.client.items;

import org.pepstock.charba.client.commons.Key;
import org.pepstock.charba.client.commons.NativeObject;
import org.pepstock.charba.client.commons.NativeObjectContainer;
import org.pepstock.charba.client.commons.NativeObjectContainerFactory;

/**
 * Calling some methods on your chart instance passing an argument of an event, will return the elements at the event position.
* The elements are mapped by this object.
* This is the CHART.JS item with all needed info about a selected dataset. This object has been created and passed to event handler or callbacks to apply own logic. * * @author Andrea "Stock" Stocchero */ public class DatasetItem extends NativeObjectContainer { private final DatasetViewItem view; /** * Name of properties of native object. */ private enum Property implements Key { DATASET_INDEX("_datasetIndex"), INDEX("_index"), VIEW("_view"), HIDDEN("hidden"); // name value of property private final String value; /** * Creates with the property value to use into native object. * * @param value value of property name */ private Property(String value) { this.value = value; } /* * (non-Javadoc) * * @see org.pepstock.charba.client.commons.Key#value() */ @Override public String value() { return value; } } /** * Creates the item using a native java script object which contains all properties. * * @param nativeObject native java script object which contains all properties. */ public DatasetItem(NativeObject nativeObject) { super(nativeObject); // initializes the sub objects view = new DatasetViewItem(getValue(Property.VIEW)); } /** * Returns the dataset index of the chart * * @return the dataset index of the chart. Default is {@link UndefinedValues#INTEGER}. */ public final int getDatasetIndex() { return getValue(Property.DATASET_INDEX, UndefinedValues.INTEGER); } /** * Returns the index of the data inside the dataset. * * @return the index of the data inside the dataset. Default is {@link UndefinedValues#INTEGER}. */ public final int getIndex() { return getValue(Property.INDEX, UndefinedValues.INTEGER); } /** * Returns if the dataset is hidden. * * @return true if the dataset is hidden, otherwise false. Default is {@link UndefinedValues#BOOLEAN}. */ public final boolean isHidden() { return getValue(Property.HIDDEN, UndefinedValues.BOOLEAN); } /** * Sets if the dataset must be hidden. * * @param hidden true if the dataset must be hidden, otherwise false. */ public final void setHidden(boolean hidden) { setValue(Property.HIDDEN, hidden); } /** * Returns all view information about the dataset. * * @return all view information about the dataset. */ public final DatasetViewItem getView() { return view; } /** * Inner class to create dataset item by a native object. * * @author Andrea "Stock" Stocchero */ public static final class DatasetItemFactory implements NativeObjectContainerFactory { /* * (non-Javadoc) * * @see org.pepstock.charba.client.commons.NativeObjectContainerFactory#create(org.pepstock.charba.client.commons. NativeObject) */ @Override public DatasetItem create(NativeObject nativeObject) { return new DatasetItem(nativeObject); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy