Search in sources :

Example 1 with PageType

use of eu.transkribus.core.model.beans.pagecontent.PageType in project TranskribusCore by Transkribus.

the class PageXmlDaoTest method main.

public static void main(String[] args) {
    TrpDoc doc = FakeDocProvider.create(false);
    TrpTranscriptMetadata md = doc.getPages().get(0).getTranscripts().get(0);
    try {
        JAXBPageTranscript transcript = new JAXBPageTranscript(md);
        transcript.build();
        // JAXBPageTranscript transcript = TrpPageTranscriptBuilder.build(md);
        // get Source Document as String
        // DOMSource domSource = new DOMSource(transcript.getSourceDoc());
        // StringWriter writer = new StringWriter();
        // StreamResult result = new StreamResult(writer);
        // TransformerFactory tf = TransformerFactory.newInstance();
        // Transformer transformer = tf.newTransformer();
        // transformer.transform(domSource, result);
        // System.out.println("XML IN String format is: \n" + writer.toString());
        // check JaxB Element
        PcGtsType page = transcript.getPageData();
        if (page == null) {
            System.out.println("page XML is null");
            System.exit(0);
        }
        PageType pageType = page.getPage();
        System.out.println(page.getMetadata());
        if (pageType == null) {
            System.out.println("pagetype element is null");
            System.exit(0);
        }
        if (pageType.getTextRegionOrImageRegionOrLineDrawingRegion() == null) {
            System.out.println("Region list is null");
            System.exit(0);
        }
        int i = 0;
        for (TextRegionType tr : transcript.getPage().getTextRegions(true)) {
            tr.setId("" + i++);
        }
        List<TrpRegionType> regions = pageType.getTextRegionOrImageRegionOrLineDrawingRegion();
        for (RegionType r : regions) {
            if (r instanceof TextRegionType) {
                TextRegionType t = (TextRegionType) r;
                System.out.println(t.getId());
            }
        }
    } catch (IllegalArgumentException | IOException e) {
        e.printStackTrace();
    }
// try {
// PrimaPageTranscript ppt = PageXmlDao.getPrimaPageTranscript(md);
// Page page = ppt.getPageData();
// 
// System.out.println(page.getImageFilename());
// Region r = page.getLayout().getRegion("tempReg357564684568544579089");
// System.out.println(r.getType().getName());
// //			System.out.println(page.getLayout().getParentChildRelation(r.getType(), r.getId().toString()).getRelationType());
// 
// IdRegister idr = r.getIdRegister();
// //			idr.
// System.out.println(idr);
// } catch (IllegalArgumentException e) {
// 
// e.printStackTrace();
// } catch (MalformedURLException e) {
// 
// e.printStackTrace();
// } catch (UnsupportedFormatVersionException e) {
// 
// e.printStackTrace();
// }
}
Also used : TrpRegionType(eu.transkribus.core.model.beans.pagecontent_trp.TrpRegionType) RegionType(eu.transkribus.core.model.beans.pagecontent.RegionType) TextRegionType(eu.transkribus.core.model.beans.pagecontent.TextRegionType) JAXBPageTranscript(eu.transkribus.core.model.beans.JAXBPageTranscript) TrpTranscriptMetadata(eu.transkribus.core.model.beans.TrpTranscriptMetadata) IOException(java.io.IOException) PcGtsType(eu.transkribus.core.model.beans.pagecontent.PcGtsType) TextRegionType(eu.transkribus.core.model.beans.pagecontent.TextRegionType) TrpRegionType(eu.transkribus.core.model.beans.pagecontent_trp.TrpRegionType) TrpDoc(eu.transkribus.core.model.beans.TrpDoc) PageType(eu.transkribus.core.model.beans.pagecontent.PageType)

Aggregations

JAXBPageTranscript (eu.transkribus.core.model.beans.JAXBPageTranscript)1 TrpDoc (eu.transkribus.core.model.beans.TrpDoc)1 TrpTranscriptMetadata (eu.transkribus.core.model.beans.TrpTranscriptMetadata)1 PageType (eu.transkribus.core.model.beans.pagecontent.PageType)1 PcGtsType (eu.transkribus.core.model.beans.pagecontent.PcGtsType)1 RegionType (eu.transkribus.core.model.beans.pagecontent.RegionType)1 TextRegionType (eu.transkribus.core.model.beans.pagecontent.TextRegionType)1 TrpRegionType (eu.transkribus.core.model.beans.pagecontent_trp.TrpRegionType)1 IOException (java.io.IOException)1