-public Color.RGBA(int red,
- int green,
- int blue,
- float alpha)
-
-
Creates an RGBA color with the specified red, green, blue and alpha
- values. The red, green and blue values must be in the range (0 -
- 255). The alpha value must be in the range (0.0-1.0). The alpha value
- deaults to 1.0
-
-
-
Parameters:
red - the red component in a color
green - the green component in a color
blue - the blue component in a color
alpha - the alpha component in a color
-
-
-
-
-
-
-
-
-Method Detail
-
-
-
-
-getAlpha
-
-public final float getAlpha()
-
-
-
-
Returns:
Returns the alpha component in the range (0.0-1.0).
-The Color interface represents RBG and RBGA colors.
- Do not confuse with java.awt.Color class. This is a simplified
- version of java.awt.Color for the purpose of InvientCharts
-
-Represents a stop-value and a color. The stop-value should be in range
- (0.0-1.0). The color of the gradient at each stop is the color specified
- for that stop. Between each such stop, the colors and the alpha component
- will be linearly interpolated over the RGBA.
-
-Represents linear gradient where points of a linear gradient specify a
- line. For more details on gradient, refer to CSS 3 gradient
- documentation.
-
xStart - the x-coordinate of a point at which linear gradient
- starts.
xStartUnit - the unit for the xStart value. It can have one of the two
- values Unit.NUMBER or Unit.PERCENT. If it is null then the
- default value is Unit.NUMBER.
yStart - the y-coordinate of a point at which linear gradient
- starts.
yStartUnit - the unit for the yStart value. It can have one of the two
- values Unit.NUMBER or Unit.PERCENT. If it is null then the
- default value is Unit.NUMBER.
xEnd - the x-coordinate of a point at which linear gradient ends.
xEndUnit - the unit for the xEnd value. It can have one of the two
- values Unit.NUMBER or Unit.PERCENT. If it is null then the
- default value is Unit.NUMBER.
yEnd - the y-coordinate of a point at which linear gradient ends.
yEndUnit - the unit for the yEnd value. It can have one of the two
- values Unit.NUMBER or Unit.PERCENT. If it is null then the
- default value is Unit.NUMBER.
colorStops - the list of colorstops for the linear gradient.
Returns an array containing the constants of this enum type, in
-the order they are declared. This method may be used to iterate
-over the constants as follows:
-
-for (Gradient.Unit c : Gradient.Unit.values())
- System.out.println(c);
-
-
-
-
-
Returns:
an array containing the constants of this enum type, in
-the order they are declared
Returns the enum constant of this type with the specified name.
-The string must match exactly an identifier used to declare an
-enum constant in this type. (Extraneous whitespace characters are
-not permitted.)
-
-
-
Parameters:
name - the name of the enum constant to be returned.
-
Returns:
the enum constant with the specified name
-
Throws:
-
java.lang.IllegalArgumentException - if this enum type has no constant
-with the specified name
-
java.lang.NullPointerException - if the argument is null
-Chart SVG event. This event is thrown, when an SVG string representing
- the chart is received or ready.
-
- Note that this event is thrown only once after a
- InvientCharts.ChartSVGAvailableListener is registered.
-
public static interface InvientCharts.ChartSVGAvailableListener
extends java.io.Serializable
-
-
-
-Interface for listening for a InvientCharts.ChartSVGAvailableEvent triggered by
- InvientCharts.
-
- The chart can have only one listener of this type registered at any time.
- If a listener has already been registered and an attempt is made to
- register another listener then the previously registered listener will be
- unregistered and the new listener will be registered.
-
- A listener will be called only once after it has been registered though
- it will be called again if the same listener is registered again.
-
-This class defines a datetime series. In this series, the X value must be
- date and Y values must be number. To use number values, use
- InvientCharts.XYSeries
-
- By default, the time of a day is not included in the X value. In order to
- include time, use a constructor with argument isIncludeTime and pass true
- value for the argument.
-
Creates a series with given name. This series will not consider time
- in the X property of InvientCharts.DateTimePoint. To include time, use any
- constructor having isIncludeTime as part of the arguments.
-
Creates a series with given name and boolean value.
-
-
-
Parameters:
name - the name of this series
isIncludeTime - If true then the time in the X property of
- InvientCharts.DateTimePoint will be considered when drawing the
- chart. Defaults to false.
Creates a series with given name, configuration and boolean value.
-
-
-
Parameters:
name - the name of this series
config - the configuration for this series
isIncludeTime - If true then the time in the X property of
- InvientCharts.DateTimePoint will be considered when drawing the
- chart. Defaults to false.
Creates a series with given name, type and boolean value.
-
-
-
Parameters:
name - the name of this series
seriesType - the type of this series
isIncludeTime - If true then the time in the X property of
- InvientCharts.DateTimePoint will be considered when drawing the
- chart. Defaults to false.
Creates a series with given name, type, configuration and boolean
- value.
-
-
-
Parameters:
name - the name of this series
seriesType - the type of this series
config - the configuration for this series
isIncludeTime - If true then the time in the X property of
- InvientCharts.DateTimePoint will be considered when drawing the
- chart. Defaults to false.
Appends the specified point into the series if they do not exists in
- this series. The points which already exists will not be appended. A
- collection of points appended to this series will be returned.
-
-
-
Parameters:
points -
-
Returns:
Returns a collection of points which are added in this
- series. If a point has same (x, y) value as any other point
- in the input argument points then it will not be added in
- this series.
Append the specified point into this series. If the argument shift is
- true then one point is shifted off the start of this series as one is
- appended to the end.
-
-
-
Parameters:
point - A point to be added at the end of this series
shift - If true then one point is shifted off the start of this
- series as one is appended to the end.
-
Returns:
Returns a collection of points which are added in this
- series. If a point has same (x, y) value as any other point
- in the input argument points then it will not be added in
- this series.
-
-
-
-
-
-isIncludeTime
-
-public boolean isIncludeTime()
-
-
-
-
Returns:
Returns true if the time in the X property of
- InvientCharts.DateTimePoint will be considered when drawing the
- chart otherwise false.
Returns all points of this series. Adding or removing any
- point to or from the returned collection will not impact the
- chart. To add a point or points, use addPoint() or
- removePoint() method.
Sets points into this series. This method removes all of its points
- and then add points specified in the method argument. If the argument
- is null then no actions are taken.
-
-
-
Parameters:
points - the collection of points to set into this series.
-
Returns:
Returns a collection of points which are added in this
- series. If a point has same (x, y) value as any other point
- in the input argument points then it will not be added in
- this series.
-This class represents a point of the chart's series. A series can have
- one or more points. A point has (X, Y) coordinates. None of the
- coordinates are mandatory. The name of a point can be displayed in a
- tooltip.
-
- To represent no activity or missing points in the chart, create a point
- with both X and Y as null or just Y as null.
-
- It is possible to specify custom configuration for each point. e.g. If a
- highest point can be marked in a chart with a different color using this
- configuration.
-
- A point cannot be created without a series. It must belong to a series.
- However, the point must be added to a series by calling Series.addPoint()
- or Series.setPoints() to permanently add point to the series.
-
-Click event. This event is thrown, when any point of this chart is
- clicked and the point marker is enabled. The point marker is enabled by
- default.
-
-Point select event. This event is thrown, when any point of this chart is
- selected and the point marker is enabled. The point marker is enabled by
- default.
-
-Poin unselect event. This event is thrown, when any point of this chart
- is unselected and the point marker is enabled. The point marker is
- enabled by default.
-
-This class defines a series of the chart. A series contains a collection
- of points. Series can be one of types defined by InvientCharts.SeriesType.
-
- Each series must have unique name. If an attempt is made to add two
- series with same then only the first added series will be in effect.
-
- If the series type is not specified, it defaults to chart type and the
- default chart type is SeriesType.LINE. A series has unique xAxis and
- yAxis object associated with it. There is no need to set xAxis and yAxis
- unless the chart has more than one one axis of any type and the series
- must belong to any of the secondary axis.
-
- It is also possible to specify configuration for individual series and
- not just series type.
-
By using this stack property, it is possible to group series in a
- stacked chart. Sets stack for this series. If two series belongs to
- the same stack then the resultant chart will be stacked chart
-
public class InvientCharts.SeriesLegendItemClickEvent
extends com.vaadin.ui.Component.Event
-
-
-
-Series legend item click event. This event is thrown, when legend item is
- clicked. This event is not applicable for PieChart instead use
- InvientCharts.SeriesLegendItemClickEvent
-
Returns an array containing the constants of this enum type, in
-the order they are declared. This method may be used to iterate
-over the constants as follows:
-
-for (InvientCharts.SeriesType c : InvientCharts.SeriesType.values())
- System.out.println(c);
-
-
-
-
-
Returns:
an array containing the constants of this enum type, in
-the order they are declared
Returns the enum constant of this type with the specified name.
-The string must match exactly an identifier used to declare an
-enum constant in this type. (Extraneous whitespace characters are
-not permitted.)
-
-
-
Parameters:
name - the name of the enum constant to be returned.
-
Returns:
the enum constant with the specified name
-
Throws:
-
java.lang.IllegalArgumentException - if this enum type has no constant
-with the specified name
-
java.lang.NullPointerException - if the argument is null
Appends the specified point into the series if they do not exists in
- this series. The points which already exists will not be appended. A
- collection of points appended to this series will be returned.
-
-
-
Parameters:
points -
-
Returns:
Returns a collection of points which are added in this
- series. If a point has same (x, y) value as any other point
- in the input argument points then it will not be added in
- this series.
Append the specified point into this series. If the argument shift is
- true then one point is shifted off the start of this series as one is
- appended to the end.
-
-
-
Parameters:
points -
shift - If true then one point is shifted off the start of this
- series as one is appended to the end.
-
Returns:
Returns a collection of points which are added in this
- series. If a point has same (x, y) value as any other point
- in the input argument points then it will not be added in
- this series.
Returns all points of this series. Adding or removing any
- point to or from the returned collection will not impact the
- chart. To add a point or points, use addPoint() or
- removePoint() method.
Sets points into this series. This method removes all of its points
- and then add points specified in the method argument. If the argument
- is null then no actions are taken.
-
-
-
Parameters:
points - the collection of points to set into this series.
-
Returns:
Returns a collection of points which are set in this series.
- If a point has same (x, y) value as any other point in the
- argument points then it will not be added.
-A Vaddin component representing charts. It is a the main class of
- InvientCharts library.
-
- A chart typically contains one or more series of same or different types.
- This class allows us to specify series of different types say line and pie
- and hence it makes it easy to build a combination chart.
-
- After a chart InvientCharts is created, the following changes to the
- chart will be reflected rendered on the webkit.
-
Adds the point click listener. If the argument seriesTypes is not
- specified then the listener will be added for all series type otherwise
- it will be added for a specific series type
-
Removes the point click listener. If the argument seriesTypes is not
- specified then the listener will be removed only for a series type
- SeriesType.COMMONSERIES otherwise the listener will be removed for all
- specified series types.
-
-
-
Parameters:
listener - the listener to be removed
seriesTypes - one or more series types as defined by (@link SeriesType}
Adds the point remove listener. If the argument seriesTypes is not
- specified then the listener will be added for all series type otherwise
- it will be added for a specific series type
-
Removes the point remove listener. If the argument seriesTypes is not
- specified then the listener will be removed only for a series type
- SeriesType.COMMONSERIES otherwise the listener will be removed for all
- specified series types.
-
-
-
Parameters:
listener - the listener to be removed
seriesTypes - one or more series types as defined by (@link SeriesType}
Adds the point unselect listener. If the argument seriesTypes is not
- specified then the listener will be added for all series type otherwise
- it will be added for a specific series type
-
Removes the point unselect listener. If the argument seriesTypes is not
- specified then the listener will be removed only for a series type
- SeriesType.COMMONSERIES otherwise the listener will be removed for all
- specified series types.
-
-
-
Parameters:
listener - the listener to be removed
seriesTypes - one or more series types as defined by (@link SeriesType}
Adds the point select listener. If the argument seriesTypes is not
- specified then the listener will be added for all series type otherwise
- it will be added for a specific series type
-
Removes the point select listener. If the argument seriesTypes is not
- specified then the listener will be removed only for a series type
- SeriesType.COMMONSERIES otherwise the listener will be removed for all
- specified series types.
-
-
-
Parameters:
listener - the listener to be removed
seriesTypes - one or more series types as defined by (@link SeriesType}
Adds the series click listener. If the argument seriesTypes is not
- specified then the listener will be added for all series type otherwise
- it will be added for a specific series type
-
Removes the series click listener. If the argument seriesTypes is not
- specified then the listener will be removed only for a series type
- SeriesType.COMMONSERIES otherwise the listener will be removed for all
- specified series types.
-
-
-
Parameters:
listener - the listener to be removed
seriesTypes - one or more series types as defined by (@link SeriesType}
Adds the series hide listener. If the argument seriesTypes is not
- specified then the listener will be added for all series type otherwise
- it will be added for a specific series type
-
Removes the series hide listener. If the argument seriesTypes is not
- specified then the listener will be removed only for a series type
- SeriesType.COMMONSERIES otherwise the listener will be removed for all
- specified series types.
-
-
-
Parameters:
listener - the listener to be removed
seriesTypes - one or more series types as defined by (@link SeriesType}
Adds the series show listener. If the argument seriesTypes is not
- specified then the listener will be added for all series type otherwise
- it will be added for a specific series type
-
Removes the series show listener. If the argument seriesTypes is not
- specified then the listener will be removed only for a series type
- SeriesType.COMMONSERIES otherwise the listener will be removed for all
- specified series types.
-
-
-
Parameters:
listener - the listener to be removed
seriesTypes - one or more series types as defined by (@link SeriesType}
Adds the series legend item click listener. If the argument seriesTypes
- is not specified then the listener will be added for all series type
- otherwise it will be added for a specific series type
-
Removes the series legend item click listener. If the argument
- seriesTypes is not specified then the listener will be removed only for a
- series type SeriesType.COMMONSERIES otherwise the listener will be
- removed for all specified series types.
-
-
-
Parameters:
listener - the listener to be removed
seriesTypes - one or more series types as defined by (@link SeriesType}
Adds the chart svg available listener for this chart. If the chart
- already has a listener of this type then the existing listener will be
- removed and the argument listener will be registered.
-
-
-
Parameters:
listener - the Listener to be added or registered.
The data of a chart is defined in terms of InvientCharts.Series. This method
- removes all previously set series of this chart and adds the argument
- series. If the argument series is null then no actions are taken.
-
-
-
Parameters:
series - A collection of series to set as chart's data
Removes the argument seriesData from this chart.
-
-
-
Parameters:
seriesData - the series object to be removed
-
-
-
-
-
-refresh
-
-public void refresh()
-
-
After a series is added or removed, there is no need to call this method
- as it is handled implicitly. This method will send updates to the client.
- This method should be called after adding/removing plotbands and
- plotlines. This inconsistency will be fixed in next revision.
-
-
-
-
-
-
-
-
-print
-
-public void print()
-
-
Displays a Print dialog of the Webkit to print this chart. Invoking this
- method causes the Webkit to hide other widgets on the screen and only
- this chart widget will be visible. Also it prints this chart widget as it
- is displayed.
-
setFillOpacity(java.lang.Double fillOpacity)
-
-
- Sets opacity for the area
-
-
-
- void
-
setLineColor(Paint lineColor)
-
-
- Sets line color for the line of an area.
-
-
-
- void
-
setThreshold(java.lang.Integer threshold)
-
-
- Sets threshold value which servers as the base for the area, for
- distinguishing between values above and below a threshold.
Returns an array containing the constants of this enum type, in
-the order they are declared. This method may be used to iterate
-over the constants as follows:
-
-for (InvientChartsConfig.AxisBase.AxisTitleAlign c : InvientChartsConfig.AxisBase.AxisTitleAlign.values())
- System.out.println(c);
-
-
-
-
-
Returns:
an array containing the constants of this enum type, in
-the order they are declared
Returns the enum constant of this type with the specified name.
-The string must match exactly an identifier used to declare an
-enum constant in this type. (Extraneous whitespace characters are
-not permitted.)
-
-
-
Parameters:
name - the name of the enum constant to be returned.
-
Returns:
the enum constant with the specified name
-
Throws:
-
java.lang.IllegalArgumentException - if this enum type has no constant
-with the specified name
-
java.lang.NullPointerException - if the argument is null
-Defines axis types.
-
- AxisType.LINEAR -
-
- AxisType.DATETIME - For datetime axis, the values are given in date
- except for InvientChartsConfig.BaseLineConfig.pointStart and InvientChartsConfig.BaseLineConfig.pointInterval
- properties, which are specified in milliseconds.
-
Returns an array containing the constants of this enum type, in
-the order they are declared. This method may be used to iterate
-over the constants as follows:
-
-for (InvientChartsConfig.AxisBase.AxisType c : InvientChartsConfig.AxisBase.AxisType.values())
- System.out.println(c);
-
-
-
-
-
Returns:
an array containing the constants of this enum type, in
-the order they are declared
Returns the enum constant of this type with the specified name.
-The string must match exactly an identifier used to declare an
-enum constant in this type. (Extraneous whitespace characters are
-not permitted.)
-
-
-
Parameters:
name - the name of the enum constant to be returned.
-
Returns:
the enum constant with the specified name
-
Throws:
-
java.lang.IllegalArgumentException - if this enum type has no constant
-with the specified name
-
java.lang.NullPointerException - if the argument is null
public static class InvientChartsConfig.AxisBase.MinorTick
extends java.lang.Object
implements java.io.Serializable
-
-
-
-Defines attributes of a minor tick. The minor ticks do not have a
- label. By default, minor ticks are not shown. To display minor ticks,
- set interval property.
-
Sets interval for the minor tick. The interval must be specified
- in the axis unit. e.g. If an axis has tick interval of 50 units
- then setting minortick interval to 10 will show 5 minor ticks.
-
-Defines attributes of a tick marks. The interval of the tick marks
- must be specified in axis unit. For datetime axis, the interval must
- be in millisecond.
-
- The default tick interval is 1.
-
Returns an array containing the constants of this enum type, in
-the order they are declared. This method may be used to iterate
-over the constants as follows:
-
-for (InvientChartsConfig.AxisBase.TickPosition c : InvientChartsConfig.AxisBase.TickPosition.values())
- System.out.println(c);
-
-
-
-
-
Returns:
an array containing the constants of this enum type, in
-the order they are declared
Returns the enum constant of this type with the specified name.
-The string must match exactly an identifier used to declare an
-enum constant in this type. (Extraneous whitespace characters are
-not permitted.)
-
-
-
Parameters:
name - the name of the enum constant to be returned.
-
Returns:
the enum constant with the specified name
-
Throws:
-
java.lang.IllegalArgumentException - if this enum type has no constant
-with the specified name
-
java.lang.NullPointerException - if the argument is null
-Defines position of the tick marks with respect to the axis
- categories. It is applicable only for categorized axes.
-
- TickmarkPlacement.ON - tick mark is placed in the center of the
- category
-
- TickmarkPlacement.BETWEEN - tick mark is placed between categories
-
Returns an array containing the constants of this enum type, in
-the order they are declared. This method may be used to iterate
-over the constants as follows:
-
-for (InvientChartsConfig.AxisBase.TickmarkPlacement c : InvientChartsConfig.AxisBase.TickmarkPlacement.values())
- System.out.println(c);
-
-
-
-
-
Returns:
an array containing the constants of this enum type, in
-the order they are declared
Returns the enum constant of this type with the specified name.
-The string must match exactly an identifier used to declare an
-enum constant in this type. (Extraneous whitespace characters are
-not permitted.)
-
-
-
Parameters:
name - the name of the enum constant to be returned.
-
Returns:
the enum constant with the specified name
-
Throws:
-
java.lang.IllegalArgumentException - if this enum type has no constant
-with the specified name
-
java.lang.NullPointerException - if the argument is null
Returns an array containing the constants of this enum type, in
-the order they are declared. This method may be used to iterate
-over the constants as follows:
-
-for (InvientChartsConfig.AxisBase.WeekDay c : InvientChartsConfig.AxisBase.WeekDay.values())
- System.out.println(c);
-
-
-
-
-
Returns:
an array containing the constants of this enum type, in
-the order they are declared
Returns the enum constant of this type with the specified name.
-The string must match exactly an identifier used to declare an
-enum constant in this type. (Extraneous whitespace characters are
-not permitted.)
-
-
-
Parameters:
name - the name of the enum constant to be returned.
-
Returns:
the enum constant with the specified name
-
Throws:
-
java.lang.IllegalArgumentException - if this enum type has no constant
-with the specified name
-
java.lang.NullPointerException - if the argument is null
Sets maximum amount of zoom for this axis. For datetime axis, the
- maxZoom must be specified in milliseconds. For example, for a
- datetime axis the main unit is milliseconds. If maxZoom is set to
- 3600000, you can't zoom in more than to one hour. (Above example is
- taken from Highcharts documentation)
-
If the argument is true then another axis on the opposite side of
- this axis will be displayed. The normal axis is on left side for
- vertical axes and bottom for horzontal axes.
-
Sets another axis which is linked with this axis. The following
- description is copied from Highcharts API documentation
- http://www.highcharts.com/ref/#xAxis.
-
- When an axis is linked to a master axis, it will take the same
- extremes as the master, but as assigned by min or max or by
- setExtremes. It can be used to show additional info, or to ease
- reading the chart by duplicating the scales. Defaults to null.
-
Sets a day to be considered as start of the week. For datetime axis,
- this decides where to put tick. e.g. if startOfWeek = THURSDAY then
- tick will be placed on every thursday.
-
setBorderColor(Paint borderColor)
-
-
- Sets the color of the border surronding each column or bar.
-
-
-
- void
-
setBorderRadius(java.lang.Integer borderRadius)
-
-
- Sets corner radius of the border surronding each column or bar.
-
-
-
- void
-
setBorderWidth(java.lang.Integer borderWidth)
-
-
- Sets width of the border surronding each column or bar.
-
-
-
- void
-
setColorByPoint(java.lang.Boolean colorByPoint)
-
-
- If the argument is true then each point (bar or column in a series
- will have a different color otherwise all points (bars/columns) of a
- series will have same color.
-
-
-
- void
-
setGroupPadding(java.lang.Double groupPadding)
-
-
- Sets padding between each value groups, in x axis units.
If the argument is true then each point (bar or column in a series
- will have a different color otherwise all points (bars/columns) of a
- series will have same color.
-
Sets the minimal height for a column or width for a bar. By default,
- 0 values are not shown. To visualize a 0 (or close to zero) point,
- set the minimal point length to a pixel value like 3. In stacked
- column charts, minPointLength might not be respected for tightly
- packed values. Defaults to 0. (For detail, refer to
- http://www.highcharts.com/ref/#plotOptions-bar);
-
setPointInterval(java.lang.Double pointInterval)
-
-
- If no x values are given for the points in a series, the argument
- pointInterval defines the interval of the x values.
-
-
-
- void
-
setPointStart(java.lang.Double pointStart)
-
-
- If no x values are given for the points in a series, the argument
- pointStart defines on what value to start.
-
-
-
- void
-
setStickyTracking(java.lang.Boolean stickyTracking)
-
-
- If the argument is true then the mouseout event on a series is not
- triggered until mouse moves over another series or comes out of the
- plot area.
If no x values are given for the points in a series, the argument
- pointStart defines on what value to start. Defaults to 0. e.g. if a
- series contains values higher than 2 m $ then sets pointStart to
- 2,000,000
-
If no x values are given for the points in a series, the argument
- pointInterval defines the interval of the x values. For example, if a
- series contains one value every day then set pointInterval to 24 *
- 3600 * 1000
-
If the argument is true then the mouseout event on a series is not
- triggered until mouse moves over another series or comes out of the
- plot area. If the argument is true then the mouseout event occurs as
- soon as mouse leaves area near to the point or marker
-
Returns an array containing the constants of this enum type, in
-the order they are declared. This method may be used to iterate
-over the constants as follows:
-
-for (InvientChartsConfig.DashStyle c : InvientChartsConfig.DashStyle.values())
- System.out.println(c);
-
-
-
-
-
Returns:
an array containing the constants of this enum type, in
-the order they are declared
Returns the enum constant of this type with the specified name.
-The string must match exactly an identifier used to declare an
-enum constant in this type. (Extraneous whitespace characters are
-not permitted.)
-
-
-
Parameters:
name - the name of the enum constant to be returned.
-
Returns:
the enum constant with the specified name
-
Throws:
-
java.lang.IllegalArgumentException - if this enum type has no constant
-with the specified name
-
java.lang.NullPointerException - if the argument is null
Sets the argument string JavaScript function. This function will be
- called to format the data label. Refer to highchart documentation for
- more details on this
- http://www.highcharts.com/ref/#plotOptions-series-dataLabels
-
Sets color for the data labels. e.g. if the color is blue then in
- case of line series, for each point, the data label will be displayed
- in blue color.
-
-The value ZoomType.X represents horizontal zoom. The value
- ZoomType.Y represents vertical zoom. The value
- ZoomType.XY represents horizontal as well as vertical zoom.
-
Returns an array containing the constants of this enum type, in
-the order they are declared. This method may be used to iterate
-over the constants as follows:
-
-for (InvientChartsConfig.GeneralChartConfig.ZoomType c : InvientChartsConfig.GeneralChartConfig.ZoomType.values())
- System.out.println(c);
-
-
-
-
-
Returns:
an array containing the constants of this enum type, in
-the order they are declared
Returns the enum constant of this type with the specified name.
-The string must match exactly an identifier used to declare an
-enum constant in this type. (Extraneous whitespace characters are
-not permitted.)
-
-
-
Parameters:
name - the name of the enum constant to be returned.
-
Returns:
the enum constant with the specified name
-
Throws:
-
java.lang.IllegalArgumentException - if this enum type has no constant
-with the specified name
-
java.lang.NullPointerException - if the argument is null
setAlignTicks(java.lang.Boolean alignTicks)
-
-
- When using multiple axis, the ticks of two or more opposite axes will
- automatically be aligned by adding ticks to the axis or axes with the
- least ticks.
-
-
-
- void
-
setAnimation(java.lang.Boolean animation)
-
-
- Set the overall animation for all chart updating.
-
-
-
- void
-
setBackgroundColor(Paint backgroundColor)
-
-
- Sets the background color for the outer chart area
-
-
-
- void
-
setBorderColor(Paint borderColor)
-
-
- Sets the border color for the outer chart border
-
-
-
- void
-
setBorderRadius(java.lang.Integer borderRadius)
-
-
- Sets radius for the outer chart border
-
-
-
- void
-
setBorderWidth(java.lang.Integer borderWidth)
-
-
- Sets pixel width of the outer chart border
-
-
-
- void
-
setClassName(java.lang.String className)
-
-
- A CSS class name to apply to the charts container
-
-
-
- void
-
setClientZoom(boolean clientZoom)
-
-
- If the argument is true then the scaling will happen on client.
-
-
-
- void
-
setHeight(java.lang.Integer height)
-
-
- Sets height for the chart
-
-
-
- void
-
setIgnoreHiddenSeries(java.lang.Boolean ignoreHiddenSeries)
-
-
- If the argument is true, the axes will scale to the remaining visible
- series once one series is hidden.
-
-
-
- void
-
setInverted(java.lang.Boolean inverted)
-
-
- If the argument is true then the x-axis is reversed.
When using multiple axis, the ticks of two or more opposite axes will
- automatically be aligned by adding ticks to the axis or axes with the
- least ticks. This can be prevented by setting alignTicks to false.
-
If the argument is true, the axes will scale to the remaining visible
- series once one series is hidden. If the argument is false, hiding
- and showing a series will not affect the axes or the other series.
-
Sets zoom type. It decides how a chart can be zoomed by dragging the
- mouse.
-
-
-
-
-
-
Parameters:
zoomType -
-
-
-
-
-
-isClientZoom
-
-public boolean isClientZoom()
-
-
-
-
-
-
-
Returns:
-
-
-
-
-
-setClientZoom
-
-public void setClientZoom(boolean clientZoom)
-
-
If the argument is true then the scaling will happen on client. If
- the argument is false then the chart will not scale. In any case, the
- server will receive event notification if registered.
-
Returns an array containing the constants of this enum type, in
-the order they are declared. This method may be used to iterate
-over the constants as follows:
-
-for (InvientChartsConfig.HorzAlign c : InvientChartsConfig.HorzAlign.values())
- System.out.println(c);
-
-
-
-
-
Returns:
an array containing the constants of this enum type, in
-the order they are declared
Returns the enum constant of this type with the specified name.
-The string must match exactly an identifier used to declare an
-enum constant in this type. (Extraneous whitespace characters are
-not permitted.)
-
-
-
Parameters:
name - the name of the enum constant to be returned.
-
Returns:
the enum constant with the specified name
-
Throws:
-
java.lang.IllegalArgumentException - if this enum type has no constant
-with the specified name
-
java.lang.NullPointerException - if the argument is null
-This marker can take url of an image which will be used as a marker for a
- point or all points of a series.
-
- The url of an image must be with respect to root of the web application.
- e.g. If an image named temperature.png is under directory
- /img/climate then the url must be
- /img/climate/temperature.png
-
Returns an array containing the constants of this enum type, in
-the order they are declared. This method may be used to iterate
-over the constants as follows:
-
-for (InvientChartsConfig.Legend.Layout c : InvientChartsConfig.Legend.Layout.values())
- System.out.println(c);
-
-
-
-
-
Returns:
an array containing the constants of this enum type, in
-the order they are declared
Returns the enum constant of this type with the specified name.
-The string must match exactly an identifier used to declare an
-enum constant in this type. (Extraneous whitespace characters are
-not permitted.)
-
-
-
Parameters:
name - the name of the enum constant to be returned.
-
Returns:
the enum constant with the specified name
-
Throws:
-
java.lang.IllegalArgumentException - if this enum type has no constant
-with the specified name
-
java.lang.NullPointerException - if the argument is null
public static interface InvientChartsConfig.Marker
extends java.io.Serializable
-
-
-
-Defines a marker for a point. Markers are applied to a point of chart's
- series. The marker can be applied at the time of drawing the chart or
- when a point is selcted or hovered.
-
- There are two types of marker.
-
-Defines a set of attributes which gets applied to a point when a point is
- selected or hovered. By default, markers are enabled so when a mouse is
- over a point marker gets applied. To turn off marker, set flag enabled to
- false.
-
- A point marker is useful only if the marker is not an image.
-
If the argument is true then the series is visible otherwise not when
- a chart is rendered initially. Defaults to true However, this is not
- applicable for series related to Pie chart.
-
setAllowPointSelect(java.lang.Boolean allowPointSelect)
-
-
- If the argument is true then the points of a can be selected
- otherwise not.
-
-
-
- void
-
setAnimation(java.lang.Boolean animation)
-
-
- If the argument is true then animation will be enabled when a series
- will be displayed otherwise not.
-
-
-
- void
-
setColor(Paint color)
-
-
- Sets color for the series.
-
-
-
- void
-
setCursor(java.lang.String cursor)
-
-
- Sets the cursor style.
setEnableMouseTracking(java.lang.Boolean enableMouseTracking)
-
-
- If the argument is true then the mouse tracking will be enabled for a
- series otherwise not.
setShadow(java.lang.Boolean shadow)
-
-
- If the argument is true then a shadow will be shown to the graph line
- otherwise not.
-
-
-
- void
-
setShowCheckbox(java.lang.Boolean showCheckbox)
-
-
- If the argument is true then a checkbox is displayed next to the
- legend item in the legend area.
-
-
-
- void
-
setShowInLegend(java.lang.Boolean showInLegend)
-
-
- If the argument is true then a series will be displayed in the legend
- otherwise not.
If the argument is true then the points of a can be selected
- otherwise not. Defaults to false, The point on a chart will toggle.
- Also, whenever a point is selected or deselected, the registered
- event listeners will be triggered.
-
Specifies whether the values of each series should be stacked on top
- of each other or not. Defaults to null. If the argument is null then
- the values of each series are not stacked.
-
If the argument is true then the series is visible otherwise not when
- a chart is rendered initially. Defaults to true However, this is not
- applicable for series related to Pie chart.
-
-Defines a set of attributes which will be applied to a series upon hover.
- The attributes linWidth is not applicable for Pie, Scatter, Bar and
- Column series.
-
setEnabled(java.lang.Boolean enabled)
-
-
- If the argument is true then the other properties of this class have
- impact on visual rendering of the series when a series is hovered or
- when a mouse is over the legend.
-
-
-
- void
-
setLineWidth(java.lang.Integer lineWidth)
-
-
- Sets width of a line in pixel.
If the argument is true then the other properties of this class have
- impact on visual rendering of the series when a series is hovered or
- when a mouse is over the legend. Enabling this has a performance
- penalty.
-
- Defaults to false.
-
-Defines ways in which series of a chart can be stacked.
-
- Stacking.Normal - represents that the values of each series are stacked.
-
- Stacking.Percent - represents that the the values of each series are
- stacked based on percentage of sum of total value, where total value is
- sum of values of all points on a particular tick of an axis.
-
Returns an array containing the constants of this enum type, in
-the order they are declared. This method may be used to iterate
-over the constants as follows:
-
-for (InvientChartsConfig.Stacking c : InvientChartsConfig.Stacking.values())
- System.out.println(c);
-
-
-
-
-
Returns:
an array containing the constants of this enum type, in
-the order they are declared
Returns the enum constant of this type with the specified name.
-The string must match exactly an identifier used to declare an
-enum constant in this type. (Extraneous whitespace characters are
-not permitted.)
-
-
-
Parameters:
name - the name of the enum constant to be returned.
-
Returns:
the enum constant with the specified name
-
Throws:
-
java.lang.IllegalArgumentException - if this enum type has no constant
-with the specified name
-
java.lang.NullPointerException - if the argument is null
-Defines state for a series and point. A series can be in hover state. A
- point can be in hover and select state. In each state, a series and a
- point can have different visual clues. This is achived by setting some
- attributes of a seires and point.
-
Returns an array containing the constants of this enum type, in
-the order they are declared. This method may be used to iterate
-over the constants as follows:
-
-for (InvientChartsConfig.SymbolMarker.Symbol c : InvientChartsConfig.SymbolMarker.Symbol.values())
- System.out.println(c);
-
-
-
-
-
Returns:
an array containing the constants of this enum type, in
-the order they are declared
Returns the enum constant of this type with the specified name.
-The string must match exactly an identifier used to declare an
-enum constant in this type. (Extraneous whitespace characters are
-not permitted.)
-
-
-
Parameters:
name - the name of the enum constant to be returned.
-
Returns:
the enum constant with the specified name
-
Throws:
-
java.lang.IllegalArgumentException - if this enum type has no constant
-with the specified name
-
java.lang.NullPointerException - if the argument is null
Sets margin (in pixel) between the chart title and subtitle, if any.
- If chart subtitle doesn't exist then it indicates the margin between
- subtitle and plotarea. Defaults to 15
-
public abstract static class InvientChartsConfig.TitleBase
extends java.lang.Object
implements java.io.Serializable
-
-
-
-A chart has a title and a subtitle. This class defines attributes which
- are common to both.
-
- The text of a title can be plain text or html text containing html
- elements. It is also possible to apply css to the title. The css must be
- valid css string e.g. { color: 'red' }
-
Returns an array containing the constants of this enum type, in
-the order they are declared. This method may be used to iterate
-over the constants as follows:
-
-for (InvientChartsConfig.VertAlign c : InvientChartsConfig.VertAlign.values())
- System.out.println(c);
-
-
-
-
-
Returns:
an array containing the constants of this enum type, in
-the order they are declared
Returns the enum constant of this type with the specified name.
-The string must match exactly an identifier used to declare an
-enum constant in this type. (Extraneous whitespace characters are
-not permitted.)
-
-
-
Parameters:
name - the name of the enum constant to be returned.
-
Returns:
the enum constant with the specified name
-
Throws:
-
java.lang.IllegalArgumentException - if this enum type has no constant
-with the specified name
-
java.lang.NullPointerException - if the argument is null
InvientCharts.DateTimeSeries.addPoint(InvientCharts.DateTimePoint... points)
-
-
- Appends the specified point into the series if they do not exists in
- this series.
InvientCharts.DateTimeSeries.addPoint(InvientCharts.DateTimePoint... points)
-
-
- Appends the specified point into the series if they do not exists in
- this series.
InvientCharts.XYSeries.addPoint(InvientCharts.DecimalPoint... points)
-
-
- Appends the specified point into the series if they do not exists in
- this series.
InvientCharts.XYSeries.addPoint(InvientCharts.DecimalPoint... points)
-
-
- Appends the specified point into the series if they do not exists in
- this series.
InvientChartsConfig.GeneralChartConfig.setType(InvientCharts.SeriesType type)
-
-
- Sets series type to one of line, spline, scatter, area, areaspline,
- pie, bar and column.
InvientChartsConfig.AxisBase.AxisTitleAlign.values()
-
-
- Returns an array containing the constants of this enum type, in
-the order they are declared.
InvientChartsConfig.AxisBase.TickmarkPlacement.values()
-
-
- Returns an array containing the constants of this enum type, in
-the order they are declared.
InvientChartsConfig.SeriesConfig.setDataLabel(InvientChartsConfig.DataLabel dataLabel)
-
-
- Sets how point value should be formatted and displayed for each
- point.
InvientChartsConfig.GeneralChartConfig.ZoomType.values()
-
-
- Returns an array containing the constants of this enum type, in
-the order they are declared.
InvientChartsConfig.SeriesConfig.setStacking(InvientChartsConfig.Stacking stacking)
-
-
- Specifies whether the values of each series should be stacked on top
- of each other or not.
InvientChartsConfig.PieDataLabel.setConnectorColor(Paint connectorColor)
-
-
- Sets the color of the line connecting the data label to the pie
- slice.
-
-
-
- void
-
InvientChartsConfig.AreaConfig.setFillColor(Paint fillColor)
-
-
- Sets fill gradient for the area
-
-
-
- void
-
InvientChartsConfig.MarkerState.setFillColor(Paint fillColor)
-
-
- Sets fill color for the marker.
-
-
-
- void
-
InvientChartsConfig.SymbolMarker.setFillColor(Paint fillColor)
-
-
- Sets color of the point marker
-
-
-
- void
-
InvientChartsConfig.AreaConfig.setLineColor(Paint lineColor)
-
-
- Sets line color for the line of an area.
-
-
-
- void
-
InvientChartsConfig.MarkerState.setLineColor(Paint lineColor)
-
-
- Sets color of the point marker's outline.
-
-
-
- void
-
InvientChartsConfig.SymbolMarker.setLineColor(Paint lineColor)
-
-
- Sets color of the point marker's outline
-
-
-
- void
-
InvientChartsConfig.AxisBase.setLineColor(Paint lineColor)
-
-
- Sets a color for line of this axis.
-
-
-
- void
-
InvientChartsConfig.AxisBase.MinorGrid.setLineColor(Paint lineColor)
-
-
- Sets color of the minor grid lines
-Client side widget which communicates with the server. Messages from the
- server are shown as HTML and mouse clicks are sent to the server.
-
- Reads data from UIDL and create appropriate JavaScript overlay objects such
- as GwtChart, GwtAxis, GwtInvientChartsConfig,
- GwtPoint and GwtSeries
-
- Uses a method newChart() of GwtInvientChartsUtil to create a chart
- object of type GwtChart
-
-
-
-
-
Author:
-
Invient
-
-
-
-
-
-
-
-
-
-
-Nested Class Summary
-
-
-
-
-
-
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
updateFromUIDL(com.vaadin.terminal.gwt.client.UIDL uidl,
- com.vaadin.terminal.gwt.client.ApplicationConnection client)
-
-
- Called whenever an update is received from the server
-
-
-
-
-
-
Methods inherited from class com.google.gwt.user.client.ui.Widget
-This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
-Overview
-
-
-
-The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.
-
-Package
-
-
-
-Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:
-
Interfaces (italic)
Classes
Enums
Exceptions
Errors
Annotation Types
-
-
-Class/Interface
-
-
-
-Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
-
Class inheritance diagram
Direct Subclasses
All Known Subinterfaces
All Known Implementing Classes
Class/interface declaration
Class/interface description
-
-
Nested Class Summary
Field Summary
Constructor Summary
Method Summary
-
-
Field Detail
Constructor Detail
Method Detail
-Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
-
-
-Annotation Type
-
-
-
-Each annotation type has its own separate page with the following sections:
-
Annotation Type declaration
Annotation Type description
Required Element Summary
Optional Element Summary
Element Detail
-
-
-
-Enum
-
-
-
-Each enum has its own separate page with the following sections:
-
Enum declaration
Enum description
Enum Constant Summary
Enum Constant Detail
-
-
-Use
-
-Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.
-
-Tree (Class Hierarchy)
-
-There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
-
When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
-
-
-Deprecated API
-
-The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
-
-Index
-
-The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
-
-Prev/Next
-These links take you to the next or previous class, interface, package, or related page.
-Frames/No Frames
-These links show and hide the HTML frames. All pages are available with or without frames.
-
-
-Serialized Form
-Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
-
When using multiple axis, the ticks of two or more opposite axes will
- automatically be aligned by adding ticks to the axis or axes with the
- least ticks.
-
If the argument is true then each point (bar or column in a series
- will have a different color otherwise all points (bars/columns) of a
- series will have same color.
-
If the argument is true then the other properties of this class have
- impact on visual rendering of the series when a series is hovered or
- when a mouse is over the legend.
-
If the argument is true then the mouseout event on a series is not
- triggered until mouse moves over another series or comes out of the
- plot area.
-
-
-
-
-
-
-
-
diff --git a/doc/stylesheet.css b/doc/stylesheet.css
deleted file mode 100644
index 6ea9e51..0000000
--- a/doc/stylesheet.css
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Javadoc style sheet */
-
-/* Define colors, fonts and other style attributes here to override the defaults */
-
-/* Page background color */
-body { background-color: #FFFFFF; color:#000000 }
-
-/* Headings */
-h1 { font-size: 145% }
-
-/* Table colors */
-.TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */
-.TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */
-.TableRowColor { background: #FFFFFF; color:#000000 } /* White */
-
-/* Font used in left-hand frame lists */
-.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
-.FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
-.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
-
-/* Navigation bar fonts and colors */
-.NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */
-.NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */
-.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;}
-.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;}
-
-.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}
-.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}
-
diff --git a/invient-charts-demo/pom.xml b/invient-charts-demo/pom.xml
new file mode 100644
index 0000000..786718b
--- /dev/null
+++ b/invient-charts-demo/pom.xml
@@ -0,0 +1,153 @@
+
+
+ 4.0.0
+
+
+ com.invient.vaadin.charts
+ invient-charts
+ 1.1-SNAPSHOT
+
+
+ invient-charts-demo
+ war
+ InvientCharts - Demo
+ Demo project that showcases the features of InvientCharts.
+
+
+
+ com.vaadin
+ vaadin
+
+
+ com.google.gwt
+ gwt-user
+
+
+ com.invient.vaadin.charts
+ invient-charts-addon
+ 1.1-SNAPSHOT
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.5.1
+
+ 1.6
+ 1.6
+ UTF-8
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 2.5
+
+ UTF-8
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 2.8.1
+
+ UTF-8
+ 1.5
+
+
+
+ install
+
+ javadoc
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 2.1.2
+
+
+ install
+
+ jar
+
+
+
+
+
+
+ org.codehaus.mojo
+ gwt-maven-plugin
+ ${gwt.plugin.version}
+
+ ${project.build.directory}/${project.build.finalName}/VAADIN/widgetsets
+
+ -Xmx1024M -Xss2024k
+ invient-charts-demo
+ ${project.build.directory}/${project.build.finalName}
+ true
+ 8080
+ false
+
+
+
+
+ resources
+ compile
+
+
+
+
+
+ com.google.gwt
+ gwt-dev
+ ${gwt.version}
+
+
+ com.google.gwt
+ gwt-user
+ ${gwt.version}
+
+
+
+
+
+ com.vaadin
+ vaadin-maven-plugin
+ 1.0.2
+
+
+
+
+
+ update-widgetset
+
+
+
+
+
+
+ org.mortbay.jetty
+ jetty-maven-plugin
+ 8.1.10.v20130312
+
+
+ /invient-charts-demo
+
+ src/main/webapp,${project.build.directory}/${project.build.finalName}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/demo/com/invient/vaadin/InvientChartsDemoApp.java b/invient-charts-demo/src/main/java/com/invient/vaadin/InvientChartsDemoApp.java
old mode 100755
new mode 100644
similarity index 100%
rename from demo/com/invient/vaadin/InvientChartsDemoApp.java
rename to invient-charts-demo/src/main/java/com/invient/vaadin/InvientChartsDemoApp.java
diff --git a/demo/com/invient/vaadin/InvientChartsDemoAppServlet.java b/invient-charts-demo/src/main/java/com/invient/vaadin/InvientChartsDemoAppServlet.java
old mode 100755
new mode 100644
similarity index 80%
rename from demo/com/invient/vaadin/InvientChartsDemoAppServlet.java
rename to invient-charts-demo/src/main/java/com/invient/vaadin/InvientChartsDemoAppServlet.java
index 2209fa8..82e9a50
--- a/demo/com/invient/vaadin/InvientChartsDemoAppServlet.java
+++ b/invient-charts-demo/src/main/java/com/invient/vaadin/InvientChartsDemoAppServlet.java
@@ -25,18 +25,22 @@
import com.vaadin.terminal.gwt.server.ApplicationServlet;
import com.vaadin.ui.Window;
+@SuppressWarnings("serial")
public class InvientChartsDemoAppServlet extends ApplicationServlet {
+ /**
+ * {@inheritDoc}
+ */
@Override
protected void writeAjaxPageHtmlVaadinScripts(Window window,
String themeName, Application application, BufferedWriter page,
String appUrl, String themeUri, String appId,
HttpServletRequest request) throws ServletException, IOException {
- page.write("\n");
super.writeAjaxPageHtmlVaadinScripts(window, themeName, application,
page, appUrl, themeUri, appId, request);
diff --git a/invient-charts-demo/src/main/java/com/invient/vaadin/InvientChartsDemoAppWidgetset.gwt.xml b/invient-charts-demo/src/main/java/com/invient/vaadin/InvientChartsDemoAppWidgetset.gwt.xml
new file mode 100644
index 0000000..95dd665
--- /dev/null
+++ b/invient-charts-demo/src/main/java/com/invient/vaadin/InvientChartsDemoAppWidgetset.gwt.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
diff --git a/demo/com/invient/vaadin/InvientChartsDemoWin.java b/invient-charts-demo/src/main/java/com/invient/vaadin/InvientChartsDemoWin.java
old mode 100755
new mode 100644
similarity index 99%
rename from demo/com/invient/vaadin/InvientChartsDemoWin.java
rename to invient-charts-demo/src/main/java/com/invient/vaadin/InvientChartsDemoWin.java
index 5080854..7344f3e
--- a/demo/com/invient/vaadin/InvientChartsDemoWin.java
+++ b/invient-charts-demo/src/main/java/com/invient/vaadin/InvientChartsDemoWin.java
@@ -2105,7 +2105,7 @@ private void showSplineWithSymbol() {
//
Tooltip tooltip = new Tooltip();
- tooltip.setCrosshairs(true);
+ tooltip.setCrosshairs(new Tooltip.Crosshairs());
tooltip.setShared(true);
chartConfig.setTooltip(tooltip);
diff --git a/WebContent/graphics/snow.png b/invient-charts-demo/src/main/webapp/VAADIN/graphics/snow.png
similarity index 100%
rename from WebContent/graphics/snow.png
rename to invient-charts-demo/src/main/webapp/VAADIN/graphics/snow.png
diff --git a/WebContent/graphics/sun.png b/invient-charts-demo/src/main/webapp/VAADIN/graphics/sun.png
similarity index 100%
rename from WebContent/graphics/sun.png
rename to invient-charts-demo/src/main/webapp/VAADIN/graphics/sun.png
diff --git a/WebContent/js/adapters/mootools-adapter.js b/invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/adapters/mootools-adapter.js
old mode 100644
new mode 100755
similarity index 100%
rename from WebContent/js/adapters/mootools-adapter.js
rename to invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/adapters/mootools-adapter.js
diff --git a/WebContent/js/adapters/mootools-adapter.src.js b/invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/adapters/mootools-adapter.src.js
old mode 100644
new mode 100755
similarity index 100%
rename from WebContent/js/adapters/mootools-adapter.src.js
rename to invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/adapters/mootools-adapter.src.js
diff --git a/WebContent/js/adapters/prototype-adapter.js b/invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/adapters/prototype-adapter.js
old mode 100644
new mode 100755
similarity index 100%
rename from WebContent/js/adapters/prototype-adapter.js
rename to invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/adapters/prototype-adapter.js
diff --git a/WebContent/js/adapters/prototype-adapter.src.js b/invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/adapters/prototype-adapter.src.js
old mode 100644
new mode 100755
similarity index 100%
rename from WebContent/js/adapters/prototype-adapter.src.js
rename to invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/adapters/prototype-adapter.src.js
diff --git a/WebContent/js/highcharts.js b/invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/highcharts.js
old mode 100644
new mode 100755
similarity index 100%
rename from WebContent/js/highcharts.js
rename to invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/highcharts.js
diff --git a/WebContent/js/modules/exporting.js b/invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/modules/exporting.js
old mode 100644
new mode 100755
similarity index 100%
rename from WebContent/js/modules/exporting.js
rename to invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/modules/exporting.js
diff --git a/WebContent/js/modules/exporting.src.js b/invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/modules/exporting.src.js
old mode 100644
new mode 100755
similarity index 100%
rename from WebContent/js/modules/exporting.src.js
rename to invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/modules/exporting.src.js
diff --git a/WebContent/js/themes/dark-blue.js b/invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/themes/dark-blue.js
old mode 100644
new mode 100755
similarity index 100%
rename from WebContent/js/themes/dark-blue.js
rename to invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/themes/dark-blue.js
diff --git a/WebContent/js/themes/dark-green.js b/invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/themes/dark-green.js
old mode 100644
new mode 100755
similarity index 100%
rename from WebContent/js/themes/dark-green.js
rename to invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/themes/dark-green.js
diff --git a/WebContent/js/themes/gray.js b/invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/themes/gray.js
old mode 100644
new mode 100755
similarity index 100%
rename from WebContent/js/themes/gray.js
rename to invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/themes/gray.js
diff --git a/WebContent/js/themes/grid.js b/invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/themes/grid.js
old mode 100644
new mode 100755
similarity index 100%
rename from WebContent/js/themes/grid.js
rename to invient-charts-demo/src/main/webapp/VAADIN/js/highcharts/themes/grid.js
diff --git a/WebContent/jquery/jquery-1.4.4.min.js b/invient-charts-demo/src/main/webapp/VAADIN/js/jquery/jquery-1.4.4.min.js
old mode 100644
new mode 100755
similarity index 100%
rename from WebContent/jquery/jquery-1.4.4.min.js
rename to invient-charts-demo/src/main/webapp/VAADIN/js/jquery/jquery-1.4.4.min.js
diff --git a/WebContent/VAADIN/themes/chartdemo/styles.css b/invient-charts-demo/src/main/webapp/VAADIN/themes/chartdemo/styles.css
similarity index 100%
rename from WebContent/VAADIN/themes/chartdemo/styles.css
rename to invient-charts-demo/src/main/webapp/VAADIN/themes/chartdemo/styles.css
diff --git a/invient-charts-demo/src/main/webapp/VAADIN/themes/chartdemo/styles.css~1f6b558... Mavenized InvientCharts project as-per Vaadin prescribed structure b/invient-charts-demo/src/main/webapp/VAADIN/themes/chartdemo/styles.css~1f6b558... Mavenized InvientCharts project as-per Vaadin prescribed structure
new file mode 100644
index 0000000..b2fd8bc
--- /dev/null
+++ b/invient-charts-demo/src/main/webapp/VAADIN/themes/chartdemo/styles.css~1f6b558... Mavenized InvientCharts project as-per Vaadin prescribed structure
@@ -0,0 +1,63 @@
+
+@import url(../reindeer/styles.css);
+
+.v-splitpanel-second-container {
+ background-color: white;
+}
+
+.v-splitpanel-hsplitter {
+ background: none repeat scroll 0 0 #AEB0B5;
+ width: 1px;
+}
+
+.v-splitpanel-hsplitter div {
+ background: none repeat scroll 0 0 transparent;
+ border: medium none;
+ margin: 0 -1px;
+ padding: 0;
+ width: 3px;
+}
+
+.v-caption .v-captiontext {
+ font-size: 14px;
+ font-weight: bold;
+ padding: 14px 0 5px 5px;
+ color: #5C5D60;
+}
+
+.v-textarea-chart-events-log {
+ border: 1px solid #C0C0C0 !important;
+}
+
+.v-caption-v-textarea-chart-events-log .v-captiontext {
+ padding: 0px 0 5px 0px ! important;
+}
+
+.v-chart-min-width {
+ min-width: 600px;
+}
+
+.v-label {
+ font-size: 14px;
+ font-weight: bold;
+ color: #5C5D60;
+}
+
+.v-label-app-title {
+ color: white;
+ float: left;
+ font-size: 24px;
+ font-weight: bold;
+ line-height: 190%;
+ text-align: center;
+ background: repeat-x scroll 0 0 #36332D;
+}
+
+div.v-splitpanel-second-container div.v-chart-master-detail div div:nth-child(n+2) {
+ position:relative;
+ top:-107px;
+}
+
+.i-progressindicator-invisible {
+ display: none;
+}
diff --git a/WebContent/WEB-INF/web.xml b/invient-charts-demo/src/main/webapp/WEB-INF/web.xml
similarity index 50%
rename from WebContent/WEB-INF/web.xml
rename to invient-charts-demo/src/main/webapp/WEB-INF/web.xml
index ad97f03..41c029b 100644
--- a/WebContent/WEB-INF/web.xml
+++ b/invient-charts-demo/src/main/webapp/WEB-INF/web.xml
@@ -5,47 +5,32 @@
id="WebApp_ID" version="3.0">
InvientCharts
-
- Vaadin production mode
+ Vaadin production modeproductionModefalse
- InvientCharts demo Application
+ InvientChartscom.invient.vaadin.InvientChartsDemoAppServlet
-
- Vaadin application class to start
+ Vaadin application class to startapplicationcom.invient.vaadin.InvientChartsDemoApp
-
- widgetset
- com.invient.vaadin.InvientChartsDemoAppWidgetset
- 1
-
-
-
- AsyncServlet
- AsyncServlet
- org.test.servlet.AsyncServlet
-
-
- InvientCharts demo Application
- /demo/*
-
+
- InvientCharts demo Application
- /VAADIN/*
-
-
- AsyncServlet
- /AsyncServlet
+ InvientCharts
+ /*
+
+ widgetset
+ com.invient.vaadin.InvientChartsDemoAppWidgetset
+
+
30
diff --git a/invient-charts/pom.xml b/invient-charts/pom.xml
new file mode 100644
index 0000000..ee833d6
--- /dev/null
+++ b/invient-charts/pom.xml
@@ -0,0 +1,146 @@
+
+
+ 4.0.0
+
+
+ com.invient.vaadin.charts
+ invient-charts
+ 1.1-SNAPSHOT
+
+
+ invient-charts-addon
+ jar
+ Invient Charts Addon
+ A Vaadin widget addon that wraps highcharts.js.
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.5.1
+
+ 1.6
+ 1.6
+ UTF-8
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 2.5
+
+ UTF-8
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 2.4
+
+
+
+ ${project.version}
+ ${project.name}
+ ${project.organization.name}
+ 1
+ com.invient.vaadin.charts.widgetset.InvientChartsWidgetset
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 2.8.1
+
+ UTF-8
+ 1.5
+
+
+
+ package
+
+ jar
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 2.1.2
+
+
+ package
+
+ jar
+
+
+
+
+
+
+ org.codehaus.mojo
+ gwt-maven-plugin
+ ${gwt.plugin.version}
+
+ ${project.build.directory}/${project.build.finalName}/VAADIN/widgetsets
+
+ -Xmx1024M -Xss2024k
+ invient-charts-addon
+ ${project.build.directory}/${project.build.finalName}
+ true
+ 8080
+ false
+
+
+
+
+ resources
+ compile
+
+
+
+
+
+ com.google.gwt
+ gwt-dev
+ ${gwt.version}
+
+
+ com.google.gwt
+ gwt-user
+ ${gwt.version}
+
+
+
+
+
+
+
+
+ src/main/java
+
+
+ src/main/resources
+
+
+
+
+
+
+
+ com.vaadin
+ vaadin
+ provided
+
+
+ com.google.gwt
+ gwt-user
+ provided
+
+
+
+
diff --git a/src/com/invient/vaadin/charts/Color.java b/invient-charts/src/main/java/com/invient/vaadin/charts/Color.java
old mode 100755
new mode 100644
similarity index 66%
rename from src/com/invient/vaadin/charts/Color.java
rename to invient-charts/src/main/java/com/invient/vaadin/charts/Color.java
index 7bb70a1..b6c37f1
--- a/src/com/invient/vaadin/charts/Color.java
+++ b/invient-charts/src/main/java/com/invient/vaadin/charts/Color.java
@@ -18,34 +18,32 @@
/**
* The Color interface represents RBG and RBGA colors.
- * Do not confuse with {@link java.awt.Color} class. This is a simplified
- * version of {@link java.awt.Color} for the purpose of InvientCharts
- *
+ *
+ * Do not confuse with {@link java.awt.Color} class. This is a simplified
+ * version of {@link java.awt.Color} for the purpose of InvientCharts.
+ *
* @author Invient
*/
+@SuppressWarnings("serial")
public interface Color extends Paint {
/**
- * Represents RBG color value.
- *
+ * Represents an RBG color value.
+ *
* @author Invient
- *
*/
- public class RGB implements Color {
+ public static class RGB implements Color {
private int red;
private int green;
private int blue;
/**
- * Creates an RGB color with the specified red, green, and blue values.
+ * Creates an {@link RGB} instance with the specified red, green, and blue values.
* The values must be in the range (0 - 255).
- *
- * @param red
- * the red component in a color
- * @param green
- * the green component in a color
- * @param blue
- * the blue component in a color
+ *
+ * @param red the red component in a color
+ * @param green the green component in a color
+ * @param blue the blue component in a color
*/
public RGB(int red, int green, int blue) {
super();
@@ -75,41 +73,36 @@ public RGB(int red, int green, int blue) {
}
/**
- *
- * @return Returns the red component in the range (0-255).
+ * @return The red component in the range (0-255).
*/
public final int getRed() {
return red;
}
/**
- *
- * @return Returns the green component in the range (0-255).
+ * @return The green component in the range (0-255).
*/
public final int getGreen() {
return green;
}
/**
- *
- * @return Returns the blue component in the range (0-255).
+ * @return The blue component in the range (0-255).
*/
public final int getBlue() {
return blue;
}
/**
- * @return Returns string representation of this RBG.
+ * @return The string representation of this RBG.
*/
@Override
public String getString() {
- return new StringBuilder().append("rgb(").append(red).append(",")
- .append(green).append(",").append(blue).append(")")
- .toString();
+ return "rgb(" + red + "," + green + "," + blue + ")";
}
/**
- * @return Returns string representation of this RBG.
+ * @return The string representation of this RBG.
*/
@Override
public String toString() {
@@ -121,26 +114,23 @@ public String toString() {
/**
* Represents RGBA color value.
- * @author Invient
*
+ * @author Invient
*/
- public class RGBA extends RGB {
+ public static class RGBA extends RGB {
+
private float alpha = 1.0f;
/**
- * Creates an RGBA color with the specified red, green, blue and alpha
+ * Creates an {@link RGBA} instance with the specified red, green, blue and alpha
* values. The red, green and blue values must be in the range (0 -
- * 255). The alpha value must be in the range (0.0-1.0). The alpha value
- * deaults to 1.0
- *
- * @param red
- * the red component in a color
- * @param green
- * the green component in a color
- * @param blue
- * the blue component in a color
- * @param alpha
- * the alpha component in a color
+ * 255). The alpha value must be in the range (0.0-1.0). The alpha value
+ * defaults to 1.0.
+ *
+ * @param red the red component in a color
+ * @param green the green component in a color
+ * @param blue the blue component in a color
+ * @param alpha the alpha component in a color
*/
public RGBA(int red, int green, int blue, float alpha) {
super(red, green, blue);
@@ -155,26 +145,22 @@ public RGBA(int red, int green, int blue, float alpha) {
}
/**
- *
- * @return Returns the alpha component in the range (0.0-1.0).
+ * @return The alpha component in the range (0.0-1.0).
*/
public final float getAlpha() {
return alpha;
}
/**
- * @return Returns string representation of this RGBA
+ * @return The string representation of this {@link RGBA}.
*/
@Override
public String getString() {
- return new StringBuilder().append("rgba(").append(getRed())
- .append(",").append(getGreen()).append(",")
- .append(getBlue()).append(",").append(alpha).append(")")
- .toString();
+ return "rgba(" + getRed() + "," + getGreen() + "," + getBlue() + "," + alpha + ")";
}
/**
- * @return Returns string representation of this RGBA
+ * @return The string representation of this {@link RGBA}.
*/
@Override
public String toString() {
diff --git a/src/com/invient/vaadin/charts/Gradient.java b/invient-charts/src/main/java/com/invient/vaadin/charts/Gradient.java
old mode 100755
new mode 100644
similarity index 66%
rename from src/com/invient/vaadin/charts/Gradient.java
rename to invient-charts/src/main/java/com/invient/vaadin/charts/Gradient.java
index c63cde5..219b3b7
--- a/src/com/invient/vaadin/charts/Gradient.java
+++ b/invient-charts/src/main/java/com/invient/vaadin/charts/Gradient.java
@@ -22,13 +22,16 @@
/**
* The Gradient defines a way to fill a shape with a linear color gradient
* pattern.
- *
+ *
* @author Invient
*/
+@SuppressWarnings("serial")
public interface Gradient extends Paint {
public static enum Unit {
+
NUMBER("number", ""), PERCENT("percent", "%");
+
private String name;
private String symbol;
@@ -44,65 +47,53 @@ public String getName() {
public String getSymbol() {
return this.symbol;
}
+
}
/**
- * Returns the x-coordinate of a point at which linear gradient
- * starts.
- * @return the x-coordinate of a point at which linear gradient
+ * @return The x-coordinate of a point at which linear gradient
* starts.
*/
public int getxStart();
/**
- * Returns the unit of x-coordinate of a point at which linear gradient starts.
- * @return the unit of x-coordinate of a point at which linear gradient starts.
+ * @return The unit of x-coordinate of a point at which linear gradient starts.
*/
public Unit getxStartUnit();
/**
- * Returns the y-coordinate of a point at which linear gradient starts.
- * @return the y-coordinate of a point at which linear gradient starts.
+ * @return The y-coordinate of a point at which linear gradient starts.
*/
public int getyStart();
/**
- * Returns the unit of y-coordinate of a point at which linear gradient starts.
- * @return the unit of y-coordinate of a point at which linear gradient starts.
+ * @return The unit of y-coordinate of a point at which linear gradient starts.
*/
public Unit getyStartUnit();
/**
- * Returns the x-coordinate of a point at which linear gradient
- * ends.
- * @return the x-coordinate of a point at which linear gradient
- * ends.
+ * @return The x-coordinate of a point at which linear gradient ends.
*/
public int getxEnd();
/**
- * Returns the unit of x-coordinate of a point at which linear gradient ends.
- * @return the unit of x-coordinate of a point at which linear gradient ends.
+ * @return The unit of x-coordinate of a point at which linear gradient ends.
*/
public Unit getxEndUnit();
/**
- * Returns the x-coordinate of a point at which linear gradient ends.
- * @return the x-coordinate of a point at which linear gradient ends.
+ * @return The x-coordinate of a point at which linear gradient ends.
*/
public int getyEnd();
/**
- * Returns the unit of y-coordinate of a point at which linear gradient ends.
- * @return the unit of y-coordinate of a point at which linear gradient ends.
+ * @return The unit of y-coordinate of a point at which linear gradient ends.
*/
public Unit getyEndUnit();
/**
- * Returns a list of colorstops associated with this gradient.
- * @return a list of colorstops associated with this gradient.
+ * @return A list of {@link ColorStop} instances associated with this gradient.
* @see ColorStop
- *
*/
public List extends ColorStop> getColorStops();
@@ -111,9 +102,8 @@ public String getSymbol() {
* (0.0-1.0). The color of the gradient at each stop is the color specified
* for that stop. Between each such stop, the colors and the alpha component
* will be linearly interpolated over the RGBA.
- *
+ *
* @author Invient
- *
*/
public interface ColorStop extends Serializable {
@@ -128,9 +118,8 @@ public interface ColorStop extends Serializable {
* Represents linear gradient where points of a linear gradient specify a
* line. For more details on gradient, refer to CSS 3 gradient
* documentation.
- *
+ *
* @author Invient
- *
*/
public class LinearGradient implements Gradient {
private int xStart = 0;
@@ -148,60 +137,45 @@ public class LinearGradient implements Gradient {
/**
* Creates a LinearGradient with the specified xStart, xEnd, yStart and
* yEnd values with default {@link Unit} value number.
- *
- * @param xStart
- * the x-coordinate of a point at which linear gradient
- * starts.
- * @param xEnd
- * the x-coordinate of a point at which linear gradient ends.
- * @param yStart
- * the y-coordinate of a point at which linear gradient
- * starts.
- * @param yEnd
- * the y-coordinate of a point at which linear gradient ends.
- * @param colorStops
- * the list of colorstops for the linear gradient.
+ *
+ * @param xStart The x-coordinate of a point at which linear gradient
+ * starts.
+ * @param xEnd The x-coordinate of a point at which linear gradient ends.
+ * @param yStart The y-coordinate of a point at which linear gradient
+ * starts.
+ * @param yEnd The y-coordinate of a point at which linear gradient ends.
+ * @param colorStops The list of colorstops for the linear gradient.
*/
public LinearGradient(int xStart, int yStart, int xEnd, int yEnd,
- List colorStops) {
+ List colorStops) {
this(xStart, null, yStart, null, xEnd, null, yEnd, null, colorStops);
}
/**
- *
- * @param xStart
- * the x-coordinate of a point at which linear gradient
- * starts.
- * @param xStartUnit
- * the unit for the xStart value. It can have one of the two
- * values Unit.NUMBER or Unit.PERCENT. If it is null then the
- * default value is Unit.NUMBER.
- * @param yStart
- * the y-coordinate of a point at which linear gradient
- * starts.
- * @param yStartUnit
- * the unit for the yStart value. It can have one of the two
- * values Unit.NUMBER or Unit.PERCENT. If it is null then the
- * default value is Unit.NUMBER.
- * @param xEnd
- * the x-coordinate of a point at which linear gradient ends.
- * @param xEndUnit
- * the unit for the xEnd value. It can have one of the two
- * values Unit.NUMBER or Unit.PERCENT. If it is null then the
- * default value is Unit.NUMBER.
- * @param yEnd
- * the y-coordinate of a point at which linear gradient ends.
- * @param yEndUnit
- * the unit for the yEnd value. It can have one of the two
- * values Unit.NUMBER or Unit.PERCENT. If it is null then the
- * default value is Unit.NUMBER.
- * @param colorStops
- * the list of colorstops for the linear gradient.
+ * @param xStart The x-coordinate of a point at which linear gradient
+ * starts.
+ * @param xStartUnit The unit for the xStart value. It can have one of the two
+ * values Unit.NUMBER or Unit.PERCENT. If it is null then the
+ * default value is Unit.NUMBER.
+ * @param yStart The y-coordinate of a point at which linear gradient
+ * starts.
+ * @param yStartUnit The unit for the yStart value. It can have one of the two
+ * values Unit.NUMBER or Unit.PERCENT. If it is null then the
+ * default value is Unit.NUMBER.
+ * @param xEnd the x-coordinate of a point at which linear gradient ends.
+ * @param xEndUnit The unit for the xEnd value. It can have one of the two
+ * values Unit.NUMBER or Unit.PERCENT. If it is null then the
+ * default value is Unit.NUMBER.
+ * @param yEnd The y-coordinate of a point at which linear gradient ends.
+ * @param yEndUnit The unit for the yEnd value. It can have one of the two
+ * values Unit.NUMBER or Unit.PERCENT. If it is null then the
+ * default value is Unit.NUMBER.
+ * @param colorStops The list of colorstops for the linear gradient.
*/
public LinearGradient(int xStart, Unit xStartUnit, int yStart,
- Unit yStartUnit, int xEnd, Unit xEndUnit, int yEnd,
- Unit yEndUnit, List colorStops) {
- super();
+ Unit yStartUnit, int xEnd, Unit xEndUnit, int yEnd,
+ Unit yEndUnit, List colorStops) {
+
this.xStart = xStart;
if (xStartUnit != null) {
this.xStartUnit = xStartUnit;
@@ -221,6 +195,7 @@ public LinearGradient(int xStart, Unit xStartUnit, int yStart,
if (colorStops != null) {
this.colorStops = colorStops;
}
+
}
/*
@@ -306,9 +281,8 @@ public List getColorStops() {
/**
* Represents stop-value and color for the {@link LinearGradient}
- *
+ *
* @author Invient
- *
*/
public static class LinearColorStop implements ColorStop {
private double stopAt;
@@ -316,24 +290,20 @@ public static class LinearColorStop implements ColorStop {
private Color color;
/**
- *
- * @param stopAt
- * @param color
+ * @param stopAt The stop-at value.
+ * @param color The color.
*/
public LinearColorStop(double stopAt, Color color) {
- super();
this.stopAt = stopAt;
this.color = color;
}
/**
- *
- * @param stopAt
- * @param stopAtUnit
- * @param color
+ * @param stopAt The stop-at value.
+ * @param stopAtUnit The stop-at unit value.
+ * @param color The color.
*/
public LinearColorStop(double stopAt, Unit stopAtUnit, Color color) {
- super();
this.stopAt = stopAt;
if (stopAtUnit != null) {
this.stopAtUnit = stopAtUnit;
@@ -364,33 +334,30 @@ public Color getColor() {
@Override
public String getString() {
StringBuilder sb = new StringBuilder();
- // The prefix "JSOBJ:" indicates that the string is a JavaScript
- // object
+ // The prefix "JSOBJ:" indicates that the string is a JavaScript object
String x1 = "'" + this.xStart + this.xStartUnit.getSymbol() + "'";
String y1 = "'" + this.yStart + this.yStartUnit.getSymbol() + "'";
String x2 = "'" + this.xEnd + this.xEndUnit.getSymbol() + "'";
String y2 = "'" + this.yEnd + this.yEndUnit.getSymbol() + "'";
sb.append("JSOBJ:{");
- sb.append(" linearGradient: [" + x1 + "," + y1 + "," + x2 + ","
- + y2 + "],");
+ sb.append(" linearGradient: [").append(x1).append(",").append(y1).append(",").append(x2).append(",").append(y2).append("],");
sb.append(" stops: [");
int count = 0;
for (LinearColorStop colorStop : this.colorStops) {
if (colorStop.getColor() != null) {
String stopAt = "'" + colorStop.getStopAt() + colorStop.getStopAtUnit().getSymbol() + "'";
- String stopColor = "'" + colorStop.getColor().getString() + "'";
+ String stopColor = "'" + colorStop.getColor().getString() + "'";
if (count > 0) {
sb.append(",");
}
- sb.append("[" + stopAt + ", "
- + stopColor + "]");
+ sb.append("[").append(stopAt).append(", ").append(stopColor).append("]");
count++;
}
}
sb.append(" ]");
sb.append("}");
-
+
return sb.toString();
}
}
diff --git a/src/com/invient/vaadin/charts/InvientCharts.java b/invient-charts/src/main/java/com/invient/vaadin/charts/InvientCharts.java
old mode 100755
new mode 100644
similarity index 81%
rename from src/com/invient/vaadin/charts/InvientCharts.java
rename to invient-charts/src/main/java/com/invient/vaadin/charts/InvientCharts.java
index a5219c1..8e037ba
--- a/src/com/invient/vaadin/charts/InvientCharts.java
+++ b/invient-charts/src/main/java/com/invient/vaadin/charts/InvientCharts.java
@@ -17,46 +17,28 @@
import java.io.Serializable;
import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+import com.invient.vaadin.charts.InvientCharts.SeriesCUR.SeriesCURType;
+import com.invient.vaadin.charts.InvientChartsConfig.*;
+import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.PlotBand;
+import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.PlotLine;
+import com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.ClientWidget;
import com.vaadin.ui.Component;
-import com.invient.vaadin.charts.InvientCharts.SeriesCUR.SeriesCURType;
-import com.invient.vaadin.charts.InvientChartsConfig.Axis;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.PlotBand;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.PlotLine;
-import com.invient.vaadin.charts.InvientChartsConfig.BaseLineConfig;
-import com.invient.vaadin.charts.InvientChartsConfig.PointConfig;
-import com.invient.vaadin.charts.InvientChartsConfig.SeriesConfig;
-import com.invient.vaadin.charts.InvientChartsConfig.SubTitle;
-import com.invient.vaadin.charts.InvientChartsConfig.Title;
-import com.invient.vaadin.charts.InvientChartsConfig.XAxis;
-import com.invient.vaadin.charts.InvientChartsConfig.YAxis;
-import com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts;
-
/**
* A Vaddin component representing charts. It is a the main class of
* InvientCharts library.
- *
+ *
* A chart typically contains one or more series of same or different types.
* This class allows us to specify series of different types say line and pie
* and hence it makes it easy to build a combination chart.
- *
+ *
* After a chart {@link InvientCharts} is created, the following changes to the
* chart will be reflected rendered on the webkit.
*
@@ -71,9 +53,8 @@
*
Add and remove one or more instances of {@link Point}
*
Register and unregister event listeners
*
- *
+ *
* @author Invient
- *
*/
@SuppressWarnings("serial")
@ClientWidget(VInvientCharts.class)
@@ -85,8 +66,8 @@ public class InvientCharts extends AbstractComponent {
/**
* Creates this chart object with given chart configuration
- *
- * @param chartConfig
+ *
+ * @param chartConfig The chart configuration.
*/
public InvientCharts(InvientChartsConfig chartConfig) {
if (chartConfig == null) {
@@ -99,13 +80,16 @@ public InvientCharts(InvientChartsConfig chartConfig) {
/**
* Returns chart configuration object
- *
+ *
* @return Returns chart configuration object
*/
public InvientChartsConfig getConfig() {
return this.chartConfig;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void paintContent(PaintTarget target) throws PaintException {
super.paintContent(target);
@@ -329,9 +313,11 @@ public void changeVariables(Object source, Map variables) {
private Point getPointFromEventData(PointEventData eventData) {
// First locate a series and then point
Series series = getSeriesFromEventData(eventData.getSeriesName());
+ // TODO: [S73417H] There is something very wrong here with instanceof checks and equality.
if (series != null) {
if (series instanceof XYSeries) {
- for (DecimalPoint point : ((XYSeries) series).getPoints()) {
+ XYSeries xySeries = (XYSeries)series;
+ for (DecimalPoint point : xySeries.getPoints()) {
if (point.getY() != null
&& point.getY().compareTo(eventData.getPointY()) == 0
&& point.getX() != null
@@ -340,14 +326,14 @@ private Point getPointFromEventData(PointEventData eventData) {
}
}
} else {
- for (DateTimePoint point : ((DateTimeSeries) series)
- .getPoints()) {
+ DateTimeSeries dateTimeSeries = (DateTimeSeries)series;
+ for (DateTimePoint point : dateTimeSeries.getPoints()) {
if (point.getY() != null
&& point.getY().compareTo(eventData.getPointY()) == 0
&& point.getX() != null
&& getDateInMilliseconds(point.getX(),
- ((DateTimeSeries) series).isIncludeTime()) == (long) eventData
- .getPointX()) {
+ ((DateTimeSeries) series).isIncludeTime()) == (long) eventData
+ .getPointX()) {
return point;
}
}
@@ -360,15 +346,11 @@ private static Long getDateInMilliseconds(Date dt, boolean isIncludeTime) {
if (dt == null) {
return null;
}
- Calendar cal = GregorianCalendar.getInstance();
- cal.setTime(dt);
if (!isIncludeTime) {
- cal.set(Calendar.HOUR, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
+ return dt.getTime() - dt.getTime() % TimeUnit.DAYS.toMillis(1);
+ } else {
+ return dt.getTime();
}
- return cal.getTimeInMillis();
}
private Series getSeriesFromEventData(String seriesName) {
@@ -403,7 +385,7 @@ private void fireChartResetZoom() {
}
private void fireSeriesClick(Series series, Point point,
- MousePosition mousePosition) {
+ MousePosition mousePosition) {
fireEvent(new SeriesClickEvent(this, this, series, point, mousePosition));
}
@@ -420,7 +402,7 @@ private void fireSeriesLegendItemClick(Series series) {
}
private void firePointClick(String category, Point point,
- MousePosition mousePosition) {
+ MousePosition mousePosition) {
fireEvent(new PointClickEvent(this, this, category, point,
mousePosition));
}
@@ -467,11 +449,10 @@ private MousePosition getClickPosition(Map eventData) {
/**
* This class contain mouse coordinates when a click event occurs on a
* chart, a series or a point.
- *
+ *
* The mouse coordinates are in pixels.
- *
+ *
* @author Invient
- *
*/
public final class MousePosition implements Serializable {
private int mouseX;
@@ -479,11 +460,9 @@ public final class MousePosition implements Serializable {
/**
* Creates this object with given arguments.
- *
- * @param mouseX
- * x position of mouse when a click event occurred, in pixel
- * @param mouseY
- * y position of mouse when a click event occurred, in pixel
+ *
+ * @param mouseX x position of mouse when a click event occurred, in pixel
+ * @param mouseY y position of mouse when a click event occurred, in pixel
*/
public MousePosition(int mouseX, int mouseY) {
this.mouseX = mouseX;
@@ -491,7 +470,6 @@ public MousePosition(int mouseX, int mouseY) {
}
/**
- *
* @return Returns x position of mouse when a click event occurred, in
* pixel
*/
@@ -500,7 +478,6 @@ public int getMouseX() {
}
/**
- *
* @return Returns y position of mouse when a click event occurred, in
* pixel
*/
@@ -523,7 +500,7 @@ private final class PointEventData implements Serializable {
private double pointY;
public PointEventData(String seriesName, String category,
- double pointX, double pointY) {
+ double pointX, double pointY) {
super();
this.seriesName = seriesName;
this.category = category;
@@ -561,7 +538,7 @@ public String toString() {
* Click event. This event is thrown, when any point of this chart is
* clicked and the point marker is enabled. The point marker is enabled by
* default.
- *
+ *
* @author Invient
*/
public class PointClickEvent extends Component.Event {
@@ -573,21 +550,16 @@ public class PointClickEvent extends Component.Event {
/**
* New instance of the point click event.
- *
- * @param source
- * the chart object itself
- * @param chart
- * the chart object itself
- * @param category
- * a category to which point is associated in case of
- * categorized axis,
- * @param point
- * the point on which the click event occurred
- * @param mousePosition
- * the position of a mouse when the click event occurred
+ *
+ * @param source the chart object itself
+ * @param chart the chart object itself
+ * @param category a category to which point is associated in case of
+ * categorized axis,
+ * @param point the point on which the click event occurred
+ * @param mousePosition the position of a mouse when the click event occurred
*/
public PointClickEvent(Component source, InvientCharts chart,
- String category, Point point, MousePosition mousePosition) {
+ String category, Point point, MousePosition mousePosition) {
super(source);
this.chart = chart;
this.category = category;
@@ -596,7 +568,6 @@ public PointClickEvent(Component source, InvientCharts chart,
}
/**
- *
* @return Returns a category to which point is associated in case of
* categorized axis only.
*/
@@ -605,7 +576,6 @@ public String getCategory() {
}
/**
- *
* @return Returns the chart object associated with the point
*/
public InvientCharts getChart() {
@@ -613,7 +583,6 @@ public InvientCharts getChart() {
}
/**
- *
* @return Returns the point on which the click event occurred
*/
public Point getPoint() {
@@ -621,7 +590,6 @@ public Point getPoint() {
}
/**
- *
* @return Returns the position of a mouse when the click event occurred
*/
public MousePosition getMousePosition() {
@@ -633,9 +601,8 @@ public MousePosition getMousePosition() {
/**
* Interface for listening for a {@link PointClickEvent} triggered by
* {@link InvientCharts}
- *
+ *
* @author Invient
- *
*/
public interface PointClickListener extends Serializable {
public void pointClick(PointClickEvent pointClickEvent);
@@ -647,14 +614,13 @@ public interface PointClickListener extends Serializable {
* Adds the point click listener. If the argument seriesTypes is not
* specified then the listener will be added for all series type otherwise
* it will be added for a specific series type
- *
- * @param listener
- * the Listener to be added.
+ *
+ * @param listener the Listener to be added.
*/
public void addListener(PointClickListener listener,
- SeriesType... seriesTypes) {
+ SeriesType... seriesTypes) {
if (seriesTypes.length == 0) {
- seriesTypes = new SeriesType[] { SeriesType.COMMONSERIES };
+ seriesTypes = new SeriesType[]{SeriesType.COMMONSERIES};
}
for (SeriesType seriesType : seriesTypes) {
@@ -674,16 +640,14 @@ public void addListener(PointClickListener listener,
* specified then the listener will be removed only for a series type
* SeriesType.COMMONSERIES otherwise the listener will be removed for all
* specified series types.
- *
- * @param listener
- * the listener to be removed
- * @param seriesTypes
- * one or more series types as defined by (@link SeriesType}
+ *
+ * @param listener the listener to be removed
+ * @param seriesTypes one or more series types as defined by (@link SeriesType}
*/
public void removeListener(PointClickListener listener,
- SeriesType... seriesTypes) {
+ SeriesType... seriesTypes) {
if (seriesTypes.length == 0) {
- seriesTypes = new SeriesType[] { SeriesType.COMMONSERIES };
+ seriesTypes = new SeriesType[]{SeriesType.COMMONSERIES};
}
for (SeriesType seriesType : seriesTypes) {
@@ -697,9 +661,9 @@ public void removeListener(PointClickListener listener,
/**
* Point remove event. This event is thrown, when any point of this chart is
* removed from its series.
- *
+ *
* This event is EXPERIMENTAL ONLY.
- *
+ *
* @author Invient
*/
public class PointRemoveEvent extends Component.Event {
@@ -710,19 +674,15 @@ public class PointRemoveEvent extends Component.Event {
/**
* New instance of the point remove event.
- *
- * @param source
- * the chart object itself
- * @param chart
- * the chart object itself
- * @param category
- * a category to which point is associated in case of
- * categorized axis,
- * @param point
- * the point removed
+ *
+ * @param source the chart object itself
+ * @param chart the chart object itself
+ * @param category a category to which point is associated in case of
+ * categorized axis,
+ * @param point the point removed
*/
public PointRemoveEvent(Component source, InvientCharts chart,
- String category, Point point) {
+ String category, Point point) {
super(source);
this.chart = chart;
this.category = category;
@@ -730,7 +690,6 @@ public PointRemoveEvent(Component source, InvientCharts chart,
}
/**
- *
* @return Returns a category to which point is associated in case of
* categorized axis only.
*/
@@ -739,7 +698,6 @@ public String getCategory() {
}
/**
- *
* @return Returns the chart object associated with the point
*/
public InvientCharts getChart() {
@@ -747,7 +705,6 @@ public InvientCharts getChart() {
}
/**
- *
* @return Returns the point which has been removed
*/
public Point getPoint() {
@@ -759,9 +716,8 @@ public Point getPoint() {
/**
* Interface for listening for a {@link PointRemoveEvent} triggered by
* {@link InvientCharts}
- *
+ *
* @author Invient
- *
*/
public interface PointRemoveListener extends Serializable {
public void pointRemove(PointRemoveEvent pointRemoveEvent);
@@ -773,14 +729,13 @@ public interface PointRemoveListener extends Serializable {
* Adds the point remove listener. If the argument seriesTypes is not
* specified then the listener will be added for all series type otherwise
* it will be added for a specific series type
- *
- * @param listener
- * the Listener to be added.
+ *
+ * @param listener the Listener to be added.
*/
public void addListener(PointRemoveListener listener,
- SeriesType... seriesTypes) {
+ SeriesType... seriesTypes) {
if (seriesTypes.length == 0) {
- seriesTypes = new SeriesType[] { SeriesType.COMMONSERIES };
+ seriesTypes = new SeriesType[]{SeriesType.COMMONSERIES};
}
for (SeriesType seriesType : seriesTypes) {
if (pointRemoveListeners.containsKey(seriesType)) {
@@ -799,16 +754,14 @@ public void addListener(PointRemoveListener listener,
* specified then the listener will be removed only for a series type
* SeriesType.COMMONSERIES otherwise the listener will be removed for all
* specified series types.
- *
- * @param listener
- * the listener to be removed
- * @param seriesTypes
- * one or more series types as defined by (@link SeriesType}
+ *
+ * @param listener the listener to be removed
+ * @param seriesTypes one or more series types as defined by (@link SeriesType}
*/
public void removeListener(PointRemoveListener listener,
- SeriesType... seriesTypes) {
+ SeriesType... seriesTypes) {
if (seriesTypes.length == 0) {
- seriesTypes = new SeriesType[] { SeriesType.COMMONSERIES };
+ seriesTypes = new SeriesType[]{SeriesType.COMMONSERIES};
}
for (SeriesType seriesType : seriesTypes) {
if (pointRemoveListeners.containsKey(seriesType)) {
@@ -820,10 +773,10 @@ public void removeListener(PointRemoveListener listener,
}
/**
- * Poin unselect event. This event is thrown, when any point of this chart
+ * Point unselect event. This event is thrown, when any point of this chart
* is unselected and the point marker is enabled. The point marker is
* enabled by default.
- *
+ *
* @author Invient
*/
public class PointUnselectEvent extends Component.Event {
@@ -834,19 +787,15 @@ public class PointUnselectEvent extends Component.Event {
/**
* New instance of the point unselect event.
- *
- * @param source
- * the chart object itself
- * @param chart
- * the chart object itself
- * @param category
- * a category to which point is associated in case of
- * categorized axis,
- * @param point
- * the point unselected as a result of this event
+ *
+ * @param source the chart object itself
+ * @param chart the chart object itself
+ * @param category a category to which point is associated in case of
+ * categorized axis,
+ * @param point the point unselected as a result of this event
*/
public PointUnselectEvent(Component source, InvientCharts chart,
- String category, Point point) {
+ String category, Point point) {
super(source);
this.chart = chart;
this.category = category;
@@ -854,7 +803,6 @@ public PointUnselectEvent(Component source, InvientCharts chart,
}
/**
- *
* @return Returns a category to which point is associated in case of
* categorized axis only.
*/
@@ -863,7 +811,6 @@ public String getCategory() {
}
/**
- *
* @return Returns the chart object associated with the point
*/
public InvientCharts getChart() {
@@ -871,7 +818,6 @@ public InvientCharts getChart() {
}
/**
- *
* @return Returns the unselected point
*/
public Point getPoint() {
@@ -883,9 +829,8 @@ public Point getPoint() {
/**
* Interface for listening for a {@link PointUnselectEvent} triggered by
* {@link InvientCharts}
- *
+ *
* @author Invient
- *
*/
public interface PointUnselectListener extends Serializable {
public void pointUnSelect(PointUnselectEvent pointUnSelectEvent);
@@ -897,14 +842,13 @@ public interface PointUnselectListener extends Serializable {
* Adds the point unselect listener. If the argument seriesTypes is not
* specified then the listener will be added for all series type otherwise
* it will be added for a specific series type
- *
- * @param listener
- * the Listener to be added.
+ *
+ * @param listener the Listener to be added.
*/
public void addListener(PointUnselectListener listener,
- SeriesType... seriesTypes) {
+ SeriesType... seriesTypes) {
if (seriesTypes.length == 0) {
- seriesTypes = new SeriesType[] { SeriesType.COMMONSERIES };
+ seriesTypes = new SeriesType[]{SeriesType.COMMONSERIES};
}
for (SeriesType seriesType : seriesTypes) {
if (pointUnselectListeners.containsKey(seriesType)) {
@@ -923,16 +867,14 @@ public void addListener(PointUnselectListener listener,
* specified then the listener will be removed only for a series type
* SeriesType.COMMONSERIES otherwise the listener will be removed for all
* specified series types.
- *
- * @param listener
- * the listener to be removed
- * @param seriesTypes
- * one or more series types as defined by (@link SeriesType}
+ *
+ * @param listener the listener to be removed
+ * @param seriesTypes one or more series types as defined by (@link SeriesType}
*/
public void removeListener(PointUnselectListener listener,
- SeriesType... seriesTypes) {
+ SeriesType... seriesTypes) {
if (seriesTypes.length == 0) {
- seriesTypes = new SeriesType[] { SeriesType.COMMONSERIES };
+ seriesTypes = new SeriesType[]{SeriesType.COMMONSERIES};
}
for (SeriesType seriesType : seriesTypes) {
if (pointUnselectListeners.containsKey(seriesType)) {
@@ -947,7 +889,7 @@ public void removeListener(PointUnselectListener listener,
* Point select event. This event is thrown, when any point of this chart is
* selected and the point marker is enabled. The point marker is enabled by
* default.
- *
+ *
* @author Invient
*/
public class PointSelectEvent extends Component.Event {
@@ -958,19 +900,15 @@ public class PointSelectEvent extends Component.Event {
/**
* New instance of the point select event.
- *
- * @param source
- * the chart object itself
- * @param chart
- * the chart object itself
- * @param category
- * a category to which point is associated in case of
- * categorized axis,
- * @param point
- * the point selected as a result of this event
+ *
+ * @param source the chart object itself
+ * @param chart the chart object itself
+ * @param category a category to which point is associated in case of
+ * categorized axis,
+ * @param point the point selected as a result of this event
*/
public PointSelectEvent(Component source, InvientCharts chart,
- String category, Point point) {
+ String category, Point point) {
super(source);
this.chart = chart;
this.category = category;
@@ -978,7 +916,6 @@ public PointSelectEvent(Component source, InvientCharts chart,
}
/**
- *
* @return Returns a category to which point is associated in case of
* categorized axis only.
*/
@@ -987,7 +924,6 @@ public String getCategory() {
}
/**
- *
* @return Returns the chart object associated with the point
*/
public InvientCharts getChart() {
@@ -995,7 +931,6 @@ public InvientCharts getChart() {
}
/**
- *
* @return Returns the selected point
*/
public Point getPoint() {
@@ -1007,9 +942,8 @@ public Point getPoint() {
/**
* Interface for listening for a {@link PointSelectListener} triggered by
* {@link InvientCharts}
- *
+ *
* @author Invient
- *
*/
public interface PointSelectListener extends Serializable {
public void pointSelected(PointSelectEvent pointSelectEvent);
@@ -1021,14 +955,13 @@ public interface PointSelectListener extends Serializable {
* Adds the point select listener. If the argument seriesTypes is not
* specified then the listener will be added for all series type otherwise
* it will be added for a specific series type
- *
- * @param listener
- * the Listener to be added.
+ *
+ * @param listener the Listener to be added.
*/
public void addListener(PointSelectListener listener,
- SeriesType... seriesTypes) {
+ SeriesType... seriesTypes) {
if (seriesTypes.length == 0) {
- seriesTypes = new SeriesType[] { SeriesType.COMMONSERIES };
+ seriesTypes = new SeriesType[]{SeriesType.COMMONSERIES};
}
for (SeriesType seriesType : seriesTypes) {
@@ -1048,16 +981,14 @@ public void addListener(PointSelectListener listener,
* specified then the listener will be removed only for a series type
* SeriesType.COMMONSERIES otherwise the listener will be removed for all
* specified series types.
- *
- * @param listener
- * the listener to be removed
- * @param seriesTypes
- * one or more series types as defined by (@link SeriesType}
+ *
+ * @param listener the listener to be removed
+ * @param seriesTypes one or more series types as defined by (@link SeriesType}
*/
public void removeListener(PointSelectListener listener,
- SeriesType... seriesTypes) {
+ SeriesType... seriesTypes) {
if (seriesTypes.length == 0) {
- seriesTypes = new SeriesType[] { SeriesType.COMMONSERIES };
+ seriesTypes = new SeriesType[]{SeriesType.COMMONSERIES};
}
for (SeriesType seriesType : seriesTypes) {
if (pointSelectListeners.containsKey(seriesType)) {
@@ -1075,14 +1006,14 @@ public void removeListener(PointSelectListener listener,
static {
try {
POINT_CLICK_METHOD = PointClickListener.class.getDeclaredMethod(
- "pointClick", new Class[] { PointClickEvent.class });
+ "pointClick", new Class[]{PointClickEvent.class});
POINT_REMOVE_METHOD = PointRemoveListener.class.getDeclaredMethod(
- "pointRemove", new Class[] { PointRemoveEvent.class });
+ "pointRemove", new Class[]{PointRemoveEvent.class});
POINT_SELECT_METHOD = PointSelectListener.class.getDeclaredMethod(
- "pointSelected", new Class[] { PointSelectEvent.class });
+ "pointSelected", new Class[]{PointSelectEvent.class});
POINT_UNSELECT_METHOD = PointUnselectListener.class
.getDeclaredMethod("pointUnSelect",
- new Class[] { PointUnselectEvent.class });
+ new Class[]{PointUnselectEvent.class});
} catch (final java.lang.NoSuchMethodException e) {
// This should not happen
throw new java.lang.RuntimeException(
@@ -1095,7 +1026,7 @@ public void removeListener(PointSelectListener listener,
/**
* Series click event. This event is thrown, when any series of this chart
* is clicked.
- *
+ *
* @author Invient
*/
public class SeriesClickEvent extends Component.Event {
@@ -1106,20 +1037,15 @@ public class SeriesClickEvent extends Component.Event {
/**
* New instance of the series click event.
- *
- * @param source
- * the chart object itself
- * @param chart
- * the chart object itself
- * @param series
- * the series on which click event occurred
- * @param point
- * the closest point of a series
- * @param mousePosition
- * the position of a mouse when the click event occurred
+ *
+ * @param source the chart object itself
+ * @param chart the chart object itself
+ * @param series the series on which click event occurred
+ * @param point the closest point of a series
+ * @param mousePosition the position of a mouse when the click event occurred
*/
public SeriesClickEvent(Component source, InvientCharts chart,
- Series series, Point point, MousePosition mousePosition) {
+ Series series, Point point, MousePosition mousePosition) {
super(source);
this.chart = chart;
this.series = series;
@@ -1128,7 +1054,6 @@ public SeriesClickEvent(Component source, InvientCharts chart,
}
/**
- *
* @return Returns the chart object associated with the point
*/
public InvientCharts getChart() {
@@ -1136,7 +1061,6 @@ public InvientCharts getChart() {
}
/**
- *
* @return Returns the series object on which the click event occurred
*/
public Series getSeries() {
@@ -1144,7 +1068,6 @@ public Series getSeries() {
}
/**
- *
* @return Returns the point of a series closest to the position where
* mouse click event occurred.
*/
@@ -1153,7 +1076,6 @@ public Point getNearestPoint() {
}
/**
- *
* @return Returns the position of a mouse when the click event occurred
*/
public MousePosition getMousePosition() {
@@ -1165,9 +1087,8 @@ public MousePosition getMousePosition() {
/**
* Interface for listening for a {@link SeriesClickListerner} triggered by
* {@link InvientCharts}
- *
+ *
* @author Invient
- *
*/
public interface SeriesClickListerner extends Serializable {
public void seriesClick(SeriesClickEvent seriesClickEvent);
@@ -1179,14 +1100,13 @@ public interface SeriesClickListerner extends Serializable {
* Adds the series click listener. If the argument seriesTypes is not
* specified then the listener will be added for all series type otherwise
* it will be added for a specific series type
- *
- * @param listener
- * the Listener to be added.
+ *
+ * @param listener the Listener to be added.
*/
public void addListener(SeriesClickListerner listener,
- SeriesType... seriesTypes) {
+ SeriesType... seriesTypes) {
if (seriesTypes.length == 0) {
- seriesTypes = new SeriesType[] { SeriesType.COMMONSERIES };
+ seriesTypes = new SeriesType[]{SeriesType.COMMONSERIES};
}
for (SeriesType seriesType : seriesTypes) {
@@ -1206,16 +1126,14 @@ public void addListener(SeriesClickListerner listener,
* specified then the listener will be removed only for a series type
* SeriesType.COMMONSERIES otherwise the listener will be removed for all
* specified series types.
- *
- * @param listener
- * the listener to be removed
- * @param seriesTypes
- * one or more series types as defined by (@link SeriesType}
+ *
+ * @param listener the listener to be removed
+ * @param seriesTypes one or more series types as defined by (@link SeriesType}
*/
public void removeListener(SeriesClickListerner listener,
- SeriesType... seriesTypes) {
+ SeriesType... seriesTypes) {
if (seriesTypes.length == 0) {
- seriesTypes = new SeriesType[] { SeriesType.COMMONSERIES };
+ seriesTypes = new SeriesType[]{SeriesType.COMMONSERIES};
}
for (SeriesType seriesType : seriesTypes) {
@@ -1229,7 +1147,7 @@ public void removeListener(SeriesClickListerner listener,
/**
* Series Hide event. This event is thrown, when any series of this chart is
* hidden.
- *
+ *
* @author Invient
*/
public class SeriesHideEvent extends Component.Event {
@@ -1237,23 +1155,18 @@ public class SeriesHideEvent extends Component.Event {
private InvientCharts chart;
/**
- *
- * @param source
- * the chart object itself
- * @param chart
- * the chart object itself
- * @param series
- * the series which got hidden
+ * @param source the chart object itself
+ * @param chart the chart object itself
+ * @param series the series which got hidden
*/
public SeriesHideEvent(Component source, InvientCharts chart,
- Series series) {
+ Series series) {
super(source);
this.chart = chart;
this.series = series;
}
/**
- *
* @return Returns the chart object associated with the point
*/
public InvientCharts getChart() {
@@ -1261,7 +1174,6 @@ public InvientCharts getChart() {
}
/**
- *
* @return Returns the series which got hidden
*/
public Series getSeries() {
@@ -1272,9 +1184,8 @@ public Series getSeries() {
/**
* Interface for listening for a {@link SeriesHideEvent} triggered by
* {@link InvientCharts}
- *
+ *
* @author Invient
- *
*/
public interface SeriesHideListerner extends Serializable {
public void seriesHide(SeriesHideEvent seriesHideEvent);
@@ -1286,14 +1197,13 @@ public interface SeriesHideListerner extends Serializable {
* Adds the series hide listener. If the argument seriesTypes is not
* specified then the listener will be added for all series type otherwise
* it will be added for a specific series type
- *
- * @param listener
- * the Listener to be added.
+ *
+ * @param listener the Listener to be added.
*/
public void addListener(SeriesHideListerner listener,
- SeriesType... seriesTypes) {
+ SeriesType... seriesTypes) {
if (seriesTypes.length == 0) {
- seriesTypes = new SeriesType[] { SeriesType.COMMONSERIES };
+ seriesTypes = new SeriesType[]{SeriesType.COMMONSERIES};
}
for (SeriesType seriesType : seriesTypes) {
@@ -1313,16 +1223,14 @@ public void addListener(SeriesHideListerner listener,
* specified then the listener will be removed only for a series type
* SeriesType.COMMONSERIES otherwise the listener will be removed for all
* specified series types.
- *
- * @param listener
- * the listener to be removed
- * @param seriesTypes
- * one or more series types as defined by (@link SeriesType}
+ *
+ * @param listener the listener to be removed
+ * @param seriesTypes one or more series types as defined by (@link SeriesType}
*/
public void removeListener(SeriesHideListerner listener,
- SeriesType... seriesTypes) {
+ SeriesType... seriesTypes) {
if (seriesTypes.length == 0) {
- seriesTypes = new SeriesType[] { SeriesType.COMMONSERIES };
+ seriesTypes = new SeriesType[]{SeriesType.COMMONSERIES};
}
for (SeriesType seriesType : seriesTypes) {
@@ -1336,7 +1244,7 @@ public void removeListener(SeriesHideListerner listener,
/**
* Series show event. This event is thrown, when any series of this chart is
* displayed after a chart is created.
- *
+ *
* @author Invient
*/
public class SeriesShowEvent extends Component.Event {
@@ -1345,23 +1253,19 @@ public class SeriesShowEvent extends Component.Event {
/**
* New instance of the series show event.
- *
- * @param source
- * the chart object itself
- * @param chart
- * the chart object itself
- * @param series
- * the series which got displayed
+ *
+ * @param source the chart object itself
+ * @param chart the chart object itself
+ * @param series the series which got displayed
*/
public SeriesShowEvent(Component source, InvientCharts chart,
- Series series) {
+ Series series) {
super(source);
this.chart = chart;
this.series = series;
}
/**
- *
* @return Returns the chart object associated with the series
*/
public InvientCharts getChart() {
@@ -1369,7 +1273,6 @@ public InvientCharts getChart() {
}
/**
- *
* @return Returns the series which got displayed
*/
public Series getSeries() {
@@ -1380,9 +1283,8 @@ public Series getSeries() {
/**
* Interface for listening for a {@link SeriesShowEvent} triggered by
* {@link InvientCharts}
- *
+ *
* @author Invient
- *
*/
public interface SeriesShowListerner extends Serializable {
public void seriesShow(SeriesShowEvent seriesShowEvent);
@@ -1394,14 +1296,13 @@ public interface SeriesShowListerner extends Serializable {
* Adds the series show listener. If the argument seriesTypes is not
* specified then the listener will be added for all series type otherwise
* it will be added for a specific series type
- *
- * @param listener
- * the Listener to be added.
+ *
+ * @param listener the Listener to be added.
*/
public void addListener(SeriesShowListerner listener,
- SeriesType... seriesTypes) {
+ SeriesType... seriesTypes) {
if (seriesTypes.length == 0) {
- seriesTypes = new SeriesType[] { SeriesType.COMMONSERIES };
+ seriesTypes = new SeriesType[]{SeriesType.COMMONSERIES};
}
for (SeriesType seriesType : seriesTypes) {
@@ -1421,16 +1322,14 @@ public void addListener(SeriesShowListerner listener,
* specified then the listener will be removed only for a series type
* SeriesType.COMMONSERIES otherwise the listener will be removed for all
* specified series types.
- *
- * @param listener
- * the listener to be removed
- * @param seriesTypes
- * one or more series types as defined by (@link SeriesType}
+ *
+ * @param listener the listener to be removed
+ * @param seriesTypes one or more series types as defined by (@link SeriesType}
*/
public void removeListener(SeriesShowListerner listener,
- SeriesType... seriesTypes) {
+ SeriesType... seriesTypes) {
if (seriesTypes.length == 0) {
- seriesTypes = new SeriesType[] { SeriesType.COMMONSERIES };
+ seriesTypes = new SeriesType[]{SeriesType.COMMONSERIES};
}
for (SeriesType seriesType : seriesTypes) {
@@ -1441,15 +1340,10 @@ public void removeListener(SeriesShowListerner listener,
removeListener(SeriesShowEvent.class, listener, SERIES_SHOW_METHOD);
}
- // LEGENDITEMCLICK
- // This event occurs when a series is clicked in the legend.
- // This event is not applicable for PieChart instead use
- // LegendItemClickEvent/LegendItemClickListener
/**
* Series legend item click event. This event is thrown, when legend item is
- * clicked. This event is not applicable for PieChart instead use
- * {@link LegendItemClickEvent}
- *
+ * clicked. This event is not applicable for PieChart instead use {@link PieChartLegendItemClickEvent}.
+ *
* @author Invient
*/
public class SeriesLegendItemClickEvent extends Component.Event {
@@ -1458,23 +1352,19 @@ public class SeriesLegendItemClickEvent extends Component.Event {
/**
* New instance of the point click event.
- *
- * @param source
- * the chart object itself
- * @param chart
- * the chart object itself
- * @param series
- * the series associated with the legend item
+ *
+ * @param source the chart object itself
+ * @param chart the chart object itself
+ * @param series the series associated with the legend item
*/
public SeriesLegendItemClickEvent(Component source,
- InvientCharts chart, Series series) {
+ InvientCharts chart, Series series) {
super(source);
this.chart = chart;
this.series = series;
}
/**
- *
* @return Returns the chart object associated with the series
*/
public InvientCharts getChart() {
@@ -1482,7 +1372,6 @@ public InvientCharts getChart() {
}
/**
- *
* @return Returns the series associated with the legend item
*/
public Series getSeries() {
@@ -1493,9 +1382,8 @@ public Series getSeries() {
/**
* Interface for listening for a {@link SeriesLegendItemClickEvent}
* triggered by {@link InvientCharts}
- *
+ *
* @author Invient
- *
*/
public interface SeriesLegendItemClickListerner extends Serializable {
public void seriesLegendItemClick(
@@ -1508,14 +1396,13 @@ public void seriesLegendItemClick(
* Adds the series legend item click listener. If the argument seriesTypes
* is not specified then the listener will be added for all series type
* otherwise it will be added for a specific series type
- *
- * @param listener
- * the Listener to be added.
+ *
+ * @param listener the Listener to be added.
*/
public void addListener(SeriesLegendItemClickListerner listener,
- SeriesType... seriesTypes) {
+ SeriesType... seriesTypes) {
if (seriesTypes.length == 0) {
- seriesTypes = new SeriesType[] { SeriesType.COMMONSERIES };
+ seriesTypes = new SeriesType[]{SeriesType.COMMONSERIES};
}
for (SeriesType seriesType : seriesTypes) {
@@ -1536,16 +1423,14 @@ public void addListener(SeriesLegendItemClickListerner listener,
* seriesTypes is not specified then the listener will be removed only for a
* series type SeriesType.COMMONSERIES otherwise the listener will be
* removed for all specified series types.
- *
- * @param listener
- * the listener to be removed
- * @param seriesTypes
- * one or more series types as defined by (@link SeriesType}
+ *
+ * @param listener the listener to be removed
+ * @param seriesTypes one or more series types as defined by (@link SeriesType}
*/
public void removeListener(SeriesLegendItemClickListerner listener,
- SeriesType... seriesTypes) {
+ SeriesType... seriesTypes) {
if (seriesTypes.length == 0) {
- seriesTypes = new SeriesType[] { SeriesType.COMMONSERIES };
+ seriesTypes = new SeriesType[]{SeriesType.COMMONSERIES};
}
for (SeriesType seriesType : seriesTypes) {
if (seriesLegendItemClickListeners.containsKey(seriesType)) {
@@ -1565,17 +1450,17 @@ public void removeListener(SeriesLegendItemClickListerner listener,
static {
try {
SERIES_CLICK_METHOD = SeriesClickListerner.class.getDeclaredMethod(
- "seriesClick", new Class[] { SeriesClickEvent.class });
+ "seriesClick", new Class[]{SeriesClickEvent.class});
// SERIES_CHECKBOX_CLICK_METHOD = SeriesCheckboxClickListerner.class
// .getDeclaredMethod("seriesCheckboxClick",
// new Class[] { SeriesCheckboxClickEvent.class });
SERIES_HIDE_METHOD = SeriesHideListerner.class.getDeclaredMethod(
- "seriesHide", new Class[] { SeriesHideEvent.class });
+ "seriesHide", new Class[]{SeriesHideEvent.class});
SERIES_SHOW_METHOD = SeriesShowListerner.class.getDeclaredMethod(
- "seriesShow", new Class[] { SeriesShowEvent.class });
+ "seriesShow", new Class[]{SeriesShowEvent.class});
SERIES_LEGENDITEM_CLICK_METHOD = SeriesLegendItemClickListerner.class
.getDeclaredMethod("seriesLegendItemClick",
- new Class[] { SeriesLegendItemClickEvent.class });
+ new Class[]{SeriesLegendItemClickEvent.class});
} catch (final java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException(
@@ -1590,7 +1475,7 @@ public void removeListener(SeriesLegendItemClickListerner listener,
/**
* PieChart legend item click event. This event is thrown, when the legend
* item belonging to the pie point (slice) is clicked.
- *
+ *
* @author Invient
*/
public class PieChartLegendItemClickEvent extends Component.Event {
@@ -1600,23 +1485,19 @@ public class PieChartLegendItemClickEvent extends Component.Event {
/**
* New instance of the piechart legend item click event
- *
- * @param source
- * the chart object itself
- * @param chart
- * the chart object itself
- * @param point
- * the pie point (slice) associated with the legend item
+ *
+ * @param source the chart object itself
+ * @param chart the chart object itself
+ * @param point the pie point (slice) associated with the legend item
*/
public PieChartLegendItemClickEvent(Component source,
- InvientCharts chart, Point point) {
+ InvientCharts chart, Point point) {
super(source);
this.chart = chart;
this.point = point;
}
/**
- *
* @return Returns the chart object associated with the point
*/
public InvientCharts getChart() {
@@ -1624,7 +1505,6 @@ public InvientCharts getChart() {
}
/**
- *
* @return Returns the pie point (slice) associated with the legend item
*/
public Point getPoint() {
@@ -1635,9 +1515,8 @@ public Point getPoint() {
/**
* Interface for listening for a {@link PieChartLegendItemClickEvent}
* triggered by {@link InvientCharts}
- *
+ *
* @author Invient
- *
*/
public interface PieChartLegendItemClickListener extends Serializable {
public void legendItemClick(
@@ -1648,9 +1527,8 @@ public void legendItemClick(
/**
* Adds the piechart legend item click listener.
- *
- * @param listener
- * the Listener to be added.
+ *
+ * @param listener the Listener to be added.
*/
public void addListener(PieChartLegendItemClickListener listener) {
pieChartLegendItemClickListener.add(listener);
@@ -1660,9 +1538,8 @@ public void addListener(PieChartLegendItemClickListener listener) {
/**
* Removes the piechart legend item click listener.
- *
- * @param listener
- * the listener to be removed
+ *
+ * @param listener the listener to be removed
*/
public void removeListener(PieChartLegendItemClickListener listener) {
pieChartLegendItemClickListener.remove(listener);
@@ -1676,7 +1553,7 @@ public void removeListener(PieChartLegendItemClickListener listener) {
try {
LEGENDITEM_CLICK_METHOD = PieChartLegendItemClickListener.class
.getDeclaredMethod("legendItemClick",
- new Class[] { PieChartLegendItemClickEvent.class });
+ new Class[]{PieChartLegendItemClickEvent.class});
} catch (final java.lang.NoSuchMethodException e) {
// This should never happen
throw new java.lang.RuntimeException(
@@ -1687,7 +1564,7 @@ public void removeListener(PieChartLegendItemClickListener listener) {
/***************************** Chart Events *****************************/
/**
* Chart Click event. This event is thrown, when this chart is clicked.
- *
+ *
* @author Invient
*/
public class ChartClickEvent extends Component.Event {
@@ -1697,19 +1574,15 @@ public class ChartClickEvent extends Component.Event {
/**
* New instance of the chart click event.
- *
- * @param source
- * the chart object itself
- * @param chart
- * the chart object itself
- * @param point
- * the position where the click event occurred in axes units
- * @param mousePosition
- * the coordinate of mouse where the click event occurred in
- * pixels
+ *
+ * @param source the chart object itself
+ * @param chart the chart object itself
+ * @param point the position where the click event occurred in axes units
+ * @param mousePosition the coordinate of mouse where the click event occurred in
+ * pixels
*/
public ChartClickEvent(Component source, InvientCharts chart,
- Point point, MousePosition mousePosition) {
+ Point point, MousePosition mousePosition) {
super(source);
this.chart = chart;
this.point = point;
@@ -1718,7 +1591,7 @@ public ChartClickEvent(Component source, InvientCharts chart,
/**
* Returns the chart object on which the click event occurred
- *
+ *
* @return Returns the chart object on which the click event occurred
* @see InvientCharts
*/
@@ -1729,7 +1602,7 @@ public InvientCharts getChart() {
/**
* Returns the point representing the position where the click event
* occurred in axes units
- *
+ *
* @return Returns the point representing the position where the click
* event occurred in axes units
* @see Point
@@ -1740,7 +1613,7 @@ public Point getPoint() {
/**
* Returns the position of a mouse when the click event occurred
- *
+ *
* @return Returns the position of a mouse when the click event occurred
* @see MousePosition
*/
@@ -1759,9 +1632,8 @@ public String toString() {
/**
* Interface for listening for a {@link ChartClickEvent} triggered by
* {@link InvientCharts}
- *
+ *
* @author Invient
- *
*/
public interface ChartClickListener extends Serializable {
public void chartClick(ChartClickEvent chartClickEvent);
@@ -1771,9 +1643,8 @@ public interface ChartClickListener extends Serializable {
/**
* Adds the chart click listener.
- *
- * @param listener
- * the Listener to be added.
+ *
+ * @param listener the Listener to be added.
*/
public void addListener(ChartClickListener listener) {
chartClickListener.add(listener);
@@ -1782,9 +1653,8 @@ public void addListener(ChartClickListener listener) {
/**
* Removes the chart click listener.
- *
- * @param listener
- * the listener to be removed
+ *
+ * @param listener the listener to be removed
*/
public void removeListener(ChartClickListener listener) {
chartClickListener.remove(listener);
@@ -1794,7 +1664,7 @@ public void removeListener(ChartClickListener listener) {
/**
* Add series event. This event is thrown, when a series is added to the
* chart.
- *
+ *
* @author Invient
*/
public class ChartAddSeriesEvent extends Component.Event {
@@ -1802,7 +1672,7 @@ public class ChartAddSeriesEvent extends Component.Event {
/**
* New instance of the chart add series event.
- *
+ *
* @param source
* @param chart
*/
@@ -1813,7 +1683,7 @@ public ChartAddSeriesEvent(Component source, InvientCharts chart) {
/**
* Returns the chart object to which a series is added
- *
+ *
* @return Returns the chart object to which a series has been added.
* @see InvientCharts
*/
@@ -1825,9 +1695,8 @@ public InvientCharts getChart() {
/**
* Interface for listening for a {@link ChartAddSeriesEvent} triggered by
* {@link InvientCharts}
- *
+ *
* @author Invient
- *
*/
public interface ChartAddSeriesListener extends Serializable {
public void chartAddSeries(ChartAddSeriesEvent chartAddSeriesEvent);
@@ -1837,9 +1706,8 @@ public interface ChartAddSeriesListener extends Serializable {
/**
* Adds the series add listener.
- *
- * @param listener
- * the Listener to be added.
+ *
+ * @param listener the Listener to be added.
*/
public void addListener(ChartAddSeriesListener listener) {
chartAddSeriesListener.add(listener);
@@ -1849,9 +1717,8 @@ public void addListener(ChartAddSeriesListener listener) {
/**
* Removes the series add listener.
- *
- * @param listener
- * the listener to be removed
+ *
+ * @param listener the listener to be removed
*/
public void removeListener(ChartAddSeriesListener listener) {
chartAddSeriesListener.remove(listener);
@@ -1861,9 +1728,8 @@ public void removeListener(ChartAddSeriesListener listener) {
/**
* Defines information on the selected area.
- *
+ *
* @author Invient
- *
*/
public final class ChartArea implements Serializable {
private double xAxisMin;
@@ -1872,7 +1738,7 @@ public final class ChartArea implements Serializable {
private double yAxisMax;
public ChartArea(double xAxisMin, double xAxisMax, double yAxisMin,
- double yAxisMax) {
+ double yAxisMax) {
this.xAxisMin = xAxisMin;
this.xAxisMax = xAxisMax;
this.yAxisMin = yAxisMin;
@@ -1907,7 +1773,7 @@ public String toString() {
/**
* Chart zoom event. This event is thrown, when an area of the chart has
* been selected.
- *
+ *
* @author Invient
*/
public class ChartZoomEvent extends Component.Event {
@@ -1916,17 +1782,14 @@ public class ChartZoomEvent extends Component.Event {
/**
* New instance of the chart zoom event.
- *
- * @param source
- * the chart object itself
- * @param chart
- * the chart object itself
- * @param chartArea
- * the chartArea object containing dimensions of zoomed area
- * of the chart
+ *
+ * @param source the chart object itself
+ * @param chart the chart object itself
+ * @param chartArea the chartArea object containing dimensions of zoomed area
+ * of the chart
*/
public ChartZoomEvent(Component source, InvientCharts chart,
- ChartArea chartArea) {
+ ChartArea chartArea) {
super(source);
this.chart = chart;
this.chartArea = chartArea;
@@ -1934,7 +1797,7 @@ public ChartZoomEvent(Component source, InvientCharts chart,
/**
* Returns the chart object for which the zoom event has occurred
- *
+ *
* @return Returns the chart object for which the zoom event has
* occurred
*/
@@ -1945,7 +1808,7 @@ public InvientCharts getChart() {
/**
* Returns the chartArea object containing dimensions of zoomed area of
* the chart
- *
+ *
* @return Returns the chartArea object containing dimensions of zoomed
* area of the chart
*/
@@ -1957,9 +1820,8 @@ public ChartArea getChartArea() {
/**
* Interface for listening for a {@link ChartZoomEvent} triggered by
* {@link InvientCharts}
- *
+ *
* @author Invient
- *
*/
public interface ChartZoomListener extends Serializable {
public void chartZoom(ChartZoomEvent chartZoomEvent);
@@ -1969,9 +1831,8 @@ public interface ChartZoomListener extends Serializable {
/**
* Adds the chart zoom listener.
- *
- * @param listener
- * the Listener to be added.
+ *
+ * @param listener the Listener to be added.
*/
public void addListener(ChartZoomListener listener) {
chartZoomListener.add(listener);
@@ -1980,9 +1841,8 @@ public void addListener(ChartZoomListener listener) {
/**
* Removes the chart zoom listener.
- *
- * @param listener
- * the listener to be removed
+ *
+ * @param listener the listener to be removed
*/
public void removeListener(ChartZoomListener listener) {
chartZoomListener.remove(listener);
@@ -1992,7 +1852,7 @@ public void removeListener(ChartZoomListener listener) {
/**
* Chart reset zoom event. This event is thrown, when a chart is reset by
* setting its zoom level to normal.
- *
+ *
* @author Invient
*/
public class ChartResetZoomEvent extends Component.Event {
@@ -2000,11 +1860,9 @@ public class ChartResetZoomEvent extends Component.Event {
/**
* New instance of the chart reset zoom event
- *
- * @param source
- * the chart object itself
- * @param chart
- * the chart object itself
+ *
+ * @param source the chart object itself
+ * @param chart the chart object itself
*/
public ChartResetZoomEvent(Component source, InvientCharts chart) {
super(source);
@@ -2013,7 +1871,7 @@ public ChartResetZoomEvent(Component source, InvientCharts chart) {
/**
* Returns the chart object for which zoom has been reset to normal
- *
+ *
* @return Returns the chart object for which zoom has been reset to
* normal
*/
@@ -2025,9 +1883,8 @@ public InvientCharts getChart() {
/**
* Interface for listening for a {@link ChartResetZoomEvent} triggered by
* {@link InvientCharts}
- *
+ *
* @author Invient
- *
*/
public interface ChartResetZoomListener extends Serializable {
public void chartResetZoom(ChartResetZoomEvent chartResetZoomEvent);
@@ -2037,9 +1894,8 @@ public interface ChartResetZoomListener extends Serializable {
/**
* Adds the chart reset zoom listener.
- *
- * @param listener
- * the Listener to be added.
+ *
+ * @param listener the Listener to be added.
*/
public void addListener(ChartResetZoomListener listener) {
chartResetZoomListener.add(listener);
@@ -2049,9 +1905,8 @@ public void addListener(ChartResetZoomListener listener) {
/**
* Removes the chart reset zoom listener.
- *
- * @param listener
- * the listener to be removed
+ *
+ * @param listener the listener to be removed
*/
public void removeListener(ChartResetZoomListener listener) {
chartResetZoomListener.remove(listener);
@@ -2062,10 +1917,10 @@ public void removeListener(ChartResetZoomListener listener) {
/**
* Chart SVG event. This event is thrown, when an SVG string representing
* the chart is received or ready.
- *
+ *
* Note that this event is thrown only once after a
* {@link ChartSVGAvailableListener} is registered.
- *
+ *
* @author Invient
*/
public class ChartSVGAvailableEvent extends Component.Event {
@@ -2074,16 +1929,13 @@ public class ChartSVGAvailableEvent extends Component.Event {
/**
* New instance of the chart svg available event.
- *
- * @param source
- * the chart object itself
- * @param chart
- * the chart object itself
- * @param svg
- * an svg string representing the chart object
+ *
+ * @param source the chart object itself
+ * @param chart the chart object itself
+ * @param svg an svg string representing the chart object
*/
public ChartSVGAvailableEvent(Component source, InvientCharts chart,
- String svg) {
+ String svg) {
super(source);
this.chart = chart;
this.svg = svg;
@@ -2092,7 +1944,7 @@ public ChartSVGAvailableEvent(Component source, InvientCharts chart,
/**
* Returns the chart object for which an svg string representation is
* available
- *
+ *
* @return Returns the chart object for which an svg string
* representation is available
*/
@@ -2101,7 +1953,6 @@ public InvientCharts getChart() {
}
/**
- *
* @return Returns an SVG string representing the chart
*/
public String getSVG() {
@@ -2113,17 +1964,16 @@ public String getSVG() {
/**
* Interface for listening for a {@link ChartSVGAvailableEvent} triggered by
* {@link InvientCharts}.
- *
+ *
* The chart can have only one listener of this type registered at any time.
* If a listener has already been registered and an attempt is made to
* register another listener then the previously registered listener will be
* unregistered and the new listener will be registered.
- *
+ *
* A listener will be called only once after it has been registered though
* it will be called again if the same listener is registered again.
- *
+ *
* @author Invient
- *
*/
public interface ChartSVGAvailableListener extends Serializable {
public void svgAvailable(ChartSVGAvailableEvent chartSVGAvailableEvent);
@@ -2135,9 +1985,8 @@ public interface ChartSVGAvailableListener extends Serializable {
* Adds the chart svg available listener for this chart. If the chart
* already has a listener of this type then the existing listener will be
* removed and the argument listener will be registered.
- *
- * @param listener
- * the Listener to be added or registered.
+ *
+ * @param listener the Listener to be added or registered.
*/
public void addListener(ChartSVGAvailableListener listener) {
if (svgAvailableListener != null && svgAvailableListener != listener) {
@@ -2153,9 +2002,8 @@ public void addListener(ChartSVGAvailableListener listener) {
/**
* Removes the chart svg available listener for this chart.
- *
- * @param listener
- * the listener to be removed or unregistered.
+ *
+ * @param listener the listener to be removed or unregistered.
*/
public void removeListener(ChartSVGAvailableListener listener) {
if (svgAvailableListener == listener) {
@@ -2175,18 +2023,18 @@ public void removeListener(ChartSVGAvailableListener listener) {
static {
try {
CHART_CLICK_METHOD = ChartClickListener.class.getDeclaredMethod(
- "chartClick", new Class[] { ChartClickEvent.class });
+ "chartClick", new Class[]{ChartClickEvent.class});
CHART_ADD_SERIES_METHOD = ChartAddSeriesListener.class
.getDeclaredMethod("chartAddSeries",
- new Class[] { ChartAddSeriesEvent.class });
+ new Class[]{ChartAddSeriesEvent.class});
CHART_ZOOM_METHOD = ChartZoomListener.class.getDeclaredMethod(
- "chartZoom", new Class[] { ChartZoomEvent.class });
+ "chartZoom", new Class[]{ChartZoomEvent.class});
CHART_RESET_ZOOM_METHOD = ChartResetZoomListener.class
.getDeclaredMethod("chartResetZoom",
- new Class[] { ChartResetZoomEvent.class });
+ new Class[]{ChartResetZoomEvent.class});
CHART_SVG_AVAILABLE_METHOD = ChartSVGAvailableListener.class
.getDeclaredMethod("svgAvailable",
- new Class[] { ChartSVGAvailableEvent.class });
+ new Class[]{ChartSVGAvailableEvent.class});
} catch (final java.lang.NoSuchMethodException e) {
// This should never happen unless there is a typo!
throw new java.lang.RuntimeException(
@@ -2205,9 +2053,8 @@ public void removeListener(ChartSVGAvailableListener listener) {
* The data of a chart is defined in terms of {@link Series}. This method
* removes all previously set series of this chart and adds the argument
* series. If the argument series is null then no actions are taken.
- *
- * @param series
- * A collection of series to set as chart's data
+ *
+ * @param series A collection of series to set as chart's data
*/
public void setSeries(LinkedHashSet series) {
if (series != null) {
@@ -2222,9 +2069,8 @@ public void setSeries(LinkedHashSet series) {
/**
* Returns a series whose name matches the argument name.
- *
- * @param name
- * the name of the series
+ *
+ * @param name the name of the series
* @return Returns a series with the given name
*/
public Series getSeries(String name) {
@@ -2238,6 +2084,7 @@ public Series getSeries(String name) {
/**
* Returns all series associated with this chart.
+ *
* @return returns all series associated with this chart.
*/
public LinkedHashSet getAllSeries() {
@@ -2246,9 +2093,8 @@ public LinkedHashSet getAllSeries() {
/**
* Adds the argument series to this chart.
- *
- * @param seriesData
- * the series to be added
+ *
+ * @param seriesData the series to be added
*/
public void addSeries(Series seriesData) {
if (this.chartSeries.add(seriesData)) {
@@ -2263,11 +2109,11 @@ public void addSeries(Series seriesData) {
// Before sending data to the client, this method sets
// axis in all series associated with the chart
private void setAxisInAllSeriesIfNotSetAlready() {
- for(Series series : this.chartSeries) {
+ for (Series series : this.chartSeries) {
setAxisInSeriesIfNotSetAlready(series);
}
}
-
+
private void setAxisInSeriesIfNotSetAlready(Series series) {
if (this.getConfig() != null) {
if (series.getXAxis() == null
@@ -2285,13 +2131,12 @@ private void setAxisInSeriesIfNotSetAlready(Series series) {
/**
* Removes a series whose name matches the argument name.
- *
- * @param name
- * the name of the series
+ *
+ * @param name the name of the series
*/
public void removeSeries(String name) {
for (Iterator seriesItr = this.chartSeries.iterator(); seriesItr
- .hasNext();) {
+ .hasNext(); ) {
Series series = seriesItr.next();
if (series.getName().equals(name)) {
seriesItr.remove();
@@ -2305,9 +2150,8 @@ public void removeSeries(String name) {
/**
* Removes the argument seriesData from this chart.
- *
- * @param seriesData
- * the series object to be removed
+ *
+ * @param seriesData the series object to be removed
*/
public void removeSeries(Series seriesData) {
if (this.chartSeries.remove(seriesData)) {
@@ -2323,24 +2167,22 @@ public void removeSeries(Series seriesData) {
* one or more points. A point has (X, Y) coordinates. None of the
* coordinates are mandatory. The name of a point can be displayed in a
* tooltip.
- *
+ *
* To represent no activity or missing points in the chart, create a point
* with both X and Y as null or just Y as null.
- *
+ *
* It is possible to specify custom configuration for each point. e.g. If a
* highest point can be marked in a chart with a different color using this
* configuration.
- *
+ *
* A point cannot be created without a series. It must belong to a series.
* However, the point must be added to a series by calling Series.addPoint()
* or Series.setPoints() to permanently add point to the series.
- *
+ *
* @author Invient
- *
* @see DecimalPoint
* @see DateTimePoint
* @see PointConfig
- *
*/
public static abstract class Point implements Serializable {
private String id;
@@ -2352,12 +2194,9 @@ public static abstract class Point implements Serializable {
/**
* Creates a point with given arguments.
- *
- * @param series
- * The series to which the point must be associated.
- * @exception IllegalArgumentException
- * If the argument series is null
- *
+ *
+ * @param series The series to which the point must be associated.
+ * @throws IllegalArgumentException If the argument series is null
*/
public Point(Series series) {
if (series == null) {
@@ -2376,13 +2215,10 @@ private Point() {
/**
* Creates a point with given arguments.
- *
- * @param series
- * The series to which the point must be associated.
- * @param config
- * The configuration for this point, if any
- * @exception IllegalArgumentException
- * If the argument series is null
+ *
+ * @param series The series to which the point must be associated.
+ * @param config The configuration for this point, if any
+ * @throws IllegalArgumentException If the argument series is null
*/
public Point(Series series, PointConfig config) {
this(series);
@@ -2391,13 +2227,10 @@ public Point(Series series, PointConfig config) {
/**
* Creates a point with given arguments.
- *
- * @param series
- * The series to which the point must be associated.
- * @param name
- * name of this point
- * @exception IllegalArgumentException
- * If the argument series is null
+ *
+ * @param series The series to which the point must be associated.
+ * @param name name of this point
+ * @throws IllegalArgumentException If the argument series is null
*/
public Point(Series series, String name) {
this(series);
@@ -2406,15 +2239,11 @@ public Point(Series series, String name) {
/**
* Creates a point with given arguments.
- *
- * @param series
- * The series to which the point must be associated.
- * @param name
- * name of this point
- * @param config
- * The configuration for this point, if any
- * @exception IllegalArgumentException
- * If the argument series is null
+ *
+ * @param series The series to which the point must be associated.
+ * @param name name of this point
+ * @param config The configuration for this point, if any
+ * @throws IllegalArgumentException If the argument series is null
*/
public Point(Series series, String name, PointConfig config) {
this(series, name);
@@ -2426,7 +2255,6 @@ String getId() {
}
/**
- *
* @return Returns name of this point
*/
public String getName() {
@@ -2435,16 +2263,14 @@ public String getName() {
/**
* Sets name of this point
- *
- * @param name
- * name of this point
+ *
+ * @param name name of this point
*/
public void setName(String name) {
this.name = name;
}
/**
- *
* @return Returns {@link Series} associated with this point
*/
public Series getSeries() {
@@ -2452,7 +2278,6 @@ public Series getSeries() {
}
/**
- *
* @return Returns {@link PointConfig} for this point
*/
public PointConfig getConfig() {
@@ -2461,9 +2286,8 @@ public PointConfig getConfig() {
/**
* Sets {@link PointConfig} for this point
- *
- * @param config
- * configuration of this point
+ *
+ * @param config configuration of this point
* @see PointConfig
*/
public void setConfig(PointConfig config) {
@@ -2471,7 +2295,6 @@ public void setConfig(PointConfig config) {
}
/**
- *
* @return Returns true if X value of this point is set programmatically
*/
boolean isAutosetX() {
@@ -2481,7 +2304,7 @@ boolean isAutosetX() {
/**
* If the argument is true it indicates that the X value of this point
* is set programmatically and user has not specified it.
- *
+ *
* @return
*/
void setAutosetX(boolean isAutosetX) {
@@ -2489,7 +2312,6 @@ void setAutosetX(boolean isAutosetX) {
}
/**
- *
* @return Returns true if a point at the start of the series should be
* shifted off when this point is appended otherwise false.
*/
@@ -2500,7 +2322,7 @@ boolean isShift() {
/**
* A value of true means one point is shifted off the start of the
* series as one is appended to the end.
- *
+ *
* @param shift
*/
void setShift(boolean shift) {
@@ -2508,13 +2330,11 @@ void setShift(boolean shift) {
}
/**
- *
* @return Returns X value of this point
*/
public abstract Object getX();
/**
- *
* @return Returns Y value of this point
*/
public abstract Object getY();
@@ -2530,27 +2350,23 @@ public String toString() {
/**
* This class represent a point with (X, Y) both as number. It should be
* used to add points to {@link XYSeries}
- *
+ *
* @author Invient
- *
*/
public static final class DecimalPoint extends Point {
private Double x;
private Double y;
/**
- * @param series
- * the series to which this belongs to
+ * @param series the series to which this belongs to
*/
public DecimalPoint(Series series) {
super(series);
}
/**
- * @param series
- * the series to which this point belongs to
- * @param y
- * the y value of this point
+ * @param series the series to which this point belongs to
+ * @param y the y value of this point
*/
public DecimalPoint(Series series, double y) {
super(series);
@@ -2558,12 +2374,9 @@ public DecimalPoint(Series series, double y) {
}
/**
- * @param series
- * the series to which this belongs to
- * @param name
- * the name of this point
- * @param y
- * the y value of this point
+ * @param series the series to which this belongs to
+ * @param name the name of this point
+ * @param y the y value of this point
*/
public DecimalPoint(Series series, String name, double y) {
super(series, name);
@@ -2572,11 +2385,9 @@ public DecimalPoint(Series series, String name, double y) {
/**
* To allow creation of a point within the InvientChart.
- *
- * @param x
- * the x value of this point
- * @param y
- * the y value of this point
+ *
+ * @param x the x value of this point
+ * @param y the y value of this point
*/
private DecimalPoint(double x, double y) {
// FIXME this is not a correct way of doing it.
@@ -2586,27 +2397,21 @@ private DecimalPoint(double x, double y) {
}
/**
- * @param series
- * the series to which this belongs to
- * @param name
- * the name for this point
- * @param y
- * the y value of this point
+ * @param series the series to which this belongs to
+ * @param name the name for this point
+ * @param y the y value of this point
* @param config
*/
public DecimalPoint(Series series, String name, double y,
- PointConfig config) {
+ PointConfig config) {
super(series, name, config);
this.y = y;
}
/**
- * @param series
- * the series to which this belongs to
- * @param y
- * the y value of this point
- * @param config
- * the configuration for this point
+ * @param series the series to which this belongs to
+ * @param y the y value of this point
+ * @param config the configuration for this point
*/
public DecimalPoint(Series series, double y, PointConfig config) {
super(series, config);
@@ -2614,58 +2419,44 @@ public DecimalPoint(Series series, double y, PointConfig config) {
}
/**
- * @param series
- * the series to which this belongs to
- * @param x
- * the x value of this point
- * @param y
- * the y value of this point
+ * @param series the series to which this belongs to
+ * @param x the x value of this point
+ * @param y the y value of this point
*/
public DecimalPoint(Series series, double x, double y) {
this(series, x, y, null);
}
/**
- * @param series
- * the series to which this belongs to
- * @param x
- * the x value of this point
- * @param y
- * the y value of this point
+ * @param series the series to which this belongs to
+ * @param x the x value of this point
+ * @param y the y value of this point
*/
public DecimalPoint(Series series, Double x, Double y) {
this(series, x, y, null);
}
/**
- * @param series
- * the series to which this belongs to
- * @param x
- * the x value of this point
- * @param y
- * the y value of this point
- * @param config
- * the configuration of this point
+ * @param series the series to which this belongs to
+ * @param x the x value of this point
+ * @param y the y value of this point
+ * @param config the configuration of this point
*/
public DecimalPoint(Series series, double x, double y,
- PointConfig config) {
+ PointConfig config) {
super(series, config);
this.x = x;
this.y = y;
}
/**
- * @param series
- * the series to which this belongs to
- * @param x
- * the x value of this point
- * @param y
- * the y value of this point
- * @param config
- * the configuration of this point
+ * @param series the series to which this belongs to
+ * @param x the x value of this point
+ * @param y the y value of this point
+ * @param config the configuration of this point
*/
public DecimalPoint(Series series, Double x, Double y,
- PointConfig config) {
+ PointConfig config) {
super(series, config);
this.x = x;
this.y = y;
@@ -2683,7 +2474,7 @@ public Double getX() {
/**
* Sets the x value of this point
- *
+ *
* @param x
*/
private void setX(Double x) {
@@ -2702,7 +2493,7 @@ public Double getY() {
/**
* Sets the y value of this point
- *
+ *
* @param y
*/
private void setY(Double y) {
@@ -2755,39 +2546,32 @@ public boolean equals(Object obj) {
/**
* This class represent a point with (X, Y) both as number. It should be
* used to add points to {@link DateTimeSeries}
- *
+ *
* @author Invient
- *
*/
public static final class DateTimePoint extends Point {
private Date x;
private Double y;
/**
- * @param series
- * the series to which this belongs to
+ * @param series the series to which this belongs to
*/
public DateTimePoint(Series series) {
super(series);
}
/**
- * @param series
- * the series to which this belongs to
- * @param y
- * the y value of this point
+ * @param series the series to which this belongs to
+ * @param y the y value of this point
*/
public DateTimePoint(Series series, double y) {
this(series, "", y);
}
/**
- * @param series
- * the series to which this belongs to
- * @param name
- * the name of this point
- * @param y
- * the y value of this point
+ * @param series the series to which this belongs to
+ * @param name the name of this point
+ * @param y the y value of this point
*/
public DateTimePoint(Series series, String name, double y) {
super(series, name);
@@ -2795,27 +2579,21 @@ public DateTimePoint(Series series, String name, double y) {
}
/**
- * @param series
- * the series to which this belongs to
- * @param name
- * the name of this point
- * @param y
- * the y value of this point
+ * @param series the series to which this belongs to
+ * @param name the name of this point
+ * @param y the y value of this point
* @param config
*/
public DateTimePoint(Series series, String name, double y,
- PointConfig config) {
+ PointConfig config) {
super(series, name, config);
this.y = y;
}
/**
- * @param series
- * the series to which this belongs to
- * @param x
- * the x value of this point
- * @param y
- * the y value of this point
+ * @param series the series to which this belongs to
+ * @param x the x value of this point
+ * @param y the y value of this point
*/
public DateTimePoint(Series series, Date x, double y) {
this(series, y);
@@ -2833,7 +2611,7 @@ public Date getX() {
/**
* Sets the x value of this point
- *
+ *
* @param x
*/
private void setX(Date x) {
@@ -2851,7 +2629,7 @@ public Double getY() {
/**
* Sets the y value of this point
- *
+ *
* @param y
*/
private void setY(Double y) {
@@ -2862,9 +2640,9 @@ private void setY(Double y) {
public String toString() {
return "DateTimePoint [x="
+ getDateInMilliseconds(
- x,
- (getSeries() != null ? ((DateTimeSeries) getSeries())
- .isIncludeTime() : false)) + ", y=" + y
+ x,
+ (getSeries() != null ? ((DateTimeSeries) getSeries())
+ .isIncludeTime() : false)) + ", y=" + y
+ ", id=" + getId() + ", name=" + getName()
+ ", seriesName="
+ (getSeries() != null ? getSeries().getName() : "") + "]";
@@ -2875,6 +2653,7 @@ public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((y == null) ? 0 : y.hashCode());
+ result = prime * result + ((x == null) ? 0 : (int) x.getTime());
return result;
}
@@ -2918,24 +2697,24 @@ public boolean equals(Object obj) {
/**
* This class defines a series of the chart. A series contains a collection
* of points. Series can be one of types defined by {@link SeriesType}.
- *
+ *
* Each series must have unique name. If an attempt is made to add two
* series with same then only the first added series will be in effect.
- *
+ *
* If the series type is not specified, it defaults to chart type and the
* default chart type is SeriesType.LINE. A series has unique xAxis and
* yAxis object associated with it. There is no need to set xAxis and yAxis
* unless the chart has more than one one axis of any type and the series
* must belong to any of the secondary axis.
- *
+ *
* It is also possible to specify configuration for individual series and
* not just series type.
- *
+ *
* @author Invient
- *
*/
- public static abstract class Series implements Serializable {
- private LinkedHashSet points = new LinkedHashSet();
+ public static abstract class Series implements Serializable {
+
+ private LinkedHashSet points = new LinkedHashSet();
private String name = "";
private SeriesType type;
private String stack;
@@ -2946,9 +2725,8 @@ public static abstract class Series implements Serializable {
/**
* Creates a series with given name
- *
- * @param name
- * the name of this series
+ *
+ * @param name the name of this series
*/
public Series(String name) {
this.name = name;
@@ -2956,11 +2734,9 @@ public Series(String name) {
/**
* Creates a series with given name and type
- *
- * @param name
- * the name of this series
- * @param seriesType
- * the type of this series
+ *
+ * @param name the name of this series
+ * @param seriesType the type of this series
*/
public Series(String name, SeriesType seriesType) {
this(name);
@@ -2969,11 +2745,9 @@ public Series(String name, SeriesType seriesType) {
/**
* Creates a series with given name and configuration
- *
- * @param name
- * the name of this series
- * @param config
- * the configuration for this series
+ *
+ * @param name the name of this series
+ * @param config the configuration for this series
*/
public Series(String name, SeriesConfig config) {
this(name);
@@ -2982,13 +2756,10 @@ public Series(String name, SeriesConfig config) {
/**
* Creates a series with given name, type and configuration
- *
- * @param name
- * the name of this series
- * @param seriesType
- * the type of this series
- * @param config
- * the configuration for this series
+ *
+ * @param name the name of this series
+ * @param seriesType the type of this series
+ * @param config the configuration for this series
*/
public Series(String name, SeriesType seriesType, SeriesConfig config) {
this(name, config);
@@ -3011,7 +2782,7 @@ public String getName() {
/**
* Sets name of this series
- *
+ *
* @param name
*/
public void setName(String name) {
@@ -3027,7 +2798,7 @@ public SeriesType getType() {
/**
* Sets type of this series
- *
+ *
* @param type
*/
public void setType(SeriesType type) {
@@ -3045,7 +2816,7 @@ public String getStack() {
* By using this stack property, it is possible to group series in a
* stacked chart. Sets stack for this series. If two series belongs to
* the same stack then the resultant chart will be stacked chart
- *
+ *
* @param stack
*/
public void setStack(String stack) {
@@ -3063,7 +2834,7 @@ public XAxis getXAxis() {
/**
* Sets x-axis of this series. A series can be associated with at most
* one x-axis.
- *
+ *
* @param xAxis
*/
public void setXAxis(XAxis xAxis) {
@@ -3080,7 +2851,7 @@ public YAxis getYAxis() {
/**
* Sets y-axis of this series. A series can be associated with at most
* one y-axis.
- *
+ *
* @param yAxis
*/
public void setYAxis(YAxis yAxis) {
@@ -3122,24 +2893,24 @@ protected void removeAllPoints() {
/**
* Adds one or more points into this series, specified as an argument to
* this method
- *
+ *
* @param points
* @return Returns null if the argument is null otherwise returns a
* collection of points which are added in this series. If a
* point has same (x, y) value as any other point in the
* argument points then it will not be added.
*/
- protected LinkedHashSet addPoint(boolean shift, Point... points) {
+ protected LinkedHashSet addPoint(boolean shift, T... points) {
if (shift) {
// Remove first point as other points gets appended at the end
- Iterator pointsItr = this.points.iterator();
+ Iterator pointsItr = this.points.iterator();
if (pointsItr.hasNext()) {
pointsItr.next();
pointsItr.remove();
}
}
- List pointsAddedList = new ArrayList();
- for (Point point : points) {
+ List pointsAddedList = new ArrayList();
+ for (T point : points) {
if (this.points.add(point)) {
pointsAddedList.add(point);
}
@@ -3153,36 +2924,35 @@ protected LinkedHashSet addPoint(boolean shift, Point... points) {
this.invientCharts.requestRepaint();
}
}
- return new LinkedHashSet(pointsAddedList);
+ return new LinkedHashSet(pointsAddedList);
}
- private void addPointsInternal(LinkedHashSet extends Point> points) {
- for (Point point : points) {
+ private void addPointsInternal(LinkedHashSet points) {
+ for (T point : points) {
this.points.add(point);
}
}
/**
- *
* @return Returns all points of this series. Adding or removing any
* point to or from the returned collection will not impact the
* chart. To add a point or points, use addPoint() or
* removePoint() method.
*/
- protected LinkedHashSet getPoints() {
- return new LinkedHashSet(this.points);
+ protected LinkedHashSet getPoints() {
+ return new LinkedHashSet(this.points);
}
/**
* Sets points into this series
- *
- * @param points
- * @return Returns null if the argument is null otherwise returns a
+ *
+ * @param points The points to set.
+ * @return Returns {@code null} if the argument is {@code null} otherwise returns a
* collection of points which are set in this series. If a point
* has same (x, y) value as any other point in the argument
* points then it will not be added.
*/
- protected LinkedHashSet setPoints(LinkedHashSet extends Point> points) {
+ protected LinkedHashSet setPoints(LinkedHashSet points) {
if (points != null) {
this.points.clear();
addPointsInternal(points);
@@ -3271,18 +3041,16 @@ public String toString() {
/**
* This class defines a number series. In this series both X and Y values
* must be number. To use date values, use {@link DateTimeSeries}
- *
+ *
* @author Invient
- *
* @see DateTimeSeries
*/
- public static class XYSeries extends Series {
+ public static class XYSeries extends Series {
/**
* Creates a series with given name
- *
- * @param name
- * the name of this series
+ *
+ * @param name the name of this series
*/
public XYSeries(String name) {
super(name);
@@ -3290,11 +3058,9 @@ public XYSeries(String name) {
/**
* Creates a series with given name and configuration
- *
- * @param name
- * the name of this series
- * @param config
- * the configuration for this series
+ *
+ * @param name the name of this series
+ * @param config the configuration for this series
*/
public XYSeries(String name, SeriesConfig config) {
super(name, config);
@@ -3302,11 +3068,9 @@ public XYSeries(String name, SeriesConfig config) {
/**
* Creates a series with given name and type
- *
- * @param name
- * the name of this series
- * @param seriesType
- * the type of this series
+ *
+ * @param name the name of this series
+ * @param seriesType the type of this series
*/
public XYSeries(String name, SeriesType seriesType) {
super(name, seriesType);
@@ -3314,13 +3078,10 @@ public XYSeries(String name, SeriesType seriesType) {
/**
* Creates a series with given name, type and configuration
- *
- * @param name
- * the name of this series
- * @param seriesType
- * the type of this series
- * @param config
- * the configuration for this series
+ *
+ * @param name the name of this series
+ * @param seriesType the type of this series
+ * @param config the configuration for this series
*/
public XYSeries(String name, SeriesType seriesType, SeriesConfig config) {
super(name, seriesType, config);
@@ -3328,8 +3089,8 @@ public XYSeries(String name, SeriesType seriesType, SeriesConfig config) {
/**
* Removes the specified point from the series
- *
- * @param points
+ *
+ * @param points Points to be removed.
*/
public void removePoint(DecimalPoint... points) {
super.removePoint(points);
@@ -3348,8 +3109,8 @@ public void removeAllPoints() {
* Appends the specified point into the series if they do not exists in
* this series. The points which already exists will not be appended. A
* collection of points appended to this series will be returned.
- *
- * @param points
+ *
+ * @param points Points to be added.
* @return Returns a collection of points which are added in this
* series. If a point has same (x, y) value as any other point
* in the input argument points then it will not be added in
@@ -3363,26 +3124,23 @@ public LinkedHashSet addPoint(DecimalPoint... points) {
* Append the specified point into this series. If the argument shift is
* true then one point is shifted off the start of this series as one is
* appended to the end.
- *
- * @param points
- * @param shift
- * If true then one point is shifted off the start of this
- * series as one is appended to the end.
+ *
+ * @param point Point to add.
+ * @param shift If true then one point is shifted off the start of this
+ * series as one is appended to the end.
* @return Returns a collection of points which are added in this
* series. If a point has same (x, y) value as any other point
* in the input argument points then it will not be added in
* this series.
*/
public LinkedHashSet addPoint(DecimalPoint point,
- boolean shift) {
+ boolean shift) {
point.setShift(shift);
return super.addPoint(shift, point);
}
- /*
- * (non-Javadoc)
- *
- * @see com.invient.vaadin.chart.InvientChart.Series#getPoints()
+ /**
+ * {@inheritDoc}
*/
public LinkedHashSet getPoints() {
return super.getPoints();
@@ -3392,15 +3150,13 @@ public LinkedHashSet getPoints() {
* Sets points into this series. This method removes all of its points
* and then add points specified in the method argument. If the argument
* is null then no actions are taken.
- *
- * @param points
- * the collection of points to set into this series.
+ *
+ * @param points the collection of points to set into this series.
* @return Returns a collection of points which are set in this series.
* If a point has same (x, y) value as any other point in the
* argument points then it will not be added.
*/
- public LinkedHashSet setSeriesPoints(
- LinkedHashSet points) {
+ public LinkedHashSet setSeriesPoints(LinkedHashSet points) {
return super.setPoints(points);
}
@@ -3418,16 +3174,16 @@ protected void updatePointXValuesIfNotPresent() {
}
}
int count = 0;
- for (DecimalPoint point : getPoints()) {
- if ((point.getX() == null || (point.getX() != null && point
- .isAutosetX()))) {
+ for (Point point : getPoints()) {
+ if ((point.getX() == null || (point.getX() != null && point.isAutosetX()))) {
+ DecimalPoint decimalPoint = (DecimalPoint) point;
point.setAutosetX(true);
if (count == 0) {
- point.setX(pointStart);
+ decimalPoint.setX(pointStart);
count++;
} else {
pointStart = pointStart + pointInterval;
- point.setX(pointStart);
+ decimalPoint.setX(pointStart);
}
}
}
@@ -3439,25 +3195,23 @@ protected void updatePointXValuesIfNotPresent() {
* This class defines a datetime series. In this series, the X value must be
* date and Y values must be number. To use number values, use
* {@link XYSeries}
- *
+ *
* By default, the time of a day is not included in the X value. In order to
* include time, use a constructor with argument isIncludeTime and pass true
* value for the argument.
- *
+ *
* @author Invient
- *
* @see XYSeries
*/
- public static class DateTimeSeries extends Series {
+ public static class DateTimeSeries extends Series {
private boolean includeTime;
/**
* Creates a series with given name. This series will not consider time
* in the X property of {@link DateTimePoint}. To include time, use any
* constructor having isIncludeTime as part of the arguments.
- *
- * @param name
- * the name of this series
+ *
+ * @param name the name of this series
*/
public DateTimeSeries(String name) {
this(name, false);
@@ -3465,13 +3219,11 @@ public DateTimeSeries(String name) {
/**
* Creates a series with given name and boolean value.
- *
- * @param name
- * the name of this series
- * @param isIncludeTime
- * If true then the time in the X property of
- * {@link DateTimePoint} will be considered when drawing the
- * chart. Defaults to false.
+ *
+ * @param name the name of this series
+ * @param isIncludeTime If true then the time in the X property of
+ * {@link DateTimePoint} will be considered when drawing the
+ * chart. Defaults to false.
*/
public DateTimeSeries(String name, boolean isIncludeTime) {
super(name);
@@ -3480,11 +3232,9 @@ public DateTimeSeries(String name, boolean isIncludeTime) {
/**
* Creates a series with given name and configuration.
- *
- * @param name
- * the name of this series
- * @param config
- * the configuration for this series
+ *
+ * @param name the name of this series
+ * @param config the configuration for this series
*/
public DateTimeSeries(String name, SeriesConfig config) {
this(name, config, false);
@@ -3492,29 +3242,24 @@ public DateTimeSeries(String name, SeriesConfig config) {
/**
* Creates a series with given name, configuration and boolean value.
- *
- * @param name
- * the name of this series
- * @param config
- * the configuration for this series
- * @param isIncludeTime
- * If true then the time in the X property of
- * {@link DateTimePoint} will be considered when drawing the
- * chart. Defaults to false.
+ *
+ * @param name the name of this series
+ * @param config the configuration for this series
+ * @param isIncludeTime If true then the time in the X property of
+ * {@link DateTimePoint} will be considered when drawing the
+ * chart. Defaults to false.
*/
public DateTimeSeries(String name, SeriesConfig config,
- boolean isIncludeTime) {
+ boolean isIncludeTime) {
super(name, config);
this.includeTime = isIncludeTime;
}
/**
* Creates a series with given name and type.
- *
- * @param name
- * the name of this series
- * @param seriesType
- * the type of this series
+ *
+ * @param name the name of this series
+ * @param seriesType the type of this series
*/
public DateTimeSeries(String name, SeriesType seriesType) {
this(name, seriesType, false);
@@ -3522,62 +3267,52 @@ public DateTimeSeries(String name, SeriesType seriesType) {
/**
* Creates a series with given name, type and boolean value.
- *
- * @param name
- * the name of this series
- * @param seriesType
- * the type of this series
- * @param isIncludeTime
- * If true then the time in the X property of
- * {@link DateTimePoint} will be considered when drawing the
- * chart. Defaults to false.
+ *
+ * @param name the name of this series
+ * @param seriesType the type of this series
+ * @param isIncludeTime If true then the time in the X property of
+ * {@link DateTimePoint} will be considered when drawing the
+ * chart. Defaults to false.
*/
public DateTimeSeries(String name, SeriesType seriesType,
- boolean isIncludeTime) {
+ boolean isIncludeTime) {
super(name, seriesType);
this.includeTime = isIncludeTime;
}
/**
* Creates a series with given name, type and configuration.
- *
- * @param name
- * the name of this series
- * @param seriesType
- * the type of this series
- * @param config
- * the configuration for this series
+ *
+ * @param name the name of this series
+ * @param seriesType the type of this series
+ * @param config the configuration for this series
*/
public DateTimeSeries(String name, SeriesType seriesType,
- SeriesConfig config) {
+ SeriesConfig config) {
this(name, seriesType, config, false);
}
/**
* Creates a series with given name, type, configuration and boolean
* value.
- *
- * @param name
- * the name of this series
- * @param seriesType
- * the type of this series
- * @param config
- * the configuration for this series
- * @param isIncludeTime
- * If true then the time in the X property of
- * {@link DateTimePoint} will be considered when drawing the
- * chart. Defaults to false.
+ *
+ * @param name the name of this series
+ * @param seriesType the type of this series
+ * @param config the configuration for this series
+ * @param isIncludeTime If true then the time in the X property of
+ * {@link DateTimePoint} will be considered when drawing the
+ * chart. Defaults to false.
*/
public DateTimeSeries(String name, SeriesType seriesType,
- SeriesConfig config, boolean isIncludeTime) {
+ SeriesConfig config, boolean isIncludeTime) {
super(name, seriesType, config);
this.includeTime = isIncludeTime;
}
/**
* Removes all points specified as method argument into this series
- *
- * @param points
+ *
+ * @param points The points to be removed.
*/
public void removePoint(DateTimePoint... points) {
super.removePoint(points);
@@ -3596,8 +3331,9 @@ public void removeAllPoints() {
* Appends the specified point into the series if they do not exists in
* this series. The points which already exists will not be appended. A
* collection of points appended to this series will be returned.
- *
- * @param points
+ *
+ * @param points The points to be removed.
+ *
* @return Returns a collection of points which are added in this
* series. If a point has same (x, y) value as any other point
* in the input argument points then it will not be added in
@@ -3611,25 +3347,22 @@ public LinkedHashSet addPoint(DateTimePoint... points) {
* Append the specified point into this series. If the argument shift is
* true then one point is shifted off the start of this series as one is
* appended to the end.
- *
- * @param point
- * A point to be added at the end of this series
- * @param shift
- * If true then one point is shifted off the start of this
- * series as one is appended to the end.
+ *
+ * @param point A point to be added at the end of this series
+ * @param shift If true then one point is shifted off the start of this
+ * series as one is appended to the end.
* @return Returns a collection of points which are added in this
* series. If a point has same (x, y) value as any other point
* in the input argument points then it will not be added in
* this series.
*/
public LinkedHashSet addPoint(DateTimePoint point,
- boolean shift) {
+ boolean shift) {
point.setShift(shift);
return super.addPoint(shift, point);
}
/**
- *
* @return Returns true if the time in the X property of
* {@link DateTimePoint} will be considered when drawing the
* chart otherwise false.
@@ -3638,10 +3371,8 @@ public boolean isIncludeTime() {
return includeTime;
}
- /*
- * (non-Javadoc)
- *
- * @see com.invient.vaadin.chart.InvientChart.Series#getPoints()
+ /**
+ * {@inheritDoc}
*/
public LinkedHashSet getPoints() {
return super.getPoints();
@@ -3651,16 +3382,14 @@ public LinkedHashSet getPoints() {
* Sets points into this series. This method removes all of its points
* and then add points specified in the method argument. If the argument
* is null then no actions are taken.
- *
- * @param points
- * the collection of points to set into this series.
+ *
+ * @param points the collection of points to set into this series.
* @return Returns a collection of points which are added in this
* series. If a point has same (x, y) value as any other point
* in the input argument points then it will not be added in
* this series.
*/
- public LinkedHashSet setSeriesPoints(
- LinkedHashSet points) {
+ public LinkedHashSet setSeriesPoints(LinkedHashSet points) {
return super.setPoints(points);
}
@@ -3679,17 +3408,18 @@ protected void updatePointXValuesIfNotPresent() {
}
Date prevDate = new Date((long) pointStart);
int count = 0;
- for (DateTimePoint point : getPoints()) {
+ for (Point point : getPoints()) {
+ DateTimePoint dateTimePoint = (DateTimePoint)point;
if ((point.getX() == null || (point.getX() != null && point
.isAutosetX()))) {
point.setAutosetX(true);
if (count == 0) {
- point.setX(prevDate);
+ dateTimePoint.setX(prevDate);
count++;
} else {
- point.setX(getUpdatedDate(prevDate,
+ dateTimePoint.setX(getUpdatedDate(prevDate,
(long) pointInterval));
- prevDate = point.getX();
+ prevDate = dateTimePoint.getX();
}
}
}
@@ -3724,14 +3454,19 @@ public String toString() {
}
- // *******************************************************************//
- // *************** Highcharts Configuration options ******************//
- // *******************************************************************//
public static enum SeriesType {
- COMMONSERIES("series"), LINE("line"), SPLINE("spline"), SCATTER(
- "scatter"), AREA("area"), AREASPLINE("areaspline"), BAR("bar"), COLUMN(
- "column"), PIE("pie");
+
+ COMMONSERIES("series"),
+ LINE("line"),
+ SPLINE("spline"),
+ SCATTER("scatter"),
+ AREA("area"),
+ AREASPLINE("areaspline"),
+ BAR("bar"),
+ COLUMN("column"),
+ PIE("pie");
+
private String type;
private SeriesType(String type) {
@@ -3741,9 +3476,11 @@ private SeriesType(String type) {
public String getName() {
return this.type;
}
+
}
static class SeriesCUR implements Serializable {
+
private SeriesCURType type;
private String name;
private boolean reloadPoints = false;
@@ -3774,7 +3511,7 @@ public SeriesCUR(SeriesCURType type, String name, boolean reloadPoints) {
/**
* Indicates whether the client/terminal should update series by setting
* all data of a series instead of adding or removing individual points
- *
+ *
* @return Returns true if the data of the series must be reloaded
* otherwise false.
*/
@@ -3908,7 +3645,7 @@ boolean addSeriesCUROperation(SeriesCUR newSeriesCUR) {
if (seriesCUR.getName().equals(newSeriesCUR.getName())) {
if (SeriesCURType.REMOVE.equals(newSeriesCUR.getType())
&& SeriesCURType.ADD
- .equals(seriesCUR.getType())) {
+ .equals(seriesCUR.getType())) {
// Remove addition of a series as there is no reason
// to add
// a series and
@@ -3921,7 +3658,7 @@ boolean addSeriesCUROperation(SeriesCUR newSeriesCUR) {
}
if (SeriesCURType.UPDATE.equals(newSeriesCUR.getType())
&& SeriesCURType.ADD
- .equals(seriesCUR.getType())) {
+ .equals(seriesCUR.getType())) {
// There is no need for update as adding a series
// will
// take care of applying any update to the series
@@ -3931,7 +3668,7 @@ boolean addSeriesCUROperation(SeriesCUR newSeriesCUR) {
}
if (SeriesCURType.REMOVE.equals(newSeriesCUR.getType())
&& SeriesCURType.UPDATE.equals(seriesCUR
- .getType())) {
+ .getType())) {
// Remove update of a series as there is no reason
// to update
// a series
@@ -4036,7 +3773,6 @@ void addSeriesPointRemovedOperation(String seriesName, Point point) {
* as it is handled implicitly. This method will send updates to the client.
* This method should be called after adding/removing plotbands and
* plotlines. This inconsistency will be fixed in next revision.
- *
*/
public void refresh() {
super.requestRepaint();
@@ -4047,7 +3783,6 @@ public void refresh() {
* method causes the Webkit to hide other widgets on the screen and only
* this chart widget will be visible. Also it prints this chart widget as it
* is displayed.
- *
*/
public void print() {
isPrint = true;
diff --git a/src/com/invient/vaadin/charts/InvientChartsConfig.java b/invient-charts/src/main/java/com/invient/vaadin/charts/InvientChartsConfig.java
old mode 100755
new mode 100644
similarity index 90%
rename from src/com/invient/vaadin/charts/InvientChartsConfig.java
rename to invient-charts/src/main/java/com/invient/vaadin/charts/InvientChartsConfig.java
index 491b250..bf5a5b3
--- a/src/com/invient/vaadin/charts/InvientChartsConfig.java
+++ b/invient-charts/src/main/java/com/invient/vaadin/charts/InvientChartsConfig.java
@@ -1,5460 +1,5439 @@
-/*
- * Copyright 2011 Invient (www.invient.com)
- *
- * 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 com.invient.vaadin.charts;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-
-import com.invient.vaadin.charts.InvientCharts.SeriesType;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.AxisTitle;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.AxisType;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.Grid;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.MinorGrid;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.MinorTick;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.Tick;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.WeekDay;
-import com.invient.vaadin.charts.InvientChartsConfig.GeneralChartConfig.ZoomType;
-
-/**
- * This class encapsulates a number of configuration options for the
- * InvientChars. These configuration options are {@link Title}, {@link SubTitle}
- * , {@link GeneralChartConfig}, {@link Credit}, {@link Legend}, {@link Tooltip}
- * , {@link ChartLabel}, {@link SeriesConfig}, {@link XAxis} and {@link YAxis}
- *
- * All configuration properties which are of object type are initialized with an
- * object instance.
- *
- * These configuration options are static and generally set once. After a chart
- * ({@link InvientCharts}) created, any changes made to the configuration options
- * will not reflect in the chart. You would have to create a new chart
- * {@link InvientCharts}
- *
- * For some APIs, the description has been taken from
- * http://www.highcharts.com/ref/
- *
- * @author Invient
- */
-@SuppressWarnings("serial")
-public final class InvientChartsConfig implements Serializable {
-
- private Title title = new Title();
- private SubTitle subtitle = new SubTitle();
- private GeneralChartConfig generalChartConfig = new GeneralChartConfig();
- private Credit credit = new Credit();
- private Legend legend = new Legend();
- private Tooltip tooltip = new Tooltip();
- private ChartLabel chartLabel = new ChartLabel();
-
- private LinkedHashMap seriesTypeConfig = new LinkedHashMap();
- private LinkedHashSet xAxes = new LinkedHashSet();
- private LinkedHashSet yAxes = new LinkedHashSet();
-
- private InvientCharts invientCharts;
-
- InvientCharts getInvientCharts() {
- return this.invientCharts;
- }
-
- void setInvientCharts(InvientCharts invientCharts) {
- this.invientCharts = invientCharts;
- }
-
- /**
- *
- * @return The {@link ChartLabel} object representing labels at arbitrary
- * position in the chart.
- */
- public ChartLabel getChartLabel() {
- return chartLabel;
- }
-
- /**
- * Sets the argument {@link ChartLabel} object only if it is non-null
- *
- * @param chartLabel
- */
- public void setChartLabel(ChartLabel chartLabel) {
- if (chartLabel != null) {
- this.chartLabel = chartLabel;
- }
- }
-
- /**
- * The {@link ChartLabel} class represents a set of labels which an be
- * placed at arbitrary position in the chart.
- *
- * @author Invient
- *
- */
- public static class ChartLabel implements Serializable {
-
- private String style;
- private List labels = new ArrayList();
-
- /**
- *
- * @return Returns css style.
- */
- public String getStyle() {
- return style;
- }
-
- /**
- * Sets css style for all labels in this class
- *
- * @param style
- * css style string
- */
- public void setStyle(String style) {
- this.style = style;
- }
-
- /**
- * @return Returns a list of {@link ChartLabelItem} objects
- */
- public List getLabels() {
- return labels;
- }
-
- /**
- * Sets a list of {@link ChartLabelItem} objects
- *
- * @param labels
- */
- public void setLabels(List labels) {
- if (labels != null) {
- this.labels = labels;
- }
- }
-
- /**
- * Appends the specified element at the end of {@link ChartLabelItem}
- * list
- *
- * @param label
- * element to be appended
- */
- public void addLabel(ChartLabelItem label) {
- this.labels.add(label);
- }
-
- /**
- * Removes the specified element from the list of {@link ChartLabelItem}
- *
- * @param label
- */
- public void removeLabel(ChartLabelItem label) {
- this.labels.remove(label);
- }
-
- /**
- * This class represents a label placed at arbitrary location in the
- * chart. The label can have html text and it can be styled using
- * css-style.
- *
- * @author Invient
- *
- */
- public static class ChartLabelItem implements Serializable {
- private String html;
- private String style;
-
- /**
- * Creates a new instance with specified html and style arguments.
- *
- * @param html
- * @param style
- */
- public ChartLabelItem(String html, String style) {
- super();
- this.html = html;
- this.style = style;
- }
-
- /**
- *
- * @return Returns html of this label
- */
- public String getHtml() {
- return html;
- }
-
- /**
- * Sets html for this label
- *
- * @param html
- * It can be plain or html string.
- */
- public void setHtml(String html) {
- this.html = html;
- }
-
- /**
- *
- * @return Returns css-style of this label
- */
- public String getStyle() {
- return style;
- }
-
- /**
- * Sets css style for this label
- *
- * @param style
- */
- public void setStyle(String style) {
- this.style = style;
- }
- }
-
- }
-
- /**
- *
- * @return Returns a collection of x-axis.
- */
- public LinkedHashSet getXAxes() {
- return xAxes;
- }
-
- /**
- * Sets a collection of x-axis for the chart. The collection of x-axis is
- * set only if argument xAxes is non-null.
- *
- * @param xAxes
- */
- public void setXAxes(LinkedHashSet xAxes) {
- if (xAxes != null) {
- this.xAxes = xAxes;
- }
- }
-
- /**
- * Adds specified x-axis to the collection of x-axis
- *
- * @param xAxis
- * @return Returns true if the x-axis is added successfully otherwise false
- */
- public boolean addXAxes(XAxis xAxis) {
- return this.xAxes.add(xAxis);
- }
-
- /**
- * @return Returns a collection of y-axis.
- */
- public LinkedHashSet getYAxes() {
- return yAxes;
- }
-
- /**
- * Sets a collection of y-axis for the chart. The collection of y-axis is
- * set only if argument yAxes is non-null
- *
- * @param yAxes
- */
- public void setYAxes(LinkedHashSet yAxes) {
- if (yAxes != null) {
- this.yAxes = yAxes;
- }
- }
-
- /**
- * Adds specified y-axis to the collection of y-axis
- *
- * @param yAxis
- * @return Returns true if the y-axis is added successfully otherwise false
- */
- public boolean addYAxes(YAxis yAxis) {
- return this.yAxes.add(yAxis);
- }
-
- /**
- * @return Returns {@link Title} object
- */
- public Title getTitle() {
- return title;
- }
-
- /**
- * Sets the argument title only if the argument title is non-null
- *
- * @param title
- */
- public void setTitle(Title title) {
- if (title != null) {
- this.title = title;
- }
- }
-
- /**
- *
- * @return Returns subtitle
- */
- public SubTitle getSubtitle() {
- return subtitle;
- }
-
- /**
- * Sets the argument subtitle only if the argument is non-null
- *
- * @param subtitle
- */
- public void setSubtitle(SubTitle subtitle) {
- if (subtitle != null) {
- this.subtitle = subtitle;
- }
- }
-
- /**
- *
- * @return Returns tooltip object associated with this class
- */
- public Tooltip getTooltip() {
- return tooltip;
- }
-
- /**
- * Sets {@link Tooltip} object only if the argument tooltip is non-null
- *
- * @param tooltip
- */
- public void setTooltip(Tooltip tooltip) {
- if (tooltip != null) {
- this.tooltip = tooltip;
- }
- }
-
- /**
- *
- * @return Returns legend object of the chart
- */
- public Legend getLegend() {
- return legend;
- }
-
- /**
- * Sets {@link Legend} object only if the argument legend is non-null
- *
- * @param legend
- */
- public void setLegend(Legend legend) {
- if (legend != null) {
- this.legend = legend;
- }
- }
-
- /**
- *
- * @return Returns credit object of the chart
- */
- public Credit getCredit() {
- return credit;
- }
-
- /**
- * Sets the {@link Credit} object only if the argument credit is non-null
- *
- * @param credit
- */
- public void setCredit(Credit credit) {
- if (credit != null) {
- this.credit = credit;
- }
- }
-
- /**
- *
- * @return Returns {@link GeneralChartConfig} object
- */
- public GeneralChartConfig getGeneralChartConfig() {
- return generalChartConfig;
- }
-
- /**
- * Sets {@link GeneralChartConfig} object only if the argument is non-null
- *
- * @param generalChartConfig
- */
- public void setGeneralChartConfig(GeneralChartConfig generalChartConfig) {
- if (generalChartConfig != null) {
- this.generalChartConfig = generalChartConfig;
- }
- }
-
- LinkedHashMap getSeriesConfig() {
- return seriesTypeConfig;
- }
-
- /**
- * Sets a set of {@link SeriesConfig} objects only if the argument is
- * non-null
- *
- * @param seriesConfigs
- */
- public void setSeriesConfig(LinkedHashSet seriesConfigs) {
- if (seriesTypeConfig != null) {
- this.seriesTypeConfig.clear();
- for (SeriesConfig config : seriesConfigs) {
- addSeriesConfig(config);
- }
- }
- }
-
- /**
- * Adds the specified argument only if it is non-null.
- *
- * @param seriesConfig
- * @throws IllegalArgumentException
- * if the argument is null
- */
- public void addSeriesConfig(SeriesConfig seriesConfig) {
- if (seriesConfig == null) {
- throw new IllegalArgumentException(
- "Argument SeriesConfig cannot be null.");
- }
- this.seriesTypeConfig.put(getSeriesType(seriesConfig), seriesConfig);
- }
-
- /**
- * @param seriesConfig
- * @return
- */
- private static SeriesType getSeriesType(SeriesConfig seriesConfig) {
- SeriesType seriesType = SeriesType.COMMONSERIES;
- if (LineConfig.class.equals(seriesConfig.getClass())) {
- seriesType = SeriesType.LINE;
- } else if (SplineConfig.class.equals(seriesConfig.getClass())) {
- seriesType = SeriesType.SPLINE;
- } else if (ScatterConfig.class.equals(seriesConfig.getClass())) {
- seriesType = SeriesType.SCATTER;
- } else if (AreaConfig.class.equals(seriesConfig.getClass())) {
- seriesType = SeriesType.AREA;
- } else if (AreaSplineConfig.class.equals(seriesConfig.getClass())) {
- seriesType = SeriesType.AREASPLINE;
- } else if (BarConfig.class.equals(seriesConfig.getClass())) {
- seriesType = SeriesType.BAR;
- } else if (ColumnConfig.class.equals(seriesConfig.getClass())) {
- seriesType = SeriesType.COLUMN;
- } else if (PieConfig.class.equals(seriesConfig.getClass())) {
- seriesType = SeriesType.PIE;
- }
- return seriesType;
- }
-
- /**
- * This class contains configuration properties at a chart level.
- *
- * @author Invient
- *
- */
- public static class GeneralChartConfig implements Serializable {
- private Paint backgroundColor;
- private Paint borderColor;
- private Integer borderRadius;
- private Integer borderWidth;
- private Integer height;
- private Integer width;
- private Boolean ignoreHiddenSeries;
- private Boolean inverted;
- private Margin margin;
- private Spacing spacing;
- private Boolean showAxes;
- private SeriesType type = SeriesType.LINE;
- private ZoomType zoomType = ZoomType.NONE;
- private boolean clientZoom = true;
- private Boolean alignTicks;
- private Boolean animation;
- private String className;
- private Boolean reflow;
- private Boolean shadow;
- private Plot plot;
- private String style;
-
- /**
- * This class represents drawing area of the chart and contains methods
- * specific to it.
- *
- * @author chirag
- *
- */
- public static class Plot implements Serializable {
- private Paint backgroundColor;
- private String backgroundImage;
- private Paint borderColor;
- private Integer borderWidth;
- private Boolean shadow;
-
- public Paint getBackgroundColor() {
- return backgroundColor;
- }
-
- public void setBackgroundColor(Paint backgroundColor) {
- this.backgroundColor = backgroundColor;
- }
-
- public String getBackgroundImage() {
- return backgroundImage;
- }
-
- public void setBackgroundImage(String backgroundImage) {
- this.backgroundImage = backgroundImage;
- }
-
- public Paint getBorderColor() {
- return borderColor;
- }
-
- public void setBorderColor(Paint borderColor) {
- this.borderColor = borderColor;
- }
-
- public Integer getBorderWidth() {
- return borderWidth;
- }
-
- public void setBorderWidth(Integer borderWidth) {
- this.borderWidth = borderWidth;
- }
-
- public Boolean getShadow() {
- return shadow;
- }
-
- public void setShadow(Boolean shadow) {
- this.shadow = shadow;
- }
-
- @Override
- public String toString() {
- return "Plot [backgroundColor=" + backgroundColor
- + ", backgroundImage=" + backgroundImage
- + ", borderColor=" + borderColor + ", borderWidth="
- + borderWidth + ", shadow=" + shadow + "]";
- }
-
- }
-
- /**
- * This class represents space around the chart. The boundary of the
- * chart includes axis, axis labels, legend, chart title and subtitle.
- *
- * @author Invient
- *
- */
- public static class Spacing implements Serializable {
- private Integer left;
- private Integer top;
- private Integer right;
- private Integer bottom;
-
- public Integer getLeft() {
- return left;
- }
-
- public void setLeft(Integer left) {
- this.left = left;
- }
-
- public Integer getTop() {
- return top;
- }
-
- public void setTop(Integer top) {
- this.top = top;
- }
-
- public Integer getRight() {
- return right;
- }
-
- public void setRight(Integer right) {
- this.right = right;
- }
-
- public Integer getBottom() {
- return bottom;
- }
-
- public void setBottom(Integer bottom) {
- this.bottom = bottom;
- }
-
- @Override
- public String toString() {
- return "Spacing [left=" + left + ", top=" + top + ", right="
- + right + ", bottom=" + bottom + "]";
- }
-
- }
-
- /**
- *
- * This class represents margin between the outer edge of the chart and
- * the plot area.
- *
- * @author Invient
- *
- */
- public static class Margin implements Serializable {
- private Integer left;
- private Integer top;
- private Integer right;
- private Integer bottom;
-
- public Margin() {
- }
-
- public Margin(Integer top, Integer right, Integer bottom, Integer left) {
- this.top = top;
- this.right = right;
- this.bottom = bottom;
- this.left = left;
- }
-
- public Integer getLeft() {
- return left;
- }
-
- public void setLeft(Integer left) {
- this.left = left;
- }
-
- public Integer getTop() {
- return top;
- }
-
- public void setTop(Integer top) {
- this.top = top;
- }
-
- public Integer getRight() {
- return right;
- }
-
- public void setRight(Integer right) {
- this.right = right;
- }
-
- public Integer getBottom() {
- return bottom;
- }
-
- public void setBottom(Integer bottom) {
- this.bottom = bottom;
- }
-
- @Override
- public String toString() {
- return "Margin [left=" + left + ", top=" + top + ", right="
- + right + ", bottom=" + bottom + "]";
- }
-
- }
-
- /**
- * @return
- */
- public Boolean getAlignTicks() {
- return alignTicks;
- }
-
- /**
- * When using multiple axis, the ticks of two or more opposite axes will
- * automatically be aligned by adding ticks to the axis or axes with the
- * least ticks. This can be prevented by setting alignTicks to false.
- *
- * @param alignTicks
- */
- public void setAlignTicks(Boolean alignTicks) {
- this.alignTicks = alignTicks;
- }
-
- /**
- * @return
- */
- public Boolean getAnimation() {
- return animation;
- }
-
- /**
- * Set the overall animation for all chart updating.
- *
- * @param animation
- */
- public void setAnimation(Boolean animation) {
- this.animation = animation;
- }
-
- /**
- * @return
- */
- public String getClassName() {
- return className;
- }
-
- /**
- * A CSS class name to apply to the charts container
- *
- * @param className
- */
- public void setClassName(String className) {
- this.className = className;
- }
-
- /**
- *
- * @return Returns plot object representing chart's drawing area
- */
- public Plot getPlot() {
- return plot;
- }
-
- /**
- * Sets plot object
- *
- * @param plot
- */
- public void setPlot(Plot plot) {
- this.plot = plot;
- }
-
- /**
- *
- * @return
- */
- public Boolean getReflow() {
- return reflow;
- }
-
- /**
- * A value of true indicates that the chart will fit the width of the
- * charts container otherwise not.
- *
- * @param reflow
- */
- public void setReflow(Boolean reflow) {
- this.reflow = reflow;
- }
-
- /**
- * @return
- */
- public Boolean getShadow() {
- return shadow;
- }
-
- /**
- * A value of true indicates that the drop shadow will apply to the
- * outer chart area otherwise not.
- *
- * @param shadow
- */
- public void setShadow(Boolean shadow) {
- this.shadow = shadow;
- }
-
- /**
- * @return
- */
- public String getStyle() {
- return style;
- }
-
- /**
- * A CSS string to apply to the charts container
- *
- * @param style
- */
- public void setStyle(String style) {
- this.style = style;
- }
-
- /**
- * @return
- */
- public Paint getBackgroundColor() {
- return backgroundColor;
- }
-
- /**
- * Sets the background color for the outer chart area
- *
- * @param backgroundColor
- */
- public void setBackgroundColor(Paint backgroundColor) {
- this.backgroundColor = backgroundColor;
- }
-
- /**
- * @return
- */
- public Paint getBorderColor() {
- return borderColor;
- }
-
- /**
- * Sets the border color for the outer chart border
- *
- * @param borderColor
- */
- public void setBorderColor(Paint borderColor) {
- this.borderColor = borderColor;
- }
-
- /**
- * @return
- */
- public Integer getBorderRadius() {
- return borderRadius;
- }
-
- /**
- * Sets radius for the outer chart border
- *
- * @param borderRadius
- */
- public void setBorderRadius(Integer borderRadius) {
- this.borderRadius = borderRadius;
- }
-
- /**
- * @return
- */
- public Integer getBorderWidth() {
- return borderWidth;
- }
-
- /**
- * Sets pixel width of the outer chart border
- *
- * @param borderWidth
- */
- public void setBorderWidth(Integer borderWidth) {
- this.borderWidth = borderWidth;
- }
-
- /**
- * @return
- */
- public Integer getHeight() {
- return height;
- }
-
- /**
- * Sets height for the chart
- *
- * @param height
- */
- public void setHeight(Integer height) {
- this.height = height;
- }
-
- /**
- * @return
- */
- public Integer getWidth() {
- return width;
- }
-
- /**
- * Sets width for the chart
- *
- * @param width
- */
- public void setWidth(Integer width) {
- this.width = width;
- }
-
- /**
- *
- * @return
- */
- public Boolean getIgnoreHiddenSeries() {
- return ignoreHiddenSeries;
- }
-
- /**
- * If the argument is true, the axes will scale to the remaining visible
- * series once one series is hidden. If the argument is false, hiding
- * and showing a series will not affect the axes or the other series.
- *
- * @param ignoreHiddenSeries
- */
- public void setIgnoreHiddenSeries(Boolean ignoreHiddenSeries) {
- this.ignoreHiddenSeries = ignoreHiddenSeries;
- }
-
- /**
- * @return
- */
- public Boolean getInverted() {
- return inverted;
- }
-
- /**
- * If the argument is true then the x-axis is reversed. If a bar plot is
- * present, it will be inverted automatically.
- *
- * @param inverted
- */
- public void setInverted(Boolean inverted) {
- this.inverted = inverted;
- }
-
- /**
- *
- * @return
- */
- public Margin getMargin() {
- return margin;
- }
-
- /**
- * @param margin
- */
- public void setMargin(Margin margin) {
- this.margin = margin;
- }
-
- /**
- * @return
- */
- public Boolean getShowAxes() {
- return showAxes;
- }
-
- /**
- * If the argument is true then the axes will be shown initially. This
- * is useful when the chart is empty and axes must be shown.
- *
- * @param showAxes
- */
- public void setShowAxes(Boolean showAxes) {
- this.showAxes = showAxes;
- }
-
- /**
- * @return
- */
- public Spacing getSpacing() {
- return spacing;
- }
-
- /**
- * @param spacing
- */
- public void setSpacing(Spacing spacing) {
- this.spacing = spacing;
- }
-
- /**
- * @return
- */
- public SeriesType getType() {
- return type;
- }
-
- /**
- * Sets series type to one of line, spline, scatter, area, areaspline,
- * pie, bar and column.
- *
- * @param type
- */
- public void setType(SeriesType type) {
- this.type = type;
- }
-
- /**
- * @return
- */
- public ZoomType getZoomType() {
- return zoomType;
- }
-
- /**
- * Sets zoom type. It decides how a chart can be zoomed by dragging the
- * mouse.
- *
- * @param zoomType
- */
- public void setZoomType(ZoomType zoomType) {
- this.zoomType = zoomType;
- }
-
- /**
- * @return
- */
- public boolean isClientZoom() {
- return clientZoom;
- }
-
- /**
- * If the argument is true then the scaling will happen on client. If
- * the argument is false then the chart will not scale. In any case, the
- * server will receive event notification if registered.
- *
- * @param clientZoom
- */
- public void setClientZoom(boolean clientZoom) {
- this.clientZoom = clientZoom;
- }
-
- @Override
- public String toString() {
- return "Chart [backgroundColor=" + backgroundColor
- + ", borderColor=" + borderColor + ", borderRadius="
- + borderRadius + ", borderWidth=" + borderWidth
- + ", height=" + height + ", width=" + width
- + ", ignoreHiddenSeries=" + ignoreHiddenSeries
- + ", inverted=" + inverted + ", margin=" + margin
- + ", spacing=" + spacing + ", showAxes=" + showAxes
- + ", type=" + type + ", zoomType=" + zoomType
- + ", alignTicks=" + alignTicks + ", animation=" + animation
- + ", className=" + className + ", reflow=" + reflow
- + ", shadow=" + shadow + ", plot=" + plot + ", style="
- + style + "]";
- }
-
- /**
- * The value {@link ZoomType.X} represents horizontal zoom. The value
- * {@link ZoomType.Y} represents vertical zoom. The value
- * {@link ZoomType.XY} represents horizontal as well as vertical zoom.
- *
- * @author Invient
- *
- */
- public static enum ZoomType {
- X("x"), Y("y"), XY("xy"), NONE("");
- private String type;
-
- private ZoomType(String type) {
- this.type = type;
- }
-
- public String getName() {
- return this.type;
- }
- }
- }
-
- /**
- * This class contains general configuration options for all series types
- * such as line, area and pie.
- *
- * @author Invient
- *
- */
- public static class SeriesConfig implements Serializable {
- private Boolean allowPointSelect;
- private Boolean animation;
- private Boolean enableMouseTracking;
- private Boolean showInLegend;
- private String cursor;
- // No impact in case of Pie chart
- private Stacking stacking;
- private Boolean showCheckbox;
- // private Boolean selected;
- private Boolean visible; // NA for pie
- private Boolean shadow; // NA for pie and scatter
- private SeriesState hoverState;
- private DataLabel dataLabel;
- private Paint color;
-
- public SeriesConfig() {
- }
-
- /**
- * @return
- */
- public Boolean getAllowPointSelect() {
- return allowPointSelect;
- }
-
- /**
- * If the argument is true then the points of a can be selected
- * otherwise not. Defaults to false, The point on a chart will toggle.
- * Also, whenever a point is selected or deselected, the registered
- * event listeners will be triggered.
- *
- * @param allowPointSelect
- */
- public void setAllowPointSelect(Boolean allowPointSelect) {
- this.allowPointSelect = allowPointSelect;
- }
-
- public Boolean getAnimation() {
- return animation;
- }
-
- /**
- * If the argument is true then animation will be enabled when a series
- * will be displayed otherwise not. Defaults to false.
- *
- * @param animation
- */
- public void setAnimation(Boolean animation) {
- this.animation = animation;
- }
-
- /**
- * @return
- */
- public Boolean getEnableMouseTracking() {
- return enableMouseTracking;
- }
-
- /**
- * If the argument is true then the mouse tracking will be enabled for a
- * series otherwise not. Defaults to true.
- *
- * @param enableMouseTracking
- */
- public void setEnableMouseTracking(Boolean enableMouseTracking) {
- this.enableMouseTracking = enableMouseTracking;
- }
-
- /**
- * @return
- */
- public Boolean getShowInLegend() {
- return showInLegend;
- }
-
- /**
- * If the argument is true then a series will be displayed in the legend
- * otherwise not. Defaults to true.
- *
- * @param showInLegend
- */
- public void setShowInLegend(Boolean showInLegend) {
- this.showInLegend = showInLegend;
- }
-
- /**
- * @return
- */
- public String getCursor() {
- return cursor;
- }
-
- /**
- * Sets the cursor style. E.g. cursor can be set to css cursor style
- * 'pointer', 'hand' or any other. Defaults to null.
- *
- * @param cursor
- */
- public void setCursor(String cursor) {
- this.cursor = cursor;
- }
-
- /**
- * @return
- */
- public Stacking getStacking() {
- return stacking;
- }
-
- /**
- * Specifies whether the values of each series should be stacked on top
- * of each other or not. Defaults to null. If the argument is null then
- * the values of each series are not stacked.
- *
- * @param stacking
- */
- public void setStacking(Stacking stacking) {
- this.stacking = stacking;
- }
-
- /**
- * @return
- */
- public Boolean getShowCheckbox() {
- return showCheckbox;
- }
-
- /**
- * If the argument is true then a checkbox is displayed next to the
- * legend item in the legend area. Defaults to false
- *
- * @param showCheckbox
- */
- public void setShowCheckbox(Boolean showCheckbox) {
- this.showCheckbox = showCheckbox;
- }
-
- // public Boolean getSelected() {
- // return selected;
- // }
- //
- // public void setSelected(Boolean selected) {
- // this.selected = selected;
- // }
-
- /**
- * @return
- */
- public Boolean getVisible() {
- return visible;
- }
-
- // Only in case of Pie chart exception is thrown
- /**
- * If the argument is true then the series is visible otherwise not when
- * a chart is rendered initially. Defaults to true However, this is not
- * applicable for series related to Pie chart.
- *
- * @param visible
- * @throws UnsupportedOperationException
- * If this method is invoked on {@link PieConfig}
- */
- public void setVisible(Boolean visible)
- throws UnsupportedOperationException {
- this.visible = visible;
- }
-
- /**
- * @return
- */
- public Boolean getShadow() {
- return shadow;
- }
-
- // Only in case of Pie and Scatter chart exception is thrown
- /**
- * If the argument is true then a shadow will be shown to the graph line
- * otherwise not. Defaults to true.
- *
- * @param shadow
- * @throws UnsupportedOperationException
- * If this method is invoked on {@link PieConfig}
- */
- public void setShadow(Boolean shadow)
- throws UnsupportedOperationException {
- this.shadow = shadow;
- }
-
- /**
- *
- * @return
- */
- public SeriesState getHoverState() {
- return hoverState;
- }
-
- /**
- * Sets attributes which should be applied to a series when series is
- * hovered.
- *
- * @param state
- */
- public void setHoverState(SeriesState state) {
- this.hoverState = state;
- }
-
- /**
- * @return
- */
- public DataLabel getDataLabel() {
- return dataLabel;
- }
-
- /**
- * Sets how point value should be formatted and displayed for each
- * point.
- *
- * @param dataLabel
- */
- public void setDataLabel(DataLabel dataLabel) {
- this.dataLabel = dataLabel;
- }
-
- /**
- * @return
- */
- public Paint getColor() {
- return color;
- }
-
- /**
- * Sets color for the series.
- *
- * @param color
- */
- public void setColor(Paint color) {
- this.color = color;
- }
-
- }
-
- /**
- * This class contains various attributes to format data labels. The data
- * labels are displayed along with points and axis.
- *
- * @author Invient
- *
- */
- public static class DataLabel implements Serializable {
- private HorzAlign align; // NA for pie
- private Boolean enabled = Boolean.TRUE;
- private String formatterJsFunc;
- private Integer rotation;
- private String style;
- private Integer x;
- private Integer y;
- private Color color;
-
- public DataLabel() {
-
- }
-
- /**
- * If the argument is true then the datalabels will be displayed
- * otherwise not.
- *
- * @param enabled
- */
- public DataLabel(boolean enabled) {
- this.enabled = enabled;
- }
-
- /**
- * @return
- */
- public HorzAlign getAlign() {
- return align;
- }
-
- /**
- * @param align
- */
- public void setAlign(HorzAlign align) {
- this.align = align;
- }
-
- /**
- * @return
- */
- public Boolean getEnabled() {
- return enabled;
- }
-
- /**
- * If the argument is true then the datalabels will be displayed
- * otherwise not.
- *
- * @param enabled
- */
- public void setEnabled(Boolean enabled) {
- this.enabled = enabled;
- }
-
- /**
- * @return
- */
- public String getFormatterJsFunc() {
- return formatterJsFunc;
- }
-
- /**
- * Sets the argument string JavaScript function. This function will be
- * called to format the data label. Refer to highchart documentation for
- * more details on this
- * http://www.highcharts.com/ref/#plotOptions-series-dataLabels
- *
- * @param formatterJsFunc
- */
- public void setFormatterJsFunc(String formatterJsFunc) {
- this.formatterJsFunc = formatterJsFunc;
- }
-
- /**
- * @return
- */
- public Integer getRotation() {
- return rotation;
- }
-
- /**
- * Sets text rotation in degrees
- *
- * @param rotation
- */
- public void setRotation(Integer rotation) {
- this.rotation = rotation;
- }
-
- /**
- * @return
- */
- public String getStyle() {
- return style;
- }
-
- /**
- * Sets css style for the data label
- *
- * @param style
- */
- public void setStyle(String style) {
- this.style = style;
- }
-
- /**
- * @return
- */
- public Integer getX() {
- return x;
- }
-
- /**
- * Sets the x position offset of the label relative to the point.
- * Defaults to 0.
- *
- * @param x
- */
- public void setX(Integer x) {
- this.x = x;
- }
-
- /**
- * @return
- */
- public Integer getY() {
- return y;
- }
-
- /**
- * Sets the y position offset of the label relative to the point.
- * Defaults to -6.
- *
- * @param y
- */
- public void setY(Integer y) {
- this.y = y;
- }
-
- /**
- * @return
- */
- public Color getColor() {
- return color;
- }
-
- /**
- * Sets color for the data labels. e.g. if the color is blue then in
- * case of line series, for each point, the data label will be displayed
- * in blue color.
- *
- * @param color
- */
- public void setColor(Color color) {
- this.color = color;
- }
-
- @Override
- public String toString() {
- return "DataLabel [align=" + align + ", enabled=" + enabled
- + ", formatter=" + formatterJsFunc + ", rotation="
- + rotation + ", style=" + style + ", x=" + x + ", y=" + y
- + "]";
- }
-
- }
-
- /**
- * This class contains configuration attributes of data labels specific to
- * Pie series.
- *
- * @author Invient
- *
- */
- public final static class PieDataLabel extends DataLabel {
- private Integer connectorWidth;
- private Paint connectorColor;
- private Integer connectorPadding;
- private Integer distance;
-
- /**
- *
- */
- public PieDataLabel() {
-
- }
-
- /**
- * If the argument is true then the datalabels will be displayed
- * otherwise not.
- *
- * @param enabled
- */
- public PieDataLabel(boolean enabled) {
- super(enabled);
- }
-
- /**
- * @return
- */
- public Integer getConnectorWidth() {
- return connectorWidth;
- }
-
- /**
- * Sets width (in pixel) of the line connecting the data label to the
- * pie slice. Defaults to 1.
- *
- * @param connectorWidth
- */
- public void setConnectorWidth(Integer connectorWidth) {
- this.connectorWidth = connectorWidth;
- }
-
- /**
- * @return
- */
- public Paint getConnectorColor() {
- return connectorColor;
- }
-
- /**
- * Sets the color of the line connecting the data label to the pie
- * slice.
- *
- * @param connectorColor
- */
- public void setConnectorColor(Paint connectorColor) {
- this.connectorColor = connectorColor;
- }
-
- /**
- *
- * @return
- */
- public Integer getConnectorPadding() {
- return connectorPadding;
- }
-
- /**
- * Sets the distance (in pixel) from the data label to the connector.
- * Defaults to 5.
- *
- * @param connectorPadding
- */
- public void setConnectorPadding(Integer connectorPadding) {
- this.connectorPadding = connectorPadding;
- }
-
- /**
- * @return
- */
- public Integer getDistance() {
- return distance;
- }
-
- /**
- * Sets the distance (in pixel) of the data label from the pie's edge.
- *
- * @param distance
- */
- public void setDistance(Integer distance) {
- this.distance = distance;
- }
-
- @Override
- public String toString() {
- return "PieDataLabel [connectorWidth=" + connectorWidth
- + ", connectorColor=" + connectorColor
- + ", connectorPadding=" + connectorPadding + ", distance="
- + distance + ", getAlign()=" + getAlign()
- + ", getEnabled()=" + getEnabled() + ", getFormatter()="
- + getFormatterJsFunc() + ", getRotation()=" + getRotation()
- + ", getStyle()=" + getStyle() + ", getX()=" + getX()
- + ", getY()=" + getY() + ", toString()=" + super.toString()
- + ", getClass()=" + getClass() + ", hashCode()="
- + hashCode() + "]";
- }
-
- }
-
- /**
- * This class contains configuration properties for axis labels. The axis
- * labels are the one which are displayed for each tick.
- *
- * @author Invient
- *
- */
- public static abstract class AxisDataLabel extends DataLabel {
- private Integer step;
-
- public AxisDataLabel() {
- super();
- }
-
- /**
- * If the argument is true then the data labels will be displayed
- * otherwise not.
- *
- * @param enabled
- */
- public AxisDataLabel(boolean enabled) {
- super(enabled);
- }
-
- /**
- * @return
- */
- public Integer getStep() {
- return step;
- }
-
- /**
- * Sets at what interval the labels on the axis should be displayed.
- * Setting the step to 2 shows every other label. Defaults to null
- *
- * @param step
- */
- public void setStep(Integer step) {
- this.step = step;
- }
- }
-
- /**
- * This class contains configuration properties specifically for x-axis
- * labels.
- *
- * @author Invient
- *
- */
- public static final class XAxisDataLabel extends AxisDataLabel {
- private Integer staggerLines;
-
- /**
- * If the argument is true then the data labels will be displayed
- * otherwise not.
- *
- * @param enabled
- */
- public XAxisDataLabel(boolean enabled) {
- super(enabled);
- }
-
- public XAxisDataLabel() {
- super();
- }
-
- /**
- * @return
- */
- public Integer getStaggerLines() {
- return staggerLines;
- }
-
- /**
- * Sets number of lines to spread the labels over to make room or
- * tighter labels.
- *
- * @param staggerLines
- */
- public void setStaggerLines(Integer staggerLines) {
- this.staggerLines = staggerLines;
- }
- }
-
- /**
- * This class contains configuration properties specifically for x-axis
- * labels.
- *
- * @author Invient
- *
- */
- public static final class YAxisDataLabel extends AxisDataLabel {
- public YAxisDataLabel() {
- super();
- }
-
- /**
- * If the argument is true then the data labels will be displayed
- * otherwise not.
- *
- * @param enabled
- */
- public YAxisDataLabel(boolean enabled) {
- super(enabled);
- }
- }
-
- /**
- * This class contains configuration options for line series such as line
- * and area but not column series.
- *
- * @author Invient
- *
- */
- public abstract static class BaseLineConfig extends SeriesConfig {
- private Double pointStart;
- private Double pointInterval;
- private Boolean stickyTracking;
- private Marker marker;
- private DashStyle dashStyle;
- private Integer lineWidth;
-
- /**
- * @return
- */
- public Double getPointStart() {
- return pointStart;
- }
-
- /**
- * If no x values are given for the points in a series, the argument
- * pointStart defines on what value to start. Defaults to 0. e.g. if a
- * series contains values higher than 2 m $ then sets pointStart to
- * 2,000,000
- *
- * @param pointStart
- */
- public void setPointStart(Double pointStart) {
- this.pointStart = pointStart;
- }
-
- /**
- * @return
- */
- public Double getPointInterval() {
- return pointInterval;
- }
-
- /**
- * If no x values are given for the points in a series, the argument
- * pointInterval defines the interval of the x values. For example, if a
- * series contains one value every day then set pointInterval to 24 *
- * 3600 * 1000
- *
- * @param pointInterval
- */
- public void setPointInterval(Double pointInterval) {
- this.pointInterval = pointInterval;
- }
-
- /**
- * @return
- */
- public Boolean getStickyTracking() {
- return stickyTracking;
- }
-
- /**
- * If the argument is true then the mouseout event on a series is not
- * triggered until mouse moves over another series or comes out of the
- * plot area. If the argument is true then the mouseout event occurs as
- * soon as mouse leaves area near to the point or marker
- *
- * @param stickyTracking
- */
- public void setStickyTracking(Boolean stickyTracking) {
- this.stickyTracking = stickyTracking;
- }
-
- /**
- * @return
- */
- public Marker getMarker() {
- return marker;
- }
-
- /**
- * Sets marker for points of a series
- *
- * @param marker
- */
- public void setMarker(Marker marker) {
- this.marker = marker;
- }
-
- /**
- * @return
- */
- public DashStyle getDashStyle() {
- return dashStyle;
- }
-
- /**
- * Sets dash style to use when drawing a series.
- *
- * @param dashStyle
- */
- public void setDashStyle(DashStyle dashStyle) {
- this.dashStyle = dashStyle;
- }
-
- /**
- * @return
- */
- public Integer getLineWidth() {
- return lineWidth;
- }
-
- /**
- * Sets width of a line
- *
- * @param lineWidth
- */
- public void setLineWidth(Integer lineWidth) {
- this.lineWidth = lineWidth;
- }
- }
-
- public static enum DashStyle {
- SOLID("Solid"), SHORT_DASH("ShortDash"), SHORT_DOT("ShortDot"), SHORT_DASH_DOT(
- "ShortDashDot"), SHORT_DASH_DOT_DOT("ShortDashDotDot"), DOT(
- "Dot"), DASH("Dash"), LONG_DASH("LongDash"), DASH_DOT("DashDot"), LONG_DASH_DOT(
- "LongDashDot"), LONG_DASH_DOT_DOT("LongDashDotDot");
- private String name;
-
- private DashStyle(String name) {
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
- }
-
- /**
- *
- * This class contains configuration options for area series, area and
- * areaspline.
- *
- * @author Invient
- *
- */
- public static class AreaConfig extends BaseLineConfig {
- private Paint fillColor;
- private Paint lineColor;
- private Double fillOpacity;
- private Integer threshold;
-
- /**
- * @return Returns fill color of the area.
- */
- public Paint getFillColor() {
- return fillColor;
- }
-
- /**
- * Sets fill gradient for the area
- *
- * @param fillColor
- */
- public void setFillColor(Paint fillColor) {
- this.fillColor = fillColor;
- }
-
- /**
- * @return Returns color of a line drawing above the area
- */
- public Paint getLineColor() {
- return lineColor;
- }
-
- /**
- * Sets line color for the line of an area.
- *
- * @param lineColor
- */
- public void setLineColor(Paint lineColor) {
- this.lineColor = lineColor;
- }
-
- /**
- * @return Returns opacity (transparency) which will be used when the area is filled with the fill color
- */
- public Double getFillOpacity() {
- return fillOpacity;
- }
-
- /**
- * Sets opacity for the area
- *
- * @param fillOpacity
- */
- public void setFillOpacity(Double fillOpacity) {
- this.fillOpacity = fillOpacity;
- }
-
- /**
- * @return Returns threadshold of the area
- */
- public Integer getThreshold() {
- return threshold;
- }
-
- /**
- * Sets threshold value which servers as the base for the area, for
- * distinguishing between values above and below a threshold. Defaults
- * to 0.
- *
- * @param threshold
- */
- public void setThreshold(Integer threshold) {
- this.threshold = threshold;
- }
-
- }
-
- /**
- * This class contains configuration options for areaspline series
- *
- * @author Invient
- *
- */
- public static class AreaSplineConfig extends AreaConfig {
-
- }
-
- /**
- * This class contains configuration options for line series
- *
- * @author Invient
- *
- */
- public static class LineConfig extends BaseLineConfig {
- private Boolean step;
-
- /**
- * @return Returns true if the line should be drawn using steps otherwise false.
- */
- public Boolean getStep() {
- return step;
- }
-
- /**
- * If the argument is true then line will be drawn using steps otherwise
- * not. Defaults to false.
- *
- * @param step
- */
- public void setStep(Boolean step) {
- this.step = step;
- }
- }
-
- /**
- * This class contains configuration options for scatter series
- *
- * @author Invient
- *
- */
- public static class ScatterConfig extends BaseLineConfig {
-
- /**
- *
- * @param shadow
- * @exception UnsupportedOperationException
- * Scatter series does not support shadow so this method
- * throws an exception if invoked.
- */
- @Override
- public void setShadow(Boolean shadow)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException(
- "Scatter chart does not support shadow.");
- }
-
- /**
- * @return Returns null as scatter series does not have shadow.
- */
- @Override
- public Boolean getShadow() {
- return null;
- }
- }
-
- /**
- * This class contains configuration options for spline series
- *
- * @author Invient
- *
- */
- public static class SplineConfig extends BaseLineConfig {
-
- }
-
- /**
- * This class contains configuration options for pie series.
- *
- * @author Invient
- *
- */
- public static class PieConfig extends SeriesConfig {
- private Integer centerX;
- private Integer centerY;
- private Paint borderColor;
- private Integer borderWidth;
- private Integer innerSize;
- private Integer size;
- private Integer slicedOffset;
-
- /**
- * @return Returns x position (in pixel) of the center of the pie chart relative to
- * the plot area.
- */
- public Integer getCenterX() {
- return centerX;
- }
-
- /**
- * Sets x position (in pixel) of the center of the pie chart relative to
- * the plot area.
- *
- * @param centerX
- */
- public void setCenterX(Integer centerX) {
- this.centerX = centerX;
- }
-
- /**
- * @return Returns y position (in pixel) of the center of the pie chart relative to
- * the plot area.
- */
- public Integer getCenterY() {
- return centerY;
- }
-
- /**
- * Sets y position (in pixel) of the center of the pie chart relative to
- * the plot area.
- *
- * @param centerY
- */
- public void setCenterY(Integer centerY) {
- this.centerY = centerY;
- }
-
- /**
- * @return Returns color of border surrounding each slice.
- */
- public Paint getBorderColor() {
- return borderColor;
- }
-
- /**
- * Sets color of border surrounding each slice.
- *
- * @param borderColor
- */
- public void setBorderColor(Paint borderColor) {
- this.borderColor = borderColor;
- }
-
- /**
- * @return Returns width of the border surrounding each slice.
- */
- public Integer getBorderWidth() {
- return borderWidth;
- }
-
- /**
- * Sets width of border surrounding each slice.
- *
- * @param borderWidth
- */
- public void setBorderWidth(Integer borderWidth) {
- this.borderWidth = borderWidth;
- }
-
- /**
- * @return Returns size of the inner diameter of the pie.
- */
- public Integer getInnerSize() {
- return innerSize;
- }
-
- /**
- * Sets the size of the inner diameter for the pie. Any value greater
- * than 0 renders a donut chart.
- *
- * @param innerSize
- */
- public void setInnerSize(Integer innerSize) {
- this.innerSize = innerSize;
- }
-
- /**
- * @return Returns size of diameter of the pie relative to the plot area.
- */
- public Integer getSize() {
- return size;
- }
-
- /**
- * Sets size of diameter of the pie relative to the plot area.
- *
- * @param size
- */
- public void setSize(Integer size) {
- this.size = size;
- }
-
- /**
- * @return Returns offset in pixel by which a slice should be moved out from the
- * center.
- */
- public Integer getSlicedOffset() {
- return slicedOffset;
- }
-
- /**
- * Sets offset in pixel by which a slice should be moved out from the
- * center.
- *
- * @param slicedOffset
- */
- public void setSlicedOffset(Integer slicedOffset) {
- this.slicedOffset = slicedOffset;
- }
-
- /**
- * @exception UnsupportedOperationException
- * Pie chart does not support visible property so this
- * method throws an exception if invoked.
- */
- @Override
- public void setVisible(Boolean visible)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException(
- "Pie chart does not support visible property.");
- }
-
- /**
- * @exception UnsupportedOperationException
- * Pie chart does not support shadow property so this
- * method throws an exception if invoked.
- */
- @Override
- public void setShadow(Boolean shadow)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException(
- "Pie chart does not support shadow.");
- }
-
- /**
- * @return Returns null as pie does not support toggle (show/hide pie) feature.
- */
- @Override
- public Boolean getVisible() {
- return null;
- }
-
- /**
- * @return Returns null as pie series does not support shadow.
- */
- @Override
- public Boolean getShadow() {
- return null;
- }
-
- /**
- * Sets an object of {@link PieDataLabel} which contains configuration
- * for formatting data labels.
- *
- * @param dataLabel
- */
- public void setDataLabel(PieDataLabel dataLabel) {
- super.setDataLabel(dataLabel);
- }
-
- /**
- *
- */
- public PieDataLabel getDataLabel() {
- return (PieDataLabel) super.getDataLabel();
- }
-
- /**
- * Sets state which should be applied to a slice when a mouse is over
- * the slice
- *
- * @param state
- */
- public void setHoverState(NonLinearSeriesState state) {
- super.setHoverState(state);
- }
-
- public NonLinearSeriesState getHoverState() {
- if (super.getHoverState() instanceof NonLinearSeriesState) {
- return (NonLinearSeriesState) super.getHoverState();
- }
- return null;
- }
-
- }
-
- /**
- * This class contains configuration options for bar and column series.
- *
- * @author Invient
- *
- */
- public abstract static class BaseBarConfig extends SeriesConfig {
- private Paint borderColor;
- private Integer borderRadius;
- private Integer borderWidth;
- private Boolean colorByPoint;
- private Double groupPadding;
- private Double minPointLength;
- private Double pointPadding;
- private Integer pointWidth;
-
- /**
- * @return
- */
- public Paint getBorderColor() {
- return borderColor;
- }
-
- /**
- * Sets the color of the border surronding each column or bar.
- *
- * @param borderColor
- */
- public void setBorderColor(Paint borderColor) {
- this.borderColor = borderColor;
- }
-
- /**
- * @return
- */
- public Integer getBorderRadius() {
- return borderRadius;
- }
-
- /**
- * Sets corner radius of the border surronding each column or bar.
- *
- * @param borderRadius
- */
- public void setBorderRadius(Integer borderRadius) {
- this.borderRadius = borderRadius;
- }
-
- /**
- * @return
- */
- public Integer getBorderWidth() {
- return borderWidth;
- }
-
- /**
- * Sets width of the border surronding each column or bar.
- *
- * @param borderWidth
- */
- public void setBorderWidth(Integer borderWidth) {
- this.borderWidth = borderWidth;
- }
-
- /**
- * @return
- */
- public Boolean getColorByPoint() {
- return colorByPoint;
- }
-
- /**
- * If the argument is true then each point (bar or column in a series
- * will have a different color otherwise all points (bars/columns) of a
- * series will have same color.
- *
- * @param colorByPoint
- */
- public void setColorByPoint(Boolean colorByPoint) {
- this.colorByPoint = colorByPoint;
- }
-
- /**
- *
- * @return
- */
- public Double getGroupPadding() {
- return groupPadding;
- }
-
- /**
- * Sets padding between each value groups, in x axis units. Defaults to
- * 0.2.
- *
- * @param groupPadding
- */
- public void setGroupPadding(Double groupPadding) {
- this.groupPadding = groupPadding;
- }
-
- /**
- * @return
- */
- public Double getMinPointLength() {
- return minPointLength;
- }
-
- /**
- * Sets the minimal height for a column or width for a bar. By default,
- * 0 values are not shown. To visualize a 0 (or close to zero) point,
- * set the minimal point length to a pixel value like 3. In stacked
- * column charts, minPointLength might not be respected for tightly
- * packed values. Defaults to 0. (For detail, refer to
- * http://www.highcharts.com/ref/#plotOptions-bar);
- *
- * @param minPointLength
- */
- public void setMinPointLength(Double minPointLength) {
- this.minPointLength = minPointLength;
- }
-
- /**
- *
- * @return
- */
- public Double getPointPadding() {
- return pointPadding;
- }
-
- /**
- * Sets padding between each column or bar, in x axis units.
- *
- * @param pointPadding
- */
- public void setPointPadding(Double pointPadding) {
- this.pointPadding = pointPadding;
- }
-
- /**
- * @return
- */
- public Integer getPointWidth() {
- return pointWidth;
- }
-
- /**
- * Sets width of each bar or column in pixel.
- *
- * @param pointWidth
- */
- public void setPointWidth(Integer pointWidth) {
- this.pointWidth = pointWidth;
- }
-
- /**
- * Sets state which should be applied to a bar or column when a mouse is
- * over the bar or column
- *
- * @param state
- */
- public void setHoverState(NonLinearSeriesState state) {
- super.setHoverState(state);
- }
-
- /**
- *
- */
- public NonLinearSeriesState getHoverState() {
- if (super.getHoverState() instanceof NonLinearSeriesState) {
- return (NonLinearSeriesState) super.getHoverState();
- }
- return null;
- }
- }
-
- /**
- * This class contains configuration options for column series.
- *
- * @author Invient
- *
- */
- public static class ColumnConfig extends BaseBarConfig {
-
- }
-
- /**
- * This class contains configuration options for bar series.
- *
- * @author Invient
- *
- */
- public static class BarConfig extends BaseBarConfig {
-
- }
-
- /**
- * Defines ways in which series of a chart can be stacked.
- *
- * Stacking.Normal - represents that the values of each series are stacked.
- *
- * Stacking.Percent - represents that the the values of each series are
- * stacked based on percentage of sum of total value, where total value is
- * sum of values of all points on a particular tick of an axis.
- *
- * @author Invient
- *
- */
- public static enum Stacking {
- NORMAL("normal"), PERCENT("percent");
- private String stacking;
-
- private Stacking(String stacking) {
- this.stacking = stacking;
- }
-
- public String getName() {
- return this.stacking;
- }
- }
-
- /**
- * Defines configuration per point in a series. It is possible to assign
- * each point a different color and marker.
- *
- * @author Invient
- *
- */
- public static final class PointConfig implements Serializable {
- private Boolean sliced;
- private Boolean selected;
- private Paint color;
- private Marker marker;
-
- /**
- * Creates an instance of this class with specified marker
- *
- * @param marker
- */
- public PointConfig(Marker marker) {
- this(null, null, null, marker);
- }
-
- /**
- * Creates an instance of this class with specified color
- *
- * @param color
- */
- public PointConfig(Paint color) {
- this(null, null, color, null);
- }
-
- /**
- * Creates an instance of this class with specified argument. The sliced
- * attribute has meaning only for Pie chart/series.
- *
- * @param sliced
- */
- public PointConfig(Boolean sliced) {
- this(sliced, sliced, null, null);
- }
-
- /**
- *
- * @param sliced
- * - If true then the slice of a pie will be at an offset
- * from the center of the pie. Applicable only for Pie
- * chart/series.
- * @param selected
- * - If true then the point, to which this object is
- * associated, will be shown as selected otherwise not.
- * @param color
- * - Specifies individual color for a point, to which this
- * object is associated.
- * @param marker
- * - Specifies marker for a point, to which this object is
- * associated.
- * @see Marker
- * @see Color
- */
- public PointConfig(Boolean sliced, Boolean selected, Paint color,
- Marker marker) {
- super();
- this.sliced = sliced;
- this.selected = selected;
- this.color = color;
- this.marker = marker;
- }
-
- /**
- * @return
- */
- public Boolean getSliced() {
- return sliced;
- }
-
- /**
- * @param sliced
- */
- public void setSliced(Boolean sliced) {
- this.sliced = sliced;
- }
-
- /**
- * @return
- */
- public Boolean getSelected() {
- return selected;
- }
-
- /**
- * @param selected
- */
- public void setSelected(Boolean selected) {
- this.selected = selected;
- }
-
- /**
- * @return
- */
- public Paint getColor() {
- return color;
- }
-
- /**
- * @param color
- */
- public void setColor(Paint color) {
- this.color = color;
- }
-
- /**
- * @return
- */
- public Marker getMarker() {
- return marker;
- }
-
- /**
- * @param marker
- */
- public void setMarker(Marker marker) {
- this.marker = marker;
- }
-
- /**
- * @return Returns string representation of this object.
- */
- @Override
- public String toString() {
- return "PointConfig [sliced=" + sliced + ", selected=" + selected
- + ", color=" + color + ", marker=" + marker + "]";
- }
-
- }
-
- /**
- * A chart has a title and a subtitle. This class defines attributes which
- * are common to both.
- *
- * The text of a title can be plain text or html text containing html
- * elements. It is also possible to apply css to the title. The css must be
- * valid css string e.g. { color: 'red' }
- *
- * @author Invient
- *
- * @see Title
- * @see SubTitle
- * @see HorzAlign
- * @see VertAlign
- */
- public static abstract class TitleBase implements Serializable {
- private HorzAlign align;
- private VertAlign vertAlign;
- private Boolean floating;
- private String text;
- private Integer x;
- private Integer y;
- private String style;
-
- /**
- * @return
- */
- public HorzAlign getAlign() {
- return align;
- }
-
- /**
- * Sets horizontal alignment of the title. Defaults to HorzAlign.CENTER
- *
- * @param align
- */
- public void setAlign(HorzAlign align) {
- this.align = align;
- }
-
- /**
- * @return
- */
- public VertAlign getVertAlign() {
- return vertAlign;
- }
-
- /**
- * Sets horizontal alignment of the title. Defaults to VertAlign.TOP
- *
- * @param vertAlign
- */
- public void setVertAlign(VertAlign vertAlign) {
- this.vertAlign = vertAlign;
- }
-
- /**
- * @return
- */
- public Boolean getFloating() {
- return floating;
- }
-
- /**
- * If the argument is true then the plot area will not move to make
- * space for the chart title. Defaults to false.
- *
- * @param floating
- */
- public void setFloating(Boolean floating) {
- this.floating = floating;
- }
-
- /**
- * @return
- */
- public String getText() {
- return text;
- }
-
- /**
- * Sets text for the chart's title. The text can be plain or html
- * string.
- *
- * @param text
- */
- public void setText(String text) {
- this.text = text;
- }
-
- /**
- * @return
- */
- public Integer getX() {
- return x;
- }
-
- /**
- * Sets x position (in pixel) of the title relative to the alignment
- * within Spacing.left and Spacing.right. Defaults to 0
- *
- * @param x
- */
- public void setX(Integer x) {
- this.x = x;
- }
-
- /**
- * @return
- */
- public Integer getY() {
- return y;
- }
-
- /**
- * Sets y position (in pixel) of the title relative to the alignment
- * within Spacing.top and Spacing.bottom. Defaults to 0
- *
- * @param y
- */
- public void setY(Integer y) {
- this.y = y;
- }
-
- /**
- * @return
- */
- public String getStyle() {
- return style;
- }
-
- /**
- * Sets css for the title. The css must be a valid css object. e.g. css
- * string "{ color:'red' }" is valid but "{ color: 'red'" is invalid.
- *
- * @param style
- */
- public void setStyle(String style) {
- this.style = style;
- }
- }
-
- /**
- * Defines attributes of chart title.
- *
- * @author Invient
- *
- */
- public static final class Title extends TitleBase {
- private Integer margin;
-
- /**
- * @return
- */
- public Integer getMargin() {
- return margin;
- }
-
- /**
- * Sets margin (in pixel) between the chart title and subtitle, if any.
- * If chart subtitle doesn't exist then it indicates the margin between
- * subtitle and plotarea. Defaults to 15
- *
- * @param margin
- */
- public void setMargin(Integer margin) {
- this.margin = margin;
- }
- }
-
- /**
- * Defines attributes of chart subtitle.
- *
- * @author Invient
- *
- */
- public static final class SubTitle extends TitleBase {
-
- }
-
- public static enum HorzAlign {
- LEFT("left"), CENTER("center"), RIGHT("right");
- private String align;
-
- private HorzAlign(String align) {
- this.align = align;
- }
-
- public String getName() {
- return this.align;
- }
- }
-
- public static enum VertAlign {
- TOP("top"), MIDDLE("middle"), BOTTOM("bottom");
- private String align;
-
- private VertAlign(String align) {
- this.align = align;
- }
-
- public String getName() {
- return this.align;
- }
- }
-
- /**
- * Defines state for a series and point. A series can be in hover state. A
- * point can be in hover and select state. In each state, a series and a
- * point can have different visual clues. This is achived by setting some
- * attributes of a seires and point.
- *
- * @author Invient
- *
- * @see SeriesState
- */
- public static interface State extends Serializable {
- public Boolean getEnabled();
- }
-
- /**
- * Defines a set of attributes which will be applied to a series upon hover.
- * The attributes linWidth is not applicable for Pie, Scatter, Bar and
- * Column series.
- *
- * @author Invient
- *
- */
- public static class SeriesState implements State {
- private Boolean enabled;
- private Integer lineWidth;
-
- public Boolean getEnabled() {
- return enabled;
- }
-
- /**
- * If the argument is true then the other properties of this class have
- * impact on visual rendering of the series when a series is hovered or
- * when a mouse is over the legend. Enabling this has a performance
- * penalty.
- *
- * Defaults to false.
- *
- * @param enabled
- */
- public void setEnabled(Boolean enabled) {
- this.enabled = enabled;
- }
-
- /**
- * @return
- */
- public Integer getLineWidth() {
- return lineWidth;
- }
-
- /**
- * Sets width of a line in pixel. Defaults to 2.
- *
- * @param lineWidth
- */
- public void setLineWidth(Integer lineWidth) {
- this.lineWidth = lineWidth;
- }
- }
-
- /**
- * Defines a set of attributes which are meaningful for bar and colum
- * series.
- *
- * @author Invient
- *
- */
- public static class NonLinearSeriesState extends SeriesState {
- private Double brightness;
-
- /**
- * @return
- */
- public Double getBrightness() {
- return brightness;
- }
-
- /**
- * Sets intensity of brightness for a point. This applies only to bar
- * and column series/chart
- *
- * Defaults to 0.1
- *
- * @param brightness
- */
- public void setBrightness(Double brightness) {
- this.brightness = brightness;
- }
- }
-
- /**
- * Defines a collection of attributes which makes a marker. Markers are
- * generally used to annotate a graph points.
- *
- * @author Invient
- *
- */
- private static class MarkerAttribute implements Serializable {
- private Boolean enabled;
- private Paint fillColor;
- private Paint lineColor;
- private Integer lineWidth;
- private Integer radius;
-
- public Boolean getEnabled() {
- return enabled;
- }
-
- public void setEnabled(Boolean enabled) {
- this.enabled = enabled;
- }
-
- public Paint getFillColor() {
- return fillColor;
- }
-
- public void setFillColor(Paint fillColor) {
- this.fillColor = fillColor;
- }
-
- public Paint getLineColor() {
- return lineColor;
- }
-
- public void setLineColor(Paint lineColor) {
- this.lineColor = lineColor;
- }
-
- public Integer getLineWidth() {
- return lineWidth;
- }
-
- public void setLineWidth(Integer lineWidth) {
- this.lineWidth = lineWidth;
- }
-
- public Integer getRadius() {
- return radius;
- }
-
- public void setRadius(Integer radius) {
- this.radius = radius;
- }
-
- @Override
- public String toString() {
- return "MarkerStateAttribute [enabled=" + enabled + ", fillColor="
- + fillColor + ", lineColor=" + lineColor + ", lineWidth="
- + lineWidth + ", radius=" + radius + "]";
- }
-
- }
-
- /**
- * Defines a set of attributes which gets applied to a point when a point is
- * selected or hovered. By default, markers are enabled so when a mouse is
- * over a point marker gets applied. To turn off marker, set flag enabled to
- * false.
- *
- * A point marker is useful only if the marker is not an image.
- *
- * @author Invient
- *
- * @see ImageMarker
- * @see SymbolMarker
- *
- */
- public static final class MarkerState implements State {
- private MarkerAttribute markerAttribute = new MarkerAttribute();
-
- /**
- * Creates this marker with enabled = true
- */
- public MarkerState() {
- markerAttribute.setEnabled(true);
- }
-
- /**
- * Creates this marker with specified argument. If enabled = false then
- * the marker will not be applied to a point on hover or select state.
- */
- public MarkerState(boolean enabled) {
- markerAttribute.setEnabled(enabled);
- }
-
- /**
- *
- */
- public Boolean getEnabled() {
- return markerAttribute.getEnabled();
- }
-
- /**
- * If enabled = false then the marker will not be applied to a point on
- * hover or select state. Defaults to true
- *
- * @param enabled
- */
- public void setEnabled(Boolean enabled) {
- this.markerAttribute.setEnabled(enabled);
- }
-
- /**
- * @return
- */
- public Paint getFillColor() {
- return markerAttribute.getFillColor();
- }
-
- /**
- * Sets fill color for the marker. When not specified it takes color of
- * a series or point.
- *
- * @param fillColor
- */
- public void setFillColor(Paint fillColor) {
- this.markerAttribute.setFillColor(fillColor);
- }
-
- /**
- * @return
- */
- public Paint getLineColor() {
- return markerAttribute.getLineColor();
- }
-
- /**
- * Sets color of the point marker's outline. When not specified it takes
- * color of a series or point.
- *
- * @param lineColor
- */
- public void setLineColor(Paint lineColor) {
- this.markerAttribute.setLineColor(lineColor);
- }
-
- /**
- * @return
- */
- public Integer getLineWidth() {
- return markerAttribute.getLineWidth();
- }
-
- /**
- * Sets width of the point marker's outline. Defaults to 0.
- *
- * @param lineWidth
- */
- public void setLineWidth(Integer lineWidth) {
- this.markerAttribute.setLineWidth(lineWidth);
- }
-
- /**
- * @return
- */
- public Integer getRadius() {
- return markerAttribute.getRadius();
- }
-
- /**
- * Sets radius of the point marker. Defaults to 0.
- *
- * @param radius
- */
- public void setRadius(Integer radius) {
- this.markerAttribute.setRadius(radius);
- }
-
- @Override
- public String toString() {
- return "MarkerState [enabled=" + getEnabled() + ", fillColor="
- + getFillColor() + ", lineColor=" + getLineColor()
- + ", lineWidth=" + getLineWidth() + ", radius="
- + getRadius() + "]";
- }
-
- }
-
- /**
- * Defines a marker for a point. Markers are applied to a point of chart's
- * series. The marker can be applied at the time of drawing the chart or
- * when a point is selcted or hovered.
- *
- * There are two types of marker.
- *
- *
- * {@link SymbolMarker}
- *
- * {@link ImageMarker}
- *
- *
- * @author Invient
- *
- * @see SymbolMarker
- * @see ImageMarker
- */
- public static interface Marker extends Serializable {
- public Boolean getEnabled();
-
- public void setEnabled(Boolean enabled);
- }
-
- /**
- * Defines attributes for a marker.
- *
- * @author Invient
- *
- * @see SymbolMarker
- * @see ImageMarker
- */
- public static abstract class AbstractMarker implements Marker {
- private MarkerAttribute markerAttribute = new MarkerAttribute();
-
- public AbstractMarker() {
- }
-
- public AbstractMarker(boolean enabled) {
- this.markerAttribute.setEnabled(enabled);
- }
-
- protected Paint getLineColor() {
- return markerAttribute.getLineColor();
- }
-
- protected void setLineColor(Paint lineColor) {
- this.markerAttribute.setLineColor(lineColor);
- }
-
- protected Paint getFillColor() {
- return markerAttribute.getFillColor();
- }
-
- protected void setFillColor(Paint fillColor) {
- this.markerAttribute.setFillColor(fillColor);
- }
-
- protected Integer getLineWidth() {
- return markerAttribute.getLineWidth();
- }
-
- protected void setLineWidth(Integer lineWidth) {
- this.markerAttribute.setLineWidth(lineWidth);
- }
-
- protected Integer getRadius() {
- return markerAttribute.getRadius();
- }
-
- protected void setRadius(Integer radius) {
- this.markerAttribute.setRadius(radius);
- }
-
- public Boolean getEnabled() {
- return markerAttribute.getEnabled();
- }
-
- public void setEnabled(Boolean enabled) {
- this.markerAttribute.setEnabled(enabled);
- }
-
- }
-
- /**
- * This marker can take url of an image which will be used as a marker for a
- * point or all points of a series.
- *
- * The url of an image must be with respect to root of the web application.
- * e.g. If an image named temperature.png is under directory
- * /img/climate then the url must be
- * /img/climate/temperature.png
- *
- * @author Invient
- *
- */
- public static class ImageMarker extends AbstractMarker {
- private String imageURL;
-
- /**
- * Creates this marker with specified arguments.
- *
- * @param imageURL
- * - URL of an image
- * @param enabled
- * - If false then this marker will not be applied to a
- * point. What this means is that the data points of a line
- * chart will not stand out.
- */
- public ImageMarker(String imageURL, boolean enabled) {
- super(enabled);
- this.imageURL = imageURL;
- }
-
- /**
- * Creates this marker with specified arguments.
- *
- * @param imageURL
- * - URL of an image
- */
- public ImageMarker(String imageURL) {
- super(true);
- this.imageURL = imageURL;
- }
-
- /**
- * @return
- */
- public String getImageURL() {
- return imageURL;
- }
-
- /**
- * @param imageURL
- */
- public void setImageURL(String imageURL) {
- this.imageURL = imageURL;
- }
-
- @Override
- public String toString() {
- return "ImageMarker [imageURL=" + imageURL + ", enabled"
- + getEnabled() + "]";
- }
- }
-
- /**
- * This marker has predefined shape which cannot be changed. However, marker
- * attributes can be set.
- *
- * @author Invient
- *
- */
- public static class SymbolMarker extends AbstractMarker {
- private Symbol symbol;
- private MarkerState hoverState;
- private MarkerState selectState;
-
- /**
- * Creates this marker with enabled = true
- */
- public SymbolMarker() {
- super(true);
- }
-
- /**
- * Creates this marker with specified arguments.
- *
- * @param enabled
- * If false then this marker will not be applied to a point.
- * What this means is that the data points of a line chart
- * will not stand out.
- */
- public SymbolMarker(boolean enabled) {
- super(enabled);
- }
-
- /**
- * Creates this marker with specified arguments.
- *
- * @param lineColor
- * - Color of the point marker's outline
- */
- public SymbolMarker(Paint lineColor) {
- super(true);
- super.setLineColor(lineColor);
- }
-
- /**
- * Creates this marker with specified arguments.
- *
- * @param radius
- * Radius of the point marker.
- */
- public SymbolMarker(Integer radius) {
- super(true);
- this.setRadius(radius);
- }
-
- /**
- * Creates this marker with specified arguments.
- *
- * @param symbol
- * It must be one of the predefine symbol such as
- * Symbol.CIRCLE or Symbol.DIAMOND
- */
- public SymbolMarker(Symbol symbol) {
- super(true);
- this.symbol = symbol;
- }
-
- /**
- * Creates this marker with specified arguments.
- *
- * @param lineColor
- * Color of the point marker's outline
- * @param radius
- * Radius of the point marker.
- */
- public SymbolMarker(Paint lineColor, Integer radius) {
- super(true);
- super.setLineColor(lineColor);
- super.setRadius(radius);
- }
-
- /**
- * Creates this marker with specified arguments.
- *
- * @param lineColor
- * - Color of the point marker's outline
- * @param radius
- * Radius of the point marker.
- * @param symbol
- * It must be one of the predefine symbol such as
- * Symbol.CIRCLE or Symbol.DIAMOND
- */
- public SymbolMarker(Paint lineColor, Integer radius, Symbol symbol) {
- super(true);
- super.setLineColor(lineColor);
- super.setRadius(radius);
- this.symbol = symbol;
- }
-
- /**
- *
- */
- @Override
- public Paint getLineColor() {
- return super.getLineColor();
- }
-
- /**
- * Sets color of the point marker's outline
- *
- * @param lineColor
- */
- @Override
- public void setLineColor(Paint lineColor) {
- super.setLineColor(lineColor);
- }
-
- /**
- *
- */
- @Override
- public Paint getFillColor() {
- return super.getFillColor();
- }
-
- /**
- * Sets color of the point marker
- *
- * @param fillColor
- */
- @Override
- public void setFillColor(Paint fillColor) {
- super.setFillColor(fillColor);
- }
-
- /**
- *
- */
- @Override
- public Integer getLineWidth() {
- return super.getLineWidth();
- }
-
- /**
- * Sets width of the point marker outline
- *
- * @param lineWidth
- */
- @Override
- public void setLineWidth(Integer lineWidth) {
- super.setLineWidth(lineWidth);
- }
-
- /**
- *
- */
- @Override
- public Integer getRadius() {
- return super.getRadius();
- }
-
- /**
- * Sets radius of the point marker
- *
- * @param radius
- */
- @Override
- public void setRadius(Integer radius) {
- super.setRadius(radius);
- }
-
- /**
- *
- * @return
- */
- public Symbol getSymbol() {
- return symbol;
- }
-
- /**
- * Sets symbol for the point marker. It must be one of the predefine
- * symbol such as Symbol.CIRCLE or Symbol.DIAMOND
- *
- * @param symbol
- */
- public void setSymbol(Symbol symbol) {
- this.symbol = symbol;
- }
-
- /**
- *
- * @return
- */
- public MarkerState getHoverState() {
- return hoverState;
- }
-
- /**
- * Sets marker to be applied to a point when it is hovered.
- *
- * @param hoverState
- */
- public void setHoverState(MarkerState hoverState) {
- this.hoverState = hoverState;
- }
-
- /**
- * @return
- */
- public MarkerState getSelectState() {
- return selectState;
- }
-
- /**
- * Sets marker to be applied to a point when it is selected.
- *
- * @param selectState
- */
- public void setSelectState(MarkerState selectState) {
- this.selectState = selectState;
- }
-
- @Override
- public String toString() {
- return "SymbolMarker [symbol=" + symbol + ", hoverState="
- + hoverState + ", selectState=" + selectState
- + ", getLineColor()=" + getLineColor()
- + ", getFillColor()=" + getFillColor()
- + ", getLineWidth()=" + getLineWidth() + ", getRadius()="
- + getRadius() + ", getSymbol()=" + getSymbol()
- + ", getHoverState()=" + getHoverState()
- + ", getSelectState()=" + getSelectState() + "]";
- }
-
- /**
- * Defines predefined marker shapes to be used along with
- * {@link SymbolMarker}
- *
- * @author Invient
- *
- * @see SymbolMarker
- */
- public static enum Symbol {
- CIRCLE("circle"), DIAMOND("diamond"), SQUARE("square"), TRIANGLE(
- "triangle"), TRIANGLE_DOWN("triangle-down");
- private String symbol;
-
- private Symbol(String symbol) {
- this.symbol = symbol;
- }
-
- public String getName() {
- return this.symbol;
- }
- }
-
- }
-
- /**
- * This class defines attributes common to X axis and Y axis. A chart can
- * have one or more axis of each type.
- *
- * @author chirag
- *
- * @see XAxis
- * @see YAxis
- *
- */
- public static abstract class AxisBase implements Axis {
- private String id;
-
- private AxisType type = AxisType.LINEAR;
- private AxisTitle title;
- private AxisDataLabel label;
- private LinkedHashSet plotBands = new LinkedHashSet();
- private LinkedHashSet plotLines = new LinkedHashSet();
-
- private Paint alternateGridColor;
- private Boolean endOnTick;
-
- private Grid grid;
-
- private Paint lineColor;
- private Integer lineWidth;
- private Axis linkedTo;
-
- private Double maxPadding;
- private Integer maxZoom;
- // private Double max;
- // private Double min;
- private Double minPadding;
-
- private Tick tick;
- private MinorGrid minorGrid;
- private MinorTick minorTick;
-
- private Integer offset;
- private Boolean opposite;
- private Boolean reversed;
- private Boolean showFirstLabel;
- private Boolean showLastLabel;
- private WeekDay startOfWeek;
- private Boolean startOnTick;
-
- /**
- * Defines attributes of a minor tick. The minor ticks do not have a
- * label. By default, minor ticks are not shown. To display minor ticks,
- * set interval property.
- *
- * @author Invient
- *
- * @see Tick
- *
- */
- public static class MinorTick implements Serializable {
- private Paint color;
- private Double interval;
- private Integer length;
- private TickPosition position;
- private Integer width;
-
- public Paint getColor() {
- return color;
- }
-
- public void setColor(Paint color) {
- this.color = color;
- }
-
- public Double getInterval() {
- return interval;
- }
-
- /**
- * Sets interval for the minor tick. The interval must be specified
- * in the axis unit. e.g. If an axis has tick interval of 50 units
- * then setting minortick interval to 10 will show 5 minor ticks.
- *
- * @param interval
- */
- public void setInterval(Double interval) {
- this.interval = interval;
- }
-
- public Integer getLength() {
- return length;
- }
-
- /**
- * Sets length of the minorticks in pixel
- *
- * @param length
- */
- public void setLength(Integer length) {
- this.length = length;
- }
-
- /**
- * @return
- */
- public TickPosition getPosition() {
- return position;
- }
-
- /**
- * @param position
- */
- public void setPosition(TickPosition position) {
- this.position = position;
- }
-
- /**
- * @return
- */
- public Integer getWidth() {
- return width;
- }
-
- /**
- * Sets width of the minorticks in pixel
- *
- * @param width
- */
- public void setWidth(Integer width) {
- this.width = width;
- }
-
- @Override
- public String toString() {
- return "MinorTick [color=" + color + ", length=" + length
- + ", position=" + position + ", width=" + width + "]";
- }
-
- }
-
- /**
- *
- * Defines attributes of a tick marks. The interval of the tick marks
- * must be specified in axis unit. For datetime axis, the interval must
- * be in millisecond.
- *
- * The default tick interval is 1.
- *
- * @author Invient
- *
- * @see MinorTick
- * @see TickmarkPlacement
- */
- public static final class Tick extends MinorTick {
- private TickmarkPlacement placement;
- private Integer pixelInterval;
-
- /**
- * @return
- */
- public TickmarkPlacement getPlacement() {
- return placement;
- }
-
- /**
- * Sets placement of the tick marks.
- *
- * @param placement
- */
- public void setPlacement(TickmarkPlacement placement) {
- this.placement = placement;
- }
-
- /**
- * @return
- */
- public Integer getPixelInterval() {
- return pixelInterval;
- }
-
- /**
- * Sets pixel interval of the tick marks
- *
- * @param pixelInterval
- */
- public void setPixelInterval(Integer pixelInterval) {
- this.pixelInterval = pixelInterval;
- }
-
- @Override
- public String toString() {
- return "Tick [placement=" + placement + ", pixelInterval="
- + pixelInterval + ", getColor()=" + getColor()
- + ", getLength()=" + getLength() + ", getPosition()="
- + getPosition() + ", getWidth()=" + getWidth() + "]";
- }
-
- }
-
- /**
- * Defines attributes of minor grid lines of the chart. In order to show
- * minor grid lines, you must specify set MinorTick for the axis also.
- *
- * @author Invient
- * @see MinorTick
- * @see Grid
- */
- public static class MinorGrid implements Serializable {
- private Paint lineColor;
- private DashStyle lineDashStyle;
- private Integer lineWidth;
-
- public Paint getLineColor() {
- return lineColor;
- }
-
- /**
- * Sets color of the minor grid lines
- *
- * @param lineColor
- */
- public void setLineColor(Paint lineColor) {
- this.lineColor = lineColor;
- }
-
- /**
- * @return
- */
- public DashStyle getLineDashStyle() {
- return lineDashStyle;
- }
-
- /**
- * Sets dash or dot style of the minor grid lines. Defaults to
- * DashStyle.SOLID
- *
- * @param lineDashStyle
- *
- * @see DashStyle
- *
- */
- public void setLineDashStyle(DashStyle lineDashStyle) {
- this.lineDashStyle = lineDashStyle;
- }
-
- /**
- * @return
- */
- public Integer getLineWidth() {
- return lineWidth;
- }
-
- /**
- * Sets width (in pixel) of the minor grid lines. Defaults to 1
- *
- * @param lineWidth
- */
- public void setLineWidth(Integer lineWidth) {
- this.lineWidth = lineWidth;
- }
-
- @Override
- public String toString() {
- return "MinorGrid [lineColor=" + lineColor + ", lineDashStyle="
- + lineDashStyle + ", lineWidth=" + lineWidth + "]";
- }
-
- }
-
- /**
- * Defines attributes of grid lines of the chart. By default, the grid
- * lines are shown. To hide them set property lineWidth to 0.
- *
- * @author Invient
- *
- */
- public static final class Grid extends MinorGrid {
-
- }
-
- protected LinkedHashSet getAllPlotBands() {
- return plotBands;
- }
-
- protected void setAllPlotBands(LinkedHashSet plotBands) {
- if (plotBands != null) {
- this.plotBands = plotBands;
- }
- }
-
- protected void addPlotBand(PlotBand plotBand) {
- this.plotBands.add(plotBand);
- }
-
- protected void removePlotBand(PlotBand plotBand) {
- this.plotBands.remove(plotBand);
- }
-
- /**
- * Removes a plotband with given id.
- *
- * @param id
- */
- public void removePlotBand(String id) {
- Iterator plotBandItr = ((LinkedHashSet) this.plotBands)
- .iterator();
- while (plotBandItr.hasNext()) {
- if (plotBandItr.next().getId().equals(id)) {
- plotBandItr.remove();
- break;
- }
- }
- }
-
- /**
- * @return
- */
- protected LinkedHashSet getAllPlotLines() {
- return plotLines;
- }
-
- /**
- * @param plotLines
- */
- protected void setAllPlotLines(LinkedHashSet plotLines) {
- if (plotLines != null) {
- this.plotLines = plotLines;
- }
- }
-
- /**
- * @param plotLine
- */
- protected void addPlotLine(PlotLine plotLine) {
- this.plotLines.add(plotLine);
- }
-
- /**
- * @param plotLine
- */
- protected void removePlotLine(PlotLine plotLine) {
- this.plotLines.remove(plotLine);
- }
-
- /**
- * @param id
- */
- public void removePlotLine(String id) {
- Iterator plotLineItr = ((LinkedHashSet) this.plotLines)
- .iterator();
- while (plotLineItr.hasNext()) {
- if (plotLineItr.next().getId().equals(id)) {
- plotLineItr.remove();
- break;
- }
- }
- }
-
- /**
- *
- */
- public String getId() {
- return id;
- }
-
- /**
- * Sets an id for the axis
- */
- public void setId(String id) {
- this.id = id;
- }
-
- /**
- *
- */
- public Tick getTick() {
- return tick;
- }
-
- /**
- * Sets tick for the axis
- */
- public void setTick(Tick tick) {
- this.tick = tick;
- }
-
- /**
- *
- */
- public Integer getMaxZoom() {
- return maxZoom;
- }
-
- /**
- * Sets maximum amount of zoom for this axis. For datetime axis, the
- * maxZoom must be specified in milliseconds. For example, for a
- * datetime axis the main unit is milliseconds. If maxZoom is set to
- * 3600000, you can't zoom in more than to one hour. (Above example is
- * taken from Highcharts documentation)
- */
- public void setMaxZoom(Integer maxZoom) {
- this.maxZoom = maxZoom;
- }
-
- /**
- *
- */
- public Boolean getReversed() {
- return reversed;
- }
-
- /**
- * If the argument it true then this axis will be reversed. Defaults to
- * false.
- */
- public void setReversed(Boolean reversed) {
- this.reversed = reversed;
- }
-
- /**
- *
- */
- public Boolean getOpposite() {
- return opposite;
- }
-
- /**
- * If the argument is true then another axis on the opposite side of
- * this axis will be displayed. The normal axis is on left side for
- * vertical axes and bottom for horzontal axes.
- */
- public void setOpposite(Boolean opposite) {
- this.opposite = opposite;
- }
-
- public AxisType getType() {
- return type;
- }
-
- /**
- * Sets type of this axis. Used by subclasses
- *
- * @param type
- *
- * @see NumberXAxis
- * @see NumberYAxis
- * @see DateTimeAxis
- *
- */
- protected void setType(AxisType type) {
- this.type = type;
- }
-
- public AxisTitle getTitle() {
- return title;
- }
-
- /**
- * Sets title for the axis
- *
- * @see AxisTitle
- */
- public void setTitle(AxisTitle title) {
- this.title = title;
- }
-
- /**
- *
- * @return
- */
- protected AxisDataLabel getLabel() {
- return label;
- }
-
- /**
- *
- * @param label
- */
- protected void setLabel(AxisDataLabel label) {
- this.label = label;
- }
-
- /**
- *
- */
- public Paint getAlternateGridColor() {
- return alternateGridColor;
- }
-
- /**
- * Sets a color to be used for alternate grids of the chart
- */
- public void setAlternateGridColor(Paint alternateGridColor) {
- this.alternateGridColor = alternateGridColor;
- }
-
- /**
- *
- */
- public Boolean getEndOnTick() {
- return endOnTick;
- }
-
- /**
- * If the argument is true then this axis will end on a tick.
- */
- public void setEndOnTick(Boolean endOnTick) {
- this.endOnTick = endOnTick;
- }
-
- /**
- *
- */
- public Grid getGrid() {
- return grid;
- }
-
- /**
- * Sets grid for this axis
- *
- * @see Grid
- */
- public void setGrid(Grid grid) {
- this.grid = grid;
- }
-
- /**
- *
- */
- public Paint getLineColor() {
- return lineColor;
- }
-
- /**
- * Sets a color for line of this axis. This line indicate this axis
- */
- public void setLineColor(Paint lineColor) {
- this.lineColor = lineColor;
- }
-
- /**
- *
- */
- public Integer getLineWidth() {
- return lineWidth;
- }
-
- /**
- * Sets width of this axis line
- */
- public void setLineWidth(Integer lineWidth) {
- this.lineWidth = lineWidth;
- }
-
- /**
- *
- */
- public Axis getLinkedTo() {
- return linkedTo;
- }
-
- /**
- * Sets another axis which is linked with this axis. The following
- * description is copied from Highcharts API documentation
- * http://www.highcharts.com/ref/#xAxis.
- *
- * When an axis is linked to a master axis, it will take the same
- * extremes as the master, but as assigned by min or max or by
- * setExtremes. It can be used to show additional info, or to ease
- * reading the chart by duplicating the scales. Defaults to null.
- */
- public void setLinkedTo(Axis linkedTo) {
- if (linkedTo != this) {
- this.linkedTo = linkedTo;
- }
- }
-
- /**
- *
- */
- public Double getMaxPadding() {
- return maxPadding;
- }
-
- public void setMaxPadding(Double maxPadding) {
- this.maxPadding = maxPadding;
- }
-
- public Double getMinPadding() {
- return minPadding;
- }
-
- public void setMinPadding(Double minPadding) {
- this.minPadding = minPadding;
- }
-
- public MinorGrid getMinorGrid() {
- return minorGrid;
- }
-
- public void setMinorGrid(MinorGrid minorGrid) {
- this.minorGrid = minorGrid;
- }
-
- public MinorTick getMinorTick() {
- return minorTick;
- }
-
- public void setMinorTick(MinorTick minorTick) {
- this.minorTick = minorTick;
- }
-
- public Integer getOffset() {
- return offset;
- }
-
- /**
- * Sets distance of this axis from the plot area
- */
- public void setOffset(Integer offset) {
- this.offset = offset;
- }
-
- public Boolean getShowFirstLabel() {
- return showFirstLabel;
- }
-
- /**
- * If the argument is true then the label of this axis' first tick will
- * be displayed. Defaults to true.
- */
- public void setShowFirstLabel(Boolean showFirstLabel) {
- this.showFirstLabel = showFirstLabel;
- }
-
- public Boolean getShowLastLabel() {
- return showLastLabel;
- }
-
- /**
- * If the argument is true then the label of this axis' last tick will
- * be displayed. Defaults to false
- */
- public void setShowLastLabel(Boolean showLastLabel) {
- this.showLastLabel = showLastLabel;
- }
-
- public WeekDay getStartOfWeek() {
- return startOfWeek;
- }
-
- /**
- * Sets a day to be considered as start of the week. For datetime axis,
- * this decides where to put tick. e.g. if startOfWeek = THURSDAY then
- * tick will be placed on every thursday.
- */
- public void setStartOfWeek(WeekDay startOfWeek) {
- this.startOfWeek = startOfWeek;
- }
-
- public Boolean getStartOnTick() {
- return startOnTick;
- }
-
- /**
- * If the argument is true then this axis must start on a tick. Defaults
- * to false
- */
- public void setStartOnTick(Boolean startOnTick) {
- this.startOnTick = startOnTick;
- }
-
- public static enum WeekDay {
- SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY;
- }
-
- /**
- * Defines position of the tick marks with respect to the axis
- * categories. It is applicable only for categorized axes.
- *
- * TickmarkPlacement.ON - tick mark is placed in the center of the
- * category
- *
- * TickmarkPlacement.BETWEEN - tick mark is placed between categories
- *
- * @author Invient
- *
- */
- public static enum TickmarkPlacement {
- ON("on"), BETWEEN("between");
- private String name;
-
- private TickmarkPlacement(String name) {
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
- }
-
- /**
- * Defines position of the axis ticks with respect to the axis line
- *
- * @author Invient
- *
- */
- public static enum TickPosition {
- OUTSIDE("outside"), INSIDE("inside");
- private String name;
-
- private TickPosition(String name) {
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
- }
-
- /**
- * Defines axis types.
- *
- * AxisType.LINEAR -
- *
- * AxisType.DATETIME - For datetime axis, the values are given in date
- * except for {@link BaseLineConfig}.pointStart and {@link BaseLineConfig}.pointInterval
- * properties, which are specified in milliseconds.
- *
- * @author Invient
- *
- * @see NumberXAxis
- * @see NumberYAxis
- * @see DateTimeAxis
- */
- public static enum AxisType {
- LINEAR("linear"), DATETIME("datetime");
- private String type;
-
- private AxisType(String type) {
- this.type = type;
- }
-
- public String getName() {
- return this.type;
- }
- }
-
- public static enum AxisTitleAlign {
- LOW("low"), MIDDLE("middle"), HIGH("high");
- private String name;
-
- private AxisTitleAlign(String name) {
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
- }
-
- public static final class AxisTitle implements Serializable {
- private String text;
- private AxisTitleAlign align;
- private String style;
- private Integer rotation;
- private Integer margin;
-
- public AxisTitle(String text) {
- this.text = text;
- }
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- public AxisTitleAlign getAlign() {
- return align;
- }
-
- public void setAlign(AxisTitleAlign align) {
- this.align = align;
- }
-
- public String getStyle() {
- return style;
- }
-
- public void setStyle(String style) {
- this.style = style;
- }
-
- public Integer getRotation() {
- return rotation;
- }
-
- public void setRotation(Integer rotation) {
- this.rotation = rotation;
- }
-
- public Integer getMargin() {
- return margin;
- }
-
- public void setMargin(Integer margin) {
- this.margin = margin;
- }
-
- }
-
- public static final class PlotLabel implements Serializable {
- private HorzAlign align;
- private VertAlign vertAlign;
- private Integer rotation;
- private String style;
- private HorzAlign textAlign;
- private Integer x;
- private Integer y;
- private String text;
-
- public PlotLabel(String text) {
- super();
- this.text = text;
- }
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- public HorzAlign getAlign() {
- return align;
- }
-
- public void setAlign(HorzAlign align) {
- this.align = align;
- }
-
- public VertAlign getVertAlign() {
- return vertAlign;
- }
-
- public void setVertAlign(VertAlign vertAlign) {
- this.vertAlign = vertAlign;
- }
-
- public Integer getRotation() {
- return rotation;
- }
-
- public void setRotation(Integer rotation) {
- this.rotation = rotation;
- }
-
- public String getStyle() {
- return style;
- }
-
- public void setStyle(String style) {
- this.style = style;
- }
-
- public HorzAlign getTextAlign() {
- return textAlign;
- }
-
- public void setTextAlign(HorzAlign textAlign) {
- this.textAlign = textAlign;
- }
-
- public Integer getX() {
- return x;
- }
-
- public void setX(Integer x) {
- this.x = x;
- }
-
- public Integer getY() {
- return y;
- }
-
- public void setY(Integer y) {
- this.y = y;
- }
-
- }
-
- public static abstract class PlotBand implements Serializable {
- private Paint color;
- private Range range;
- private String id;
- private Integer zIndex;
- private PlotLabel label;
-
- public PlotBand(String id) {
- this.id = id;
- }
-
- public Paint getColor() {
- return color;
- }
-
- public void setColor(Paint color) {
- this.color = color;
- }
-
- protected Range getRange() {
- return range;
- }
-
- protected void setRange(Range range) {
- this.range = range;
- }
-
- public String getId() {
- return id;
- }
-
- public Integer getZIndex() {
- return zIndex;
- }
-
- public void setZIndex(Integer zIndex) {
- this.zIndex = zIndex;
- }
-
- public PlotLabel getLabel() {
- return label;
- }
-
- public void setLabel(PlotLabel label) {
- this.label = label;
- }
-
- public static abstract class Range implements Serializable {
-
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- PlotBand other = (PlotBand) obj;
- if (id == null) {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- return true;
- }
-
- }
-
- public static final class NumberPlotBand extends PlotBand {
-
- public NumberPlotBand(String id) {
- super(id);
- }
-
- public NumberRange getRange() {
- return (NumberRange) super.getRange();
- }
-
- public void setRange(NumberRange range) {
- super.setRange((NumberRange) range);
- }
-
- public static final class NumberRange extends Range {
- private Double from;
- private Double to;
-
- public NumberRange(Double from, Double to) {
- super();
- this.from = from;
- this.to = to;
- }
-
- public Double getFrom() {
- return from;
- }
-
- public void setFrom(Double from) {
- this.from = from;
- }
-
- public Double getTo() {
- return to;
- }
-
- public void setTo(Double to) {
- this.to = to;
- }
- }
- }
-
- public static final class DateTimePlotBand extends PlotBand {
-
- public DateTimePlotBand(String id) {
- super(id);
- }
-
- public DateTimeRange getRange() {
- return (DateTimeRange) super.getRange();
- }
-
- public void setRange(DateTimeRange range) {
- super.setRange((DateTimeRange) range);
- }
-
- public static final class DateTimeRange extends Range {
- private Date from;
- private Date to;
-
- public DateTimeRange(Date from, Date to) {
- super();
- this.from = from;
- this.to = to;
- }
-
- public Date getFrom() {
- return from;
- }
-
- public void setFrom(Date from) {
- this.from = from;
- }
-
- public Date getTo() {
- return to;
- }
-
- public void setTo(Date to) {
- this.to = to;
- }
- }
-
- }
-
- public static abstract class PlotLine implements Serializable {
- private Paint color;
- private DashStyle dashStyle;
- private String id;
- private Value value;
- private Integer width = 1;
- private Integer zIndex;
- private PlotLabel label;
-
- public PlotLine(String id) {
- this.id = id;
- }
-
- public Paint getColor() {
- return color;
- }
-
- public void setColor(Paint color) {
- this.color = color;
- }
-
- public DashStyle getDashStyle() {
- return dashStyle;
- }
-
- public void setDashStyle(DashStyle dashStyle) {
- this.dashStyle = dashStyle;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- protected Value getValue() {
- return value;
- }
-
- protected void setValue(Value value) {
- this.value = value;
- }
-
- public Integer getWidth() {
- return width;
- }
-
- public void setWidth(Integer width) {
- this.width = width;
- }
-
- public Integer getZIndex() {
- return zIndex;
- }
-
- public void setZIndex(Integer zIndex) {
- this.zIndex = zIndex;
- }
-
- public PlotLabel getLabel() {
- return label;
- }
-
- public void setLabel(PlotLabel label) {
- this.label = label;
- }
-
- public static abstract class Value implements Serializable {
-
- }
-
- }
-
- public static final class NumberPlotLine extends PlotLine {
-
- public NumberPlotLine(String id) {
- super(id);
- }
-
- public NumberValue getValue() {
- return (NumberValue) super.getValue();
- }
-
- public void setValue(NumberValue value) {
- super.setValue((NumberValue) value);
- }
-
- public static final class NumberValue extends Value {
-
- public NumberValue(Double value) {
- super();
- this.value = value;
- }
-
- private Double value;
-
- public Double getValue() {
- return value;
- }
-
- public void setValue(Double value) {
- this.value = value;
- }
- }
- }
-
- public static final class DateTimePlotLine extends PlotLine {
- public DateTimePlotLine(String id) {
- super(id);
- }
-
- public DateTimeValue getValue() {
- return (DateTimeValue) super.getValue();
- }
-
- public void setValue(DateTimeValue value) {
- super.setValue((DateTimeValue) value);
- }
-
- public static final class DateTimeValue extends Value {
- private Date value;
-
- public DateTimeValue(Date value) {
- super();
- this.value = value;
- }
-
- public Date getValue() {
- return value;
- }
-
- public void setValue(Date value) {
- this.value = value;
- }
- }
- }
- }
-
- public static interface Axis extends Serializable {
- public String getId();
-
- public void setId(String id);
-
- public Tick getTick();
-
- public void setTick(Tick tick);
-
- public Integer getMaxZoom();
-
- public void setMaxZoom(Integer maxZoom);
-
- public Boolean getReversed();
-
- public void setReversed(Boolean reversed);
-
- public Boolean getOpposite();
-
- public void setOpposite(Boolean opposite);
-
- public AxisType getType();
-
- public AxisTitle getTitle();
-
- public void setTitle(AxisTitle title);
-
- public Paint getAlternateGridColor();
-
- public void setAlternateGridColor(Paint alternateGridColor);
-
- public Boolean getEndOnTick();
-
- public void setEndOnTick(Boolean endOnTick);
-
- public Grid getGrid();
-
- public void setGrid(Grid grid);
-
- public Paint getLineColor();
-
- public void setLineColor(Paint lineColor);
-
- public Integer getLineWidth();
-
- public void setLineWidth(Integer lineWidth);
-
- public Axis getLinkedTo();
-
- public void setLinkedTo(Axis linkedTo);
-
- public Double getMaxPadding();
-
- public void setMaxPadding(Double maxPadding);
-
- public Double getMinPadding();
-
- public void setMinPadding(Double minPadding);
-
- public MinorGrid getMinorGrid();
-
- public void setMinorGrid(MinorGrid minorGrid);
-
- public MinorTick getMinorTick();
-
- public void setMinorTick(MinorTick minorTick);
-
- public Integer getOffset();
-
- public void setOffset(Integer offset);
-
- public Boolean getShowFirstLabel();
-
- public void setShowFirstLabel(Boolean showFirstLabel);
-
- public Boolean getShowLastLabel();
-
- public void setShowLastLabel(Boolean showLastLabel);
-
- public WeekDay getStartOfWeek();
-
- public void setStartOfWeek(WeekDay startOfWeek);
-
- public Boolean getStartOnTick();
-
- public void setStartOnTick(Boolean startOnTick);
-
- }
-
- public static interface XAxis extends Axis {
- }
-
- public static interface YAxis extends Axis {
- }
-
- public static abstract class NumberAxis extends AxisBase {
- private Boolean allowDecimals;
- private Double max;
- private Double min;
-
- public NumberAxis() {
- super.setType(AxisType.LINEAR);
- }
-
- public Boolean getAllowDecimals() {
- return allowDecimals;
- }
-
- public void setAllowDecimals(Boolean allowDecimals) {
- this.allowDecimals = allowDecimals;
- }
-
- public void setMax(Double max) {
- this.max = max;
- }
-
- public void setMin(Double min) {
- this.min = min;
- }
-
- public Double getMin() {
- return this.min;
- }
-
- public Double getMax() {
- return this.max;
- }
-
- public LinkedHashSet getPlotBands() {
- return super.getAllPlotBands();
- }
-
- public void setPlotBands(LinkedHashSet plotBands) {
- super.setAllPlotBands(plotBands);
- }
-
- public void addPlotBand(NumberPlotBand plotBand) {
- super.addPlotBand(plotBand);
- }
-
- public void removePlotBand(NumberPlotBand plotBand) {
- super.removePlotBand(plotBand);
- }
-
- public LinkedHashSet getPlotLines() {
- return super.getAllPlotLines();
- }
-
- public void setPlotLines(LinkedHashSet plotLines) {
- super.setAllPlotLines(plotLines);
- }
-
- public void addPlotLine(NumberPlotLine plotLine) {
- super.addPlotLine(plotLine);
- }
-
- public void removePlotLine(NumberPlotLine plotLine) {
- super.removePlotLine(plotLine);
- }
-
- }
-
- public static final class NumberXAxis extends NumberAxis implements XAxis {
-
- public void setLabel(XAxisDataLabel label) {
- super.setLabel(label);
- }
-
- public XAxisDataLabel getLabel() {
- return (XAxisDataLabel) super.getLabel();
- }
- }
-
- public static final class NumberYAxis extends NumberAxis implements YAxis {
- public void setLabel(YAxisDataLabel label) {
- super.setLabel(label);
- }
-
- public YAxisDataLabel getLabel() {
- return (YAxisDataLabel) super.getLabel();
- }
-
- }
-
- public static final class DateTimeAxis extends AxisBase implements XAxis {
- private DateTimeLabelFormat dateTimeLabelFormats;
- private Date max;
- private Date min;
-
- // private Date tickInterval; // FIXME It should be more intuitive to
- // specify tick interval such as
- // Month, Week, day, year similar to
- // private Date minorTickInterval;
-
- public static final class DateTimeLabelFormat {
- private String second = "%H:%M:%S";
- private String minute = "%H:%M";
- private String hour = "%H:%M";
- private String day = "%e. %b";
- private String week = "%e. %b";
- private String month = "%b '%y";
- private String year = "%Y";
-
- public String getSecond() {
- return second;
- }
-
- public void setSecond(String second) {
- this.second = second;
- }
-
- public String getMinute() {
- return minute;
- }
-
- public void setMinute(String minute) {
- this.minute = minute;
- }
-
- public String getHour() {
- return hour;
- }
-
- public void setHour(String hour) {
- this.hour = hour;
- }
-
- public String getDay() {
- return day;
- }
-
- public void setDay(String day) {
- this.day = day;
- }
-
- public String getWeek() {
- return week;
- }
-
- public void setWeek(String week) {
- this.week = week;
- }
-
- public String getMonth() {
- return month;
- }
-
- public void setMonth(String month) {
- this.month = month;
- }
-
- public String getYear() {
- return year;
- }
-
- public void setYear(String year) {
- this.year = year;
- }
-
- @Override
- public String toString() {
- return "DateTimeLabelFormat [second=" + second + ", minute="
- + minute + ", hour=" + hour + ", day=" + day
- + ", week=" + week + ", month=" + month + ", year="
- + year + "]";
- }
-
- }
-
- public DateTimeAxis() {
- super.setType(AxisType.DATETIME);
- }
-
- public DateTimeLabelFormat getDateTimeLabelFormat() {
- return dateTimeLabelFormats;
- }
-
- public void setDateTimeLabelFormat(
- DateTimeLabelFormat dateTimeLabelFormat) {
- this.dateTimeLabelFormats = dateTimeLabelFormat;
- }
-
- public void setMax(Date max) {
- this.max = max;
- }
-
- public void setMin(Date min) {
- this.min = min;
- }
-
- public Date getMin() {
- return this.min;
- }
-
- public Date getMax() {
- return this.max;
- }
-
- public LinkedHashSet getPlotBands() {
- return super.getAllPlotBands();
- }
-
- public void setPlotBands(LinkedHashSet plotBands) {
- super.setAllPlotBands(plotBands);
- }
-
- public void addPlotBand(DateTimePlotBand plotBand) {
- super.addPlotBand(plotBand);
- }
-
- public void removePlotBand(DateTimePlotBand plotBand) {
- super.removePlotBand(plotBand);
- }
-
- public LinkedHashSet getPlotLines() {
- return super.getAllPlotLines();
- }
-
- public void setPlotLines(LinkedHashSet plotLines) {
- super.setAllPlotLines(plotLines);
- }
-
- public void addPlotLine(DateTimePlotLine plotLine) {
- super.addPlotLine(plotLine);
- }
-
- public void removePlotLine(DateTimePlotLine plotLine) {
- super.removePlotLine(plotLine);
- }
-
- }
-
- public static final class CategoryAxis extends AxisBase implements XAxis {
- private List categories = new ArrayList();
-
- public List getCategories() {
- return categories;
- }
-
- public void setCategories(List categories) {
- if (categories != null) {
- this.categories = categories;
- }
- }
-
- public void setLabel(XAxisDataLabel label) {
- super.setLabel(label);
- }
-
- public XAxisDataLabel getLabel() {
- return (XAxisDataLabel) super.getLabel();
- }
-
- public LinkedHashSet getPlotBands() {
- return super.getAllPlotBands();
- }
-
- public void setPlotBands(LinkedHashSet plotBands) {
- super.setAllPlotBands(plotBands);
- }
-
- public void addPlotBand(NumberPlotBand plotBand) {
- super.addPlotBand(plotBand);
- }
-
- public void removePlotBand(NumberPlotBand plotBand) {
- super.removePlotBand(plotBand);
- }
-
- public LinkedHashSet getPlotLines() {
- return super.getAllPlotLines();
- }
-
- public void setPlotLines(LinkedHashSet plotLines) {
- super.setAllPlotLines(plotLines);
- }
-
- public void addPlotLine(NumberPlotLine plotLine) {
- super.addPlotLine(plotLine);
- }
-
- public void removePlotLine(NumberPlotLine plotLine) {
- super.removePlotLine(plotLine);
- }
- }
-
- // Legend
- public static final class Legend implements Serializable {
- private Paint backgroundColor;
- private Paint borderColor;
- private Integer borderRadius;
- private Integer borderWidth;
- private Boolean enabled;
- private Boolean floating;
- private String itemHiddenStyle;
- private String itemHoverStyle;
- private String itemStyle;
- private Integer itemWidth;
- private Layout layout;
- private String labelFormatterJsFunc;
- private Integer margin;
- private Boolean reversed;
- private Boolean shadow;
- private Integer symbolPadding;
- private Integer symbolWidth;
- private Integer width;
- private Position position;
-
- public Legend() {
- }
-
- public Legend(boolean enabled) {
- this.enabled = enabled;
- }
-
- public static enum Layout {
- HORIZONTAL("horizontal"), VERTICAL("vertical");
- private String name;
-
- private Layout(String name) {
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
- }
-
- public Paint getBackgroundColor() {
- return backgroundColor;
- }
-
- public void setBackgroundColor(Paint backgroundColor) {
- this.backgroundColor = backgroundColor;
- }
-
- public Paint getBorderColor() {
- return borderColor;
- }
-
- public void setBorderColor(Paint borderColor) {
- this.borderColor = borderColor;
- }
-
- public Integer getBorderRadius() {
- return borderRadius;
- }
-
- public void setBorderRadius(Integer borderRadius) {
- this.borderRadius = borderRadius;
- }
-
- public Integer getBorderWidth() {
- return borderWidth;
- }
-
- public void setBorderWidth(Integer borderWidth) {
- this.borderWidth = borderWidth;
- }
-
- public Boolean getEnabled() {
- return enabled;
- }
-
- public void setEnabled(Boolean enabled) {
- this.enabled = enabled;
- }
-
- public Boolean getFloating() {
- return floating;
- }
-
- public void setFloating(Boolean floating) {
- this.floating = floating;
- }
-
- public String getItemHiddenStyle() {
- return itemHiddenStyle;
- }
-
- public void setItemHiddenStyle(String itemHiddenStyle) {
- this.itemHiddenStyle = itemHiddenStyle;
- }
-
- public String getItemHoverStyle() {
- return itemHoverStyle;
- }
-
- public void setItemHoverStyle(String itemHoverStyle) {
- this.itemHoverStyle = itemHoverStyle;
- }
-
- public String getItemStyle() {
- return itemStyle;
- }
-
- public void setItemStyle(String itemStyle) {
- this.itemStyle = itemStyle;
- }
-
- public Integer getItemWidth() {
- return itemWidth;
- }
-
- public void setItemWidth(Integer itemWidth) {
- this.itemWidth = itemWidth;
- }
-
- public Layout getLayout() {
- return layout;
- }
-
- public void setLayout(Layout layout) {
- this.layout = layout;
- }
-
- public String getLabelFormatterJsFunc() {
- return labelFormatterJsFunc;
- }
-
- public void setLabelFormatterJsFunc(String labelFormatterJsFunc) {
- this.labelFormatterJsFunc = labelFormatterJsFunc;
- }
-
- public Integer getMargin() {
- return margin;
- }
-
- public void setMargin(Integer margin) {
- this.margin = margin;
- }
-
- public Boolean getReversed() {
- return reversed;
- }
-
- public void setReversed(Boolean reversed) {
- this.reversed = reversed;
- }
-
- public Boolean getShadow() {
- return shadow;
- }
-
- public void setShadow(Boolean shadow) {
- this.shadow = shadow;
- }
-
- public Integer getSymbolPadding() {
- return symbolPadding;
- }
-
- public void setSymbolPadding(Integer symbolPadding) {
- this.symbolPadding = symbolPadding;
- }
-
- public Integer getSymbolWidth() {
- return symbolWidth;
- }
-
- public void setSymbolWidth(Integer symbolWidth) {
- this.symbolWidth = symbolWidth;
- }
-
- public Integer getWidth() {
- return width;
- }
-
- public void setWidth(Integer width) {
- this.width = width;
- }
-
- public Position getPosition() {
- return position;
- }
-
- public void setPosition(Position position) {
- this.position = position;
- }
-
- @Override
- public String toString() {
- return "Legend [backgroundColor=" + backgroundColor
- + ", borderColor=" + borderColor + ", borderRadius="
- + borderRadius + ", borderWidth=" + borderWidth
- + ", enabled=" + enabled + ", floating=" + floating
- + ", itemHiddenStyle=" + itemHiddenStyle
- + ", itemHoverStyle=" + itemHoverStyle + ", itemStyle="
- + itemStyle + ", itemWidth=" + itemWidth + ", layout="
- + layout + ", labelFormatter=" + labelFormatterJsFunc
- + ", margin=" + margin + ", reversed=" + reversed
- + ", shadow=" + shadow + ", symbolPadding=" + symbolPadding
- + ", symbolWidth=" + symbolWidth + ", width=" + width
- + ", position=" + position + "]";
- }
-
- }
-
- // Credits
- public static final class Credit implements Serializable {
- private Boolean enabled;
- private String link;
- private String style;
- private String text;
- private Position position;
-
- public Boolean getEnabled() {
- return enabled;
- }
-
- public void setEnabled(Boolean enabled) {
- this.enabled = enabled;
- }
-
- public String getLink() {
- return link;
- }
-
- public void setLink(String link) {
- this.link = link;
- }
-
- public String getStyle() {
- return style;
- }
-
- public void setStyle(String style) {
- this.style = style;
- }
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- public Position getPosition() {
- return position;
- }
-
- public void setPosition(Position position) {
- this.position = position;
- }
-
- @Override
- public String toString() {
- return "Credit [enabled=" + enabled + ", link=" + link + ", style="
- + style + ", text=" + text + ", position=" + position + "]";
- }
- }
-
- public static final class Position implements Serializable {
- private HorzAlign align;
- private VertAlign vertAlign;
- private Integer x;
- private Integer y;
-
- public HorzAlign getAlign() {
- return align;
- }
-
- public void setAlign(HorzAlign align) {
- this.align = align;
- }
-
- public VertAlign getVertAlign() {
- return vertAlign;
- }
-
- public void setVertAlign(VertAlign vertAlign) {
- this.vertAlign = vertAlign;
- }
-
- public Integer getX() {
- return x;
- }
-
- public void setX(Integer x) {
- this.x = x;
- }
-
- public Integer getY() {
- return y;
- }
-
- public void setY(Integer y) {
- this.y = y;
- }
-
- @Override
- public String toString() {
- return "Position [align=" + align + ", vertAlign=" + vertAlign
- + ", x=" + x + ", y=" + y + "]";
- }
-
- }
-
- // Tooltip
- public static final class Tooltip implements Serializable {
- private Paint backgroundColor;
- private Paint borderColor;
- private Integer borderRadius;
- private Integer borderWidth;
- private Boolean crosshairs; // FIMXE
- private Boolean enabled;
- private String formatterJsFunc;
- private Boolean shadow;
- private Boolean shared;
- private Integer snap; // NA for pie/bar/column
- private String style;
-
- public Paint getBackgroundColor() {
- return backgroundColor;
- }
-
- public void setBackgroundColor(Paint backgroundColor) {
- this.backgroundColor = backgroundColor;
- }
-
- public Paint getBorderColor() {
- return borderColor;
- }
-
- public void setBorderColor(Paint borderColor) {
- this.borderColor = borderColor;
- }
-
- public Integer getBorderRadius() {
- return borderRadius;
- }
-
- public void setBorderRadius(Integer borderRadius) {
- this.borderRadius = borderRadius;
- }
-
- public Integer getBorderWidth() {
- return borderWidth;
- }
-
- public void setBorderWidth(Integer borderWidth) {
- this.borderWidth = borderWidth;
- }
-
- public Boolean getCrosshairs() {
- return crosshairs;
- }
-
- public void setCrosshairs(Boolean crosshairs) {
- this.crosshairs = crosshairs;
- }
-
- public Boolean getEnabled() {
- return enabled;
- }
-
- public void setEnabled(Boolean enabled) {
- this.enabled = enabled;
- }
-
- public String getFormatterJsFunc() {
- return formatterJsFunc;
- }
-
- public void setFormatterJsFunc(String formatterJsFunc) {
- this.formatterJsFunc = formatterJsFunc;
- }
-
- public Boolean getShadow() {
- return shadow;
- }
-
- public void setShadow(Boolean shadow) {
- this.shadow = shadow;
- }
-
- public Boolean getShared() {
- return shared;
- }
-
- public void setShared(Boolean shared) {
- this.shared = shared;
- }
-
- public Integer getSnap() {
- return snap;
- }
-
- public void setSnap(Integer snap) {
- this.snap = snap;
- }
-
- public String getStyle() {
- return style;
- }
-
- public void setStyle(String style) {
- this.style = style;
- }
-
- @Override
- public String toString() {
- return "Tooltip [backgroundColor=" + backgroundColor
- + ", borderColor=" + borderColor + ", borderRadius="
- + borderRadius + ", borderWidth=" + borderWidth
- + ", crosshairs=" + crosshairs + ", enabled=" + enabled
- + ", formatter=" + formatterJsFunc + ", shadow=" + shadow
- + ", shared=" + shared + ", snap=" + snap + ", style="
- + style + "]";
- }
-
- }
-}
+/*
+ * Copyright 2011 Invient (www.invient.com)
+ *
+ * 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 com.invient.vaadin.charts;
+
+import java.io.Serializable;
+import java.util.*;
+
+import com.invient.vaadin.charts.InvientCharts.SeriesType;
+import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.*;
+
+
+/**
+ * This class encapsulates a number of configuration options for the
+ * InvientChars. These configuration options are {@link Title}, {@link SubTitle}
+ * , {@link GeneralChartConfig}, {@link Credit}, {@link Legend}, {@link Tooltip}
+ * , {@link ChartLabel}, {@link SeriesConfig}, {@link XAxis} and {@link YAxis}.
+ *
+ * All configuration properties which are of object type are initialized with an
+ * object instance.
+ *
+ * These configuration options are static and generally set once. After a chart
+ * ({@link InvientCharts}) created, any changes made to the configuration options
+ * will not reflect in the chart. You would have to create a new chart
+ * {@link InvientCharts} instance.
+ *
+ * For some APIs, the description has been taken from "http://www.highcharts.com/ref/".
+ *
+ * @author Invient
+ */
+@SuppressWarnings("serial")
+public final class InvientChartsConfig implements Serializable {
+
+ private Title title = new Title();
+ private SubTitle subtitle = new SubTitle();
+ private GeneralChartConfig generalChartConfig = new GeneralChartConfig();
+ private Credit credit = new Credit();
+ private Legend legend = new Legend();
+ private Tooltip tooltip = new Tooltip();
+ private ChartLabel chartLabel = new ChartLabel();
+ private LinkedHashMap seriesTypeConfig = new LinkedHashMap();
+ private LinkedHashSet xAxes = new LinkedHashSet();
+ private LinkedHashSet yAxes = new LinkedHashSet();
+ private InvientCharts invientCharts;
+
+ InvientCharts getInvientCharts() {
+ return this.invientCharts;
+ }
+
+ void setInvientCharts(InvientCharts invientCharts) {
+ this.invientCharts = invientCharts;
+ }
+
+ /**
+ * @return The {@link ChartLabel} object representing labels at arbitrary
+ * position in the chart.
+ */
+ public ChartLabel getChartLabel() {
+ return chartLabel;
+ }
+
+ /**
+ * Sets the argument {@link ChartLabel} object only if it is non-null.
+ *
+ * @param chartLabel The chart label.
+ */
+ public void setChartLabel(ChartLabel chartLabel) {
+ if (chartLabel != null) {
+ this.chartLabel = chartLabel;
+ }
+ }
+
+ /**
+ * The {@link ChartLabel} class represents a set of labels which an be
+ * placed at arbitrary position in the chart.
+ *
+ * @author Invient
+ */
+ public static class ChartLabel implements Serializable {
+
+ private String style;
+ private List labels = new ArrayList();
+
+ /**
+ * @return Returns css style.
+ */
+ public String getStyle() {
+ return style;
+ }
+
+ /**
+ * Sets css style for all labels in this class
+ *
+ * @param style css style string
+ */
+ public void setStyle(String style) {
+ this.style = style;
+ }
+
+ /**
+ * @return Returns a list of {@link ChartLabelItem} objects
+ */
+ public List getLabels() {
+ return labels;
+ }
+
+ /**
+ * Sets a list of {@link ChartLabelItem} objects
+ *
+ * @param labels
+ */
+ public void setLabels(List labels) {
+ if (labels != null) {
+ this.labels = labels;
+ }
+ }
+
+ /**
+ * Appends the specified element at the end of {@link ChartLabelItem}
+ * list
+ *
+ * @param label element to be appended
+ */
+ public void addLabel(ChartLabelItem label) {
+ this.labels.add(label);
+ }
+
+ /**
+ * Removes the specified element from the list of {@link ChartLabelItem}
+ *
+ * @param label
+ */
+ public void removeLabel(ChartLabelItem label) {
+ this.labels.remove(label);
+ }
+
+ /**
+ * This class represents a label placed at arbitrary location in the
+ * chart. The label can have html text and it can be styled using
+ * css-style.
+ *
+ * @author Invient
+ */
+ public static class ChartLabelItem implements Serializable {
+ private String html;
+ private String style;
+
+ /**
+ * Creates a new instance with specified html and style arguments.
+ *
+ * @param html
+ * @param style
+ */
+ public ChartLabelItem(String html, String style) {
+ super();
+ this.html = html;
+ this.style = style;
+ }
+
+ /**
+ * @return Returns html of this label
+ */
+ public String getHtml() {
+ return html;
+ }
+
+ /**
+ * Sets html for this label
+ *
+ * @param html It can be plain or html string.
+ */
+ public void setHtml(String html) {
+ this.html = html;
+ }
+
+ /**
+ * @return Returns css-style of this label
+ */
+ public String getStyle() {
+ return style;
+ }
+
+ /**
+ * Sets css style for this label
+ *
+ * @param style
+ */
+ public void setStyle(String style) {
+ this.style = style;
+ }
+ }
+
+ }
+
+ /**
+ * @return Returns a collection of x-axis.
+ */
+ public LinkedHashSet getXAxes() {
+ return xAxes;
+ }
+
+ /**
+ * Sets a collection of x-axis for the chart. The collection of x-axis is
+ * set only if argument xAxes is non-null.
+ *
+ * @param xAxes
+ */
+ public void setXAxes(LinkedHashSet xAxes) {
+ if (xAxes != null) {
+ this.xAxes = xAxes;
+ }
+ }
+
+ /**
+ * Adds specified x-axis to the collection of x-axis
+ *
+ * @param xAxis
+ * @return Returns true if the x-axis is added successfully otherwise false
+ */
+ public boolean addXAxes(XAxis xAxis) {
+ return this.xAxes.add(xAxis);
+ }
+
+ /**
+ * @return Returns a collection of y-axis.
+ */
+ public LinkedHashSet getYAxes() {
+ return yAxes;
+ }
+
+ /**
+ * Sets a collection of y-axis for the chart. The collection of y-axis is
+ * set only if argument yAxes is non-null
+ *
+ * @param yAxes
+ */
+ public void setYAxes(LinkedHashSet yAxes) {
+ if (yAxes != null) {
+ this.yAxes = yAxes;
+ }
+ }
+
+ /**
+ * Adds specified y-axis to the collection of y-axis
+ *
+ * @param yAxis
+ * @return Returns true if the y-axis is added successfully otherwise false
+ */
+ public boolean addYAxes(YAxis yAxis) {
+ return this.yAxes.add(yAxis);
+ }
+
+ /**
+ * @return Returns {@link Title} object
+ */
+ public Title getTitle() {
+ return title;
+ }
+
+ /**
+ * Sets the argument title only if the argument title is non-null
+ *
+ * @param title
+ */
+ public void setTitle(Title title) {
+ if (title != null) {
+ this.title = title;
+ }
+ }
+
+ /**
+ * @return Returns subtitle
+ */
+ public SubTitle getSubtitle() {
+ return subtitle;
+ }
+
+ /**
+ * Sets the argument subtitle only if the argument is non-null
+ *
+ * @param subtitle
+ */
+ public void setSubtitle(SubTitle subtitle) {
+ if (subtitle != null) {
+ this.subtitle = subtitle;
+ }
+ }
+
+ /**
+ * @return Returns tooltip object associated with this class
+ */
+ public Tooltip getTooltip() {
+ return tooltip;
+ }
+
+ /**
+ * Sets {@link Tooltip} object only if the argument tooltip is non-null
+ *
+ * @param tooltip
+ */
+ public void setTooltip(Tooltip tooltip) {
+ if (tooltip != null) {
+ this.tooltip = tooltip;
+ }
+ }
+
+ /**
+ * @return Returns legend object of the chart
+ */
+ public Legend getLegend() {
+ return legend;
+ }
+
+ /**
+ * Sets {@link Legend} object only if the argument legend is non-null
+ *
+ * @param legend
+ */
+ public void setLegend(Legend legend) {
+ if (legend != null) {
+ this.legend = legend;
+ }
+ }
+
+ /**
+ * @return Returns credit object of the chart
+ */
+ public Credit getCredit() {
+ return credit;
+ }
+
+ /**
+ * Sets the {@link Credit} object only if the argument credit is non-null
+ *
+ * @param credit
+ */
+ public void setCredit(Credit credit) {
+ if (credit != null) {
+ this.credit = credit;
+ }
+ }
+
+ /**
+ * @return Returns {@link GeneralChartConfig} object
+ */
+ public GeneralChartConfig getGeneralChartConfig() {
+ return generalChartConfig;
+ }
+
+ /**
+ * Sets {@link GeneralChartConfig} object only if the argument is non-null
+ *
+ * @param generalChartConfig
+ */
+ public void setGeneralChartConfig(GeneralChartConfig generalChartConfig) {
+ if (generalChartConfig != null) {
+ this.generalChartConfig = generalChartConfig;
+ }
+ }
+
+ LinkedHashMap getSeriesConfig() {
+ return seriesTypeConfig;
+ }
+
+ /**
+ * Sets a set of {@link SeriesConfig} objects only if the argument is
+ * non-null
+ *
+ * @param seriesConfigs
+ */
+ public void setSeriesConfig(LinkedHashSet seriesConfigs) {
+ if (seriesTypeConfig != null) {
+ this.seriesTypeConfig.clear();
+ for (SeriesConfig config : seriesConfigs) {
+ addSeriesConfig(config);
+ }
+ }
+ }
+
+ /**
+ * Adds the specified argument only if it is non-null.
+ *
+ * @param seriesConfig
+ * @throws IllegalArgumentException if the argument is null
+ */
+ public void addSeriesConfig(SeriesConfig seriesConfig) {
+ if (seriesConfig == null) {
+ throw new IllegalArgumentException(
+ "Argument SeriesConfig cannot be null.");
+ }
+ this.seriesTypeConfig.put(getSeriesType(seriesConfig), seriesConfig);
+ }
+
+ /**
+ * @param seriesConfig
+ * @return
+ */
+ private static SeriesType getSeriesType(SeriesConfig seriesConfig) {
+ SeriesType seriesType = SeriesType.COMMONSERIES;
+ if (LineConfig.class.equals(seriesConfig.getClass())) {
+ seriesType = SeriesType.LINE;
+ } else if (SplineConfig.class.equals(seriesConfig.getClass())) {
+ seriesType = SeriesType.SPLINE;
+ } else if (ScatterConfig.class.equals(seriesConfig.getClass())) {
+ seriesType = SeriesType.SCATTER;
+ } else if (AreaConfig.class.equals(seriesConfig.getClass())) {
+ seriesType = SeriesType.AREA;
+ } else if (AreaSplineConfig.class.equals(seriesConfig.getClass())) {
+ seriesType = SeriesType.AREASPLINE;
+ } else if (BarConfig.class.equals(seriesConfig.getClass())) {
+ seriesType = SeriesType.BAR;
+ } else if (ColumnConfig.class.equals(seriesConfig.getClass())) {
+ seriesType = SeriesType.COLUMN;
+ } else if (PieConfig.class.equals(seriesConfig.getClass())) {
+ seriesType = SeriesType.PIE;
+ }
+ return seriesType;
+ }
+
+ /**
+ * This class contains configuration properties at a chart level.
+ *
+ * @author Invient
+ */
+ public static class GeneralChartConfig implements Serializable {
+ private Paint backgroundColor;
+ private Paint borderColor;
+ private Integer borderRadius;
+ private Integer borderWidth;
+ private Integer height;
+ private Integer width;
+ private Boolean ignoreHiddenSeries;
+ private Boolean inverted;
+ private Margin margin;
+ private Spacing spacing;
+ private Boolean showAxes;
+ private SeriesType type = SeriesType.LINE;
+ private ZoomType zoomType = ZoomType.NONE;
+ private boolean clientZoom = true;
+ private Boolean alignTicks;
+ private Boolean animation;
+ private String className;
+ private Boolean reflow;
+ private Boolean shadow;
+ private Plot plot;
+ private String style;
+
+ /**
+ * This class represents drawing area of the chart and contains methods
+ * specific to it.
+ *
+ * @author chirag
+ */
+ public static class Plot implements Serializable {
+ private Paint backgroundColor;
+ private String backgroundImage;
+ private Paint borderColor;
+ private Integer borderWidth;
+ private Boolean shadow;
+
+ public Paint getBackgroundColor() {
+ return backgroundColor;
+ }
+
+ public void setBackgroundColor(Paint backgroundColor) {
+ this.backgroundColor = backgroundColor;
+ }
+
+ public String getBackgroundImage() {
+ return backgroundImage;
+ }
+
+ public void setBackgroundImage(String backgroundImage) {
+ this.backgroundImage = backgroundImage;
+ }
+
+ public Paint getBorderColor() {
+ return borderColor;
+ }
+
+ public void setBorderColor(Paint borderColor) {
+ this.borderColor = borderColor;
+ }
+
+ public Integer getBorderWidth() {
+ return borderWidth;
+ }
+
+ public void setBorderWidth(Integer borderWidth) {
+ this.borderWidth = borderWidth;
+ }
+
+ public Boolean getShadow() {
+ return shadow;
+ }
+
+ public void setShadow(Boolean shadow) {
+ this.shadow = shadow;
+ }
+
+ @Override
+ public String toString() {
+ return "Plot [backgroundColor=" + backgroundColor
+ + ", backgroundImage=" + backgroundImage
+ + ", borderColor=" + borderColor + ", borderWidth="
+ + borderWidth + ", shadow=" + shadow + "]";
+ }
+
+ }
+
+ /**
+ * This class represents space around the chart. The boundary of the
+ * chart includes axis, axis labels, legend, chart title and subtitle.
+ *
+ * @author Invient
+ */
+ public static class Spacing implements Serializable {
+ private Integer left;
+ private Integer top;
+ private Integer right;
+ private Integer bottom;
+
+ public Integer getLeft() {
+ return left;
+ }
+
+ public void setLeft(Integer left) {
+ this.left = left;
+ }
+
+ public Integer getTop() {
+ return top;
+ }
+
+ public void setTop(Integer top) {
+ this.top = top;
+ }
+
+ public Integer getRight() {
+ return right;
+ }
+
+ public void setRight(Integer right) {
+ this.right = right;
+ }
+
+ public Integer getBottom() {
+ return bottom;
+ }
+
+ public void setBottom(Integer bottom) {
+ this.bottom = bottom;
+ }
+
+ @Override
+ public String toString() {
+ return "Spacing [left=" + left + ", top=" + top + ", right="
+ + right + ", bottom=" + bottom + "]";
+ }
+
+ }
+
+ /**
+ * This class represents margin between the outer edge of the chart and
+ * the plot area.
+ *
+ * @author Invient
+ */
+ public static class Margin implements Serializable {
+ private Integer left;
+ private Integer top;
+ private Integer right;
+ private Integer bottom;
+
+ public Margin() {
+ }
+
+ public Margin(Integer top, Integer right, Integer bottom, Integer left) {
+ this.top = top;
+ this.right = right;
+ this.bottom = bottom;
+ this.left = left;
+ }
+
+ public Integer getLeft() {
+ return left;
+ }
+
+ public void setLeft(Integer left) {
+ this.left = left;
+ }
+
+ public Integer getTop() {
+ return top;
+ }
+
+ public void setTop(Integer top) {
+ this.top = top;
+ }
+
+ public Integer getRight() {
+ return right;
+ }
+
+ public void setRight(Integer right) {
+ this.right = right;
+ }
+
+ public Integer getBottom() {
+ return bottom;
+ }
+
+ public void setBottom(Integer bottom) {
+ this.bottom = bottom;
+ }
+
+ @Override
+ public String toString() {
+ return "Margin [left=" + left + ", top=" + top + ", right="
+ + right + ", bottom=" + bottom + "]";
+ }
+
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getAlignTicks() {
+ return alignTicks;
+ }
+
+ /**
+ * When using multiple axis, the ticks of two or more opposite axes will
+ * automatically be aligned by adding ticks to the axis or axes with the
+ * least ticks. This can be prevented by setting alignTicks to false.
+ *
+ * @param alignTicks
+ */
+ public void setAlignTicks(Boolean alignTicks) {
+ this.alignTicks = alignTicks;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getAnimation() {
+ return animation;
+ }
+
+ /**
+ * Set the overall animation for all chart updating.
+ *
+ * @param animation
+ */
+ public void setAnimation(Boolean animation) {
+ this.animation = animation;
+ }
+
+ /**
+ * @return
+ */
+ public String getClassName() {
+ return className;
+ }
+
+ /**
+ * A CSS class name to apply to the charts container
+ *
+ * @param className
+ */
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ /**
+ * @return Returns plot object representing chart's drawing area
+ */
+ public Plot getPlot() {
+ return plot;
+ }
+
+ /**
+ * Sets plot object
+ *
+ * @param plot
+ */
+ public void setPlot(Plot plot) {
+ this.plot = plot;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getReflow() {
+ return reflow;
+ }
+
+ /**
+ * A value of true indicates that the chart will fit the width of the
+ * charts container otherwise not.
+ *
+ * @param reflow
+ */
+ public void setReflow(Boolean reflow) {
+ this.reflow = reflow;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getShadow() {
+ return shadow;
+ }
+
+ /**
+ * A value of true indicates that the drop shadow will apply to the
+ * outer chart area otherwise not.
+ *
+ * @param shadow
+ */
+ public void setShadow(Boolean shadow) {
+ this.shadow = shadow;
+ }
+
+ /**
+ * @return
+ */
+ public String getStyle() {
+ return style;
+ }
+
+ /**
+ * A CSS string to apply to the charts container
+ *
+ * @param style
+ */
+ public void setStyle(String style) {
+ this.style = style;
+ }
+
+ /**
+ * @return
+ */
+ public Paint getBackgroundColor() {
+ return backgroundColor;
+ }
+
+ /**
+ * Sets the background color for the outer chart area
+ *
+ * @param backgroundColor
+ */
+ public void setBackgroundColor(Paint backgroundColor) {
+ this.backgroundColor = backgroundColor;
+ }
+
+ /**
+ * @return
+ */
+ public Paint getBorderColor() {
+ return borderColor;
+ }
+
+ /**
+ * Sets the border color for the outer chart border
+ *
+ * @param borderColor
+ */
+ public void setBorderColor(Paint borderColor) {
+ this.borderColor = borderColor;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getBorderRadius() {
+ return borderRadius;
+ }
+
+ /**
+ * Sets radius for the outer chart border
+ *
+ * @param borderRadius
+ */
+ public void setBorderRadius(Integer borderRadius) {
+ this.borderRadius = borderRadius;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getBorderWidth() {
+ return borderWidth;
+ }
+
+ /**
+ * Sets pixel width of the outer chart border
+ *
+ * @param borderWidth
+ */
+ public void setBorderWidth(Integer borderWidth) {
+ this.borderWidth = borderWidth;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getHeight() {
+ return height;
+ }
+
+ /**
+ * Sets height for the chart
+ *
+ * @param height
+ */
+ public void setHeight(Integer height) {
+ this.height = height;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getWidth() {
+ return width;
+ }
+
+ /**
+ * Sets width for the chart
+ *
+ * @param width
+ */
+ public void setWidth(Integer width) {
+ this.width = width;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getIgnoreHiddenSeries() {
+ return ignoreHiddenSeries;
+ }
+
+ /**
+ * If the argument is true, the axes will scale to the remaining visible
+ * series once one series is hidden. If the argument is false, hiding
+ * and showing a series will not affect the axes or the other series.
+ *
+ * @param ignoreHiddenSeries
+ */
+ public void setIgnoreHiddenSeries(Boolean ignoreHiddenSeries) {
+ this.ignoreHiddenSeries = ignoreHiddenSeries;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getInverted() {
+ return inverted;
+ }
+
+ /**
+ * If the argument is true then the x-axis is reversed. If a bar plot is
+ * present, it will be inverted automatically.
+ *
+ * @param inverted
+ */
+ public void setInverted(Boolean inverted) {
+ this.inverted = inverted;
+ }
+
+ /**
+ * @return
+ */
+ public Margin getMargin() {
+ return margin;
+ }
+
+ /**
+ * @param margin
+ */
+ public void setMargin(Margin margin) {
+ this.margin = margin;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getShowAxes() {
+ return showAxes;
+ }
+
+ /**
+ * If the argument is true then the axes will be shown initially. This
+ * is useful when the chart is empty and axes must be shown.
+ *
+ * @param showAxes
+ */
+ public void setShowAxes(Boolean showAxes) {
+ this.showAxes = showAxes;
+ }
+
+ /**
+ * @return
+ */
+ public Spacing getSpacing() {
+ return spacing;
+ }
+
+ /**
+ * @param spacing
+ */
+ public void setSpacing(Spacing spacing) {
+ this.spacing = spacing;
+ }
+
+ /**
+ * @return
+ */
+ public SeriesType getType() {
+ return type;
+ }
+
+ /**
+ * Sets series type to one of line, spline, scatter, area, areaspline,
+ * pie, bar and column.
+ *
+ * @param type
+ */
+ public void setType(SeriesType type) {
+ this.type = type;
+ }
+
+ /**
+ * @return
+ */
+ public ZoomType getZoomType() {
+ return zoomType;
+ }
+
+ /**
+ * Sets zoom type. It decides how a chart can be zoomed by dragging the
+ * mouse.
+ *
+ * @param zoomType
+ */
+ public void setZoomType(ZoomType zoomType) {
+ this.zoomType = zoomType;
+ }
+
+ /**
+ * @return
+ */
+ public boolean isClientZoom() {
+ return clientZoom;
+ }
+
+ /**
+ * If the argument is true then the scaling will happen on client. If
+ * the argument is false then the chart will not scale. In any case, the
+ * server will receive event notification if registered.
+ *
+ * @param clientZoom
+ */
+ public void setClientZoom(boolean clientZoom) {
+ this.clientZoom = clientZoom;
+ }
+
+ @Override
+ public String toString() {
+ return "Chart [backgroundColor=" + backgroundColor
+ + ", borderColor=" + borderColor + ", borderRadius="
+ + borderRadius + ", borderWidth=" + borderWidth
+ + ", height=" + height + ", width=" + width
+ + ", ignoreHiddenSeries=" + ignoreHiddenSeries
+ + ", inverted=" + inverted + ", margin=" + margin
+ + ", spacing=" + spacing + ", showAxes=" + showAxes
+ + ", type=" + type + ", zoomType=" + zoomType
+ + ", alignTicks=" + alignTicks + ", animation=" + animation
+ + ", className=" + className + ", reflow=" + reflow
+ + ", shadow=" + shadow + ", plot=" + plot + ", style="
+ + style + "]";
+ }
+
+ /**
+ * The value {@link ZoomType#X} represents horizontal zoom. The value
+ * {@link ZoomType#Y} represents vertical zoom. The value
+ * {@link ZoomType#XY} represents horizontal as well as vertical zoom.
+ *
+ * @author Invient
+ */
+ public static enum ZoomType {
+
+ X("x"), Y("y"), XY("xy"), NONE("");
+
+ private String type;
+
+ private ZoomType(String type) {
+ this.type = type;
+ }
+
+ public String getName() {
+ return this.type;
+ }
+ }
+ }
+
+ /**
+ * This class contains general configuration options for all series types
+ * such as line, area and pie.
+ *
+ * @author Invient
+ */
+ public static class SeriesConfig implements Serializable {
+ private Boolean allowPointSelect;
+ private Boolean animation;
+ private Boolean enableMouseTracking;
+ private Boolean showInLegend;
+ private String cursor;
+ // No impact in case of Pie chart
+ private Stacking stacking;
+ private Boolean showCheckbox;
+ // private Boolean selected;
+ private Boolean visible; // NA for pie
+ private Boolean shadow; // NA for scatter
+ private SeriesState hoverState;
+ private DataLabel dataLabel;
+ private Paint color;
+
+ public SeriesConfig() {
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getAllowPointSelect() {
+ return allowPointSelect;
+ }
+
+ /**
+ * If the argument is true then the points of a can be selected
+ * otherwise not. Defaults to false, The point on a chart will toggle.
+ * Also, whenever a point is selected or deselected, the registered
+ * event listeners will be triggered.
+ *
+ * @param allowPointSelect
+ */
+ public void setAllowPointSelect(Boolean allowPointSelect) {
+ this.allowPointSelect = allowPointSelect;
+ }
+
+ public Boolean getAnimation() {
+ return animation;
+ }
+
+ /**
+ * If the argument is true then animation will be enabled when a series
+ * will be displayed otherwise not. Defaults to false.
+ *
+ * @param animation
+ */
+ public void setAnimation(Boolean animation) {
+ this.animation = animation;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getEnableMouseTracking() {
+ return enableMouseTracking;
+ }
+
+ /**
+ * If the argument is true then the mouse tracking will be enabled for a
+ * series otherwise not. Defaults to true.
+ *
+ * @param enableMouseTracking
+ */
+ public void setEnableMouseTracking(Boolean enableMouseTracking) {
+ this.enableMouseTracking = enableMouseTracking;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getShowInLegend() {
+ return showInLegend;
+ }
+
+ /**
+ * If the argument is true then a series will be displayed in the legend
+ * otherwise not. Defaults to true.
+ *
+ * @param showInLegend
+ */
+ public void setShowInLegend(Boolean showInLegend) {
+ this.showInLegend = showInLegend;
+ }
+
+ /**
+ * @return
+ */
+ public String getCursor() {
+ return cursor;
+ }
+
+ /**
+ * Sets the cursor style. E.g. cursor can be set to css cursor style
+ * 'pointer', 'hand' or any other. Defaults to null.
+ *
+ * @param cursor
+ */
+ public void setCursor(String cursor) {
+ this.cursor = cursor;
+ }
+
+ /**
+ * @return
+ */
+ public Stacking getStacking() {
+ return stacking;
+ }
+
+ /**
+ * Specifies whether the values of each series should be stacked on top
+ * of each other or not. Defaults to null. If the argument is null then
+ * the values of each series are not stacked.
+ *
+ * @param stacking
+ */
+ public void setStacking(Stacking stacking) {
+ this.stacking = stacking;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getShowCheckbox() {
+ return showCheckbox;
+ }
+
+ /**
+ * If the argument is true then a checkbox is displayed next to the
+ * legend item in the legend area. Defaults to false
+ *
+ * @param showCheckbox
+ */
+ public void setShowCheckbox(Boolean showCheckbox) {
+ this.showCheckbox = showCheckbox;
+ }
+
+ // public Boolean getSelected() {
+ // return selected;
+ // }
+ //
+ // public void setSelected(Boolean selected) {
+ // this.selected = selected;
+ // }
+
+ /**
+ * @return
+ */
+ public Boolean getVisible() {
+ return visible;
+ }
+
+ // Only in case of Pie chart exception is thrown
+
+ /**
+ * If the argument is true then the series is visible otherwise not when
+ * a chart is rendered initially. Defaults to true However, this is not
+ * applicable for series related to Pie chart.
+ *
+ * @param visible
+ * @throws UnsupportedOperationException If this method is invoked on {@link PieConfig}
+ */
+ public void setVisible(Boolean visible)
+ throws UnsupportedOperationException {
+ this.visible = visible;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getShadow() {
+ return shadow;
+ }
+
+ // Only in case of Pie and Scatter chart exception is thrown
+
+ /**
+ * If the argument is true then a shadow will be shown to the graph line
+ * otherwise not. Defaults to true.
+ *
+ * @param shadow
+ * @throws UnsupportedOperationException If this method is invoked on {@link PieConfig}
+ */
+ public void setShadow(Boolean shadow)
+ throws UnsupportedOperationException {
+ this.shadow = shadow;
+ }
+
+ /**
+ * @return
+ */
+ public SeriesState getHoverState() {
+ return hoverState;
+ }
+
+ /**
+ * Sets attributes which should be applied to a series when series is
+ * hovered.
+ *
+ * @param state
+ */
+ public void setHoverState(SeriesState state) {
+ this.hoverState = state;
+ }
+
+ /**
+ * @return
+ */
+ public DataLabel getDataLabel() {
+ return dataLabel;
+ }
+
+ /**
+ * Sets how point value should be formatted and displayed for each
+ * point.
+ *
+ * @param dataLabel
+ */
+ public void setDataLabel(DataLabel dataLabel) {
+ this.dataLabel = dataLabel;
+ }
+
+ /**
+ * @return
+ */
+ public Paint getColor() {
+ return color;
+ }
+
+ /**
+ * Sets color for the series.
+ *
+ * @param color
+ */
+ public void setColor(Paint color) {
+ this.color = color;
+ }
+
+ }
+
+ /**
+ * This class contains various attributes to format data labels. The data
+ * labels are displayed along with points and axis.
+ *
+ * @author Invient
+ */
+ public static class DataLabel implements Serializable {
+ private HorzAlign align; // NA for pie
+ private Boolean enabled = Boolean.TRUE;
+ private String formatterJsFunc;
+ private Integer rotation;
+ private String style;
+ private Integer x;
+ private Integer y;
+ private Color color;
+
+ public DataLabel() {
+
+ }
+
+ /**
+ * If the argument is true then the datalabels will be displayed
+ * otherwise not.
+ *
+ * @param enabled
+ */
+ public DataLabel(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ /**
+ * @return
+ */
+ public HorzAlign getAlign() {
+ return align;
+ }
+
+ /**
+ * @param align
+ */
+ public void setAlign(HorzAlign align) {
+ this.align = align;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ /**
+ * If the argument is true then the datalabels will be displayed
+ * otherwise not.
+ *
+ * @param enabled
+ */
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ /**
+ * @return
+ */
+ public String getFormatterJsFunc() {
+ return formatterJsFunc;
+ }
+
+ /**
+ * Sets the argument string JavaScript function. This function will be
+ * called to format the data label. Refer to highchart documentation for
+ * more details on this
+ * http://www.highcharts.com/ref/#plotOptions-series-dataLabels
+ *
+ * @param formatterJsFunc
+ */
+ public void setFormatterJsFunc(String formatterJsFunc) {
+ this.formatterJsFunc = formatterJsFunc;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getRotation() {
+ return rotation;
+ }
+
+ /**
+ * Sets text rotation in degrees
+ *
+ * @param rotation
+ */
+ public void setRotation(Integer rotation) {
+ this.rotation = rotation;
+ }
+
+ /**
+ * @return
+ */
+ public String getStyle() {
+ return style;
+ }
+
+ /**
+ * Sets css style for the data label
+ *
+ * @param style
+ */
+ public void setStyle(String style) {
+ this.style = style;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getX() {
+ return x;
+ }
+
+ /**
+ * Sets the x position offset of the label relative to the point.
+ * Defaults to 0.
+ *
+ * @param x
+ */
+ public void setX(Integer x) {
+ this.x = x;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getY() {
+ return y;
+ }
+
+ /**
+ * Sets the y position offset of the label relative to the point.
+ * Defaults to -6.
+ *
+ * @param y
+ */
+ public void setY(Integer y) {
+ this.y = y;
+ }
+
+ /**
+ * @return
+ */
+ public Color getColor() {
+ return color;
+ }
+
+ /**
+ * Sets color for the data labels. e.g. if the color is blue then in
+ * case of line series, for each point, the data label will be displayed
+ * in blue color.
+ *
+ * @param color
+ */
+ public void setColor(Color color) {
+ this.color = color;
+ }
+
+ @Override
+ public String toString() {
+ return "DataLabel [align=" + align + ", enabled=" + enabled
+ + ", formatter=" + formatterJsFunc + ", rotation="
+ + rotation + ", style=" + style + ", x=" + x + ", y=" + y
+ + "]";
+ }
+
+ }
+
+ /**
+ * This class contains configuration attributes of data labels specific to
+ * Pie series.
+ *
+ * @author Invient
+ */
+ public final static class PieDataLabel extends DataLabel {
+ private Integer connectorWidth;
+ private Paint connectorColor;
+ private Integer connectorPadding;
+ private Integer distance;
+
+ /**
+ *
+ */
+ public PieDataLabel() {
+
+ }
+
+ /**
+ * If the argument is true then the datalabels will be displayed
+ * otherwise not.
+ *
+ * @param enabled
+ */
+ public PieDataLabel(boolean enabled) {
+ super(enabled);
+ }
+
+ /**
+ * @return
+ */
+ public Integer getConnectorWidth() {
+ return connectorWidth;
+ }
+
+ /**
+ * Sets width (in pixel) of the line connecting the data label to the
+ * pie slice. Defaults to 1.
+ *
+ * @param connectorWidth
+ */
+ public void setConnectorWidth(Integer connectorWidth) {
+ this.connectorWidth = connectorWidth;
+ }
+
+ /**
+ * @return
+ */
+ public Paint getConnectorColor() {
+ return connectorColor;
+ }
+
+ /**
+ * Sets the color of the line connecting the data label to the pie
+ * slice.
+ *
+ * @param connectorColor
+ */
+ public void setConnectorColor(Paint connectorColor) {
+ this.connectorColor = connectorColor;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getConnectorPadding() {
+ return connectorPadding;
+ }
+
+ /**
+ * Sets the distance (in pixel) from the data label to the connector.
+ * Defaults to 5.
+ *
+ * @param connectorPadding
+ */
+ public void setConnectorPadding(Integer connectorPadding) {
+ this.connectorPadding = connectorPadding;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getDistance() {
+ return distance;
+ }
+
+ /**
+ * Sets the distance (in pixel) of the data label from the pie's edge.
+ *
+ * @param distance
+ */
+ public void setDistance(Integer distance) {
+ this.distance = distance;
+ }
+
+ @Override
+ public String toString() {
+ return "PieDataLabel [connectorWidth=" + connectorWidth
+ + ", connectorColor=" + connectorColor
+ + ", connectorPadding=" + connectorPadding + ", distance="
+ + distance + ", getAlign()=" + getAlign()
+ + ", getEnabled()=" + getEnabled() + ", getFormatter()="
+ + getFormatterJsFunc() + ", getRotation()=" + getRotation()
+ + ", getStyle()=" + getStyle() + ", getX()=" + getX()
+ + ", getY()=" + getY() + ", toString()=" + super.toString()
+ + ", getClass()=" + getClass() + ", hashCode()="
+ + hashCode() + "]";
+ }
+
+ }
+
+ /**
+ * This class contains configuration properties for axis labels. The axis
+ * labels are the one which are displayed for each tick.
+ *
+ * @author Invient
+ */
+ public static abstract class AxisDataLabel extends DataLabel {
+ private Integer step;
+
+ public AxisDataLabel() {
+ super();
+ }
+
+ /**
+ * If the argument is true then the data labels will be displayed
+ * otherwise not.
+ *
+ * @param enabled
+ */
+ public AxisDataLabel(boolean enabled) {
+ super(enabled);
+ }
+
+ /**
+ * @return
+ */
+ public Integer getStep() {
+ return step;
+ }
+
+ /**
+ * Sets at what interval the labels on the axis should be displayed.
+ * Setting the step to 2 shows every other label. Defaults to null
+ *
+ * @param step
+ */
+ public void setStep(Integer step) {
+ this.step = step;
+ }
+ }
+
+ /**
+ * This class contains configuration properties specifically for x-axis
+ * labels.
+ *
+ * @author Invient
+ */
+ public static final class XAxisDataLabel extends AxisDataLabel {
+ private Integer staggerLines;
+
+ /**
+ * If the argument is true then the data labels will be displayed
+ * otherwise not.
+ *
+ * @param enabled
+ */
+ public XAxisDataLabel(boolean enabled) {
+ super(enabled);
+ }
+
+ public XAxisDataLabel() {
+ super();
+ }
+
+ /**
+ * @return
+ */
+ public Integer getStaggerLines() {
+ return staggerLines;
+ }
+
+ /**
+ * Sets number of lines to spread the labels over to make room or
+ * tighter labels.
+ *
+ * @param staggerLines
+ */
+ public void setStaggerLines(Integer staggerLines) {
+ this.staggerLines = staggerLines;
+ }
+ }
+
+ /**
+ * This class contains configuration properties specifically for x-axis
+ * labels.
+ *
+ * @author Invient
+ */
+ public static final class YAxisDataLabel extends AxisDataLabel {
+ public YAxisDataLabel() {
+ super();
+ }
+
+ /**
+ * If the argument is true then the data labels will be displayed
+ * otherwise not.
+ *
+ * @param enabled
+ */
+ public YAxisDataLabel(boolean enabled) {
+ super(enabled);
+ }
+ }
+
+ /**
+ * This class contains configuration options for line series such as line
+ * and area but not column series.
+ *
+ * @author Invient
+ */
+ public abstract static class BaseLineConfig extends SeriesConfig {
+ private Double pointStart;
+ private Double pointInterval;
+ private Boolean stickyTracking;
+ private Marker marker;
+ private DashStyle dashStyle;
+ private Integer lineWidth;
+ private Integer turboThreshold;
+
+ /**
+ * @return
+ */
+ public Double getPointStart() {
+ return pointStart;
+ }
+
+ /**
+ * If no x values are given for the points in a series, the argument
+ * pointStart defines on what value to start. Defaults to 0. e.g. if a
+ * series contains values higher than 2 m $ then sets pointStart to
+ * 2,000,000
+ *
+ * @param pointStart
+ */
+ public void setPointStart(Double pointStart) {
+ this.pointStart = pointStart;
+ }
+
+ /**
+ * @return
+ */
+ public Double getPointInterval() {
+ return pointInterval;
+ }
+
+ /**
+ * If no x values are given for the points in a series, the argument
+ * pointInterval defines the interval of the x values. For example, if a
+ * series contains one value every day then set pointInterval to 24 *
+ * 3600 * 1000
+ *
+ * @param pointInterval
+ */
+ public void setPointInterval(Double pointInterval) {
+ this.pointInterval = pointInterval;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getStickyTracking() {
+ return stickyTracking;
+ }
+
+ /**
+ * If the argument is true then the mouseout event on a series is not
+ * triggered until mouse moves over another series or comes out of the
+ * plot area. If the argument is true then the mouseout event occurs as
+ * soon as mouse leaves area near to the point or marker
+ *
+ * @param stickyTracking
+ */
+ public void setStickyTracking(Boolean stickyTracking) {
+ this.stickyTracking = stickyTracking;
+ }
+
+ /**
+ * @return
+ */
+ public Marker getMarker() {
+ return marker;
+ }
+
+ /**
+ * Sets marker for points of a series
+ *
+ * @param marker
+ */
+ public void setMarker(Marker marker) {
+ this.marker = marker;
+ }
+
+ /**
+ * @return
+ */
+ public DashStyle getDashStyle() {
+ return dashStyle;
+ }
+
+ /**
+ * Sets dash style to use when drawing a series.
+ *
+ * @param dashStyle
+ */
+ public void setDashStyle(DashStyle dashStyle) {
+ this.dashStyle = dashStyle;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getLineWidth() {
+ return lineWidth;
+ }
+
+ /**
+ * Sets width of a line
+ *
+ * @param lineWidth
+ */
+ public void setLineWidth(Integer lineWidth) {
+ this.lineWidth = lineWidth;
+ }
+
+ public Integer getTurboThreshold() {
+ return turboThreshold;
+ }
+
+ public void setTurboThreshold(Integer turboThreshold) {
+ this.turboThreshold = turboThreshold;
+ }
+ }
+
+ public static enum DashStyle {
+ SOLID("Solid"), SHORT_DASH("ShortDash"), SHORT_DOT("ShortDot"), SHORT_DASH_DOT(
+ "ShortDashDot"), SHORT_DASH_DOT_DOT("ShortDashDotDot"), DOT(
+ "Dot"), DASH("Dash"), LONG_DASH("LongDash"), DASH_DOT("DashDot"), LONG_DASH_DOT(
+ "LongDashDot"), LONG_DASH_DOT_DOT("LongDashDotDot");
+ private String name;
+
+ private DashStyle(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+ }
+
+ /**
+ * This class contains configuration options for area series, area and
+ * areaspline.
+ *
+ * @author Invient
+ */
+ public static class AreaConfig extends BaseLineConfig {
+ private Paint fillColor;
+ private Paint lineColor;
+ private Double fillOpacity;
+ private Integer threshold;
+
+ /**
+ * @return Returns fill color of the area.
+ */
+ public Paint getFillColor() {
+ return fillColor;
+ }
+
+ /**
+ * Sets fill gradient for the area
+ *
+ * @param fillColor
+ */
+ public void setFillColor(Paint fillColor) {
+ this.fillColor = fillColor;
+ }
+
+ /**
+ * @return Returns color of a line drawing above the area
+ */
+ public Paint getLineColor() {
+ return lineColor;
+ }
+
+ /**
+ * Sets line color for the line of an area.
+ *
+ * @param lineColor
+ */
+ public void setLineColor(Paint lineColor) {
+ this.lineColor = lineColor;
+ }
+
+ /**
+ * @return Returns opacity (transparency) which will be used when the area is filled with the fill color
+ */
+ public Double getFillOpacity() {
+ return fillOpacity;
+ }
+
+ /**
+ * Sets opacity for the area
+ *
+ * @param fillOpacity
+ */
+ public void setFillOpacity(Double fillOpacity) {
+ this.fillOpacity = fillOpacity;
+ }
+
+ /**
+ * @return Returns threadshold of the area
+ */
+ public Integer getThreshold() {
+ return threshold;
+ }
+
+ /**
+ * Sets threshold value which servers as the base for the area, for
+ * distinguishing between values above and below a threshold. Defaults
+ * to 0.
+ *
+ * @param threshold
+ */
+ public void setThreshold(Integer threshold) {
+ this.threshold = threshold;
+ }
+
+ }
+
+ /**
+ * This class contains configuration options for areaspline series
+ *
+ * @author Invient
+ */
+ public static class AreaSplineConfig extends AreaConfig {
+
+ }
+
+ /**
+ * This class contains configuration options for line series
+ *
+ * @author Invient
+ */
+ public static class LineConfig extends BaseLineConfig {
+ private Boolean step;
+
+ /**
+ * @return Returns true if the line should be drawn using steps otherwise false.
+ */
+ public Boolean getStep() {
+ return step;
+ }
+
+ /**
+ * If the argument is true then line will be drawn using steps otherwise
+ * not. Defaults to false.
+ *
+ * @param step
+ */
+ public void setStep(Boolean step) {
+ this.step = step;
+ }
+ }
+
+ /**
+ * This class contains configuration options for scatter series
+ *
+ * @author Invient
+ */
+ public static class ScatterConfig extends BaseLineConfig {
+
+ /**
+ * @param shadow
+ * @throws UnsupportedOperationException Scatter series does not support shadow so this method
+ * throws an exception if invoked.
+ */
+ @Override
+ public void setShadow(Boolean shadow)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "Scatter chart does not support shadow.");
+ }
+
+ /**
+ * @return Returns null as scatter series does not have shadow.
+ */
+ @Override
+ public Boolean getShadow() {
+ return null;
+ }
+ }
+
+ /**
+ * This class contains configuration options for spline series
+ *
+ * @author Invient
+ */
+ public static class SplineConfig extends BaseLineConfig {
+
+ }
+
+ /**
+ * This class contains configuration options for pie series.
+ *
+ * @author Invient
+ */
+ public static class PieConfig extends SeriesConfig {
+ private Integer centerX;
+ private Integer centerY;
+ private Paint borderColor;
+ private Double borderWidth;
+ private Integer innerSize;
+ private Integer size;
+ private Integer slicedOffset;
+ private Boolean ignoreHiddenPoint;
+
+ public Boolean getIgnoreHiddenPoint() {
+ return ignoreHiddenPoint;
+ }
+
+ public void setIgnoreHiddenPoint(Boolean ignoreHiddenPoint) {
+ this.ignoreHiddenPoint = ignoreHiddenPoint;
+ }
+
+ /**
+ * @return Returns x position (in pixel) of the center of the pie chart relative to
+ * the plot area.
+ */
+ public Integer getCenterX() {
+ return centerX;
+ }
+
+ /**
+ * Sets x position (in pixel) of the center of the pie chart relative to
+ * the plot area.
+ *
+ * @param centerX
+ */
+ public void setCenterX(Integer centerX) {
+ this.centerX = centerX;
+ }
+
+ /**
+ * @return Returns y position (in pixel) of the center of the pie chart relative to
+ * the plot area.
+ */
+ public Integer getCenterY() {
+ return centerY;
+ }
+
+ /**
+ * Sets y position (in pixel) of the center of the pie chart relative to
+ * the plot area.
+ *
+ * @param centerY
+ */
+ public void setCenterY(Integer centerY) {
+ this.centerY = centerY;
+ }
+
+ /**
+ * @return Returns color of border surrounding each slice.
+ */
+ public Paint getBorderColor() {
+ return borderColor;
+ }
+
+ /**
+ * Sets color of border surrounding each slice.
+ *
+ * @param borderColor
+ */
+ public void setBorderColor(Paint borderColor) {
+ this.borderColor = borderColor;
+ }
+
+ /**
+ * @return Returns width of the border surrounding each slice.
+ */
+ public Double getBorderWidth() {
+ return borderWidth;
+ }
+
+ /**
+ * Sets width of border surrounding each slice.
+ *
+ * @param borderWidth
+ */
+ public void setBorderWidth(Double borderWidth) {
+ this.borderWidth = borderWidth;
+ }
+
+ /**
+ * @return Returns size of the inner diameter of the pie.
+ */
+ public Integer getInnerSize() {
+ return innerSize;
+ }
+
+ /**
+ * Sets the size of the inner diameter for the pie. Any value greater
+ * than 0 renders a donut chart.
+ *
+ * @param innerSize
+ */
+ public void setInnerSize(Integer innerSize) {
+ this.innerSize = innerSize;
+ }
+
+ /**
+ * @return Returns size of diameter of the pie relative to the plot area.
+ */
+ public Integer getSize() {
+ return size;
+ }
+
+ /**
+ * Sets size of diameter of the pie relative to the plot area.
+ *
+ * @param size
+ */
+ public void setSize(Integer size) {
+ this.size = size;
+ }
+
+ /**
+ * @return Returns offset in pixel by which a slice should be moved out from the
+ * center.
+ */
+ public Integer getSlicedOffset() {
+ return slicedOffset;
+ }
+
+ /**
+ * Sets offset in pixel by which a slice should be moved out from the
+ * center.
+ *
+ * @param slicedOffset
+ */
+ public void setSlicedOffset(Integer slicedOffset) {
+ this.slicedOffset = slicedOffset;
+ }
+
+ /**
+ * @throws UnsupportedOperationException Pie chart does not support visible property so this
+ * method throws an exception if invoked.
+ */
+ @Override
+ public void setVisible(Boolean visible)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "Pie chart does not support visible property.");
+ }
+
+ /**
+ * @return Returns null as pie does not support toggle (show/hide pie) feature.
+ */
+ @Override
+ public Boolean getVisible() {
+ return null;
+ }
+
+ /**
+ * Sets an object of {@link PieDataLabel} which contains configuration
+ * for formatting data labels.
+ *
+ * @param dataLabel
+ */
+ public void setDataLabel(PieDataLabel dataLabel) {
+ super.setDataLabel(dataLabel);
+ }
+
+ /**
+ *
+ */
+ public PieDataLabel getDataLabel() {
+ return (PieDataLabel) super.getDataLabel();
+ }
+
+ /**
+ * Sets state which should be applied to a slice when a mouse is over
+ * the slice
+ *
+ * @param state
+ */
+ public void setHoverState(NonLinearSeriesState state) {
+ super.setHoverState(state);
+ }
+
+ public NonLinearSeriesState getHoverState() {
+ if (super.getHoverState() instanceof NonLinearSeriesState) {
+ return (NonLinearSeriesState) super.getHoverState();
+ }
+ return null;
+ }
+
+ }
+
+ /**
+ * This class contains configuration options for bar and column series.
+ *
+ * @author Invient
+ */
+ public abstract static class BaseBarConfig extends SeriesConfig {
+ private Paint borderColor;
+ private Integer borderRadius;
+ private Integer borderWidth;
+ private Boolean colorByPoint;
+ private Double groupPadding;
+ private Double minPointLength;
+ private Double pointPadding;
+ private Integer pointWidth;
+
+ /**
+ * @return
+ */
+ public Paint getBorderColor() {
+ return borderColor;
+ }
+
+ /**
+ * Sets the color of the border surronding each column or bar.
+ *
+ * @param borderColor
+ */
+ public void setBorderColor(Paint borderColor) {
+ this.borderColor = borderColor;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getBorderRadius() {
+ return borderRadius;
+ }
+
+ /**
+ * Sets corner radius of the border surronding each column or bar.
+ *
+ * @param borderRadius
+ */
+ public void setBorderRadius(Integer borderRadius) {
+ this.borderRadius = borderRadius;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getBorderWidth() {
+ return borderWidth;
+ }
+
+ /**
+ * Sets width of the border surronding each column or bar.
+ *
+ * @param borderWidth
+ */
+ public void setBorderWidth(Integer borderWidth) {
+ this.borderWidth = borderWidth;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getColorByPoint() {
+ return colorByPoint;
+ }
+
+ /**
+ * If the argument is true then each point (bar or column in a series
+ * will have a different color otherwise all points (bars/columns) of a
+ * series will have same color.
+ *
+ * @param colorByPoint
+ */
+ public void setColorByPoint(Boolean colorByPoint) {
+ this.colorByPoint = colorByPoint;
+ }
+
+ /**
+ * @return
+ */
+ public Double getGroupPadding() {
+ return groupPadding;
+ }
+
+ /**
+ * Sets padding between each value groups, in x axis units. Defaults to
+ * 0.2.
+ *
+ * @param groupPadding
+ */
+ public void setGroupPadding(Double groupPadding) {
+ this.groupPadding = groupPadding;
+ }
+
+ /**
+ * @return
+ */
+ public Double getMinPointLength() {
+ return minPointLength;
+ }
+
+ /**
+ * Sets the minimal height for a column or width for a bar. By default,
+ * 0 values are not shown. To visualize a 0 (or close to zero) point,
+ * set the minimal point length to a pixel value like 3. In stacked
+ * column charts, minPointLength might not be respected for tightly
+ * packed values. Defaults to 0. (For detail, refer to
+ * http://www.highcharts.com/ref/#plotOptions-bar);
+ *
+ * @param minPointLength
+ */
+ public void setMinPointLength(Double minPointLength) {
+ this.minPointLength = minPointLength;
+ }
+
+ /**
+ * @return
+ */
+ public Double getPointPadding() {
+ return pointPadding;
+ }
+
+ /**
+ * Sets padding between each column or bar, in x axis units.
+ *
+ * @param pointPadding
+ */
+ public void setPointPadding(Double pointPadding) {
+ this.pointPadding = pointPadding;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getPointWidth() {
+ return pointWidth;
+ }
+
+ /**
+ * Sets width of each bar or column in pixel.
+ *
+ * @param pointWidth
+ */
+ public void setPointWidth(Integer pointWidth) {
+ this.pointWidth = pointWidth;
+ }
+
+ /**
+ * Sets state which should be applied to a bar or column when a mouse is
+ * over the bar or column
+ *
+ * @param state
+ */
+ public void setHoverState(NonLinearSeriesState state) {
+ super.setHoverState(state);
+ }
+
+ /**
+ *
+ */
+ public NonLinearSeriesState getHoverState() {
+ if (super.getHoverState() instanceof NonLinearSeriesState) {
+ return (NonLinearSeriesState) super.getHoverState();
+ }
+ return null;
+ }
+ }
+
+ /**
+ * This class contains configuration options for column series.
+ *
+ * @author Invient
+ */
+ public static class ColumnConfig extends BaseBarConfig {
+
+ }
+
+ /**
+ * This class contains configuration options for bar series.
+ *
+ * @author Invient
+ */
+ public static class BarConfig extends BaseBarConfig {
+
+ }
+
+ /**
+ * Defines ways in which series of a chart can be stacked.
+ *
+ * Stacking.Normal - represents that the values of each series are stacked.
+ *
+ * Stacking.Percent - represents that the the values of each series are
+ * stacked based on percentage of sum of total value, where total value is
+ * sum of values of all points on a particular tick of an axis.
+ *
+ * @author Invient
+ */
+ public static enum Stacking {
+ NORMAL("normal"), PERCENT("percent");
+ private String stacking;
+
+ private Stacking(String stacking) {
+ this.stacking = stacking;
+ }
+
+ public String getName() {
+ return this.stacking;
+ }
+ }
+
+ /**
+ * Defines configuration per point in a series. It is possible to assign
+ * each point a different color and marker.
+ *
+ * @author Invient
+ */
+ public static final class PointConfig implements Serializable {
+ private Boolean sliced;
+ private Boolean selected;
+ private Paint color;
+ private Marker marker;
+
+ /**
+ * Creates an instance of this class with specified marker
+ *
+ * @param marker
+ */
+ public PointConfig(Marker marker) {
+ this(null, null, null, marker);
+ }
+
+ /**
+ * Creates an instance of this class with specified color
+ *
+ * @param color
+ */
+ public PointConfig(Paint color) {
+ this(null, null, color, null);
+ }
+
+ /**
+ * Creates an instance of this class with specified argument. The sliced
+ * attribute has meaning only for Pie chart/series.
+ *
+ * @param sliced
+ */
+ public PointConfig(Boolean sliced) {
+ this(sliced, sliced, null, null);
+ }
+
+ /**
+ * @param sliced - If true then the slice of a pie will be at an offset
+ * from the center of the pie. Applicable only for Pie
+ * chart/series.
+ * @param selected - If true then the point, to which this object is
+ * associated, will be shown as selected otherwise not.
+ * @param color - Specifies individual color for a point, to which this
+ * object is associated.
+ * @param marker - Specifies marker for a point, to which this object is
+ * associated.
+ * @see Marker
+ * @see Color
+ */
+ public PointConfig(Boolean sliced, Boolean selected, Paint color,
+ Marker marker) {
+ super();
+ this.sliced = sliced;
+ this.selected = selected;
+ this.color = color;
+ this.marker = marker;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getSliced() {
+ return sliced;
+ }
+
+ /**
+ * @param sliced
+ */
+ public void setSliced(Boolean sliced) {
+ this.sliced = sliced;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getSelected() {
+ return selected;
+ }
+
+ /**
+ * @param selected
+ */
+ public void setSelected(Boolean selected) {
+ this.selected = selected;
+ }
+
+ /**
+ * @return
+ */
+ public Paint getColor() {
+ return color;
+ }
+
+ /**
+ * @param color
+ */
+ public void setColor(Paint color) {
+ this.color = color;
+ }
+
+ /**
+ * @return
+ */
+ public Marker getMarker() {
+ return marker;
+ }
+
+ /**
+ * @param marker
+ */
+ public void setMarker(Marker marker) {
+ this.marker = marker;
+ }
+
+ /**
+ * @return Returns string representation of this object.
+ */
+ @Override
+ public String toString() {
+ return "PointConfig [sliced=" + sliced + ", selected=" + selected
+ + ", color=" + color + ", marker=" + marker + "]";
+ }
+
+ }
+
+ /**
+ * A chart has a title and a subtitle. This class defines attributes which
+ * are common to both.
+ *
+ * The text of a title can be plain text or html text containing html
+ * elements. It is also possible to apply css to the title. The css must be
+ * valid css string e.g. { color: 'red' }
+ *
+ * @author Invient
+ * @see Title
+ * @see SubTitle
+ * @see HorzAlign
+ * @see VertAlign
+ */
+ public static abstract class TitleBase implements Serializable {
+ private HorzAlign align;
+ private VertAlign vertAlign;
+ private Boolean floating;
+ private String text;
+ private Integer x;
+ private Integer y;
+ private String style;
+
+ /**
+ * @return
+ */
+ public HorzAlign getAlign() {
+ return align;
+ }
+
+ /**
+ * Sets horizontal alignment of the title. Defaults to HorzAlign.CENTER
+ *
+ * @param align
+ */
+ public void setAlign(HorzAlign align) {
+ this.align = align;
+ }
+
+ /**
+ * @return
+ */
+ public VertAlign getVertAlign() {
+ return vertAlign;
+ }
+
+ /**
+ * Sets horizontal alignment of the title. Defaults to VertAlign.TOP
+ *
+ * @param vertAlign
+ */
+ public void setVertAlign(VertAlign vertAlign) {
+ this.vertAlign = vertAlign;
+ }
+
+ /**
+ * @return
+ */
+ public Boolean getFloating() {
+ return floating;
+ }
+
+ /**
+ * If the argument is true then the plot area will not move to make
+ * space for the chart title. Defaults to false.
+ *
+ * @param floating
+ */
+ public void setFloating(Boolean floating) {
+ this.floating = floating;
+ }
+
+ /**
+ * @return
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * Sets text for the chart's title. The text can be plain or html
+ * string.
+ *
+ * @param text
+ */
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getX() {
+ return x;
+ }
+
+ /**
+ * Sets x position (in pixel) of the title relative to the alignment
+ * within Spacing.left and Spacing.right. Defaults to 0
+ *
+ * @param x
+ */
+ public void setX(Integer x) {
+ this.x = x;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getY() {
+ return y;
+ }
+
+ /**
+ * Sets y position (in pixel) of the title relative to the alignment
+ * within Spacing.top and Spacing.bottom. Defaults to 0
+ *
+ * @param y
+ */
+ public void setY(Integer y) {
+ this.y = y;
+ }
+
+ /**
+ * @return
+ */
+ public String getStyle() {
+ return style;
+ }
+
+ /**
+ * Sets css for the title. The css must be a valid css object. e.g. css
+ * string "{ color:'red' }" is valid but "{ color: 'red'" is invalid.
+ *
+ * @param style
+ */
+ public void setStyle(String style) {
+ this.style = style;
+ }
+ }
+
+ /**
+ * Defines attributes of chart title.
+ *
+ * @author Invient
+ */
+ public static final class Title extends TitleBase {
+ private Integer margin;
+
+ /**
+ * @return
+ */
+ public Integer getMargin() {
+ return margin;
+ }
+
+ /**
+ * Sets margin (in pixel) between the chart title and subtitle, if any.
+ * If chart subtitle doesn't exist then it indicates the margin between
+ * subtitle and plotarea. Defaults to 15
+ *
+ * @param margin
+ */
+ public void setMargin(Integer margin) {
+ this.margin = margin;
+ }
+ }
+
+ /**
+ * Defines attributes of chart subtitle.
+ *
+ * @author Invient
+ */
+ public static final class SubTitle extends TitleBase {
+
+ }
+
+ public static enum HorzAlign {
+ LEFT("left"), CENTER("center"), RIGHT("right");
+ private String align;
+
+ private HorzAlign(String align) {
+ this.align = align;
+ }
+
+ public String getName() {
+ return this.align;
+ }
+ }
+
+ public static enum VertAlign {
+ TOP("top"), MIDDLE("middle"), BOTTOM("bottom");
+ private String align;
+
+ private VertAlign(String align) {
+ this.align = align;
+ }
+
+ public String getName() {
+ return this.align;
+ }
+ }
+
+ /**
+ * Defines state for a series and point. A series can be in hover state. A
+ * point can be in hover and select state. In each state, a series and a
+ * point can have different visual clues. This is achived by setting some
+ * attributes of a seires and point.
+ *
+ * @author Invient
+ * @see SeriesState
+ */
+ public static interface State extends Serializable {
+ public Boolean getEnabled();
+ }
+
+ /**
+ * Defines a set of attributes which will be applied to a series upon hover.
+ * The attributes linWidth is not applicable for Pie, Scatter, Bar and
+ * Column series.
+ *
+ * @author Invient
+ */
+ public static class SeriesState implements State {
+ private Boolean enabled;
+ private Integer lineWidth;
+
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ /**
+ * If the argument is true then the other properties of this class have
+ * impact on visual rendering of the series when a series is hovered or
+ * when a mouse is over the legend. Enabling this has a performance
+ * penalty.
+ *
+ * Defaults to false.
+ *
+ * @param enabled
+ */
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getLineWidth() {
+ return lineWidth;
+ }
+
+ /**
+ * Sets width of a line in pixel. Defaults to 2.
+ *
+ * @param lineWidth
+ */
+ public void setLineWidth(Integer lineWidth) {
+ this.lineWidth = lineWidth;
+ }
+ }
+
+ /**
+ * Defines a set of attributes which are meaningful for bar and colum
+ * series.
+ *
+ * @author Invient
+ */
+ public static class NonLinearSeriesState extends SeriesState {
+ private Double brightness;
+
+ /**
+ * @return
+ */
+ public Double getBrightness() {
+ return brightness;
+ }
+
+ /**
+ * Sets intensity of brightness for a point. This applies only to bar
+ * and column series/chart
+ *
+ * Defaults to 0.1
+ *
+ * @param brightness
+ */
+ public void setBrightness(Double brightness) {
+ this.brightness = brightness;
+ }
+ }
+
+ /**
+ * Defines a collection of attributes which makes a marker. Markers are
+ * generally used to annotate a graph points.
+ *
+ * @author Invient
+ */
+ private static class MarkerAttribute implements Serializable {
+ private Boolean enabled;
+ private Paint fillColor;
+ private Paint lineColor;
+ private Integer lineWidth;
+ private Integer radius;
+
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public Paint getFillColor() {
+ return fillColor;
+ }
+
+ public void setFillColor(Paint fillColor) {
+ this.fillColor = fillColor;
+ }
+
+ public Paint getLineColor() {
+ return lineColor;
+ }
+
+ public void setLineColor(Paint lineColor) {
+ this.lineColor = lineColor;
+ }
+
+ public Integer getLineWidth() {
+ return lineWidth;
+ }
+
+ public void setLineWidth(Integer lineWidth) {
+ this.lineWidth = lineWidth;
+ }
+
+ public Integer getRadius() {
+ return radius;
+ }
+
+ public void setRadius(Integer radius) {
+ this.radius = radius;
+ }
+
+ @Override
+ public String toString() {
+ return "MarkerStateAttribute [enabled=" + enabled + ", fillColor="
+ + fillColor + ", lineColor=" + lineColor + ", lineWidth="
+ + lineWidth + ", radius=" + radius + "]";
+ }
+
+ }
+
+ /**
+ * Defines a set of attributes which gets applied to a point when a point is
+ * selected or hovered. By default, markers are enabled so when a mouse is
+ * over a point marker gets applied. To turn off marker, set flag enabled to
+ * false.
+ *
+ * A point marker is useful only if the marker is not an image.
+ *
+ * @author Invient
+ * @see ImageMarker
+ * @see SymbolMarker
+ */
+ public static final class MarkerState implements State {
+ private MarkerAttribute markerAttribute = new MarkerAttribute();
+
+ /**
+ * Creates this marker with enabled = true
+ */
+ public MarkerState() {
+ markerAttribute.setEnabled(true);
+ }
+
+ /**
+ * Creates this marker with specified argument. If enabled = false then
+ * the marker will not be applied to a point on hover or select state.
+ */
+ public MarkerState(boolean enabled) {
+ markerAttribute.setEnabled(enabled);
+ }
+
+ /**
+ *
+ */
+ public Boolean getEnabled() {
+ return markerAttribute.getEnabled();
+ }
+
+ /**
+ * If enabled = false then the marker will not be applied to a point on
+ * hover or select state. Defaults to true
+ *
+ * @param enabled
+ */
+ public void setEnabled(Boolean enabled) {
+ this.markerAttribute.setEnabled(enabled);
+ }
+
+ /**
+ * @return
+ */
+ public Paint getFillColor() {
+ return markerAttribute.getFillColor();
+ }
+
+ /**
+ * Sets fill color for the marker. When not specified it takes color of
+ * a series or point.
+ *
+ * @param fillColor
+ */
+ public void setFillColor(Paint fillColor) {
+ this.markerAttribute.setFillColor(fillColor);
+ }
+
+ /**
+ * @return
+ */
+ public Paint getLineColor() {
+ return markerAttribute.getLineColor();
+ }
+
+ /**
+ * Sets color of the point marker's outline. When not specified it takes
+ * color of a series or point.
+ *
+ * @param lineColor
+ */
+ public void setLineColor(Paint lineColor) {
+ this.markerAttribute.setLineColor(lineColor);
+ }
+
+ /**
+ * @return
+ */
+ public Integer getLineWidth() {
+ return markerAttribute.getLineWidth();
+ }
+
+ /**
+ * Sets width of the point marker's outline. Defaults to 0.
+ *
+ * @param lineWidth
+ */
+ public void setLineWidth(Integer lineWidth) {
+ this.markerAttribute.setLineWidth(lineWidth);
+ }
+
+ /**
+ * @return
+ */
+ public Integer getRadius() {
+ return markerAttribute.getRadius();
+ }
+
+ /**
+ * Sets radius of the point marker. Defaults to 0.
+ *
+ * @param radius
+ */
+ public void setRadius(Integer radius) {
+ this.markerAttribute.setRadius(radius);
+ }
+
+ @Override
+ public String toString() {
+ return "MarkerState [enabled=" + getEnabled() + ", fillColor="
+ + getFillColor() + ", lineColor=" + getLineColor()
+ + ", lineWidth=" + getLineWidth() + ", radius="
+ + getRadius() + "]";
+ }
+
+ }
+
+ /**
+ * Defines a marker for a point. Markers are applied to a point of chart's
+ * series. The marker can be applied at the time of drawing the chart or
+ * when a point is selcted or hovered.
+ *
+ * There are two types of marker.
+ *
+ *
+ * {@link SymbolMarker}
+ *
+ * {@link ImageMarker}
+ *
+ *
+ * @author Invient
+ * @see SymbolMarker
+ * @see ImageMarker
+ */
+ public static interface Marker extends Serializable {
+ public Boolean getEnabled();
+
+ public void setEnabled(Boolean enabled);
+ }
+
+ /**
+ * Defines attributes for a marker.
+ *
+ * @author Invient
+ * @see SymbolMarker
+ * @see ImageMarker
+ */
+ public static abstract class AbstractMarker implements Marker {
+ private MarkerAttribute markerAttribute = new MarkerAttribute();
+
+ public AbstractMarker() {
+ }
+
+ public AbstractMarker(boolean enabled) {
+ this.markerAttribute.setEnabled(enabled);
+ }
+
+ protected Paint getLineColor() {
+ return markerAttribute.getLineColor();
+ }
+
+ protected void setLineColor(Paint lineColor) {
+ this.markerAttribute.setLineColor(lineColor);
+ }
+
+ protected Paint getFillColor() {
+ return markerAttribute.getFillColor();
+ }
+
+ protected void setFillColor(Paint fillColor) {
+ this.markerAttribute.setFillColor(fillColor);
+ }
+
+ protected Integer getLineWidth() {
+ return markerAttribute.getLineWidth();
+ }
+
+ protected void setLineWidth(Integer lineWidth) {
+ this.markerAttribute.setLineWidth(lineWidth);
+ }
+
+ protected Integer getRadius() {
+ return markerAttribute.getRadius();
+ }
+
+ protected void setRadius(Integer radius) {
+ this.markerAttribute.setRadius(radius);
+ }
+
+ public Boolean getEnabled() {
+ return markerAttribute.getEnabled();
+ }
+
+ public void setEnabled(Boolean enabled) {
+ this.markerAttribute.setEnabled(enabled);
+ }
+
+ }
+
+ /**
+ * This marker can take url of an image which will be used as a marker for a
+ * point or all points of a series.
+ *
+ * The url of an image must be with respect to root of the web application.
+ * e.g. If an image named temperature.png is under directory
+ * /img/climate then the url must be
+ * /img/climate/temperature.png
+ *
+ * @author Invient
+ */
+ public static class ImageMarker extends AbstractMarker {
+ private String imageURL;
+
+ /**
+ * Creates this marker with specified arguments.
+ *
+ * @param imageURL - URL of an image
+ * @param enabled - If false then this marker will not be applied to a
+ * point. What this means is that the data points of a line
+ * chart will not stand out.
+ */
+ public ImageMarker(String imageURL, boolean enabled) {
+ super(enabled);
+ this.imageURL = imageURL;
+ }
+
+ /**
+ * Creates this marker with specified arguments.
+ *
+ * @param imageURL - URL of an image
+ */
+ public ImageMarker(String imageURL) {
+ super(true);
+ this.imageURL = imageURL;
+ }
+
+ /**
+ * @return
+ */
+ public String getImageURL() {
+ return imageURL;
+ }
+
+ /**
+ * @param imageURL
+ */
+ public void setImageURL(String imageURL) {
+ this.imageURL = imageURL;
+ }
+
+ @Override
+ public String toString() {
+ return "ImageMarker [imageURL=" + imageURL + ", enabled"
+ + getEnabled() + "]";
+ }
+ }
+
+ /**
+ * This marker has predefined shape which cannot be changed. However, marker
+ * attributes can be set.
+ *
+ * @author Invient
+ */
+ public static class SymbolMarker extends AbstractMarker {
+ private Symbol symbol;
+ private MarkerState hoverState;
+ private MarkerState selectState;
+
+ /**
+ * Creates this marker with enabled = true
+ */
+ public SymbolMarker() {
+ super(true);
+ }
+
+ /**
+ * Creates this marker with specified arguments.
+ *
+ * @param enabled If false then this marker will not be applied to a point.
+ * What this means is that the data points of a line chart
+ * will not stand out.
+ */
+ public SymbolMarker(boolean enabled) {
+ super(enabled);
+ }
+
+ /**
+ * Creates this marker with specified arguments.
+ *
+ * @param lineColor - Color of the point marker's outline
+ */
+ public SymbolMarker(Paint lineColor) {
+ super(true);
+ super.setLineColor(lineColor);
+ }
+
+ /**
+ * Creates this marker with specified arguments.
+ *
+ * @param radius Radius of the point marker.
+ */
+ public SymbolMarker(Integer radius) {
+ super(true);
+ this.setRadius(radius);
+ }
+
+ /**
+ * Creates this marker with specified arguments.
+ *
+ * @param symbol It must be one of the predefine symbol such as
+ * Symbol.CIRCLE or Symbol.DIAMOND
+ */
+ public SymbolMarker(Symbol symbol) {
+ super(true);
+ this.symbol = symbol;
+ }
+
+ /**
+ * Creates this marker with specified arguments.
+ *
+ * @param lineColor Color of the point marker's outline
+ * @param radius Radius of the point marker.
+ */
+ public SymbolMarker(Paint lineColor, Integer radius) {
+ super(true);
+ super.setLineColor(lineColor);
+ super.setRadius(radius);
+ }
+
+ /**
+ * Creates this marker with specified arguments.
+ *
+ * @param lineColor - Color of the point marker's outline
+ * @param radius Radius of the point marker.
+ * @param symbol It must be one of the predefine symbol such as
+ * Symbol.CIRCLE or Symbol.DIAMOND
+ */
+ public SymbolMarker(Paint lineColor, Integer radius, Symbol symbol) {
+ super(true);
+ super.setLineColor(lineColor);
+ super.setRadius(radius);
+ this.symbol = symbol;
+ }
+
+ /**
+ *
+ */
+ @Override
+ public Paint getLineColor() {
+ return super.getLineColor();
+ }
+
+ /**
+ * Sets color of the point marker's outline
+ *
+ * @param lineColor
+ */
+ @Override
+ public void setLineColor(Paint lineColor) {
+ super.setLineColor(lineColor);
+ }
+
+ /**
+ *
+ */
+ @Override
+ public Paint getFillColor() {
+ return super.getFillColor();
+ }
+
+ /**
+ * Sets color of the point marker
+ *
+ * @param fillColor
+ */
+ @Override
+ public void setFillColor(Paint fillColor) {
+ super.setFillColor(fillColor);
+ }
+
+ /**
+ *
+ */
+ @Override
+ public Integer getLineWidth() {
+ return super.getLineWidth();
+ }
+
+ /**
+ * Sets width of the point marker outline
+ *
+ * @param lineWidth
+ */
+ @Override
+ public void setLineWidth(Integer lineWidth) {
+ super.setLineWidth(lineWidth);
+ }
+
+ /**
+ *
+ */
+ @Override
+ public Integer getRadius() {
+ return super.getRadius();
+ }
+
+ /**
+ * Sets radius of the point marker
+ *
+ * @param radius
+ */
+ @Override
+ public void setRadius(Integer radius) {
+ super.setRadius(radius);
+ }
+
+ /**
+ * @return
+ */
+ public Symbol getSymbol() {
+ return symbol;
+ }
+
+ /**
+ * Sets symbol for the point marker. It must be one of the predefine
+ * symbol such as Symbol.CIRCLE or Symbol.DIAMOND
+ *
+ * @param symbol
+ */
+ public void setSymbol(Symbol symbol) {
+ this.symbol = symbol;
+ }
+
+ /**
+ * @return
+ */
+ public MarkerState getHoverState() {
+ return hoverState;
+ }
+
+ /**
+ * Sets marker to be applied to a point when it is hovered.
+ *
+ * @param hoverState
+ */
+ public void setHoverState(MarkerState hoverState) {
+ this.hoverState = hoverState;
+ }
+
+ /**
+ * @return
+ */
+ public MarkerState getSelectState() {
+ return selectState;
+ }
+
+ /**
+ * Sets marker to be applied to a point when it is selected.
+ *
+ * @param selectState
+ */
+ public void setSelectState(MarkerState selectState) {
+ this.selectState = selectState;
+ }
+
+ @Override
+ public String toString() {
+ return "SymbolMarker [symbol=" + symbol + ", hoverState="
+ + hoverState + ", selectState=" + selectState
+ + ", getLineColor()=" + getLineColor()
+ + ", getFillColor()=" + getFillColor()
+ + ", getLineWidth()=" + getLineWidth() + ", getRadius()="
+ + getRadius() + ", getSymbol()=" + getSymbol()
+ + ", getHoverState()=" + getHoverState()
+ + ", getSelectState()=" + getSelectState() + "]";
+ }
+
+ /**
+ * Defines predefined marker shapes to be used along with
+ * {@link SymbolMarker}
+ *
+ * @author Invient
+ * @see SymbolMarker
+ */
+ public static enum Symbol {
+ CIRCLE("circle"), DIAMOND("diamond"), SQUARE("square"), TRIANGLE(
+ "triangle"), TRIANGLE_DOWN("triangle-down");
+ private String symbol;
+
+ private Symbol(String symbol) {
+ this.symbol = symbol;
+ }
+
+ public String getName() {
+ return this.symbol;
+ }
+ }
+
+ }
+
+ /**
+ * This class defines attributes common to X axis and Y axis. A chart can
+ * have one or more axis of each type.
+ *
+ * @author chirag
+ * @see XAxis
+ * @see YAxis
+ */
+ public static abstract class AxisBase implements Axis {
+ private String id;
+
+ private AxisType type = AxisType.LINEAR;
+ private AxisTitle title;
+ private AxisDataLabel label;
+ private LinkedHashSet plotBands = new LinkedHashSet();
+ private LinkedHashSet plotLines = new LinkedHashSet();
+
+ private Paint alternateGridColor;
+ private Boolean endOnTick;
+
+ private Grid grid;
+
+ private Paint lineColor;
+ private Integer lineWidth;
+ private Axis linkedTo;
+
+ private Double maxPadding;
+ private Integer maxZoom;
+ // private Double max;
+ // private Double min;
+ private Double minPadding;
+
+ private Tick tick;
+ private MinorGrid minorGrid;
+ private MinorTick minorTick;
+
+ private Integer offset;
+ private Boolean opposite;
+ private Boolean reversed;
+ private Boolean showFirstLabel;
+ private Boolean showLastLabel;
+ private WeekDay startOfWeek;
+ private Boolean startOnTick;
+
+ /**
+ * Defines attributes of a minor tick. The minor ticks do not have a
+ * label. By default, minor ticks are not shown. To display minor ticks,
+ * set interval property.
+ *
+ * @author Invient
+ * @see Tick
+ */
+ public static class MinorTick implements Serializable {
+ private Paint color;
+ private Double interval;
+ private Integer length;
+ private TickPosition position;
+ private Integer width;
+
+ public Paint getColor() {
+ return color;
+ }
+
+ public void setColor(Paint color) {
+ this.color = color;
+ }
+
+ public Double getInterval() {
+ return interval;
+ }
+
+ /**
+ * Sets interval for the minor tick. The interval must be specified
+ * in the axis unit. e.g. If an axis has tick interval of 50 units
+ * then setting minortick interval to 10 will show 5 minor ticks.
+ *
+ * @param interval
+ */
+ public void setInterval(Double interval) {
+ this.interval = interval;
+ }
+
+ public Integer getLength() {
+ return length;
+ }
+
+ /**
+ * Sets length of the minorticks in pixel
+ *
+ * @param length
+ */
+ public void setLength(Integer length) {
+ this.length = length;
+ }
+
+ /**
+ * @return
+ */
+ public TickPosition getPosition() {
+ return position;
+ }
+
+ /**
+ * @param position
+ */
+ public void setPosition(TickPosition position) {
+ this.position = position;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getWidth() {
+ return width;
+ }
+
+ /**
+ * Sets width of the minorticks in pixel
+ *
+ * @param width
+ */
+ public void setWidth(Integer width) {
+ this.width = width;
+ }
+
+ @Override
+ public String toString() {
+ return "MinorTick [color=" + color + ", length=" + length
+ + ", position=" + position + ", width=" + width + "]";
+ }
+
+ }
+
+ /**
+ * Defines attributes of a tick marks. The interval of the tick marks
+ * must be specified in axis unit. For datetime axis, the interval must
+ * be in millisecond.
+ *
+ * The default tick interval is 1.
+ *
+ * @author Invient
+ * @see MinorTick
+ * @see TickmarkPlacement
+ */
+ public static final class Tick extends MinorTick {
+ private TickmarkPlacement placement;
+ private Integer pixelInterval;
+
+ /**
+ * @return
+ */
+ public TickmarkPlacement getPlacement() {
+ return placement;
+ }
+
+ /**
+ * Sets placement of the tick marks.
+ *
+ * @param placement
+ */
+ public void setPlacement(TickmarkPlacement placement) {
+ this.placement = placement;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getPixelInterval() {
+ return pixelInterval;
+ }
+
+ /**
+ * Sets pixel interval of the tick marks
+ *
+ * @param pixelInterval
+ */
+ public void setPixelInterval(Integer pixelInterval) {
+ this.pixelInterval = pixelInterval;
+ }
+
+ @Override
+ public String toString() {
+ return "Tick [placement=" + placement + ", pixelInterval="
+ + pixelInterval + ", getColor()=" + getColor()
+ + ", getLength()=" + getLength() + ", getPosition()="
+ + getPosition() + ", getWidth()=" + getWidth() + "]";
+ }
+
+ }
+
+ /**
+ * Defines attributes of minor grid lines of the chart. In order to show
+ * minor grid lines, you must specify set MinorTick for the axis also.
+ *
+ * @author Invient
+ * @see MinorTick
+ * @see Grid
+ */
+ public static class MinorGrid implements Serializable {
+ private Paint lineColor;
+ private DashStyle lineDashStyle;
+ private Integer lineWidth;
+
+ public Paint getLineColor() {
+ return lineColor;
+ }
+
+ /**
+ * Sets color of the minor grid lines
+ *
+ * @param lineColor
+ */
+ public void setLineColor(Paint lineColor) {
+ this.lineColor = lineColor;
+ }
+
+ /**
+ * @return
+ */
+ public DashStyle getLineDashStyle() {
+ return lineDashStyle;
+ }
+
+ /**
+ * Sets dash or dot style of the minor grid lines. Defaults to
+ * DashStyle.SOLID
+ *
+ * @param lineDashStyle
+ * @see DashStyle
+ */
+ public void setLineDashStyle(DashStyle lineDashStyle) {
+ this.lineDashStyle = lineDashStyle;
+ }
+
+ /**
+ * @return
+ */
+ public Integer getLineWidth() {
+ return lineWidth;
+ }
+
+ /**
+ * Sets width (in pixel) of the minor grid lines. Defaults to 1
+ *
+ * @param lineWidth
+ */
+ public void setLineWidth(Integer lineWidth) {
+ this.lineWidth = lineWidth;
+ }
+
+ @Override
+ public String toString() {
+ return "MinorGrid [lineColor=" + lineColor + ", lineDashStyle="
+ + lineDashStyle + ", lineWidth=" + lineWidth + "]";
+ }
+
+ }
+
+ /**
+ * Defines attributes of grid lines of the chart. By default, the grid
+ * lines are shown. To hide them set property lineWidth to 0.
+ *
+ * @author Invient
+ */
+ public static final class Grid extends MinorGrid {
+
+ }
+
+ protected LinkedHashSet getAllPlotBands() {
+ return plotBands;
+ }
+
+ protected void setAllPlotBands(LinkedHashSet plotBands) {
+ if (plotBands != null) {
+ this.plotBands = plotBands;
+ }
+ }
+
+ protected void addPlotBand(PlotBand plotBand) {
+ this.plotBands.add(plotBand);
+ }
+
+ protected void removePlotBand(PlotBand plotBand) {
+ this.plotBands.remove(plotBand);
+ }
+
+ /**
+ * Removes a plotband with given id.
+ *
+ * @param id
+ */
+ public void removePlotBand(String id) {
+ Iterator plotBandItr = ((LinkedHashSet) this.plotBands)
+ .iterator();
+ while (plotBandItr.hasNext()) {
+ if (plotBandItr.next().getId().equals(id)) {
+ plotBandItr.remove();
+ break;
+ }
+ }
+ }
+
+ /**
+ * @return
+ */
+ protected LinkedHashSet getAllPlotLines() {
+ return plotLines;
+ }
+
+ /**
+ * @param plotLines
+ */
+ protected void setAllPlotLines(LinkedHashSet plotLines) {
+ if (plotLines != null) {
+ this.plotLines = plotLines;
+ }
+ }
+
+ /**
+ * @param plotLine
+ */
+ protected void addPlotLine(PlotLine plotLine) {
+ this.plotLines.add(plotLine);
+ }
+
+ /**
+ * @param plotLine
+ */
+ protected void removePlotLine(PlotLine plotLine) {
+ this.plotLines.remove(plotLine);
+ }
+
+ /**
+ * @param id
+ */
+ public void removePlotLine(String id) {
+ Iterator plotLineItr = ((LinkedHashSet) this.plotLines)
+ .iterator();
+ while (plotLineItr.hasNext()) {
+ if (plotLineItr.next().getId().equals(id)) {
+ plotLineItr.remove();
+ break;
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets an id for the axis
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ *
+ */
+ public Tick getTick() {
+ return tick;
+ }
+
+ /**
+ * Sets tick for the axis
+ */
+ public void setTick(Tick tick) {
+ this.tick = tick;
+ }
+
+ /**
+ *
+ */
+ public Integer getMaxZoom() {
+ return maxZoom;
+ }
+
+ /**
+ * Sets maximum amount of zoom for this axis. For datetime axis, the
+ * maxZoom must be specified in milliseconds. For example, for a
+ * datetime axis the main unit is milliseconds. If maxZoom is set to
+ * 3600000, you can't zoom in more than to one hour. (Above example is
+ * taken from Highcharts documentation)
+ */
+ public void setMaxZoom(Integer maxZoom) {
+ this.maxZoom = maxZoom;
+ }
+
+ /**
+ *
+ */
+ public Boolean getReversed() {
+ return reversed;
+ }
+
+ /**
+ * If the argument it true then this axis will be reversed. Defaults to
+ * false.
+ */
+ public void setReversed(Boolean reversed) {
+ this.reversed = reversed;
+ }
+
+ /**
+ *
+ */
+ public Boolean getOpposite() {
+ return opposite;
+ }
+
+ /**
+ * If the argument is true then another axis on the opposite side of
+ * this axis will be displayed. The normal axis is on left side for
+ * vertical axes and bottom for horzontal axes.
+ */
+ public void setOpposite(Boolean opposite) {
+ this.opposite = opposite;
+ }
+
+ public AxisType getType() {
+ return type;
+ }
+
+ /**
+ * Sets type of this axis. Used by subclasses
+ *
+ * @param type
+ * @see NumberXAxis
+ * @see NumberYAxis
+ * @see DateTimeAxis
+ */
+ protected void setType(AxisType type) {
+ this.type = type;
+ }
+
+ public AxisTitle getTitle() {
+ return title;
+ }
+
+ /**
+ * Sets title for the axis
+ *
+ * @see AxisTitle
+ */
+ public void setTitle(AxisTitle title) {
+ this.title = title;
+ }
+
+ /**
+ * @return
+ */
+ protected AxisDataLabel getLabel() {
+ return label;
+ }
+
+ /**
+ * @param label
+ */
+ protected void setLabel(AxisDataLabel label) {
+ this.label = label;
+ }
+
+ /**
+ *
+ */
+ public Paint getAlternateGridColor() {
+ return alternateGridColor;
+ }
+
+ /**
+ * Sets a color to be used for alternate grids of the chart
+ */
+ public void setAlternateGridColor(Paint alternateGridColor) {
+ this.alternateGridColor = alternateGridColor;
+ }
+
+ /**
+ *
+ */
+ public Boolean getEndOnTick() {
+ return endOnTick;
+ }
+
+ /**
+ * If the argument is true then this axis will end on a tick.
+ */
+ public void setEndOnTick(Boolean endOnTick) {
+ this.endOnTick = endOnTick;
+ }
+
+ /**
+ *
+ */
+ public Grid getGrid() {
+ return grid;
+ }
+
+ /**
+ * Sets grid for this axis
+ *
+ * @see Grid
+ */
+ public void setGrid(Grid grid) {
+ this.grid = grid;
+ }
+
+ /**
+ *
+ */
+ public Paint getLineColor() {
+ return lineColor;
+ }
+
+ /**
+ * Sets a color for line of this axis. This line indicate this axis
+ */
+ public void setLineColor(Paint lineColor) {
+ this.lineColor = lineColor;
+ }
+
+ /**
+ *
+ */
+ public Integer getLineWidth() {
+ return lineWidth;
+ }
+
+ /**
+ * Sets width of this axis line
+ */
+ public void setLineWidth(Integer lineWidth) {
+ this.lineWidth = lineWidth;
+ }
+
+ /**
+ *
+ */
+ public Axis getLinkedTo() {
+ return linkedTo;
+ }
+
+ /**
+ * Sets another axis which is linked with this axis. The following
+ * description is copied from Highcharts API documentation
+ * http://www.highcharts.com/ref/#xAxis.
+ *
+ * When an axis is linked to a master axis, it will take the same
+ * extremes as the master, but as assigned by min or max or by
+ * setExtremes. It can be used to show additional info, or to ease
+ * reading the chart by duplicating the scales. Defaults to null.
+ */
+ public void setLinkedTo(Axis linkedTo) {
+ if (linkedTo != this) {
+ this.linkedTo = linkedTo;
+ }
+ }
+
+ /**
+ *
+ */
+ public Double getMaxPadding() {
+ return maxPadding;
+ }
+
+ public void setMaxPadding(Double maxPadding) {
+ this.maxPadding = maxPadding;
+ }
+
+ public Double getMinPadding() {
+ return minPadding;
+ }
+
+ public void setMinPadding(Double minPadding) {
+ this.minPadding = minPadding;
+ }
+
+ public MinorGrid getMinorGrid() {
+ return minorGrid;
+ }
+
+ public void setMinorGrid(MinorGrid minorGrid) {
+ this.minorGrid = minorGrid;
+ }
+
+ public MinorTick getMinorTick() {
+ return minorTick;
+ }
+
+ public void setMinorTick(MinorTick minorTick) {
+ this.minorTick = minorTick;
+ }
+
+ public Integer getOffset() {
+ return offset;
+ }
+
+ /**
+ * Sets distance of this axis from the plot area
+ */
+ public void setOffset(Integer offset) {
+ this.offset = offset;
+ }
+
+ public Boolean getShowFirstLabel() {
+ return showFirstLabel;
+ }
+
+ /**
+ * If the argument is true then the label of this axis' first tick will
+ * be displayed. Defaults to true.
+ */
+ public void setShowFirstLabel(Boolean showFirstLabel) {
+ this.showFirstLabel = showFirstLabel;
+ }
+
+ public Boolean getShowLastLabel() {
+ return showLastLabel;
+ }
+
+ /**
+ * If the argument is true then the label of this axis' last tick will
+ * be displayed. Defaults to false
+ */
+ public void setShowLastLabel(Boolean showLastLabel) {
+ this.showLastLabel = showLastLabel;
+ }
+
+ public WeekDay getStartOfWeek() {
+ return startOfWeek;
+ }
+
+ /**
+ * Sets a day to be considered as start of the week. For datetime axis,
+ * this decides where to put tick. e.g. if startOfWeek = THURSDAY then
+ * tick will be placed on every thursday.
+ */
+ public void setStartOfWeek(WeekDay startOfWeek) {
+ this.startOfWeek = startOfWeek;
+ }
+
+ public Boolean getStartOnTick() {
+ return startOnTick;
+ }
+
+ /**
+ * If the argument is true then this axis must start on a tick. Defaults
+ * to false
+ */
+ public void setStartOnTick(Boolean startOnTick) {
+ this.startOnTick = startOnTick;
+ }
+
+ public static enum WeekDay {
+ SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY;
+ }
+
+ /**
+ * Defines position of the tick marks with respect to the axis
+ * categories. It is applicable only for categorized axes.
+ *
+ * TickmarkPlacement.ON - tick mark is placed in the center of the
+ * category
+ *
+ * TickmarkPlacement.BETWEEN - tick mark is placed between categories
+ *
+ * @author Invient
+ */
+ public static enum TickmarkPlacement {
+ ON("on"), BETWEEN("between");
+ private String name;
+
+ private TickmarkPlacement(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+ }
+
+ /**
+ * Defines position of the axis ticks with respect to the axis line
+ *
+ * @author Invient
+ */
+ public static enum TickPosition {
+ OUTSIDE("outside"), INSIDE("inside");
+ private String name;
+
+ private TickPosition(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+ }
+
+ /**
+ * Defines axis types.
+ *
+ * AxisType.LINEAR -
+ *
+ * AxisType.DATETIME - For datetime axis, the values are given in date
+ * except for {@link BaseLineConfig}.pointStart and {@link BaseLineConfig}.pointInterval
+ * properties, which are specified in milliseconds.
+ *
+ * @author Invient
+ * @see NumberXAxis
+ * @see NumberYAxis
+ * @see DateTimeAxis
+ */
+ public static enum AxisType {
+ LINEAR("linear"), DATETIME("datetime");
+ private String type;
+
+ private AxisType(String type) {
+ this.type = type;
+ }
+
+ public String getName() {
+ return this.type;
+ }
+ }
+
+ public static enum AxisTitleAlign {
+ LOW("low"), MIDDLE("middle"), HIGH("high");
+ private String name;
+
+ private AxisTitleAlign(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+ }
+
+ public static final class AxisTitle implements Serializable {
+ private String text;
+ private AxisTitleAlign align;
+ private String style;
+ private Integer rotation;
+ private Integer margin;
+
+ public AxisTitle(String text) {
+ this.text = text;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public AxisTitleAlign getAlign() {
+ return align;
+ }
+
+ public void setAlign(AxisTitleAlign align) {
+ this.align = align;
+ }
+
+ public String getStyle() {
+ return style;
+ }
+
+ public void setStyle(String style) {
+ this.style = style;
+ }
+
+ public Integer getRotation() {
+ return rotation;
+ }
+
+ public void setRotation(Integer rotation) {
+ this.rotation = rotation;
+ }
+
+ public Integer getMargin() {
+ return margin;
+ }
+
+ public void setMargin(Integer margin) {
+ this.margin = margin;
+ }
+
+ }
+
+ public static final class PlotLabel implements Serializable {
+ private HorzAlign align;
+ private VertAlign vertAlign;
+ private Integer rotation;
+ private String style;
+ private HorzAlign textAlign;
+ private Integer x;
+ private Integer y;
+ private String text;
+
+ public PlotLabel(String text) {
+ super();
+ this.text = text;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public HorzAlign getAlign() {
+ return align;
+ }
+
+ public void setAlign(HorzAlign align) {
+ this.align = align;
+ }
+
+ public VertAlign getVertAlign() {
+ return vertAlign;
+ }
+
+ public void setVertAlign(VertAlign vertAlign) {
+ this.vertAlign = vertAlign;
+ }
+
+ public Integer getRotation() {
+ return rotation;
+ }
+
+ public void setRotation(Integer rotation) {
+ this.rotation = rotation;
+ }
+
+ public String getStyle() {
+ return style;
+ }
+
+ public void setStyle(String style) {
+ this.style = style;
+ }
+
+ public HorzAlign getTextAlign() {
+ return textAlign;
+ }
+
+ public void setTextAlign(HorzAlign textAlign) {
+ this.textAlign = textAlign;
+ }
+
+ public Integer getX() {
+ return x;
+ }
+
+ public void setX(Integer x) {
+ this.x = x;
+ }
+
+ public Integer getY() {
+ return y;
+ }
+
+ public void setY(Integer y) {
+ this.y = y;
+ }
+
+ }
+
+ public static abstract class PlotBand implements Serializable {
+ private Paint color;
+ private Range range;
+ private String id;
+ private Integer zIndex;
+ private PlotLabel label;
+
+ public PlotBand(String id) {
+ this.id = id;
+ }
+
+ public Paint getColor() {
+ return color;
+ }
+
+ public void setColor(Paint color) {
+ this.color = color;
+ }
+
+ protected Range getRange() {
+ return range;
+ }
+
+ protected void setRange(Range range) {
+ this.range = range;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public Integer getZIndex() {
+ return zIndex;
+ }
+
+ public void setZIndex(Integer zIndex) {
+ this.zIndex = zIndex;
+ }
+
+ public PlotLabel getLabel() {
+ return label;
+ }
+
+ public void setLabel(PlotLabel label) {
+ this.label = label;
+ }
+
+ public static abstract class Range implements Serializable {
+
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ PlotBand other = (PlotBand) obj;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ return true;
+ }
+
+ }
+
+ public static final class NumberPlotBand extends PlotBand {
+
+ public NumberPlotBand(String id) {
+ super(id);
+ }
+
+ public NumberRange getRange() {
+ return (NumberRange) super.getRange();
+ }
+
+ public void setRange(NumberRange range) {
+ super.setRange((NumberRange) range);
+ }
+
+ public static final class NumberRange extends Range {
+ private Double from;
+ private Double to;
+
+ public NumberRange(Double from, Double to) {
+ super();
+ this.from = from;
+ this.to = to;
+ }
+
+ public Double getFrom() {
+ return from;
+ }
+
+ public void setFrom(Double from) {
+ this.from = from;
+ }
+
+ public Double getTo() {
+ return to;
+ }
+
+ public void setTo(Double to) {
+ this.to = to;
+ }
+ }
+ }
+
+ public static final class DateTimePlotBand extends PlotBand {
+
+ public DateTimePlotBand(String id) {
+ super(id);
+ }
+
+ public DateTimeRange getRange() {
+ return (DateTimeRange) super.getRange();
+ }
+
+ public void setRange(DateTimeRange range) {
+ super.setRange((DateTimeRange) range);
+ }
+
+ public static final class DateTimeRange extends Range {
+ private Date from;
+ private Date to;
+
+ public DateTimeRange(Date from, Date to) {
+ super();
+ this.from = from;
+ this.to = to;
+ }
+
+ public Date getFrom() {
+ return from;
+ }
+
+ public void setFrom(Date from) {
+ this.from = from;
+ }
+
+ public Date getTo() {
+ return to;
+ }
+
+ public void setTo(Date to) {
+ this.to = to;
+ }
+ }
+
+ }
+
+ public static abstract class PlotLine implements Serializable {
+ private Paint color;
+ private DashStyle dashStyle;
+ private String id;
+ private Value value;
+ private Integer width = 1;
+ private Integer zIndex;
+ private PlotLabel label;
+
+ public PlotLine(String id) {
+ this.id = id;
+ }
+
+ public Paint getColor() {
+ return color;
+ }
+
+ public void setColor(Paint color) {
+ this.color = color;
+ }
+
+ public DashStyle getDashStyle() {
+ return dashStyle;
+ }
+
+ public void setDashStyle(DashStyle dashStyle) {
+ this.dashStyle = dashStyle;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ protected Value getValue() {
+ return value;
+ }
+
+ protected void setValue(Value value) {
+ this.value = value;
+ }
+
+ public Integer getWidth() {
+ return width;
+ }
+
+ public void setWidth(Integer width) {
+ this.width = width;
+ }
+
+ public Integer getZIndex() {
+ return zIndex;
+ }
+
+ public void setZIndex(Integer zIndex) {
+ this.zIndex = zIndex;
+ }
+
+ public PlotLabel getLabel() {
+ return label;
+ }
+
+ public void setLabel(PlotLabel label) {
+ this.label = label;
+ }
+
+ public static abstract class Value implements Serializable {
+
+ }
+
+ }
+
+ public static final class NumberPlotLine extends PlotLine {
+
+ public NumberPlotLine(String id) {
+ super(id);
+ }
+
+ public NumberValue getValue() {
+ return (NumberValue) super.getValue();
+ }
+
+ public void setValue(NumberValue value) {
+ super.setValue((NumberValue) value);
+ }
+
+ public static final class NumberValue extends Value {
+
+ public NumberValue(Double value) {
+ super();
+ this.value = value;
+ }
+
+ private Double value;
+
+ public Double getValue() {
+ return value;
+ }
+
+ public void setValue(Double value) {
+ this.value = value;
+ }
+ }
+ }
+
+ public static final class DateTimePlotLine extends PlotLine {
+ public DateTimePlotLine(String id) {
+ super(id);
+ }
+
+ public DateTimeValue getValue() {
+ return (DateTimeValue) super.getValue();
+ }
+
+ public void setValue(DateTimeValue value) {
+ super.setValue((DateTimeValue) value);
+ }
+
+ public static final class DateTimeValue extends Value {
+ private Date value;
+
+ public DateTimeValue(Date value) {
+ super();
+ this.value = value;
+ }
+
+ public Date getValue() {
+ return value;
+ }
+
+ public void setValue(Date value) {
+ this.value = value;
+ }
+ }
+ }
+ }
+
+ public static interface Axis extends Serializable {
+
+ public String getId();
+
+ public void setId(String id);
+
+ public Tick getTick();
+
+ public void setTick(Tick tick);
+
+ public Integer getMaxZoom();
+
+ public void setMaxZoom(Integer maxZoom);
+
+ public Boolean getReversed();
+
+ public void setReversed(Boolean reversed);
+
+ public Boolean getOpposite();
+
+ public void setOpposite(Boolean opposite);
+
+ public AxisType getType();
+
+ public AxisTitle getTitle();
+
+ public void setTitle(AxisTitle title);
+
+ public Paint getAlternateGridColor();
+
+ public void setAlternateGridColor(Paint alternateGridColor);
+
+ public Boolean getEndOnTick();
+
+ public void setEndOnTick(Boolean endOnTick);
+
+ public Grid getGrid();
+
+ public void setGrid(Grid grid);
+
+ public Paint getLineColor();
+
+ public void setLineColor(Paint lineColor);
+
+ public Integer getLineWidth();
+
+ public void setLineWidth(Integer lineWidth);
+
+ public Axis getLinkedTo();
+
+ public void setLinkedTo(Axis linkedTo);
+
+ public Double getMaxPadding();
+
+ public void setMaxPadding(Double maxPadding);
+
+ public Double getMinPadding();
+
+ public void setMinPadding(Double minPadding);
+
+ public MinorGrid getMinorGrid();
+
+ public void setMinorGrid(MinorGrid minorGrid);
+
+ public MinorTick getMinorTick();
+
+ public void setMinorTick(MinorTick minorTick);
+
+ public Integer getOffset();
+
+ public void setOffset(Integer offset);
+
+ public Boolean getShowFirstLabel();
+
+ public void setShowFirstLabel(Boolean showFirstLabel);
+
+ public Boolean getShowLastLabel();
+
+ public void setShowLastLabel(Boolean showLastLabel);
+
+ public WeekDay getStartOfWeek();
+
+ public void setStartOfWeek(WeekDay startOfWeek);
+
+ public Boolean getStartOnTick();
+
+ public void setStartOnTick(Boolean startOnTick);
+
+ }
+
+ public static interface XAxis extends Axis {
+ }
+
+ public static interface YAxis extends Axis {
+ }
+
+ public static abstract class NumberAxis extends AxisBase {
+ private Boolean allowDecimals;
+ private Double max;
+ private Double min;
+
+ public NumberAxis() {
+ super.setType(AxisType.LINEAR);
+ }
+
+ public Boolean getAllowDecimals() {
+ return allowDecimals;
+ }
+
+ public void setAllowDecimals(Boolean allowDecimals) {
+ this.allowDecimals = allowDecimals;
+ }
+
+ public void setMax(Double max) {
+ this.max = max;
+ }
+
+ public void setMin(Double min) {
+ this.min = min;
+ }
+
+ public Double getMin() {
+ return this.min;
+ }
+
+ public Double getMax() {
+ return this.max;
+ }
+
+ public LinkedHashSet getPlotBands() {
+ return super.getAllPlotBands();
+ }
+
+ public void setPlotBands(LinkedHashSet plotBands) {
+ super.setAllPlotBands(plotBands);
+ }
+
+ public void addPlotBand(NumberPlotBand plotBand) {
+ super.addPlotBand(plotBand);
+ }
+
+ public void removePlotBand(NumberPlotBand plotBand) {
+ super.removePlotBand(plotBand);
+ }
+
+ public LinkedHashSet getPlotLines() {
+ return super.getAllPlotLines();
+ }
+
+ public void setPlotLines(LinkedHashSet plotLines) {
+ super.setAllPlotLines(plotLines);
+ }
+
+ public void addPlotLine(NumberPlotLine plotLine) {
+ super.addPlotLine(plotLine);
+ }
+
+ public void removePlotLine(NumberPlotLine plotLine) {
+ super.removePlotLine(plotLine);
+ }
+
+ }
+
+ public static final class NumberXAxis extends NumberAxis implements XAxis {
+
+ public void setLabel(XAxisDataLabel label) {
+ super.setLabel(label);
+ }
+
+ public XAxisDataLabel getLabel() {
+ return (XAxisDataLabel) super.getLabel();
+ }
+ }
+
+ public static final class NumberYAxis extends NumberAxis implements YAxis {
+ public void setLabel(YAxisDataLabel label) {
+ super.setLabel(label);
+ }
+
+ public YAxisDataLabel getLabel() {
+ return (YAxisDataLabel) super.getLabel();
+ }
+
+ }
+
+ public static final class DateTimeAxis extends AxisBase implements XAxis {
+ private DateTimeLabelFormat dateTimeLabelFormats;
+ private Date max;
+ private Date min;
+
+ // private Date tickInterval; // FIXME It should be more intuitive to
+ // specify tick interval such as
+ // Month, Week, day, year similar to
+ // private Date minorTickInterval;
+
+ public static final class DateTimeLabelFormat {
+ private String millisecond = "%H:%M:%S.%L";
+ private String second = "%H:%M:%S";
+ private String minute = "%H:%M";
+ private String hour = "%H:%M";
+ private String day = "%e. %b";
+ private String week = "%e. %b";
+ private String month = "%b '%y";
+ private String year = "%Y";
+
+ public String getMillisecond() {
+ return millisecond;
+ }
+
+ public void setMillisecond(String millisecond) {
+ this.millisecond = millisecond;
+ }
+
+ public String getSecond() {
+ return second;
+ }
+
+ public void setSecond(String second) {
+ this.second = second;
+ }
+
+ public String getMinute() {
+ return minute;
+ }
+
+ public void setMinute(String minute) {
+ this.minute = minute;
+ }
+
+ public String getHour() {
+ return hour;
+ }
+
+ public void setHour(String hour) {
+ this.hour = hour;
+ }
+
+ public String getDay() {
+ return day;
+ }
+
+ public void setDay(String day) {
+ this.day = day;
+ }
+
+ public String getWeek() {
+ return week;
+ }
+
+ public void setWeek(String week) {
+ this.week = week;
+ }
+
+ public String getMonth() {
+ return month;
+ }
+
+ public void setMonth(String month) {
+ this.month = month;
+ }
+
+ public String getYear() {
+ return year;
+ }
+
+ public void setYear(String year) {
+ this.year = year;
+ }
+
+ @Override
+ public String toString() {
+ return "DateTimeLabelFormat [second=" + second + ", minute="
+ + minute + ", hour=" + hour + ", day=" + day
+ + ", week=" + week + ", month=" + month + ", year="
+ + year + "]";
+ }
+
+ }
+
+ public DateTimeAxis() {
+ super.setType(AxisType.DATETIME);
+ }
+
+ public DateTimeLabelFormat getDateTimeLabelFormat() {
+ return dateTimeLabelFormats;
+ }
+
+ public void setDateTimeLabelFormat(
+ DateTimeLabelFormat dateTimeLabelFormat) {
+ this.dateTimeLabelFormats = dateTimeLabelFormat;
+ }
+
+ public void setMax(Date max) {
+ this.max = max;
+ }
+
+ public void setMin(Date min) {
+ this.min = min;
+ }
+
+ public Date getMin() {
+ return this.min;
+ }
+
+ public Date getMax() {
+ return this.max;
+ }
+
+ public LinkedHashSet getPlotBands() {
+ return super.getAllPlotBands();
+ }
+
+ public void setPlotBands(LinkedHashSet plotBands) {
+ super.setAllPlotBands(plotBands);
+ }
+
+ public void addPlotBand(DateTimePlotBand plotBand) {
+ super.addPlotBand(plotBand);
+ }
+
+ public void removePlotBand(DateTimePlotBand plotBand) {
+ super.removePlotBand(plotBand);
+ }
+
+ public LinkedHashSet getPlotLines() {
+ return super.getAllPlotLines();
+ }
+
+ public void setPlotLines(LinkedHashSet plotLines) {
+ super.setAllPlotLines(plotLines);
+ }
+
+ public void addPlotLine(DateTimePlotLine plotLine) {
+ super.addPlotLine(plotLine);
+ }
+
+ public void removePlotLine(DateTimePlotLine plotLine) {
+ super.removePlotLine(plotLine);
+ }
+
+ }
+
+ public static final class CategoryAxis extends AxisBase implements XAxis {
+ private List categories = new ArrayList();
+
+ public List getCategories() {
+ return categories;
+ }
+
+ public void setCategories(List categories) {
+ if (categories != null) {
+ this.categories = categories;
+ }
+ }
+
+ public void setLabel(XAxisDataLabel label) {
+ super.setLabel(label);
+ }
+
+ public XAxisDataLabel getLabel() {
+ return (XAxisDataLabel) super.getLabel();
+ }
+
+ public LinkedHashSet getPlotBands() {
+ return super.getAllPlotBands();
+ }
+
+ public void setPlotBands(LinkedHashSet plotBands) {
+ super.setAllPlotBands(plotBands);
+ }
+
+ public void addPlotBand(NumberPlotBand plotBand) {
+ super.addPlotBand(plotBand);
+ }
+
+ public void removePlotBand(NumberPlotBand plotBand) {
+ super.removePlotBand(plotBand);
+ }
+
+ public LinkedHashSet getPlotLines() {
+ return super.getAllPlotLines();
+ }
+
+ public void setPlotLines(LinkedHashSet plotLines) {
+ super.setAllPlotLines(plotLines);
+ }
+
+ public void addPlotLine(NumberPlotLine plotLine) {
+ super.addPlotLine(plotLine);
+ }
+
+ public void removePlotLine(NumberPlotLine plotLine) {
+ super.removePlotLine(plotLine);
+ }
+ }
+
+ // Legend
+ public static final class Legend implements Serializable {
+ private Paint backgroundColor;
+ private Paint borderColor;
+ private Integer borderRadius;
+ private Integer borderWidth;
+ private Boolean enabled;
+ private Boolean floating;
+ private String itemHiddenStyle;
+ private String itemHoverStyle;
+ private String itemStyle;
+ private Integer itemWidth;
+ private Layout layout;
+ private String labelFormatterJsFunc;
+ private Integer margin;
+ private Boolean reversed;
+ private Boolean shadow;
+ private Integer symbolPadding;
+ private Integer symbolWidth;
+ private Integer width;
+ private Position position;
+
+ public Legend() {
+ }
+
+ public Legend(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public static enum Layout {
+ HORIZONTAL("horizontal"), VERTICAL("vertical");
+ private String name;
+
+ private Layout(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+ }
+
+ public Paint getBackgroundColor() {
+ return backgroundColor;
+ }
+
+ public void setBackgroundColor(Paint backgroundColor) {
+ this.backgroundColor = backgroundColor;
+ }
+
+ public Paint getBorderColor() {
+ return borderColor;
+ }
+
+ public void setBorderColor(Paint borderColor) {
+ this.borderColor = borderColor;
+ }
+
+ public Integer getBorderRadius() {
+ return borderRadius;
+ }
+
+ public void setBorderRadius(Integer borderRadius) {
+ this.borderRadius = borderRadius;
+ }
+
+ public Integer getBorderWidth() {
+ return borderWidth;
+ }
+
+ public void setBorderWidth(Integer borderWidth) {
+ this.borderWidth = borderWidth;
+ }
+
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public Boolean getFloating() {
+ return floating;
+ }
+
+ public void setFloating(Boolean floating) {
+ this.floating = floating;
+ }
+
+ public String getItemHiddenStyle() {
+ return itemHiddenStyle;
+ }
+
+ public void setItemHiddenStyle(String itemHiddenStyle) {
+ this.itemHiddenStyle = itemHiddenStyle;
+ }
+
+ public String getItemHoverStyle() {
+ return itemHoverStyle;
+ }
+
+ public void setItemHoverStyle(String itemHoverStyle) {
+ this.itemHoverStyle = itemHoverStyle;
+ }
+
+ public String getItemStyle() {
+ return itemStyle;
+ }
+
+ public void setItemStyle(String itemStyle) {
+ this.itemStyle = itemStyle;
+ }
+
+ public Integer getItemWidth() {
+ return itemWidth;
+ }
+
+ public void setItemWidth(Integer itemWidth) {
+ this.itemWidth = itemWidth;
+ }
+
+ public Layout getLayout() {
+ return layout;
+ }
+
+ public void setLayout(Layout layout) {
+ this.layout = layout;
+ }
+
+ public String getLabelFormatterJsFunc() {
+ return labelFormatterJsFunc;
+ }
+
+ public void setLabelFormatterJsFunc(String labelFormatterJsFunc) {
+ this.labelFormatterJsFunc = labelFormatterJsFunc;
+ }
+
+ public Integer getMargin() {
+ return margin;
+ }
+
+ public void setMargin(Integer margin) {
+ this.margin = margin;
+ }
+
+ public Boolean getReversed() {
+ return reversed;
+ }
+
+ public void setReversed(Boolean reversed) {
+ this.reversed = reversed;
+ }
+
+ public Boolean getShadow() {
+ return shadow;
+ }
+
+ public void setShadow(Boolean shadow) {
+ this.shadow = shadow;
+ }
+
+ public Integer getSymbolPadding() {
+ return symbolPadding;
+ }
+
+ public void setSymbolPadding(Integer symbolPadding) {
+ this.symbolPadding = symbolPadding;
+ }
+
+ public Integer getSymbolWidth() {
+ return symbolWidth;
+ }
+
+ public void setSymbolWidth(Integer symbolWidth) {
+ this.symbolWidth = symbolWidth;
+ }
+
+ public Integer getWidth() {
+ return width;
+ }
+
+ public void setWidth(Integer width) {
+ this.width = width;
+ }
+
+ public Position getPosition() {
+ return position;
+ }
+
+ public void setPosition(Position position) {
+ this.position = position;
+ }
+
+ @Override
+ public String toString() {
+ return "Legend [backgroundColor=" + backgroundColor
+ + ", borderColor=" + borderColor + ", borderRadius="
+ + borderRadius + ", borderWidth=" + borderWidth
+ + ", enabled=" + enabled + ", floating=" + floating
+ + ", itemHiddenStyle=" + itemHiddenStyle
+ + ", itemHoverStyle=" + itemHoverStyle + ", itemStyle="
+ + itemStyle + ", itemWidth=" + itemWidth + ", layout="
+ + layout + ", labelFormatter=" + labelFormatterJsFunc
+ + ", margin=" + margin + ", reversed=" + reversed
+ + ", shadow=" + shadow + ", symbolPadding=" + symbolPadding
+ + ", symbolWidth=" + symbolWidth + ", width=" + width
+ + ", position=" + position + "]";
+ }
+
+ }
+
+ // Credits
+ public static final class Credit implements Serializable {
+ private Boolean enabled;
+ private String link;
+ private String style;
+ private String text;
+ private Position position;
+
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public String getLink() {
+ return link;
+ }
+
+ public void setLink(String link) {
+ this.link = link;
+ }
+
+ public String getStyle() {
+ return style;
+ }
+
+ public void setStyle(String style) {
+ this.style = style;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public Position getPosition() {
+ return position;
+ }
+
+ public void setPosition(Position position) {
+ this.position = position;
+ }
+
+ @Override
+ public String toString() {
+ return "Credit [enabled=" + enabled + ", link=" + link + ", style="
+ + style + ", text=" + text + ", position=" + position + "]";
+ }
+ }
+
+ public static final class Position implements Serializable {
+ private HorzAlign align;
+ private VertAlign vertAlign;
+ private Integer x;
+ private Integer y;
+
+ public HorzAlign getAlign() {
+ return align;
+ }
+
+ public void setAlign(HorzAlign align) {
+ this.align = align;
+ }
+
+ public VertAlign getVertAlign() {
+ return vertAlign;
+ }
+
+ public void setVertAlign(VertAlign vertAlign) {
+ this.vertAlign = vertAlign;
+ }
+
+ public Integer getX() {
+ return x;
+ }
+
+ public void setX(Integer x) {
+ this.x = x;
+ }
+
+ public Integer getY() {
+ return y;
+ }
+
+ public void setY(Integer y) {
+ this.y = y;
+ }
+
+ @Override
+ public String toString() {
+ return "Position [align=" + align + ", vertAlign=" + vertAlign
+ + ", x=" + x + ", y=" + y + "]";
+ }
+
+ }
+
+ // Tooltip
+ public static final class Tooltip implements Serializable {
+ private Paint backgroundColor;
+ private Paint borderColor;
+ private Integer borderRadius;
+ private Integer borderWidth;
+ private Crosshairs crosshairs;
+ private Boolean enabled;
+ private String formatterJsFunc;
+ private Boolean shadow;
+ private Boolean shared;
+ private Integer snap; // NA for pie/bar/column
+ private String style;
+ private Boolean useHTML;
+ private String headerFormat;
+ private String pointFormat;
+ private String footerFormat;
+
+ public String getHeaderFormat() {
+ return headerFormat;
+ }
+
+ public void setHeaderFormat(String headerFormat) {
+ this.headerFormat = headerFormat;
+ }
+
+ public String getPointFormat() {
+ return pointFormat;
+ }
+
+ public void setPointFormat(String pointFormat) {
+ this.pointFormat = pointFormat;
+ }
+
+ public String getFooterFormat() {
+ return footerFormat;
+ }
+
+ public void setFooterFormat(String footerFormat) {
+ this.footerFormat = footerFormat;
+ }
+
+ public Boolean getUseHTML() {
+ return useHTML;
+ }
+
+ public void setUseHTML(Boolean useHTML) {
+ this.useHTML = useHTML;
+ }
+
+ public Paint getBackgroundColor() {
+ return backgroundColor;
+ }
+
+ public void setBackgroundColor(Paint backgroundColor) {
+ this.backgroundColor = backgroundColor;
+ }
+
+ public Paint getBorderColor() {
+ return borderColor;
+ }
+
+ public void setBorderColor(Paint borderColor) {
+ this.borderColor = borderColor;
+ }
+
+ public Integer getBorderRadius() {
+ return borderRadius;
+ }
+
+ public void setBorderRadius(Integer borderRadius) {
+ this.borderRadius = borderRadius;
+ }
+
+ public Integer getBorderWidth() {
+ return borderWidth;
+ }
+
+ public void setBorderWidth(Integer borderWidth) {
+ this.borderWidth = borderWidth;
+ }
+
+ public Crosshairs getCrosshairs() {
+ return crosshairs;
+ }
+
+ public void setCrosshairs(Crosshairs crosshairs) {
+ this.crosshairs = crosshairs;
+ }
+
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public String getFormatterJsFunc() {
+ return formatterJsFunc;
+ }
+
+ public void setFormatterJsFunc(String formatterJsFunc) {
+ this.formatterJsFunc = formatterJsFunc;
+ }
+
+ public Boolean getShadow() {
+ return shadow;
+ }
+
+ public void setShadow(Boolean shadow) {
+ this.shadow = shadow;
+ }
+
+ public Boolean getShared() {
+ return shared;
+ }
+
+ public void setShared(Boolean shared) {
+ this.shared = shared;
+ }
+
+ public Integer getSnap() {
+ return snap;
+ }
+
+ public void setSnap(Integer snap) {
+ this.snap = snap;
+ }
+
+ public String getStyle() {
+ return style;
+ }
+
+ public void setStyle(String style) {
+ this.style = style;
+ }
+
+ @Override
+ public String toString() {
+ return "Tooltip [backgroundColor=" + backgroundColor
+ + ", borderColor=" + borderColor + ", borderRadius="
+ + borderRadius + ", borderWidth=" + borderWidth
+ + ", crosshairs=" + crosshairs + ", enabled=" + enabled
+ + ", formatter=" + formatterJsFunc + ", shadow=" + shadow
+ + ", shared=" + shared + ", snap=" + snap + ", style="
+ + style + "]";
+ }
+
+ public static class Crosshairs {
+ private Double width;
+ private Paint color;
+ private DashStyle dashStyle;
+ private Integer zIndex;
+
+ public Double getWidth() {
+ return width;
+ }
+
+ public void setWidth(Double width) {
+ this.width = width;
+ }
+
+ public Paint getColor() {
+ return color;
+ }
+
+ public void setColor(Paint color) {
+ this.color = color;
+ }
+
+ public DashStyle getDashStyle() {
+ return dashStyle;
+ }
+
+ public void setDashStyle(DashStyle dashStyle) {
+ this.dashStyle = dashStyle;
+ }
+
+ public Integer getzIndex() {
+ return zIndex;
+ }
+
+ public void setzIndex(Integer zIndex) {
+ this.zIndex = zIndex;
+ }
+
+ @Override
+ public String toString() {
+ return "Crosshairs{" +
+ "width=" + width +
+ ", color=" + color +
+ ", dashStyle=" + dashStyle +
+ ", zIndex=" + zIndex +
+ '}';
+ }
+ }
+ }
+}
diff --git a/src/com/invient/vaadin/charts/InvientChartsUtil.java b/invient-charts/src/main/java/com/invient/vaadin/charts/InvientChartsUtil.java
old mode 100755
new mode 100644
similarity index 85%
rename from src/com/invient/vaadin/charts/InvientChartsUtil.java
rename to invient-charts/src/main/java/com/invient/vaadin/charts/InvientChartsUtil.java
index 49e48cf..ff25ba4
--- a/src/com/invient/vaadin/charts/InvientChartsUtil.java
+++ b/invient-charts/src/main/java/com/invient/vaadin/charts/InvientChartsUtil.java
@@ -1,2055 +1,2055 @@
-/*
- * Copyright 2011 Invient (www.invient.com)
- *
- * 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 com.invient.vaadin.charts;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import com.vaadin.terminal.PaintException;
-import com.vaadin.terminal.PaintTarget;
-
-import com.invient.vaadin.charts.InvientCharts.DateTimeSeries;
-import com.invient.vaadin.charts.InvientCharts.DecimalPoint;
-import com.invient.vaadin.charts.InvientCharts.Point;
-import com.invient.vaadin.charts.InvientCharts.Series;
-import com.invient.vaadin.charts.InvientCharts.SeriesCUR;
-import com.invient.vaadin.charts.InvientCharts.SeriesType;
-import com.invient.vaadin.charts.InvientChartsConfig.AreaConfig;
-import com.invient.vaadin.charts.InvientChartsConfig.AreaSplineConfig;
-import com.invient.vaadin.charts.InvientChartsConfig.Axis;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.AxisTitle;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.DateTimePlotBand.DateTimeRange;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.DateTimePlotLine.DateTimeValue;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.Grid;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.MinorGrid;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.MinorTick;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.NumberPlotBand.NumberRange;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.NumberPlotLine.NumberValue;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.PlotBand;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.PlotBand.Range;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.PlotLabel;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.PlotLine;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.PlotLine.Value;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.Tick;
-import com.invient.vaadin.charts.InvientChartsConfig.AxisDataLabel;
-import com.invient.vaadin.charts.InvientChartsConfig.BarConfig;
-import com.invient.vaadin.charts.InvientChartsConfig.BaseBarConfig;
-import com.invient.vaadin.charts.InvientChartsConfig.BaseLineConfig;
-import com.invient.vaadin.charts.InvientChartsConfig.CategoryAxis;
-import com.invient.vaadin.charts.InvientChartsConfig.ChartLabel;
-import com.invient.vaadin.charts.InvientChartsConfig.ChartLabel.ChartLabelItem;
-import com.invient.vaadin.charts.InvientChartsConfig.ColumnConfig;
-import com.invient.vaadin.charts.InvientChartsConfig.Credit;
-import com.invient.vaadin.charts.InvientChartsConfig.DataLabel;
-import com.invient.vaadin.charts.InvientChartsConfig.DateTimeAxis;
-import com.invient.vaadin.charts.InvientChartsConfig.DateTimeAxis.DateTimeLabelFormat;
-import com.invient.vaadin.charts.InvientChartsConfig.GeneralChartConfig;
-import com.invient.vaadin.charts.InvientChartsConfig.ImageMarker;
-import com.invient.vaadin.charts.InvientChartsConfig.Legend;
-import com.invient.vaadin.charts.InvientChartsConfig.LineConfig;
-import com.invient.vaadin.charts.InvientChartsConfig.Marker;
-import com.invient.vaadin.charts.InvientChartsConfig.MarkerState;
-import com.invient.vaadin.charts.InvientChartsConfig.NonLinearSeriesState;
-import com.invient.vaadin.charts.InvientChartsConfig.NumberAxis;
-import com.invient.vaadin.charts.InvientChartsConfig.NumberXAxis;
-import com.invient.vaadin.charts.InvientChartsConfig.NumberYAxis;
-import com.invient.vaadin.charts.InvientChartsConfig.PieConfig;
-import com.invient.vaadin.charts.InvientChartsConfig.PieDataLabel;
-import com.invient.vaadin.charts.InvientChartsConfig.ScatterConfig;
-import com.invient.vaadin.charts.InvientChartsConfig.SeriesConfig;
-import com.invient.vaadin.charts.InvientChartsConfig.SeriesState;
-import com.invient.vaadin.charts.InvientChartsConfig.SplineConfig;
-import com.invient.vaadin.charts.InvientChartsConfig.SubTitle;
-import com.invient.vaadin.charts.InvientChartsConfig.SymbolMarker;
-import com.invient.vaadin.charts.InvientChartsConfig.Title;
-import com.invient.vaadin.charts.InvientChartsConfig.TitleBase;
-import com.invient.vaadin.charts.InvientChartsConfig.Tooltip;
-import com.invient.vaadin.charts.InvientChartsConfig.XAxis;
-import com.invient.vaadin.charts.InvientChartsConfig.XAxisDataLabel;
-import com.invient.vaadin.charts.InvientChartsConfig.YAxis;
-import com.invient.vaadin.charts.InvientChartsConfig.YAxisDataLabel;
-
-/**
- * A utility class used by {@link InvientCharts} to write its state to the UIDL
- * stream. The state includes properties of {@link InvientCharts} such as
- * {@link InvientChartsConfig}, {@link Series}, {@link Point} and various chart
- * events.
- *
- * In general, only non-null properties/attributes of a chart are written to the
- * UIDL stream.
- *
- * @author Invient
- *
- */
-final class InvientChartsUtil {
-
- private InvientChartsUtil() {
- throw new RuntimeException("This class cannot be instantiated.");
- }
-
- /**
- * Writes configuration attributes common to chart title and subtitle.
- *
- * @param target
- * @param titleBaseOptions
- * @throws PaintException
- */
- private static void writeTitleBaseOptions(PaintTarget target,
- TitleBase titleBaseOptions) throws PaintException {
- if (titleBaseOptions.getText() != null) {
- target.addAttribute("text", titleBaseOptions.getText());
- }
- if (titleBaseOptions.getX() != null) {
- target.addAttribute("x", titleBaseOptions.getX());
- }
- if (titleBaseOptions.getY() != null) {
- target.addAttribute("y", titleBaseOptions.getY());
- }
- if (titleBaseOptions.getFloating() != null) {
- target.addAttribute("floating", titleBaseOptions.getFloating());
- }
-
- if (titleBaseOptions.getAlign() != null) {
- target.addAttribute("align", titleBaseOptions.getAlign().getName());
- }
- if (titleBaseOptions.getVertAlign() != null) {
- target.addAttribute("verticalAlign", titleBaseOptions
- .getVertAlign().getName());
- }
- if(titleBaseOptions.getStyle() != null) {
- target.addAttribute("style", titleBaseOptions.getStyle());
- }
- }
-
- /**
- * Writes configuration attributes of the chart title.
- *
- * @param target
- * @param titleOptions
- * @throws PaintException
- */
- public static void writeTitleConfig(PaintTarget target, Title titleOptions)
- throws PaintException {
- target.startTag("title");
- writeTitleBaseOptions(target, titleOptions);
- if (titleOptions.getMargin() != null) {
- target.addAttribute("margin", titleOptions.getMargin());
- }
- target.endTag("title");
- }
-
- /**
- * Writes configuration attributes of the chart subtitle. Only those
- * attributes are written who have got non-null values.
- *
- * @param target
- * @param subtitleOptions
- * @throws PaintException
- */
- public static void writeSubtitleConfig(PaintTarget target,
- SubTitle subtitleOptions) throws PaintException {
- target.startTag("subtitle");
- writeTitleBaseOptions(target, subtitleOptions);
- target.endTag("subtitle");
- }
-
- /**
- * Writes configuration attributes of the chart subtitle.
- *
- * @param target
- * @param creditOptions
- * @throws PaintException
- */
- public static void writeCreditConfig(PaintTarget target,
- Credit creditOptions) throws PaintException {
- target.startTag("credit");
-
- if (creditOptions.getEnabled() != null) {
- target.addAttribute("enabled", creditOptions.getEnabled());
- }
- target.startTag("position");
- if (creditOptions.getPosition() != null) {
- if (creditOptions.getPosition().getAlign() != null) {
- target.addAttribute("align", creditOptions.getPosition()
- .getAlign().getName());
- }
- if (creditOptions.getPosition().getVertAlign() != null) {
- target.addAttribute("verticalAlign", creditOptions
- .getPosition().getVertAlign().getName());
- }
- if (creditOptions.getPosition().getX() != null) {
- target.addAttribute("x", creditOptions.getPosition().getX());
- }
- if (creditOptions.getPosition().getY() != null) {
- target.addAttribute("y", creditOptions.getPosition().getY());
- }
- }
- target.endTag("position");
-
- if (creditOptions.getLink() != null) {
- target.addAttribute("href", creditOptions.getLink());
- }
- if (creditOptions.getStyle() != null) {
- target.addAttribute("style", creditOptions.getStyle());
- }
- if (creditOptions.getText() != null) {
- target.addAttribute("text", creditOptions.getText());
- }
- target.endTag("credit");
- }
-
- /**
- * Writes configuration attributes of the chart legend.
- *
- * @param target
- * @param legendOptions
- * @throws PaintException
- */
- public static void writeLegendConfig(PaintTarget target,
- Legend legendOptions) throws PaintException {
- target.startTag("legend");
-
- if (legendOptions.getBackgroundColor() != null) {
- target.addAttribute("backgroundColor", legendOptions
- .getBackgroundColor().getString());
- }
-
- if (legendOptions.getBorderColor() != null) {
- target.addAttribute("borderColor", legendOptions.getBorderColor()
- .getString());
- }
-
- if (legendOptions.getBorderRadius() != null) {
- target.addAttribute("borderRadius", legendOptions.getBorderRadius());
- }
-
- if (legendOptions.getBorderWidth() != null) {
- target.addAttribute("borderWidth", legendOptions.getBorderWidth());
- }
-
- if (legendOptions.getEnabled() != null) {
- target.addAttribute("enabled", legendOptions.getEnabled());
- }
-
- if (legendOptions.getFloating() != null) {
- target.addAttribute("floating", legendOptions.getFloating());
- }
-
- if (legendOptions.getItemHiddenStyle() != null) {
- target.addAttribute("itemHiddenStyle",
- legendOptions.getItemHiddenStyle());
- }
-
- if (legendOptions.getItemHoverStyle() != null) {
- target.addAttribute("itemHoverStyle",
- legendOptions.getItemHoverStyle());
- }
-
- if (legendOptions.getItemStyle() != null) {
- target.addAttribute("itemStyle", legendOptions.getItemStyle());
- }
-
- if (legendOptions.getItemWidth() != null) {
- target.addAttribute("itemWidth", legendOptions.getItemWidth());
- }
-
- if (legendOptions.getLayout() != null) {
- target.addAttribute("layout", legendOptions.getLayout().getName());
- }
-
- if (legendOptions.getLabelFormatterJsFunc() != null) {
- target.addAttribute("labelFormatter",
- legendOptions.getLabelFormatterJsFunc());
- }
-
- if (legendOptions.getMargin() != null) {
- target.addAttribute("margin", legendOptions.getMargin());
- }
-
- if (legendOptions.getReversed() != null) {
- target.addAttribute("reversed", legendOptions.getReversed());
- }
-
- if (legendOptions.getShadow() != null) {
- target.addAttribute("shadow", legendOptions.getShadow());
- }
-
- if (legendOptions.getSymbolPadding() != null) {
- target.addAttribute("symbolPadding",
- legendOptions.getSymbolPadding());
- }
-
- if (legendOptions.getSymbolWidth() != null) {
- target.addAttribute("symbolWidth", legendOptions.getSymbolWidth());
- }
-
- if (legendOptions.getWidth() != null) {
- target.addAttribute("width", legendOptions.getWidth());
- }
-
- if (legendOptions.getPosition() != null) {
- if (legendOptions.getPosition().getAlign() != null) {
- target.addAttribute("align", legendOptions.getPosition()
- .getAlign().getName());
- }
- if (legendOptions.getPosition().getVertAlign() != null) {
- target.addAttribute("verticalAlign", legendOptions
- .getPosition().getVertAlign().getName());
- }
- if (legendOptions.getPosition().getX() != null) {
- target.addAttribute("x", legendOptions.getPosition().getX());
- }
- if (legendOptions.getPosition().getY() != null) {
- target.addAttribute("y", legendOptions.getPosition().getY());
- }
- }
-
- target.endTag("legend");
- }
-
- /**
- * Writes configuration attributes of the chart tooltip.
- *
- * @param target
- * @param tooltipOptions
- * @throws PaintException
- */
- public static void writeTooltipConfig(PaintTarget target,
- Tooltip tooltipOptions) throws PaintException {
- target.startTag("tooltip");
-
- if (tooltipOptions.getBackgroundColor() != null) {
- target.addAttribute("backgroundColor", tooltipOptions
- .getBackgroundColor().getString());
- }
- if (tooltipOptions.getBorderColor() != null) {
- target.addAttribute("borderColor", tooltipOptions.getBorderColor()
- .getString());
- }
- if (tooltipOptions.getBorderRadius() != null) {
- target.addAttribute("borderRadius",
- tooltipOptions.getBorderRadius());
- }
- if (tooltipOptions.getBorderWidth() != null) {
- target.addAttribute("borderWidth", tooltipOptions.getBorderWidth());
- }
- if (tooltipOptions.getCrosshairs() != null) {
- target.addAttribute("crosshairs", tooltipOptions.getCrosshairs());
- }
- if (tooltipOptions.getEnabled() != null) {
- target.addAttribute("enabled", tooltipOptions.getEnabled());
- }
- if (tooltipOptions.getFormatterJsFunc() != null) {
- target.addAttribute("formatter",
- tooltipOptions.getFormatterJsFunc());
- }
- if (tooltipOptions.getShadow() != null) {
- target.addAttribute("shadow", tooltipOptions.getShadow());
- }
- if (tooltipOptions.getShared() != null) {
- target.addAttribute("shared", tooltipOptions.getShared());
- }
- if (tooltipOptions.getSnap() != null) {
- target.addAttribute("snap", tooltipOptions.getSnap());
- }
- if (tooltipOptions.getStyle() != null) {
- target.addAttribute("style", tooltipOptions.getStyle());
- }
-
- target.endTag("tooltip");
- }
-
- /**
- * Writes configuration attributes of the chart itself.
- *
- * @param target
- * @param chartOptions
- * @throws PaintException
- */
- public static void writeGeneralChartConfig(PaintTarget target,
- GeneralChartConfig chartOptions) throws PaintException {
- target.startTag("chart");
-
- if (chartOptions.getType() != null) {
- target.addAttribute("type", chartOptions.getType().getName());
- }
-
- if (chartOptions.getWidth() != null) {
- target.addAttribute("width", chartOptions.getWidth());
- }
- if (chartOptions.getHeight() != null) {
- target.addAttribute("height", chartOptions.getHeight());
- }
-
- if (chartOptions.getBackgroundColor() != null) {
- target.addAttribute("backgroundColor", chartOptions
- .getBackgroundColor().getString());
- }
- if (chartOptions.getBorderColor() != null) {
- target.addAttribute("borderColor", chartOptions.getBorderColor()
- .getString());
- }
- if (chartOptions.getBorderRadius() != null) {
- target.addAttribute("borderRadius", chartOptions.getBorderRadius());
- }
- if (chartOptions.getBorderWidth() != null) {
- target.addAttribute("borderWidth", chartOptions.getBorderWidth());
- }
-
- if (chartOptions.getIgnoreHiddenSeries() != null) {
- target.addAttribute("ignoreHiddenSeries",
- chartOptions.getIgnoreHiddenSeries());
- }
- if (chartOptions.getInverted() != null) {
- target.addAttribute("inverted", chartOptions.getInverted());
- }
-
- if (chartOptions.getMargin() != null) {
- if (chartOptions.getMargin().getTop() != null) {
- target.addAttribute("marginTop", chartOptions.getMargin()
- .getTop());
- }
- if (chartOptions.getMargin().getLeft() != null) {
- target.addAttribute("marginLeft", chartOptions.getMargin()
- .getLeft());
- }
- if (chartOptions.getMargin().getBottom() != null) {
- target.addAttribute("marginBottom", chartOptions.getMargin()
- .getBottom());
- }
- if (chartOptions.getMargin().getRight() != null) {
- target.addAttribute("marginRight", chartOptions.getMargin()
- .getRight());
- }
- }
-
- if (chartOptions.getSpacing() != null) {
-
- if (chartOptions.getSpacing().getTop() != null) {
- target.addAttribute("spacingTop", chartOptions.getSpacing()
- .getTop());
- }
- if (chartOptions.getSpacing().getLeft() != null) {
- target.addAttribute("spacingLeft", chartOptions.getSpacing()
- .getLeft());
- }
- if (chartOptions.getSpacing().getBottom() != null) {
- target.addAttribute("spacingBottom", chartOptions.getSpacing()
- .getBottom());
- }
- if (chartOptions.getSpacing().getRight() != null) {
- target.addAttribute("spacingRight", chartOptions.getSpacing()
- .getRight());
- }
- }
-
- if (chartOptions.getShowAxes() != null) {
- target.addAttribute("showAxes", chartOptions.getShowAxes());
- }
- if (chartOptions.getZoomType() != null) {
- target.addAttribute("zoomType", chartOptions.getZoomType()
- .getName());
- }
- target.addAttribute("clientZoom", chartOptions.isClientZoom());
-
- if (chartOptions.getAlignTicks() != null) {
- target.addAttribute("alignTicks", chartOptions.getAlignTicks());
- }
- if (chartOptions.getAnimation() != null) {
- target.addAttribute("animation", chartOptions.getAnimation());
- }
- if (chartOptions.getClassName() != null) {
- target.addAttribute("className", chartOptions.getClassName());
- }
-
- if (chartOptions.getPlot() != null) {
- if (chartOptions.getPlot().getBackgroundColor() != null) {
- target.addAttribute("plotBackgroundColor", chartOptions
- .getPlot().getBackgroundColor().getString());
- }
- if (chartOptions.getPlot().getBorderColor() != null) {
- target.addAttribute("plotBorderColor", chartOptions.getPlot()
- .getBorderColor().getString());
- }
- if (chartOptions.getPlot().getBackgroundImage() != null) {
- target.addAttribute("plotBackgroundImage", chartOptions
- .getPlot().getBackgroundImage());
- }
- if (chartOptions.getPlot().getBorderWidth() != null) {
- target.addAttribute("plotBorderWidth", chartOptions.getPlot()
- .getBorderWidth());
- }
- if (chartOptions.getPlot().getShadow() != null) {
- target.addAttribute("plotShadow", chartOptions.getPlot()
- .getShadow());
- }
- }
-
- if (chartOptions.getReflow() != null) {
- target.addAttribute("reflow", chartOptions.getReflow());
- }
- if (chartOptions.getShadow() != null) {
- target.addAttribute("shadow", chartOptions.getShadow());
- }
- if (chartOptions.getStyle() != null) {
- target.addAttribute("style", chartOptions.getStyle());
- }
-
- target.endTag("chart");
- }
-
- /**
- * Writes configuration attributes of every series type. The series type can
- * be one of the line, spline, scatter, area, areaspline, bar, column and
- * pie.
- *
- * @param target
- * @param seriesOptions
- * @throws PaintException
- */
- public static void writeSeriesConfigPerSeriesType(PaintTarget target,
- Map seriesOptions) throws PaintException {
- target.startTag("seriesOptionsPerSeriesType");
- // For each SeriesType have separate tag
- for (Entry seriesEntryOptions : seriesOptions
- .entrySet()) {
- String tagName = seriesEntryOptions.getKey().getName();
- //
- target.startTag(tagName);
- // Write options for appropriate series type
- writeSeriesConfig(target, seriesEntryOptions.getValue());
- //
- target.endTag(tagName);
- }
- target.endTag("seriesOptionsPerSeriesType");
- }
-
- /**
- * Writes configuration attributes of a single series.
- *
- * @param target
- * @param series
- * @throws PaintException
- */
- private static void writeSeriesConfig(PaintTarget target,
- SeriesConfig series) throws PaintException {
- // Write options for appropriate series type
- if (series instanceof LineConfig) {
- writeLineOptions(target, (LineConfig) series);
- } else if (series instanceof ScatterConfig) {
- writeScatterOptions(target, (ScatterConfig) series);
- } else if (series instanceof SplineConfig) {
- writeSplineOptions(target, (SplineConfig) series);
- } else if (series instanceof AreaConfig) {
- writeAreaOptions(target, (AreaConfig) series);
- } else if (series instanceof AreaSplineConfig) {
- writeAreaSplineOptions(target, (AreaSplineConfig) series);
- } else if (series instanceof ColumnConfig) {
- writeColumnOptions(target, (ColumnConfig) series);
- } else if (series instanceof BarConfig) {
- writeBarOptions(target, (BarConfig) series);
- } else if (series instanceof PieConfig) {
- writePieOptions(target, (PieConfig) series);
- } else { // Common series attributes
- writeCommonSeriesOptions(target, series);
- }
- }
-
- /**
- * Writes configuration attributes common to all types of series.
- *
- * @param target
- * @param seriesOptions
- * @throws PaintException
- */
- private static void writeCommonSeriesOptions(PaintTarget target,
- SeriesConfig seriesOptions) throws PaintException {
- if (seriesOptions.getAllowPointSelect() != null) {
- target.addAttribute("allowPointSelect",
- seriesOptions.getAllowPointSelect());
- }
- if (seriesOptions.getAnimation() != null) {
- target.addAttribute("animation", seriesOptions.getAnimation());
- }
- if (seriesOptions.getCursor() != null) {
- target.addAttribute("cursor", seriesOptions.getCursor());
- }
- //
- if (seriesOptions.getColor() != null) {
- target.addAttribute("color", seriesOptions.getColor().getString());
- }
- if (seriesOptions.getEnableMouseTracking() != null) {
- target.addAttribute("enableMouseTracking",
- seriesOptions.getEnableMouseTracking());
- }
- // if (seriesOptions.getSelected() != null) {
- // target.addAttribute("selected", seriesOptions.getSelected());
- // }
- if (seriesOptions.getShowCheckbox() != null) {
- target.addAttribute("showCheckbox", seriesOptions.getShowCheckbox());
- }
- if (seriesOptions.getShowInLegend() != null) {
- target.addAttribute("showInLegend", seriesOptions.getShowInLegend());
- }
- if (seriesOptions.getStacking() != null) {
- target.addAttribute("stacking", seriesOptions.getStacking()
- .getName());
- }
- if (seriesOptions.getShadow() != null) {
- target.addAttribute("shadow", seriesOptions.getShadow());
- }
- if (seriesOptions.getVisible() != null) {
- target.addAttribute("visible", seriesOptions.getVisible());
- }
- // Data Label
- writeSeriesDataLabel(target, seriesOptions.getDataLabel());
- // State
- writeSeriesState(target, seriesOptions.getHoverState());
- }
-
- /**
- * Writes configuration attributes of a series hover state.
- *
- * @param target
- * @param seriesState
- * @throws PaintException
- */
- private static void writeSeriesState(PaintTarget target,
- SeriesState seriesState) throws PaintException {
- target.startTag("state");
- if (seriesState != null) {
- target.startTag("hover");
- if (seriesState.getEnabled() != null) {
- target.addAttribute("enabled", seriesState.getEnabled());
- }
- if (seriesState.getLineWidth() != null) {
- target.addAttribute("lineWidth", seriesState.getLineWidth());
- }
- if (seriesState instanceof NonLinearSeriesState
- && ((NonLinearSeriesState) seriesState).getBrightness() != null) {
- target.addAttribute("brightness",
- ((NonLinearSeriesState) seriesState).getBrightness());
- }
- target.endTag("hover");
- }
- target.endTag("state");
- }
-
- /**
- * Writes configuration attributes common to all types of series. It takes
- * care of specific data labels in case of pie.
- *
- * @param target
- * @param dataLabel
- * @throws PaintException
- */
- private static void writeSeriesDataLabel(PaintTarget target,
- DataLabel dataLabel) throws PaintException {
- target.startTag("dataLabel");
- if (dataLabel != null) {
- if (dataLabel instanceof PieDataLabel) {
- writePieDataLabel(target, (PieDataLabel) dataLabel);
- } else {
- writeDataLabel(target, dataLabel);
- }
- }
- target.endTag("dataLabel");
- }
-
- /**
- * Writes configuration attributes of a series data labels.
- *
- * @param target
- * @param dataLabel
- * @throws PaintException
- */
- private static void writeDataLabel(PaintTarget target, DataLabel dataLabel)
- throws PaintException {
- if (dataLabel.getAlign() != null) {
- target.addAttribute("align", dataLabel.getAlign().getName());
- }
- if (dataLabel.getEnabled() != null) {
- target.addAttribute("enabled", dataLabel.getEnabled());
- }
- if (dataLabel.getFormatterJsFunc() != null) {
- target.addAttribute("formatter", dataLabel.getFormatterJsFunc());
- }
- if (dataLabel.getRotation() != null) {
- target.addAttribute("rotation", dataLabel.getRotation());
- }
- if (dataLabel.getStyle() != null) {
- target.addAttribute("style", dataLabel.getStyle());
- }
- if (dataLabel.getX() != null) {
- target.addAttribute("x", dataLabel.getX());
- }
- if (dataLabel.getY() != null) {
- target.addAttribute("y", dataLabel.getY());
- }
- if (dataLabel.getColor() != null) {
- target.addAttribute("color", dataLabel.getColor().getString());
- }
- }
-
- /**
- * Writes configuration attributes of a pie chart's data label.
- *
- * @param target
- * @param dataLabel
- * @throws PaintException
- */
- private static void writePieDataLabel(PaintTarget target,
- PieDataLabel dataLabel) throws PaintException {
-
- writeDataLabel(target, dataLabel);
-
- if (dataLabel.getConnectorWidth() != null) {
- target.addAttribute("connectorWidth", dataLabel.getConnectorWidth());
- }
- if (dataLabel.getConnectorPadding() != null) {
- target.addAttribute("connectorPadding",
- dataLabel.getConnectorPadding());
- }
- if (dataLabel.getConnectorColor() != null) {
- target.addAttribute("connectorColor", dataLabel.getConnectorColor()
- .getString());
- }
- if (dataLabel.getDistance() != null) {
- target.addAttribute("distance", dataLabel.getDistance());
- }
- }
-
- /**
- * Writes configuration attributes of an axis data labels.
- *
- * @param target
- * @param dataLabel
- * @throws PaintException
- */
- private static void writeAxisDataLabel(PaintTarget target,
- AxisDataLabel dataLabel) throws PaintException {
-
- writeDataLabel(target, dataLabel);
-
- if (dataLabel.getStep() != null) {
- target.addAttribute("step", dataLabel.getStep());
- }
- }
-
- /**
- * Writes configuration attributes of an x-axis data labels.
- *
- * @param target
- * @param dataLabel
- * @throws PaintException
- */
- private static void writeXAxisDataLabel(PaintTarget target,
- XAxisDataLabel dataLabel) throws PaintException {
- target.startTag("label");
- if (dataLabel != null) {
- writeAxisDataLabel(target, dataLabel);
-
- if (dataLabel.getStaggerLines() != null) {
- target.addAttribute("staggerLines", dataLabel.getStaggerLines());
- }
- }
-
- target.endTag("label");
- }
-
- /**
- * Writes configuration attributes of y-axis data labels.
- *
- * @param target
- * @param dataLabel
- * @throws PaintException
- */
- private static void writeYAxisDataLabel(PaintTarget target,
- YAxisDataLabel dataLabel) throws PaintException {
- target.startTag("label");
-
- if (dataLabel != null) {
- writeAxisDataLabel(target, dataLabel);
- }
- target.endTag("label");
- }
-
- /**
- * Writes configuration attributes of a marker. It takes care of handling
- * image or symbol marker.
- *
- * @param target
- * @param markerOptions
- * @throws PaintException
- */
- private static void writeMarkerOptions(PaintTarget target,
- Marker markerOptions) throws PaintException {
- target.startTag("marker");
- if (markerOptions != null) {
- if (markerOptions.getEnabled() != null) {
- target.addAttribute("enabled", markerOptions.getEnabled());
- }
- if (markerOptions instanceof ImageMarker) {
- target.addAttribute("markerType", "image");
- writeImageMarkerOptions(target, (ImageMarker) markerOptions);
- } else if (markerOptions instanceof SymbolMarker) {
- target.addAttribute("markerType", "symbol");
- writeSymbolMarkerOptions(target, (SymbolMarker) markerOptions);
- writeMarkerStates(target, (SymbolMarker) markerOptions);
- }
- }
- target.endTag("marker");
- }
-
- /**
- * Writes configuration attributes of a marker states hover and select
- *
- *
- * @param target
- * @param marker
- * @throws PaintException
- */
- private static void writeMarkerStates(PaintTarget target,
- SymbolMarker marker) throws PaintException {
- target.startTag("states");
- //
- target.startTag("hover");
- if (marker.getHoverState() != null) {
- writeMarkerState(target, marker.getHoverState());
- }
- target.endTag("hover");
-
- //
- target.startTag("select");
- if (marker.getSelectState() != null) {
- writeMarkerState(target, marker.getSelectState());
- }
- target.endTag("select");
-
- target.endTag("states");
- }
-
- /**
- * Writes configuration attributes of an image marker
- *
- * @param target
- * @param imgMarker
- * @throws PaintException
- */
- private static void writeImageMarkerOptions(PaintTarget target,
- ImageMarker imgMarker) throws PaintException {
- if (imgMarker.getImageURL() != null) {
- target.addAttribute("symbol", imgMarker.getImageURL());
- }
- }
-
- /**
- * Writes configuration attributes of a symbol marker
- *
- * @param target
- * @param symbolMarker
- * @throws PaintException
- */
- private static void writeSymbolMarkerOptions(PaintTarget target,
- SymbolMarker symbolMarker) throws PaintException {
- if (symbolMarker.getFillColor() != null) {
- target.addAttribute("fillColor", symbolMarker.getFillColor()
- .getString());
- }
- if (symbolMarker.getLineColor() != null) {
- target.addAttribute("lineColor", symbolMarker.getLineColor()
- .getString());
- }
- if (symbolMarker.getLineWidth() != null) {
- target.addAttribute("lineWidth", symbolMarker.getLineWidth());
- }
- if (symbolMarker.getRadius() != null) {
- target.addAttribute("radius", symbolMarker.getRadius());
- }
- if (symbolMarker.getSymbol() != null) {
- target.addAttribute("symbol", symbolMarker.getSymbol().getName());
- }
- }
-
- /**
- * Writes configuration attributes of a marker
- *
- * @param target
- * @param markerState
- * @throws PaintException
- */
- private static void writeMarkerState(PaintTarget target,
- MarkerState markerState) throws PaintException {
- if (markerState.getEnabled() != null) {
- target.addAttribute("enabled", markerState.getEnabled());
- }
- if (markerState.getFillColor() != null) {
- target.addAttribute("fillColor", markerState.getFillColor()
- .getString());
- }
- if (markerState.getLineColor() != null) {
- target.addAttribute("lineColor", markerState.getLineColor()
- .getString());
- }
- if (markerState.getLineWidth() != null) {
- target.addAttribute("lineWidth", markerState.getLineWidth());
- }
- if (markerState.getRadius() != null) {
- target.addAttribute("radius", markerState.getRadius());
- }
- }
-
- /**
- * Writes configuration attributes common to all lines series such as line,
- * spline and area.
- *
- * @param target
- * @param baseLineOptions
- * @throws PaintException
- */
- private static void writeBaseLineOptions(PaintTarget target,
- BaseLineConfig baseLineOptions) throws PaintException {
- writeCommonSeriesOptions(target, baseLineOptions);
- if (baseLineOptions.getDashStyle() != null) {
- target.addAttribute("dashStyle", baseLineOptions.getDashStyle()
- .getName());
- }
- if (baseLineOptions.getLineWidth() != null) {
- target.addAttribute("lineWidth", baseLineOptions.getLineWidth());
- }
- if (baseLineOptions.getPointInterval() != null) {
- target.addAttribute("pointInterval",
- baseLineOptions.getPointInterval());
- }
- if (baseLineOptions.getPointStart() != null) {
- target.addAttribute("pointStart", baseLineOptions.getPointStart());
- }
- if (baseLineOptions.getStickyTracking() != null) {
- target.addAttribute("stickyTracking",
- baseLineOptions.getStickyTracking());
- }
- writeMarkerOptions(target, baseLineOptions.getMarker());
- }
-
- /**
- * Writes configuration attributes of a spline series
- *
- * @param target
- * @param splineOptions
- * @throws PaintException
- */
- private static void writeSplineOptions(PaintTarget target,
- SplineConfig splineOptions) throws PaintException {
- writeBaseLineOptions(target, splineOptions);
- }
-
- /**
- * Writes configuration attributes of s scatter series
- *
- * @param target
- * @param scatterOptions
- * @throws PaintException
- */
- private static void writeScatterOptions(PaintTarget target,
- ScatterConfig scatterOptions) throws PaintException {
- writeBaseLineOptions(target, scatterOptions);
- }
-
- /**
- * Writes configuration attributes of a line series
- *
- * @param target
- * @param lineOptions
- * @throws PaintException
- */
- private static void writeLineOptions(PaintTarget target,
- LineConfig lineOptions) throws PaintException {
- writeBaseLineOptions(target, lineOptions);
- //
- if (lineOptions.getStep() != null) {
- target.addAttribute("step", lineOptions.getStep());
- }
- }
-
- /**
- * Writes configuration attributes of an area series
- *
- * @param target
- * @param areaOptions
- * @throws PaintException
- */
- private static void writeAreaOptions(PaintTarget target,
- AreaConfig areaOptions) throws PaintException {
- writeBaseLineOptions(target, areaOptions);
- //
- if (areaOptions.getFillColor() != null) {
- target.addAttribute("fillColor", areaOptions.getFillColor()
- .getString());
- }
- if (areaOptions.getFillOpacity() != null) {
- target.addAttribute("fillOpacity", areaOptions.getFillOpacity());
- }
- if (areaOptions.getLineColor() != null) {
- target.addAttribute("lineColor", areaOptions.getLineColor()
- .getString());
- }
- if (areaOptions.getThreshold() != null) {
- target.addAttribute("threshold", areaOptions.getThreshold());
- }
- }
-
- /**
- * Writes configuration attributes of an area-spline
- *
- * @param target
- * @param areaSplineOptions
- * @throws PaintException
- */
- private static void writeAreaSplineOptions(PaintTarget target,
- AreaSplineConfig areaSplineOptions) throws PaintException {
- writeAreaOptions(target, areaSplineOptions);
- }
-
- /**
- * Writes configuration attributes of a pie series
- *
- * @param target
- * @param pieOptions
- * @throws PaintException
- */
- private static void writePieOptions(PaintTarget target, PieConfig pieOptions)
- throws PaintException {
- writeCommonSeriesOptions(target, pieOptions);
- //
- if (pieOptions.getBorderColor() != null) {
- target.addAttribute("borderColor", pieOptions.getBorderColor()
- .getString());
- }
- if (pieOptions.getBorderWidth() != null) {
- target.addAttribute("borderWidth", pieOptions.getBorderWidth());
- }
- if (pieOptions.getCenterX() != null) {
- target.addAttribute("centerX", pieOptions.getCenterX());
- }
- if (pieOptions.getCenterY() != null) {
- target.addAttribute("centerY", pieOptions.getCenterY());
- }
- if (pieOptions.getInnerSize() != null) {
- target.addAttribute("innerSize", pieOptions.getInnerSize());
- }
- if (pieOptions.getSize() != null) {
- target.addAttribute("size", pieOptions.getSize());
- }
- if (pieOptions.getSlicedOffset() != null) {
- target.addAttribute("slicedOffset", pieOptions.getSlicedOffset());
- }
- }
-
- /**
- * Writes configuration attributes common to columnar series such as bar and
- * column
- *
- * @param target
- * @param baseBarOptions
- * @throws PaintException
- */
- private static void writeBaseBarOptions(PaintTarget target,
- BaseBarConfig baseBarOptions) throws PaintException {
- writeCommonSeriesOptions(target, baseBarOptions);
-
- if (baseBarOptions.getBorderColor() != null) {
- target.addAttribute("borderColor", baseBarOptions.getBorderColor()
- .getString());
- }
- if (baseBarOptions.getBorderRadius() != null) {
- target.addAttribute("borderRadius",
- baseBarOptions.getBorderRadius());
- }
- if (baseBarOptions.getBorderWidth() != null) {
- target.addAttribute("borderWidth", baseBarOptions.getBorderWidth());
- }
- if (baseBarOptions.getColorByPoint() != null) {
- target.addAttribute("colorByPoint",
- baseBarOptions.getColorByPoint());
- }
- if (baseBarOptions.getGroupPadding() != null) {
- target.addAttribute("groupPadding",
- baseBarOptions.getGroupPadding());
- }
- if (baseBarOptions.getMinPointLength() != null) {
- target.addAttribute("minPointLength",
- baseBarOptions.getMinPointLength());
- }
- if (baseBarOptions.getPointPadding() != null) {
- target.addAttribute("pointPadding",
- baseBarOptions.getPointPadding());
- }
- if (baseBarOptions.getPointWidth() != null) {
- target.addAttribute("pointWidth", baseBarOptions.getPointWidth());
- }
- }
-
- /**
- * Writes configuration attributes of a bar series
- *
- * @param target
- * @param barOptions
- * @throws PaintException
- */
- private static void writeBarOptions(PaintTarget target, BarConfig barOptions)
- throws PaintException {
- writeBaseBarOptions(target, barOptions);
- }
-
- /**
- * Writes configuration attributes of a column series
- *
- * @param target
- * @param columnOptions
- * @throws PaintException
- */
- private static void writeColumnOptions(PaintTarget target,
- ColumnConfig columnOptions) throws PaintException {
- writeBaseBarOptions(target, columnOptions);
- }
-
- /**
- * Writes data of each series of the chart. It transforms data into a form
- * which is usable by the Vaadin terminal class. It also writes
- * configuration attributes specific to each series, if any.
- *
- * @param target
- * @param chartSeriesType
- * @param data
- * @param xAxes
- * @param yAxes
- * @throws PaintException
- */
- public static void writeSeries(PaintTarget target,
- SeriesType chartSeriesType, LinkedHashSet data,
- LinkedHashSet xAxes, LinkedHashSet yAxes)
- throws PaintException {
- if (data == null) {
- return;
- }
- for (Series series : data) {
- target.startTag("series");
-
- if (series.getName() != null && series.getName().length() > 0) {
- target.addAttribute("name", series.getName());
- }
- if (series.getType() != null) {
- target.addAttribute("type", series.getType().getName());
- }
- if (series.getStack() != null && series.getStack().length() > 0) {
- target.addAttribute("stack", series.getStack());
- }
-
- target.addAttribute("xAxis",
- getXAxisIndex(series.getXAxis(), xAxes));
- target.addAttribute("yAxis",
- getYAxisIndex(series.getYAxis(), yAxes));
-
- String seriesOptionsTagName = chartSeriesType.getName();
- if (series.getType() != null) {
- seriesOptionsTagName = series.getType().getName();
- }
-
- target.startTag(seriesOptionsTagName);
- if (series.getConfig() != null) {
- writeSeriesConfig(target, series.getConfig());
- }
- target.endTag(seriesOptionsTagName);
-
- target.startTag("points");
- if (series.getPoints() != null) {
- writePoints(target, series.getPoints());
- }
- target.endTag("points");
-
- target.endTag("series");
- }
-
- }
-
- /**
- * Writes point data (x, y) and its configuration attributes, if any. If a
- * point does not have x and y values then the point is skipped. However,
- * for such points empty tags is created without any attributes or children.
- *
- * @param target
- * @param points
- * @throws PaintException
- */
- private static void writePoints(PaintTarget target,
- LinkedHashSet extends Point> points) throws PaintException {
- if (points == null) {
- return;
- }
- for (Point point : points) {
- target.startTag("point");
- if (point.getX() != null || point.getY() != null) {
- if (point.getId() != null && point.getId().length() > 0) {
- target.addAttribute("id", point.getId());
- }
- if (point.getName() != null && point.getName().length() > 0) {
- target.addAttribute("name", point.getName());
- }
- if (point.getX() != null) {
- if (point instanceof DecimalPoint) {
- target.addAttribute("x", (Double) point.getX());
- } else {
- target.addAttribute(
- "x",
- getDate((Date) point.getX(),
- ((DateTimeSeries) point.getSeries())
- .isIncludeTime()));
- }
- }
- if (point.getY() != null) {
- target.addAttribute("y", (Double) point.getY());
- }
- target.addAttribute("isShift", point.isShift());
- // Point config
- if (point.getConfig() != null) {
- if (point.getConfig().getSliced() != null) {
- target.addAttribute("sliced", point.getConfig()
- .getSliced());
- }
- if (point.getConfig().getSelected() != null) {
- target.addAttribute("selected", point.getConfig()
- .getSelected());
- }
- if (point.getConfig().getColor() != null) {
- target.addAttribute("color", point.getConfig()
- .getColor().getString());
- }
- if (point.getConfig().getMarker() != null) {
- writeMarkerOptions(target, point.getConfig()
- .getMarker());
- }
- }
- }
- target.endTag("point");
- }
- }
-
- /**
- * Writes configuration attributes common to all types of axis.
- *
- * @param target
- * @param axis
- * @param axes
- * @throws PaintException
- */
- private static void writeBaseAxis(PaintTarget target, AxisBase axis,
- LinkedHashSet extends Axis> axes) throws PaintException {
-
- if (axis.getAlternateGridColor() != null) {
- target.addAttribute("alternateGridColor", axis
- .getAlternateGridColor().getString());
- }
- if (axis.getEndOnTick() != null) {
- target.addAttribute("endOnTick", axis.getEndOnTick());
- }
- if (axis.getGrid() != null) {
- writeAxisGrid(target, axis.getGrid());
- }
- if (axis.getId() != null && axis.getId().length() > 0) {
- target.addAttribute("id", axis.getId());
- }
-
- if (axis.getLineColor() != null) {
- target.addAttribute("lineColor", axis.getLineColor().getString());
- }
- if (axis.getLineWidth() != null) {
- target.addAttribute("lineWidth", axis.getLineWidth());
- }
- if (axis.getLinkedTo() != null) {
- target.addAttribute("linkedTo",
- getAxisIndex(axis.getLinkedTo(), axes));
- }
-
- if (axis.getMaxPadding() != null) {
- target.addAttribute("maxPadding", axis.getMaxPadding());
- }
- if (axis.getMaxZoom() != null) {
- target.addAttribute("maxZoom", axis.getMaxZoom());
- }
- if (axis.getMinPadding() != null) {
- target.addAttribute("minPadding", axis.getMinPadding());
- }
-
- //
- if (axis.getMinorGrid() != null) {
- writeAxisMinorGrid(target, axis.getMinorGrid());
- }
- //
- if (axis.getMinorTick() != null) {
- writeAxisMinorTick(target, axis.getMinorTick());
- }
-
- if (axis.getOffset() != null) {
- target.addAttribute("offset", axis.getOffset());
- }
- if (axis.getOpposite() != null) {
- target.addAttribute("opposite", axis.getOpposite());
- }
- if (axis.getReversed() != null) {
- target.addAttribute("reversed", axis.getReversed());
- }
- if (axis.getShowFirstLabel() != null) {
- target.addAttribute("showFirstLabel", axis.getShowFirstLabel());
- }
- if (axis.getShowLastLabel() != null) {
- target.addAttribute("showLastLabel", axis.getShowLastLabel());
- }
-
- if (axis.getStartOfWeek() != null) {
- target.addAttribute("startOfWeek", axis.getStartOfWeek().ordinal());
- }
- if (axis.getStartOnTick() != null) {
- target.addAttribute("startOnTick", axis.getStartOnTick());
- }
- //
- if (axis.getTick() != null) {
- writeAxisTick(target, axis.getTick());
- }
- //
- if (axis.getType() != null) {
- target.addAttribute("type", axis.getType().getName());
- }
- // Title
- writeAxisTitle(target, axis.getTitle());
- // Labels
- if (axis.getLabel() instanceof XAxisDataLabel) {
- writeXAxisDataLabel(target, (XAxisDataLabel) axis.getLabel());
- } else {
- writeYAxisDataLabel(target, (YAxisDataLabel) axis.getLabel());
- }
-
- if (axis instanceof NumberAxis) {
- writePlotBands(target, ((NumberAxis) axis).getPlotBands());
- //
- writePlotLines(target, ((NumberAxis) axis).getPlotLines());
- } else if (axis instanceof DateTimeAxis) {
- writePlotBands(target, ((DateTimeAxis) axis).getPlotBands());
- //
- writePlotLines(target, ((DateTimeAxis) axis).getPlotLines());
- } else if (axis instanceof CategoryAxis) {
- writePlotBands(target, ((CategoryAxis) axis).getPlotBands());
- //
- writePlotLines(target, ((CategoryAxis) axis).getPlotLines());
- }
-
- }
-
- /**
- * Returns an index of an x-axis in a list of x-axis only if the x-axis
- * exists otherwise null
- *
- * @param indexOfXAxis
- * @param xAxes
- * @return Retrieves Retrieves an index of an x-axis in a list of x-axis
- * only if the x-axis exists otherwise null
- */
- private static Integer getXAxisIndex(XAxis indexOfXAxis,
- LinkedHashSet xAxes) {
- return getAxisIndex(indexOfXAxis, xAxes);
- }
-
- /**
- * Returns an index of a y-axis in a list of y-axis only if the y-axis
- * exists otherwise null
- *
- * @param indexOfYAxis
- * @param yAxes
- * @return Returns index of a y-axis in a list of y-axis only if the y-axis
- * exists otherwise null
- */
- private static Integer getYAxisIndex(YAxis indexOfYAxis,
- LinkedHashSet yAxes) {
- return getAxisIndex(indexOfYAxis, yAxes);
- }
-
- /**
- * Returns an index of an axis in a list of axis only if the axis exists
- * otherwise null
- *
- * @param indexOfAxis
- * @param axes
- * @return Returns an index of an axis in a list of axis only if the axis
- * exists otherwise null
- */
- private static Integer getAxisIndex(Axis indexOfAxis,
- LinkedHashSet extends Axis> axes) {
- if (indexOfAxis == null || axes == null || axes.size() == 0) {
- return 0;
- }
- int index = 0;
- for (Axis axis : axes) {
- if (axis == indexOfAxis) {
- return index;
- }
- index++;
- }
-
- return null;
- }
-
- /**
- * Writes configuration attributes of the plotbands associated with an axis.
- *
- * @param target
- * @param plotBands
- * @throws PaintException
- */
- private static void writePlotBands(PaintTarget target,
- LinkedHashSet extends PlotBand> plotBands) throws PaintException {
- target.startTag("plotBands");
- if (plotBands != null) {
- for (PlotBand plotBand : plotBands) {
- target.startTag("plotBand");
-
- if (plotBand.getColor() != null) {
- target.addAttribute("color", plotBand.getColor()
- .getString());
- }
- if (plotBand.getId() != null) {
- target.addAttribute("id", plotBand.getId());
- }
- if (plotBand.getZIndex() != null) {
- target.addAttribute("zIndex", plotBand.getZIndex());
- }
- writePlotLabel(target, plotBand.getLabel());
- writePlotBandRange(target, plotBand.getRange());
-
- target.endTag("plotBand");
- }
- }
- target.endTag("plotBands");
- }
-
- /**
- * Writes configuration attributes of a plotlabel.
- *
- * @param target
- * @param plotLabel
- * @throws PaintException
- */
- private static void writePlotLabel(PaintTarget target, PlotLabel plotLabel)
- throws PaintException {
-
- target.startTag("label");
-
- if (plotLabel != null) {
- if (plotLabel.getAlign() != null) {
- target.addAttribute("align", plotLabel.getAlign().getName());
- }
- if (plotLabel.getRotation() != null) {
- target.addAttribute("rotation", plotLabel.getRotation());
- }
- if (plotLabel.getStyle() != null) {
- target.addAttribute("style", plotLabel.getStyle());
- }
- if (plotLabel.getText() != null) {
- target.addAttribute("text", plotLabel.getText());
- }
- if (plotLabel.getTextAlign() != null) {
- target.addAttribute("textAlign", plotLabel.getTextAlign()
- .getName());
- }
- if (plotLabel.getVertAlign() != null) {
- target.addAttribute("verticalAlign", plotLabel.getVertAlign()
- .getName());
- }
- if (plotLabel.getX() != null) {
- target.addAttribute("x", plotLabel.getX());
- }
- if (plotLabel.getY() != null) {
- target.addAttribute("y", plotLabel.getY());
- }
- }
-
- target.endTag("label");
- }
-
- /**
- * Writes from/to value for a plotband. It considers date and number values
- * separately.
- *
- * @param target
- * @param plotBandRange
- * @throws PaintException
- */
- private static void writePlotBandRange(PaintTarget target,
- Range plotBandRange) throws PaintException {
- target.startTag("rangeValue");
- if (plotBandRange != null) {
- if (plotBandRange instanceof NumberRange) {
- target.addAttribute("valueType", "number");
- NumberRange numberRange = (NumberRange) plotBandRange;
- if (numberRange.getFrom() != null) {
- target.addAttribute("from", numberRange.getFrom());
- }
- if (numberRange.getTo() != null) {
- target.addAttribute("to", numberRange.getTo());
- }
- } else if (plotBandRange instanceof DateTimeRange) {
- target.addAttribute("valueType", "date");
- DateTimeRange dateRange = (DateTimeRange) plotBandRange;
- target.startTag("from");
- if (dateRange.getFrom() != null) {
- target.addAttribute("year",
- getYearFromDate(dateRange.getFrom()));
- target.addAttribute("month",
- getMonthFromDate(dateRange.getFrom()));
- target.addAttribute("day",
- getDayFromDate(dateRange.getFrom()));
- }
- target.endTag("from");
- target.startTag("to");
- if (dateRange.getTo() != null) {
- target.addAttribute("year",
- getYearFromDate(dateRange.getTo()));
- target.addAttribute("month",
- getMonthFromDate(dateRange.getTo()));
- target.addAttribute("day",
- getDayFromDate(dateRange.getTo()));
- }
- target.endTag("to");
- }
- }
- target.endTag("rangeValue");
- }
-
- /**
- * Writes configuration attributes of the plotlines
- *
- * @param target
- * @param plotLines
- * @throws PaintException
- */
- private static void writePlotLines(PaintTarget target,
- LinkedHashSet extends PlotLine> plotLines) throws PaintException {
- target.startTag("plotLines");
- if (plotLines != null) {
- for (PlotLine plotLine : plotLines) {
- target.startTag("plotLine");
-
- if (plotLine.getColor() != null) {
- target.addAttribute("color", plotLine.getColor()
- .getString());
- }
- if (plotLine.getDashStyle() != null) {
- target.addAttribute("dashStyle", plotLine.getDashStyle()
- .getName());
- }
- if (plotLine.getId() != null) {
- target.addAttribute("id", plotLine.getId());
- }
- if (plotLine.getWidth() != null) {
- target.addAttribute("width", plotLine.getWidth());
- }
- if (plotLine.getZIndex() != null) {
- target.addAttribute("zIndex", plotLine.getZIndex());
- }
- writePlotLabel(target, plotLine.getLabel());
- writePlotLineValue(target, plotLine.getValue());
- target.endTag("plotLine");
- }
- }
- target.endTag("plotLines");
- }
-
- /**
- * Writes value of a plotline. It considers date and number value
- * separately.
- *
- * @param target
- * @param plotLineValue
- * @throws PaintException
- */
- private static void writePlotLineValue(PaintTarget target,
- Value plotLineValue) throws PaintException {
-
- target.startTag("lineValue");
- if (plotLineValue != null) {
- if (plotLineValue instanceof NumberValue
- && ((NumberValue) plotLineValue).getValue() != null) {
- target.addAttribute("valueType", "number");
- target.addAttribute("value",
- ((NumberValue) plotLineValue).getValue());
- } else if (plotLineValue instanceof DateTimeValue
- && ((DateTimeValue) plotLineValue).getValue() != null) {
- target.addAttribute("valueType", "date");
- Date date = ((DateTimeValue) plotLineValue).getValue();
- target.addAttribute("year", getYearFromDate(date));
- target.addAttribute("month", getMonthFromDate(date));
- target.addAttribute("day", getDayFromDate(date));
- }
- }
- target.endTag("lineValue");
- }
-
- /**
- * @param target
- * @param tick
- * @throws PaintException
- */
- private static void writeAxisTick(PaintTarget target, Tick tick)
- throws PaintException {
- writeAxisMinorTick(target, tick);
- if (tick.getPixelInterval() != null) {
- target.addAttribute("tickPixelInterval", tick.getPixelInterval());
- }
- if (tick.getPlacement() != null) {
- target.addAttribute("tickmarkPlacement", tick.getPlacement()
- .getName());
- }
- }
-
- /**
- * Writes configuration attributes of an axis. Depending on type of the
- * argument tick, it either writes attributes for {@link MinorTick} or
- * {@link Tick}
- *
- * @param target
- * @param tick
- * @throws PaintException
- */
- private static void writeAxisMinorTick(PaintTarget target, MinorTick tick)
- throws PaintException {
-
- String attNameColor = "minorTickColor";
- String attNameInterval = "minorTickInterval";
- String attNameLength = "minorTickLength";
- String attNamePosition = "minorTickPosition";
- String attNameWidth = "minorTickWidth";
- if (tick instanceof Tick) {
- attNameColor = "tickColor";
- attNameInterval = "tickInterval";
- attNameLength = "tickLength";
- attNamePosition = "tickPosition";
- attNameWidth = "tickWidth";
- }
- if (tick.getColor() != null) {
- target.addAttribute(attNameColor, tick.getColor().getString());
- }
- if (tick.getInterval() != null) {
- target.addAttribute(attNameInterval, tick.getInterval());
- }
- if (tick.getLength() != null) {
- target.addAttribute(attNameLength, tick.getLength());
- }
- if (tick.getPosition() != null) {
- target.addAttribute(attNamePosition, tick.getPosition().getName());
- }
- if (tick.getWidth() != null) {
- target.addAttribute(attNameWidth, tick.getWidth());
- }
- }
-
- /**
- * @param target
- * @param grid
- * @throws PaintException
- */
- private static void writeAxisGrid(PaintTarget target, Grid grid)
- throws PaintException {
- writeAxisMinorGrid(target, grid);
- }
-
- /**
- * Writes configuration attributes of an axis. Depending on type of the
- * argument tick, it either writes attributes for {@link MinorGrid} or
- * {@link Grid}
- *
- * @param target
- * @param grid
- * @throws PaintException
- */
- private static void writeAxisMinorGrid(PaintTarget target, MinorGrid grid)
- throws PaintException {
-
- String attNameLineColor = "minorGridLineColor";
- String attNameLineWidth = "minorGridLineWidth";
- String attNameLineDashStyle = "minorGridLineDashStyle";
- if (grid instanceof Grid) {
- attNameLineColor = "gridLineColor";
- attNameLineWidth = "gridLineWidth";
- attNameLineDashStyle = "gridLineDashStyle";
- }
-
- if (grid.getLineColor() != null) {
- target.addAttribute(attNameLineColor, grid.getLineColor()
- .getString());
- }
- if (grid.getLineWidth() != null) {
- target.addAttribute(attNameLineWidth, grid.getLineWidth());
- }
- if (grid.getLineDashStyle() != null) {
- target.addAttribute(attNameLineDashStyle, grid.getLineDashStyle()
- .getName());
- }
- }
-
- /**
- *
- * @param target
- * @param title
- * @throws PaintException
- */
- private static void writeAxisTitle(PaintTarget target, AxisTitle title)
- throws PaintException {
- target.startTag("title");
- if (title != null) {
- if (title.getAlign() != null) {
- target.addAttribute("align", title.getAlign().getName());
- }
- if (title.getMargin() != null) {
- target.addAttribute("margin", title.getMargin());
- }
- if (title.getRotation() != null) {
- target.addAttribute("rotation", title.getRotation());
- }
- if (title.getStyle() != null) {
- target.addAttribute("style", title.getStyle());
- }
- if (title.getText() != null) {
- target.addAttribute("text", title.getText());
- }
- }
- target.endTag("title");
- }
-
- /**
- * Iteratively processes each x-axis and writes configuration attributes of
- * each axis based on type of the axis e.g. {@link NumberAxis},
- * {@link DateTimeAxis} and {@link CategoryAxis}
- *
- * @param target
- * @param axes
- * @throws PaintException
- */
- public static void writeXAxes(PaintTarget target,
- LinkedHashSet axes, InvientChartsConfig config)
- throws PaintException {
- target.startTag("xAxes");
-
- if (axes != null) {
- for (XAxis xAxis : axes) {
- target.startTag("xAxis");
- writeBaseAxis(target, (AxisBase) xAxis, axes);
- if (xAxis instanceof NumberXAxis) {
- writeNumberAxis(target, (NumberXAxis) xAxis);
- } else if (xAxis instanceof CategoryAxis) {
- writeCategoryAxis(target, (CategoryAxis) xAxis);
- } else if (xAxis instanceof DateTimeAxis) {
- // Check if time should be included as part of a date value.
- // If any of the datetime series
- writeDateTimeAxis(
- target,
- (DateTimeAxis) xAxis,
- isIncludeTime((DateTimeAxis) xAxis, config
- .getInvientCharts().getAllSeries()));
- }
-
- target.endTag("xAxis");
- }
- }
-
- target.endTag("xAxes");
- }
-
- private static boolean isIncludeTime(DateTimeAxis axis,
- LinkedHashSet chartSeries) {
- for (Series series : chartSeries) {
- if (series instanceof DateTimeSeries && series.getXAxis() == axis) {
- return ((DateTimeSeries) series).isIncludeTime();
- }
- }
- return false;
- }
-
- /**
- * @param target
- * @param numberAxis
- * @throws PaintException
- */
- private static void writeNumberAxis(PaintTarget target,
- NumberAxis numberAxis) throws PaintException {
- if (numberAxis.getAllowDecimals() != null) {
- target.addAttribute("allowDecimals", numberAxis.getAllowDecimals());
- }
- if (numberAxis.getMax() != null) {
- target.addAttribute("max", numberAxis.getMax());
- }
- if (numberAxis.getMin() != null) {
- target.addAttribute("min", numberAxis.getMin());
- }
- }
-
- /**
- * Returns milliseconds of the date argument dt excluding time.
- *
- * @param dt
- * @return
- */
- public static long getDate(Date dt) {
- return getDate(dt, false);
- }
-
- /**
- * Returns milliseconds of the date argument dt. If the argument
- * isIncludeTime is false then the returned milliseconds does not include
- * time.
- *
- * @param dt
- * @param isIncludeTime
- * @return
- */
- private static long getDate(Date dt, boolean isIncludeTime) {
- Calendar cal = GregorianCalendar.getInstance();
- cal.setTime(dt);
- if (!isIncludeTime) {
- cal.set(Calendar.HOUR, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
- }
- return cal.getTimeInMillis();
- }
-
- /**
- * @param target
- * @param dateTimeAxis
- * @throws PaintException
- */
- private static void writeDateTimeAxis(PaintTarget target,
- DateTimeAxis dateTimeAxis, boolean isIncludeTime)
- throws PaintException {
- if (dateTimeAxis.getMax() != null) {
- target.addAttribute("max",
- getDate(dateTimeAxis.getMax(), isIncludeTime));
- }
- if (dateTimeAxis.getMin() != null) {
- target.addAttribute("min",
- getDate(dateTimeAxis.getMin(), isIncludeTime));
- }
- if (dateTimeAxis.getDateTimeLabelFormat() != null) {
- target.startTag("dateTimeLabelFormats");
- DateTimeLabelFormat dateTimeLabelFormat = dateTimeAxis
- .getDateTimeLabelFormat();
- if (dateTimeLabelFormat.getSecond() != null) {
- target.addAttribute("second", dateTimeAxis
- .getDateTimeLabelFormat().getSecond());
- }
- if (dateTimeLabelFormat.getMinute() != null) {
- target.addAttribute("minute", dateTimeAxis
- .getDateTimeLabelFormat().getMinute());
- }
- if (dateTimeLabelFormat.getHour() != null) {
- target.addAttribute("hour", dateTimeAxis
- .getDateTimeLabelFormat().getHour());
- }
- if (dateTimeLabelFormat.getDay() != null) {
- target.addAttribute("day", dateTimeAxis
- .getDateTimeLabelFormat().getDay());
- }
- if (dateTimeLabelFormat.getWeek() != null) {
- target.addAttribute("week", dateTimeAxis
- .getDateTimeLabelFormat().getWeek());
- }
- if (dateTimeLabelFormat.getMonth() != null) {
- target.addAttribute("month", dateTimeAxis
- .getDateTimeLabelFormat().getMonth());
- }
- if (dateTimeLabelFormat.getYear() != null) {
- target.addAttribute("year", dateTimeAxis
- .getDateTimeLabelFormat().getYear());
- }
- target.endTag("dateTimeLabelFormats");
- }
- }
-
- /**
- * @param target
- * @param categoryAxis
- * @throws PaintException
- */
- private static void writeCategoryAxis(PaintTarget target,
- CategoryAxis categoryAxis) throws PaintException {
- target.startTag("categories");
- if (categoryAxis.getCategories() != null
- && categoryAxis.getCategories().size() > 0) {
- for (String category : categoryAxis.getCategories()) {
- target.startTag("category");
- target.addAttribute("name", category);
- target.endTag("category");
- }
- }
- target.endTag("categories");
- }
-
- /**
- * @param target
- * @param axes
- * @throws PaintException
- */
- public static void writeYAxes(PaintTarget target,
- LinkedHashSet axes, InvientChartsConfig config)
- throws PaintException {
- target.startTag("yAxes");
-
- if (axes != null) {
- for (YAxis yAxis : axes) {
- target.startTag("yAxis");
- writeBaseAxis(target, (AxisBase) yAxis, axes);
- if (yAxis instanceof NumberYAxis) {
- writeNumberAxis(target, (NumberYAxis) yAxis);
- }
- target.endTag("yAxis");
- }
- }
-
- target.endTag("yAxes");
- }
-
- /**
- * Writes configuration attributes of the chart labels.
- *
- * @param target
- * @param chartLabel
- * @throws PaintException
- */
- public static void writeChartLabelConfig(PaintTarget target,
- ChartLabel chartLabel) throws PaintException {
- target.startTag("labels");
-
- if (chartLabel != null && chartLabel.getLabels() != null
- && chartLabel.getLabels().size() > 0) {
- if (chartLabel.getStyle() != null) {
- target.addAttribute("style", chartLabel.getStyle());
- }
- target.startTag("items");
- for (ChartLabelItem label : chartLabel.getLabels()) {
- if (label.getHtml() != null || label.getStyle() != null) {
- target.startTag("item");
- if (label.getHtml() != null) {
- target.addAttribute("html", label.getHtml());
- }
- if (label.getStyle() != null) {
- target.addAttribute("style", label.getStyle());
- }
- target.endTag("item");
- }
- }
- target.endTag("items");
- }
-
- target.endTag("labels");
- }
-
- /**
- * @param date
- * @return Returns year of the argument date.
- */
- private static String getYearFromDate(Date date) {
- if (date == null) {
- return null;
- }
- Calendar cal = Calendar.getInstance();
- cal.setTime(date);
- return String.valueOf(cal.get(Calendar.YEAR));
- }
-
- /**
- * @param date
- * @return Returns month of the argument date. The returned values is based
- * on zero-index i.e. for month January, the values returned is "0"
- */
- private static String getMonthFromDate(Date date) {
- if (date == null) {
- return null;
- }
- Calendar cal = Calendar.getInstance();
- cal.setTime(date);
- return String.valueOf(cal.get(Calendar.MONTH));
- }
-
- /**
- * @param date
- * @return
- */
- private static String getDayFromDate(Date date) {
- if (date == null) {
- return null;
- }
- Calendar cal = Calendar.getInstance();
- cal.setTime(date);
- return String.valueOf(cal.get(Calendar.DAY_OF_MONTH));
- }
-
- /**
- * Writes information about which series were added, removed or updated.
- * This information is used by Vaadin terminal class to decide whether to
- * add a new series or remove/delete an existing series. Basically, this
- * information helps client to update only a portion of the chart instead of
- * full chart.
- *
- * @param target
- * @param seriesCURMap
- * @throws PaintException
- */
-
- public static void writeChartDataUpdates(PaintTarget target,
- LinkedHashMap> seriesCURMap)
- throws PaintException {
- for (String seriesName : seriesCURMap.keySet()) {
- LinkedHashSet seriesCURSet = seriesCURMap
- .get(seriesName);
- if (seriesCURSet != null && seriesCURSet.size() > 0) {
- for (SeriesCUR seriesCUR : seriesCURSet) {
- target.startTag("seriesDataUpdate");
- target.addAttribute("seriesName", seriesCUR.getName());
- target.addAttribute("operation", seriesCUR.getType()
- .getName());
- target.addAttribute("isReloadPoints",
- seriesCUR.isReloadPoints());
- target.startTag("pointsAdded");
- if (seriesCUR.getPointsAdded().size() > 0) {
- writePoints(target, seriesCUR.getPointsAdded());
- }
- target.endTag("pointsAdded");
- target.startTag("pointsRemoved");
- if (seriesCUR.getPointsRemoved().size() > 0) {
- writePoints(target, seriesCUR.getPointsRemoved());
- }
- target.endTag("pointsRemoved");
- target.endTag("seriesDataUpdate");
- }
- }
- }
- }
-
-}
+/*
+ * Copyright 2011 Invient (www.invient.com)
+ *
+ * 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 com.invient.vaadin.charts;
+
+import com.invient.vaadin.charts.InvientCharts.*;
+import com.invient.vaadin.charts.InvientChartsConfig.*;
+import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.*;
+import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.DateTimePlotBand.DateTimeRange;
+import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.DateTimePlotLine.DateTimeValue;
+import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.NumberPlotBand.NumberRange;
+import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.NumberPlotLine.NumberValue;
+import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.PlotBand.Range;
+import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.PlotLine.Value;
+import com.invient.vaadin.charts.InvientChartsConfig.ChartLabel.ChartLabelItem;
+import com.invient.vaadin.charts.InvientChartsConfig.DateTimeAxis.DateTimeLabelFormat;
+import com.vaadin.terminal.PaintException;
+import com.vaadin.terminal.PaintTarget;
+
+import java.util.*;
+import java.util.Map.Entry;
+
+/**
+ * A utility class used by {@link InvientCharts} to write its state to the UIDL
+ * stream. The state includes properties of {@link InvientCharts} such as
+ * {@link InvientChartsConfig}, {@link Series}, {@link Point} and various chart
+ * events.
+ *
+ * In general, only non-null properties/attributes of a chart are written to the
+ * UIDL stream.
+ *
+ * @author Invient
+ */
+final class InvientChartsUtil {
+
+ /**
+ * Private constructor to prevent instantiation.
+ */
+ private InvientChartsUtil() {
+
+ }
+
+ /**
+ * Writes configuration attributes common to chart title and subtitle.
+ *
+ * @param target The paint target.
+ * @param titleBaseOptions The title base options.
+ * @throws PaintException
+ */
+ private static void writeTitleBaseOptions(PaintTarget target,
+ TitleBase titleBaseOptions) throws PaintException {
+ if (titleBaseOptions.getText() != null) {
+ target.addAttribute("text", titleBaseOptions.getText());
+ }
+ if (titleBaseOptions.getX() != null) {
+ target.addAttribute("x", titleBaseOptions.getX());
+ }
+ if (titleBaseOptions.getY() != null) {
+ target.addAttribute("y", titleBaseOptions.getY());
+ }
+ if (titleBaseOptions.getFloating() != null) {
+ target.addAttribute("floating", titleBaseOptions.getFloating());
+ }
+
+ if (titleBaseOptions.getAlign() != null) {
+ target.addAttribute("align", titleBaseOptions.getAlign().getName());
+ }
+ if (titleBaseOptions.getVertAlign() != null) {
+ target.addAttribute("verticalAlign", titleBaseOptions
+ .getVertAlign().getName());
+ }
+ if (titleBaseOptions.getStyle() != null) {
+ target.addAttribute("style", titleBaseOptions.getStyle());
+ }
+ }
+
+ /**
+ * Writes configuration attributes of the chart title.
+ *
+ * @param target The paint target.
+ * @param titleOptions The title options.
+ * @throws PaintException
+ */
+ public static void writeTitleConfig(PaintTarget target, Title titleOptions)
+ throws PaintException {
+ target.startTag("title");
+ writeTitleBaseOptions(target, titleOptions);
+ if (titleOptions.getMargin() != null) {
+ target.addAttribute("margin", titleOptions.getMargin());
+ }
+ target.endTag("title");
+ }
+
+ /**
+ * Writes configuration attributes of the chart subtitle. Only those
+ * attributes are written who have got non-null values.
+ *
+ * @param target The paint target.
+ * @param subtitleOptions The subtitle options.
+ * @throws PaintException
+ */
+ public static void writeSubtitleConfig(PaintTarget target,
+ SubTitle subtitleOptions) throws PaintException {
+ target.startTag("subtitle");
+ writeTitleBaseOptions(target, subtitleOptions);
+ target.endTag("subtitle");
+ }
+
+ /**
+ * Writes configuration attributes of the chart subtitle.
+ *
+ * @param target The paint target.
+ * @param creditOptions The credit options.
+ * @throws PaintException
+ */
+ public static void writeCreditConfig(PaintTarget target,
+ Credit creditOptions) throws PaintException {
+ target.startTag("credit");
+
+ if (creditOptions.getEnabled() != null) {
+ target.addAttribute("enabled", creditOptions.getEnabled());
+ }
+ target.startTag("position");
+ if (creditOptions.getPosition() != null) {
+ if (creditOptions.getPosition().getAlign() != null) {
+ target.addAttribute("align", creditOptions.getPosition()
+ .getAlign().getName());
+ }
+ if (creditOptions.getPosition().getVertAlign() != null) {
+ target.addAttribute("verticalAlign", creditOptions
+ .getPosition().getVertAlign().getName());
+ }
+ if (creditOptions.getPosition().getX() != null) {
+ target.addAttribute("x", creditOptions.getPosition().getX());
+ }
+ if (creditOptions.getPosition().getY() != null) {
+ target.addAttribute("y", creditOptions.getPosition().getY());
+ }
+ }
+ target.endTag("position");
+
+ if (creditOptions.getLink() != null) {
+ target.addAttribute("href", creditOptions.getLink());
+ }
+ if (creditOptions.getStyle() != null) {
+ target.addAttribute("style", creditOptions.getStyle());
+ }
+ if (creditOptions.getText() != null) {
+ target.addAttribute("text", creditOptions.getText());
+ }
+ target.endTag("credit");
+ }
+
+ /**
+ * Writes configuration attributes of the chart legend.
+ *
+ * @param target The paint target.
+ * @param legendOptions The ledgend options.
+ * @throws PaintException
+ */
+ public static void writeLegendConfig(PaintTarget target,
+ Legend legendOptions) throws PaintException {
+ target.startTag("legend");
+
+ if (legendOptions.getBackgroundColor() != null) {
+ target.addAttribute("backgroundColor", legendOptions
+ .getBackgroundColor().getString());
+ }
+
+ if (legendOptions.getBorderColor() != null) {
+ target.addAttribute("borderColor", legendOptions.getBorderColor()
+ .getString());
+ }
+
+ if (legendOptions.getBorderRadius() != null) {
+ target.addAttribute("borderRadius", legendOptions.getBorderRadius());
+ }
+
+ if (legendOptions.getBorderWidth() != null) {
+ target.addAttribute("borderWidth", legendOptions.getBorderWidth());
+ }
+
+ if (legendOptions.getEnabled() != null) {
+ target.addAttribute("enabled", legendOptions.getEnabled());
+ }
+
+ if (legendOptions.getFloating() != null) {
+ target.addAttribute("floating", legendOptions.getFloating());
+ }
+
+ if (legendOptions.getItemHiddenStyle() != null) {
+ target.addAttribute("itemHiddenStyle",
+ legendOptions.getItemHiddenStyle());
+ }
+
+ if (legendOptions.getItemHoverStyle() != null) {
+ target.addAttribute("itemHoverStyle",
+ legendOptions.getItemHoverStyle());
+ }
+
+ if (legendOptions.getItemStyle() != null) {
+ target.addAttribute("itemStyle", legendOptions.getItemStyle());
+ }
+
+ if (legendOptions.getItemWidth() != null) {
+ target.addAttribute("itemWidth", legendOptions.getItemWidth());
+ }
+
+ if (legendOptions.getLayout() != null) {
+ target.addAttribute("layout", legendOptions.getLayout().getName());
+ }
+
+ if (legendOptions.getLabelFormatterJsFunc() != null) {
+ target.addAttribute("labelFormatter",
+ legendOptions.getLabelFormatterJsFunc());
+ }
+
+ if (legendOptions.getMargin() != null) {
+ target.addAttribute("margin", legendOptions.getMargin());
+ }
+
+ if (legendOptions.getReversed() != null) {
+ target.addAttribute("reversed", legendOptions.getReversed());
+ }
+
+ if (legendOptions.getShadow() != null) {
+ target.addAttribute("shadow", legendOptions.getShadow());
+ }
+
+ if (legendOptions.getSymbolPadding() != null) {
+ target.addAttribute("symbolPadding",
+ legendOptions.getSymbolPadding());
+ }
+
+ if (legendOptions.getSymbolWidth() != null) {
+ target.addAttribute("symbolWidth", legendOptions.getSymbolWidth());
+ }
+
+ if (legendOptions.getWidth() != null) {
+ target.addAttribute("width", legendOptions.getWidth());
+ }
+
+ if (legendOptions.getPosition() != null) {
+ if (legendOptions.getPosition().getAlign() != null) {
+ target.addAttribute("align", legendOptions.getPosition()
+ .getAlign().getName());
+ }
+ if (legendOptions.getPosition().getVertAlign() != null) {
+ target.addAttribute("verticalAlign", legendOptions
+ .getPosition().getVertAlign().getName());
+ }
+ if (legendOptions.getPosition().getX() != null) {
+ target.addAttribute("x", legendOptions.getPosition().getX());
+ }
+ if (legendOptions.getPosition().getY() != null) {
+ target.addAttribute("y", legendOptions.getPosition().getY());
+ }
+ }
+
+ target.endTag("legend");
+ }
+
+ /**
+ * Writes configuration attributes of the chart tooltip.
+ *
+ * @param target The paint target.
+ * @param tooltipOptions The tooltip options.
+ * @throws PaintException
+ */
+ public static void writeTooltipConfig(PaintTarget target,
+ Tooltip tooltipOptions) throws PaintException {
+ target.startTag("tooltip");
+
+ if (tooltipOptions.getBackgroundColor() != null) {
+ target.addAttribute("backgroundColor", tooltipOptions
+ .getBackgroundColor().getString());
+ }
+ if (tooltipOptions.getBorderColor() != null) {
+ target.addAttribute("borderColor", tooltipOptions.getBorderColor()
+ .getString());
+ }
+ if (tooltipOptions.getBorderRadius() != null) {
+ target.addAttribute("borderRadius",
+ tooltipOptions.getBorderRadius());
+ }
+ if (tooltipOptions.getBorderWidth() != null) {
+ target.addAttribute("borderWidth", tooltipOptions.getBorderWidth());
+ }
+ if (tooltipOptions.getCrosshairs() != null) {
+ target.startTag("crosshairs");
+ writeTooltipCrosshairsConfig(target, tooltipOptions.getCrosshairs());
+ target.endTag("crosshairs");
+ }
+ if (tooltipOptions.getEnabled() != null) {
+ target.addAttribute("enabled", tooltipOptions.getEnabled());
+ }
+ if (tooltipOptions.getFormatterJsFunc() != null) {
+ target.addAttribute("formatter",
+ tooltipOptions.getFormatterJsFunc());
+ }
+ if (tooltipOptions.getShadow() != null) {
+ target.addAttribute("shadow", tooltipOptions.getShadow());
+ }
+ if (tooltipOptions.getShared() != null) {
+ target.addAttribute("shared", tooltipOptions.getShared());
+ }
+ if (tooltipOptions.getSnap() != null) {
+ target.addAttribute("snap", tooltipOptions.getSnap());
+ }
+ if (tooltipOptions.getStyle() != null) {
+ target.addAttribute("style", tooltipOptions.getStyle());
+ }
+ if (tooltipOptions.getUseHTML() != null) {
+ target.addAttribute("useHTML", tooltipOptions.getUseHTML());
+ }
+ if (tooltipOptions.getHeaderFormat() != null) {
+ target.addAttribute("headerFormat", tooltipOptions.getHeaderFormat());
+ }
+ if (tooltipOptions.getPointFormat() != null) {
+ target.addAttribute("pointFormat", tooltipOptions.getPointFormat());
+ }
+ if (tooltipOptions.getFooterFormat() != null) {
+ target.addAttribute("footerFormat", tooltipOptions.getFooterFormat());
+ }
+
+ target.endTag("tooltip");
+ }
+
+ /**
+ * Writes configuration attributes of the charts tooltip crosshairsOptions.
+ *
+ * @param target The paint target.
+ * @param crosshairsOptions The crosshairs options.
+ * @throws PaintException
+ */
+ public static void writeTooltipCrosshairsConfig(PaintTarget target,
+ Tooltip.Crosshairs crosshairsOptions) throws PaintException {
+ if (crosshairsOptions.getWidth() != null) {
+ target.addAttribute("width", crosshairsOptions.getWidth());
+ }
+ if (crosshairsOptions.getColor() != null) {
+ target.addAttribute("color", crosshairsOptions.getColor().getString());
+ }
+ if (crosshairsOptions.getDashStyle() != null) {
+ target.addAttribute("dashStyle", crosshairsOptions.getDashStyle().getName());
+ }
+ if (crosshairsOptions.getzIndex() != null) {
+ target.addAttribute("zIndex", crosshairsOptions.getzIndex());
+ }
+
+ }
+
+ /**
+ * Writes configuration attributes of the chart itself.
+ *
+ * @param target The paint target.
+ * @param chartOptions The chart options.
+ * @throws PaintException
+ */
+ public static void writeGeneralChartConfig(PaintTarget target,
+ GeneralChartConfig chartOptions) throws PaintException {
+ target.startTag("chart");
+
+ if (chartOptions.getType() != null) {
+ target.addAttribute("type", chartOptions.getType().getName());
+ }
+
+ if (chartOptions.getWidth() != null) {
+ target.addAttribute("width", chartOptions.getWidth());
+ }
+ if (chartOptions.getHeight() != null) {
+ target.addAttribute("height", chartOptions.getHeight());
+ }
+
+ if (chartOptions.getBackgroundColor() != null) {
+ target.addAttribute("backgroundColor", chartOptions
+ .getBackgroundColor().getString());
+ }
+ if (chartOptions.getBorderColor() != null) {
+ target.addAttribute("borderColor", chartOptions.getBorderColor()
+ .getString());
+ }
+ if (chartOptions.getBorderRadius() != null) {
+ target.addAttribute("borderRadius", chartOptions.getBorderRadius());
+ }
+ if (chartOptions.getBorderWidth() != null) {
+ target.addAttribute("borderWidth", chartOptions.getBorderWidth());
+ }
+
+ if (chartOptions.getIgnoreHiddenSeries() != null) {
+ target.addAttribute("ignoreHiddenSeries",
+ chartOptions.getIgnoreHiddenSeries());
+ }
+ if (chartOptions.getInverted() != null) {
+ target.addAttribute("inverted", chartOptions.getInverted());
+ }
+
+ if (chartOptions.getMargin() != null) {
+ if (chartOptions.getMargin().getTop() != null) {
+ target.addAttribute("marginTop", chartOptions.getMargin()
+ .getTop());
+ }
+ if (chartOptions.getMargin().getLeft() != null) {
+ target.addAttribute("marginLeft", chartOptions.getMargin()
+ .getLeft());
+ }
+ if (chartOptions.getMargin().getBottom() != null) {
+ target.addAttribute("marginBottom", chartOptions.getMargin()
+ .getBottom());
+ }
+ if (chartOptions.getMargin().getRight() != null) {
+ target.addAttribute("marginRight", chartOptions.getMargin()
+ .getRight());
+ }
+ }
+
+ if (chartOptions.getSpacing() != null) {
+
+ if (chartOptions.getSpacing().getTop() != null) {
+ target.addAttribute("spacingTop", chartOptions.getSpacing()
+ .getTop());
+ }
+ if (chartOptions.getSpacing().getLeft() != null) {
+ target.addAttribute("spacingLeft", chartOptions.getSpacing()
+ .getLeft());
+ }
+ if (chartOptions.getSpacing().getBottom() != null) {
+ target.addAttribute("spacingBottom", chartOptions.getSpacing()
+ .getBottom());
+ }
+ if (chartOptions.getSpacing().getRight() != null) {
+ target.addAttribute("spacingRight", chartOptions.getSpacing()
+ .getRight());
+ }
+ }
+
+ if (chartOptions.getShowAxes() != null) {
+ target.addAttribute("showAxes", chartOptions.getShowAxes());
+ }
+ if (chartOptions.getZoomType() != null) {
+ target.addAttribute("zoomType", chartOptions.getZoomType()
+ .getName());
+ }
+ target.addAttribute("clientZoom", chartOptions.isClientZoom());
+
+ if (chartOptions.getAlignTicks() != null) {
+ target.addAttribute("alignTicks", chartOptions.getAlignTicks());
+ }
+ if (chartOptions.getAnimation() != null) {
+ target.addAttribute("animation", chartOptions.getAnimation());
+ }
+ if (chartOptions.getClassName() != null) {
+ target.addAttribute("className", chartOptions.getClassName());
+ }
+
+ if (chartOptions.getPlot() != null) {
+ if (chartOptions.getPlot().getBackgroundColor() != null) {
+ target.addAttribute("plotBackgroundColor", chartOptions
+ .getPlot().getBackgroundColor().getString());
+ }
+ if (chartOptions.getPlot().getBorderColor() != null) {
+ target.addAttribute("plotBorderColor", chartOptions.getPlot()
+ .getBorderColor().getString());
+ }
+ if (chartOptions.getPlot().getBackgroundImage() != null) {
+ target.addAttribute("plotBackgroundImage", chartOptions
+ .getPlot().getBackgroundImage());
+ }
+ if (chartOptions.getPlot().getBorderWidth() != null) {
+ target.addAttribute("plotBorderWidth", chartOptions.getPlot()
+ .getBorderWidth());
+ }
+ if (chartOptions.getPlot().getShadow() != null) {
+ target.addAttribute("plotShadow", chartOptions.getPlot()
+ .getShadow());
+ }
+ }
+
+ if (chartOptions.getReflow() != null) {
+ target.addAttribute("reflow", chartOptions.getReflow());
+ }
+ if (chartOptions.getShadow() != null) {
+ target.addAttribute("shadow", chartOptions.getShadow());
+ }
+ if (chartOptions.getStyle() != null) {
+ target.addAttribute("style", chartOptions.getStyle());
+ }
+
+ target.endTag("chart");
+ }
+
+ /**
+ * Writes configuration attributes of every series type. The series type can
+ * be one of the line, spline, scatter, area, areaspline, bar, column and
+ * pie.
+ *
+ * @param target The paint target.
+ * @param seriesOptions The series options.
+ * @throws PaintException
+ */
+ public static void writeSeriesConfigPerSeriesType(PaintTarget target,
+ Map seriesOptions) throws PaintException {
+ target.startTag("seriesOptionsPerSeriesType");
+ // For each SeriesType have separate tag
+ for (Entry seriesEntryOptions : seriesOptions
+ .entrySet()) {
+ String tagName = seriesEntryOptions.getKey().getName();
+ //
+ target.startTag(tagName);
+ // Write options for appropriate series type
+ writeSeriesConfig(target, seriesEntryOptions.getValue());
+ //
+ target.endTag(tagName);
+ }
+ target.endTag("seriesOptionsPerSeriesType");
+ }
+
+ /**
+ * Writes configuration attributes of a single series.
+ *
+ * @param target The paint target.
+ * @param series The series options.
+ * @throws PaintException
+ */
+ private static void writeSeriesConfig(PaintTarget target, SeriesConfig series) throws PaintException {
+ // Write options for appropriate series type
+
+ if (series instanceof LineConfig) {
+ writeLineOptions(target, (LineConfig) series);
+ } else if (series instanceof ScatterConfig) {
+ writeScatterOptions(target, (ScatterConfig) series);
+ } else if (series instanceof AreaSplineConfig) {
+ writeAreaSplineOptions(target, (AreaSplineConfig) series);
+ } else if (series instanceof SplineConfig) {
+ writeSplineOptions(target, (SplineConfig) series);
+ } else if (series instanceof AreaConfig) {
+ writeAreaOptions(target, (AreaConfig) series);
+ } else if (series instanceof ColumnConfig) {
+ writeColumnOptions(target, (ColumnConfig) series);
+ } else if (series instanceof BarConfig) {
+ writeBarOptions(target, (BarConfig) series);
+ } else if (series instanceof PieConfig) {
+ writePieOptions(target, (PieConfig) series);
+ } else {
+ // Common series attributes
+ writeCommonSeriesOptions(target, series);
+ }
+
+ }
+
+ /**
+ * Writes configuration attributes common to all types of series.
+ *
+ * @param target The paint target.
+ * @param seriesOptions The series options.
+ * @throws PaintException
+ */
+ private static void writeCommonSeriesOptions(PaintTarget target,
+ SeriesConfig seriesOptions) throws PaintException {
+ if (seriesOptions.getAllowPointSelect() != null) {
+ target.addAttribute("allowPointSelect",
+ seriesOptions.getAllowPointSelect());
+ }
+ if (seriesOptions.getAnimation() != null) {
+ target.addAttribute("animation", seriesOptions.getAnimation());
+ }
+ if (seriesOptions.getCursor() != null) {
+ target.addAttribute("cursor", seriesOptions.getCursor());
+ }
+
+ if (seriesOptions.getColor() != null) {
+ target.addAttribute("color", seriesOptions.getColor().getString());
+ }
+ if (seriesOptions.getEnableMouseTracking() != null) {
+ target.addAttribute("enableMouseTracking",
+ seriesOptions.getEnableMouseTracking());
+ }
+
+ // if (seriesOptions.getSelected() != null) {
+ // target.addAttribute("selected", seriesOptions.getSelected());
+ // }
+
+ if (seriesOptions.getShowCheckbox() != null) {
+ target.addAttribute("showCheckbox", seriesOptions.getShowCheckbox());
+ }
+ if (seriesOptions.getShowInLegend() != null) {
+ target.addAttribute("showInLegend", seriesOptions.getShowInLegend());
+ }
+ if (seriesOptions.getStacking() != null) {
+ target.addAttribute("stacking", seriesOptions.getStacking()
+ .getName());
+ }
+ if (seriesOptions.getShadow() != null) {
+ target.addAttribute("shadow", seriesOptions.getShadow());
+ }
+ if (seriesOptions.getVisible() != null) {
+ target.addAttribute("visible", seriesOptions.getVisible());
+ }
+
+ writeSeriesDataLabel(target, seriesOptions.getDataLabel());
+ writeSeriesState(target, seriesOptions.getHoverState());
+ }
+
+ /**
+ * Writes configuration attributes of a series hover state.
+ *
+ * @param target The paint target.
+ * @param seriesState The series state.
+ * @throws PaintException
+ */
+ private static void writeSeriesState(PaintTarget target,
+ SeriesState seriesState) throws PaintException {
+ target.startTag("state");
+ if (seriesState != null) {
+ target.startTag("hover");
+ if (seriesState.getEnabled() != null) {
+ target.addAttribute("enabled", seriesState.getEnabled());
+ }
+ if (seriesState.getLineWidth() != null) {
+ target.addAttribute("lineWidth", seriesState.getLineWidth());
+ }
+ if (seriesState instanceof NonLinearSeriesState
+ && ((NonLinearSeriesState) seriesState).getBrightness() != null) {
+ target.addAttribute("brightness",
+ ((NonLinearSeriesState) seriesState).getBrightness());
+ }
+ target.endTag("hover");
+ }
+ target.endTag("state");
+ }
+
+ /**
+ * Writes configuration attributes common to all types of series. It takes
+ * care of specific data labels in case of pie.
+ *
+ * @param target The paint target.
+ * @param dataLabel The data label.
+ * @throws PaintException
+ */
+ private static void writeSeriesDataLabel(PaintTarget target,
+ DataLabel dataLabel) throws PaintException {
+ target.startTag("dataLabel");
+ if (dataLabel != null) {
+ if (dataLabel instanceof PieDataLabel) {
+ writePieDataLabel(target, (PieDataLabel) dataLabel);
+ } else {
+ writeDataLabel(target, dataLabel);
+ }
+ }
+ target.endTag("dataLabel");
+ }
+
+ /**
+ * Writes configuration attributes of a series data labels.
+ *
+ * @param target The paint target.
+ * @param dataLabel The data label.
+ * @throws PaintException
+ */
+ private static void writeDataLabel(PaintTarget target, DataLabel dataLabel)
+ throws PaintException {
+ if (dataLabel.getAlign() != null) {
+ target.addAttribute("align", dataLabel.getAlign().getName());
+ }
+ if (dataLabel.getEnabled() != null) {
+ target.addAttribute("enabled", dataLabel.getEnabled());
+ }
+ if (dataLabel.getFormatterJsFunc() != null) {
+ target.addAttribute("formatter", dataLabel.getFormatterJsFunc());
+ }
+ if (dataLabel.getRotation() != null) {
+ target.addAttribute("rotation", dataLabel.getRotation());
+ }
+ if (dataLabel.getStyle() != null) {
+ target.addAttribute("style", dataLabel.getStyle());
+ }
+ if (dataLabel.getX() != null) {
+ target.addAttribute("x", dataLabel.getX());
+ }
+ if (dataLabel.getY() != null) {
+ target.addAttribute("y", dataLabel.getY());
+ }
+ if (dataLabel.getColor() != null) {
+ target.addAttribute("color", dataLabel.getColor().getString());
+ }
+ }
+
+ /**
+ * Writes configuration attributes of a pie chart's data label.
+ *
+ * @param target The paint target.
+ * @param dataLabel The data label.
+ * @throws PaintException
+ */
+ private static void writePieDataLabel(PaintTarget target,
+ PieDataLabel dataLabel) throws PaintException {
+
+ writeDataLabel(target, dataLabel);
+
+ if (dataLabel.getConnectorWidth() != null) {
+ target.addAttribute("connectorWidth", dataLabel.getConnectorWidth());
+ }
+ if (dataLabel.getConnectorPadding() != null) {
+ target.addAttribute("connectorPadding",
+ dataLabel.getConnectorPadding());
+ }
+ if (dataLabel.getConnectorColor() != null) {
+ target.addAttribute("connectorColor", dataLabel.getConnectorColor()
+ .getString());
+ }
+ if (dataLabel.getDistance() != null) {
+ target.addAttribute("distance", dataLabel.getDistance());
+ }
+
+ }
+
+ /**
+ * Writes configuration attributes of an axis data labels.
+ *
+ * @param target The paint target.
+ * @param dataLabel The data label.
+ * @throws PaintException
+ */
+ private static void writeAxisDataLabel(PaintTarget target,
+ AxisDataLabel dataLabel) throws PaintException {
+
+ writeDataLabel(target, dataLabel);
+
+ if (dataLabel.getStep() != null) {
+ target.addAttribute("step", dataLabel.getStep());
+ }
+
+ }
+
+ /**
+ * Writes configuration attributes of an x-axis data labels.
+ *
+ * @param target The paint target.
+ * @param dataLabel The data label.
+ * @throws PaintException
+ */
+ private static void writeXAxisDataLabel(PaintTarget target,
+ XAxisDataLabel dataLabel) throws PaintException {
+ target.startTag("label");
+ if (dataLabel != null) {
+ writeAxisDataLabel(target, dataLabel);
+
+ if (dataLabel.getStaggerLines() != null) {
+ target.addAttribute("staggerLines", dataLabel.getStaggerLines());
+ }
+ }
+
+ target.endTag("label");
+ }
+
+ /**
+ * Writes configuration attributes of y-axis data labels.
+ *
+ * @param target The paint target.
+ * @param dataLabel The data label.
+ * @throws PaintException
+ */
+ private static void writeYAxisDataLabel(PaintTarget target,
+ YAxisDataLabel dataLabel) throws PaintException {
+ target.startTag("label");
+
+ if (dataLabel != null) {
+ writeAxisDataLabel(target, dataLabel);
+ }
+ target.endTag("label");
+ }
+
+ /**
+ * Writes configuration attributes of a marker. It takes care of handling
+ * image or symbol marker.
+ *
+ * @param target The paint target.
+ * @param markerOptions The marker options.
+ * @throws PaintException
+ */
+ private static void writeMarkerOptions(PaintTarget target,
+ Marker markerOptions) throws PaintException {
+ target.startTag("marker");
+ if (markerOptions != null) {
+ if (markerOptions.getEnabled() != null) {
+ target.addAttribute("enabled", markerOptions.getEnabled());
+ }
+ if (markerOptions instanceof ImageMarker) {
+ target.addAttribute("markerType", "image");
+ writeImageMarkerOptions(target, (ImageMarker) markerOptions);
+ } else if (markerOptions instanceof SymbolMarker) {
+ target.addAttribute("markerType", "symbol");
+ writeSymbolMarkerOptions(target, (SymbolMarker) markerOptions);
+ writeMarkerStates(target, (SymbolMarker) markerOptions);
+ }
+ }
+ target.endTag("marker");
+ }
+
+ /**
+ * Writes configuration attributes of a marker states hover and select
+ *
+ * @param target The paint target.
+ * @param marker The marker.
+ * @throws PaintException
+ */
+ private static void writeMarkerStates(PaintTarget target,
+ SymbolMarker marker) throws PaintException {
+ target.startTag("states");
+ //
+ target.startTag("hover");
+ if (marker.getHoverState() != null) {
+ writeMarkerState(target, marker.getHoverState());
+ }
+ target.endTag("hover");
+
+ //
+ target.startTag("select");
+ if (marker.getSelectState() != null) {
+ writeMarkerState(target, marker.getSelectState());
+ }
+ target.endTag("select");
+
+ target.endTag("states");
+ }
+
+ /**
+ * Writes configuration attributes of an image marker
+ *
+ * @param target The paint target.
+ * @param imgMarker The image marker.
+ * @throws PaintException
+ */
+ private static void writeImageMarkerOptions(PaintTarget target,
+ ImageMarker imgMarker) throws PaintException {
+ if (imgMarker.getImageURL() != null) {
+ target.addAttribute("symbol", imgMarker.getImageURL());
+ }
+ }
+
+ /**
+ * Writes configuration attributes of a symbol marker
+ *
+ * @param target The paint target.
+ * @param symbolMarker The symbol marker.
+ * @throws PaintException
+ */
+ private static void writeSymbolMarkerOptions(PaintTarget target,
+ SymbolMarker symbolMarker) throws PaintException {
+ if (symbolMarker.getFillColor() != null) {
+ target.addAttribute("fillColor", symbolMarker.getFillColor()
+ .getString());
+ }
+ if (symbolMarker.getLineColor() != null) {
+ target.addAttribute("lineColor", symbolMarker.getLineColor()
+ .getString());
+ }
+ if (symbolMarker.getLineWidth() != null) {
+ target.addAttribute("lineWidth", symbolMarker.getLineWidth());
+ }
+ if (symbolMarker.getRadius() != null) {
+ target.addAttribute("radius", symbolMarker.getRadius());
+ }
+ if (symbolMarker.getSymbol() != null) {
+ target.addAttribute("symbol", symbolMarker.getSymbol().getName());
+ }
+ }
+
+ /**
+ * Writes configuration attributes of a marker
+ *
+ * @param target The paint target.
+ * @param markerState The marker state.
+ * @throws PaintException
+ */
+ private static void writeMarkerState(PaintTarget target,
+ MarkerState markerState) throws PaintException {
+ if (markerState.getEnabled() != null) {
+ target.addAttribute("enabled", markerState.getEnabled());
+ }
+ if (markerState.getFillColor() != null) {
+ target.addAttribute("fillColor", markerState.getFillColor()
+ .getString());
+ }
+ if (markerState.getLineColor() != null) {
+ target.addAttribute("lineColor", markerState.getLineColor()
+ .getString());
+ }
+ if (markerState.getLineWidth() != null) {
+ target.addAttribute("lineWidth", markerState.getLineWidth());
+ }
+ if (markerState.getRadius() != null) {
+ target.addAttribute("radius", markerState.getRadius());
+ }
+ }
+
+ /**
+ * Writes configuration attributes common to all lines series such as line,
+ * spline and area.
+ *
+ * @param target The paint target.
+ * @param baseLineOptions The base line options.
+ * @throws PaintException
+ */
+ private static void writeBaseLineOptions(PaintTarget target,
+ BaseLineConfig baseLineOptions) throws PaintException {
+ writeCommonSeriesOptions(target, baseLineOptions);
+ if (baseLineOptions.getDashStyle() != null) {
+ target.addAttribute("dashStyle", baseLineOptions.getDashStyle()
+ .getName());
+ }
+ if (baseLineOptions.getLineWidth() != null) {
+ target.addAttribute("lineWidth", baseLineOptions.getLineWidth());
+ }
+ if (baseLineOptions.getPointInterval() != null) {
+ target.addAttribute("pointInterval",
+ baseLineOptions.getPointInterval());
+ }
+ if (baseLineOptions.getTurboThreshold() != null) {
+ target.addAttribute("turboThreshold",
+ baseLineOptions.getTurboThreshold());
+ }
+ if (baseLineOptions.getPointStart() != null) {
+ target.addAttribute("pointStart", baseLineOptions.getPointStart());
+ }
+ if (baseLineOptions.getStickyTracking() != null) {
+ target.addAttribute("stickyTracking",
+ baseLineOptions.getStickyTracking());
+ }
+ writeMarkerOptions(target, baseLineOptions.getMarker());
+ }
+
+ /**
+ * Writes configuration attributes of a spline series
+ *
+ * @param target The paint target.
+ * @param splineOptions The spline options.
+ * @throws PaintException
+ */
+ private static void writeSplineOptions(PaintTarget target,
+ SplineConfig splineOptions) throws PaintException {
+ writeBaseLineOptions(target, splineOptions);
+ }
+
+ /**
+ * Writes configuration attributes of s scatter series
+ *
+ * @param target The paint target.
+ * @param scatterOptions The scatter options.
+ * @throws PaintException
+ */
+ private static void writeScatterOptions(PaintTarget target,
+ ScatterConfig scatterOptions) throws PaintException {
+ writeBaseLineOptions(target, scatterOptions);
+ }
+
+ /**
+ * Writes configuration attributes of a line series
+ *
+ * @param target The paint target.
+ * @param lineOptions The line options.
+ * @throws PaintException
+ */
+ private static void writeLineOptions(PaintTarget target,
+ LineConfig lineOptions) throws PaintException {
+ writeBaseLineOptions(target, lineOptions);
+ //
+ if (lineOptions.getStep() != null) {
+ target.addAttribute("step", lineOptions.getStep());
+ }
+ }
+
+ /**
+ * Writes configuration attributes of an area series
+ *
+ * @param target The paint target.
+ * @param areaOptions The area options.
+ * @throws PaintException
+ */
+ private static void writeAreaOptions(PaintTarget target,
+ AreaConfig areaOptions) throws PaintException {
+ writeBaseLineOptions(target, areaOptions);
+ //
+ if (areaOptions.getFillColor() != null) {
+ target.addAttribute("fillColor", areaOptions.getFillColor()
+ .getString());
+ }
+ if (areaOptions.getFillOpacity() != null) {
+ target.addAttribute("fillOpacity", areaOptions.getFillOpacity());
+ }
+ if (areaOptions.getLineColor() != null) {
+ target.addAttribute("lineColor", areaOptions.getLineColor()
+ .getString());
+ }
+ if (areaOptions.getThreshold() != null) {
+ target.addAttribute("threshold", areaOptions.getThreshold());
+ }
+
+ }
+
+ /**
+ * Writes configuration attributes of an area-spline
+ *
+ * @param target The paint target.
+ * @param areaSplineOptions The area spline options.
+ * @throws PaintException
+ */
+ private static void writeAreaSplineOptions(PaintTarget target,
+ AreaSplineConfig areaSplineOptions) throws PaintException {
+ writeAreaOptions(target, areaSplineOptions);
+ }
+
+ /**
+ * Writes configuration attributes of a pie series
+ *
+ * @param target The paint target.
+ * @param pieOptions The pie options.
+ * @throws PaintException
+ */
+ private static void writePieOptions(PaintTarget target, PieConfig pieOptions)
+ throws PaintException {
+ writeCommonSeriesOptions(target, pieOptions);
+ //
+ if (pieOptions.getBorderColor() != null) {
+ target.addAttribute("borderColor", pieOptions.getBorderColor()
+ .getString());
+ }
+ if (pieOptions.getBorderWidth() != null) {
+ target.addAttribute("borderWidth", pieOptions.getBorderWidth());
+ }
+ if (pieOptions.getCenterX() != null) {
+ target.addAttribute("centerX", pieOptions.getCenterX());
+ }
+ if (pieOptions.getCenterY() != null) {
+ target.addAttribute("centerY", pieOptions.getCenterY());
+ }
+ if (pieOptions.getInnerSize() != null) {
+ target.addAttribute("innerSize", pieOptions.getInnerSize());
+ }
+ if (pieOptions.getSize() != null) {
+ target.addAttribute("size", pieOptions.getSize());
+ }
+ if (pieOptions.getSlicedOffset() != null) {
+ target.addAttribute("slicedOffset", pieOptions.getSlicedOffset());
+ }
+ if (pieOptions.getIgnoreHiddenPoint() != null) {
+ target.addAttribute("ignoreHiddenPoint", pieOptions.getIgnoreHiddenPoint());
+ }
+ }
+
+ /**
+ * Writes configuration attributes common to columnar series such as bar and
+ * column
+ *
+ * @param target The paint target.
+ * @param baseBarOptions The base bar options.
+ * @throws PaintException
+ */
+ private static void writeBaseBarOptions(PaintTarget target,
+ BaseBarConfig baseBarOptions) throws PaintException {
+ writeCommonSeriesOptions(target, baseBarOptions);
+
+ if (baseBarOptions.getBorderColor() != null) {
+ target.addAttribute("borderColor", baseBarOptions.getBorderColor()
+ .getString());
+ }
+ if (baseBarOptions.getBorderRadius() != null) {
+ target.addAttribute("borderRadius",
+ baseBarOptions.getBorderRadius());
+ }
+ if (baseBarOptions.getBorderWidth() != null) {
+ target.addAttribute("borderWidth", baseBarOptions.getBorderWidth());
+ }
+ if (baseBarOptions.getColorByPoint() != null) {
+ target.addAttribute("colorByPoint",
+ baseBarOptions.getColorByPoint());
+ }
+ if (baseBarOptions.getGroupPadding() != null) {
+ target.addAttribute("groupPadding",
+ baseBarOptions.getGroupPadding());
+ }
+ if (baseBarOptions.getMinPointLength() != null) {
+ target.addAttribute("minPointLength",
+ baseBarOptions.getMinPointLength());
+ }
+ if (baseBarOptions.getPointPadding() != null) {
+ target.addAttribute("pointPadding",
+ baseBarOptions.getPointPadding());
+ }
+ if (baseBarOptions.getPointWidth() != null) {
+ target.addAttribute("pointWidth", baseBarOptions.getPointWidth());
+ }
+ }
+
+ /**
+ * Writes configuration attributes of a bar series
+ *
+ * @param target The paint target.
+ * @param barOptions The bar options.
+ * @throws PaintException
+ */
+ private static void writeBarOptions(PaintTarget target, BarConfig barOptions)
+ throws PaintException {
+ writeBaseBarOptions(target, barOptions);
+ }
+
+ /**
+ * Writes configuration attributes of a column series
+ *
+ * @param target The paint target.
+ * @param columnOptions The column options.
+ * @throws PaintException
+ */
+ private static void writeColumnOptions(PaintTarget target,
+ ColumnConfig columnOptions) throws PaintException {
+ writeBaseBarOptions(target, columnOptions);
+ }
+
+ /**
+ * Writes data of each series of the chart. It transforms data into a form
+ * which is usable by the Vaadin terminal class. It also writes
+ * configuration attributes specific to each series, if any.
+ *
+ * @param target The paint target.
+ * @param chartSeriesType The chart series type.
+ * @param data The data.
+ * @param xAxis The x-axis.
+ * @param yAxis The y-axis.
+ *
+ * @throws PaintException
+ */
+ public static void writeSeries(PaintTarget target,
+ SeriesType chartSeriesType, LinkedHashSet data,
+ LinkedHashSet xAxis, LinkedHashSet yAxis)
+ throws PaintException {
+ if (data == null) {
+ return;
+ }
+ for (Series series : data) {
+ target.startTag("series");
+
+ if (series.getName() != null && series.getName().length() > 0) {
+ target.addAttribute("name", series.getName());
+ }
+ if (series.getType() != null) {
+ target.addAttribute("type", series.getType().getName());
+ }
+ if (series.getStack() != null && series.getStack().length() > 0) {
+ target.addAttribute("stack", series.getStack());
+ }
+
+ target.addAttribute("xAxis",
+ getXAxisIndex(series.getXAxis(), xAxis));
+ target.addAttribute("yAxis",
+ getYAxisIndex(series.getYAxis(), yAxis));
+
+ String seriesOptionsTagName = chartSeriesType.getName();
+ if (series.getType() != null) {
+ seriesOptionsTagName = series.getType().getName();
+ }
+
+ target.startTag(seriesOptionsTagName);
+ if (series.getConfig() != null) {
+ writeSeriesConfig(target, series.getConfig());
+ }
+ target.endTag(seriesOptionsTagName);
+
+ target.startTag("points");
+ if (series.getPoints() != null) {
+ writePoints(target, series.getPoints());
+ }
+ target.endTag("points");
+
+ target.endTag("series");
+ }
+
+ }
+
+ /**
+ * Writes point data (x, y) and its configuration attributes, if any. If a
+ * point does not have x and y values then the point is skipped. However,
+ * for such points empty tags is created without any attributes or children.
+ *
+ * @param target
+ * @param points
+ * @throws PaintException
+ */
+ private static void writePoints(PaintTarget target,
+ LinkedHashSet extends Point> points) throws PaintException {
+ if (points == null) {
+ return;
+ }
+ for (Point point : points) {
+ target.startTag("point");
+ if (point.getX() != null || point.getY() != null) {
+ if (point.getId() != null && point.getId().length() > 0) {
+ target.addAttribute("id", point.getId());
+ }
+ if (point.getName() != null && point.getName().length() > 0) {
+ target.addAttribute("name", point.getName());
+ }
+ if (point.getX() != null) {
+ if (point instanceof DecimalPoint) {
+ target.addAttribute("x", (Double) point.getX());
+ } else {
+ target.addAttribute(
+ "x",
+ getDate((Date) point.getX(),
+ ((DateTimeSeries) point.getSeries())
+ .isIncludeTime()));
+ }
+ }
+ if (point.getY() != null) {
+ target.addAttribute("y", (Double) point.getY());
+ }
+ target.addAttribute("isShift", point.isShift());
+ // Point config
+ if (point.getConfig() != null) {
+ if (point.getConfig().getSliced() != null) {
+ target.addAttribute("sliced", point.getConfig()
+ .getSliced());
+ }
+ if (point.getConfig().getSelected() != null) {
+ target.addAttribute("selected", point.getConfig()
+ .getSelected());
+ }
+ if (point.getConfig().getColor() != null) {
+ target.addAttribute("color", point.getConfig()
+ .getColor().getString());
+ }
+ if (point.getConfig().getMarker() != null) {
+ writeMarkerOptions(target, point.getConfig()
+ .getMarker());
+ }
+ }
+ }
+ target.endTag("point");
+ }
+ }
+
+ /**
+ * Writes configuration attributes common to all types of axis.
+ *
+ * @param target
+ * @param axis
+ * @param axes
+ * @throws PaintException
+ */
+ private static void writeBaseAxis(PaintTarget target, AxisBase axis,
+ LinkedHashSet extends Axis> axes) throws PaintException {
+
+ if (axis.getAlternateGridColor() != null) {
+ target.addAttribute("alternateGridColor", axis
+ .getAlternateGridColor().getString());
+ }
+ if (axis.getEndOnTick() != null) {
+ target.addAttribute("endOnTick", axis.getEndOnTick());
+ }
+ if (axis.getGrid() != null) {
+ writeAxisGrid(target, axis.getGrid());
+ }
+ if (axis.getId() != null && axis.getId().length() > 0) {
+ target.addAttribute("id", axis.getId());
+ }
+
+ if (axis.getLineColor() != null) {
+ target.addAttribute("lineColor", axis.getLineColor().getString());
+ }
+ if (axis.getLineWidth() != null) {
+ target.addAttribute("lineWidth", axis.getLineWidth());
+ }
+ if (axis.getLinkedTo() != null) {
+ target.addAttribute("linkedTo",
+ getAxisIndex(axis.getLinkedTo(), axes));
+ }
+
+ if (axis.getMaxPadding() != null) {
+ target.addAttribute("maxPadding", axis.getMaxPadding());
+ }
+ if (axis.getMaxZoom() != null) {
+ target.addAttribute("maxZoom", axis.getMaxZoom());
+ }
+ if (axis.getMinPadding() != null) {
+ target.addAttribute("minPadding", axis.getMinPadding());
+ }
+
+ //
+ if (axis.getMinorGrid() != null) {
+ writeAxisMinorGrid(target, axis.getMinorGrid());
+ }
+ //
+ if (axis.getMinorTick() != null) {
+ writeAxisMinorTick(target, axis.getMinorTick());
+ }
+
+ if (axis.getOffset() != null) {
+ target.addAttribute("offset", axis.getOffset());
+ }
+ if (axis.getOpposite() != null) {
+ target.addAttribute("opposite", axis.getOpposite());
+ }
+ if (axis.getReversed() != null) {
+ target.addAttribute("reversed", axis.getReversed());
+ }
+ if (axis.getShowFirstLabel() != null) {
+ target.addAttribute("showFirstLabel", axis.getShowFirstLabel());
+ }
+ if (axis.getShowLastLabel() != null) {
+ target.addAttribute("showLastLabel", axis.getShowLastLabel());
+ }
+
+ if (axis.getStartOfWeek() != null) {
+ target.addAttribute("startOfWeek", axis.getStartOfWeek().ordinal());
+ }
+ if (axis.getStartOnTick() != null) {
+ target.addAttribute("startOnTick", axis.getStartOnTick());
+ }
+ //
+ if (axis.getTick() != null) {
+ writeAxisTick(target, axis.getTick());
+ }
+ //
+ if (axis.getType() != null) {
+ target.addAttribute("type", axis.getType().getName());
+ }
+ // Title
+ writeAxisTitle(target, axis.getTitle());
+ // Labels
+ if (axis.getLabel() instanceof XAxisDataLabel) {
+ writeXAxisDataLabel(target, (XAxisDataLabel) axis.getLabel());
+ } else {
+ writeYAxisDataLabel(target, (YAxisDataLabel) axis.getLabel());
+ }
+
+ if (axis instanceof NumberAxis) {
+ writePlotBands(target, ((NumberAxis) axis).getPlotBands());
+ //
+ writePlotLines(target, ((NumberAxis) axis).getPlotLines());
+ } else if (axis instanceof DateTimeAxis) {
+ writePlotBands(target, ((DateTimeAxis) axis).getPlotBands());
+ //
+ writePlotLines(target, ((DateTimeAxis) axis).getPlotLines());
+ } else if (axis instanceof CategoryAxis) {
+ writePlotBands(target, ((CategoryAxis) axis).getPlotBands());
+ //
+ writePlotLines(target, ((CategoryAxis) axis).getPlotLines());
+ }
+
+ }
+
+ /**
+ * Returns an index of an x-axis in a list of x-axis only if the x-axis
+ * exists otherwise null
+ *
+ * @param indexOfXAxis
+ * @param xAxes
+ * @return Retrieves Retrieves an index of an x-axis in a list of x-axis
+ * only if the x-axis exists otherwise null
+ */
+ private static Integer getXAxisIndex(XAxis indexOfXAxis,
+ LinkedHashSet xAxes) {
+ return getAxisIndex(indexOfXAxis, xAxes);
+ }
+
+ /**
+ * Returns an index of a y-axis in a list of y-axis only if the y-axis
+ * exists otherwise null
+ *
+ * @param indexOfYAxis
+ * @param yAxes
+ * @return Returns index of a y-axis in a list of y-axis only if the y-axis
+ * exists otherwise null
+ */
+ private static Integer getYAxisIndex(YAxis indexOfYAxis,
+ LinkedHashSet yAxes) {
+ return getAxisIndex(indexOfYAxis, yAxes);
+ }
+
+ /**
+ * Returns an index of an axis in a list of axis only if the axis exists
+ * otherwise null
+ *
+ * @param indexOfAxis
+ * @param axes
+ * @return Returns an index of an axis in a list of axis only if the axis
+ * exists otherwise null
+ */
+ private static Integer getAxisIndex(Axis indexOfAxis,
+ LinkedHashSet extends Axis> axes) {
+ if (indexOfAxis == null || axes == null || axes.size() == 0) {
+ return 0;
+ }
+ int index = 0;
+ for (Axis axis : axes) {
+ if (axis == indexOfAxis) {
+ return index;
+ }
+ index++;
+ }
+
+ return null;
+ }
+
+ /**
+ * Writes configuration attributes of the plotbands associated with an axis.
+ *
+ * @param target
+ * @param plotBands
+ * @throws PaintException
+ */
+ private static void writePlotBands(PaintTarget target,
+ LinkedHashSet extends PlotBand> plotBands) throws PaintException {
+ target.startTag("plotBands");
+ if (plotBands != null) {
+ for (PlotBand plotBand : plotBands) {
+ target.startTag("plotBand");
+
+ if (plotBand.getColor() != null) {
+ target.addAttribute("color", plotBand.getColor()
+ .getString());
+ }
+ if (plotBand.getId() != null) {
+ target.addAttribute("id", plotBand.getId());
+ }
+ if (plotBand.getZIndex() != null) {
+ target.addAttribute("zIndex", plotBand.getZIndex());
+ }
+ writePlotLabel(target, plotBand.getLabel());
+ writePlotBandRange(target, plotBand.getRange());
+
+ target.endTag("plotBand");
+ }
+ }
+ target.endTag("plotBands");
+ }
+
+ /**
+ * Writes configuration attributes of a plotlabel.
+ *
+ * @param target
+ * @param plotLabel
+ * @throws PaintException
+ */
+ private static void writePlotLabel(PaintTarget target, PlotLabel plotLabel)
+ throws PaintException {
+
+ target.startTag("label");
+
+ if (plotLabel != null) {
+ if (plotLabel.getAlign() != null) {
+ target.addAttribute("align", plotLabel.getAlign().getName());
+ }
+ if (plotLabel.getRotation() != null) {
+ target.addAttribute("rotation", plotLabel.getRotation());
+ }
+ if (plotLabel.getStyle() != null) {
+ target.addAttribute("style", plotLabel.getStyle());
+ }
+ if (plotLabel.getText() != null) {
+ target.addAttribute("text", plotLabel.getText());
+ }
+ if (plotLabel.getTextAlign() != null) {
+ target.addAttribute("textAlign", plotLabel.getTextAlign()
+ .getName());
+ }
+ if (plotLabel.getVertAlign() != null) {
+ target.addAttribute("verticalAlign", plotLabel.getVertAlign()
+ .getName());
+ }
+ if (plotLabel.getX() != null) {
+ target.addAttribute("x", plotLabel.getX());
+ }
+ if (plotLabel.getY() != null) {
+ target.addAttribute("y", plotLabel.getY());
+ }
+ }
+
+ target.endTag("label");
+ }
+
+ /**
+ * Writes from/to value for a plotband. It considers date and number values
+ * separately.
+ *
+ * @param target
+ * @param plotBandRange
+ * @throws PaintException
+ */
+ private static void writePlotBandRange(PaintTarget target,
+ Range plotBandRange) throws PaintException {
+ target.startTag("rangeValue");
+ if (plotBandRange != null) {
+ if (plotBandRange instanceof NumberRange) {
+ target.addAttribute("valueType", "number");
+ NumberRange numberRange = (NumberRange) plotBandRange;
+ if (numberRange.getFrom() != null) {
+ target.addAttribute("from", numberRange.getFrom());
+ }
+ if (numberRange.getTo() != null) {
+ target.addAttribute("to", numberRange.getTo());
+ }
+ } else if (plotBandRange instanceof DateTimeRange) {
+ target.addAttribute("valueType", "date");
+ DateTimeRange dateRange = (DateTimeRange) plotBandRange;
+ target.startTag("from");
+ if (dateRange.getFrom() != null) {
+ target.addAttribute("year",
+ getYearFromDate(dateRange.getFrom()));
+ target.addAttribute("month",
+ getMonthFromDate(dateRange.getFrom()));
+ target.addAttribute("day",
+ getDayFromDate(dateRange.getFrom()));
+ }
+ target.endTag("from");
+ target.startTag("to");
+ if (dateRange.getTo() != null) {
+ target.addAttribute("year",
+ getYearFromDate(dateRange.getTo()));
+ target.addAttribute("month",
+ getMonthFromDate(dateRange.getTo()));
+ target.addAttribute("day",
+ getDayFromDate(dateRange.getTo()));
+ }
+ target.endTag("to");
+ }
+ }
+ target.endTag("rangeValue");
+ }
+
+ /**
+ * Writes configuration attributes of the plotlines
+ *
+ * @param target
+ * @param plotLines
+ * @throws PaintException
+ */
+ private static void writePlotLines(PaintTarget target,
+ LinkedHashSet extends PlotLine> plotLines) throws PaintException {
+ target.startTag("plotLines");
+ if (plotLines != null) {
+ for (PlotLine plotLine : plotLines) {
+ target.startTag("plotLine");
+
+ if (plotLine.getColor() != null) {
+ target.addAttribute("color", plotLine.getColor()
+ .getString());
+ }
+ if (plotLine.getDashStyle() != null) {
+ target.addAttribute("dashStyle", plotLine.getDashStyle()
+ .getName());
+ }
+ if (plotLine.getId() != null) {
+ target.addAttribute("id", plotLine.getId());
+ }
+ if (plotLine.getWidth() != null) {
+ target.addAttribute("width", plotLine.getWidth());
+ }
+ if (plotLine.getZIndex() != null) {
+ target.addAttribute("zIndex", plotLine.getZIndex());
+ }
+ writePlotLabel(target, plotLine.getLabel());
+ writePlotLineValue(target, plotLine.getValue());
+ target.endTag("plotLine");
+ }
+ }
+ target.endTag("plotLines");
+ }
+
+ /**
+ * Writes value of a plotline. It considers date and number value
+ * separately.
+ *
+ * @param target
+ * @param plotLineValue
+ * @throws PaintException
+ */
+ private static void writePlotLineValue(PaintTarget target,
+ Value plotLineValue) throws PaintException {
+
+ target.startTag("lineValue");
+ if (plotLineValue != null) {
+ if (plotLineValue instanceof NumberValue
+ && ((NumberValue) plotLineValue).getValue() != null) {
+ target.addAttribute("valueType", "number");
+ target.addAttribute("value",
+ ((NumberValue) plotLineValue).getValue());
+ } else if (plotLineValue instanceof DateTimeValue
+ && ((DateTimeValue) plotLineValue).getValue() != null) {
+ target.addAttribute("valueType", "date");
+ Date date = ((DateTimeValue) plotLineValue).getValue();
+ target.addAttribute("year", getYearFromDate(date));
+ target.addAttribute("month", getMonthFromDate(date));
+ target.addAttribute("day", getDayFromDate(date));
+ }
+ }
+ target.endTag("lineValue");
+ }
+
+ /**
+ * @param target
+ * @param tick
+ * @throws PaintException
+ */
+ private static void writeAxisTick(PaintTarget target, Tick tick)
+ throws PaintException {
+ writeAxisMinorTick(target, tick);
+ if (tick.getPixelInterval() != null) {
+ target.addAttribute("tickPixelInterval", tick.getPixelInterval());
+ }
+ if (tick.getPlacement() != null) {
+ target.addAttribute("tickmarkPlacement", tick.getPlacement()
+ .getName());
+ }
+ }
+
+ /**
+ * Writes configuration attributes of an axis. Depending on type of the
+ * argument tick, it either writes attributes for {@link MinorTick} or
+ * {@link Tick}
+ *
+ * @param target
+ * @param tick
+ * @throws PaintException
+ */
+ private static void writeAxisMinorTick(PaintTarget target, MinorTick tick)
+ throws PaintException {
+
+ String attNameColor = "minorTickColor";
+ String attNameInterval = "minorTickInterval";
+ String attNameLength = "minorTickLength";
+ String attNamePosition = "minorTickPosition";
+ String attNameWidth = "minorTickWidth";
+ if (tick instanceof Tick) {
+ attNameColor = "tickColor";
+ attNameInterval = "tickInterval";
+ attNameLength = "tickLength";
+ attNamePosition = "tickPosition";
+ attNameWidth = "tickWidth";
+ }
+ if (tick.getColor() != null) {
+ target.addAttribute(attNameColor, tick.getColor().getString());
+ }
+ if (tick.getInterval() != null) {
+ target.addAttribute(attNameInterval, tick.getInterval());
+ }
+ if (tick.getLength() != null) {
+ target.addAttribute(attNameLength, tick.getLength());
+ }
+ if (tick.getPosition() != null) {
+ target.addAttribute(attNamePosition, tick.getPosition().getName());
+ }
+ if (tick.getWidth() != null) {
+ target.addAttribute(attNameWidth, tick.getWidth());
+ }
+ }
+
+ /**
+ * @param target
+ * @param grid
+ * @throws PaintException
+ */
+ private static void writeAxisGrid(PaintTarget target, Grid grid)
+ throws PaintException {
+ writeAxisMinorGrid(target, grid);
+ }
+
+ /**
+ * Writes configuration attributes of an axis. Depending on type of the
+ * argument tick, it either writes attributes for {@link MinorGrid} or
+ * {@link Grid}
+ *
+ * @param target
+ * @param grid
+ * @throws PaintException
+ */
+ private static void writeAxisMinorGrid(PaintTarget target, MinorGrid grid)
+ throws PaintException {
+
+ String attNameLineColor = "minorGridLineColor";
+ String attNameLineWidth = "minorGridLineWidth";
+ String attNameLineDashStyle = "minorGridLineDashStyle";
+ if (grid instanceof Grid) {
+ attNameLineColor = "gridLineColor";
+ attNameLineWidth = "gridLineWidth";
+ attNameLineDashStyle = "gridLineDashStyle";
+ }
+
+ if (grid.getLineColor() != null) {
+ target.addAttribute(attNameLineColor, grid.getLineColor()
+ .getString());
+ }
+ if (grid.getLineWidth() != null) {
+ target.addAttribute(attNameLineWidth, grid.getLineWidth());
+ }
+ if (grid.getLineDashStyle() != null) {
+ target.addAttribute(attNameLineDashStyle, grid.getLineDashStyle()
+ .getName());
+ }
+ }
+
+ /**
+ * @param target
+ * @param title
+ * @throws PaintException
+ */
+ private static void writeAxisTitle(PaintTarget target, AxisTitle title)
+ throws PaintException {
+ target.startTag("title");
+ if (title != null) {
+ if (title.getAlign() != null) {
+ target.addAttribute("align", title.getAlign().getName());
+ }
+ if (title.getMargin() != null) {
+ target.addAttribute("margin", title.getMargin());
+ }
+ if (title.getRotation() != null) {
+ target.addAttribute("rotation", title.getRotation());
+ }
+ if (title.getStyle() != null) {
+ target.addAttribute("style", title.getStyle());
+ }
+ if (title.getText() != null) {
+ target.addAttribute("text", title.getText());
+ }
+ }
+ target.endTag("title");
+ }
+
+ /**
+ * Iteratively processes each x-axis and writes configuration attributes of
+ * each axis based on type of the axis e.g. {@link NumberAxis},
+ * {@link DateTimeAxis} and {@link CategoryAxis}
+ *
+ * @param target
+ * @param axes
+ * @throws PaintException
+ */
+ public static void writeXAxes(PaintTarget target,
+ LinkedHashSet axes, InvientChartsConfig config)
+ throws PaintException {
+ target.startTag("xAxes");
+
+ if (axes != null) {
+ for (XAxis xAxis : axes) {
+ target.startTag("xAxis");
+ writeBaseAxis(target, (AxisBase) xAxis, axes);
+ if (xAxis instanceof NumberXAxis) {
+ writeNumberAxis(target, (NumberXAxis) xAxis);
+ } else if (xAxis instanceof CategoryAxis) {
+ writeCategoryAxis(target, (CategoryAxis) xAxis);
+ } else if (xAxis instanceof DateTimeAxis) {
+ // Check if time should be included as part of a date value.
+ // If any of the datetime series
+ writeDateTimeAxis(
+ target,
+ (DateTimeAxis) xAxis,
+ isIncludeTime((DateTimeAxis) xAxis, config
+ .getInvientCharts().getAllSeries()));
+ }
+
+ target.endTag("xAxis");
+ }
+ }
+
+ target.endTag("xAxes");
+ }
+
+ private static boolean isIncludeTime(DateTimeAxis axis,
+ LinkedHashSet chartSeries) {
+ for (Series series : chartSeries) {
+ if (series instanceof DateTimeSeries && series.getXAxis() == axis) {
+ return ((DateTimeSeries) series).isIncludeTime();
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param target
+ * @param numberAxis
+ * @throws PaintException
+ */
+ private static void writeNumberAxis(PaintTarget target,
+ NumberAxis numberAxis) throws PaintException {
+ if (numberAxis.getAllowDecimals() != null) {
+ target.addAttribute("allowDecimals", numberAxis.getAllowDecimals());
+ }
+ if (numberAxis.getMax() != null) {
+ target.addAttribute("max", numberAxis.getMax());
+ }
+ if (numberAxis.getMin() != null) {
+ target.addAttribute("min", numberAxis.getMin());
+ }
+ }
+
+ /**
+ * Returns milliseconds of the date argument dt excluding time.
+ *
+ * @param dt
+ * @return
+ */
+ public static long getDate(Date dt) {
+ return getDate(dt, false);
+ }
+
+ /**
+ * Returns milliseconds of the date argument dt. If the argument
+ * isIncludeTime is false then the returned milliseconds does not include
+ * time.
+ *
+ * @param dt
+ * @param isIncludeTime
+ * @return
+ */
+ private static long getDate(Date dt, boolean isIncludeTime) {
+ Calendar cal = GregorianCalendar.getInstance();
+ cal.setTime(dt);
+ if (!isIncludeTime) {
+ cal.set(Calendar.HOUR, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ }
+ return cal.getTimeInMillis();
+ }
+
+ /**
+ * @param target
+ * @param dateTimeAxis
+ * @throws PaintException
+ */
+ private static void writeDateTimeAxis(PaintTarget target,
+ DateTimeAxis dateTimeAxis, boolean isIncludeTime)
+ throws PaintException {
+ if (dateTimeAxis.getMax() != null) {
+ target.addAttribute("max",
+ getDate(dateTimeAxis.getMax(), isIncludeTime));
+ }
+ if (dateTimeAxis.getMin() != null) {
+ target.addAttribute("min",
+ getDate(dateTimeAxis.getMin(), isIncludeTime));
+ }
+ if (dateTimeAxis.getDateTimeLabelFormat() != null) {
+ target.startTag("dateTimeLabelFormats");
+ DateTimeLabelFormat dateTimeLabelFormat = dateTimeAxis
+ .getDateTimeLabelFormat();
+ if (dateTimeLabelFormat.getMillisecond() != null) {
+ target.addAttribute("millisecond", dateTimeAxis
+ .getDateTimeLabelFormat().getMillisecond());
+ }
+ if (dateTimeLabelFormat.getSecond() != null) {
+ target.addAttribute("second", dateTimeAxis
+ .getDateTimeLabelFormat().getSecond());
+ }
+ if (dateTimeLabelFormat.getMinute() != null) {
+ target.addAttribute("minute", dateTimeAxis
+ .getDateTimeLabelFormat().getMinute());
+ }
+ if (dateTimeLabelFormat.getHour() != null) {
+ target.addAttribute("hour", dateTimeAxis
+ .getDateTimeLabelFormat().getHour());
+ }
+ if (dateTimeLabelFormat.getDay() != null) {
+ target.addAttribute("day", dateTimeAxis
+ .getDateTimeLabelFormat().getDay());
+ }
+ if (dateTimeLabelFormat.getWeek() != null) {
+ target.addAttribute("week", dateTimeAxis
+ .getDateTimeLabelFormat().getWeek());
+ }
+ if (dateTimeLabelFormat.getMonth() != null) {
+ target.addAttribute("month", dateTimeAxis
+ .getDateTimeLabelFormat().getMonth());
+ }
+ if (dateTimeLabelFormat.getYear() != null) {
+ target.addAttribute("year", dateTimeAxis
+ .getDateTimeLabelFormat().getYear());
+ }
+ target.endTag("dateTimeLabelFormats");
+ }
+ }
+
+ /**
+ * @param target
+ * @param categoryAxis
+ * @throws PaintException
+ */
+ private static void writeCategoryAxis(PaintTarget target,
+ CategoryAxis categoryAxis) throws PaintException {
+ target.startTag("categories");
+ if (categoryAxis.getCategories() != null
+ && categoryAxis.getCategories().size() > 0) {
+ for (String category : categoryAxis.getCategories()) {
+ target.startTag("category");
+ target.addAttribute("name", category);
+ target.endTag("category");
+ }
+ }
+ target.endTag("categories");
+ }
+
+ /**
+ * @param target
+ * @param axes
+ * @throws PaintException
+ */
+ public static void writeYAxes(PaintTarget target,
+ LinkedHashSet axes, InvientChartsConfig config)
+ throws PaintException {
+ target.startTag("yAxes");
+
+ if (axes != null) {
+ for (YAxis yAxis : axes) {
+ target.startTag("yAxis");
+ writeBaseAxis(target, (AxisBase) yAxis, axes);
+ if (yAxis instanceof NumberYAxis) {
+ writeNumberAxis(target, (NumberYAxis) yAxis);
+ }
+ target.endTag("yAxis");
+ }
+ }
+
+ target.endTag("yAxes");
+ }
+
+ /**
+ * Writes configuration attributes of the chart labels.
+ *
+ * @param target
+ * @param chartLabel
+ * @throws PaintException
+ */
+ public static void writeChartLabelConfig(PaintTarget target,
+ ChartLabel chartLabel) throws PaintException {
+ target.startTag("labels");
+
+ if (chartLabel != null && chartLabel.getLabels() != null
+ && chartLabel.getLabels().size() > 0) {
+ if (chartLabel.getStyle() != null) {
+ target.addAttribute("style", chartLabel.getStyle());
+ }
+ target.startTag("items");
+ for (ChartLabelItem label : chartLabel.getLabels()) {
+ if (label.getHtml() != null || label.getStyle() != null) {
+ target.startTag("item");
+ if (label.getHtml() != null) {
+ target.addAttribute("html", label.getHtml());
+ }
+ if (label.getStyle() != null) {
+ target.addAttribute("style", label.getStyle());
+ }
+ target.endTag("item");
+ }
+ }
+ target.endTag("items");
+ }
+
+ target.endTag("labels");
+ }
+
+ /**
+ * @param date
+ * @return Returns year of the argument date.
+ */
+ private static String getYearFromDate(Date date) {
+ if (date == null) {
+ return null;
+ }
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(date);
+ return String.valueOf(cal.get(Calendar.YEAR));
+ }
+
+ /**
+ * @param date
+ * @return Returns month of the argument date. The returned values is based
+ * on zero-index i.e. for month January, the values returned is "0"
+ */
+ private static String getMonthFromDate(Date date) {
+ if (date == null) {
+ return null;
+ }
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(date);
+ return String.valueOf(cal.get(Calendar.MONTH));
+ }
+
+ /**
+ * @param date
+ * @return
+ */
+ private static String getDayFromDate(Date date) {
+ if (date == null) {
+ return null;
+ }
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(date);
+ return String.valueOf(cal.get(Calendar.DAY_OF_MONTH));
+ }
+
+ /**
+ * Writes information about which series were added, removed or updated.
+ * This information is used by Vaadin terminal class to decide whether to
+ * add a new series or remove/delete an existing series. Basically, this
+ * information helps client to update only a portion of the chart instead of
+ * full chart.
+ *
+ * @param target
+ * @param seriesCURMap
+ * @throws PaintException
+ */
+
+ public static void writeChartDataUpdates(PaintTarget target,
+ LinkedHashMap> seriesCURMap)
+ throws PaintException {
+ for (String seriesName : seriesCURMap.keySet()) {
+ LinkedHashSet seriesCURSet = seriesCURMap
+ .get(seriesName);
+ if (seriesCURSet != null && seriesCURSet.size() > 0) {
+ for (SeriesCUR seriesCUR : seriesCURSet) {
+ target.startTag("seriesDataUpdate");
+ target.addAttribute("seriesName", seriesCUR.getName());
+ target.addAttribute("operation", seriesCUR.getType()
+ .getName());
+ target.addAttribute("isReloadPoints",
+ seriesCUR.isReloadPoints());
+ target.startTag("pointsAdded");
+ if (seriesCUR.getPointsAdded().size() > 0) {
+ writePoints(target, seriesCUR.getPointsAdded());
+ }
+ target.endTag("pointsAdded");
+ target.startTag("pointsRemoved");
+ if (seriesCUR.getPointsRemoved().size() > 0) {
+ writePoints(target, seriesCUR.getPointsRemoved());
+ }
+ target.endTag("pointsRemoved");
+ target.endTag("seriesDataUpdate");
+ }
+ }
+ }
+ }
+
+}
diff --git a/src/com/invient/vaadin/charts/Paint.java b/invient-charts/src/main/java/com/invient/vaadin/charts/Paint.java
old mode 100755
new mode 100644
similarity index 100%
rename from src/com/invient/vaadin/charts/Paint.java
rename to invient-charts/src/main/java/com/invient/vaadin/charts/Paint.java
diff --git a/invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/InvientChartsWidgetset.gwt.xml b/invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/InvientChartsWidgetset.gwt.xml
new file mode 100644
index 0000000..ef7ee05
--- /dev/null
+++ b/invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/InvientChartsWidgetset.gwt.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/src/com/invient/vaadin/charts/widgetset/client/ui/GwtAxis.java b/invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/GwtAxis.java
old mode 100755
new mode 100644
similarity index 100%
rename from src/com/invient/vaadin/charts/widgetset/client/ui/GwtAxis.java
rename to invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/GwtAxis.java
diff --git a/src/com/invient/vaadin/charts/widgetset/client/ui/GwtChart.java b/invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/GwtChart.java
old mode 100755
new mode 100644
similarity index 100%
rename from src/com/invient/vaadin/charts/widgetset/client/ui/GwtChart.java
rename to invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/GwtChart.java
diff --git a/src/com/invient/vaadin/charts/widgetset/client/ui/GwtInvientCharts.java b/invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/GwtInvientCharts.java
old mode 100755
new mode 100644
similarity index 95%
rename from src/com/invient/vaadin/charts/widgetset/client/ui/GwtInvientCharts.java
rename to invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/GwtInvientCharts.java
index 7069f5f..ee87cf8
--- a/src/com/invient/vaadin/charts/widgetset/client/ui/GwtInvientCharts.java
+++ b/invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/GwtInvientCharts.java
@@ -1,219 +1,235 @@
-/*
- * Copyright 2011 Invient (www.invient.com)
- *
- * 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 com.invient.vaadin.charts.widgetset.client.ui;
-
-import com.google.gwt.core.client.JavaScriptObject;
-import com.google.gwt.dom.client.DivElement;
-import com.google.gwt.dom.client.Document;
-import com.google.gwt.user.client.ui.Widget;
-
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtExportingOptions;
-
-/**
- *
- * This is the base class for InvientCharts.
- * It does followings:
- *
- *
- * creates container element for the chart.
- *
- *
- * destroys chart when the container element is removed
- *
- *
- * defines a set of JavaScript functions to register various event listeners for the Highcharts. These JavaScript function will call
- * predefined GWT methods where actual code is written to communicate to the server-side Vaadin components.
- *
- *
- *
- * @author Invient
- *
- */
-class GwtInvientCharts extends Widget {
-
- protected GwtChart chart;
- protected String divId = "hchartdiv_" + System.currentTimeMillis();
-
- public GwtInvientCharts() {
- DivElement divElement = Document.get().createDivElement();
- divElement.setId(divId);
- setElement(divElement);
- }
-
- @Override
- public void onLoad() {
- }
-
- @Override
- public void onUnload() {
- // Remove chart and purge memory (prevents memory leaks)
- if (chart != null) {
- chart.destroy();
- // chart variable must be set to null so that the chart can be created again
- // when using chart with Portal Layout.
- // In portal layout, when one window is dragged, the chart is removed from
- // html dom and when the window is dropped to a new position the chart
- // needs to be recreated.
- chart = null;
- }
- }
-
- protected void createChart(GwtInvientChartsConfig options) {
- // For now, disable exporting icons on client. If we need then we would
- // add support for setting exporting options through server-side code
- GwtExportingOptions exportingOptions = GwtExportingOptions.create();
- exportingOptions.setEnabled(false);
- options.setExportingOptions(exportingOptions);
- //
- chart = GwtInvientChartsUtil.newChart(options);
- }
-
- protected static final class EventCallbacks {
-
- // Chart events
- protected static native final JavaScriptObject getChartAddSeries(
- VInvientCharts graphWidget) /*-{
- return function(event) {
- var thisWidget = graphWidget;
- thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::chartAddSeriesListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtChart;)(this);
- };
- }-*/;
-
- protected static native final JavaScriptObject getChartClick(
- VInvientCharts graphWidget) /*-{
- return function(event) {
- var thisWidget = graphWidget;
- var mouseCoords = $wnd.getMouseCoords(event);
- thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::chartClickListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtChart;DDII)(this, event.xAxis[0].value, event.yAxis[0].value, mouseCoords.x, mouseCoords.y);
- };
- }-*/;
-
- protected static native final JavaScriptObject getClientChartSelection(
- VInvientCharts graphWidget) /*-{
- return function(event) {
- var thisWidget = graphWidget;
- if(event.xAxis && event.yAxis) {
- thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::chartSelectionListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtChart;DDDD)(this, event.xAxis[0].min, event.xAxis[0].max, event.yAxis[0].min, event.yAxis[0].max);
- }
- else {
- thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::chartResetZoomListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtChart;)(this);
- }
- };
- }-*/;
-
- protected static native final JavaScriptObject getServerChartSelection(
- VInvientCharts graphWidget) /*-{
- return function(event) {
- var thisWidget = graphWidget;
- if(event.xAxis && event.yAxis) {
- thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::chartSelectionListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtChart;DDDD)(this, event.xAxis[0].min, event.xAxis[0].max, event.yAxis[0].min, event.yAxis[0].max);
- }
- else {
- thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::chartResetZoomListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtChart;)(this);
- }
- return false;
- };
- }-*/;
-
- // Series events
- protected static native final JavaScriptObject getSeriesClick(
- VInvientCharts graphWidget) /*-{
- return function(event) {
- var thisWidget = graphWidget;
- var mouseCoords = $wnd.getMouseCoords(event);
- thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::seriesClickListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtSeries;Lcom/invient/vaadin/charts/widgetset/client/ui/GwtPoint;II)(this, event.point, mouseCoords.x, mouseCoords.y);
- };
- }-*/;
-
- protected static native final JavaScriptObject getSeriesHide(
- VInvientCharts graphWidget) /*-{
- return function() {
- var thisWidget = graphWidget;
- thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::seriesHideListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtSeries;)(this);
- };
- }-*/;
-
- protected static native final JavaScriptObject getSeriesShow(
- VInvientCharts graphWidget) /*-{
- return function() {
- var thisWidget = graphWidget;
- thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::seriesShowListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtSeries;)(this);
- };
- }-*/;
-
- protected static native final JavaScriptObject getSeriesLegendItemClick(
- VInvientCharts graphWidget) /*-{
- return function(event) {
- var thisWidget = graphWidget;
- thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::seriesLegendItemClickListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtSeries;)(this);
- };
- }-*/;
-
- // Point events
- protected static native final JavaScriptObject getPieLegendItemClick(
- VInvientCharts graphWidget) /*-{
- return function(event) {
- var thisWidget = graphWidget;
- thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::pieLegendItemClickListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtPoint;)(this);
- };
- }-*/;
-
- protected static native final JavaScriptObject getPointClick(
- VInvientCharts graphWidget) /*-{
- return function(event) {
- var thisWidget = graphWidget;
- var mouseCoords = $wnd.getMouseCoords(event);
- thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::pointClickListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtPoint;II)(this, mouseCoords.x, mouseCoords.y);
- };
- }-*/;
-
- protected static native final JavaScriptObject getPointSelect(
- VInvientCharts graphWidget) /*-{
- return function(event) {
- var thisWidget = graphWidget;
- thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::pointSelectListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtPoint;)(this);
- };
- }-*/;
-
- protected static native final JavaScriptObject getPointUnselect(
- VInvientCharts graphWidget) /*-{
- return function(event) {
- var thisWidget = graphWidget;
- thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::pointUnselectListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtPoint;)(this);
- };
- }-*/;
-
- protected static native final JavaScriptObject getPointRemove(
- VInvientCharts graphWidget) /*-{
- return function(event) {
- var thisWidget = graphWidget;
- thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::pointRemoveListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtPoint;)(this);
- };
- }-*/;
-
- }
-
-// @Override
-// public void setHeight(String height) {
-// getElement().setAttribute("height", height);
-// }
-//
-// @Override
-// public void setWidth(String width) {
-// getElement().setAttribute("width", width);
-// }
-
+/*
+ * Copyright 2011 Invient (www.invient.com)
+ *
+ * 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 com.invient.vaadin.charts.widgetset.client.ui;
+
+import java.util.UUID;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.dom.client.DivElement;
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.user.client.ui.Widget;
+
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtExportingOptions;
+
+/**
+ *
+ * This is the base class for InvientCharts.
+ * It does followings:
+ *
+ *
+ * creates container element for the chart.
+ *
+ *
+ * destroys chart when the container element is removed
+ *
+ *
+ * defines a set of JavaScript functions to register various event listeners for the Highcharts. These JavaScript function will call
+ * predefined GWT methods where actual code is written to communicate to the server-side Vaadin components.
+ *
+ *
+ *
+ * @author Invient
+ *
+ */
+class GwtInvientCharts extends Widget {
+
+ private static long chartId = System.currentTimeMillis();
+
+ protected GwtChart chart;
+ protected String divId = "hchartdiv_" + chartId++;
+
+ // Cached chart options so that we can re-load them if we are detached and re-attached.
+ private GwtInvientChartsConfig options;
+
+ public GwtInvientCharts() {
+ DivElement divElement = Document.get().createDivElement();
+ divElement.setId(divId);
+ setElement(divElement);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void onLoad() {
+ if(chart == null && options != null) {
+ // And we are back again... (component was re-attached).
+ createChart(options);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void onUnload() {
+ // Remove chart and purge memory (prevents memory leaks)
+ if (chart != null) {
+ chart.destroy();
+ // chart variable must be set to null so that the chart can be created again
+ // when using chart with Portal Layout.
+ // In portal layout, when one window is dragged, the chart is removed from
+ // html dom and when the window is dropped to a new position the chart
+ // needs to be recreated.
+ chart = null;
+ }
+ }
+
+ protected void createChart(GwtInvientChartsConfig options) {
+ // For now, disable exporting icons on client. If we need then we would
+ // add support for setting exporting options through server-side code
+ GwtExportingOptions exportingOptions = GwtExportingOptions.create();
+ exportingOptions.setEnabled(false);
+ options.setExportingOptions(exportingOptions);
+ //
+ chart = GwtInvientChartsUtil.newChart(options);
+ this.options = options;
+ }
+
+ protected static final class EventCallbacks {
+
+ // Chart events
+ protected static native final JavaScriptObject getChartAddSeries(
+ VInvientCharts graphWidget) /*-{
+ return function(event) {
+ var thisWidget = graphWidget;
+ thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::chartAddSeriesListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtChart;)(this);
+ };
+ }-*/;
+
+ protected static native final JavaScriptObject getChartClick(
+ VInvientCharts graphWidget) /*-{
+ return function(event) {
+ var thisWidget = graphWidget;
+ var mouseCoords = $wnd.getMouseCoords(event);
+ thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::chartClickListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtChart;DDII)(this, event.xAxis[0].value, event.yAxis[0].value, mouseCoords.x, mouseCoords.y);
+ };
+ }-*/;
+
+ protected static native final JavaScriptObject getClientChartSelection(
+ VInvientCharts graphWidget) /*-{
+ return function(event) {
+ var thisWidget = graphWidget;
+ if(event.xAxis && event.yAxis) {
+ thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::chartSelectionListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtChart;DDDD)(this, event.xAxis[0].min, event.xAxis[0].max, event.yAxis[0].min, event.yAxis[0].max);
+ }
+ else {
+ thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::chartResetZoomListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtChart;)(this);
+ }
+ };
+ }-*/;
+
+ protected static native final JavaScriptObject getServerChartSelection(
+ VInvientCharts graphWidget) /*-{
+ return function(event) {
+ var thisWidget = graphWidget;
+ if(event.xAxis && event.yAxis) {
+ thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::chartSelectionListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtChart;DDDD)(this, event.xAxis[0].min, event.xAxis[0].max, event.yAxis[0].min, event.yAxis[0].max);
+ }
+ else {
+ thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::chartResetZoomListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtChart;)(this);
+ }
+ return false;
+ };
+ }-*/;
+
+ // Series events
+ protected static native final JavaScriptObject getSeriesClick(
+ VInvientCharts graphWidget) /*-{
+ return function(event) {
+ var thisWidget = graphWidget;
+ var mouseCoords = $wnd.getMouseCoords(event);
+ thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::seriesClickListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtSeries;Lcom/invient/vaadin/charts/widgetset/client/ui/GwtPoint;II)(this, event.point, mouseCoords.x, mouseCoords.y);
+ };
+ }-*/;
+
+ protected static native final JavaScriptObject getSeriesHide(
+ VInvientCharts graphWidget) /*-{
+ return function() {
+ var thisWidget = graphWidget;
+ thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::seriesHideListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtSeries;)(this);
+ };
+ }-*/;
+
+ protected static native final JavaScriptObject getSeriesShow(
+ VInvientCharts graphWidget) /*-{
+ return function() {
+ var thisWidget = graphWidget;
+ thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::seriesShowListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtSeries;)(this);
+ };
+ }-*/;
+
+ protected static native final JavaScriptObject getSeriesLegendItemClick(
+ VInvientCharts graphWidget) /*-{
+ return function(event) {
+ var thisWidget = graphWidget;
+ thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::seriesLegendItemClickListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtSeries;)(this);
+ };
+ }-*/;
+
+ // Point events
+ protected static native final JavaScriptObject getPieLegendItemClick(
+ VInvientCharts graphWidget) /*-{
+ return function(event) {
+ var thisWidget = graphWidget;
+ thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::pieLegendItemClickListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtPoint;)(this);
+ };
+ }-*/;
+
+ protected static native final JavaScriptObject getPointClick(
+ VInvientCharts graphWidget) /*-{
+ return function(event) {
+ var thisWidget = graphWidget;
+ var mouseCoords = $wnd.getMouseCoords(event);
+ thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::pointClickListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtPoint;II)(this, mouseCoords.x, mouseCoords.y);
+ };
+ }-*/;
+
+ protected static native final JavaScriptObject getPointSelect(
+ VInvientCharts graphWidget) /*-{
+ return function(event) {
+ var thisWidget = graphWidget;
+ thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::pointSelectListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtPoint;)(this);
+ };
+ }-*/;
+
+ protected static native final JavaScriptObject getPointUnselect(
+ VInvientCharts graphWidget) /*-{
+ return function(event) {
+ var thisWidget = graphWidget;
+ thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::pointUnselectListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtPoint;)(this);
+ };
+ }-*/;
+
+ protected static native final JavaScriptObject getPointRemove(
+ VInvientCharts graphWidget) /*-{
+ return function(event) {
+ var thisWidget = graphWidget;
+ thisWidget.@com.invient.vaadin.charts.widgetset.client.ui.VInvientCharts::pointRemoveListener(Lcom/invient/vaadin/charts/widgetset/client/ui/GwtPoint;)(this);
+ };
+ }-*/;
+
+ }
+
+// /** {@inheritDoc} */
+// @Override
+// public void setHeight(String height) {
+// getElement().setAttribute("height", height);
+// }
+//
+// /** {@inheritDoc} */
+// @Override
+// public void setWidth(String width) {
+// getElement().setAttribute("width", width);
+// }
+
}
\ No newline at end of file
diff --git a/src/com/invient/vaadin/charts/widgetset/client/ui/GwtInvientChartsConfig.java b/invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/GwtInvientChartsConfig.java
old mode 100755
new mode 100644
similarity index 97%
rename from src/com/invient/vaadin/charts/widgetset/client/ui/GwtInvientChartsConfig.java
rename to invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/GwtInvientChartsConfig.java
index 92ef102..8d24f18
--- a/src/com/invient/vaadin/charts/widgetset/client/ui/GwtInvientChartsConfig.java
+++ b/invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/GwtInvientChartsConfig.java
@@ -764,6 +764,10 @@ public native final void setStickyTracking(boolean stickyTracking) /*-{
public native final void setMarker(GwtMarker marker) /*-{
this.marker = marker;
}-*/;
+
+ public native final void setTurboThreshold(int turboThreshold) /*-{
+ this.turboThreshold = turboThreshold;
+ }-*/;
}
static class GwtLineOptions extends GwtBaseLineOptions {
@@ -848,7 +852,7 @@ public native final void setBorderColor(String borderColor) /*-{
this.borderColor = $wnd.getInvientChartsColor(borderColor);
}-*/;
- public native final void setBorderWidth(int borderWidth) /*-{
+ public native final void setBorderWidth(double borderWidth) /*-{
this.borderWidth = borderWidth;
}-*/;
@@ -864,7 +868,10 @@ public native final void setSlicedOffset(int slicedOffset) /*-{
this.slicedOffset = slicedOffset;
}-*/;
- }
+ public native final void setIgnoreHiddenPoint(boolean ignoreHiddenPoint) /*-{
+ this.ignoreHiddenPoint = ignoreHiddenPoint;
+ }-*/;
+ }
static class GwtBaseBarOptions extends GwtSeriesGeneralOptions {
protected GwtBaseBarOptions() {
@@ -1607,6 +1614,10 @@ public static native final GwtDateTimeLabelFormats create() /*-{
return { };
}-*/;
+ public native final void setMillisecond(String millisecond) /*-{
+ this.millisecond = millisecond;
+ }-*/;
+
public native final void setSecond(String second) /*-{
this.second = second;
}-*/;
@@ -1730,9 +1741,9 @@ public native final void setBorderWidth(int borderWidth) /*-{
}-*/;
// FIXME all diff. values
- public native final void setCrosshairs(boolean crosshairs) /*-{
- this.crosshairs = crosshairs;
- }-*/;
+ public native final void setCrosshairs(GwtTooltipCrosshairs crosshairs) /*-{
+ this.crosshairs = crosshairs;
+ }-*/;
public native final void setEnabled(boolean enabled) /*-{
this.enabled = enabled;
@@ -1757,8 +1768,48 @@ public native final void setSnap(int snap) /*-{
public native final void setStyle(String style) /*-{
this.style = eval("(" + style + ")");
}-*/;
+
+ public native final void setUseHTML(boolean useHTML) /*-{
+ this.useHTML = useHTML;
+ }-*/;
+
+ public native final void setHeaderFormat(String headerFormat) /*-{
+ this.headerFormat = headerFormat;
+ }-*/;
+
+ public native final void setPointFormat(String pointFormat) /*-{
+ this.pointFormat = pointFormat;
+ }-*/;
+
+ public native final void setFooterFormat(String footerFormat) /*-{
+ this.footerFormat = footerFormat;
+ }-*/;
}
+ static final class GwtTooltipCrosshairs extends JavaScriptObject {
+ protected GwtTooltipCrosshairs() {
+ }
+
+ public native final static GwtTooltipCrosshairs create() /*-{
+ return {};
+ }-*/;
+
+ public native final void setWidth(double width) /*-{
+ this.width = width;
+ }-*/;
+
+ public native final void setColor(String color) /*-{
+ this.color = $wnd.getInvientChartsColor(color);
+ }-*/;
+
+ public native final void setDashstyle(String dashStyle) /*-{
+ this.dashStyle = dashStyle;
+ }-*/;
+ public native final void setZIndex(int zIndex) /*-{
+ this.zIndex = zIndex;
+ }-*/;
+ }
+
static final class GwtLegendOptions extends JavaScriptObject {
protected GwtLegendOptions() {
}
@@ -1816,7 +1867,7 @@ public native final void setItemHoverStyle(String itemHoverStyle) /*-{
}-*/;
public native final void setItemStyle(String itemStyle) /*-{
- this.itemStyle = itemStyle;
+ this.itemStyle = eval("(" + itemStyle + ")");
}-*/;
public native final void setItemWidth(int itemWidth) /*-{
diff --git a/src/com/invient/vaadin/charts/widgetset/client/ui/GwtInvientChartsUtil.java b/invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/GwtInvientChartsUtil.java
old mode 100755
new mode 100644
similarity index 100%
rename from src/com/invient/vaadin/charts/widgetset/client/ui/GwtInvientChartsUtil.java
rename to invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/GwtInvientChartsUtil.java
diff --git a/src/com/invient/vaadin/charts/widgetset/client/ui/GwtPoint.java b/invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/GwtPoint.java
old mode 100755
new mode 100644
similarity index 100%
rename from src/com/invient/vaadin/charts/widgetset/client/ui/GwtPoint.java
rename to invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/GwtPoint.java
diff --git a/src/com/invient/vaadin/charts/widgetset/client/ui/GwtSeries.java b/invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/GwtSeries.java
old mode 100755
new mode 100644
similarity index 100%
rename from src/com/invient/vaadin/charts/widgetset/client/ui/GwtSeries.java
rename to invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/GwtSeries.java
diff --git a/src/com/invient/vaadin/charts/widgetset/client/ui/VInvientCharts.java b/invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/VInvientCharts.java
old mode 100755
new mode 100644
similarity index 97%
rename from src/com/invient/vaadin/charts/widgetset/client/ui/VInvientCharts.java
rename to invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/VInvientCharts.java
index ffd8e36..c2aca7d
--- a/src/com/invient/vaadin/charts/widgetset/client/ui/VInvientCharts.java
+++ b/invient-charts/src/main/java/com/invient/vaadin/charts/widgetset/client/ui/VInvientCharts.java
@@ -1,2713 +1,2784 @@
-/*
- * Copyright 2011 Invient (www.invient.com)
- *
- * 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 com.invient.vaadin.charts.widgetset.client.ui;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.google.gwt.core.client.JavaScriptObject;
-import com.google.gwt.core.client.JsArray;
-import com.google.gwt.core.client.JsArrayNumber;
-import com.google.gwt.core.client.JsArrayString;
-import com.vaadin.terminal.gwt.client.ApplicationConnection;
-import com.vaadin.terminal.gwt.client.Paintable;
-import com.vaadin.terminal.gwt.client.UIDL;
-import com.vaadin.terminal.gwt.client.VConsole;
-
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtAxisBaseOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtAxisBaseOptions.GwtAxisDataLabels;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtAxisBaseOptions.GwtAxisTitleOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtAxisBaseOptions.GwtPlotBands;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtAxisBaseOptions.GwtPlotLabel;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtAxisBaseOptions.GwtPlotLines;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtAxisBaseOptions.GwtXAxisDataLabels;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtAxisBaseOptions.GwtYAxisDataLabels;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtChartLabels;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtChartLabels.GwtChartLabelItem;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtChartOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtChartOptions.GwtChartEvents;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtCreditOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtLegendOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtAreaOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtAreaSplineOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtBarOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtBaseBarOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtBaseLineOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtColumnOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtDataLabels;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtLineOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtMarker;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtMarker.GwtMarkerStates;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtMarker.GwtMarkerStates.GwtMarkerState;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtPieDataLabels;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtPieOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtScatterOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtSeriesEvents;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtSeriesGeneralOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtSeriesGeneralOptions.GwtStates;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtSeriesGeneralOptions.GwtStates.GwtHover;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtSplineOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPointOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPointOptions.GwtPointEvents;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPosition;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtSeriesDataOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtSubtitleOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtTitleBaseOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtTitleOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtTooltipOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtXAxisOptions;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtXAxisOptions.GwtDateTimeLabelFormats;
-import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtYAxisOptions;
-
-/**
- * Client side widget which communicates with the server. Messages from the
- * server are shown as HTML and mouse clicks are sent to the server.
- *
- * Reads data from UIDL and create appropriate JavaScript overlay objects such
- * as {@link GwtChart}, {@link GwtAxis}, {@link GwtInvientChartsConfig},
- * {@link GwtPoint} and {@link GwtSeries}
- *
- * Uses a method newChart() of {@link GwtInvientChartsUtil} to create a chart
- * object of type {@link GwtChart}
- *
- * @author Invient
- */
-public class VInvientCharts extends GwtInvientCharts implements Paintable /*
- * ,
- * ClickHandler
- * ,
- * ScrollHandler
- */{
-
- private static final long serialVersionUID = -762763091427791681L;
-
- /** Set the CSS class name to allow styling. */
- public static final String CLASSNAME = "v-invientcharts";
-
- /** The client side widget identifier */
- protected String uidlId;
-
- /** Reference to the server connection object. */
- protected ApplicationConnection client;
-
- /**
- * The constructor should first call super() to initialize the component and
- * then handle any initialization relevant to Vaadin.
- */
- public VInvientCharts() {
- super();
- setStyleName(CLASSNAME);
- publish();
- }
-
- /**
- * Called whenever an update is received from the server
- */
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- VConsole.log("Enter [updateFromUIDL]");
- // This call should be made first.
- // It handles sizes, captions, tooltips, etc. automatically.
- if (client.updateComponent(this, uidl, true)) {
- // If client.updateComponent returns true there has been no changes
- // and we
- // do not need to update anything.
- return;
- }
-
- // Save reference to server connection object to be able to send
- // user interaction later
- this.client = client;
-
- // Save the client side identifier (paintable id) for the widget
- uidlId = uidl.getId();
-
- // Create chart only once along with chart options
- // Chart options are set only once.
- if (chart == null) {
- // Chart options
- GwtInvientChartsConfig options = getInvientChartOptions(uidl
- .getChildUIDL(ChartUIDLIndex.OPTIONS.ordinal()));
- // Chart events
- updateOptionsWithEvents(options,
- uidl.getChildUIDL(ChartUIDLIndex.EVENTS.ordinal()));
- // Chart data
- JsArray chartData = getChartData(uidl
- .getChildUIDL(ChartUIDLIndex.DATA.ordinal()));
- options.setSeriesInstanceOptions(chartData);
- VConsole.log("Going to create a chart.");
- createChart(options);
- } else {
- resetRedrawChart();
- if (uidl.getBooleanAttribute("reloadChartSeries")) {
- // Get all series and add them to chart
- JsArray chartData = getChartData(uidl
- .getChildUIDL(ChartUIDLIndex.DATA.ordinal()));
- int seriesCount = chart.getSeries().length();
- VConsole.log("# of series the chart has " + seriesCount);
- VConsole.log("Going to remove all series of the chart.");
- for (int ind = seriesCount - 1; ind >= 0; ind--) {
- setRedrawChart();
- chart.getSeries().get(ind).remove(false);
- }
- VConsole.log("Goint to add series to the chart.");
- for (int ind = 0; ind < chartData.length(); ind++) {
- setRedrawChart();
- chart.addSeries(chartData.get(ind), false);
- }
- } else {
- VConsole.log("Going to update chart data.");
- UIDL chartDataUIDL = uidl.getChildUIDL(ChartUIDLIndex.DATA
- .ordinal());
- UIDL chartDataUpdatesUIDL = uidl
- .getChildUIDL(ChartUIDLIndex.DATA_UPDATES.ordinal());
- updateChartData(chartDataUpdatesUIDL, chartDataUIDL);
- }
-
- // Options UIDL
- UIDL optionsUIDL = uidl.getChildUIDL(ChartUIDLIndex.OPTIONS
- .ordinal());
- // Update chart title & subtitle
- setChartTitleAndSubtitle(optionsUIDL);
- // Size
- setChartSize(optionsUIDL);
-
- VConsole.log("Getting x-axis options...");
- JsArray uidlXAxesOptionsArr = getXAxisOptions(optionsUIDL
- .getChildUIDL(ChartOptionsUIDLIndex.X_AXES.ordinal()));
- JsArray chartXAxesOptionsArr = JavaScriptObject
- .createArray().cast();
- JsArray chartXAxesArr = chart.getXAxes();
- if (chart.getOptions().hasXAxesOptions()) {
- chartXAxesOptionsArr = chart.getOptions().getXAxesOptions();
- updateXAxisCategories(chartXAxesArr, chartXAxesOptionsArr,
- uidlXAxesOptionsArr);
- }
- updateAxesPlotBandsAndPlotLines(chartXAxesArr,
- chartXAxesOptionsArr, uidlXAxesOptionsArr);
-
- VConsole.log("Getting y-axis options...");
- JsArray uidlYAxesOptionsArr = getYAxisOptions(optionsUIDL
- .getChildUIDL(ChartOptionsUIDLIndex.Y_AXES.ordinal()));
- JsArray chartYAxesOptionsArr = JavaScriptObject
- .createArray().cast();
- if (chart.getOptions().hasYAxesOptions()) {
- chartYAxesOptionsArr = chart.getOptions().getYAxesOptions();
- }
- JsArray chartYAxesArr = chart.getYAxes();
- updateAxesPlotBandsAndPlotLines(chartYAxesArr,
- chartYAxesOptionsArr, uidlYAxesOptionsArr);
- // Update axis extremes
- if (chart.getOptions().hasXAxesOptions()
- || chart.getOptions().hasYAxesOptions()) {
- updateAxisExtremes(chart.getXAxes(), chartXAxesOptionsArr,
- uidlXAxesOptionsArr);
- updateAxisExtremes(chart.getYAxes(), chartYAxesOptionsArr,
- uidlYAxesOptionsArr);
- }
- if (isRedrawChart()) {
- VConsole.log("Going to redraw the chart.");
- chart.redraw();
- }
- }
- // Get SVG if required and send it to server
- handleChartSVG(uidl);
- handlePrint(uidl);
- VConsole.log("Exit [updateFromUIDL]");
- }
-
- // Set title & subtitle
- private void setChartTitleAndSubtitle(UIDL optionsUIDL) {
- VConsole.log("Enter [setChartTitleAndSubtitle]");
- // There is not need to set redrawChart flag as setting title & subtitle
- // does not require redrawing of the chart.
- chart.setTitle(
- getTitleOptions(optionsUIDL
- .getChildUIDL(ChartOptionsUIDLIndex.TITLE.ordinal())),
- getSubtitleOptions(optionsUIDL
- .getChildUIDL(ChartOptionsUIDLIndex.SUBTITLE.ordinal())));
- VConsole.log("Exit [setChartTitleAndSubtitle]");
- }
-
- // Set chart size
- private void setChartSize(UIDL optionsUIDL) {
- // There is not need to set redrawChart flag as setting title & subtitle
- // does not require redrawing of the chart.
- GwtChartOptions chartOptions = getChartOptions(optionsUIDL
- .getChildUIDL(ChartOptionsUIDLIndex.CHART_CONFIG.ordinal()));
- int newWidth = chartOptions.getWidth();
- int newHeight = chartOptions.getHeight();
- int existingWidth = chart.getOptions().getChartOptions().getWidth();
- int existingHeight = chart.getOptions().getChartOptions().getHeight();
-
- if ((newWidth != -1 && newWidth != existingWidth)
- || (newHeight != -1 && newHeight != existingHeight)) {
- VConsole.log("Set chart size.");
- chart.getOptions().getChartOptions().setWidth(newWidth);
- chart.getOptions().getChartOptions().setHeight(newHeight);
- chart.setSize(newWidth, newHeight);
- }
- }
-
- private void handlePrint(UIDL uidl) {
- boolean isPrint = uidl.getBooleanAttribute("isPrint");
- if (isPrint) {
- VConsole.log("Going to print the chart...");
- chart.printInvientChart();
- }
- }
-
- private void handleChartSVG(UIDL uidl) {
- boolean isRetrieveSVG = uidl.getBooleanAttribute("isRetrieveSVG");
- if (isRetrieveSVG) {
- VConsole.log("Get an svg string...");
- String svg = chart.getSVG(null);
- // send svg to server
- client.updateVariable(uidlId, "event", "chartSVGAvailable", false);
- Map eventData = new HashMap();
- eventData.put("svg", svg);
- client.updateVariable(uidlId, "eventData", eventData, true);
- }
- }
-
- private void updateXAxisCategories(JsArray chartAxesArr,
- JsArray chartXAxesOptionsArr,
- JsArray uidlXAxesOptionsArr) {
- VConsole.log("Enter [updateXAxisCategories]");
- if (chartXAxesOptionsArr == null || chartXAxesOptionsArr.length() == 0) {
- VConsole.log("Chart doesn't have any X axis]");
- VConsole.log("Exit [updateXAxisCategories]");
- return;
- }
- int noOfAxis = chartXAxesOptionsArr.length();
- for (int ind = 0; ind < noOfAxis; ind++) {
- GwtAxis chartAxis = chartAxesArr.get(ind);
- GwtXAxisOptions chartAxisOptions = chartXAxesOptionsArr.get(ind);
- GwtXAxisOptions uidlAxisOptions = uidlXAxesOptionsArr.get(ind);
- if (chartAxis != null && chartAxisOptions != null
- && uidlAxisOptions != null) {
- // If axis
- if (!areStringArraysEqual(uidlAxisOptions.getCategories(),
- chartAxis.getCategories())) {
- setRedrawChart();
- chartAxisOptions.setCategories(uidlAxisOptions
- .getCategories());
- chartAxis.setCategories(uidlAxisOptions.getCategories(),
- false);
- }
- }
- }
- VConsole.log("Exit [updateXAxisCategories]");
- }
-
- private boolean areStringArraysEqual(JsArrayString arrOne,
- JsArrayString arrTwo) {
- if (arrOne == arrTwo) {
- return true;
- }
- if ((arrOne != null && arrTwo == null)
- || (arrOne == null && arrTwo != null)) {
- return false;
- }
- if (arrOne.length() != arrTwo.length()) {
- return false;
- }
- // Compare each array element
- for (int arrInd = 0; arrInd < arrOne.length(); arrInd++) {
- String arrOneVal = arrOne.get(arrInd);
- String arrTwoVal = arrTwo.get(arrInd);
- if (arrOneVal == null) {
- if (arrTwoVal != null) {
- return false;
- }
- }
- else if(!arrOneVal.equals(arrTwoVal)) {
- return false;
- }
- }
-
- return true;
- }
-
- private void updateAxisExtremes(JsArray chartAxesArr,
- JsArray extends GwtAxisBaseOptions> chartAxesOptionsArr,
- JsArray extends GwtAxisBaseOptions> uidlAxesOptionsArr) {
- VConsole.log("Enter [updateAxisExtremes]");
- if (chartAxesOptionsArr == null || chartAxesOptionsArr.length() == 0) {
- VConsole.log("Chart doesn't have any X/Y axis]");
- VConsole.log("Exit [updateAxisExtremes]");
- return;
- }
- int noOfAxis = chartAxesOptionsArr.length();
- for (int ind = 0; ind < noOfAxis; ind++) {
- GwtAxis chartAxis = chartAxesArr.get(ind);
- GwtAxisBaseOptions chartAxisOptions = chartAxesOptionsArr.get(ind);
- GwtAxisBaseOptions uidlAxisOptions = uidlAxesOptionsArr.get(ind);
- if (chartAxis != null && chartAxisOptions != null
- && uidlAxisOptions != null) {
- double uidlMin = uidlAxisOptions.getMin();
- double uidlMax = uidlAxisOptions.getMax();
- double chartMin = chartAxisOptions.getMin();
- double chartMax = chartAxisOptions.getMax();
- // Update chart's axis options as
- // it is not updated when extremes are set using
- // axis.setExtremes()
- if (uidlMin != chartMin) {
- setRedrawChart();
- chartAxisOptions.setMin(uidlMin);
- }
- if (uidlMax != chartMax) {
- setRedrawChart();
- chartAxisOptions.setMax(uidlMax);
- }
- VConsole.log("[updateAxisExtremes] min " + chartAxisOptions.getMin() + ", max " + chartAxisOptions.getMax());
- chartAxis.setExtremes(chartAxisOptions.getMin(), chartAxisOptions.getMax(), false);
- }
- }
- VConsole.log("Exit [updateAxisExtremes]");
- }
-
- private enum ChartUIDLIndex {
- OPTIONS, DATA, EVENTS, DATA_UPDATES;
- }
-
- private enum ChartOptionsUIDLIndex {
- TITLE, SUBTITLE, CREDIT, LEGEND, TOOLTIP, CHART_CONFIG, SERIES_OPTIONS, X_AXES, Y_AXES, LABEL;
- }
-
- private void updateAxesPlotBandsAndPlotLines(
- JsArray extends GwtAxis> chartAxesArr,
- JsArray extends GwtAxisBaseOptions> chartAxesOptionsArr,
- JsArray extends GwtAxisBaseOptions> uidlAxesOptionsArr) {
- VConsole.log("Enter [updateAxesPlotBandsAndPlotLines]");
- int noOfAxis = chartAxesArr.length();
- for (int ind = 0; ind < noOfAxis; ind++) {
- GwtAxis chartAxis = chartAxesArr.get(ind);
- GwtAxisBaseOptions chartAxisOptions = chartAxesOptionsArr.get(ind);
- GwtAxisBaseOptions uidlAxisOptions = uidlAxesOptionsArr.get(ind);
- if (chartAxis != null && chartAxisOptions != null
- && uidlAxisOptions != null) {
- updatePlotBands(chartAxis, chartAxisOptions, uidlAxisOptions);
- updatePlotLines(chartAxis, chartAxisOptions, uidlAxisOptions);
- }
- }
- VConsole.log("Exit [updateAxesPlotBandsAndPlotLines]");
- }
-
- //
- private void updatePlotLines(GwtAxis chartAxis,
- GwtAxisBaseOptions chartAxisOptions,
- GwtAxisBaseOptions uidlAxisOptions) {
- VConsole.log("Enter [updatePlotLines]");
- // Update chartAxisPlotBands whenever a plotline is added or removed as
- // the library
- // does not update chart options by itself.
- JsArray chartAxisPlotLines = chartAxisOptions
- .getPlotLines();
- JsArray uidlAxisPlotLines = uidlAxisOptions
- .getPlotLines();
- if (uidlAxisPlotLines == null && chartAxisPlotLines == null) {
- VConsole.log("No plotlines found.");
- VConsole.log("Exit [updatePlotLines]");
- return;
- }
- if (uidlAxisPlotLines == null) {
- uidlAxisPlotLines = JavaScriptObject.createArray().cast();
- }
- if (chartAxisPlotLines == null) {
- chartAxisPlotLines = JavaScriptObject.createArray().cast();
- }
- JsArray updatedChartAxisPlotLines = JavaScriptObject
- .createArray().cast();
- int numOfChartAxisPlotLines = chartAxisPlotLines.length();
- int numOfUIDLAxisPlotLines = uidlAxisPlotLines.length();
- boolean updatedAxisPlotLines = false;
- for (int indOuter = 0; indOuter < numOfChartAxisPlotLines; indOuter++) {
- GwtPlotLines chartPlotLine = chartAxisPlotLines.get(indOuter);
- String plotLineId = chartPlotLine.getId();
- boolean found = false;
- for (int indInner = 0; indInner < numOfUIDLAxisPlotLines; indInner++) {
- GwtPlotLines uidlPlotLine = uidlAxisPlotLines.get(indInner);
- if (uidlPlotLine != null
- && uidlPlotLine.getId().equals(plotLineId)) {
- if (uidlPlotLine.getValue() == chartPlotLine.getValue()) {
- // PlotLine exists and value is same so no action should
- // be taken except marking UIDL PlotLine to null.
- // Setting UIDL PlotLine
- // to null ensures that remaining PlotLines in UIDL can
- // be added
- // safely to the chart.
- uidlAxisPlotLines.set(indInner, null);
- updatedChartAxisPlotLines.push(chartPlotLine);
- found = true;
- }
- break;
- }
- }
- if (!found) {
- // remove plot line as it is not found in UIDL received from the
- // server
- updatedAxisPlotLines = true;
- chartAxis.removePlotLine(plotLineId);
- }
- }
- // Add all remaining plot lines in UIDL to the chart
- for (int ind = 0; ind < numOfUIDLAxisPlotLines; ind++) {
- GwtPlotLines uidlPlotLine = uidlAxisPlotLines.get(ind);
- if (uidlPlotLine != null) {
- updatedAxisPlotLines = true;
- chartAxis.addPlotLine(uidlPlotLine);
- updatedChartAxisPlotLines.push(uidlPlotLine);
- }
- }
-
- // Update chart axis plotlines
- if (updatedAxisPlotLines) {
- setRedrawChart();
- chartAxisOptions.setPlotLines(updatedChartAxisPlotLines);
- }
- VConsole.log("Exit [updatePlotLines]");
- }
-
- //
- private void updatePlotBands(GwtAxis chartAxis,
- GwtAxisBaseOptions chartAxisOptions,
- GwtAxisBaseOptions uidlAxisOptions) {
- VConsole.log("Enter [updatePlotBands]");
- // Update chartAxisPlotBands whenever a plotband is added or removed as
- // the library
- // does not update chart options by itself.
- JsArray chartAxisPlotBands = chartAxisOptions
- .getPlotBands();
- JsArray uidlAxisPlotBands = uidlAxisOptions
- .getPlotBands();
- if (uidlAxisPlotBands == null && chartAxisPlotBands == null) {
- VConsole.log("No plotbands found.");
- VConsole.log("Exit [updatePlotBands]");
- return;
- }
- if (uidlAxisPlotBands == null) {
- uidlAxisPlotBands = JavaScriptObject.createArray().cast();
- }
- if (chartAxisPlotBands == null) {
- chartAxisPlotBands = JavaScriptObject.createArray().cast();
- }
- JsArray updatedChartAxisPlotBands = JavaScriptObject
- .createArray().cast();
- int numOfChartAxisPlotBands = chartAxisPlotBands.length();
- int numOfUIDLAxisPlotBands = uidlAxisPlotBands.length();
- boolean updatedAxisPlotBands = false;
- for (int indOuter = 0; indOuter < numOfChartAxisPlotBands; indOuter++) {
- GwtPlotBands chartPlotBand = chartAxisPlotBands.get(indOuter);
- String plotBandId = chartPlotBand.getId();
- boolean found = false;
- for (int indInner = 0; indInner < numOfUIDLAxisPlotBands; indInner++) {
- GwtPlotBands uidlPlotBand = uidlAxisPlotBands.get(indInner);
- if (uidlPlotBand != null
- && uidlPlotBand.getId().equals(plotBandId)) {
- if (chartPlotBand.getFrom() == uidlPlotBand.getFrom()
- && chartPlotBand.getTo() == uidlPlotBand.getTo()) {
- VConsole.log("Plotband id "
- + plotBandId
- + " exists in chart as well as in UIDL from the server.");
- // PlotBand exists and from/to values are same so
- // nothing to be done.
- // The UIDL plotband is set to null so that remaining
- // plotbands
- // can be safely added to the chart
- uidlAxisPlotBands.set(indInner, null);
- updatedChartAxisPlotBands.push(chartPlotBand);
- VConsole.log("Plotband id " + plotBandId
- + " exists in both.");
- found = true;
- }
- break;
- }
- }
- if (!found) {
- // remove plot band as it is not found in UIDL received from the
- // server
- VConsole.log("Plotband id " + plotBandId + " removed.");
- updatedAxisPlotBands = true;
- chartAxis.removePlotBand(plotBandId);
- }
- }
- // Add all remaining plot bands in UIDL to the chart
- for (int ind = 0; ind < numOfUIDLAxisPlotBands; ind++) {
- GwtPlotBands uidlPlotBand = uidlAxisPlotBands.get(ind);
- if (uidlPlotBand != null) {
- updatedAxisPlotBands = true;
- VConsole.log("Plotband id " + uidlPlotBand.getId()
- + " added with from : " + uidlPlotBand.getFrom()
- + " and to: " + uidlPlotBand.getTo());
- chartAxis.addPlotBand(uidlPlotBand);
- updatedChartAxisPlotBands.push(uidlPlotBand);
- }
- }
-
- // Update chart axis plotbands
- if (updatedAxisPlotBands) {
- setRedrawChart();
- chartAxisOptions.setPlotBands(updatedChartAxisPlotBands);
- }
- VConsole.log("Exit [updatePlotBands]");
- }
-
- private boolean redrawChart = false;
-
- private void setRedrawChart() {
- this.redrawChart = true;
- }
-
- private boolean isRedrawChart() {
- return this.redrawChart;
- }
-
- private void resetRedrawChart() {
- this.redrawChart = false;
- }
-
- private void updateChartData(UIDL uidlChartDataUpdates, UIDL uidlChartData) {
- VConsole.log("Enter [updateChartData]");
- JsArrayString seriesToAdd = JavaScriptObject.createArray().cast();
- JsArrayString seriesToUpdate = JavaScriptObject.createArray().cast();
- List seriesToUpdateList = new ArrayList();
- for (int ind = 0; ind < uidlChartDataUpdates.getChildCount(); ind++) {
- UIDL seriesUpdateUIDL = uidlChartDataUpdates.getChildUIDL(ind);
- String seriesName = seriesUpdateUIDL
- .getStringAttribute("seriesName");
- String operation = seriesUpdateUIDL.getStringAttribute("operation");
- VConsole.log("Series name : " + seriesName + ", operation : "
- + operation);
- if (seriesName != null && seriesName.length() > 0
- && operation != null && operation.length() > 0) {
- if (SeriesCURType.REMOVE.getName().equals(operation)) {
- GwtSeries series = chart.getSeries(seriesName);
- if (series != null) {
- VConsole.log("Removing series : " + seriesName);
- setRedrawChart();
- series.remove(false);
- }
- } else if (SeriesCURType.ADD.getName().equals(operation)) {
- seriesToAdd.push(seriesName);
- } else if (SeriesCURType.UPDATE.getName().equals(operation)) {
- VConsole.log("Will update series : " + seriesName);
- seriesToUpdateList.add(seriesUpdateUIDL);
- seriesToUpdate.push(seriesName);
- }
- }
- }
-
- if (seriesToAdd.length() > 0) {
- setRedrawChart();
- JsArray uidlChartDataArr = getChartData(
- uidlChartData, seriesToAdd);
- for (int ind = 0; ind < uidlChartDataArr.length(); ind++) {
- VConsole.log("Adding series "
- + uidlChartDataArr.get(ind).getName());
- chart.addSeries(uidlChartDataArr.get(ind), false);
- }
- }
- if (seriesToUpdateList.size() > 0) {
- setRedrawChart();
- JsArray uidlChartDataArr = getChartData(
- uidlChartData, seriesToUpdate);
- for (int ind = 0; ind < seriesToUpdateList.size(); ind++) {
- UIDL uidlSeriesToUpdate = seriesToUpdateList.get(ind);
- GwtSeriesDataOptions uidlSeriesDataOptions = uidlChartDataArr
- .get(ind);
- GwtSeries chartSeries = chart.getSeries(uidlSeriesDataOptions
- .getName());
- GwtSeriesGeneralOptions chartSeriesOptions = chartSeries
- .getSeriesGeneralOptions();
- GwtSeriesGeneralOptions uidlSeriesOptions = uidlSeriesDataOptions
- .getSeriesOptions();
- // Update visibility
- boolean isVisible = (uidlSeriesOptions != null ? uidlSeriesOptions
- .isVisible() : true);
- chartSeriesOptions.setVisible(isVisible);
- if (chartSeriesOptions.isVisible() == true
- && chartSeries.isVisible() == false) {
- chartSeries.show();
- }
- if (chartSeriesOptions.isVisible() == false
- && chartSeries.isVisible() == true) {
- chartSeries.hide();
- }
- // Update points
- if (uidlSeriesToUpdate.getBooleanAttribute("isReloadPoints")) {
- // update all points
- VConsole.log("Reloading points for series : "
- + uidlSeriesToUpdate.getStringAttribute("name"));
- chartSeries.setDataAsPointOptions(
- uidlSeriesDataOptions.getDataAsPointOptions(),
- false);
- } else {
- UIDL uidlPointsAdded = uidlSeriesToUpdate.getChildUIDL(0);
- UIDL uidlPointsRemoved = uidlSeriesToUpdate.getChildUIDL(1);
- updateSeriesData(chartSeries, uidlPointsAdded,
- uidlPointsRemoved);
- }
- }
- }
-
- VConsole.log("Exit [updateChartData]");
- }
-
- private void updateSeriesData(GwtSeries chartSeries, UIDL uidlPointsAdded,
- UIDL uidlPointsRemoved) {
- VConsole.log("Enter [updateSeriesData]");
- if (uidlPointsAdded != null && uidlPointsAdded.getChildCount() > 0) {
- // Add points
- JsArray pointsTobeAdded = getSeriesPoints(uidlPointsAdded);
- VConsole.log("# of points to be added : "
- + pointsTobeAdded.length());
- for (int cnt = 0; cnt < pointsTobeAdded.length(); cnt++) {
- GwtPointOptions pointOptions = pointsTobeAdded.get(cnt);
- chartSeries.addPoint(pointOptions, false,
- pointOptions.isShift());
- }
- }
-
- if (uidlPointsRemoved != null && uidlPointsRemoved.getChildCount() > 0) {
- // Remove points
- JsArray pointsTobeRemoved = getSeriesPoints(uidlPointsRemoved);
- VConsole.log("# of points to be removed : "
- + pointsTobeRemoved.length());
- JsArray chartSeriesData = chartSeries.getData();
- for (int cnt = 0; cnt < pointsTobeRemoved.length(); cnt++) {
- GwtPointOptions pointToRemove = pointsTobeRemoved.get(cnt);
- for (int chartPointCnt = 0; chartPointCnt < chartSeriesData
- .length(); chartPointCnt++) {
- GwtPoint chartSeriesPoint = chartSeriesData
- .get(chartPointCnt);
- // Using Double.compareTo(another Double) does not result in
- // appr. code which can be executed in JS correctly.
- // e.g. x.compareTo(y) results in compare(x.value, y.value)
- // where x.value is undefined in JS,
- // Don't know the reason yet but will figure out. So do a
- // direct comparison
- if (chartSeriesPoint.getX() == pointToRemove.getX()
- && chartSeriesPoint.getY() == pointToRemove.getY()) {
- VConsole.log("Removing point ("
- + chartSeriesPoint.getX() + ", "
- + chartSeriesPoint.getY() + ")");
- chartSeriesPoint.remove();
- break;
- }
- }
- }
- }
- VConsole.log("Exit [updateSeriesData]");
- }
-
- private static enum SeriesCURType {
- ADD("Add"), UPDATE("Update"), REMOVE("Remove");
- private String name;
-
- private SeriesCURType(String name) {
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
- }
-
- private JsArray getChartData(UIDL uidl) {
- return getChartData(uidl, null);
- }
-
- private boolean doesArrayContainSeriesName(
- JsArrayString namesOfSeriesToAdd, String seriesName) {
- for (int ind = 0; ind < namesOfSeriesToAdd.length(); ind++) {
- if (seriesName.equals(namesOfSeriesToAdd.get(ind))) {
- return true;
- }
- }
- return false;
- }
-
- private JsArray getChartData(UIDL uidl,
- JsArrayString namesOfSeriesToAdd) {
- VConsole.log("Enter [getChartData]");
-
- JsArray seriesDataArr = JavaScriptObject
- .createArray().cast();
- // Process each series data
- for (int cnt = 0; cnt < uidl.getChildCount(); cnt++) {
- GwtSeriesDataOptions seriesData = GwtSeriesDataOptions.create();
- UIDL seriesUIDL = uidl.getChildUIDL(cnt);
- String seriesName = seriesUIDL.getStringAttribute("name");
- if (seriesName != null && namesOfSeriesToAdd != null) {
- if (!doesArrayContainSeriesName(namesOfSeriesToAdd, seriesName)) {
- continue;
- }
- }
- // From charts series data retrieve only those series data
- // whose names are specified in the second argument
- if (seriesUIDL.hasAttribute("name")) {
- // Setting name automatically sets series id which can later be
- // used to retrieve using chart.get(id);
- seriesData.setName(seriesName);
- }
- if (seriesUIDL.hasAttribute("stack")) {
- seriesData.setStack(seriesUIDL.getStringAttribute("stack"));
- }
- // FIXME - fallback on chart options type if series doesn't have a
- // type
- String seriesType = "line";
- if (seriesUIDL.hasAttribute("type")) {
- seriesType = seriesUIDL.getStringAttribute("type");
- seriesData.setType(seriesType);
- }
- if (seriesUIDL.hasAttribute("xAxis")) {
- seriesData.setXAxis(seriesUIDL.getIntAttribute("xAxis"));
- }
- if (seriesUIDL.hasAttribute("yAxis")) {
- seriesData.setYAxis(seriesUIDL.getIntAttribute("yAxis"));
- }
- // Get data/points
- seriesData.setDataAsPointOptions(getSeriesPoints(seriesUIDL
- .getChildUIDL(1)));
- // Get series options
- GwtSeriesGeneralOptions seriesOptions = getSeriesOptions(
- seriesType, seriesUIDL.getChildUIDL(0));
- if (seriesOptions != null) {
- seriesData.setSeriesOptions(seriesOptions);
- }
-
- seriesDataArr.push(seriesData);
- }
-
- VConsole.log("Exit [getChartData]");
- return seriesDataArr;
- }
-
- private JsArray getSeriesPoints(UIDL pointsUIDL) {
- VConsole.log("Enter [getSeriesPoints]");
-
- JsArray pointsArr = JavaScriptObject.createArray()
- .cast();
- for (int cnt = 0; cnt < pointsUIDL.getChildCount(); cnt++) {
- UIDL pointUIDL = pointsUIDL.getChildUIDL(cnt);
- GwtPointOptions pointOptions = GwtPointOptions.create();
- // If a point doesn't have any attributes then
- // consider it as a null since a user might want to represent
- // no activity graph
- if (pointUIDL.getAttributeNames().size() == 0) {
- pointOptions.setNullY();
- } else {
- if (pointUIDL.hasAttribute("id")) {
- pointOptions.setId(pointUIDL.getStringAttribute("id"));
- }
- if (pointUIDL.hasAttribute("name")) {
- pointOptions.setName(pointUIDL.getStringAttribute("name"));
- }
- if (pointUIDL.hasAttribute("color")) {
- pointOptions
- .setColor(pointUIDL.getStringAttribute("color"));
- }
- if (pointUIDL.hasAttribute("sliced")) {
- pointOptions.setSliced(pointUIDL
- .getBooleanAttribute("sliced"));
- }
- if (pointUIDL.hasAttribute("selected")) {
- pointOptions.setSelected(pointUIDL
- .getBooleanAttribute("selected"));
- }
- if (pointUIDL.hasAttribute("x")) {
- pointOptions.setX(pointUIDL.getIntAttribute("x"));
- } else {
- pointOptions.setNullX();
- }
- if (pointUIDL.hasAttribute("y")) {
- pointOptions.setY(pointUIDL.getIntAttribute("y"));
- } else {
- pointOptions.setNullY();
- }
- if (pointUIDL.hasAttribute("isShift")) {
- pointOptions.setShift(pointUIDL
- .getBooleanAttribute("isShift"));
- }
- GwtMarker markerOptions = getMarkerOptions(pointUIDL
- .getChildUIDL(0));
- if (markerOptions != null) {
- pointOptions.setMarker(markerOptions);
- }
- }
- pointsArr.push(pointOptions);
- }
-
- VConsole.log("Exit [getSeriesPoints]");
- return pointsArr;
- }
-
- private GwtInvientChartsConfig getInvientChartOptions(UIDL uidl) {
- VConsole.log("Enter [getInvientChartOptions]");
- VConsole.log("Child UIDL count : " + uidl.getChildCount());
- GwtInvientChartsConfig options = GwtInvientChartsConfig.create();
- // Get title UIDL
- VConsole.log("Getting title options...");
- // Title
- options.setTitleOptions(getTitleOptions(uidl
- .getChildUIDL(ChartOptionsUIDLIndex.TITLE.ordinal())));
-
- VConsole.log("Getting subtitle options...");
- // Subtitle
- options.setSubtitleOptions(getSubtitleOptions(uidl
- .getChildUIDL(ChartOptionsUIDLIndex.SUBTITLE.ordinal())));
- // Credit
- options.setCreditOptions(getCreditOptions(uidl
- .getChildUIDL(ChartOptionsUIDLIndex.CREDIT.ordinal())));
- // Legend
- options.setLegendOptions(getLegendOptions(uidl
- .getChildUIDL(ChartOptionsUIDLIndex.LEGEND.ordinal())));
- // Tooltip
- options.setTooltipOptions(getTooltipOptions(uidl
- .getChildUIDL(ChartOptionsUIDLIndex.TOOLTIP.ordinal())));
-
- // Then DEMO application
- VConsole.log("Getting chart options...");
- // Chart Options
- options.setChartOptions(getChartOptions(uidl
- .getChildUIDL(ChartOptionsUIDLIndex.CHART_CONFIG.ordinal())));
-
- VConsole.log("Getting plot options...");
- // Plot Options for various series types
- options.setPlotOptions(getPlotOptions(uidl
- .getChildUIDL(ChartOptionsUIDLIndex.SERIES_OPTIONS.ordinal())));
-
- VConsole.log("Getting x-axis options...");
- JsArray xAxisOptions = getXAxisOptions(uidl
- .getChildUIDL(ChartOptionsUIDLIndex.X_AXES.ordinal()));
- if (xAxisOptions.length() > 0) {
- options.setXAxesOptions(xAxisOptions);
- }
-
- VConsole.log("Getting y-axis options...");
- JsArray yAxisOptions = getYAxisOptions(uidl
- .getChildUIDL(ChartOptionsUIDLIndex.Y_AXES.ordinal()));
- if (yAxisOptions.length() > 0) {
- options.setYAxesOptions(yAxisOptions);
- }
-
- VConsole.log("Getting chart labels...");
- GwtChartLabels labels = getChartLabels(uidl
- .getChildUIDL(ChartOptionsUIDLIndex.LABEL.ordinal()));
- if (labels != null) {
- options.setLabels(labels);
- }
-
- VConsole.log("Exit [getInvientChartOptions]");
- return options;
- }
-
- private GwtChartLabels getChartLabels(UIDL uidl) {
- VConsole.log("Enter [getChartLabels]");
- VConsole.log("Tag name -> " + uidl.getTag());
- if ((uidl.getAttributeNames().size() == 0 && uidl.getChildCount() == 0)
- || (uidl.getAttributeNames().size() > 0 && uidl.getChildCount() == 0)) {
- VConsole.log("Exit [getChartLabels]");
- return null;
- }
- UIDL labelItemsUIDL = uidl.getChildUIDL(0);
- if (labelItemsUIDL.getChildCount() == 0) {
- VConsole.log("Exit [getChartLabels]");
- return null;
- }
-
- GwtChartLabels labels = GwtChartLabels.create();
- if (uidl.hasAttribute("style")) {
- labels.setStyle(uidl.getStringAttribute("style"));
- }
-
- JsArray chartLabelItemsArr = JavaScriptObject
- .createArray().cast();
- for (int cnt = 0; cnt < labelItemsUIDL.getChildCount(); cnt++) {
- UIDL labelItemUIDL = labelItemsUIDL.getChildUIDL(cnt);
- if (labelItemUIDL.hasAttribute("html")
- || labelItemUIDL.hasAttribute("style")) {
- GwtChartLabelItem labelItem = GwtChartLabelItem.create();
- if (labelItemUIDL.hasAttribute("html")) {
- labelItem.setHtml(labelItemUIDL.getStringAttribute("html"));
- }
- //
- if (labelItemUIDL.hasAttribute("style")) {
- labelItem.setStyle(labelItemUIDL
- .getStringAttribute("style"));
- }
- chartLabelItemsArr.push(labelItem);
- }
- }
- labels.setItems(chartLabelItemsArr);
- VConsole.log("Exit [getChartLabels]");
- return labels;
- }
-
- private GwtCreditOptions getCreditOptions(UIDL uidl) {
- VConsole.log("Enter [getCreditOptions]");
- VConsole.log("Tag name -> " + uidl.getTag());
- GwtCreditOptions creditOptions = GwtCreditOptions.create();
-
- if (uidl.hasAttribute("enabled")) {
- creditOptions.setEnabled(uidl.getBooleanAttribute("enabled"));
- }
- if (uidl.hasAttribute("href")) {
- creditOptions.setHref(uidl.getStringAttribute("href"));
- }
- if (uidl.hasAttribute("style")) {
- creditOptions.setStyle(uidl.getStringAttribute("style"));
- }
- if (uidl.hasAttribute("text")) {
- creditOptions.setText(uidl.getStringAttribute("text"));
- }
- UIDL positionUIDL = uidl.getChildUIDL(0);
- GwtPosition position = GwtPosition.create();
- if (positionUIDL.hasAttribute("align")) {
- position.setAlign(positionUIDL.getStringAttribute("align"));
- }
- if (positionUIDL.hasAttribute("verticalAlign")) {
- position.setVerticalAlign(positionUIDL
- .getStringAttribute("verticalAlign"));
- }
- if (positionUIDL.hasAttribute("x")) {
- position.setX(positionUIDL.getIntAttribute("x"));
- }
- if (positionUIDL.hasAttribute("y")) {
- position.setY(positionUIDL.getIntAttribute("y"));
- }
- creditOptions.setPosition(position);
-
- VConsole.log("Exit [getCreditOptions]");
- return creditOptions;
- }
-
- private GwtLegendOptions getLegendOptions(UIDL uidl) {
- VConsole.log("Enter [getLegendOptions]");
- VConsole.log("Tag name -> " + uidl.getTag());
-
- GwtLegendOptions legendOptions = GwtLegendOptions.create();
- if (uidl.hasAttribute("align")) {
- legendOptions.setAlign(uidl.getStringAttribute("align"));
- }
- if (uidl.hasAttribute("backgroundColor")) {
- legendOptions.setBackgroundColor(uidl
- .getStringAttribute("backgroundColor"));
- }
- if (uidl.hasAttribute("borderColor")) {
- legendOptions
- .setBorderColor(uidl.getStringAttribute("borderColor"));
- }
- if (uidl.hasAttribute("borderRadius")) {
- legendOptions.setBorderRadius(uidl.getIntAttribute("borderRadius"));
- }
- if (uidl.hasAttribute("borderWidth")) {
- legendOptions.setBorderWidth(uidl.getIntAttribute("borderWidth"));
- }
- if (uidl.hasAttribute("enabled")) {
- legendOptions.setEnabled(uidl.getBooleanAttribute("enabled"));
- }
- if (uidl.hasAttribute("floating")) {
- legendOptions.setFloating(uidl.getBooleanAttribute("floating"));
- }
- if (uidl.hasAttribute("itemHiddenStyle")) {
- legendOptions.setItemHiddenStyle(uidl
- .getStringAttribute("itemHiddenStyle"));
- }
- if (uidl.hasAttribute("itemHoverStyle")) {
- legendOptions.setItemHoverStyle(uidl
- .getStringAttribute("itemHoverStyle"));
- }
- if (uidl.hasAttribute("itemStyle")) {
- legendOptions.setItemStyle(uidl.getStringAttribute("itemStyle"));
- }
- if (uidl.hasAttribute("itemWidth")) {
- legendOptions.setItemWidth(uidl.getIntAttribute("itemWidth"));
- }
- if (uidl.hasAttribute("layout")) {
- legendOptions.setLayout(uidl.getStringAttribute("layout"));
- }
- if (uidl.hasAttribute("labelFormatter")) {
- legendOptions.setLabelFormatter(getExecutableFunction(uidl
- .getStringAttribute("labelFormatter")));
- }
- if (uidl.hasAttribute("margin")) {
- legendOptions.setMargin(uidl.getIntAttribute("margin"));
- }
- if (uidl.hasAttribute("reversed")) {
- legendOptions.setReversed(uidl.getBooleanAttribute("reversed"));
- }
- if (uidl.hasAttribute("shadow")) {
- legendOptions.setShadow(uidl.getBooleanAttribute("shadow"));
- }
- if (uidl.hasAttribute("symbolPadding")) {
- legendOptions.setSymbolPadding(uidl
- .getIntAttribute("symbolPadding"));
- }
- if (uidl.hasAttribute("symbolWidth")) {
- legendOptions.setSymbolWidth(uidl.getIntAttribute("symbolWidth"));
- }
- if (uidl.hasAttribute("verticalAlign")) {
- legendOptions.setVerticalAlign(uidl
- .getStringAttribute("verticalAlign"));
- }
- if (uidl.hasAttribute("width")) {
- legendOptions.setWidth(uidl.getIntAttribute("width"));
- }
- if (uidl.hasAttribute("x")) {
- legendOptions.setX(uidl.getIntAttribute("x"));
- }
- if (uidl.hasAttribute("y")) {
- legendOptions.setY(uidl.getIntAttribute("y"));
- }
-
- VConsole.log("Exit [getLegendOptions]");
- return legendOptions;
- }
-
- private GwtTooltipOptions getTooltipOptions(UIDL uidl) {
- VConsole.log("Enter [getTooltipOptions]");
- VConsole.log("Tag name -> " + uidl.getTag());
- GwtTooltipOptions tooltipOptions = GwtTooltipOptions.create();
-
- if (uidl.hasAttribute("backgroundColor")) {
- tooltipOptions.setBackgroundColor(uidl
- .getStringAttribute("backgroundColor"));
- }
- if (uidl.hasAttribute("borderColor")) {
- tooltipOptions.setBorderColor(uidl
- .getStringAttribute("borderColor"));
- }
- if (uidl.hasAttribute("borderRadius")) {
- tooltipOptions
- .setBorderRadius(uidl.getIntAttribute("borderRadius"));
- }
- if (uidl.hasAttribute("borderWidth")) {
- tooltipOptions.setBorderWidth(uidl.getIntAttribute("borderWidth"));
- }
- if (uidl.hasAttribute("crosshairs")) {
- tooltipOptions
- .setCrosshairs(uidl.getBooleanAttribute("crosshairs"));
- }
- if (uidl.hasAttribute("enabled")) {
- tooltipOptions.setEnabled(uidl.getBooleanAttribute("enabled"));
- }
- if (uidl.hasAttribute("formatter")) {
- tooltipOptions.setFormatter(getExecutableFunction(uidl
- .getStringAttribute("formatter")));
- }
- if (uidl.hasAttribute("shadow")) {
- tooltipOptions.setShadow(uidl.getBooleanAttribute("shadow"));
- }
- if (uidl.hasAttribute("shared")) {
- tooltipOptions.setShared(uidl.getBooleanAttribute("shared"));
- }
- if (uidl.hasAttribute("snap")) {
- tooltipOptions.setSnap(uidl.getIntAttribute("snap"));
- }
- if (uidl.hasAttribute("style")) {
- tooltipOptions.setStyle(uidl.getStringAttribute("style"));
- }
-
- VConsole.log("Exit [getTooltipOptions]");
- return tooltipOptions;
- }
-
- private GwtTitleOptions getTitleOptions(UIDL uidl) {
- VConsole.log("Enter [getTitleOptions]");
- VConsole.log("Tag Name : " + uidl.getTag());
- GwtTitleOptions titleOptions = GwtTitleOptions.createTitleOptions();
- updateTitleBaseOptions(uidl, titleOptions);
-
- if (uidl.hasAttribute("margin")) {
- titleOptions.setMargin(uidl.getIntAttribute("margin"));
- }
-
- VConsole.log("Exit [getTitleOptions]");
- return titleOptions;
- }
-
- private GwtSubtitleOptions getSubtitleOptions(UIDL uidl) {
- VConsole.log("Enter [getSubtitleOptions]");
- VConsole.log("Tag Name : " + uidl.getTag());
- GwtSubtitleOptions subtitleOptions = GwtSubtitleOptions
- .createSubtitleOptions();
- updateTitleBaseOptions(uidl, subtitleOptions);
- VConsole.log("Exit [getTitleOptions]");
- return subtitleOptions;
- }
-
- private void updateTitleBaseOptions(UIDL uidl,
- GwtTitleBaseOptions titleBaseOptions) {
- VConsole.log("Enter [updateTitleBaseOptions]");
- VConsole.log("Tag Name : " + uidl.getTag());
- if (uidl.hasAttribute("text")) {
- titleBaseOptions.setText(uidl.getStringAttribute("text"));
- }
- if (uidl.hasAttribute("align")) {
- titleBaseOptions.setAlign(uidl.getStringAttribute("align"));
- }
- if (uidl.hasAttribute("floating")) {
- titleBaseOptions.setFloating(uidl.getBooleanAttribute("floating"));
- }
- if (uidl.hasAttribute("style")) {
- titleBaseOptions.setStyle(uidl.getStringAttribute("style"));
- }
- if (uidl.hasAttribute("verticalAlign")) {
- titleBaseOptions.setVerticalAlign(uidl
- .getStringAttribute("verticalAlign"));
- }
- if (uidl.hasAttribute("x")) {
- titleBaseOptions.setX(uidl.getIntAttribute("x"));
- }
- if (uidl.hasAttribute("y")) {
- titleBaseOptions.setY(uidl.getIntAttribute("y"));
- }
-
- VConsole.log("Exit [updateTitleBaseOptions]");
- }
-
- private GwtChartOptions getChartOptions(UIDL uidl) {
- VConsole.log("Enter [getChartOptions]");
- VConsole.log("Tag Name : " + uidl.getTag());
-
- GwtChartOptions chartOptions = GwtChartOptions.create();
- // DIV - A container for the InvientChart
- chartOptions.setRenderTo(super.divId);
-
- if (uidl.hasAttribute("type")) {
- chartOptions.setType(uidl.getStringAttribute("type"));
- }
- if (uidl.hasAttribute("width")) {
- chartOptions.setWidth(uidl.getIntAttribute("width"));
- }
- if (uidl.hasAttribute("height")) {
- chartOptions.setHeight(uidl.getIntAttribute("height"));
- }
- if (uidl.hasAttribute("backgroundColor")) {
- chartOptions.setBackgroundColor(uidl
- .getStringAttribute("backgroundColor"));
- }
- if (uidl.hasAttribute("borderColor")) {
- chartOptions.setBorderColor(uidl.getStringAttribute("borderColor"));
- }
- if (uidl.hasAttribute("borderRadius")) {
- chartOptions.setBorderRadius(uidl.getIntAttribute("borderRadius"));
- }
- if (uidl.hasAttribute("borderWidth")) {
- chartOptions.setBorderWidth(uidl.getIntAttribute("borderWidth"));
- }
- if (uidl.hasAttribute("ignoreHiddenSeries")) {
- chartOptions.setIgnoreHiddenSeries(uidl
- .getBooleanAttribute("ignoreHiddenSeries"));
- }
- if (uidl.hasAttribute("inverted")) {
- chartOptions.setInverted(uidl.getBooleanAttribute("inverted"));
- }
- if (uidl.hasAttribute("marginTop")) {
- chartOptions.setMarginTop(uidl.getIntAttribute("marginTop"));
- }
- if (uidl.hasAttribute("marginLeft")) {
- chartOptions.setMarginLeft(uidl.getIntAttribute("marginLeft"));
- }
- if (uidl.hasAttribute("marginRight")) {
- chartOptions.setMarginRight(uidl.getIntAttribute("marginRight"));
- }
- if (uidl.hasAttribute("marginBottom")) {
- chartOptions.setMarginBottom(uidl.getIntAttribute("marginBottom"));
- }
- if (uidl.hasAttribute("spacingTop")) {
- chartOptions.setSpacingTop(uidl.getIntAttribute("spacingTop"));
- }
- if (uidl.hasAttribute("spacingLeft")) {
- chartOptions.setSpacingLeft(uidl.getIntAttribute("spacingLeft"));
- }
- if (uidl.hasAttribute("spacingRight")) {
- chartOptions.setSpacingRight(uidl.getIntAttribute("spacingRight"));
- }
- if (uidl.hasAttribute("spacingBottom")) {
- chartOptions
- .setSpacingBottom(uidl.getIntAttribute("spacingBottom"));
- }
- if (uidl.hasAttribute("showAxes")) {
- chartOptions.setShowAxes(uidl.getBooleanAttribute("showAxes"));
- }
- if (uidl.hasAttribute("zoomType")) {
- chartOptions.setZoomType(uidl.getStringAttribute("zoomType"));
- }
- if (uidl.hasAttribute("clientZoom")) {
- chartOptions.setClientZoom(uidl.getBooleanAttribute("clientZoom"));
- }
-
- if (uidl.hasAttribute("alignTicks")) {
- chartOptions.setAlignTicks(uidl.getBooleanAttribute("alignTicks"));
- }
- if (uidl.hasAttribute("animation")) {
- chartOptions.setAnimation(uidl.getBooleanAttribute("animation"));
- }
- if (uidl.hasAttribute("className")) {
- chartOptions.setClassName(uidl.getStringAttribute("className"));
- }
- if (uidl.hasAttribute("plotBackgroundColor")) {
- chartOptions.setPlotBackgroundColor(uidl
- .getStringAttribute("plotBackgroundColor"));
- }
- if (uidl.hasAttribute("plotBorderColor")) {
- chartOptions.setPlotBorderColor(uidl
- .getStringAttribute("plotBorderColor"));
- }
- if (uidl.hasAttribute("plotBackgroundImage")) {
- chartOptions.setPlotBackgroundImage(uidl
- .getStringAttribute("plotBackgroundImage"));
- }
- if (uidl.hasAttribute("plotBorderWidth")) {
- chartOptions.setPlotBorderWidth(uidl
- .getIntAttribute("plotBorderWidth"));
- }
- if (uidl.hasAttribute("plotShadow")) {
- chartOptions.setPlotShadow(uidl.getBooleanAttribute("plotShadow"));
- }
- if (uidl.hasAttribute("reflow")) {
- chartOptions.setReflow(uidl.getBooleanAttribute("reflow"));
- }
- if (uidl.hasAttribute("shadow")) {
- chartOptions.setShadow(uidl.getBooleanAttribute("shadow"));
- }
- if (uidl.hasAttribute("style")) {
- chartOptions.setStyle(uidl.getStringAttribute("style"));
- }
-
- VConsole.log("Exit [getChartOptions]");
- return chartOptions;
- }
-
- private void updateBaseAxisOptions(UIDL axisUIDL,
- GwtAxisBaseOptions axisBaseOptions) {
- VConsole.log("Enter [updateBaseAxisOptions]");
- if (axisUIDL.hasAttribute("id")) {
- axisBaseOptions.setId(axisUIDL.getStringAttribute("id"));
- }
- if (axisUIDL.hasAttribute("allowDecimals")) {
- axisBaseOptions.setAllowDecimals(axisUIDL
- .getBooleanAttribute("allowDecimals"));
- }
- if (axisUIDL.hasAttribute("alternateGridColor")) {
- axisBaseOptions.setAlternateGridColor(axisUIDL
- .getStringAttribute("alternateGridColor"));
- }
- if (axisUIDL.hasAttribute("endOnTick")) {
- axisBaseOptions.setEndOnTick(axisUIDL
- .getBooleanAttribute("endOnTick"));
- }
- // Grid
- if (axisUIDL.hasAttribute("gridLineColor")) {
- axisBaseOptions.setGridLineColor(axisUIDL
- .getStringAttribute("gridLineColor"));
- }
- if (axisUIDL.hasAttribute("gridLineWidth")) {
- axisBaseOptions.setGridLineWidth(axisUIDL
- .getIntAttribute("gridLineWidth"));
- }
- if (axisUIDL.hasAttribute("gridLineDashStyle")) {
- axisBaseOptions.setGridLineDashStyle(axisUIDL
- .getStringAttribute("gridLineDashStyle"));
- }
- // Line
- if (axisUIDL.hasAttribute("lineColor")) {
- axisBaseOptions.setLineColor(axisUIDL
- .getStringAttribute("lineColor"));
- }
- if (axisUIDL.hasAttribute("lineWidth")) {
- axisBaseOptions.setLineWidth(axisUIDL.getIntAttribute("lineWidth"));
- }
- //
- if (axisUIDL.hasAttribute("linkedTo")) {
- axisBaseOptions.setLinkedTo(axisUIDL.getIntAttribute("linkedTo"));
- }
-
- if (axisUIDL.hasAttribute("max")) {
- axisBaseOptions.setMax(axisUIDL.getDoubleAttribute("max"));
- }
- if (axisUIDL.hasAttribute("maxPadding")) {
- axisBaseOptions.setMaxPadding(axisUIDL
- .getDoubleAttribute("maxPadding"));
- }
- if (axisUIDL.hasAttribute("maxZoom")) {
- axisBaseOptions.setMaxZoom(axisUIDL.getIntAttribute("maxZoom"));
- }
-
- //
- if (axisUIDL.hasAttribute("min")) {
- axisBaseOptions.setMin(axisUIDL.getDoubleAttribute("min"));
- }
- if (axisUIDL.hasAttribute("minPadding")) {
- axisBaseOptions.setMinPadding(axisUIDL
- .getDoubleAttribute("minPadding"));
- }
- // Minor Grid
- if (axisUIDL.hasAttribute("minorGridLineColor")) {
- axisBaseOptions.setMinorGridLineColor(axisUIDL
- .getStringAttribute("minorGridLineColor"));
- }
- if (axisUIDL.hasAttribute("minorGridLineWidth")) {
- axisBaseOptions.setMinorGridLineWidth(axisUIDL
- .getIntAttribute("minorGridLineWidth"));
- }
- if (axisUIDL.hasAttribute("minorGridLineDashStyle")) {
- axisBaseOptions.setMinorGridLineDashStyle(axisUIDL
- .getStringAttribute("minorGridLineDashStyle"));
- }
- // Minor Ticks
- if (axisUIDL.hasAttribute("minorTickColor")) {
- axisBaseOptions.setMinorTickColor(axisUIDL
- .getStringAttribute("minorTickColor"));
- }
- if (axisUIDL.hasAttribute("minorTickInterval")) {
- axisBaseOptions.setMinorTickInterval(axisUIDL
- .getDoubleAttribute("minorTickInterval"));
- }
- if (axisUIDL.hasAttribute("minorTickLength")) {
- axisBaseOptions.setMinorTickLength(axisUIDL
- .getIntAttribute("minorTickLength"));
- }
- if (axisUIDL.hasAttribute("minorTickPosition")) {
- axisBaseOptions.setMinorTickPosition(axisUIDL
- .getStringAttribute("minorTickPosition"));
- }
- if (axisUIDL.hasAttribute("minorTickWidth")) {
- axisBaseOptions.setMinorTickWidth(axisUIDL
- .getIntAttribute("minorTickWidth"));
- }
- //
- if (axisUIDL.hasAttribute("offset")) {
- axisBaseOptions.setOffset(axisUIDL.getIntAttribute("offset"));
- }
- if (axisUIDL.hasAttribute("opposite")) {
- axisBaseOptions.setOpposite(axisUIDL
- .getBooleanAttribute("opposite"));
- }
- if (axisUIDL.hasAttribute("reversed")) {
- axisBaseOptions.setReversed(axisUIDL
- .getBooleanAttribute("reversed"));
- }
- if (axisUIDL.hasAttribute("showFirstLabel")) {
- axisBaseOptions.setShowFirstLabel(axisUIDL
- .getBooleanAttribute("showFirstLabel"));
- }
- if (axisUIDL.hasAttribute("showLastLabel")) {
- axisBaseOptions.setShowLastLabel(axisUIDL
- .getBooleanAttribute("showLastLabel"));
- }
- if (axisUIDL.hasAttribute("startOfWeek")) {
- axisBaseOptions.setStartOfWeek(axisUIDL
- .getIntAttribute("startOfWeek"));
- }
- if (axisUIDL.hasAttribute("startOnTick")) {
- axisBaseOptions.setStartOnTick(axisUIDL
- .getBooleanAttribute("startOnTick"));
- }
- // Tick
- if (axisUIDL.hasAttribute("tickColor")) {
- axisBaseOptions.setTickColor(axisUIDL
- .getStringAttribute("tickColor"));
- }
- if (axisUIDL.hasAttribute("tickInterval")) {
- axisBaseOptions.setTickInterval(axisUIDL
- .getDoubleAttribute("tickInterval"));
- }
- if (axisUIDL.hasAttribute("tickLength")) {
- axisBaseOptions.setTickLength(axisUIDL
- .getIntAttribute("tickLength"));
- }
- if (axisUIDL.hasAttribute("tickPosition")) {
- axisBaseOptions.setTickPosition(axisUIDL
- .getStringAttribute("tickPosition"));
- }
- if (axisUIDL.hasAttribute("tickWidth")) {
- axisBaseOptions.setTickWidth(axisUIDL.getIntAttribute("tickWidth"));
- }
- if (axisUIDL.hasAttribute("tickPixelInterval")) {
- axisBaseOptions.setTickPixelInterval(axisUIDL
- .getIntAttribute("tickPixelInterval"));
- }
- if (axisUIDL.hasAttribute("tickmarkPlacement")) {
- axisBaseOptions.setTickmarkPlacement(axisUIDL
- .getStringAttribute("tickmarkPlacement"));
- }
-
- if (axisUIDL.hasAttribute("type")) {
- axisBaseOptions.setType(axisUIDL.getStringAttribute("type"));
- }
-
- // title
- UIDL titleUIDL = axisUIDL.getChildUIDL(0);
- GwtAxisTitleOptions titleOptions = getAxisTitleOptions(titleUIDL);
- if (titleOptions != null) {
- axisBaseOptions.setTitle(titleOptions);
- }
-
- // label
- UIDL labelUIDL = axisUIDL.getChildUIDL(1);
- String axisName = axisUIDL.getTag();
- GwtAxisDataLabels axisDataLabels = getAxisDataLabels(labelUIDL,
- axisName);
- if (axisDataLabels != null) {
- axisBaseOptions.setLabels(axisDataLabels);
- }
- // plotband
- UIDL plotBandsUIDL = axisUIDL.getChildUIDL(2);
- JsArray plotBands = getPlotBands(plotBandsUIDL);
- if (plotBands.length() > 0) {
- axisBaseOptions.setPlotBands(plotBands);
- }
- // plotline
- UIDL plotLinesUIDL = axisUIDL.getChildUIDL(3);
- JsArray plotLines = getPlotLines(plotLinesUIDL);
- if (plotLines.length() > 0) {
- axisBaseOptions.setPlotLines(plotLines);
- }
- VConsole.log("Exit [updateBaseAxisOptions]");
- }
-
- private GwtAxisTitleOptions getAxisTitleOptions(UIDL axisTitleUIDL) {
- if (axisTitleUIDL == null
- || axisTitleUIDL.getAttributeNames().size() == 0) {
- return null;
- }
- GwtAxisTitleOptions titleOptions = GwtAxisTitleOptions.create();
- if (axisTitleUIDL.hasAttribute("align")) {
- titleOptions.setAlign(axisTitleUIDL.getStringAttribute("align"));
- }
- if (axisTitleUIDL.hasAttribute("margin")) {
- titleOptions.setMargin(axisTitleUIDL.getIntAttribute("margin"));
- }
- if (axisTitleUIDL.hasAttribute("rotation")) {
- titleOptions.setRotation(axisTitleUIDL.getIntAttribute("rotation"));
- }
- if (axisTitleUIDL.hasAttribute("style")) {
- titleOptions.setStyle(axisTitleUIDL.getStringAttribute("style"));
- }
- if (axisTitleUIDL.hasAttribute("text")) {
- titleOptions.setText(axisTitleUIDL.getStringAttribute("text"));
- }
- return titleOptions;
- }
-
- private JsArray getPlotBands(UIDL plotBandsUIDL) {
- JsArray plotBandsArr = JavaScriptObject.createArray()
- .cast();
- for (int cnt = 0; cnt < plotBandsUIDL.getChildCount(); cnt++) {
- UIDL plotBandUIDL = plotBandsUIDL.getChildUIDL(cnt);
- if (plotBandUIDL.getAttributeNames().size() == 0
- && plotBandUIDL.getChildCount() == 0) {
- continue;
- }
- GwtPlotBands plotBands = GwtPlotBands.create();
- if (plotBandUIDL.hasAttribute("color")) {
- plotBands.setColor(plotBandUIDL.getStringAttribute("color"));
- }
- if (plotBandUIDL.hasAttribute("id")) {
- plotBands.setId(plotBandUIDL.getStringAttribute("id"));
- }
- if (plotBandUIDL.hasAttribute("zIndex")) {
- plotBands.setZIndex(plotBandUIDL.getIntAttribute("zIndex"));
- }
- // label
- GwtPlotLabel label = getPlotLabel(plotBandUIDL.getChildUIDL(0));
- if (label != null) {
- plotBands.setLabel(label);
- }
- // from/to value
- UIDL valueUIDL = plotBandUIDL.getChildUIDL(1);
- if (valueUIDL.hasAttribute("valueType")) {
- String valueType = valueUIDL.getStringAttribute("valueType");
- if (valueType.equals("number")) {
- plotBands.setFrom(valueUIDL.getDoubleAttribute("from"));
- plotBands.setTo(valueUIDL.getDoubleAttribute("to"));
- } else { // date
- // from
- UIDL fromUIDL = valueUIDL.getChildUIDL(0);
- int fromYear = fromUIDL.getIntAttribute("year");
- int fromMonth = fromUIDL.getIntAttribute("month");
- int fromDay = fromUIDL.getIntAttribute("day");
- plotBands.setFrom("Date.UTC(" + fromYear + ", " + fromMonth
- + "," + fromDay + ")");
- // to
- UIDL toUIDL = valueUIDL.getChildUIDL(1);
- int toYear = toUIDL.getIntAttribute("year");
- int toMonth = toUIDL.getIntAttribute("month");
- int toDay = toUIDL.getIntAttribute("day");
- plotBands.setTo("Date.UTC(" + toYear + ", " + toMonth + ","
- + toDay + ")");
- }
- }
- //
- plotBandsArr.push(plotBands);
- }
- return plotBandsArr;
- }
-
- private JsArray getPlotLines(UIDL plotLinesUIDL) {
- JsArray plotLinesArr = JavaScriptObject.createArray()
- .cast();
- for (int cnt = 0; cnt < plotLinesUIDL.getChildCount(); cnt++) {
- UIDL plotLineUIDL = plotLinesUIDL.getChildUIDL(cnt);
- if (plotLineUIDL.getAttributeNames().size() == 0
- && plotLineUIDL.getChildCount() == 0) {
- continue;
- }
- GwtPlotLines plotLines = GwtPlotLines.create();
- if (plotLineUIDL.hasAttribute("color")) {
- plotLines.setColor(plotLineUIDL.getStringAttribute("color"));
- }
- if (plotLineUIDL.hasAttribute("dashStyle")) {
- plotLines.setDashStyle(plotLineUIDL
- .getStringAttribute("dashStyle"));
- }
- if (plotLineUIDL.hasAttribute("id")) {
- plotLines.setId(plotLineUIDL.getStringAttribute("id"));
- }
- if (plotLineUIDL.hasAttribute("width")) {
- plotLines.setWidth(plotLineUIDL.getIntAttribute("width"));
- }
- if (plotLineUIDL.hasAttribute("zIndex")) {
- plotLines.setZIndex(plotLineUIDL.getIntAttribute("zIndex"));
- }
- // label
- GwtPlotLabel label = getPlotLabel(plotLineUIDL.getChildUIDL(0));
- if (label != null) {
- plotLines.setLabel(label);
- }
- // line value
- UIDL lineValueUIDL = plotLineUIDL.getChildUIDL(1);
- if (lineValueUIDL.hasAttribute("valueType")) {
- String valueType = lineValueUIDL
- .getStringAttribute("valueType");
- if (valueType.equals("number")) {
- if (lineValueUIDL.hasAttribute("value")) {
- plotLines.setValue(lineValueUIDL
- .getDoubleAttribute("value"));
- }
- } else { // date
- int year = lineValueUIDL.getIntAttribute("year");
- int month = lineValueUIDL.getIntAttribute("month");
- int day = lineValueUIDL.getIntAttribute("day");
- plotLines.setValue("Date.UTC(" + year + ", " + month + ","
- + day + ")");
- }
- }
- //
- plotLinesArr.push(plotLines);
- }
- return plotLinesArr;
- }
-
- private GwtPlotLabel getPlotLabel(UIDL plotLabelUIDL) {
- if (plotLabelUIDL == null
- || plotLabelUIDL.getAttributeNames().size() == 0) {
- return null;
- }
- GwtPlotLabel label = GwtPlotLabel.create();
- if (plotLabelUIDL.hasAttribute("align")) {
- label.setAlign(plotLabelUIDL.getStringAttribute("align"));
- }
- if (plotLabelUIDL.hasAttribute("rotation")) {
- label.setRotation(plotLabelUIDL.getIntAttribute("rotation"));
- }
- if (plotLabelUIDL.hasAttribute("style")) {
- label.setStyle(plotLabelUIDL.getStringAttribute("style"));
- }
- if (plotLabelUIDL.hasAttribute("align")) {
- label.setAlign(plotLabelUIDL.getStringAttribute("align"));
- }
- if (plotLabelUIDL.hasAttribute("text")) {
- label.setText(plotLabelUIDL.getStringAttribute("text"));
- }
- if (plotLabelUIDL.hasAttribute("verticalAlign")) {
- label.setVerticalAlign(plotLabelUIDL
- .getStringAttribute("verticalAlign"));
- }
- if (plotLabelUIDL.hasAttribute("x")) {
- label.setX(plotLabelUIDL.getIntAttribute("x"));
- }
- if (plotLabelUIDL.hasAttribute("y")) {
- label.setY(plotLabelUIDL.getIntAttribute("y"));
- }
-
- return label;
- }
-
- // FIXME - Code organization
- private GwtAxisDataLabels getAxisDataLabels(UIDL labelUIDL, String axisName) {
- if (labelUIDL == null || labelUIDL.getAttributeNames().size() == 0) {
- return null;
- }
- if (axisName.equals("xAxis")) {
- GwtXAxisDataLabels labels = GwtXAxisDataLabels.createXAxisLabels();
- updateDataLabel(labelUIDL, labels);
- if (labelUIDL.hasAttribute("staggerLines")) {
- labels.setStaggerLines(labelUIDL
- .getIntAttribute("staggerLines"));
- }
- if (labelUIDL.hasAttribute("step")) {
- labels.setStep(labelUIDL.getIntAttribute("step"));
- }
- return labels;
- } else {
- GwtYAxisDataLabels labels = GwtYAxisDataLabels.createYAxisLabels();
- updateDataLabel(labelUIDL, labels);
- return labels;
- }
- }
-
- private JsArray getXAxisOptions(UIDL uidl) {
- VConsole.log("Enter [getXAxisOptions]");
- VConsole.log("Tag Name : " + uidl.getTag());
- JsArray xAxes = JavaScriptObject.createArray().cast();
-
- for (int cnt = 0; cnt < uidl.getChildCount(); cnt++) {
- GwtXAxisOptions xAxisOptions = GwtXAxisOptions.create();
- UIDL axisUIDL = uidl.getChildUIDL(cnt);
- if (axisUIDL.getAttributeNames().size() == 0
- && axisUIDL.getChildCount() == 0) {
- continue;
- }
- updateBaseAxisOptions(axisUIDL, xAxisOptions);
-
- UIDL childUIDL = axisUIDL.getChildUIDL(4);
- if (childUIDL != null) {
- if (childUIDL.getTag().equals("categories")
- && childUIDL.getChildCount() > 0) {
- JsArrayString categories = JavaScriptObject.createArray()
- .cast();
- UIDL categoriesUIDL = childUIDL;
- for (int idx = 0; idx < categoriesUIDL.getChildCount(); idx++) {
- categories.push(categoriesUIDL.getChildUIDL(idx)
- .getStringAttribute("name"));
- }
- xAxisOptions.setCategories(categories);
- } else if (childUIDL.getTag().equals("dateTimeLabelFormats")
- && childUIDL.getAttributeNames().size() > 0) {
- UIDL dateTimeLblFmtsUIDL = childUIDL;
- GwtDateTimeLabelFormats formats = GwtDateTimeLabelFormats
- .create();
- if (dateTimeLblFmtsUIDL.hasAttribute("second")) {
- formats.setSecond(dateTimeLblFmtsUIDL
- .getStringAttribute("second"));
- }
- if (dateTimeLblFmtsUIDL.hasAttribute("minute")) {
- formats.setMinute(dateTimeLblFmtsUIDL
- .getStringAttribute("minute"));
- }
- if (dateTimeLblFmtsUIDL.hasAttribute("hour")) {
- formats.setHour(dateTimeLblFmtsUIDL
- .getStringAttribute("hour"));
- }
- if (dateTimeLblFmtsUIDL.hasAttribute("day")) {
- formats.setDay(dateTimeLblFmtsUIDL
- .getStringAttribute("day"));
- }
- if (dateTimeLblFmtsUIDL.hasAttribute("week")) {
- formats.setWeek(dateTimeLblFmtsUIDL
- .getStringAttribute("week"));
- }
- if (dateTimeLblFmtsUIDL.hasAttribute("month")) {
- formats.setMonth(dateTimeLblFmtsUIDL
- .getStringAttribute("month"));
- }
- if (dateTimeLblFmtsUIDL.hasAttribute("year")) {
- formats.setYear(dateTimeLblFmtsUIDL
- .getStringAttribute("year"));
- }
- xAxisOptions.setDateTimeLabelFormats(formats);
- }
- }
- xAxes.push(xAxisOptions);
- }
-
- VConsole.log("Exit [getXAxisOptions]");
- return xAxes;
- }
-
- private JsArray getYAxisOptions(UIDL uidl) {
- VConsole.log("Enter [getYAxisOptions]");
- VConsole.log("Tag Name : " + uidl.getTag());
- JsArray yAxes = JavaScriptObject.createArray().cast();
-
- for (int cnt = 0; cnt < uidl.getChildCount(); cnt++) {
- GwtYAxisOptions yAxisOptions = GwtYAxisOptions.create();
- UIDL axisUIDL = uidl.getChildUIDL(cnt);
- if (axisUIDL.getAttributeNames().size() == 0
- && axisUIDL.getChildCount() == 0) {
- continue;
- }
- updateBaseAxisOptions(axisUIDL, yAxisOptions);
- yAxes.push(yAxisOptions);
- }
-
- VConsole.log("Exit [getYAxisOptions]");
- return yAxes;
- }
-
- private GwtPlotOptions getPlotOptions(UIDL uidl) {
- VConsole.log("Enter [getPlotOptions]");
- VConsole.log("Tag Name : " + uidl.getTag());
-
- GwtPlotOptions plotOptions = GwtPlotOptions.create();
-
- for (int cnt = 0; cnt < uidl.getChildCount(); cnt++) {
- UIDL seriesUIDL = uidl.getChildUIDL(cnt);
- String seriesType = seriesUIDL.getTag();
- VConsole.log("Series Type : " + seriesType);
- GwtSeriesGeneralOptions seriesOptions = getSeriesOptions(
- seriesType, seriesUIDL);
- if (seriesOptions == null) {
- continue;
- }
- if (seriesType.equals("series")) {
- plotOptions.setSeries(seriesOptions);
- } else if (seriesType.equals("line")) {
- plotOptions.setLine((GwtLineOptions) seriesOptions);
- } else if (seriesType.equals("scatter")) {
- plotOptions.setScatter((GwtScatterOptions) seriesOptions);
- } else if (seriesType.equals("spline")) {
- plotOptions.setSpline((GwtSplineOptions) seriesOptions);
- } else if (seriesType.equals("area")) {
- plotOptions.setArea((GwtAreaOptions) seriesOptions);
- } else if (seriesType.equals("areaspline")) {
- plotOptions.setAreaSpline((GwtAreaSplineOptions) seriesOptions);
- } else if (seriesType.equals("bar")) {
- plotOptions.setBar((GwtBarOptions) seriesOptions);
- } else if (seriesType.equals("column")) {
- plotOptions.setColumn((GwtColumnOptions) seriesOptions);
- } else if (seriesType.equals("pie")) {
- plotOptions.setPie((GwtPieOptions) seriesOptions);
- }
- }
-
- VConsole.log("Exit [getPlotOptions]");
- return plotOptions;
- }
-
- private GwtSeriesGeneralOptions getSeriesOptions(String seriesType,
- UIDL seriesUIDL) {
- VConsole.log("Enter [getSeriesOptions]");
- VConsole.log("Tag Name : " + seriesUIDL.getTag());
- if (seriesUIDL.getAttributeNames().size() == 0
- && seriesUIDL.getChildCount() == 0) {
- VConsole.log("No attributes/children found for series type : "
- + seriesType);
- VConsole.log("Exit [getSeriesOptions]");
- return null;
- }
- GwtSeriesGeneralOptions seriesOptions = null;
- if (seriesType.equals("series")) {
- seriesOptions = GwtSeriesGeneralOptions.createSeriesOptions();
- updateSeriesOptions(seriesUIDL, seriesOptions);
- } else if (seriesType.equals("line")) {
- seriesOptions = GwtLineOptions.createLineOptions();
- updateLineOptions(seriesUIDL, (GwtLineOptions) seriesOptions);
- } else if (seriesType.equals("scatter")) {
- seriesOptions = GwtScatterOptions.createScatterOptions();
- updateScatterOptions(seriesUIDL, (GwtScatterOptions) seriesOptions);
- } else if (seriesType.equals("spline")) {
- seriesOptions = GwtSplineOptions.createSplineOptions();
- updateSplineOptions(seriesUIDL, (GwtSplineOptions) seriesOptions);
- } else if (seriesType.equals("area")) {
- seriesOptions = GwtAreaOptions.createAreaOptions();
- updateAreaOptions(seriesUIDL, (GwtAreaOptions) seriesOptions);
- } else if (seriesType.equals("areaspline")) {
- seriesOptions = GwtAreaSplineOptions.createAreaSplineOptions();
- updateAreaSplineOptions(seriesUIDL,
- (GwtAreaSplineOptions) seriesOptions);
- } else if (seriesType.equals("bar")) {
- seriesOptions = GwtBarOptions.createBarOptions();
- updateBarOptions(seriesUIDL, (GwtBarOptions) seriesOptions);
- } else if (seriesType.equals("column")) {
- seriesOptions = GwtColumnOptions.createColumnOptions();
- updateColumnOptions(seriesUIDL, (GwtColumnOptions) seriesOptions);
- } else if (seriesType.equals("pie")) {
- seriesOptions = GwtPieOptions.createPieOptions();
- updatePieOptions(seriesUIDL, (GwtPieOptions) seriesOptions);
- } else {
- // This should not happen
- VConsole.log("[getSeriesOptions] : Invalid series type "
- + seriesType);
- }
- VConsole.log("Exit [getSeriesOptions]");
- return seriesOptions;
- }
-
- private void updateSeriesOptions(UIDL seriesUIDL,
- GwtSeriesGeneralOptions seriesOptions) {
- VConsole.log("Enter [updateSeriesOptions]");
- VConsole.log("Tag Name : " + seriesUIDL.getTag());
-
- if (seriesUIDL.hasAttribute("allowPointSelect")) {
- seriesOptions.setAllowPointSelect(seriesUIDL
- .getBooleanAttribute("allowPointSelect"));
- }
- if (seriesUIDL.hasAttribute("animation")) {
- seriesOptions.setAnimation(seriesUIDL
- .getBooleanAttribute("animation"));
- }
- if (seriesUIDL.hasAttribute("cursor")) {
- seriesOptions.setCursor(seriesUIDL.getStringAttribute("cursor"));
- }
- if (seriesUIDL.hasAttribute("enableMouseTracking")) {
- seriesOptions.setEnableMouseTracking(seriesUIDL
- .getBooleanAttribute("enableMouseTracking"));
- }
- if (seriesUIDL.hasAttribute("selected")) {
- seriesOptions.setSelected(seriesUIDL
- .getBooleanAttribute("selected"));
- }
- if (seriesUIDL.hasAttribute("shadow")) {
- seriesOptions.setShadow(seriesUIDL.getBooleanAttribute("shadow"));
- }
- if (seriesUIDL.hasAttribute("showCheckbox")) {
- seriesOptions.setShowCheckbox(seriesUIDL
- .getBooleanAttribute("showCheckbox"));
- }
- if (seriesUIDL.hasAttribute("showInLegend")) {
- seriesOptions.setShowInLegend(seriesUIDL
- .getBooleanAttribute("showInLegend"));
- }
- if (seriesUIDL.hasAttribute("stacking")) {
- seriesOptions
- .setStacking(seriesUIDL.getStringAttribute("stacking"));
- }
- if (seriesUIDL.hasAttribute("visible")) {
- seriesOptions.setVisible(seriesUIDL.getBooleanAttribute("visible"));
- }
- if (seriesUIDL.hasAttribute("color")) {
- seriesOptions.setColor(seriesUIDL.getStringAttribute("color"));
- }
- // FIXME - How to get series type
- // datalabels
- GwtDataLabels dataLabels = getSeriesDataLabel(
- seriesUIDL.getChildUIDL(0), seriesUIDL.getTag());
- if (dataLabels != null) {
- seriesOptions.setDataLabels(dataLabels);
- }
-
- // state
- GwtStates seriesState = getSeriesState(seriesUIDL.getChildUIDL(1));
-
- if (seriesState != null) {
- seriesOptions.setStates(seriesState);
- }
-
- VConsole.log("Exit [updateSeriesOptions]");
- }
-
- private GwtDataLabels getSeriesDataLabel(UIDL dataLabelUIDL,
- String seriesType) {
- VConsole.log("Enter [getSeriesDataLabel]");
- if (dataLabelUIDL == null
- || dataLabelUIDL.getAttributeNames().size() == 0) {
- return null;
- }
- GwtDataLabels dataLabel = GwtDataLabels.createDataLabels();
- if (seriesType.equals("pie")) {
- dataLabel = GwtPieDataLabels.createPieDataLabels();
- updatePieDataLabel(dataLabelUIDL, (GwtPieDataLabels) dataLabel);
- } else {
- updateDataLabel(dataLabelUIDL, dataLabel);
- }
- VConsole.log("Exit [getSeriesDataLabel]");
- return dataLabel;
- }
-
- private void updatePieDataLabel(UIDL dataLabelUIDL,
- GwtPieDataLabels pieDataLabel) {
- updateDataLabel(dataLabelUIDL, pieDataLabel);
- if (dataLabelUIDL.hasAttribute("connectorColor")) {
- pieDataLabel.setConnectorColor(dataLabelUIDL
- .getStringAttribute("connectorColor"));
- }
- if (dataLabelUIDL.hasAttribute("connectorWidth")) {
- pieDataLabel.setConnectorWidth(dataLabelUIDL
- .getIntAttribute("connectorWidth"));
- }
- if (dataLabelUIDL.hasAttribute("connectorPadding")) {
- pieDataLabel.setConnectorPadding(dataLabelUIDL
- .getIntAttribute("connectorPadding"));
- }
- if (dataLabelUIDL.hasAttribute("distance")) {
- pieDataLabel.setDistance(dataLabelUIDL.getIntAttribute("distance"));
- }
- }
-
- private void updateDataLabel(UIDL dataLabelUIDL, GwtDataLabels dataLabel) {
- if (dataLabelUIDL.hasAttribute("align")) {
- dataLabel.setAlign(dataLabelUIDL.getStringAttribute("align"));
- }
- if (dataLabelUIDL.hasAttribute("enabled")) {
- dataLabel.setEnabled(dataLabelUIDL.getBooleanAttribute("enabled"));
- }
- if (dataLabelUIDL.hasAttribute("formatter")) {
- dataLabel.setFormatter(getExecutableFunction(dataLabelUIDL
- .getStringAttribute("formatter")));
- }
- if (dataLabelUIDL.hasAttribute("rotation")) {
- dataLabel.setRotation(dataLabelUIDL.getIntAttribute("rotation"));
- }
- if (dataLabelUIDL.hasAttribute("style")) {
- dataLabel.setStyle(dataLabelUIDL.getStringAttribute("style"));
- }
- if (dataLabelUIDL.hasAttribute("x")) {
- dataLabel.setX(dataLabelUIDL.getIntAttribute("x"));
- }
- if (dataLabelUIDL.hasAttribute("y")) {
- dataLabel.setY(dataLabelUIDL.getIntAttribute("y"));
- }
- if (dataLabelUIDL.hasAttribute("color")) {
- dataLabel.setColor(dataLabelUIDL.getStringAttribute("color"));
- }
- }
-
- private GwtStates getSeriesState(UIDL stateUIDL) {
- if (stateUIDL == null
- || (stateUIDL != null && stateUIDL.getChildCount() == 0)
- || (stateUIDL.getChildCount() > 0 && stateUIDL.getChildUIDL(0)
- .getAttributeNames().size() == 0)) {
- return null;
- }
- GwtStates state = GwtStates.create();
- GwtHover hover = GwtHover.create();
- state.setHover(hover);
- UIDL hoverUIDL = stateUIDL.getChildUIDL(0);
- if (hoverUIDL.hasAttribute("enabled")) {
- hover.setEnabled(hoverUIDL.getBooleanAttribute("enabled"));
- }
- if (hoverUIDL.hasAttribute("lineWidth")) {
- hover.setLineWidth(hoverUIDL.getIntAttribute("lineWidth"));
- }
- if (hoverUIDL.hasAttribute("brightness")) {
- hover.setBrightness(hoverUIDL.getDoubleAttribute("brightness"));
- }
- return state;
- }
-
- private GwtMarker getMarkerOptions(UIDL uidl) {
- VConsole.log("Enter [getMarkerOptions]");
- int noOfAttrs = 0;
- noOfAttrs = (uidl != null ? uidl.getAttributeNames().size() : 0);
- if (uidl == null || (noOfAttrs == 0 && uidl.getChildCount() == 0)) {
- VConsole.log("Exit [getMarkerOptions]");
- return null;
- }
- GwtMarker marker = GwtMarker.create();
- String markerType = uidl.getStringAttribute("markerType");
- if (uidl.hasAttribute("enabled")) {
- marker.setEnabled(uidl.getBooleanAttribute("enabled"));
- }
- if (uidl.hasAttribute("lineColor")) {
- marker.setLineColor(uidl.getStringAttribute("lineColor"));
- }
- if (uidl.hasAttribute("fillColor")) {
- marker.setFillColor(uidl.getStringAttribute("fillColor"));
- }
- if (uidl.hasAttribute("lineWidth")) {
- marker.setLineWidth(uidl.getIntAttribute("lineWidth"));
- }
- if (uidl.hasAttribute("radius")) {
- marker.setRadius(uidl.getIntAttribute("radius"));
- }
- if (uidl.hasAttribute("symbol")) {
- if (markerType.equals("image")) {
- marker.setSymbol("url(." + uidl.getStringAttribute("symbol")
- + ")");
- } else {
- marker.setSymbol(uidl.getStringAttribute("symbol"));
- }
- }
-
- // Marker states exist only in case of SymbolMarker and not ImageMarker
- if (uidl.getChildCount() > 0) {
- UIDL statesUIDL = uidl.getChildUIDL(0);
- UIDL hoverStateUIDL = statesUIDL.getChildUIDL(0);
- UIDL selectStateUIDL = statesUIDL.getChildUIDL(1);
- GwtMarkerState markerHoverState = getMarkerState(hoverStateUIDL);
- GwtMarkerState markerSelectState = getMarkerState(selectStateUIDL);
- if (markerHoverState != null || markerSelectState != null) {
- VConsole.log("Setting marker states...");
- GwtMarkerStates markerStates = GwtMarkerStates.create();
- if (markerHoverState != null) {
- markerStates.setHover(markerHoverState);
- }
- if (markerSelectState != null) {
- markerStates.setSelect(markerSelectState);
- }
- marker.setStates(markerStates);
- }
- }
- VConsole.log("Exit [getMarkerOptions]");
- return marker;
- }
-
- private GwtMarkerState getMarkerState(UIDL uidl) {
- VConsole.log("Enter [getMarkerState]");
- if (uidl == null || uidl.getAttributeNames().size() == 0) {
- VConsole.log("Neither hover nor select states found for a maker.");
- VConsole.log("Exit [getMarkerState]");
- return null;
- }
- GwtMarkerState markerState = GwtMarkerState.create();
- if (uidl.hasAttribute("enabled")) {
- markerState.setEnabled(uidl.getBooleanAttribute("enabled"));
- }
- if (uidl.hasAttribute("lineColor")) {
- markerState.setLineColor(uidl.getStringAttribute("lineColor"));
- }
- if (uidl.hasAttribute("fillColor")) {
- markerState.setFillColor(uidl.getStringAttribute("fillColor"));
- }
- if (uidl.hasAttribute("lineWidth")) {
- markerState.setLineWidth(uidl.getIntAttribute("lineWidth"));
- }
- if (uidl.hasAttribute("radius")) {
- markerState.setRadius(uidl.getIntAttribute("radius"));
- }
- VConsole.log("Exit [getMarkerState]");
- return markerState;
- }
-
- private void updateBaseLineOptions(UIDL lineUIDL,
- GwtBaseLineOptions lineOptions) {
- VConsole.log("Enter [updateBaseLineOptions]");
-
- updateSeriesOptions(lineUIDL, lineOptions);
- if (lineUIDL.hasAttribute("color")) {
- lineOptions.setColor(lineUIDL.getStringAttribute("color"));
- }
- if (lineUIDL.hasAttribute("dashStyle")) {
- lineOptions.setDashStyle(lineUIDL.getStringAttribute("dashStyle"));
- }
- if (lineUIDL.hasAttribute("lineWidth")) {
- lineOptions.setLineWidth(lineUIDL.getIntAttribute("lineWidth"));
- }
- if (lineUIDL.hasAttribute("pointStart")) {
- lineOptions.setPointStart(lineUIDL.getDoubleAttribute("pointStart"));
- }
- if (lineUIDL.hasAttribute("pointInterval")) {
- lineOptions.setPointInterval(lineUIDL
- .getIntAttribute("pointInterval"));
- }
- if (lineUIDL.hasAttribute("stickyTracking")) {
- lineOptions.setStickyTracking(lineUIDL
- .getBooleanAttribute("stickyTracking"));
- }
-
- GwtMarker marker = getMarkerOptions(lineUIDL.getChildUIDL(2));
- if (marker != null) {
- lineOptions.setMarker(marker);
- }
- VConsole.log("Exit [updateBaseLineOptions]");
- }
-
- private void updateLineOptions(UIDL lineUIDL, GwtLineOptions lineOptions) {
- VConsole.log("Enter [updateLineOptions]");
- VConsole.log("Tag Name : " + lineUIDL.getTag());
-
- updateBaseLineOptions(lineUIDL, lineOptions);
-
- if (lineUIDL.hasAttribute("step")) {
- lineOptions.setStep(lineUIDL.getBooleanAttribute("step"));
- }
-
- VConsole.log("Exit [updateBaseLineOptions]");
- }
-
- private void updateScatterOptions(UIDL scatterUIDL,
- GwtScatterOptions scatterOptions) {
- VConsole.log("Enter [updateScatterOptions]");
- VConsole.log("Tag Name : " + scatterUIDL.getTag());
-
- updateBaseLineOptions(scatterUIDL, scatterOptions);
-
- VConsole.log("Exit [updateScatterOptions]");
- }
-
- private void updateSplineOptions(UIDL splineUIDL,
- GwtSplineOptions splineOptions) {
- VConsole.log("Enter [updateSplineOptions]");
- VConsole.log("Tag Name : " + splineUIDL.getTag());
-
- updateBaseLineOptions(splineUIDL, splineOptions);
-
- VConsole.log("Exit [updateSplineOptions]");
- }
-
- private void updateAreaOptions(UIDL areaUIDL, GwtAreaOptions areaOptions) {
- VConsole.log("Enter [updateAreaOptions]");
- VConsole.log("Tag Name : " + areaUIDL.getTag());
-
- updateBaseLineOptions(areaUIDL, areaOptions);
- if (areaUIDL.hasAttribute("fillColor")) {
- areaOptions.setFillColor(areaUIDL.getStringAttribute("fillColor"));
- }
- if (areaUIDL.hasAttribute("lineColor")) {
- areaOptions.setLineColor(areaUIDL.getStringAttribute("lineColor"));
- }
- if (areaUIDL.hasAttribute("fillOpacity")) {
- areaOptions.setFillOpacity(areaUIDL
- .getDoubleAttribute("fillOpacity"));
- }
- if (areaUIDL.hasAttribute("threshold")) {
- areaOptions.setThreshold(areaUIDL.getIntAttribute("threshold"));
- }
-
- VConsole.log("Exit [updateAreaOptions]");
- }
-
- private void updateAreaSplineOptions(UIDL areaSplineUIDL,
- GwtAreaSplineOptions areaSplineOptions) {
- VConsole.log("Enter [updateAreaSplineOptions]");
- VConsole.log("Tag Name : " + areaSplineUIDL.getTag());
-
- updateAreaOptions(areaSplineUIDL, areaSplineOptions);
-
- VConsole.log("Exit [updateAreaSplineOptions]");
- }
-
- private void updatePieOptions(UIDL pieUIDL, GwtPieOptions pieOptions) {
- VConsole.log("Enter [updatePieOptions]");
- VConsole.log("Tag Name : " + pieUIDL.getTag());
-
- updateSeriesOptions(pieUIDL, pieOptions);
- Integer centerX = null;
- Integer centerY = null;
- if (pieUIDL.hasAttribute("centerX")) {
- centerX = pieUIDL.getIntAttribute("centerX");
- }
- if (pieUIDL.hasAttribute("centerY")) {
- centerY = pieUIDL.getIntAttribute("centerY");
- }
- if (centerX != null || centerY != null) {
- JsArrayNumber center = JavaScriptObject.createArray().cast();
- center.push((centerX == null ? 0 : centerX));
- center.push((centerY == null ? 0 : centerY));
- pieOptions.setCenter(center);
- }
- if (pieUIDL.hasAttribute("borderColor")) {
- pieOptions
- .setBorderColor(pieUIDL.getStringAttribute("borderColor"));
- }
- if (pieUIDL.hasAttribute("borderWidth")) {
- pieOptions.setBorderWidth(pieUIDL.getIntAttribute("borderWidth"));
- }
- if (pieUIDL.hasAttribute("innerSize")) {
- pieOptions.setInnerSize(pieUIDL.getIntAttribute("innerSize"));
- }
- if (pieUIDL.hasAttribute("size")) {
- pieOptions.setSize(pieUIDL.getIntAttribute("size"));
- }
- if (pieUIDL.hasAttribute("slicedOffset")) {
- pieOptions.setSlicedOffset(pieUIDL.getIntAttribute("slicedOffset"));
- }
-
- VConsole.log("Exit [updatePieOptions]");
- }
-
- private void updateBaseBarOptions(UIDL barUIDL,
- GwtBaseBarOptions baseBarOptions) {
- VConsole.log("Enter [updateBaseBarOptions]");
-
- updateSeriesOptions(barUIDL, baseBarOptions);
- if (barUIDL.hasAttribute("borderColor")) {
- baseBarOptions.setBorderColor(barUIDL
- .getStringAttribute("borderColor"));
- }
- if (barUIDL.hasAttribute("borderWidth")) {
- baseBarOptions.setBorderWidth(barUIDL
- .getIntAttribute("borderWidth"));
- }
- if (barUIDL.hasAttribute("borderRadius")) {
- baseBarOptions.setBorderRadius(barUIDL
- .getIntAttribute("borderRadius"));
- }
- if (barUIDL.hasAttribute("colorByPoint")) {
- baseBarOptions.setColorByPoint(barUIDL
- .getBooleanAttribute("colorByPoint"));
- }
- if (barUIDL.hasAttribute("groupPadding")) {
- baseBarOptions.setGroupPadding(barUIDL
- .getDoubleAttribute("groupPadding"));
- }
- if (barUIDL.hasAttribute("minPointLength")) {
- baseBarOptions.setMinPointLength(barUIDL
- .getDoubleAttribute("minPointLength"));
- }
- if (barUIDL.hasAttribute("pointPadding")) {
- baseBarOptions.setPointPadding(barUIDL
- .getDoubleAttribute("pointPadding"));
- }
- if (barUIDL.hasAttribute("pointWidth")) {
- baseBarOptions.setPointWidth(barUIDL.getIntAttribute("pointWidth"));
- }
-
- VConsole.log("Exit [updateBaseBarOptions]");
- }
-
- private void updateBarOptions(UIDL barUIDL, GwtBarOptions barOptions) {
- VConsole.log("Enter [updateBarOptions]");
- VConsole.log("Tag Name : " + barUIDL.getTag());
-
- updateBaseBarOptions(barUIDL, barOptions);
-
- VConsole.log("Exit [updateBarOptions]");
- }
-
- private void updateColumnOptions(UIDL columnUIDL,
- GwtColumnOptions columnOptions) {
- VConsole.log("Enter [updateColumnOptions]");
- VConsole.log("Tag Name : " + columnUIDL.getTag());
-
- updateBaseBarOptions(columnUIDL, columnOptions);
-
- VConsole.log("Exit [updateColumnOptions]");
- }
-
- private void updateOptionsWithChartEvents(GwtInvientChartsConfig options,
- UIDL chartEventUIDL) {
- VConsole.log("Enter [updateOptionsWithChartEvents]");
-
- // Chart events
- GwtChartEvents chartEvents = GwtChartEvents.create();
- if (chartEventUIDL.hasAttribute("addSeries")
- && chartEventUIDL.getBooleanAttribute("addSeries")) {
- chartEvents.setAddSeriesEvent(EventCallbacks
- .getChartAddSeries(this));
- }
- if (chartEventUIDL.hasAttribute("click")
- && chartEventUIDL.getBooleanAttribute("click")) {
- chartEvents.setClickEvent(EventCallbacks.getChartClick(this));
- }
- if (chartEventUIDL.hasAttribute("selection")
- && chartEventUIDL.getBooleanAttribute("selection")) {
- if (options.getChartOptions().getClientZoom()) {
- chartEvents.setSelectionEvent(EventCallbacks
- .getClientChartSelection(this));
- } else {
- chartEvents.setSelectionEvent(EventCallbacks
- .getServerChartSelection(this));
- }
- }
- if (options.getChartOptions() == null) {
- options.setChartOptions(GwtChartOptions.create());
- }
- options.getChartOptions().setEvents(chartEvents);
-
- VConsole.log("Exit [updateOptionsWithChartEvents]");
- }
-
- private GwtSeriesEvents getSeriesEvents(UIDL seriesEventUIDL) {
- GwtSeriesEvents seriesEvents = GwtSeriesEvents.create();
- boolean foundEvt = false;
- if (seriesEventUIDL.hasAttribute("legendItemClick")
- && seriesEventUIDL.getBooleanAttribute("legendItemClick")) {
- seriesEvents.setLegendItemClickEvent(EventCallbacks
- .getSeriesLegendItemClick(this));
- foundEvt = true;
- }
- if (seriesEventUIDL.hasAttribute("click")
- && seriesEventUIDL.getBooleanAttribute("click")) {
- seriesEvents.setClickEvent(EventCallbacks.getSeriesClick(this));
- foundEvt = true;
- }
- if (seriesEventUIDL.hasAttribute("show")
- && seriesEventUIDL.getBooleanAttribute("show")) {
- seriesEvents.setShowEvent(EventCallbacks.getSeriesShow(this));
- foundEvt = true;
- }
- if (seriesEventUIDL.hasAttribute("hide")
- && seriesEventUIDL.getBooleanAttribute("hide")) {
- seriesEvents.setHideEvent(EventCallbacks.getSeriesHide(this));
- foundEvt = true;
- }
- if (foundEvt) {
- return seriesEvents;
- }
- return null;
- }
-
- private void updateOptionsWithSeriesAndPoingEvents(
- GwtInvientChartsConfig options, UIDL chartSeriesEventsUIDL) {
- VConsole.log("Enter [updateOptionsWithSeriesAndPoingEvents]");
- VConsole.log("[updateOptionsWithSeriesEvents] # of series : "
- + chartSeriesEventsUIDL.getChildCount());
-
- // UIDL seriesEventUIDL = eventUIDL.getChildUIDL(1);
- if (chartSeriesEventsUIDL.getChildCount() > 0
- && options.getPlotOptions() == null) {
- options.setPlotOptions(GwtPlotOptions.create());
- }
- for (int cnt = 0; cnt < chartSeriesEventsUIDL.getChildCount(); cnt++) {
- UIDL seriesEventsUIDL = chartSeriesEventsUIDL.getChildUIDL(cnt);
- String seriesType = seriesEventsUIDL.getTag(); // can be
- // series/pie/line
- // etc
- VConsole.log("Series type " + seriesType);
- //
- GwtSeriesEvents seriesEvents = getSeriesEvents(seriesEventsUIDL);
- //
- GwtPointEvents pointEvents = null;
- if (seriesEventsUIDL.getChildCount() > 0) {
- pointEvents = getPointEvents(options,
- seriesEventsUIDL.getChildUIDL(0));
- }
- if (seriesEvents == null && pointEvents == null) {
- VConsole.log("No series/point events found for series type : "
- + seriesType);
- continue;
- }
- GwtSeriesGeneralOptions seriesOptions = null;
- if (seriesType.equals("line")) {
- if (options.getPlotOptions().getLine() == null) {
- options.getPlotOptions().setLine(
- GwtLineOptions.createLineOptions());
- }
- seriesOptions = options.getPlotOptions().getLine();
- } else if (seriesType.equals("spline")) {
- if (options.getPlotOptions().getSpline() == null) {
- options.getPlotOptions().setSpline(
- GwtSplineOptions.createSplineOptions());
- }
- seriesOptions = options.getPlotOptions().getSpline();
- } else if (seriesType.equals("area")) {
- if (options.getPlotOptions().getArea() == null) {
- options.getPlotOptions().setArea(
- GwtAreaOptions.createAreaOptions());
- }
- seriesOptions = options.getPlotOptions().getArea();
- } else if (seriesType.equals("areaspline")) {
- if (options.getPlotOptions().getAreaSpline() == null) {
- options.getPlotOptions().setAreaSpline(
- GwtAreaSplineOptions.createAreaSplineOptions());
- }
- seriesOptions = options.getPlotOptions().getAreaSpline();
- } else if (seriesType.equals("bar")) {
- if (options.getPlotOptions().getBar() == null) {
- options.getPlotOptions().setBar(
- GwtBarOptions.createBarOptions());
- }
- seriesOptions = options.getPlotOptions().getBar();
- } else if (seriesType.equals("column")) {
- if (options.getPlotOptions().getColumn() == null) {
- options.getPlotOptions().setColumn(
- GwtColumnOptions.createColumnOptions());
- }
- seriesOptions = options.getPlotOptions().getColumn();
- } else if (seriesType.equals("scatter")) {
- if (options.getPlotOptions().getScatter() == null) {
- options.getPlotOptions().setScatter(
- GwtScatterOptions.createScatterOptions());
- }
- seriesOptions = options.getPlotOptions().getScatter();
- } else if (seriesType.equals("pie")) {
- if (options.getPlotOptions().getPie() == null) {
- options.getPlotOptions().setPie(
- GwtPieOptions.createPieOptions());
- }
- seriesOptions = options.getPlotOptions().getPie();
- } else {
- if (options.getPlotOptions().getSeries() == null) {
- options.getPlotOptions().setSeries(
- GwtSeriesGeneralOptions.createSeriesOptions());
- }
- seriesOptions = options.getPlotOptions().getSeries();
- }
- // Set series/point events
- if (seriesEvents != null) {
- seriesOptions.setEvents(seriesEvents);
- }
- if (pointEvents != null) {
- seriesOptions.setPointEvents(pointEvents);
- }
- }
- VConsole.log("Exit [updateOptionsWithSeriesAndPoingEvents]");
- }
-
- private GwtPointEvents getPointEvents(GwtInvientChartsConfig options,
- UIDL pointEventsUIDL) {
- VConsole.log("Enter [getPointEvents]");
- // Point events
- boolean foundEvt = false;
- GwtPointEvents pointEvents = GwtPointEvents.create();
- if (pointEventsUIDL.hasAttribute("legendItemClick")
- && pointEventsUIDL.getBooleanAttribute("legendItemClick")) {
- pointEvents.setLegendItemClickEvent(EventCallbacks
- .getPieLegendItemClick(this));
- foundEvt = true;
- }
- if (pointEventsUIDL.hasAttribute("click")
- && pointEventsUIDL.getBooleanAttribute("click")) {
- pointEvents.setClickEvent(EventCallbacks.getPointClick(this));
- foundEvt = true;
- }
- if (pointEventsUIDL.hasAttribute("remove")
- && pointEventsUIDL.getBooleanAttribute("remove")) {
- pointEvents.setRemoveEvent(EventCallbacks.getPointRemove(this));
- foundEvt = true;
- }
- if (pointEventsUIDL.hasAttribute("select")
- && pointEventsUIDL.getBooleanAttribute("select")) {
- pointEvents.setSelectEvent(EventCallbacks.getPointSelect(this));
- foundEvt = true;
- }
- if (pointEventsUIDL.hasAttribute("unselect")
- && pointEventsUIDL.getBooleanAttribute("unselect")) {
- pointEvents.setUnselectEvent(EventCallbacks.getPointUnselect(this));
- foundEvt = true;
- }
- VConsole.log("Exit [getPointEvents]");
- if (foundEvt) {
- return pointEvents;
- }
- return null;
- }
-
- private void updateOptionsWithEvents(GwtInvientChartsConfig options,
- UIDL eventUIDL) {
- VConsole.log("Enter [updateOptionsWithEvents]");
-
- // Chart events
- updateOptionsWithChartEvents(options, eventUIDL.getChildUIDL(0));
-
- // Series events
- updateOptionsWithSeriesAndPoingEvents(options,
- eventUIDL.getChildUIDL(1));
-
- VConsole.log("Exit [updateOptionsWithEvents]");
- }
-
- protected void chartAddSeriesListener(GwtChart chart) {
- VConsole.log("Enter [chartAddSeriesListener]");
-
- client.updateVariable(uidlId, "event", "addSeries", true);
-
- VConsole.log("Exit [chartAddSeriesListener]");
- }
-
- protected void chartClickListener(GwtChart chart, double xAxisPos,
- double yAxisPos, int pageX, int pageY) {
- VConsole.log("Enter [chartClickListener]");
-
- VConsole.log("chartClickListener : xAxisPos : " + xAxisPos
- + ", yAxisPos : " + yAxisPos);
- client.updateVariable(uidlId, "event", "chartClick", false);
- Map eventData = new HashMap();
- eventData.put("xAxisPos", String.valueOf(xAxisPos));
- eventData.put("yAxisPos", String.valueOf(yAxisPos));
- updateEventDataWithMousePosition(eventData, pageX, pageY);
- client.updateVariable(uidlId, "eventData", eventData, true);
-
- VConsole.log("Exit [chartClickListener]");
- }
-
- protected void chartSelectionListener(GwtChart chart, double xAxisMin,
- double xAxisMax, double yAxisMin, double yAxisMax) {
- VConsole.log("Enter [chartSelectionListener]");
-
- VConsole.log("[chartSelectionListener] xAxisMin : " + xAxisMin
- + ", xAxisMax : " + xAxisMax + ", yAxisMin : " + yAxisMin
- + ", yAxisMax : " + yAxisMax);
- client.updateVariable(uidlId, "event", "chartZoom", false);
- Map eventData = new HashMap();
- eventData.put("xAxisMin", String.valueOf(xAxisMin));
- eventData.put("xAxisMax", String.valueOf(xAxisMax));
- eventData.put("yAxisMin", String.valueOf(yAxisMin));
- eventData.put("yAxisMax", String.valueOf(yAxisMax));
- client.updateVariable(uidlId, "eventData", eventData, true);
-
- VConsole.log("Exit [chartSelectionListener]");
- }
-
- protected void chartResetZoomListener(GwtChart chart) {
- VConsole.log("Enter [chartResetZoomListener]");
-
- client.updateVariable(uidlId, "event", "chartResetZoom", true);
-
- VConsole.log("Exit [chartResetZoomListener]");
- }
-
- protected void seriesClickListener(GwtSeries series, GwtPoint nearestPoint,
- int pageX, int pageY) {
- VConsole.log("Enter [seriesClickListener]");
-
- VConsole.log("[seriesClickListener] point x: " + nearestPoint.getX()
- + ", point y: " + nearestPoint.getY());
- client.updateVariable(uidlId, "event", "seriesClick", false);
- Map eventData = getEventData(nearestPoint);
- updateEventDataWithMousePosition(eventData, pageX, pageY);
- client.updateVariable(uidlId, "eventData", eventData, true);
-
- VConsole.log("Exit [seriesClickListener]");
- }
-
- protected void seriesHideListener(GwtSeries series) {
- VConsole.log("Enter [seriesHideListener]");
-
- VConsole.log("[seriesHideListener] series name " + series.getName());
- client.updateVariable(uidlId, "event", "seriesHide", false);
- Map eventData = new HashMap();
- eventData.put("seriesName", series.getName());
- client.updateVariable(uidlId, "eventData", eventData, true);
-
- VConsole.log("Exit [seriesHideListener]");
- }
-
- protected void seriesShowListener(GwtSeries series) {
- VConsole.log("Enter [seriesShowListener]");
-
- VConsole.log("[seriesShowListener] series name " + series.getName());
- client.updateVariable(uidlId, "event", "seriesShow", false);
- Map eventData = new HashMap();
- eventData.put("seriesName", series.getName());
- client.updateVariable(uidlId, "eventData", eventData, true);
-
- VConsole.log("Exit [seriesShowListener]");
- }
-
- protected void seriesLegendItemClickListener(GwtSeries series) {
- VConsole.log("Enter [seriesLegendItemClickListener]");
-
- VConsole.log("[seriesLegendItemClickListener] name " + series.getName());
- client.updateVariable(uidlId, "event", "seriesLegendItemClick", false);
- Map eventData = new HashMap();
- eventData.put("seriesName", series.getName());
- client.updateVariable(uidlId, "eventData", eventData, true);
-
- VConsole.log("Exit [seriesLegendItemClickListener]");
- }
-
- protected void pieLegendItemClickListener(GwtPoint point) {
- VConsole.log("Enter [pieLegendItemClickListener]");
-
- client.updateVariable(uidlId, "event", "pieLegendItemClick", false);
- Map eventData = getEventData(point);
- client.updateVariable(uidlId, "eventData", eventData, true);
-
- VConsole.log("Exit [pieLegendItemClickListener]");
- }
-
- protected void pointClickListener(GwtPoint point, int pageX, int pageY) {
- VConsole.log("Enter [pointClickListener]");
-
- client.updateVariable(uidlId, "event", "pointClick", false);
- Map eventData = getEventData(point);
- updateEventDataWithMousePosition(eventData, pageX, pageY);
- client.updateVariable(uidlId, "eventData", eventData, true);
-
- VConsole.log("Exit [pointClickListener]");
- }
-
- protected void pointSelectListener(GwtPoint point) {
- VConsole.log("Enter [pointSelectListener]");
-
- VConsole.log("[pointSelectListener] point " + point.getX() + ", "
- + point.getY());
- client.updateVariable(uidlId, "event", "pointSelect", false);
- client.updateVariable(uidlId, "eventData", getEventData(point), true);
-
- VConsole.log("Exit [pointSelectListener]");
- }
-
- protected void pointUnselectListener(GwtPoint point) {
- VConsole.log("Enter [pointUnselectListener]");
-
- VConsole.log("[pointUnselectListener] point " + point.getX() + ", "
- + point.getY());
- client.updateVariable(uidlId, "event", "pointUnselect", false);
- client.updateVariable(uidlId, "eventData", getEventData(point), true);
-
- VConsole.log("Exit [pointUnselectListener]");
- }
-
- protected void pointRemoveListener(GwtPoint point) {
- VConsole.log("Enter [pointRemoveListener]");
-
- VConsole.log("[pointRemoveListener] point " + point.getX() + ", "
- + point.getY());
- client.updateVariable(uidlId, "event", "pointRemove", false);
- client.updateVariable(uidlId, "eventData", getEventData(point), true);
-
- VConsole.log("Exit [pointRemoveListener]");
- }
-
- private Map getEventData(GwtPoint point) {
- Map eventData = new HashMap();
- eventData.put("seriesName", point.getSeries().getName());
- eventData.put("category", point.getCategory());
- // The point x and y values are converted into
- // string value to avoid data conversion issues
- // for datetime series/axis
- // It is responsibility of the server to convert string value
- // into appropriate data type e.g. double or Date
- eventData.put("pointX", String.valueOf(point.getX()));
- eventData.put("pointY", String.valueOf(point.getY()));
- return eventData;
- }
-
- private void updateEventDataWithMousePosition(
- Map eventData, int pageX, int pageY) {
- eventData.put("mouseX", pageX);
- eventData.put("mouseY", pageY);
- }
-
- private String getExecutableFunction(String formatterFunc) {
- StringBuilder sb = new StringBuilder("");
- sb.append("function dummy() { ");
- sb.append(" return ");
- sb.append(formatterFunc).append(";");
- sb.append(" }");
- sb.append(" dummy();");
- return sb.toString();
- }
-
- /**
- * Define a JS function to be used in order to get mouse coordinates when
- * click event occurs on a chart/series/point
- */
- private native final void publish() /*-{
- // Used in based class GwtInvientCharts.java
- $wnd.getMouseCoords = function(ev) {
- if(ev.pageX || ev.pageY){
- return {x:ev.pageX, y:ev.pageY};
- } else {
- return {
- x:ev.clientX + document.documentElement.scrollLeft,
- y:ev.clientY + document.documentElement.scrollTop
- };
- }
- };
- // Used in class GwtInvientChartsConfig.java
- $wnd.getInvientChartsColor = function(colorVal) {
- var colorKey = 'JSOBJ:';
- var index = colorVal.indexOf(colorKey);
- if(index == 0) {
- return eval('(' + colorVal.substring(index+colorKey.length) + ')');
- }
- return colorVal;
- };
- }-*/;
-
-}
+/*
+ * Copyright 2011 Invient (www.invient.com)
+ *
+ * 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 com.invient.vaadin.charts.widgetset.client.ui;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.core.client.JsArray;
+import com.google.gwt.core.client.JsArrayNumber;
+import com.google.gwt.core.client.JsArrayString;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtAxisBaseOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtAxisBaseOptions.GwtAxisDataLabels;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtAxisBaseOptions.GwtAxisTitleOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtAxisBaseOptions.GwtPlotBands;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtAxisBaseOptions.GwtPlotLabel;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtAxisBaseOptions.GwtPlotLines;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtAxisBaseOptions.GwtXAxisDataLabels;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtAxisBaseOptions.GwtYAxisDataLabels;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtChartLabels;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtChartLabels.GwtChartLabelItem;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtChartOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtChartOptions.GwtChartEvents;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtCreditOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtLegendOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtAreaOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtAreaSplineOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtBarOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtBaseBarOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtBaseLineOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtColumnOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtDataLabels;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtLineOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtMarker;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtMarker.GwtMarkerStates;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtMarker.GwtMarkerStates.GwtMarkerState;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtPieDataLabels;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtPieOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtScatterOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtSeriesEvents;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtSeriesGeneralOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtSeriesGeneralOptions.GwtStates;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtSeriesGeneralOptions.GwtStates.GwtHover;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPlotOptions.GwtSplineOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPointOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPointOptions.GwtPointEvents;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtPosition;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtSeriesDataOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtSubtitleOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtTitleBaseOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtTitleOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtTooltipOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtTooltipCrosshairs;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtXAxisOptions;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtXAxisOptions.GwtDateTimeLabelFormats;
+import com.invient.vaadin.charts.widgetset.client.ui.GwtInvientChartsConfig.GwtYAxisOptions;
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.Paintable;
+import com.vaadin.terminal.gwt.client.UIDL;
+import com.vaadin.terminal.gwt.client.VConsole;
+
+/**
+ * Client side widget which communicates with the server. Messages from the
+ * server are shown as HTML and mouse clicks are sent to the server.
+ *
+ * Reads data from UIDL and create appropriate JavaScript overlay objects such
+ * as {@link GwtChart}, {@link GwtAxis}, {@link GwtInvientChartsConfig},
+ * {@link GwtPoint} and {@link GwtSeries}
+ *
+ * Uses a method newChart() of {@link GwtInvientChartsUtil} to create a chart
+ * object of type {@link GwtChart}
+ *
+ * @author Invient
+ */
+public class VInvientCharts extends GwtInvientCharts implements Paintable /*
+ * ,
+ * ClickHandler
+ * ,
+ * ScrollHandler
+ */{
+
+ private static final long serialVersionUID = -762763091427791681L;
+
+ /** Set the CSS class name to allow styling. */
+ public static final String CLASSNAME = "v-invientcharts";
+
+ /** The client side widget identifier */
+ protected String uidlId;
+
+ /** Reference to the server connection object. */
+ protected ApplicationConnection client;
+
+ /**
+ * The constructor should first call super() to initialize the component and
+ * then handle any initialization relevant to Vaadin.
+ */
+ public VInvientCharts() {
+ super();
+ setStyleName(CLASSNAME);
+ publish();
+ }
+
+ /**
+ * Called whenever an update is received from the server
+ */
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+ VConsole.log("Enter [updateFromUIDL]");
+ // This call should be made first.
+ // It handles sizes, captions, tooltips, etc. automatically.
+ if (client.updateComponent(this, uidl, true)) {
+ // If client.updateComponent returns true there has been no changes
+ // and we
+ // do not need to update anything.
+ return;
+ }
+
+ // Save reference to server connection object to be able to send
+ // user interaction later
+ this.client = client;
+
+ // Save the client side identifier (paintable id) for the widget
+ uidlId = uidl.getId();
+
+ // Create chart only once along with chart options
+ // Chart options are set only once.
+ if (chart == null) {
+ // Chart options
+ GwtInvientChartsConfig options = getInvientChartOptions(uidl
+ .getChildUIDL(ChartUIDLIndex.OPTIONS.ordinal()));
+ // Chart events
+ updateOptionsWithEvents(options,
+ uidl.getChildUIDL(ChartUIDLIndex.EVENTS.ordinal()));
+ // Chart data
+ JsArray chartData = getChartData(uidl
+ .getChildUIDL(ChartUIDLIndex.DATA.ordinal()));
+ options.setSeriesInstanceOptions(chartData);
+ VConsole.log("Going to create a chart.");
+ createChart(options);
+ } else {
+ resetRedrawChart();
+ if (uidl.getBooleanAttribute("reloadChartSeries")) {
+ // Get all series and add them to chart
+ JsArray chartData = getChartData(uidl
+ .getChildUIDL(ChartUIDLIndex.DATA.ordinal()));
+ int seriesCount = chart.getSeries().length();
+ VConsole.log("# of series the chart has " + seriesCount);
+ VConsole.log("Going to remove all series of the chart.");
+ for (int ind = seriesCount - 1; ind >= 0; ind--) {
+ setRedrawChart();
+ chart.getSeries().get(ind).remove(false);
+ }
+ VConsole.log("Goint to add series to the chart.");
+ for (int ind = 0; ind < chartData.length(); ind++) {
+ setRedrawChart();
+ chart.addSeries(chartData.get(ind), false);
+ }
+ } else {
+ VConsole.log("Going to update chart data.");
+ UIDL chartDataUIDL = uidl.getChildUIDL(ChartUIDLIndex.DATA
+ .ordinal());
+ UIDL chartDataUpdatesUIDL = uidl
+ .getChildUIDL(ChartUIDLIndex.DATA_UPDATES.ordinal());
+ updateChartData(chartDataUpdatesUIDL, chartDataUIDL);
+ }
+
+ // Options UIDL
+ UIDL optionsUIDL = uidl.getChildUIDL(ChartUIDLIndex.OPTIONS
+ .ordinal());
+ // Update chart title & subtitle
+ setChartTitleAndSubtitle(optionsUIDL);
+ // Size
+ setChartSize(optionsUIDL);
+
+ VConsole.log("Getting x-axis options...");
+ JsArray uidlXAxesOptionsArr = getXAxisOptions(optionsUIDL
+ .getChildUIDL(ChartOptionsUIDLIndex.X_AXES.ordinal()));
+ JsArray chartXAxesOptionsArr = JavaScriptObject
+ .createArray().cast();
+ JsArray chartXAxesArr = chart.getXAxes();
+ if (chart.getOptions().hasXAxesOptions()) {
+ chartXAxesOptionsArr = chart.getOptions().getXAxesOptions();
+ updateXAxisCategories(chartXAxesArr, chartXAxesOptionsArr,
+ uidlXAxesOptionsArr);
+ }
+ updateAxesPlotBandsAndPlotLines(chartXAxesArr,
+ chartXAxesOptionsArr, uidlXAxesOptionsArr);
+
+ VConsole.log("Getting y-axis options...");
+ JsArray uidlYAxesOptionsArr = getYAxisOptions(optionsUIDL
+ .getChildUIDL(ChartOptionsUIDLIndex.Y_AXES.ordinal()));
+ JsArray chartYAxesOptionsArr = JavaScriptObject
+ .createArray().cast();
+ if (chart.getOptions().hasYAxesOptions()) {
+ chartYAxesOptionsArr = chart.getOptions().getYAxesOptions();
+ }
+ JsArray chartYAxesArr = chart.getYAxes();
+ updateAxesPlotBandsAndPlotLines(chartYAxesArr,
+ chartYAxesOptionsArr, uidlYAxesOptionsArr);
+ // Update axis extremes
+ if (chart.getOptions().hasXAxesOptions()
+ || chart.getOptions().hasYAxesOptions()) {
+ updateAxisExtremes(chart.getXAxes(), chartXAxesOptionsArr,
+ uidlXAxesOptionsArr);
+ updateAxisExtremes(chart.getYAxes(), chartYAxesOptionsArr,
+ uidlYAxesOptionsArr);
+ }
+ if (isRedrawChart()) {
+ VConsole.log("Going to redraw the chart.");
+ chart.redraw();
+ }
+ }
+ // Get SVG if required and send it to server
+ handleChartSVG(uidl);
+ handlePrint(uidl);
+ VConsole.log("Exit [updateFromUIDL]");
+ }
+
+ // Set title & subtitle
+ private void setChartTitleAndSubtitle(UIDL optionsUIDL) {
+ VConsole.log("Enter [setChartTitleAndSubtitle]");
+ // There is not need to set redrawChart flag as setting title & subtitle
+ // does not require redrawing of the chart.
+ chart.setTitle(
+ getTitleOptions(optionsUIDL
+ .getChildUIDL(ChartOptionsUIDLIndex.TITLE.ordinal())),
+ getSubtitleOptions(optionsUIDL
+ .getChildUIDL(ChartOptionsUIDLIndex.SUBTITLE.ordinal())));
+ VConsole.log("Exit [setChartTitleAndSubtitle]");
+ }
+
+ // Set chart size
+ private void setChartSize(UIDL optionsUIDL) {
+ // There is not need to set redrawChart flag as setting title & subtitle
+ // does not require redrawing of the chart.
+ GwtChartOptions chartOptions = getChartOptions(optionsUIDL
+ .getChildUIDL(ChartOptionsUIDLIndex.CHART_CONFIG.ordinal()));
+ int newWidth = chartOptions.getWidth();
+ int newHeight = chartOptions.getHeight();
+ updateChartSize(newWidth, newHeight);
+ }
+
+ private void updateChartSize(int newWidth, int newHeight) {
+ int existingWidth = chart.getOptions().getChartOptions().getWidth();
+ int existingHeight = chart.getOptions().getChartOptions().getHeight();
+
+ if ((newWidth != -1 && newWidth != existingWidth)
+ || (newHeight != -1 && newHeight != existingHeight)) {
+ VConsole.log("Set chart size.");
+ chart.getOptions().getChartOptions().setWidth(newWidth);
+ chart.getOptions().getChartOptions().setHeight(newHeight);
+ chart.setSize(newWidth, newHeight);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setHeight(String height) {
+ super.setHeight(height);
+ updateChartSize();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setWidth(String width) {
+ super.setWidth(width);
+ updateChartSize();
+ }
+
+ private void updateChartSize() {
+ if (chart != null) {
+ updateChartSize(getElement().getOffsetWidth(), getElement().getOffsetHeight());
+ }
+ }
+
+ private void handlePrint(UIDL uidl) {
+ boolean isPrint = uidl.getBooleanAttribute("isPrint");
+ if (isPrint) {
+ VConsole.log("Going to print the chart...");
+ chart.printInvientChart();
+ }
+ }
+
+ private void handleChartSVG(UIDL uidl) {
+ boolean isRetrieveSVG = uidl.getBooleanAttribute("isRetrieveSVG");
+ if (isRetrieveSVG) {
+ VConsole.log("Get an svg string...");
+ String svg = chart.getSVG(null);
+ // send svg to server
+ client.updateVariable(uidlId, "event", "chartSVGAvailable", false);
+ Map eventData = new HashMap();
+ eventData.put("svg", svg);
+ client.updateVariable(uidlId, "eventData", eventData, true);
+ }
+ }
+
+ private void updateXAxisCategories(JsArray chartAxesArr,
+ JsArray chartXAxesOptionsArr,
+ JsArray uidlXAxesOptionsArr) {
+ VConsole.log("Enter [updateXAxisCategories]");
+ if (chartXAxesOptionsArr == null || chartXAxesOptionsArr.length() == 0) {
+ VConsole.log("Chart doesn't have any X axis]");
+ VConsole.log("Exit [updateXAxisCategories]");
+ return;
+ }
+ int noOfAxis = chartXAxesOptionsArr.length();
+ for (int ind = 0; ind < noOfAxis; ind++) {
+ GwtAxis chartAxis = chartAxesArr.get(ind);
+ GwtXAxisOptions chartAxisOptions = chartXAxesOptionsArr.get(ind);
+ GwtXAxisOptions uidlAxisOptions = uidlXAxesOptionsArr.get(ind);
+ if (chartAxis != null && chartAxisOptions != null
+ && uidlAxisOptions != null) {
+ // If axis
+ if (!areStringArraysEqual(uidlAxisOptions.getCategories(),
+ chartAxis.getCategories())) {
+ setRedrawChart();
+ chartAxisOptions.setCategories(uidlAxisOptions
+ .getCategories());
+ chartAxis.setCategories(uidlAxisOptions.getCategories(),
+ false);
+ }
+ }
+ }
+ VConsole.log("Exit [updateXAxisCategories]");
+ }
+
+ private boolean areStringArraysEqual(JsArrayString arrOne,
+ JsArrayString arrTwo) {
+ if (arrOne == arrTwo) {
+ return true;
+ }
+ if ((arrOne != null && arrTwo == null)
+ || (arrOne == null && arrTwo != null)) {
+ return false;
+ }
+ if (arrOne.length() != arrTwo.length()) {
+ return false;
+ }
+ // Compare each array element
+ for (int arrInd = 0; arrInd < arrOne.length(); arrInd++) {
+ String arrOneVal = arrOne.get(arrInd);
+ String arrTwoVal = arrTwo.get(arrInd);
+ if (arrOneVal == null) {
+ if (arrTwoVal != null) {
+ return false;
+ }
+ }
+ else if(!arrOneVal.equals(arrTwoVal)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private void updateAxisExtremes(JsArray chartAxesArr,
+ JsArray extends GwtAxisBaseOptions> chartAxesOptionsArr,
+ JsArray extends GwtAxisBaseOptions> uidlAxesOptionsArr) {
+ VConsole.log("Enter [updateAxisExtremes]");
+ if (chartAxesOptionsArr == null || chartAxesOptionsArr.length() == 0) {
+ VConsole.log("Chart doesn't have any X/Y axis]");
+ VConsole.log("Exit [updateAxisExtremes]");
+ return;
+ }
+ int noOfAxis = chartAxesOptionsArr.length();
+ for (int ind = 0; ind < noOfAxis; ind++) {
+ GwtAxis chartAxis = chartAxesArr.get(ind);
+ GwtAxisBaseOptions chartAxisOptions = chartAxesOptionsArr.get(ind);
+ GwtAxisBaseOptions uidlAxisOptions = uidlAxesOptionsArr.get(ind);
+ if (chartAxis != null && chartAxisOptions != null
+ && uidlAxisOptions != null) {
+ double uidlMin = uidlAxisOptions.getMin();
+ double uidlMax = uidlAxisOptions.getMax();
+ double chartMin = chartAxisOptions.getMin();
+ double chartMax = chartAxisOptions.getMax();
+ // Update chart's axis options as
+ // it is not updated when extremes are set using
+ // axis.setExtremes()
+ if (uidlMin != chartMin) {
+ setRedrawChart();
+ chartAxisOptions.setMin(uidlMin);
+ }
+ if (uidlMax != chartMax) {
+ setRedrawChart();
+ chartAxisOptions.setMax(uidlMax);
+ }
+ VConsole.log("[updateAxisExtremes] min " + chartAxisOptions.getMin() + ", max " + chartAxisOptions.getMax());
+ chartAxis.setExtremes(chartAxisOptions.getMin(), chartAxisOptions.getMax(), false);
+ }
+ }
+ VConsole.log("Exit [updateAxisExtremes]");
+ }
+
+ private enum ChartUIDLIndex {
+ OPTIONS, DATA, EVENTS, DATA_UPDATES;
+ }
+
+ private enum ChartOptionsUIDLIndex {
+ TITLE, SUBTITLE, CREDIT, LEGEND, TOOLTIP, CHART_CONFIG, SERIES_OPTIONS, X_AXES, Y_AXES, LABEL, CROSSHAIRS;
+ }
+
+ private void updateAxesPlotBandsAndPlotLines(
+ JsArray extends GwtAxis> chartAxesArr,
+ JsArray extends GwtAxisBaseOptions> chartAxesOptionsArr,
+ JsArray extends GwtAxisBaseOptions> uidlAxesOptionsArr) {
+ VConsole.log("Enter [updateAxesPlotBandsAndPlotLines]");
+ int noOfAxis = chartAxesArr.length();
+ for (int ind = 0; ind < noOfAxis; ind++) {
+ GwtAxis chartAxis = chartAxesArr.get(ind);
+ GwtAxisBaseOptions chartAxisOptions = chartAxesOptionsArr.get(ind);
+ GwtAxisBaseOptions uidlAxisOptions = uidlAxesOptionsArr.get(ind);
+ if (chartAxis != null && chartAxisOptions != null
+ && uidlAxisOptions != null) {
+ updatePlotBands(chartAxis, chartAxisOptions, uidlAxisOptions);
+ updatePlotLines(chartAxis, chartAxisOptions, uidlAxisOptions);
+ }
+ }
+ VConsole.log("Exit [updateAxesPlotBandsAndPlotLines]");
+ }
+
+ //
+ private void updatePlotLines(GwtAxis chartAxis,
+ GwtAxisBaseOptions chartAxisOptions,
+ GwtAxisBaseOptions uidlAxisOptions) {
+ VConsole.log("Enter [updatePlotLines]");
+ // Update chartAxisPlotBands whenever a plotline is added or removed as
+ // the library
+ // does not update chart options by itself.
+ JsArray chartAxisPlotLines = chartAxisOptions
+ .getPlotLines();
+ JsArray uidlAxisPlotLines = uidlAxisOptions
+ .getPlotLines();
+ if (uidlAxisPlotLines == null && chartAxisPlotLines == null) {
+ VConsole.log("No plotlines found.");
+ VConsole.log("Exit [updatePlotLines]");
+ return;
+ }
+ if (uidlAxisPlotLines == null) {
+ uidlAxisPlotLines = JavaScriptObject.createArray().cast();
+ }
+ if (chartAxisPlotLines == null) {
+ chartAxisPlotLines = JavaScriptObject.createArray().cast();
+ }
+ JsArray updatedChartAxisPlotLines = JavaScriptObject
+ .createArray().cast();
+ int numOfChartAxisPlotLines = chartAxisPlotLines.length();
+ int numOfUIDLAxisPlotLines = uidlAxisPlotLines.length();
+ boolean updatedAxisPlotLines = false;
+ for (int indOuter = 0; indOuter < numOfChartAxisPlotLines; indOuter++) {
+ GwtPlotLines chartPlotLine = chartAxisPlotLines.get(indOuter);
+ String plotLineId = chartPlotLine.getId();
+ boolean found = false;
+ for (int indInner = 0; indInner < numOfUIDLAxisPlotLines; indInner++) {
+ GwtPlotLines uidlPlotLine = uidlAxisPlotLines.get(indInner);
+ if (uidlPlotLine != null
+ && uidlPlotLine.getId().equals(plotLineId)) {
+ if (uidlPlotLine.getValue() == chartPlotLine.getValue()) {
+ // PlotLine exists and value is same so no action should
+ // be taken except marking UIDL PlotLine to null.
+ // Setting UIDL PlotLine
+ // to null ensures that remaining PlotLines in UIDL can
+ // be added
+ // safely to the chart.
+ uidlAxisPlotLines.set(indInner, null);
+ updatedChartAxisPlotLines.push(chartPlotLine);
+ found = true;
+ }
+ break;
+ }
+ }
+ if (!found) {
+ // remove plot line as it is not found in UIDL received from the
+ // server
+ updatedAxisPlotLines = true;
+ chartAxis.removePlotLine(plotLineId);
+ }
+ }
+ // Add all remaining plot lines in UIDL to the chart
+ for (int ind = 0; ind < numOfUIDLAxisPlotLines; ind++) {
+ GwtPlotLines uidlPlotLine = uidlAxisPlotLines.get(ind);
+ if (uidlPlotLine != null) {
+ updatedAxisPlotLines = true;
+ chartAxis.addPlotLine(uidlPlotLine);
+ updatedChartAxisPlotLines.push(uidlPlotLine);
+ }
+ }
+
+ // Update chart axis plotlines
+ if (updatedAxisPlotLines) {
+ setRedrawChart();
+ chartAxisOptions.setPlotLines(updatedChartAxisPlotLines);
+ }
+ VConsole.log("Exit [updatePlotLines]");
+ }
+
+ //
+ private void updatePlotBands(GwtAxis chartAxis,
+ GwtAxisBaseOptions chartAxisOptions,
+ GwtAxisBaseOptions uidlAxisOptions) {
+ VConsole.log("Enter [updatePlotBands]");
+ // Update chartAxisPlotBands whenever a plotband is added or removed as
+ // the library
+ // does not update chart options by itself.
+ JsArray chartAxisPlotBands = chartAxisOptions
+ .getPlotBands();
+ JsArray uidlAxisPlotBands = uidlAxisOptions
+ .getPlotBands();
+ if (uidlAxisPlotBands == null && chartAxisPlotBands == null) {
+ VConsole.log("No plotbands found.");
+ VConsole.log("Exit [updatePlotBands]");
+ return;
+ }
+ if (uidlAxisPlotBands == null) {
+ uidlAxisPlotBands = JavaScriptObject.createArray().cast();
+ }
+ if (chartAxisPlotBands == null) {
+ chartAxisPlotBands = JavaScriptObject.createArray().cast();
+ }
+ JsArray updatedChartAxisPlotBands = JavaScriptObject
+ .createArray().cast();
+ int numOfChartAxisPlotBands = chartAxisPlotBands.length();
+ int numOfUIDLAxisPlotBands = uidlAxisPlotBands.length();
+ boolean updatedAxisPlotBands = false;
+ for (int indOuter = 0; indOuter < numOfChartAxisPlotBands; indOuter++) {
+ GwtPlotBands chartPlotBand = chartAxisPlotBands.get(indOuter);
+ String plotBandId = chartPlotBand.getId();
+ boolean found = false;
+ for (int indInner = 0; indInner < numOfUIDLAxisPlotBands; indInner++) {
+ GwtPlotBands uidlPlotBand = uidlAxisPlotBands.get(indInner);
+ if (uidlPlotBand != null
+ && uidlPlotBand.getId().equals(plotBandId)) {
+ if (chartPlotBand.getFrom() == uidlPlotBand.getFrom()
+ && chartPlotBand.getTo() == uidlPlotBand.getTo()) {
+ VConsole.log("Plotband id "
+ + plotBandId
+ + " exists in chart as well as in UIDL from the server.");
+ // PlotBand exists and from/to values are same so
+ // nothing to be done.
+ // The UIDL plotband is set to null so that remaining
+ // plotbands
+ // can be safely added to the chart
+ uidlAxisPlotBands.set(indInner, null);
+ updatedChartAxisPlotBands.push(chartPlotBand);
+ VConsole.log("Plotband id " + plotBandId
+ + " exists in both.");
+ found = true;
+ }
+ break;
+ }
+ }
+ if (!found) {
+ // remove plot band as it is not found in UIDL received from the
+ // server
+ VConsole.log("Plotband id " + plotBandId + " removed.");
+ updatedAxisPlotBands = true;
+ chartAxis.removePlotBand(plotBandId);
+ }
+ }
+ // Add all remaining plot bands in UIDL to the chart
+ for (int ind = 0; ind < numOfUIDLAxisPlotBands; ind++) {
+ GwtPlotBands uidlPlotBand = uidlAxisPlotBands.get(ind);
+ if (uidlPlotBand != null) {
+ updatedAxisPlotBands = true;
+ VConsole.log("Plotband id " + uidlPlotBand.getId()
+ + " added with from : " + uidlPlotBand.getFrom()
+ + " and to: " + uidlPlotBand.getTo());
+ chartAxis.addPlotBand(uidlPlotBand);
+ updatedChartAxisPlotBands.push(uidlPlotBand);
+ }
+ }
+
+ // Update chart axis plotbands
+ if (updatedAxisPlotBands) {
+ setRedrawChart();
+ chartAxisOptions.setPlotBands(updatedChartAxisPlotBands);
+ }
+ VConsole.log("Exit [updatePlotBands]");
+ }
+
+ private boolean redrawChart = false;
+
+ private void setRedrawChart() {
+ this.redrawChart = true;
+ }
+
+ private boolean isRedrawChart() {
+ return this.redrawChart;
+ }
+
+ private void resetRedrawChart() {
+ this.redrawChart = false;
+ }
+
+ private void updateChartData(UIDL uidlChartDataUpdates, UIDL uidlChartData) {
+ VConsole.log("Enter [updateChartData]");
+ JsArrayString seriesToAdd = JavaScriptObject.createArray().cast();
+ JsArrayString seriesToUpdate = JavaScriptObject.createArray().cast();
+ List seriesToUpdateList = new ArrayList();
+ for (int ind = 0; ind < uidlChartDataUpdates.getChildCount(); ind++) {
+ UIDL seriesUpdateUIDL = uidlChartDataUpdates.getChildUIDL(ind);
+ String seriesName = seriesUpdateUIDL
+ .getStringAttribute("seriesName");
+ String operation = seriesUpdateUIDL.getStringAttribute("operation");
+ VConsole.log("Series name : " + seriesName + ", operation : "
+ + operation);
+ if (seriesName != null && seriesName.length() > 0
+ && operation != null && operation.length() > 0) {
+ if (SeriesCURType.REMOVE.getName().equals(operation)) {
+ GwtSeries series = chart.getSeries(seriesName);
+ if (series != null) {
+ VConsole.log("Removing series : " + seriesName);
+ setRedrawChart();
+ series.remove(false);
+ }
+ } else if (SeriesCURType.ADD.getName().equals(operation)) {
+ seriesToAdd.push(seriesName);
+ } else if (SeriesCURType.UPDATE.getName().equals(operation)) {
+ VConsole.log("Will update series : " + seriesName);
+ seriesToUpdateList.add(seriesUpdateUIDL);
+ seriesToUpdate.push(seriesName);
+ }
+ }
+ }
+
+ if (seriesToAdd.length() > 0) {
+ setRedrawChart();
+ JsArray uidlChartDataArr = getChartData(
+ uidlChartData, seriesToAdd);
+ for (int ind = 0; ind < uidlChartDataArr.length(); ind++) {
+ VConsole.log("Adding series "
+ + uidlChartDataArr.get(ind).getName());
+ chart.addSeries(uidlChartDataArr.get(ind), false);
+ }
+ }
+ if (seriesToUpdateList.size() > 0) {
+ setRedrawChart();
+ JsArray uidlChartDataArr = getChartData(
+ uidlChartData, seriesToUpdate);
+ for (int ind = 0; ind < seriesToUpdateList.size(); ind++) {
+ UIDL uidlSeriesToUpdate = seriesToUpdateList.get(ind);
+ GwtSeriesDataOptions uidlSeriesDataOptions = uidlChartDataArr
+ .get(ind);
+ GwtSeries chartSeries = chart.getSeries(uidlSeriesDataOptions
+ .getName());
+ GwtSeriesGeneralOptions chartSeriesOptions = chartSeries
+ .getSeriesGeneralOptions();
+ GwtSeriesGeneralOptions uidlSeriesOptions = uidlSeriesDataOptions
+ .getSeriesOptions();
+ // Update visibility
+ boolean isVisible = (uidlSeriesOptions != null ? uidlSeriesOptions
+ .isVisible() : true);
+ chartSeriesOptions.setVisible(isVisible);
+ if (chartSeriesOptions.isVisible() == true
+ && chartSeries.isVisible() == false) {
+ chartSeries.show();
+ }
+ if (chartSeriesOptions.isVisible() == false
+ && chartSeries.isVisible() == true) {
+ chartSeries.hide();
+ }
+ // Update points
+ if (uidlSeriesToUpdate.getBooleanAttribute("isReloadPoints")) {
+ // update all points
+ VConsole.log("Reloading points for series : "
+ + uidlSeriesToUpdate.getStringAttribute("name"));
+ chartSeries.setDataAsPointOptions(
+ uidlSeriesDataOptions.getDataAsPointOptions(),
+ false);
+ } else {
+ UIDL uidlPointsAdded = uidlSeriesToUpdate.getChildUIDL(0);
+ UIDL uidlPointsRemoved = uidlSeriesToUpdate.getChildUIDL(1);
+ updateSeriesData(chartSeries, uidlPointsAdded,
+ uidlPointsRemoved);
+ }
+ }
+ }
+
+ VConsole.log("Exit [updateChartData]");
+ }
+
+ private void updateSeriesData(GwtSeries chartSeries, UIDL uidlPointsAdded,
+ UIDL uidlPointsRemoved) {
+ VConsole.log("Enter [updateSeriesData]");
+ if (uidlPointsAdded != null && uidlPointsAdded.getChildCount() > 0) {
+ // Add points
+ JsArray pointsTobeAdded = getSeriesPoints(uidlPointsAdded);
+ VConsole.log("# of points to be added : "
+ + pointsTobeAdded.length());
+ for (int cnt = 0; cnt < pointsTobeAdded.length(); cnt++) {
+ GwtPointOptions pointOptions = pointsTobeAdded.get(cnt);
+ chartSeries.addPoint(pointOptions, false,
+ pointOptions.isShift());
+ }
+ }
+
+ if (uidlPointsRemoved != null && uidlPointsRemoved.getChildCount() > 0) {
+ // Remove points
+ JsArray pointsTobeRemoved = getSeriesPoints(uidlPointsRemoved);
+ VConsole.log("# of points to be removed : "
+ + pointsTobeRemoved.length());
+ JsArray chartSeriesData = chartSeries.getData();
+ for (int cnt = 0; cnt < pointsTobeRemoved.length(); cnt++) {
+ GwtPointOptions pointToRemove = pointsTobeRemoved.get(cnt);
+ for (int chartPointCnt = 0; chartPointCnt < chartSeriesData
+ .length(); chartPointCnt++) {
+ GwtPoint chartSeriesPoint = chartSeriesData
+ .get(chartPointCnt);
+ // Using Double.compareTo(another Double) does not result in
+ // appr. code which can be executed in JS correctly.
+ // e.g. x.compareTo(y) results in compare(x.value, y.value)
+ // where x.value is undefined in JS,
+ // Don't know the reason yet but will figure out. So do a
+ // direct comparison
+ if (chartSeriesPoint.getX() == pointToRemove.getX()
+ && chartSeriesPoint.getY() == pointToRemove.getY()) {
+ VConsole.log("Removing point ("
+ + chartSeriesPoint.getX() + ", "
+ + chartSeriesPoint.getY() + ")");
+ chartSeriesPoint.remove();
+ break;
+ }
+ }
+ }
+ }
+ VConsole.log("Exit [updateSeriesData]");
+ }
+
+ private static enum SeriesCURType {
+ ADD("Add"), UPDATE("Update"), REMOVE("Remove");
+ private String name;
+
+ private SeriesCURType(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+ }
+
+ private JsArray getChartData(UIDL uidl) {
+ return getChartData(uidl, null);
+ }
+
+ private boolean doesArrayContainSeriesName(
+ JsArrayString namesOfSeriesToAdd, String seriesName) {
+ for (int ind = 0; ind < namesOfSeriesToAdd.length(); ind++) {
+ if (seriesName.equals(namesOfSeriesToAdd.get(ind))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private JsArray getChartData(UIDL uidl,
+ JsArrayString namesOfSeriesToAdd) {
+ VConsole.log("Enter [getChartData]");
+
+ JsArray seriesDataArr = JavaScriptObject
+ .createArray().cast();
+ // Process each series data
+ for (int cnt = 0; cnt < uidl.getChildCount(); cnt++) {
+ GwtSeriesDataOptions seriesData = GwtSeriesDataOptions.create();
+ UIDL seriesUIDL = uidl.getChildUIDL(cnt);
+ String seriesName = seriesUIDL.getStringAttribute("name");
+ if (seriesName != null && namesOfSeriesToAdd != null) {
+ if (!doesArrayContainSeriesName(namesOfSeriesToAdd, seriesName)) {
+ continue;
+ }
+ }
+ // From charts series data retrieve only those series data
+ // whose names are specified in the second argument
+ if (seriesUIDL.hasAttribute("name")) {
+ // Setting name automatically sets series id which can later be
+ // used to retrieve using chart.get(id);
+ seriesData.setName(seriesName);
+ }
+ if (seriesUIDL.hasAttribute("stack")) {
+ seriesData.setStack(seriesUIDL.getStringAttribute("stack"));
+ }
+ // FIXME - fallback on chart options type if series doesn't have a
+ // type
+ String seriesType = "line";
+ if (seriesUIDL.hasAttribute("type")) {
+ seriesType = seriesUIDL.getStringAttribute("type");
+ seriesData.setType(seriesType);
+ }
+ if (seriesUIDL.hasAttribute("xAxis")) {
+ seriesData.setXAxis(seriesUIDL.getIntAttribute("xAxis"));
+ }
+ if (seriesUIDL.hasAttribute("yAxis")) {
+ seriesData.setYAxis(seriesUIDL.getIntAttribute("yAxis"));
+ }
+ // Get data/points
+ seriesData.setDataAsPointOptions(getSeriesPoints(seriesUIDL
+ .getChildUIDL(1)));
+ // Get series options
+ GwtSeriesGeneralOptions seriesOptions = getSeriesOptions(
+ seriesType, seriesUIDL.getChildUIDL(0));
+ if (seriesOptions != null) {
+ seriesData.setSeriesOptions(seriesOptions);
+ }
+
+ seriesDataArr.push(seriesData);
+ }
+
+ VConsole.log("Exit [getChartData]");
+ return seriesDataArr;
+ }
+
+ private JsArray getSeriesPoints(UIDL pointsUIDL) {
+ VConsole.log("Enter [getSeriesPoints]");
+
+ JsArray pointsArr = JavaScriptObject.createArray()
+ .cast();
+ for (int cnt = 0; cnt < pointsUIDL.getChildCount(); cnt++) {
+ UIDL pointUIDL = pointsUIDL.getChildUIDL(cnt);
+ GwtPointOptions pointOptions = GwtPointOptions.create();
+ // If a point doesn't have any attributes then
+ // consider it as a null since a user might want to represent
+ // no activity graph
+ if (pointUIDL.getAttributeNames().size() == 0) {
+ pointOptions.setNullY();
+ } else {
+ if (pointUIDL.hasAttribute("id")) {
+ pointOptions.setId(pointUIDL.getStringAttribute("id"));
+ }
+ if (pointUIDL.hasAttribute("name")) {
+ pointOptions.setName(pointUIDL.getStringAttribute("name"));
+ }
+ if (pointUIDL.hasAttribute("color")) {
+ pointOptions
+ .setColor(pointUIDL.getStringAttribute("color"));
+ }
+ if (pointUIDL.hasAttribute("sliced")) {
+ pointOptions.setSliced(pointUIDL
+ .getBooleanAttribute("sliced"));
+ }
+ if (pointUIDL.hasAttribute("selected")) {
+ pointOptions.setSelected(pointUIDL
+ .getBooleanAttribute("selected"));
+ }
+ if (pointUIDL.hasAttribute("x")) {
+ pointOptions.setX(pointUIDL.getIntAttribute("x"));
+ } else {
+ pointOptions.setNullX();
+ }
+ if (pointUIDL.hasAttribute("y")) {
+ pointOptions.setY(pointUIDL.getIntAttribute("y"));
+ } else {
+ pointOptions.setNullY();
+ }
+ if (pointUIDL.hasAttribute("isShift")) {
+ pointOptions.setShift(pointUIDL
+ .getBooleanAttribute("isShift"));
+ }
+ GwtMarker markerOptions = getMarkerOptions(pointUIDL
+ .getChildUIDL(0));
+ if (markerOptions != null) {
+ pointOptions.setMarker(markerOptions);
+ }
+ }
+ pointsArr.push(pointOptions);
+ }
+
+ VConsole.log("Exit [getSeriesPoints]");
+ return pointsArr;
+ }
+
+ private GwtInvientChartsConfig getInvientChartOptions(UIDL uidl) {
+ VConsole.log("Enter [getInvientChartOptions]");
+ VConsole.log("Child UIDL count : " + uidl.getChildCount());
+ GwtInvientChartsConfig options = GwtInvientChartsConfig.create();
+ // Get title UIDL
+ VConsole.log("Getting title options...");
+ // Title
+ options.setTitleOptions(getTitleOptions(uidl
+ .getChildUIDL(ChartOptionsUIDLIndex.TITLE.ordinal())));
+
+ VConsole.log("Getting subtitle options...");
+ // Subtitle
+ options.setSubtitleOptions(getSubtitleOptions(uidl
+ .getChildUIDL(ChartOptionsUIDLIndex.SUBTITLE.ordinal())));
+ // Credit
+ options.setCreditOptions(getCreditOptions(uidl
+ .getChildUIDL(ChartOptionsUIDLIndex.CREDIT.ordinal())));
+ // Legend
+ options.setLegendOptions(getLegendOptions(uidl
+ .getChildUIDL(ChartOptionsUIDLIndex.LEGEND.ordinal())));
+ // Tooltip
+ options.setTooltipOptions(getTooltipOptions(uidl
+ .getChildUIDL(ChartOptionsUIDLIndex.TOOLTIP.ordinal())));
+
+ // Then DEMO application
+ VConsole.log("Getting chart options...");
+ // Chart Options
+ options.setChartOptions(getChartOptions(uidl
+ .getChildUIDL(ChartOptionsUIDLIndex.CHART_CONFIG.ordinal())));
+
+ VConsole.log("Getting plot options...");
+ // Plot Options for various series types
+ options.setPlotOptions(getPlotOptions(uidl
+ .getChildUIDL(ChartOptionsUIDLIndex.SERIES_OPTIONS.ordinal())));
+
+ VConsole.log("Getting x-axis options...");
+ JsArray xAxisOptions = getXAxisOptions(uidl
+ .getChildUIDL(ChartOptionsUIDLIndex.X_AXES.ordinal()));
+ if (xAxisOptions.length() > 0) {
+ options.setXAxesOptions(xAxisOptions);
+ }
+
+ VConsole.log("Getting y-axis options...");
+ JsArray yAxisOptions = getYAxisOptions(uidl
+ .getChildUIDL(ChartOptionsUIDLIndex.Y_AXES.ordinal()));
+ if (yAxisOptions.length() > 0) {
+ options.setYAxesOptions(yAxisOptions);
+ }
+
+ VConsole.log("Getting chart labels...");
+ GwtChartLabels labels = getChartLabels(uidl
+ .getChildUIDL(ChartOptionsUIDLIndex.LABEL.ordinal()));
+ if (labels != null) {
+ options.setLabels(labels);
+ }
+
+ VConsole.log("Exit [getInvientChartOptions]");
+ return options;
+ }
+
+ private GwtChartLabels getChartLabels(UIDL uidl) {
+ VConsole.log("Enter [getChartLabels]");
+ VConsole.log("Tag name -> " + uidl.getTag());
+ if ((uidl.getAttributeNames().size() == 0 && uidl.getChildCount() == 0)
+ || (uidl.getAttributeNames().size() > 0 && uidl.getChildCount() == 0)) {
+ VConsole.log("Exit [getChartLabels]");
+ return null;
+ }
+ UIDL labelItemsUIDL = uidl.getChildUIDL(0);
+ if (labelItemsUIDL.getChildCount() == 0) {
+ VConsole.log("Exit [getChartLabels]");
+ return null;
+ }
+
+ GwtChartLabels labels = GwtChartLabels.create();
+ if (uidl.hasAttribute("style")) {
+ labels.setStyle(uidl.getStringAttribute("style"));
+ }
+
+ JsArray chartLabelItemsArr = JavaScriptObject
+ .createArray().cast();
+ for (int cnt = 0; cnt < labelItemsUIDL.getChildCount(); cnt++) {
+ UIDL labelItemUIDL = labelItemsUIDL.getChildUIDL(cnt);
+ if (labelItemUIDL.hasAttribute("html")
+ || labelItemUIDL.hasAttribute("style")) {
+ GwtChartLabelItem labelItem = GwtChartLabelItem.create();
+ if (labelItemUIDL.hasAttribute("html")) {
+ labelItem.setHtml(labelItemUIDL.getStringAttribute("html"));
+ }
+ //
+ if (labelItemUIDL.hasAttribute("style")) {
+ labelItem.setStyle(labelItemUIDL
+ .getStringAttribute("style"));
+ }
+ chartLabelItemsArr.push(labelItem);
+ }
+ }
+ labels.setItems(chartLabelItemsArr);
+ VConsole.log("Exit [getChartLabels]");
+ return labels;
+ }
+
+ private GwtCreditOptions getCreditOptions(UIDL uidl) {
+ VConsole.log("Enter [getCreditOptions]");
+ VConsole.log("Tag name -> " + uidl.getTag());
+ GwtCreditOptions creditOptions = GwtCreditOptions.create();
+
+ if (uidl.hasAttribute("enabled")) {
+ creditOptions.setEnabled(uidl.getBooleanAttribute("enabled"));
+ }
+ if (uidl.hasAttribute("href")) {
+ creditOptions.setHref(uidl.getStringAttribute("href"));
+ }
+ if (uidl.hasAttribute("style")) {
+ creditOptions.setStyle(uidl.getStringAttribute("style"));
+ }
+ if (uidl.hasAttribute("text")) {
+ creditOptions.setText(uidl.getStringAttribute("text"));
+ }
+ UIDL positionUIDL = uidl.getChildUIDL(0);
+ GwtPosition position = GwtPosition.create();
+ if (positionUIDL.hasAttribute("align")) {
+ position.setAlign(positionUIDL.getStringAttribute("align"));
+ }
+ if (positionUIDL.hasAttribute("verticalAlign")) {
+ position.setVerticalAlign(positionUIDL
+ .getStringAttribute("verticalAlign"));
+ }
+ if (positionUIDL.hasAttribute("x")) {
+ position.setX(positionUIDL.getIntAttribute("x"));
+ }
+ if (positionUIDL.hasAttribute("y")) {
+ position.setY(positionUIDL.getIntAttribute("y"));
+ }
+ creditOptions.setPosition(position);
+
+ VConsole.log("Exit [getCreditOptions]");
+ return creditOptions;
+ }
+
+ private GwtLegendOptions getLegendOptions(UIDL uidl) {
+ VConsole.log("Enter [getLegendOptions]");
+ VConsole.log("Tag name -> " + uidl.getTag());
+
+ GwtLegendOptions legendOptions = GwtLegendOptions.create();
+ if (uidl.hasAttribute("align")) {
+ legendOptions.setAlign(uidl.getStringAttribute("align"));
+ }
+ if (uidl.hasAttribute("backgroundColor")) {
+ legendOptions.setBackgroundColor(uidl
+ .getStringAttribute("backgroundColor"));
+ }
+ if (uidl.hasAttribute("borderColor")) {
+ legendOptions
+ .setBorderColor(uidl.getStringAttribute("borderColor"));
+ }
+ if (uidl.hasAttribute("borderRadius")) {
+ legendOptions.setBorderRadius(uidl.getIntAttribute("borderRadius"));
+ }
+ if (uidl.hasAttribute("borderWidth")) {
+ legendOptions.setBorderWidth(uidl.getIntAttribute("borderWidth"));
+ }
+ if (uidl.hasAttribute("enabled")) {
+ legendOptions.setEnabled(uidl.getBooleanAttribute("enabled"));
+ }
+ if (uidl.hasAttribute("floating")) {
+ legendOptions.setFloating(uidl.getBooleanAttribute("floating"));
+ }
+ if (uidl.hasAttribute("itemHiddenStyle")) {
+ legendOptions.setItemHiddenStyle(uidl
+ .getStringAttribute("itemHiddenStyle"));
+ }
+ if (uidl.hasAttribute("itemHoverStyle")) {
+ legendOptions.setItemHoverStyle(uidl
+ .getStringAttribute("itemHoverStyle"));
+ }
+ if (uidl.hasAttribute("itemStyle")) {
+ legendOptions.setItemStyle(uidl.getStringAttribute("itemStyle"));
+ }
+ if (uidl.hasAttribute("itemWidth")) {
+ legendOptions.setItemWidth(uidl.getIntAttribute("itemWidth"));
+ }
+ if (uidl.hasAttribute("layout")) {
+ legendOptions.setLayout(uidl.getStringAttribute("layout"));
+ }
+ if (uidl.hasAttribute("labelFormatter")) {
+ legendOptions.setLabelFormatter(getExecutableFunction(uidl
+ .getStringAttribute("labelFormatter")));
+ }
+ if (uidl.hasAttribute("margin")) {
+ legendOptions.setMargin(uidl.getIntAttribute("margin"));
+ }
+ if (uidl.hasAttribute("reversed")) {
+ legendOptions.setReversed(uidl.getBooleanAttribute("reversed"));
+ }
+ if (uidl.hasAttribute("shadow")) {
+ legendOptions.setShadow(uidl.getBooleanAttribute("shadow"));
+ }
+ if (uidl.hasAttribute("symbolPadding")) {
+ legendOptions.setSymbolPadding(uidl
+ .getIntAttribute("symbolPadding"));
+ }
+ if (uidl.hasAttribute("symbolWidth")) {
+ legendOptions.setSymbolWidth(uidl.getIntAttribute("symbolWidth"));
+ }
+ if (uidl.hasAttribute("verticalAlign")) {
+ legendOptions.setVerticalAlign(uidl
+ .getStringAttribute("verticalAlign"));
+ }
+ if (uidl.hasAttribute("width")) {
+ legendOptions.setWidth(uidl.getIntAttribute("width"));
+ }
+ if (uidl.hasAttribute("x")) {
+ legendOptions.setX(uidl.getIntAttribute("x"));
+ }
+ if (uidl.hasAttribute("y")) {
+ legendOptions.setY(uidl.getIntAttribute("y"));
+ }
+
+ VConsole.log("Exit [getLegendOptions]");
+ return legendOptions;
+ }
+
+ private GwtTooltipOptions getTooltipOptions(UIDL uidl) {
+ VConsole.log("Enter [getTooltipOptions]");
+ VConsole.log("Tag name -> " + uidl.getTag());
+ GwtTooltipOptions tooltipOptions = GwtTooltipOptions.create();
+
+ if(uidl.getChildByTagName("crosshairs") != null) {
+ tooltipOptions
+ .setCrosshairs(getTooltipCrosshairs(uidl.getChildByTagName("crosshairs")));
+ }
+ if (uidl.hasAttribute("backgroundColor")) {
+ tooltipOptions.setBackgroundColor(uidl
+ .getStringAttribute("backgroundColor"));
+ }
+ if (uidl.hasAttribute("borderColor")) {
+ tooltipOptions.setBorderColor(uidl
+ .getStringAttribute("borderColor"));
+ }
+ if (uidl.hasAttribute("borderRadius")) {
+ tooltipOptions
+ .setBorderRadius(uidl.getIntAttribute("borderRadius"));
+ }
+ if (uidl.hasAttribute("borderWidth")) {
+ tooltipOptions.setBorderWidth(uidl.getIntAttribute("borderWidth"));
+ }
+ if (uidl.hasAttribute("enabled")) {
+ tooltipOptions.setEnabled(uidl.getBooleanAttribute("enabled"));
+ }
+ if (uidl.hasAttribute("formatter")) {
+ tooltipOptions.setFormatter(getExecutableFunction(uidl
+ .getStringAttribute("formatter")));
+ }
+ if (uidl.hasAttribute("shadow")) {
+ tooltipOptions.setShadow(uidl.getBooleanAttribute("shadow"));
+ }
+ if (uidl.hasAttribute("shared")) {
+ tooltipOptions.setShared(uidl.getBooleanAttribute("shared"));
+ }
+ if (uidl.hasAttribute("snap")) {
+ tooltipOptions.setSnap(uidl.getIntAttribute("snap"));
+ }
+ if (uidl.hasAttribute("style")) {
+ tooltipOptions.setStyle(uidl.getStringAttribute("style"));
+ }
+ if (uidl.hasAttribute("useHTML")) {
+ tooltipOptions.setUseHTML(uidl.getBooleanAttribute("useHTML"));
+ }
+ if (uidl.hasAttribute("headerFormat")) {
+ tooltipOptions.setHeaderFormat(uidl.getStringAttribute("headerFormat"));
+ }
+ if (uidl.hasAttribute("pointFormat")) {
+ tooltipOptions.setPointFormat(uidl.getStringAttribute("pointFormat"));
+ }
+ if (uidl.hasAttribute("footerFormat")) {
+ tooltipOptions.setFooterFormat(uidl.getStringAttribute("footerFormat"));
+ }
+
+ VConsole.log("Exit [getTooltipOptions]");
+ return tooltipOptions;
+ }
+
+ private GwtTooltipCrosshairs getTooltipCrosshairs(UIDL uidl) {
+ VConsole.log("Enter [getTooltipCrosshairs]");
+ VConsole.log("Tag name -> " + uidl.getTag());
+ GwtTooltipCrosshairs crosshairs = GwtTooltipCrosshairs.create();
+ if (uidl.hasAttribute("width")) {
+ crosshairs.setWidth(uidl.getDoubleAttribute("width"));
+ }
+ if (uidl.hasAttribute("color")) {
+ crosshairs.setColor(uidl.getStringAttribute("color"));
+ }
+ if (uidl.hasAttribute("dashStyle")) {
+ crosshairs.setDashstyle(uidl.getStringAttribute("dashStyle"));
+ }
+ if (uidl.hasAttribute("zIndex")) {
+ crosshairs.setZIndex(uidl.getIntAttribute("zIndex"));
+ }
+ VConsole.log("Exit [getTooltipCrosshairs]");
+ return crosshairs;
+ }
+
+ private GwtTitleOptions getTitleOptions(UIDL uidl) {
+ VConsole.log("Enter [getTitleOptions]");
+ VConsole.log("Tag Name : " + uidl.getTag());
+ GwtTitleOptions titleOptions = GwtTitleOptions.createTitleOptions();
+ updateTitleBaseOptions(uidl, titleOptions);
+
+ if (uidl.hasAttribute("margin")) {
+ titleOptions.setMargin(uidl.getIntAttribute("margin"));
+ }
+
+ VConsole.log("Exit [getTitleOptions]");
+ return titleOptions;
+ }
+
+ private GwtSubtitleOptions getSubtitleOptions(UIDL uidl) {
+ VConsole.log("Enter [getSubtitleOptions]");
+ VConsole.log("Tag Name : " + uidl.getTag());
+ GwtSubtitleOptions subtitleOptions = GwtSubtitleOptions
+ .createSubtitleOptions();
+ updateTitleBaseOptions(uidl, subtitleOptions);
+ VConsole.log("Exit [getTitleOptions]");
+ return subtitleOptions;
+ }
+
+ private void updateTitleBaseOptions(UIDL uidl,
+ GwtTitleBaseOptions titleBaseOptions) {
+ VConsole.log("Enter [updateTitleBaseOptions]");
+ VConsole.log("Tag Name : " + uidl.getTag());
+ if (uidl.hasAttribute("text")) {
+ titleBaseOptions.setText(uidl.getStringAttribute("text"));
+ }
+ if (uidl.hasAttribute("align")) {
+ titleBaseOptions.setAlign(uidl.getStringAttribute("align"));
+ }
+ if (uidl.hasAttribute("floating")) {
+ titleBaseOptions.setFloating(uidl.getBooleanAttribute("floating"));
+ }
+ if (uidl.hasAttribute("style")) {
+ titleBaseOptions.setStyle(uidl.getStringAttribute("style"));
+ }
+ if (uidl.hasAttribute("verticalAlign")) {
+ titleBaseOptions.setVerticalAlign(uidl
+ .getStringAttribute("verticalAlign"));
+ }
+ if (uidl.hasAttribute("x")) {
+ titleBaseOptions.setX(uidl.getIntAttribute("x"));
+ }
+ if (uidl.hasAttribute("y")) {
+ titleBaseOptions.setY(uidl.getIntAttribute("y"));
+ }
+
+ VConsole.log("Exit [updateTitleBaseOptions]");
+ }
+
+ private GwtChartOptions getChartOptions(UIDL uidl) {
+ VConsole.log("Enter [getChartOptions]");
+ VConsole.log("Tag Name : " + uidl.getTag());
+
+ GwtChartOptions chartOptions = GwtChartOptions.create();
+ // DIV - A container for the InvientChart
+ chartOptions.setRenderTo(super.divId);
+
+ if (uidl.hasAttribute("type")) {
+ chartOptions.setType(uidl.getStringAttribute("type"));
+ }
+ if (uidl.hasAttribute("width")) {
+ chartOptions.setWidth(uidl.getIntAttribute("width"));
+ }
+ if (uidl.hasAttribute("height")) {
+ chartOptions.setHeight(uidl.getIntAttribute("height"));
+ }
+ if (uidl.hasAttribute("backgroundColor")) {
+ chartOptions.setBackgroundColor(uidl
+ .getStringAttribute("backgroundColor"));
+ }
+ if (uidl.hasAttribute("borderColor")) {
+ chartOptions.setBorderColor(uidl.getStringAttribute("borderColor"));
+ }
+ if (uidl.hasAttribute("borderRadius")) {
+ chartOptions.setBorderRadius(uidl.getIntAttribute("borderRadius"));
+ }
+ if (uidl.hasAttribute("borderWidth")) {
+ chartOptions.setBorderWidth(uidl.getIntAttribute("borderWidth"));
+ }
+ if (uidl.hasAttribute("ignoreHiddenSeries")) {
+ chartOptions.setIgnoreHiddenSeries(uidl
+ .getBooleanAttribute("ignoreHiddenSeries"));
+ }
+ if (uidl.hasAttribute("inverted")) {
+ chartOptions.setInverted(uidl.getBooleanAttribute("inverted"));
+ }
+ if (uidl.hasAttribute("marginTop")) {
+ chartOptions.setMarginTop(uidl.getIntAttribute("marginTop"));
+ }
+ if (uidl.hasAttribute("marginLeft")) {
+ chartOptions.setMarginLeft(uidl.getIntAttribute("marginLeft"));
+ }
+ if (uidl.hasAttribute("marginRight")) {
+ chartOptions.setMarginRight(uidl.getIntAttribute("marginRight"));
+ }
+ if (uidl.hasAttribute("marginBottom")) {
+ chartOptions.setMarginBottom(uidl.getIntAttribute("marginBottom"));
+ }
+ if (uidl.hasAttribute("spacingTop")) {
+ chartOptions.setSpacingTop(uidl.getIntAttribute("spacingTop"));
+ }
+ if (uidl.hasAttribute("spacingLeft")) {
+ chartOptions.setSpacingLeft(uidl.getIntAttribute("spacingLeft"));
+ }
+ if (uidl.hasAttribute("spacingRight")) {
+ chartOptions.setSpacingRight(uidl.getIntAttribute("spacingRight"));
+ }
+ if (uidl.hasAttribute("spacingBottom")) {
+ chartOptions
+ .setSpacingBottom(uidl.getIntAttribute("spacingBottom"));
+ }
+ if (uidl.hasAttribute("showAxes")) {
+ chartOptions.setShowAxes(uidl.getBooleanAttribute("showAxes"));
+ }
+ if (uidl.hasAttribute("zoomType")) {
+ chartOptions.setZoomType(uidl.getStringAttribute("zoomType"));
+ }
+ if (uidl.hasAttribute("clientZoom")) {
+ chartOptions.setClientZoom(uidl.getBooleanAttribute("clientZoom"));
+ }
+
+ if (uidl.hasAttribute("alignTicks")) {
+ chartOptions.setAlignTicks(uidl.getBooleanAttribute("alignTicks"));
+ }
+ if (uidl.hasAttribute("animation")) {
+ chartOptions.setAnimation(uidl.getBooleanAttribute("animation"));
+ }
+ if (uidl.hasAttribute("className")) {
+ chartOptions.setClassName(uidl.getStringAttribute("className"));
+ }
+ if (uidl.hasAttribute("plotBackgroundColor")) {
+ chartOptions.setPlotBackgroundColor(uidl
+ .getStringAttribute("plotBackgroundColor"));
+ }
+ if (uidl.hasAttribute("plotBorderColor")) {
+ chartOptions.setPlotBorderColor(uidl
+ .getStringAttribute("plotBorderColor"));
+ }
+ if (uidl.hasAttribute("plotBackgroundImage")) {
+ chartOptions.setPlotBackgroundImage(uidl
+ .getStringAttribute("plotBackgroundImage"));
+ }
+ if (uidl.hasAttribute("plotBorderWidth")) {
+ chartOptions.setPlotBorderWidth(uidl
+ .getIntAttribute("plotBorderWidth"));
+ }
+ if (uidl.hasAttribute("plotShadow")) {
+ chartOptions.setPlotShadow(uidl.getBooleanAttribute("plotShadow"));
+ }
+ if (uidl.hasAttribute("reflow")) {
+ chartOptions.setReflow(uidl.getBooleanAttribute("reflow"));
+ }
+ if (uidl.hasAttribute("shadow")) {
+ chartOptions.setShadow(uidl.getBooleanAttribute("shadow"));
+ }
+ if (uidl.hasAttribute("style")) {
+ chartOptions.setStyle(uidl.getStringAttribute("style"));
+ }
+
+ VConsole.log("Exit [getChartOptions]");
+ return chartOptions;
+ }
+
+ private void updateBaseAxisOptions(UIDL axisUIDL,
+ GwtAxisBaseOptions axisBaseOptions) {
+ VConsole.log("Enter [updateBaseAxisOptions]");
+ if (axisUIDL.hasAttribute("id")) {
+ axisBaseOptions.setId(axisUIDL.getStringAttribute("id"));
+ }
+ if (axisUIDL.hasAttribute("allowDecimals")) {
+ axisBaseOptions.setAllowDecimals(axisUIDL
+ .getBooleanAttribute("allowDecimals"));
+ }
+ if (axisUIDL.hasAttribute("alternateGridColor")) {
+ axisBaseOptions.setAlternateGridColor(axisUIDL
+ .getStringAttribute("alternateGridColor"));
+ }
+ if (axisUIDL.hasAttribute("endOnTick")) {
+ axisBaseOptions.setEndOnTick(axisUIDL
+ .getBooleanAttribute("endOnTick"));
+ }
+ // Grid
+ if (axisUIDL.hasAttribute("gridLineColor")) {
+ axisBaseOptions.setGridLineColor(axisUIDL
+ .getStringAttribute("gridLineColor"));
+ }
+ if (axisUIDL.hasAttribute("gridLineWidth")) {
+ axisBaseOptions.setGridLineWidth(axisUIDL
+ .getIntAttribute("gridLineWidth"));
+ }
+ if (axisUIDL.hasAttribute("gridLineDashStyle")) {
+ axisBaseOptions.setGridLineDashStyle(axisUIDL
+ .getStringAttribute("gridLineDashStyle"));
+ }
+ // Line
+ if (axisUIDL.hasAttribute("lineColor")) {
+ axisBaseOptions.setLineColor(axisUIDL
+ .getStringAttribute("lineColor"));
+ }
+ if (axisUIDL.hasAttribute("lineWidth")) {
+ axisBaseOptions.setLineWidth(axisUIDL.getIntAttribute("lineWidth"));
+ }
+ //
+ if (axisUIDL.hasAttribute("linkedTo")) {
+ axisBaseOptions.setLinkedTo(axisUIDL.getIntAttribute("linkedTo"));
+ }
+
+ if (axisUIDL.hasAttribute("max")) {
+ axisBaseOptions.setMax(axisUIDL.getDoubleAttribute("max"));
+ }
+ if (axisUIDL.hasAttribute("maxPadding")) {
+ axisBaseOptions.setMaxPadding(axisUIDL
+ .getDoubleAttribute("maxPadding"));
+ }
+ if (axisUIDL.hasAttribute("maxZoom")) {
+ axisBaseOptions.setMaxZoom(axisUIDL.getIntAttribute("maxZoom"));
+ }
+
+ //
+ if (axisUIDL.hasAttribute("min")) {
+ axisBaseOptions.setMin(axisUIDL.getDoubleAttribute("min"));
+ }
+ if (axisUIDL.hasAttribute("minPadding")) {
+ axisBaseOptions.setMinPadding(axisUIDL
+ .getDoubleAttribute("minPadding"));
+ }
+ // Minor Grid
+ if (axisUIDL.hasAttribute("minorGridLineColor")) {
+ axisBaseOptions.setMinorGridLineColor(axisUIDL
+ .getStringAttribute("minorGridLineColor"));
+ }
+ if (axisUIDL.hasAttribute("minorGridLineWidth")) {
+ axisBaseOptions.setMinorGridLineWidth(axisUIDL
+ .getIntAttribute("minorGridLineWidth"));
+ }
+ if (axisUIDL.hasAttribute("minorGridLineDashStyle")) {
+ axisBaseOptions.setMinorGridLineDashStyle(axisUIDL
+ .getStringAttribute("minorGridLineDashStyle"));
+ }
+ // Minor Ticks
+ if (axisUIDL.hasAttribute("minorTickColor")) {
+ axisBaseOptions.setMinorTickColor(axisUIDL
+ .getStringAttribute("minorTickColor"));
+ }
+ if (axisUIDL.hasAttribute("minorTickInterval")) {
+ axisBaseOptions.setMinorTickInterval(axisUIDL
+ .getDoubleAttribute("minorTickInterval"));
+ }
+ if (axisUIDL.hasAttribute("minorTickLength")) {
+ axisBaseOptions.setMinorTickLength(axisUIDL
+ .getIntAttribute("minorTickLength"));
+ }
+ if (axisUIDL.hasAttribute("minorTickPosition")) {
+ axisBaseOptions.setMinorTickPosition(axisUIDL
+ .getStringAttribute("minorTickPosition"));
+ }
+ if (axisUIDL.hasAttribute("minorTickWidth")) {
+ axisBaseOptions.setMinorTickWidth(axisUIDL
+ .getIntAttribute("minorTickWidth"));
+ }
+ //
+ if (axisUIDL.hasAttribute("offset")) {
+ axisBaseOptions.setOffset(axisUIDL.getIntAttribute("offset"));
+ }
+ if (axisUIDL.hasAttribute("opposite")) {
+ axisBaseOptions.setOpposite(axisUIDL
+ .getBooleanAttribute("opposite"));
+ }
+ if (axisUIDL.hasAttribute("reversed")) {
+ axisBaseOptions.setReversed(axisUIDL
+ .getBooleanAttribute("reversed"));
+ }
+ if (axisUIDL.hasAttribute("showFirstLabel")) {
+ axisBaseOptions.setShowFirstLabel(axisUIDL
+ .getBooleanAttribute("showFirstLabel"));
+ }
+ if (axisUIDL.hasAttribute("showLastLabel")) {
+ axisBaseOptions.setShowLastLabel(axisUIDL
+ .getBooleanAttribute("showLastLabel"));
+ }
+ if (axisUIDL.hasAttribute("startOfWeek")) {
+ axisBaseOptions.setStartOfWeek(axisUIDL
+ .getIntAttribute("startOfWeek"));
+ }
+ if (axisUIDL.hasAttribute("startOnTick")) {
+ axisBaseOptions.setStartOnTick(axisUIDL
+ .getBooleanAttribute("startOnTick"));
+ }
+ // Tick
+ if (axisUIDL.hasAttribute("tickColor")) {
+ axisBaseOptions.setTickColor(axisUIDL
+ .getStringAttribute("tickColor"));
+ }
+ if (axisUIDL.hasAttribute("tickInterval")) {
+ axisBaseOptions.setTickInterval(axisUIDL
+ .getDoubleAttribute("tickInterval"));
+ }
+ if (axisUIDL.hasAttribute("tickLength")) {
+ axisBaseOptions.setTickLength(axisUIDL
+ .getIntAttribute("tickLength"));
+ }
+ if (axisUIDL.hasAttribute("tickPosition")) {
+ axisBaseOptions.setTickPosition(axisUIDL
+ .getStringAttribute("tickPosition"));
+ }
+ if (axisUIDL.hasAttribute("tickWidth")) {
+ axisBaseOptions.setTickWidth(axisUIDL.getIntAttribute("tickWidth"));
+ }
+ if (axisUIDL.hasAttribute("tickPixelInterval")) {
+ axisBaseOptions.setTickPixelInterval(axisUIDL
+ .getIntAttribute("tickPixelInterval"));
+ }
+ if (axisUIDL.hasAttribute("tickmarkPlacement")) {
+ axisBaseOptions.setTickmarkPlacement(axisUIDL
+ .getStringAttribute("tickmarkPlacement"));
+ }
+
+ if (axisUIDL.hasAttribute("type")) {
+ axisBaseOptions.setType(axisUIDL.getStringAttribute("type"));
+ }
+
+ // title
+ UIDL titleUIDL = axisUIDL.getChildUIDL(0);
+ GwtAxisTitleOptions titleOptions = getAxisTitleOptions(titleUIDL);
+ if (titleOptions != null) {
+ axisBaseOptions.setTitle(titleOptions);
+ }
+
+ // label
+ UIDL labelUIDL = axisUIDL.getChildUIDL(1);
+ String axisName = axisUIDL.getTag();
+ GwtAxisDataLabels axisDataLabels = getAxisDataLabels(labelUIDL,
+ axisName);
+ if (axisDataLabels != null) {
+ axisBaseOptions.setLabels(axisDataLabels);
+ }
+ // plotband
+ UIDL plotBandsUIDL = axisUIDL.getChildUIDL(2);
+ JsArray plotBands = getPlotBands(plotBandsUIDL);
+ if (plotBands.length() > 0) {
+ axisBaseOptions.setPlotBands(plotBands);
+ }
+ // plotline
+ UIDL plotLinesUIDL = axisUIDL.getChildUIDL(3);
+ JsArray plotLines = getPlotLines(plotLinesUIDL);
+ if (plotLines.length() > 0) {
+ axisBaseOptions.setPlotLines(plotLines);
+ }
+ VConsole.log("Exit [updateBaseAxisOptions]");
+ }
+
+ private GwtAxisTitleOptions getAxisTitleOptions(UIDL axisTitleUIDL) {
+ if (axisTitleUIDL == null
+ || axisTitleUIDL.getAttributeNames().size() == 0) {
+ return null;
+ }
+ GwtAxisTitleOptions titleOptions = GwtAxisTitleOptions.create();
+ if (axisTitleUIDL.hasAttribute("align")) {
+ titleOptions.setAlign(axisTitleUIDL.getStringAttribute("align"));
+ }
+ if (axisTitleUIDL.hasAttribute("margin")) {
+ titleOptions.setMargin(axisTitleUIDL.getIntAttribute("margin"));
+ }
+ if (axisTitleUIDL.hasAttribute("rotation")) {
+ titleOptions.setRotation(axisTitleUIDL.getIntAttribute("rotation"));
+ }
+ if (axisTitleUIDL.hasAttribute("style")) {
+ titleOptions.setStyle(axisTitleUIDL.getStringAttribute("style"));
+ }
+ if (axisTitleUIDL.hasAttribute("text")) {
+ titleOptions.setText(axisTitleUIDL.getStringAttribute("text"));
+ }
+ return titleOptions;
+ }
+
+ private JsArray getPlotBands(UIDL plotBandsUIDL) {
+ JsArray plotBandsArr = JavaScriptObject.createArray()
+ .cast();
+ for (int cnt = 0; cnt < plotBandsUIDL.getChildCount(); cnt++) {
+ UIDL plotBandUIDL = plotBandsUIDL.getChildUIDL(cnt);
+ if (plotBandUIDL.getAttributeNames().size() == 0
+ && plotBandUIDL.getChildCount() == 0) {
+ continue;
+ }
+ GwtPlotBands plotBands = GwtPlotBands.create();
+ if (plotBandUIDL.hasAttribute("color")) {
+ plotBands.setColor(plotBandUIDL.getStringAttribute("color"));
+ }
+ if (plotBandUIDL.hasAttribute("id")) {
+ plotBands.setId(plotBandUIDL.getStringAttribute("id"));
+ }
+ if (plotBandUIDL.hasAttribute("zIndex")) {
+ plotBands.setZIndex(plotBandUIDL.getIntAttribute("zIndex"));
+ }
+ // label
+ GwtPlotLabel label = getPlotLabel(plotBandUIDL.getChildUIDL(0));
+ if (label != null) {
+ plotBands.setLabel(label);
+ }
+ // from/to value
+ UIDL valueUIDL = plotBandUIDL.getChildUIDL(1);
+ if (valueUIDL.hasAttribute("valueType")) {
+ String valueType = valueUIDL.getStringAttribute("valueType");
+ if (valueType.equals("number")) {
+ plotBands.setFrom(valueUIDL.getDoubleAttribute("from"));
+ plotBands.setTo(valueUIDL.getDoubleAttribute("to"));
+ } else { // date
+ // from
+ UIDL fromUIDL = valueUIDL.getChildUIDL(0);
+ int fromYear = fromUIDL.getIntAttribute("year");
+ int fromMonth = fromUIDL.getIntAttribute("month");
+ int fromDay = fromUIDL.getIntAttribute("day");
+ plotBands.setFrom("Date.UTC(" + fromYear + ", " + fromMonth
+ + "," + fromDay + ")");
+ // to
+ UIDL toUIDL = valueUIDL.getChildUIDL(1);
+ int toYear = toUIDL.getIntAttribute("year");
+ int toMonth = toUIDL.getIntAttribute("month");
+ int toDay = toUIDL.getIntAttribute("day");
+ plotBands.setTo("Date.UTC(" + toYear + ", " + toMonth + ","
+ + toDay + ")");
+ }
+ }
+ //
+ plotBandsArr.push(plotBands);
+ }
+ return plotBandsArr;
+ }
+
+ private JsArray getPlotLines(UIDL plotLinesUIDL) {
+ JsArray plotLinesArr = JavaScriptObject.createArray()
+ .cast();
+ for (int cnt = 0; cnt < plotLinesUIDL.getChildCount(); cnt++) {
+ UIDL plotLineUIDL = plotLinesUIDL.getChildUIDL(cnt);
+ if (plotLineUIDL.getAttributeNames().size() == 0
+ && plotLineUIDL.getChildCount() == 0) {
+ continue;
+ }
+ GwtPlotLines plotLines = GwtPlotLines.create();
+ if (plotLineUIDL.hasAttribute("color")) {
+ plotLines.setColor(plotLineUIDL.getStringAttribute("color"));
+ }
+ if (plotLineUIDL.hasAttribute("dashStyle")) {
+ plotLines.setDashStyle(plotLineUIDL
+ .getStringAttribute("dashStyle"));
+ }
+ if (plotLineUIDL.hasAttribute("id")) {
+ plotLines.setId(plotLineUIDL.getStringAttribute("id"));
+ }
+ if (plotLineUIDL.hasAttribute("width")) {
+ plotLines.setWidth(plotLineUIDL.getIntAttribute("width"));
+ }
+ if (plotLineUIDL.hasAttribute("zIndex")) {
+ plotLines.setZIndex(plotLineUIDL.getIntAttribute("zIndex"));
+ }
+ // label
+ GwtPlotLabel label = getPlotLabel(plotLineUIDL.getChildUIDL(0));
+ if (label != null) {
+ plotLines.setLabel(label);
+ }
+ // line value
+ UIDL lineValueUIDL = plotLineUIDL.getChildUIDL(1);
+ if (lineValueUIDL.hasAttribute("valueType")) {
+ String valueType = lineValueUIDL
+ .getStringAttribute("valueType");
+ if (valueType.equals("number")) {
+ if (lineValueUIDL.hasAttribute("value")) {
+ plotLines.setValue(lineValueUIDL
+ .getDoubleAttribute("value"));
+ }
+ } else { // date
+ int year = lineValueUIDL.getIntAttribute("year");
+ int month = lineValueUIDL.getIntAttribute("month");
+ int day = lineValueUIDL.getIntAttribute("day");
+ plotLines.setValue("Date.UTC(" + year + ", " + month + ","
+ + day + ")");
+ }
+ }
+ //
+ plotLinesArr.push(plotLines);
+ }
+ return plotLinesArr;
+ }
+
+ private GwtPlotLabel getPlotLabel(UIDL plotLabelUIDL) {
+ if (plotLabelUIDL == null
+ || plotLabelUIDL.getAttributeNames().size() == 0) {
+ return null;
+ }
+ GwtPlotLabel label = GwtPlotLabel.create();
+ if (plotLabelUIDL.hasAttribute("align")) {
+ label.setAlign(plotLabelUIDL.getStringAttribute("align"));
+ }
+ if (plotLabelUIDL.hasAttribute("rotation")) {
+ label.setRotation(plotLabelUIDL.getIntAttribute("rotation"));
+ }
+ if (plotLabelUIDL.hasAttribute("style")) {
+ label.setStyle(plotLabelUIDL.getStringAttribute("style"));
+ }
+ if (plotLabelUIDL.hasAttribute("align")) {
+ label.setAlign(plotLabelUIDL.getStringAttribute("align"));
+ }
+ if (plotLabelUIDL.hasAttribute("text")) {
+ label.setText(plotLabelUIDL.getStringAttribute("text"));
+ }
+ if (plotLabelUIDL.hasAttribute("verticalAlign")) {
+ label.setVerticalAlign(plotLabelUIDL
+ .getStringAttribute("verticalAlign"));
+ }
+ if (plotLabelUIDL.hasAttribute("x")) {
+ label.setX(plotLabelUIDL.getIntAttribute("x"));
+ }
+ if (plotLabelUIDL.hasAttribute("y")) {
+ label.setY(plotLabelUIDL.getIntAttribute("y"));
+ }
+
+ return label;
+ }
+
+ // FIXME - Code organization
+ private GwtAxisDataLabels getAxisDataLabels(UIDL labelUIDL, String axisName) {
+ if (labelUIDL == null || labelUIDL.getAttributeNames().size() == 0) {
+ return null;
+ }
+ if (axisName.equals("xAxis")) {
+ GwtXAxisDataLabels labels = GwtXAxisDataLabels.createXAxisLabels();
+ updateDataLabel(labelUIDL, labels);
+ if (labelUIDL.hasAttribute("staggerLines")) {
+ labels.setStaggerLines(labelUIDL
+ .getIntAttribute("staggerLines"));
+ }
+ if (labelUIDL.hasAttribute("step")) {
+ labels.setStep(labelUIDL.getIntAttribute("step"));
+ }
+ return labels;
+ } else {
+ GwtYAxisDataLabels labels = GwtYAxisDataLabels.createYAxisLabels();
+ updateDataLabel(labelUIDL, labels);
+ return labels;
+ }
+ }
+
+ private JsArray getXAxisOptions(UIDL uidl) {
+ VConsole.log("Enter [getXAxisOptions]");
+ VConsole.log("Tag Name : " + uidl.getTag());
+ JsArray xAxes = JavaScriptObject.createArray().cast();
+
+ for (int cnt = 0; cnt < uidl.getChildCount(); cnt++) {
+ GwtXAxisOptions xAxisOptions = GwtXAxisOptions.create();
+ UIDL axisUIDL = uidl.getChildUIDL(cnt);
+ if (axisUIDL.getAttributeNames().size() == 0
+ && axisUIDL.getChildCount() == 0) {
+ continue;
+ }
+ updateBaseAxisOptions(axisUIDL, xAxisOptions);
+
+ UIDL childUIDL = axisUIDL.getChildUIDL(4);
+ if (childUIDL != null) {
+ if (childUIDL.getTag().equals("categories")
+ && childUIDL.getChildCount() > 0) {
+ JsArrayString categories = JavaScriptObject.createArray()
+ .cast();
+ UIDL categoriesUIDL = childUIDL;
+ for (int idx = 0; idx < categoriesUIDL.getChildCount(); idx++) {
+ categories.push(categoriesUIDL.getChildUIDL(idx)
+ .getStringAttribute("name"));
+ }
+ xAxisOptions.setCategories(categories);
+ } else if (childUIDL.getTag().equals("dateTimeLabelFormats")
+ && childUIDL.getAttributeNames().size() > 0) {
+ UIDL dateTimeLblFmtsUIDL = childUIDL;
+ GwtDateTimeLabelFormats formats = GwtDateTimeLabelFormats
+ .create();
+ if (dateTimeLblFmtsUIDL.hasAttribute("millisecond")) {
+ formats.setMillisecond(dateTimeLblFmtsUIDL
+ .getStringAttribute("millisecond"));
+ }
+ if (dateTimeLblFmtsUIDL.hasAttribute("second")) {
+ formats.setSecond(dateTimeLblFmtsUIDL
+ .getStringAttribute("second"));
+ }
+ if (dateTimeLblFmtsUIDL.hasAttribute("minute")) {
+ formats.setMinute(dateTimeLblFmtsUIDL
+ .getStringAttribute("minute"));
+ }
+ if (dateTimeLblFmtsUIDL.hasAttribute("hour")) {
+ formats.setHour(dateTimeLblFmtsUIDL
+ .getStringAttribute("hour"));
+ }
+ if (dateTimeLblFmtsUIDL.hasAttribute("day")) {
+ formats.setDay(dateTimeLblFmtsUIDL
+ .getStringAttribute("day"));
+ }
+ if (dateTimeLblFmtsUIDL.hasAttribute("week")) {
+ formats.setWeek(dateTimeLblFmtsUIDL
+ .getStringAttribute("week"));
+ }
+ if (dateTimeLblFmtsUIDL.hasAttribute("month")) {
+ formats.setMonth(dateTimeLblFmtsUIDL
+ .getStringAttribute("month"));
+ }
+ if (dateTimeLblFmtsUIDL.hasAttribute("year")) {
+ formats.setYear(dateTimeLblFmtsUIDL
+ .getStringAttribute("year"));
+ }
+ xAxisOptions.setDateTimeLabelFormats(formats);
+ }
+ }
+ xAxes.push(xAxisOptions);
+ }
+
+ VConsole.log("Exit [getXAxisOptions]");
+ return xAxes;
+ }
+
+ private JsArray getYAxisOptions(UIDL uidl) {
+ VConsole.log("Enter [getYAxisOptions]");
+ VConsole.log("Tag Name : " + uidl.getTag());
+ JsArray yAxes = JavaScriptObject.createArray().cast();
+
+ for (int cnt = 0; cnt < uidl.getChildCount(); cnt++) {
+ GwtYAxisOptions yAxisOptions = GwtYAxisOptions.create();
+ UIDL axisUIDL = uidl.getChildUIDL(cnt);
+ if (axisUIDL.getAttributeNames().size() == 0
+ && axisUIDL.getChildCount() == 0) {
+ continue;
+ }
+ updateBaseAxisOptions(axisUIDL, yAxisOptions);
+ yAxes.push(yAxisOptions);
+ }
+
+ VConsole.log("Exit [getYAxisOptions]");
+ return yAxes;
+ }
+
+ private GwtPlotOptions getPlotOptions(UIDL uidl) {
+ VConsole.log("Enter [getPlotOptions]");
+ VConsole.log("Tag Name : " + uidl.getTag());
+
+ GwtPlotOptions plotOptions = GwtPlotOptions.create();
+
+ for (int cnt = 0; cnt < uidl.getChildCount(); cnt++) {
+ UIDL seriesUIDL = uidl.getChildUIDL(cnt);
+ String seriesType = seriesUIDL.getTag();
+ VConsole.log("Series Type : " + seriesType);
+ GwtSeriesGeneralOptions seriesOptions = getSeriesOptions(
+ seriesType, seriesUIDL);
+ if (seriesOptions == null) {
+ continue;
+ }
+ if (seriesType.equals("series")) {
+ plotOptions.setSeries(seriesOptions);
+ } else if (seriesType.equals("line")) {
+ plotOptions.setLine((GwtLineOptions) seriesOptions);
+ } else if (seriesType.equals("scatter")) {
+ plotOptions.setScatter((GwtScatterOptions) seriesOptions);
+ } else if (seriesType.equals("spline")) {
+ plotOptions.setSpline((GwtSplineOptions) seriesOptions);
+ } else if (seriesType.equals("area")) {
+ plotOptions.setArea((GwtAreaOptions) seriesOptions);
+ } else if (seriesType.equals("areaspline")) {
+ plotOptions.setAreaSpline((GwtAreaSplineOptions) seriesOptions);
+ } else if (seriesType.equals("bar")) {
+ plotOptions.setBar((GwtBarOptions) seriesOptions);
+ } else if (seriesType.equals("column")) {
+ plotOptions.setColumn((GwtColumnOptions) seriesOptions);
+ } else if (seriesType.equals("pie")) {
+ plotOptions.setPie((GwtPieOptions) seriesOptions);
+ }
+ }
+
+ VConsole.log("Exit [getPlotOptions]");
+ return plotOptions;
+ }
+
+ private GwtSeriesGeneralOptions getSeriesOptions(String seriesType,
+ UIDL seriesUIDL) {
+ VConsole.log("Enter [getSeriesOptions]");
+ VConsole.log("Tag Name : " + seriesUIDL.getTag());
+ if (seriesUIDL.getAttributeNames().size() == 0
+ && seriesUIDL.getChildCount() == 0) {
+ VConsole.log("No attributes/children found for series type : "
+ + seriesType);
+ VConsole.log("Exit [getSeriesOptions]");
+ return null;
+ }
+ GwtSeriesGeneralOptions seriesOptions = null;
+ if (seriesType.equals("series")) {
+ seriesOptions = GwtSeriesGeneralOptions.createSeriesOptions();
+ updateSeriesOptions(seriesUIDL, seriesOptions);
+ } else if (seriesType.equals("line")) {
+ seriesOptions = GwtLineOptions.createLineOptions();
+ updateLineOptions(seriesUIDL, (GwtLineOptions) seriesOptions);
+ } else if (seriesType.equals("scatter")) {
+ seriesOptions = GwtScatterOptions.createScatterOptions();
+ updateScatterOptions(seriesUIDL, (GwtScatterOptions) seriesOptions);
+ } else if (seriesType.equals("spline")) {
+ seriesOptions = GwtSplineOptions.createSplineOptions();
+ updateSplineOptions(seriesUIDL, (GwtSplineOptions) seriesOptions);
+ } else if (seriesType.equals("area")) {
+ seriesOptions = GwtAreaOptions.createAreaOptions();
+ updateAreaOptions(seriesUIDL, (GwtAreaOptions) seriesOptions);
+ } else if (seriesType.equals("areaspline")) {
+ seriesOptions = GwtAreaSplineOptions.createAreaSplineOptions();
+ updateAreaSplineOptions(seriesUIDL,
+ (GwtAreaSplineOptions) seriesOptions);
+ } else if (seriesType.equals("bar")) {
+ seriesOptions = GwtBarOptions.createBarOptions();
+ updateBarOptions(seriesUIDL, (GwtBarOptions) seriesOptions);
+ } else if (seriesType.equals("column")) {
+ seriesOptions = GwtColumnOptions.createColumnOptions();
+ updateColumnOptions(seriesUIDL, (GwtColumnOptions) seriesOptions);
+ } else if (seriesType.equals("pie")) {
+ seriesOptions = GwtPieOptions.createPieOptions();
+ updatePieOptions(seriesUIDL, (GwtPieOptions) seriesOptions);
+ } else {
+ // This should not happen
+ VConsole.log("[getSeriesOptions] : Invalid series type "
+ + seriesType);
+ }
+ VConsole.log("Exit [getSeriesOptions]");
+ return seriesOptions;
+ }
+
+ private void updateSeriesOptions(UIDL seriesUIDL,
+ GwtSeriesGeneralOptions seriesOptions) {
+ VConsole.log("Enter [updateSeriesOptions]");
+ VConsole.log("Tag Name : " + seriesUIDL.getTag());
+
+ if (seriesUIDL.hasAttribute("allowPointSelect")) {
+ seriesOptions.setAllowPointSelect(seriesUIDL
+ .getBooleanAttribute("allowPointSelect"));
+ }
+ if (seriesUIDL.hasAttribute("animation")) {
+ seriesOptions.setAnimation(seriesUIDL
+ .getBooleanAttribute("animation"));
+ }
+ if (seriesUIDL.hasAttribute("cursor")) {
+ seriesOptions.setCursor(seriesUIDL.getStringAttribute("cursor"));
+ }
+ if (seriesUIDL.hasAttribute("enableMouseTracking")) {
+ seriesOptions.setEnableMouseTracking(seriesUIDL
+ .getBooleanAttribute("enableMouseTracking"));
+ }
+ if (seriesUIDL.hasAttribute("selected")) {
+ seriesOptions.setSelected(seriesUIDL
+ .getBooleanAttribute("selected"));
+ }
+ if (seriesUIDL.hasAttribute("shadow")) {
+ seriesOptions.setShadow(seriesUIDL.getBooleanAttribute("shadow"));
+ }
+ if (seriesUIDL.hasAttribute("showCheckbox")) {
+ seriesOptions.setShowCheckbox(seriesUIDL
+ .getBooleanAttribute("showCheckbox"));
+ }
+ if (seriesUIDL.hasAttribute("showInLegend")) {
+ seriesOptions.setShowInLegend(seriesUIDL
+ .getBooleanAttribute("showInLegend"));
+ }
+ if (seriesUIDL.hasAttribute("stacking")) {
+ seriesOptions
+ .setStacking(seriesUIDL.getStringAttribute("stacking"));
+ }
+ if (seriesUIDL.hasAttribute("visible")) {
+ seriesOptions.setVisible(seriesUIDL.getBooleanAttribute("visible"));
+ }
+ if (seriesUIDL.hasAttribute("color")) {
+ seriesOptions.setColor(seriesUIDL.getStringAttribute("color"));
+ }
+ // FIXME - How to get series type
+ // datalabels
+ GwtDataLabels dataLabels = getSeriesDataLabel(
+ seriesUIDL.getChildUIDL(0), seriesUIDL.getTag());
+ if (dataLabels != null) {
+ seriesOptions.setDataLabels(dataLabels);
+ }
+
+ // state
+ GwtStates seriesState = getSeriesState(seriesUIDL.getChildUIDL(1));
+
+ if (seriesState != null) {
+ seriesOptions.setStates(seriesState);
+ }
+
+ VConsole.log("Exit [updateSeriesOptions]");
+ }
+
+ private GwtDataLabels getSeriesDataLabel(UIDL dataLabelUIDL,
+ String seriesType) {
+ VConsole.log("Enter [getSeriesDataLabel]");
+ if (dataLabelUIDL == null
+ || dataLabelUIDL.getAttributeNames().size() == 0) {
+ return null;
+ }
+ GwtDataLabels dataLabel = GwtDataLabels.createDataLabels();
+ if (seriesType.equals("pie")) {
+ dataLabel = GwtPieDataLabels.createPieDataLabels();
+ updatePieDataLabel(dataLabelUIDL, (GwtPieDataLabels) dataLabel);
+ } else {
+ updateDataLabel(dataLabelUIDL, dataLabel);
+ }
+ VConsole.log("Exit [getSeriesDataLabel]");
+ return dataLabel;
+ }
+
+ private void updatePieDataLabel(UIDL dataLabelUIDL,
+ GwtPieDataLabels pieDataLabel) {
+ updateDataLabel(dataLabelUIDL, pieDataLabel);
+ if (dataLabelUIDL.hasAttribute("connectorColor")) {
+ pieDataLabel.setConnectorColor(dataLabelUIDL
+ .getStringAttribute("connectorColor"));
+ }
+ if (dataLabelUIDL.hasAttribute("connectorWidth")) {
+ pieDataLabel.setConnectorWidth(dataLabelUIDL
+ .getIntAttribute("connectorWidth"));
+ }
+ if (dataLabelUIDL.hasAttribute("connectorPadding")) {
+ pieDataLabel.setConnectorPadding(dataLabelUIDL
+ .getIntAttribute("connectorPadding"));
+ }
+ if (dataLabelUIDL.hasAttribute("distance")) {
+ pieDataLabel.setDistance(dataLabelUIDL.getIntAttribute("distance"));
+ }
+ }
+
+ private void updateDataLabel(UIDL dataLabelUIDL, GwtDataLabels dataLabel) {
+ if (dataLabelUIDL.hasAttribute("align")) {
+ dataLabel.setAlign(dataLabelUIDL.getStringAttribute("align"));
+ }
+ if (dataLabelUIDL.hasAttribute("enabled")) {
+ dataLabel.setEnabled(dataLabelUIDL.getBooleanAttribute("enabled"));
+ }
+ if (dataLabelUIDL.hasAttribute("formatter")) {
+ dataLabel.setFormatter(getExecutableFunction(dataLabelUIDL
+ .getStringAttribute("formatter")));
+ }
+ if (dataLabelUIDL.hasAttribute("rotation")) {
+ dataLabel.setRotation(dataLabelUIDL.getIntAttribute("rotation"));
+ }
+ if (dataLabelUIDL.hasAttribute("style")) {
+ dataLabel.setStyle(dataLabelUIDL.getStringAttribute("style"));
+ }
+ if (dataLabelUIDL.hasAttribute("x")) {
+ dataLabel.setX(dataLabelUIDL.getIntAttribute("x"));
+ }
+ if (dataLabelUIDL.hasAttribute("y")) {
+ dataLabel.setY(dataLabelUIDL.getIntAttribute("y"));
+ }
+ if (dataLabelUIDL.hasAttribute("color")) {
+ dataLabel.setColor(dataLabelUIDL.getStringAttribute("color"));
+ }
+ }
+
+ private GwtStates getSeriesState(UIDL stateUIDL) {
+ if (stateUIDL == null
+ || (stateUIDL != null && stateUIDL.getChildCount() == 0)
+ || (stateUIDL.getChildCount() > 0 && stateUIDL.getChildUIDL(0)
+ .getAttributeNames().size() == 0)) {
+ return null;
+ }
+ GwtStates state = GwtStates.create();
+ GwtHover hover = GwtHover.create();
+ state.setHover(hover);
+ UIDL hoverUIDL = stateUIDL.getChildUIDL(0);
+ if (hoverUIDL.hasAttribute("enabled")) {
+ hover.setEnabled(hoverUIDL.getBooleanAttribute("enabled"));
+ }
+ if (hoverUIDL.hasAttribute("lineWidth")) {
+ hover.setLineWidth(hoverUIDL.getIntAttribute("lineWidth"));
+ }
+ if (hoverUIDL.hasAttribute("brightness")) {
+ hover.setBrightness(hoverUIDL.getDoubleAttribute("brightness"));
+ }
+ return state;
+ }
+
+ private GwtMarker getMarkerOptions(UIDL uidl) {
+ VConsole.log("Enter [getMarkerOptions]");
+ int noOfAttrs = 0;
+ noOfAttrs = (uidl != null ? uidl.getAttributeNames().size() : 0);
+ if (uidl == null || (noOfAttrs == 0 && uidl.getChildCount() == 0)) {
+ VConsole.log("Exit [getMarkerOptions]");
+ return null;
+ }
+ GwtMarker marker = GwtMarker.create();
+ String markerType = uidl.getStringAttribute("markerType");
+ if (uidl.hasAttribute("enabled")) {
+ marker.setEnabled(uidl.getBooleanAttribute("enabled"));
+ }
+ if (uidl.hasAttribute("lineColor")) {
+ marker.setLineColor(uidl.getStringAttribute("lineColor"));
+ }
+ if (uidl.hasAttribute("fillColor")) {
+ marker.setFillColor(uidl.getStringAttribute("fillColor"));
+ }
+ if (uidl.hasAttribute("lineWidth")) {
+ marker.setLineWidth(uidl.getIntAttribute("lineWidth"));
+ }
+ if (uidl.hasAttribute("radius")) {
+ marker.setRadius(uidl.getIntAttribute("radius"));
+ }
+ if (uidl.hasAttribute("symbol")) {
+ if (markerType.equals("image")) {
+ marker.setSymbol("url(." + uidl.getStringAttribute("symbol")
+ + ")");
+ } else {
+ marker.setSymbol(uidl.getStringAttribute("symbol"));
+ }
+ }
+
+ // Marker states exist only in case of SymbolMarker and not ImageMarker
+ if (uidl.getChildCount() > 0) {
+ UIDL statesUIDL = uidl.getChildUIDL(0);
+ UIDL hoverStateUIDL = statesUIDL.getChildUIDL(0);
+ UIDL selectStateUIDL = statesUIDL.getChildUIDL(1);
+ GwtMarkerState markerHoverState = getMarkerState(hoverStateUIDL);
+ GwtMarkerState markerSelectState = getMarkerState(selectStateUIDL);
+ if (markerHoverState != null || markerSelectState != null) {
+ VConsole.log("Setting marker states...");
+ GwtMarkerStates markerStates = GwtMarkerStates.create();
+ if (markerHoverState != null) {
+ markerStates.setHover(markerHoverState);
+ }
+ if (markerSelectState != null) {
+ markerStates.setSelect(markerSelectState);
+ }
+ marker.setStates(markerStates);
+ }
+ }
+ VConsole.log("Exit [getMarkerOptions]");
+ return marker;
+ }
+
+ private GwtMarkerState getMarkerState(UIDL uidl) {
+ VConsole.log("Enter [getMarkerState]");
+ if (uidl == null || uidl.getAttributeNames().size() == 0) {
+ VConsole.log("Neither hover nor select states found for a maker.");
+ VConsole.log("Exit [getMarkerState]");
+ return null;
+ }
+ GwtMarkerState markerState = GwtMarkerState.create();
+ if (uidl.hasAttribute("enabled")) {
+ markerState.setEnabled(uidl.getBooleanAttribute("enabled"));
+ }
+ if (uidl.hasAttribute("lineColor")) {
+ markerState.setLineColor(uidl.getStringAttribute("lineColor"));
+ }
+ if (uidl.hasAttribute("fillColor")) {
+ markerState.setFillColor(uidl.getStringAttribute("fillColor"));
+ }
+ if (uidl.hasAttribute("lineWidth")) {
+ markerState.setLineWidth(uidl.getIntAttribute("lineWidth"));
+ }
+ if (uidl.hasAttribute("radius")) {
+ markerState.setRadius(uidl.getIntAttribute("radius"));
+ }
+ VConsole.log("Exit [getMarkerState]");
+ return markerState;
+ }
+
+ private void updateBaseLineOptions(UIDL lineUIDL,
+ GwtBaseLineOptions lineOptions) {
+ VConsole.log("Enter [updateBaseLineOptions]");
+
+ updateSeriesOptions(lineUIDL, lineOptions);
+ if (lineUIDL.hasAttribute("color")) {
+ lineOptions.setColor(lineUIDL.getStringAttribute("color"));
+ }
+ if (lineUIDL.hasAttribute("dashStyle")) {
+ lineOptions.setDashStyle(lineUIDL.getStringAttribute("dashStyle"));
+ }
+ if (lineUIDL.hasAttribute("lineWidth")) {
+ lineOptions.setLineWidth(lineUIDL.getIntAttribute("lineWidth"));
+ }
+ if (lineUIDL.hasAttribute("pointStart")) {
+ lineOptions.setPointStart(lineUIDL.getDoubleAttribute("pointStart"));
+ }
+ if (lineUIDL.hasAttribute("pointInterval")) {
+ lineOptions.setPointInterval(lineUIDL
+ .getIntAttribute("pointInterval"));
+ }
+ if (lineUIDL.hasAttribute("turboThreshold")) {
+ lineOptions.setTurboThreshold(lineUIDL
+ .getIntAttribute("turboThreshold"));
+ }
+ if (lineUIDL.hasAttribute("stickyTracking")) {
+ lineOptions.setStickyTracking(lineUIDL
+ .getBooleanAttribute("stickyTracking"));
+ }
+
+ GwtMarker marker = getMarkerOptions(lineUIDL.getChildUIDL(2));
+ if (marker != null) {
+ lineOptions.setMarker(marker);
+ }
+ VConsole.log("Exit [updateBaseLineOptions]");
+ }
+
+ private void updateLineOptions(UIDL lineUIDL, GwtLineOptions lineOptions) {
+ VConsole.log("Enter [updateLineOptions]");
+ VConsole.log("Tag Name : " + lineUIDL.getTag());
+
+ updateBaseLineOptions(lineUIDL, lineOptions);
+
+ if (lineUIDL.hasAttribute("step")) {
+ lineOptions.setStep(lineUIDL.getBooleanAttribute("step"));
+ }
+
+ VConsole.log("Exit [updateBaseLineOptions]");
+ }
+
+ private void updateScatterOptions(UIDL scatterUIDL,
+ GwtScatterOptions scatterOptions) {
+ VConsole.log("Enter [updateScatterOptions]");
+ VConsole.log("Tag Name : " + scatterUIDL.getTag());
+
+ updateBaseLineOptions(scatterUIDL, scatterOptions);
+
+ VConsole.log("Exit [updateScatterOptions]");
+ }
+
+ private void updateSplineOptions(UIDL splineUIDL,
+ GwtSplineOptions splineOptions) {
+ VConsole.log("Enter [updateSplineOptions]");
+ VConsole.log("Tag Name : " + splineUIDL.getTag());
+
+ updateBaseLineOptions(splineUIDL, splineOptions);
+
+ VConsole.log("Exit [updateSplineOptions]");
+ }
+
+ private void updateAreaOptions(UIDL areaUIDL, GwtAreaOptions areaOptions) {
+ VConsole.log("Enter [updateAreaOptions]");
+ VConsole.log("Tag Name : " + areaUIDL.getTag());
+
+ updateBaseLineOptions(areaUIDL, areaOptions);
+ if (areaUIDL.hasAttribute("fillColor")) {
+ areaOptions.setFillColor(areaUIDL.getStringAttribute("fillColor"));
+ }
+ if (areaUIDL.hasAttribute("lineColor")) {
+ areaOptions.setLineColor(areaUIDL.getStringAttribute("lineColor"));
+ }
+ if (areaUIDL.hasAttribute("fillOpacity")) {
+ areaOptions.setFillOpacity(areaUIDL
+ .getDoubleAttribute("fillOpacity"));
+ }
+ if (areaUIDL.hasAttribute("threshold")) {
+ areaOptions.setThreshold(areaUIDL.getIntAttribute("threshold"));
+ }
+
+ VConsole.log("Exit [updateAreaOptions]");
+ }
+
+ private void updateAreaSplineOptions(UIDL areaSplineUIDL,
+ GwtAreaSplineOptions areaSplineOptions) {
+ VConsole.log("Enter [updateAreaSplineOptions]");
+ VConsole.log("Tag Name : " + areaSplineUIDL.getTag());
+
+ updateAreaOptions(areaSplineUIDL, areaSplineOptions);
+
+ VConsole.log("Exit [updateAreaSplineOptions]");
+ }
+
+ private void updatePieOptions(UIDL pieUIDL, GwtPieOptions pieOptions) {
+ VConsole.log("Enter [updatePieOptions]");
+ VConsole.log("Tag Name : " + pieUIDL.getTag());
+
+ updateSeriesOptions(pieUIDL, pieOptions);
+ Integer centerX = null;
+ Integer centerY = null;
+ if (pieUIDL.hasAttribute("centerX")) {
+ centerX = pieUIDL.getIntAttribute("centerX");
+ }
+ if (pieUIDL.hasAttribute("centerY")) {
+ centerY = pieUIDL.getIntAttribute("centerY");
+ }
+ if (centerX != null || centerY != null) {
+ JsArrayNumber center = JavaScriptObject.createArray().cast();
+ center.push((centerX == null ? 0 : centerX));
+ center.push((centerY == null ? 0 : centerY));
+ pieOptions.setCenter(center);
+ }
+ if (pieUIDL.hasAttribute("borderColor")) {
+ pieOptions
+ .setBorderColor(pieUIDL.getStringAttribute("borderColor"));
+ }
+ if (pieUIDL.hasAttribute("borderWidth")) {
+ pieOptions.setBorderWidth(pieUIDL.getDoubleAttribute("borderWidth"));
+ }
+ if (pieUIDL.hasAttribute("innerSize")) {
+ pieOptions.setInnerSize(pieUIDL.getIntAttribute("innerSize"));
+ }
+ if (pieUIDL.hasAttribute("ignoreHiddenPoint")) {
+ pieOptions.setIgnoreHiddenPoint(pieUIDL.getBooleanAttribute("ignoreHiddenPoint"));
+ }
+ if (pieUIDL.hasAttribute("size")) {
+ pieOptions.setSize(pieUIDL.getIntAttribute("size"));
+ }
+ if (pieUIDL.hasAttribute("slicedOffset")) {
+ pieOptions.setSlicedOffset(pieUIDL.getIntAttribute("slicedOffset"));
+ }
+
+ VConsole.log("Exit [updatePieOptions]");
+ }
+
+ private void updateBaseBarOptions(UIDL barUIDL,
+ GwtBaseBarOptions baseBarOptions) {
+ VConsole.log("Enter [updateBaseBarOptions]");
+
+ updateSeriesOptions(barUIDL, baseBarOptions);
+ if (barUIDL.hasAttribute("borderColor")) {
+ baseBarOptions.setBorderColor(barUIDL
+ .getStringAttribute("borderColor"));
+ }
+ if (barUIDL.hasAttribute("borderWidth")) {
+ baseBarOptions.setBorderWidth(barUIDL
+ .getIntAttribute("borderWidth"));
+ }
+ if (barUIDL.hasAttribute("borderRadius")) {
+ baseBarOptions.setBorderRadius(barUIDL
+ .getIntAttribute("borderRadius"));
+ }
+ if (barUIDL.hasAttribute("colorByPoint")) {
+ baseBarOptions.setColorByPoint(barUIDL
+ .getBooleanAttribute("colorByPoint"));
+ }
+ if (barUIDL.hasAttribute("groupPadding")) {
+ baseBarOptions.setGroupPadding(barUIDL
+ .getDoubleAttribute("groupPadding"));
+ }
+ if (barUIDL.hasAttribute("minPointLength")) {
+ baseBarOptions.setMinPointLength(barUIDL
+ .getDoubleAttribute("minPointLength"));
+ }
+ if (barUIDL.hasAttribute("pointPadding")) {
+ baseBarOptions.setPointPadding(barUIDL
+ .getDoubleAttribute("pointPadding"));
+ }
+ if (barUIDL.hasAttribute("pointWidth")) {
+ baseBarOptions.setPointWidth(barUIDL.getIntAttribute("pointWidth"));
+ }
+
+ VConsole.log("Exit [updateBaseBarOptions]");
+ }
+
+ private void updateBarOptions(UIDL barUIDL, GwtBarOptions barOptions) {
+ VConsole.log("Enter [updateBarOptions]");
+ VConsole.log("Tag Name : " + barUIDL.getTag());
+
+ updateBaseBarOptions(barUIDL, barOptions);
+
+ VConsole.log("Exit [updateBarOptions]");
+ }
+
+ private void updateColumnOptions(UIDL columnUIDL,
+ GwtColumnOptions columnOptions) {
+ VConsole.log("Enter [updateColumnOptions]");
+ VConsole.log("Tag Name : " + columnUIDL.getTag());
+
+ updateBaseBarOptions(columnUIDL, columnOptions);
+
+ VConsole.log("Exit [updateColumnOptions]");
+ }
+
+ private void updateOptionsWithChartEvents(GwtInvientChartsConfig options,
+ UIDL chartEventUIDL) {
+ VConsole.log("Enter [updateOptionsWithChartEvents]");
+
+ // Chart events
+ GwtChartEvents chartEvents = GwtChartEvents.create();
+ if (chartEventUIDL.hasAttribute("addSeries")
+ && chartEventUIDL.getBooleanAttribute("addSeries")) {
+ chartEvents.setAddSeriesEvent(EventCallbacks
+ .getChartAddSeries(this));
+ }
+ if (chartEventUIDL.hasAttribute("click")
+ && chartEventUIDL.getBooleanAttribute("click")) {
+ chartEvents.setClickEvent(EventCallbacks.getChartClick(this));
+ }
+ if (chartEventUIDL.hasAttribute("selection")
+ && chartEventUIDL.getBooleanAttribute("selection")) {
+ if (options.getChartOptions().getClientZoom()) {
+ chartEvents.setSelectionEvent(EventCallbacks
+ .getClientChartSelection(this));
+ } else {
+ chartEvents.setSelectionEvent(EventCallbacks
+ .getServerChartSelection(this));
+ }
+ }
+ if (options.getChartOptions() == null) {
+ options.setChartOptions(GwtChartOptions.create());
+ }
+ options.getChartOptions().setEvents(chartEvents);
+
+ VConsole.log("Exit [updateOptionsWithChartEvents]");
+ }
+
+ private GwtSeriesEvents getSeriesEvents(UIDL seriesEventUIDL) {
+ GwtSeriesEvents seriesEvents = GwtSeriesEvents.create();
+ boolean foundEvt = false;
+ if (seriesEventUIDL.hasAttribute("legendItemClick")
+ && seriesEventUIDL.getBooleanAttribute("legendItemClick")) {
+ seriesEvents.setLegendItemClickEvent(EventCallbacks
+ .getSeriesLegendItemClick(this));
+ foundEvt = true;
+ }
+ if (seriesEventUIDL.hasAttribute("click")
+ && seriesEventUIDL.getBooleanAttribute("click")) {
+ seriesEvents.setClickEvent(EventCallbacks.getSeriesClick(this));
+ foundEvt = true;
+ }
+ if (seriesEventUIDL.hasAttribute("show")
+ && seriesEventUIDL.getBooleanAttribute("show")) {
+ seriesEvents.setShowEvent(EventCallbacks.getSeriesShow(this));
+ foundEvt = true;
+ }
+ if (seriesEventUIDL.hasAttribute("hide")
+ && seriesEventUIDL.getBooleanAttribute("hide")) {
+ seriesEvents.setHideEvent(EventCallbacks.getSeriesHide(this));
+ foundEvt = true;
+ }
+ if (foundEvt) {
+ return seriesEvents;
+ }
+ return null;
+ }
+
+ private void updateOptionsWithSeriesAndPoingEvents(
+ GwtInvientChartsConfig options, UIDL chartSeriesEventsUIDL) {
+ VConsole.log("Enter [updateOptionsWithSeriesAndPoingEvents]");
+ VConsole.log("[updateOptionsWithSeriesEvents] # of series : "
+ + chartSeriesEventsUIDL.getChildCount());
+
+ // UIDL seriesEventUIDL = eventUIDL.getChildUIDL(1);
+ if (chartSeriesEventsUIDL.getChildCount() > 0
+ && options.getPlotOptions() == null) {
+ options.setPlotOptions(GwtPlotOptions.create());
+ }
+ for (int cnt = 0; cnt < chartSeriesEventsUIDL.getChildCount(); cnt++) {
+ UIDL seriesEventsUIDL = chartSeriesEventsUIDL.getChildUIDL(cnt);
+ String seriesType = seriesEventsUIDL.getTag(); // can be
+ // series/pie/line
+ // etc
+ VConsole.log("Series type " + seriesType);
+ //
+ GwtSeriesEvents seriesEvents = getSeriesEvents(seriesEventsUIDL);
+ //
+ GwtPointEvents pointEvents = null;
+ if (seriesEventsUIDL.getChildCount() > 0) {
+ pointEvents = getPointEvents(options,
+ seriesEventsUIDL.getChildUIDL(0));
+ }
+ if (seriesEvents == null && pointEvents == null) {
+ VConsole.log("No series/point events found for series type : "
+ + seriesType);
+ continue;
+ }
+ GwtSeriesGeneralOptions seriesOptions = null;
+ if (seriesType.equals("line")) {
+ if (options.getPlotOptions().getLine() == null) {
+ options.getPlotOptions().setLine(
+ GwtLineOptions.createLineOptions());
+ }
+ seriesOptions = options.getPlotOptions().getLine();
+ } else if (seriesType.equals("spline")) {
+ if (options.getPlotOptions().getSpline() == null) {
+ options.getPlotOptions().setSpline(
+ GwtSplineOptions.createSplineOptions());
+ }
+ seriesOptions = options.getPlotOptions().getSpline();
+ } else if (seriesType.equals("area")) {
+ if (options.getPlotOptions().getArea() == null) {
+ options.getPlotOptions().setArea(
+ GwtAreaOptions.createAreaOptions());
+ }
+ seriesOptions = options.getPlotOptions().getArea();
+ } else if (seriesType.equals("areaspline")) {
+ if (options.getPlotOptions().getAreaSpline() == null) {
+ options.getPlotOptions().setAreaSpline(
+ GwtAreaSplineOptions.createAreaSplineOptions());
+ }
+ seriesOptions = options.getPlotOptions().getAreaSpline();
+ } else if (seriesType.equals("bar")) {
+ if (options.getPlotOptions().getBar() == null) {
+ options.getPlotOptions().setBar(
+ GwtBarOptions.createBarOptions());
+ }
+ seriesOptions = options.getPlotOptions().getBar();
+ } else if (seriesType.equals("column")) {
+ if (options.getPlotOptions().getColumn() == null) {
+ options.getPlotOptions().setColumn(
+ GwtColumnOptions.createColumnOptions());
+ }
+ seriesOptions = options.getPlotOptions().getColumn();
+ } else if (seriesType.equals("scatter")) {
+ if (options.getPlotOptions().getScatter() == null) {
+ options.getPlotOptions().setScatter(
+ GwtScatterOptions.createScatterOptions());
+ }
+ seriesOptions = options.getPlotOptions().getScatter();
+ } else if (seriesType.equals("pie")) {
+ if (options.getPlotOptions().getPie() == null) {
+ options.getPlotOptions().setPie(
+ GwtPieOptions.createPieOptions());
+ }
+ seriesOptions = options.getPlotOptions().getPie();
+ } else {
+ if (options.getPlotOptions().getSeries() == null) {
+ options.getPlotOptions().setSeries(
+ GwtSeriesGeneralOptions.createSeriesOptions());
+ }
+ seriesOptions = options.getPlotOptions().getSeries();
+ }
+ // Set series/point events
+ if (seriesEvents != null) {
+ seriesOptions.setEvents(seriesEvents);
+ }
+ if (pointEvents != null) {
+ seriesOptions.setPointEvents(pointEvents);
+ }
+ }
+ VConsole.log("Exit [updateOptionsWithSeriesAndPoingEvents]");
+ }
+
+ private GwtPointEvents getPointEvents(GwtInvientChartsConfig options,
+ UIDL pointEventsUIDL) {
+ VConsole.log("Enter [getPointEvents]");
+ // Point events
+ boolean foundEvt = false;
+ GwtPointEvents pointEvents = GwtPointEvents.create();
+ if (pointEventsUIDL.hasAttribute("legendItemClick")
+ && pointEventsUIDL.getBooleanAttribute("legendItemClick")) {
+ pointEvents.setLegendItemClickEvent(EventCallbacks
+ .getPieLegendItemClick(this));
+ foundEvt = true;
+ }
+ if (pointEventsUIDL.hasAttribute("click")
+ && pointEventsUIDL.getBooleanAttribute("click")) {
+ pointEvents.setClickEvent(EventCallbacks.getPointClick(this));
+ foundEvt = true;
+ }
+ if (pointEventsUIDL.hasAttribute("remove")
+ && pointEventsUIDL.getBooleanAttribute("remove")) {
+ pointEvents.setRemoveEvent(EventCallbacks.getPointRemove(this));
+ foundEvt = true;
+ }
+ if (pointEventsUIDL.hasAttribute("select")
+ && pointEventsUIDL.getBooleanAttribute("select")) {
+ pointEvents.setSelectEvent(EventCallbacks.getPointSelect(this));
+ foundEvt = true;
+ }
+ if (pointEventsUIDL.hasAttribute("unselect")
+ && pointEventsUIDL.getBooleanAttribute("unselect")) {
+ pointEvents.setUnselectEvent(EventCallbacks.getPointUnselect(this));
+ foundEvt = true;
+ }
+ VConsole.log("Exit [getPointEvents]");
+ if (foundEvt) {
+ return pointEvents;
+ }
+ return null;
+ }
+
+ private void updateOptionsWithEvents(GwtInvientChartsConfig options,
+ UIDL eventUIDL) {
+ VConsole.log("Enter [updateOptionsWithEvents]");
+
+ // Chart events
+ updateOptionsWithChartEvents(options, eventUIDL.getChildUIDL(0));
+
+ // Series events
+ updateOptionsWithSeriesAndPoingEvents(options,
+ eventUIDL.getChildUIDL(1));
+
+ VConsole.log("Exit [updateOptionsWithEvents]");
+ }
+
+ protected void chartAddSeriesListener(GwtChart chart) {
+ VConsole.log("Enter [chartAddSeriesListener]");
+
+ client.updateVariable(uidlId, "event", "addSeries", true);
+
+ VConsole.log("Exit [chartAddSeriesListener]");
+ }
+
+ protected void chartClickListener(GwtChart chart, double xAxisPos,
+ double yAxisPos, int pageX, int pageY) {
+ VConsole.log("Enter [chartClickListener]");
+
+ VConsole.log("chartClickListener : xAxisPos : " + xAxisPos
+ + ", yAxisPos : " + yAxisPos);
+ client.updateVariable(uidlId, "event", "chartClick", false);
+ Map eventData = new HashMap