LDViewer is a Google Web Toolkit (GWT) widget containing a processingjs sketch for visualizing LD triangle plots.
Following steps are required:
LDViewer ldviewer = new LDViewer();
ldviewer.load(new Runnable() {
@Override
public void run() {
GWT.log("LDViewer loaded");
// Interact with sketch
ldviewer.showLDValues();
}
});
To display data users have to call the showLDValues(int[] positions,float[][] r2Values, int start, int end)
function with following parameters:
positions
: Array of integerr2Values
: multi-dimensional array of floats in a triangular matrix form.start
: start position (should be the first position of the position array)end
: end position (should be the last position of the position array)
An example of this data can be found in the sample application and one could load it this way:
final String jsonData = GET_FROM_CLIENTBUNDLE OR AJAX CALL
LDData data = JsonUtils.safeEval(jsonData);
If you're using Maven, you can add the following to your <dependencies>
section:
<dependency>
<groupId>com.github.timeu.gwtlibs.ldviewer</groupId>
<artifactId>ldviewer</artifactId>
<version>1.0.0</version>
</dependency>
LDViewer uses GWT 2.8's new JSInterop feature and thus it has to be enabled in the GWT compiler args. For maven:
<compilerArgs>
<compilerArg>-generateJsInteropExports</compilerArg>
</compilerArgs>
or passing it to the compiler via -generateJsInteropExports
You can also download the jar directly or check out the source using git from https://github.com/timeu/ldviewer.git and build it yourself. Once you've installed LDViewer, be sure to inherit the module in your .gwt.xml file like this:
<inherits name='com.github.timeu.gwtlibs.ldviewer.LDViewer'/>
- Check out the sample app (Source Code) for a full example of using LDViewer.