Class WAbstractDataSeries3D
- java.lang.Object
-
- eu.webtoolkit.jwt.WObject
-
- eu.webtoolkit.jwt.chart.WAbstractDataSeries3D
-
- Direct Known Subclasses:
WAbstractGridData,WScatterData
public abstract class WAbstractDataSeries3D extends WObject
Abstract base class for dataseries that can be drawn on aWCartesian3DChart.General
The model that is provided at construction or with
setModel()contains the data of a dataseries. Implementations of this class format the data for representation on the chart and perform all necessary drawing operations. Note that if a dataseries holds numerical data it should be added to a chart of typeChartType.Scatter, if it holds categorical data it should be added to a chart of typeChartType.Category.Color
The color used to draw data on a chart can be specified in a number of ways. The priority of this is as follows (1 being the highest):
ItemDataRole.MarkerBrushColorset on a value in the modelWAbstractColorMapset on the dataseriesWChartPalettepresent in the chart
A chart-palette will specify one color for the entire dataseries. Each new dataseries on a chart will receive another color.
A colormap assigns different colors to the data within one dataseries, based on the z-value of the data.WStandardColorMapprovides an easy way to create a colormap that is either smooth or consists of a number of bands.Data-roles
The roles on the model which are taken into account are:
ItemDataRole.MarkerBrushColor: this determines the color of a datapoint and overrides the defaultItemDataRole.MarkerScaleFactor: this determines the size of a datapoint and overrides the default
Some representations of the data ignore these roles. For example, when a surface is drawn, the roles are ignored.
Implementing a new dataseries class
When the existing implementations of WAbstractDataSeries3D don't meet your needs, you might want to make your own. When doing this there are some details of the chart that you should know. The chart is made so that when a property of the chart changes, which affect any of the GL resources, all GL resources are destroyed and re-initialized. This eliminates the need to determine which chart-setting affect which GL-resources, which can be a complicated problem.
Therefore only unchanging GL resources are initialized in
initializeGL(). The initializeGL function in the chart is implemented to immediately request a call toupdateGL(), which then initializes the rest of the GL resources. Every call to updateGL in the chart, will first calldeleteAllGLResources()on all dataseries and will then callupdateGL()on all dataseries. So, when implementing a dataseries: initialize unchanging GL resources ininitializeGL(), initialize the rest of your GL resources inupdateGL()and make GL-delete calls to all resources initialized inupdateGL()in the functiondeleteAllGLResources(). It is also best to check isNull() on each of your GL-resources when deleting them.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
-
Field Summary
Fields Modifier and Type Field Description protected WCartesian3DChartchart_protected WAbstractItemModelmodel_protected java.lang.StringpointSprite_
-
Constructor Summary
Constructors Constructor Description WAbstractDataSeries3D(WAbstractItemModel model)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voiddeleteAllGLResources()Delete GL resources.WCartesian3DChartgetChart()Returns a const pointer to theWCartesian3DCharton which the dataseries is drawn.WColorgetChartpaletteColor()WAbstractColorMapgetColorMap()Returns the colormap used by this dataseries.SidegetColorMapSide()Returns on which side the colormap is shown.java.util.List<java.lang.Object>getGlObjects()WAbstractItemModelgetModel()Returns a pointer to the model used by this dataseries.doublegetPointSize()Returns the pointsize for drawing this dataseries.java.lang.StringgetPointSprite()Returns the point sprite used for drawing this dataseries.protected WGLWidget.TexturegetPointSpriteTexture()WStringgetTitle()Returns the title of this dataseries.abstract voidinitializeGL()Initialize GL resources.booleanisColorMapVisible()Returns whether the colormap is shown alongside the chart in the form of a legend.booleanisHidden()Returns if this dataseries is hidden.booleanisLegendEnabled()Returns whether this dataseries is included in the chart-legend.protected voidloadPointSpriteTexture(WGLWidget.Texture tex)abstract doublemaximum(Axis axis)Returns the computed maximum value of this dataseries along the given axis.abstract doubleminimum(Axis axis)Returns the computed minimum value of this dataseries along the given axis.abstract voidpaintGL()Update the client-side painting function.abstract voidresizeGL()Act on resize events.voidsetChart(WCartesian3DChart chart)voidsetColorMap(WAbstractColorMap colormap)Sets the colormap for this dataseries.voidsetColorMapSide(Side side)Sets whether the colormap is shown on the left or right.voidsetColorMapVisible()Sets whether the colormap that is used should be shown alongside the chart in the form of a legend.voidsetColorMapVisible(boolean enabled)Sets whether the colormap that is used should be shown alongside the chart in the form of a legend.voidsetDefaultTitle(int i)voidsetHidden()Sets if this dataseries is hidden.voidsetHidden(boolean enabled)Sets if this dataseries is hidden.voidsetLegendEnabled()Sets whether this dataseries is included in the chart-legend.voidsetLegendEnabled(boolean enabled)Sets whether this dataseries is included in the chart-legend.voidsetModel(WAbstractItemModel model)Sets a model from which the dataseries gets its data.voidsetPointSize(double size)Sets the pointsize for drawing this dataseries.voidsetPointSprite(java.lang.String image)Set the point sprite used for drawing this dataseries.voidsetTitle(java.lang.CharSequence name)Sets the title of this dataseries.abstract voidupdateGL()Update GL resources.-
Methods inherited from class eu.webtoolkit.jwt.WObject
getId, getObjectName, remove, setFormData, setObjectName, tr
-
-
-
-
Field Detail
-
model_
protected WAbstractItemModel model_
-
chart_
protected WCartesian3DChart chart_
-
pointSprite_
protected java.lang.String pointSprite_
-
-
Constructor Detail
-
WAbstractDataSeries3D
public WAbstractDataSeries3D(WAbstractItemModel model)
Constructor.This constructor takes a
WAbstractItemModelas an argument. The model contains the data of this dataseries. How the model should be structured is dependent on the implementation. Therefore this information is found in the documentation of classes deriving from this one.
-
-
Method Detail
-
setTitle
public void setTitle(java.lang.CharSequence name)
Sets the title of this dataseries.When a dataseries that did not have a title set, is added to a
WCartesian3DChartit automatically gets the default title 'dataset i', with i the count of how many dataseries have been added to the chart.
-
getTitle
public WString getTitle()
Returns the title of this dataseries.
-
setModel
public void setModel(WAbstractItemModel model)
Sets a model from which the dataseries gets its data.Every dataseries needs a model from which it gets the data. How the data is structured is determined by the type of dataseries. Therefore more info on how to construct a proper model is provided in classes that derive from this one.
-
getModel
public WAbstractItemModel getModel()
Returns a pointer to the model used by this dataseries.- See Also:
setModel(WAbstractItemModel model)
-
minimum
public abstract double minimum(Axis axis)
Returns the computed minimum value of this dataseries along the given axis.- See Also:
maximum(Axis axis)
-
maximum
public abstract double maximum(Axis axis)
Returns the computed maximum value of this dataseries along the given axis.- See Also:
minimum(Axis axis)
-
getChart
public WCartesian3DChart getChart()
Returns a const pointer to theWCartesian3DCharton which the dataseries is drawn.
-
setPointSize
public void setPointSize(double size)
Sets the pointsize for drawing this dataseries.The default pointsize is 2 pixels.
Note: Setting the point-size is currently not supported in IE.
-
getPointSize
public double getPointSize()
Returns the pointsize for drawing this dataseries.- See Also:
setPointSize(double size)
-
setPointSprite
public void setPointSprite(java.lang.String image)
Set the point sprite used for drawing this dataseries.This should be a local (server side) path to an image, such as a PNG or GIF. Only the alpha channel of this image is used: the sprite only decides if a pixel in the point appears or not. If the alpha value is below 0.5, the pixel is discarded.
For best effect, the point sprite's width and height should be the same as the
getPointSize(), and the chart's antialiasing should be disabled.Defaults to the empty string, meaning that every pixel of the point will be drawn, yielding a square.
-
getPointSprite
public java.lang.String getPointSprite()
Returns the point sprite used for drawing this dataseries.- See Also:
setPointSprite(String image)
-
setColorMap
public void setColorMap(WAbstractColorMap colormap)
Sets the colormap for this dataseries.Ownership of the
WAbstractColorMapis transferred to this class.By default there is no colormap set. When a colormap is set on a dataseries, the color of
WCartesian3DChart.getPalette()is no longer used for this series. The colormap associates a color to the data based on the z-value of the data. If the colormap is set to 0, the value of the palette will be used again.
-
getColorMap
public WAbstractColorMap getColorMap()
Returns the colormap used by this dataseries.If this dataseries has no colormap set, 0 will be returned.
-
setColorMapVisible
public void setColorMapVisible(boolean enabled)
Sets whether the colormap that is used should be shown alongside the chart in the form of a legend.The default value is false.
-
setColorMapVisible
public final void setColorMapVisible()
Sets whether the colormap that is used should be shown alongside the chart in the form of a legend.Calls
setColorMapVisible(true)
-
isColorMapVisible
public boolean isColorMapVisible()
Returns whether the colormap is shown alongside the chart in the form of a legend.
-
setColorMapSide
public void setColorMapSide(Side side)
Sets whether the colormap is shown on the left or right.The default side is
Side.Right.Note: only
Side.LeftandSide.Rightare valid values for this function.
-
getColorMapSide
public Side getColorMapSide()
Returns on which side the colormap is shown.
-
setLegendEnabled
public void setLegendEnabled(boolean enabled)
Sets whether this dataseries is included in the chart-legend.By default, dataseries are enabled in the legend.
-
setLegendEnabled
public final void setLegendEnabled()
Sets whether this dataseries is included in the chart-legend.Calls
setLegendEnabled(true)
-
isLegendEnabled
public boolean isLegendEnabled()
Returns whether this dataseries is included in the chart-legend.- See Also:
setLegendEnabled(boolean enabled)
-
setHidden
public void setHidden(boolean enabled)
Sets if this dataseries is hidden.By default dataseries are visible.
-
setHidden
public final void setHidden()
Sets if this dataseries is hidden.Calls
setHidden(true)
-
isHidden
public boolean isHidden()
Returns if this dataseries is hidden.- See Also:
setHidden(boolean enabled)
-
setDefaultTitle
public void setDefaultTitle(int i)
-
getChartpaletteColor
public WColor getChartpaletteColor()
-
setChart
public void setChart(WCartesian3DChart chart)
-
getGlObjects
public java.util.List<java.lang.Object> getGlObjects()
-
initializeGL
public abstract void initializeGL()
Initialize GL resources.This function is called by
initializeGL()in the chart to which this dataseries was added.
-
paintGL
public abstract void paintGL()
Update the client-side painting function.This function is called by
paintGL()in the chart to which this dataseries was added.
-
updateGL
public abstract void updateGL()
Update GL resources.This function is called by
updateGL()in the chart to which this dataseries was added. Before this function is called,deleteAllGLResources()is called.- See Also:
deleteAllGLResources()
-
resizeGL
public abstract void resizeGL()
Act on resize events.This function is called by
resizeGL()in the chart to which this dataseries was added.
-
deleteAllGLResources
public abstract void deleteAllGLResources()
Delete GL resources.This function is called by
updateGL()in the chart to which this dataseries was added.
-
getPointSpriteTexture
protected WGLWidget.Texture getPointSpriteTexture()
-
loadPointSpriteTexture
protected void loadPointSpriteTexture(WGLWidget.Texture tex)
-
-