Added vdescriptor
This commit is contained in:
@@ -11,6 +11,13 @@
|
||||
<artifactId>guava</artifactId>
|
||||
<version>15.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.8.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package ch.psi.fda.vdescriptor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name="lineplot")
|
||||
public class LinePlot extends Plot {
|
||||
private List<Series> data;
|
||||
|
||||
@XmlElement
|
||||
public List<Series> getData() {
|
||||
return data;
|
||||
}
|
||||
public void setData(List<Series> data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package ch.psi.fda.vdescriptor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name="matrixplot")
|
||||
public class MatrixPlot extends Plot {
|
||||
|
||||
private List<Series> data;
|
||||
|
||||
public List<Series> getData() {
|
||||
return data;
|
||||
}
|
||||
public void setData(List<Series> data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package ch.psi.fda.vdescriptor;
|
||||
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
|
||||
@XmlSeeAlso({LinePlot.class, MatrixPlot.class})
|
||||
@XmlTransient
|
||||
public abstract class Plot {
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package ch.psi.fda.vdescriptor;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
public class Series {
|
||||
|
||||
private String x = null;
|
||||
private String y = null;
|
||||
private String z = null;
|
||||
|
||||
@XmlAttribute
|
||||
public String getX() {
|
||||
return x;
|
||||
}
|
||||
public void setX(String x) {
|
||||
this.x = x;
|
||||
}
|
||||
@XmlAttribute
|
||||
public String getY() {
|
||||
return y;
|
||||
}
|
||||
public void setY(String y) {
|
||||
this.y = y;
|
||||
}
|
||||
@XmlAttribute
|
||||
public String getZ() {
|
||||
return z;
|
||||
}
|
||||
public void setZ(String z) {
|
||||
this.z = z;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package ch.psi.fda.vdescriptor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlElements;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name="vdescriptor")
|
||||
public class VDescriptor {
|
||||
|
||||
private List<Plot> plots;
|
||||
|
||||
@XmlElementWrapper
|
||||
@XmlElements({
|
||||
@XmlElement(name="lineplot",type=LinePlot.class),
|
||||
@XmlElement(name="matrixplot",type=MatrixPlot.class),
|
||||
})
|
||||
public List<Plot> getPlots() {
|
||||
return plots;
|
||||
}
|
||||
|
||||
public void setPlots(List<Plot> plots) {
|
||||
this.plots = plots;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package ch.psi.fda.vdescriptor;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class VDescriptorTest {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(VDescriptorTest.class.getName());
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws JAXBException {
|
||||
JAXBContext context = JAXBContext.newInstance(VDescriptor.class);
|
||||
Unmarshaller u = context.createUnmarshaller();
|
||||
|
||||
VDescriptor descriptor = (VDescriptor) u.unmarshal(new File("src/test/resources/vdescriptor.xml"));
|
||||
for(Plot p: descriptor.getPlots()){
|
||||
logger.info(p.getClass().getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
15
ch.psi.fda.core/src/test/resources/vdescriptor.xml
Normal file
15
ch.psi.fda.core/src/test/resources/vdescriptor.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<vdescriptor>
|
||||
<plots>
|
||||
<lineplot>
|
||||
<data>
|
||||
<series x="A" y="B" />
|
||||
<series x="A" y="C" />
|
||||
</data>
|
||||
</lineplot>
|
||||
<matrixplot>
|
||||
<data>
|
||||
<series x="A" y="B" z="X" />
|
||||
</data>
|
||||
</matrixplot>
|
||||
</plots>
|
||||
</vdescriptor>
|
||||
Reference in New Issue
Block a user