Package org.pepstock.charba.client.items
Class ScaleItem
- java.lang.Object
-
- org.pepstock.charba.client.commons.NativeObjectContainer
-
- org.pepstock.charba.client.items.BaseBoxItem
-
- org.pepstock.charba.client.items.BaseBoxNodeItem<AxisPosition>
-
- org.pepstock.charba.client.items.ScaleItem
-
- All Implemented Interfaces:
IsArea
- Direct Known Subclasses:
AxisItem
public class ScaleItem extends BaseBoxNodeItem<AxisPosition>
Wraps the scale item of CHART JS chart.
This is a wrapper of scale of Chart (of CHART.JS).- Author:
- Andrea "Stock" Stocchero
-
-
Constructor Summary
Constructors Constructor Description ScaleItem(CallbacksEnvelop<NativeObject> envelop)Creates the item using an envelop (fromcallbackspackage) of native java script object which contains all properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AxisKindgetAxis()Which kind of axis this is.
Possible values are: ''x', 'y' or 'r'.doublegetBasePixel()Returns the pixel for the minimum chart value.
The coordinate (0, 0) is at the upper-left corner of the canvas.doublegetBaseValue()Returns the minimum chart value.intgetCharbaId()Returns the unique id of scale.IsChartgetChart()Returns the CHARBA chart instance.doublegetDecimalForPixel(double pixel)Used to get the data value from a given pixel.
This is the inverse of getPixelForValue.
The coordinate (0, 0) is at the upper-left corner of the canvas.doublegetDistanceFromCenterForValue(double value)Returns the distance from the center of a specific value.intgetDrawingArea()Returns the drawing area dimension of scale.doublegetEnd()Returns the end value of scale.ScaleIdgetId()Returns the id of scaleStringgetLabelForValue(double value)Used to get the label to display in the tooltip for the given value.doublegetLabelRotation()Returns the label rotation ratio.doublegetMax()Returns the max value of scale.DategetMaxAsDate()Returns the max value of scale.StringgetMaxAsString()Returns the max value of scale.doublegetMin()Returns the minimum value of scale.DategetMinAsDate()Returns the minimum value of scale.StringgetMinAsString()Returns the minimum value of scale.doublegetPixelForDateValue(Date value)Returns the location of the given data point.
The coordinate (0, 0) is at the upper-left corner of the canvas.doublegetPixelForDateValue(Date value, double index)Returns the location of the given data point.
Value can either be an index or a numerical value.
The coordinate (0, 0) is at the upper-left corner of the canvas.doublegetPixelForDecimal(double decimal)Utility for getting the pixel location of a percentage of scale.
The coordinate (0, 0) is at the upper-left corner of the canvas.doublegetPixelForStringValue(String value)Returns the location of the given data point.
The coordinate (0, 0) is at the upper-left corner of the canvas.doublegetPixelForStringValue(String value, double index)Returns the location of the given data point.
The coordinate (0, 0) is at the upper-left corner of the canvas.doublegetPixelForTick(double index)Returns the location of the tick at the given index.
The coordinate (0, 0) is at the upper-left corner of the canvas.doublegetPixelForValue(double value)Returns the location of the given data point.
The coordinate (0, 0) is at the upper-left corner of the canvas.doublegetPixelForValue(double value, double index)Returns the location of the given data point.
Value can either be an index or a numerical value.
The coordinate (0, 0) is at the upper-left corner of the canvas.List<String>getPointLabels()Returns the list of point labels of scale.doublegetStart()Returns the start value of scale.List<ScaleTickItem>getTicks()Returns the list of ticks.AxisTypegetType()Returns the type of scaleScaleValueItemgetValueAtEvent(BaseNativeEvent event)Returns the value on the axis related to an event position.ScaleValueItemgetValueAtEvent(ChartEventContext context)Returns the value on the axis related to an event position.ScaleValueItemgetValueAtPixel(double position)Returns the value on the axis related to a position, passed as pixels.doublegetValueForDistanceFromCenter(double distance)Returns the value calculated applying the specific distance from the center.doublegetValueForPixel(double pixel)Used to get the data value from a given pixel.
This is the inverse of getPixelForValue.
The coordinate (0, 0) is at the upper-left corner of the canvas.intgetXCenter()Returns the X center of scale.intgetYCenter()Returns the Y center of scale.booleanisHorizontal()Returnstrueif the scale is horizontal.-
Methods inherited from class org.pepstock.charba.client.items.BaseBoxNodeItem
getMaxHeight, getMaxWidth, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getPosition, getWeight, isActive, isFullSize
-
Methods inherited from class org.pepstock.charba.client.items.BaseBoxItem
getBottom, getHeight, getLeft, getRight, getTop, getWidth, isInside
-
Methods inherited from class org.pepstock.charba.client.commons.NativeObjectContainer
checkDefaultValuesArgument, empty, getArrayValue, getElement, getIncrementalId, getNativeChart, getNativeEvent, getNativeObject, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValueForMultipleKeyTypes, getValueForMultipleKeyTypes, getValueForMultipleKeyTypes, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, has, has, isType, keys, loadNativeObject, remove, remove, setArrayValue, setArrayValue, setArrayValue, setElement, setEmptyValue, setNewIncrementalId, setNewIncrementalId, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, toJSON, type
-
-
-
-
Constructor Detail
-
ScaleItem
public ScaleItem(CallbacksEnvelop<NativeObject> envelop)
Creates the item using an envelop (fromcallbackspackage) of native java script object which contains all properties.- Parameters:
envelop- envelop of native java script object which contains all properties.
-
-
Method Detail
-
getChart
public final IsChart getChart()
Returns the CHARBA chart instance.- Returns:
- the CHARBA chart instance
-
getId
public final ScaleId getId()
Returns the id of scale- Returns:
- the id of scale.
-
getCharbaId
public final int getCharbaId()
Returns the unique id of scale.- Returns:
- the unique id of scale.
-
getAxis
public final AxisKind getAxis()
Which kind of axis this is.
Possible values are: ''x', 'y' or 'r'.- Returns:
- the kind of axis.
-
getType
public final AxisType getType()
Returns the type of scale- Returns:
- the type of scale.
-
getMax
public final double getMax()
Returns the max value of scale.- Returns:
- the max value of scale.
-
getMin
public final double getMin()
Returns the minimum value of scale.- Returns:
- the minimum value of scale.
-
getMaxAsString
public final String getMaxAsString()
Returns the max value of scale.- Returns:
- the max value of scale.
-
getMinAsString
public final String getMinAsString()
Returns the minimum value of scale.- Returns:
- the minimum value of scale.
-
getMaxAsDate
public final Date getMaxAsDate()
Returns the max value of scale.- Returns:
- the max value of scale. If missing returns is
null.
-
getMinAsDate
public final Date getMinAsDate()
Returns the minimum value of scale.- Returns:
- the minimum value of scale. If missing returns is
null.
-
getTicks
public final List<ScaleTickItem> getTicks()
Returns the list of ticks.- Returns:
- the list of ticks.
-
getLabelRotation
public final double getLabelRotation()
Returns the label rotation ratio.- Returns:
- the label rotation ratio.
-
getStart
public final double getStart()
Returns the start value of scale.- Returns:
- the start value of scale.
-
getEnd
public final double getEnd()
Returns the end value of scale.- Returns:
- the end value of scale.
-
getXCenter
public final int getXCenter()
Returns the X center of scale.- Returns:
- the X center of scale.
-
getYCenter
public final int getYCenter()
Returns the Y center of scale.- Returns:
- the Y center of scale.
-
getDrawingArea
public final int getDrawingArea()
Returns the drawing area dimension of scale.- Returns:
- the drawing area dimension of scale.
-
getPointLabels
public final List<String> getPointLabels()
Returns the list of point labels of scale.- Returns:
- the list of point labels of scale.
-
isHorizontal
public final boolean isHorizontal()
Returnstrueif the scale is horizontal.- Returns:
trueif the scale is horizontal
-
getValueAtEvent
public final ScaleValueItem getValueAtEvent(ChartEventContext context)
Returns the value on the axis related to an event position.- Parameters:
context- event context instance used to get the value from the scale- Returns:
- the value on the axis related to an event position
-
getValueAtEvent
public final ScaleValueItem getValueAtEvent(BaseNativeEvent event)
Returns the value on the axis related to an event position.- Parameters:
event- event instance used to get the value from the scale- Returns:
- the value on the axis related to an event position
-
getValueAtPixel
public final ScaleValueItem getValueAtPixel(double position)
Returns the value on the axis related to a position, passed as pixels.- Parameters:
position- position in pixel used to get the value from the scale- Returns:
- the value on the axis related to a position, passed as pixels
-
getDecimalForPixel
public final double getDecimalForPixel(double pixel)
Used to get the data value from a given pixel.
This is the inverse of getPixelForValue.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
pixel- pixel value- Returns:
- the data value from a given pixel
-
getPixelForDecimal
public final double getPixelForDecimal(double decimal)
Utility for getting the pixel location of a percentage of scale.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
decimal- number value to use- Returns:
- the pixel location of a percentage of scale
-
getPixelForTick
public final double getPixelForTick(double index)
Returns the location of the tick at the given index.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
index- tick index to use- Returns:
- the location of the tick at the given index
-
getLabelForValue
public final String getLabelForValue(double value)
Used to get the label to display in the tooltip for the given value.- Parameters:
value- value of the data- Returns:
- the label to display in the tooltip for the given value
-
getPixelForStringValue
public final double getPixelForStringValue(String value)
Returns the location of the given data point.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
value- value of the data- Returns:
- the location of the given data point
-
getPixelForStringValue
public final double getPixelForStringValue(String value, double index)
Returns the location of the given data point.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
value- value of the data as stringindex- index of the data- Returns:
- the location of the given data point
-
getPixelForDateValue
public final double getPixelForDateValue(Date value)
Returns the location of the given data point.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
value- value of the data- Returns:
- the location of the given data point
-
getPixelForDateValue
public final double getPixelForDateValue(Date value, double index)
Returns the location of the given data point.
Value can either be an index or a numerical value.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
value- value of the data as dateindex- index of the data- Returns:
- the location of the given data point
-
getPixelForValue
public final double getPixelForValue(double value)
Returns the location of the given data point.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
value- value of the data- Returns:
- the location of the given data point
-
getPixelForValue
public final double getPixelForValue(double value, double index)Returns the location of the given data point.
Value can either be an index or a numerical value.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
value- value of the dataindex- index of the data- Returns:
- the location of the given data point
-
getValueForPixel
public final double getValueForPixel(double pixel)
Used to get the data value from a given pixel.
This is the inverse of getPixelForValue.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Parameters:
pixel- pixel value- Returns:
- the data value from a given pixel
-
getBaseValue
public final double getBaseValue()
Returns the minimum chart value.- Returns:
- the minimum chart value
-
getBasePixel
public final double getBasePixel()
Returns the pixel for the minimum chart value.
The coordinate (0, 0) is at the upper-left corner of the canvas.- Returns:
- the pixel for the minimum chart value
-
getDistanceFromCenterForValue
public final double getDistanceFromCenterForValue(double value)
Returns the distance from the center of a specific value.- Parameters:
value- the value of to check- Returns:
- the distance from the center of a specific value
-
getValueForDistanceFromCenter
public final double getValueForDistanceFromCenter(double distance)
Returns the value calculated applying the specific distance from the center.- Parameters:
distance- the distance which must be applied- Returns:
- the value calculated applying the specific distance from the center.
-
-