Nebula Visalization Widgets API [message #1375426] |
Fri, 23 May 2014 02:30  |
Eclipse User |
|
|
|
While using the visualization widgets API I stumbled accross some hurdles that limited my ability to utilize the xygraph in the way I wanted (multiple linked graphs in a SahForm). To implement as I wanted I modified the source to add more flexibility. The changes I made are discussed below and would welcome their consideration for implementation in the API.
Proposed modifications are divided into type 1 (backwards campatible) and type 2 (non backwards compatible) and are outlined below.
Type 1) compliant with applications that use the org.eclipse.nebula.visulaization plugin.
Created interfaces for all public methods for:
org.eclipse.nebula.visualization.xygraph.figures
Axis → IAxis
Legend → ILegend
XYGraph ->IXYGraph
org.eclipse.nebula.visualization.xygraph.linearscale
AbstractScale → IAbstractScale
LinearScale → ILinearScale
Other Code modifications:
org.eclipse.nebula.visualization.xygraph.figures
Axis Changed visibility of pan and zoomInOut methods to public so they could be added to the IAxis interface.
public void pan(final Range temp, double t1, double t2);
public void zoomInOut(final double center, final double factor);
Type 2) - creates incompatibility with applications that utilize the org.eclipse.nebula.visulaization plugin.
XYGraph - change.
final public IAxis primaryXAxis;
final public IAxis primaryYAxis;
to
private IAxis primaryXAxis;
private IAxis primaryYAxis;
and add getter/setters and add the getters/setters to IXYGraph (and concrete implementations).
public abstract IAxis getPrimaryXAxis();
public abstract void setPrimaryXAxis(IAxis primaryXAxis);
public abstract IAxis getPrimaryYAxis();
public abstract void setPrimaryYAxis(IAxis primaryYAxis);
All other classes that access the public fields to be changed to access the public getter (ie AddAnnotationDialog, AxisConfigPage, and all the examples!).
Rationale for interface extraction and code modification:
To allow me to create SWT-XY-Graph plots inside a SashForm, where an axis can be located in a child of the sashform and the plot itself can be in another child. This way I can have multiple plots that can be resized which all share a common axis.
I can understand if the type 1 changes only are considered, at least these will allow users more flexibility in implemation of the plugin.
I can attach/send the modified source code if required.
-Adrian
|
|
|
|
Re: Nebula Visalization Widgets API [message #1694990 is a reply to message #1376824] |
Mon, 11 May 2015 09:08   |
Eclipse User |
|
|
|
Sorry to resurrect an old thread, but I am encountering a similar problem to the one above.
In short I wish to add custom Axis to my graph. Specifically a sub class of Axis that provides specialised formatting for the labels.
This is difficult however, as the primary axes member variables (primaryXAxis and primaryYAxis) are final public variables which are set in the XYGraph constructor. As such if I subclass XYGraph I can't change the primary axes.
I see a couple of possible solutions:
1) Provide public accessor methods for the primary axes (i.e getPrimaryXAxis() and getPrimaryYAxis()) and modify all the code in the visualisation plugin (AddAnotationDialog, AccessConfigPage and the examples ) to use the new accessor methods. When XYGraph is then subclassed these methods can then be overwritten. To maintain compatibility with existing code however, the variables will have to be kept public and anyone who uses sub classes of XYGraph will have to know to use the accessor methods instead of accessing the variables directly.
2) A safer, but possibly larger, solution would be to provide an AxesFactory interface. This would be used by the XYGraph constructor to create the primary axes. A default one that produces the standard Axis would be provided and this would be the one the standard XYGraph() constructor would use. An alternative constructor for XYGraph would be added that takes a AxesFactory as an parameter, here the user could provide a custom factory that produces his own custom axes.
I could raise a bug and provide code for this if needed.
Alex Clayton
|
|
|
|
Powered by
FUDForum. Page generated in 0.03570 seconds