arjeneh / jpowder

Automatically exported from code.google.com/p/jpowder
1 stars 0 forks source link

Allow string meta data in Prepare 3D plot window #72

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
See attached picture. 

If time available implement this within this release.

Original issue reported on code.google.com by anders.m...@stfc.ac.uk on 19 May 2012 at 11:10

Attachments:

GoogleCodeExporter commented 9 years ago
Here is a step by step suggestion for now to implementing this:

STEP 1

First notice that line 230 in FilesPlotter3D.java we have the line

            yAxis = new SymbolAxis("", HashMapHelper.convertKeyToArray(fileNames));

Please here create the equivalent of HashMapHelper.convertKeyToArray(fileNames)
using something like

        for (int i = 0; i < plot.getDatasetCount(); i++) {
            // append: datasets.elementAt(i).getFileName() 
            // to some array which is passed to SymbolAxis
        }

and remove the argument HashMap files from

    public FilesPlotter3D(Vector<DataSet> d, String meta, HashMap files) {

in line 88 of FilesPlotter3D.java.

STEP 2

Add a new class to the core project in the package org.jpowder.dataset
along the lines of (sorry I am not familiar with the Java Generic notation,
which is equivalent to C++ Template feature)

<Generic T>
class Meta
{
   public T value()  // returns the value of the meta
   public string type() // returns the type of the meta data which may be string or double
}

STEP 3

In line 53 of DataSet.java change 

    private HashMap<String, Double> meta;

with 

    private HashMap<String, Meta> meta;

And update the code to reflect this change

STEP 4

Now final step in line 650-ish of Import3DFilesTable.java (which will also have 
been
updated in STEP 3). Before adding meta data from a column check first if any of 
the
entries are NOT numbers. If yet all meta data from that column are added string 
otherwise double.

Then finally in FilesPlotter3D.java ask if the meta data is string or double. 
If yes plot accordingly.

Original comment by anders.m...@stfc.ac.uk on 19 May 2012 at 11:14