public class XMLAnnotationManager extends Object
IDrawingLayer, or DefaultDrawingLayer respectively.| Modifier and Type | Field and Description |
|---|---|
private List<DefaultDrawingLayer> |
allLayers
This is the internal java object for all layers.
|
private AnnotationLayers |
allLayersJAXB
The root element of the serialized layers.
|
private JAXBContext |
jaxbContext |
private static org.apache.log4j.Logger |
logger |
private Marshaller |
marshaller |
private ObjectFactory |
of |
private Unmarshaller |
unmarshaller |
static String |
XML_DATA_ENCODING |
private File |
xmlFile |
private InputStream |
xmlSchemaFileIS |
private String |
xmlSchemaLocation |
| Constructor and Description |
|---|
XMLAnnotationManager()
Standard constructor.
|
XMLAnnotationManager(List<DefaultDrawingLayer> allLayers,
File xmlFile)
Create an
XMLAnnotationManager for a specified location. |
| Modifier and Type | Method and Description |
|---|---|
RoiSet |
angleROItoXML(ArrayList<AngleROI> shapes,
RoiSet roiSetJAXB)
|
protected List<DefaultDrawingLayer> |
convertToList(AnnotationLayers root)
Converts the XML mapping format to a
List of
DefaultDrawingLayers. |
protected AnnotationLayers |
convertToXML(List<DefaultDrawingLayer> allLayers)
Converts a list of
DefaultDrawingLayer to the XML mapping format. |
RoiSet |
ellipseROItoXML(ArrayList<EllipseROI> shapes,
RoiSet roiSetJAXB)
Converts the
ArrayList of EllipseROIs to XML
representation. |
RoiSet |
freehandROItoXML(ArrayList<FreehandROI> shapes,
RoiSet roiSetJAXB)
Converts the
ArrayList of FreehandROIs to XML
representation. |
List<DefaultDrawingLayer> |
getAllLayers()
Get the re-assembled list of all layers.
|
File |
getXmlFile()
Get the location of the XML file.
|
RoiSet |
lineROItoXML(ArrayList<LineROI> shapes,
RoiSet roiSetJAXB)
|
static void |
main(String[] args) |
Color |
parseXML(Color jaxbObject)
Parse a given XML object to a
Color instance. |
Shape |
parseXML(Path jaxbPath)
Reconstructs a Shape object according to a given path.
|
double[] |
parseXML(Point jaxbPoint)
Parses a 2D point into its double coordinates.
|
BasicStroke |
parseXML(Stroke jaxbObject)
Parse a given XML object to a
BasicStroke instance. |
AngleROI |
parseXMLAngleROI(AngleRoi jaxbObject)
Parse a given XML object to a
AngleROI instance. |
EllipseROI |
parseXMLEllipseROI(EllipseRoi jaxbObject)
Parse a given XML object to a
EllipseROI instance. |
FreehandROI |
parseXMLFreehandROI(FreehandRoi jaxbObject)
Parse a given XML object to a
FreehandROI instance. |
LineROI |
parseXMLLineROI(LineRoi jaxbObject)
Parse a given XML object to a
LineROI instance. |
PointROI |
parseXMLPointROI(PointRoi jaxbObject)
Parse a given XML object to a
PointROI instance. |
PolygonROI |
parseXMLPolygonROI(PolygonRoi jaxbObject)
Parse a given XML object to a
PolygonROI instance. |
RectangleROI |
parseXMLRectangleROI(RectangleRoi jaxbObject)
Parse a given XML object to a
RectangleROI instance. |
RoiSet |
pointROItoXML(ArrayList<PointROI> shapes,
RoiSet roiSetJAXB)
|
RoiSet |
polygonROItoXML(ArrayList<PolygonROI> shapes,
RoiSet roiSetJAXB)
Converts the
ArrayList of PolygonROIs to XML
representation. |
List<IDrawingLayer> |
read()
Public delegate method for reading the xml file into a
List of
DefaultDrawingLayers. |
protected AnnotationLayers |
readXML()
Loads the annotation layers from an existing XML file.
|
RoiSet |
rectangleROItoXML(ArrayList<RectangleROI> shapes,
RoiSet roiSetJAXB)
Converts the
ArrayList of RectangleROIs to XML
representation. |
void |
setAllLayers(List<DefaultDrawingLayer> allLayers)
Set a list of all layers available for saving.
|
void |
setXmlFile(File xmlFile)
Set the location of the XML file.
|
private static void |
testLoad(File f) |
Stroke |
toXML(BasicStroke stroke,
Stroke strokeJAXB,
String name)
Converts a given
BasicStroke instance to the
serializable form. |
Color |
toXML(Color c,
Color colorJAXB,
String name)
Converts a given
Color instance to the serializable
form. |
Data |
toXML(Object javaObject,
Data dataJAXB) |
Path |
toXML(PathIterator iter,
Path pathJAXB)
Generates an XML representation of the given
PathIterator object. |
Point |
toXML(Point2D point,
Point pointJAXB,
String id)
Converts a
Point2D to the XML representation. |
Bounds |
toXML(Rectangle2D bounds,
Bounds boundsJAXB)
Converts the boundaries from a
Rectangle2D to the XML
representation. |
private void |
validate()
Validates the XML file against the defined schema.
|
void |
write()
Converts the set List of
DefaultDrawingLayers to XML and writes
the file. |
protected void |
writeXML()
Writes an XML file to the specified path in the file system.
|
private static final org.apache.log4j.Logger logger
private final String xmlSchemaLocation
public static final String XML_DATA_ENCODING
private File xmlFile
private InputStream xmlSchemaFileIS
private List<DefaultDrawingLayer> allLayers
private JAXBContext jaxbContext
private Marshaller marshaller
private Unmarshaller unmarshaller
private AnnotationLayers allLayersJAXB
private ObjectFactory of
public XMLAnnotationManager()
public XMLAnnotationManager(List<DefaultDrawingLayer> allLayers, File xmlFile)
XMLAnnotationManager for a specified location.allLayers - xmlFile - public File getXmlFile()
public void setXmlFile(File xmlFile)
xmlFile - public void setAllLayers(List<DefaultDrawingLayer> allLayers)
allLayers - public List<DefaultDrawingLayer> getAllLayers()
private void validate()
protected void writeXML()
public void write()
throws JAXBException
DefaultDrawingLayers to XML and writes
the file.JAXBExceptionpublic List<IDrawingLayer> read() throws JAXBException
List of
DefaultDrawingLayers.JAXBExceptionprotected AnnotationLayers readXML() throws JAXBException
JAXBException - - if the XML file does not comply with the schemaprotected List<DefaultDrawingLayer> convertToList(AnnotationLayers root)
List of
DefaultDrawingLayers.allLayersJAXB - allLayers - DefaultDrawingLayerspublic PointROI parseXMLPointROI(PointRoi jaxbObject)
PointROI instance.jaxbObject - the XML objectpublic RectangleROI parseXMLRectangleROI(RectangleRoi jaxbObject)
RectangleROI instance.jaxbObject - the XML objectpublic AngleROI parseXMLAngleROI(AngleRoi jaxbObject)
AngleROI instance.jaxbObject - the XML objectpublic EllipseROI parseXMLEllipseROI(EllipseRoi jaxbObject)
EllipseROI instance.jaxbObject - the XML objectpublic FreehandROI parseXMLFreehandROI(FreehandRoi jaxbObject)
FreehandROI instance.jaxbObject - the XML objectpublic LineROI parseXMLLineROI(LineRoi jaxbObject)
LineROI instance.jaxbObject - the XML objectpublic PolygonROI parseXMLPolygonROI(PolygonRoi jaxbObject)
PolygonROI instance.jaxbObject - the XML objectpublic Shape parseXML(Path jaxbPath)
jaxbPath - Shapepublic double[] parseXML(Point jaxbPoint)
jaxbPoint - public BasicStroke parseXML(Stroke jaxbObject)
BasicStroke instance.jaxbObject - the XML objectpublic Color parseXML(Color jaxbObject)
Color instance.jaxbObject - the XML objectprotected AnnotationLayers convertToXML(List<DefaultDrawingLayer> allLayers)
DefaultDrawingLayer to the XML mapping format.allLayers - allLayersJAXB - public RoiSet angleROItoXML(ArrayList<AngleROI> shapes, RoiSet roiSetJAXB)
shapes - roiSetJAXB - an existing object, if null, a new object will be
generatedpublic RoiSet polygonROItoXML(ArrayList<PolygonROI> shapes, RoiSet roiSetJAXB)
ArrayList of PolygonROIs to XML
representation.shapes - roiSetJAXB - an existing object, if null, a new object will be
generatedpublic RoiSet freehandROItoXML(ArrayList<FreehandROI> shapes, RoiSet roiSetJAXB)
ArrayList of FreehandROIs to XML
representation.shapes - roiSetJAXB - an existing object, if null, a new object will be
generatedpublic RoiSet ellipseROItoXML(ArrayList<EllipseROI> shapes, RoiSet roiSetJAXB)
ArrayList of EllipseROIs to XML
representation.shapes - roiSetJAXB - an existing object, if null, a new object will be
generatedpublic RoiSet rectangleROItoXML(ArrayList<RectangleROI> shapes, RoiSet roiSetJAXB)
ArrayList of RectangleROIs to XML
representation.shapes - roiSetJAXB - an existing object, if null, a new object will be
generatedpublic RoiSet pointROItoXML(ArrayList<PointROI> shapes, RoiSet roiSetJAXB)
shapes - roiSetJAXB - an existing object, if null, a new object will be
generatedpublic RoiSet lineROItoXML(ArrayList<LineROI> shapes, RoiSet roiSetJAXB)
shapes - roiSetJAXB - an existing object, if null, a new object will be
generatedpublic Path toXML(PathIterator iter, Path pathJAXB)
PathIterator object.iter - pathJAXB - an existing object, if null, a new object will be
generatedpublic Bounds toXML(Rectangle2D bounds, Bounds boundsJAXB)
Rectangle2D to the XML
representation.bounds - boundsJAXB - an existing object, if null, a new object will be
generatedpublic Point toXML(Point2D point, Point pointJAXB, String id)
Point2D to the XML representation.point - pointJAXB - an existing object, if null, a new object will be
generatedid - public Stroke toXML(BasicStroke stroke, Stroke strokeJAXB, String name)
BasicStroke instance to the
serializable form.stroke - strokeJAXB - an existing object, if null, a new object will be
generatedname - public Color toXML(Color c, Color colorJAXB, String name)
Color instance to the serializable
form.c - colorJAXB - an existing object, if null, a new object will be
generatedname - private static void testLoad(File f)
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException, InstantiationException, IllegalAccessException
Copyright © 2009–2017 Helmut Ahammer, Philipp Kainz. All rights reserved.