Search in sources :

Example 1 with OrderedGroupType

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

the class PAGETypeFactory method createOrderedGroup.

public static OrderedGroupType createOrderedGroup(String id, String caption) {
    OrderedGroupType g = new OrderedGroupType();
    g.setId(id);
    if (caption != null)
        g.setCaption(caption);
    return g;
}
Also used : OrderedGroupType(eu.transkribus.core.model.beans.pagecontent.OrderedGroupType)

Example 2 with OrderedGroupType

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

the class CustomTagUtil method createReadingOrderOrderedGroup.

public static OrderedGroupType createReadingOrderOrderedGroup(List<? extends ITrpShapeType> shapes, String caption) {
    OrderedGroupType group = new OrderedGroupType();
    if (caption != null)
        group.setCaption(caption);
    group.setId("ro_" + CoreUtils.uniqueCurrentTimeMS());
    for (ITrpShapeType s : shapes) {
        if (s.getReadingOrder() != null) {
            RegionRefIndexedType rr = new RegionRefIndexedType();
            rr.setRegionRef(s);
            rr.setIndex(s.getReadingOrder());
            group.getRegionRefIndexedOrOrderedGroupIndexedOrUnorderedGroupIndexed().add(rr);
        }
    }
    return group;
}
Also used : RegionRefIndexedType(eu.transkribus.core.model.beans.pagecontent.RegionRefIndexedType) OrderedGroupType(eu.transkribus.core.model.beans.pagecontent.OrderedGroupType) ITrpShapeType(eu.transkribus.core.model.beans.pagecontent_trp.ITrpShapeType)

Example 3 with OrderedGroupType

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

the class CustomTagUtil method writeReadingOrderCustomTagsToPageFormat.

// public static void createReadingOrderOrderedGroupIndexed(TrpRegionType r, OrderedGroupIndexedType g) {
// 
// 
// 
// 
// if (s instanceof TrpRegionType) {
// s.getChildren(recursive)
// 
// 
// TrpRegionType r = (TrpRegionType) s;
// for (int i=0; i<r.getTextRegionOrImageRegionOrLineDrawingRegion().size(); ++i) {
// TrpRegionType cr = r.getTextRegionOrImageRegionOrLineDrawingRegion().get(i);
// 
// if (cr.hasChildren()) {
// OrderedGroupIndexedType cg = PAGETypeFactory.createOrderedGroupIndexed(i, "r_"+CoreUtils.uniqueCurrentTimeMS(), null);
// 
// 
// 
// RegionRefIndexedType rr = PAGETypeFactory.createRegionRefIndexed(index, refObject)
// 
// }
// 
// 
// }
// 
// }
// 
// 
// 
// }
// 
// public static void writeReadingOrderCustomTagsToPageFormat(TrpPageType page) {
// logger.trace("converting reading order from custom tags to page format... NEW");
// 
// ReadingOrderType ro = new ReadingOrderType();
// 
// // 1st: create parent group for all reading order elements
// OrderedGroupType group = PAGETypeFactory.createOrderedGroup("ro_"+CoreUtils.uniqueCurrentTimeMS(), "Reading order");
// 
// // 2nd: create either a region ref
// for (TrpRegionType r : page.getTextRegionOrImageRegionOrLineDrawingRegion()) {
// xxx
// 
// 
// 
// 
// }
// 
// OrderedGroupType group = createReadingOrderOrderedGroup(page.getTextRegionOrImageRegionOrLineDrawingRegion(), "Regions reading order");
// 
// 
// 
// 
// 
// 
// OrderedGroupType group = new OrderedGroupType();
// group.setCaption("Regions reading order");
// group.setId("ro_"+CoreUtils.uniqueCurrentTimeMS());
// ro.setOrderedGroup(group);
// boolean readingOrderSet=false;
// 
// for (TrpTextRegionType r : page.getTextRegions(false)) {
// if (r.getReadingOrder() != null) {
// readingOrderSet=true;
// RegionRefIndexedType rr = new RegionRefIndexedType();
// rr.setRegionRef(r);
// rr.setIndex(r.getReadingOrder());
// group.getRegionRefIndexedOrOrderedGroupIndexedOrUnorderedGroupIndexed().add(rr);
// readingOrderSet = true;
// }
// }
// 
// if (readingOrderSet)
// page.setReadingOrder(ro);
// }
public static void writeReadingOrderCustomTagsToPageFormat(TrpPageType page) {
    logger.trace("converting reading order from custom tags to page format...");
    ReadingOrderType ro = new ReadingOrderType();
    OrderedGroupType group = new OrderedGroupType();
    group.setCaption("Regions reading order");
    group.setId("ro_" + CoreUtils.uniqueCurrentTimeMS());
    ro.setOrderedGroup(group);
    boolean readingOrderSet = false;
    for (TrpTextRegionType r : page.getTextRegions(false)) {
        if (r.getReadingOrder() != null) {
            readingOrderSet = true;
            RegionRefIndexedType rr = new RegionRefIndexedType();
            rr.setRegionRef(r);
            rr.setIndex(r.getReadingOrder());
            group.getRegionRefIndexedOrOrderedGroupIndexedOrUnorderedGroupIndexed().add(rr);
            readingOrderSet = true;
        }
    }
    if (readingOrderSet)
        page.setReadingOrder(ro);
}
Also used : RegionRefIndexedType(eu.transkribus.core.model.beans.pagecontent.RegionRefIndexedType) TrpTextRegionType(eu.transkribus.core.model.beans.pagecontent_trp.TrpTextRegionType) ReadingOrderType(eu.transkribus.core.model.beans.pagecontent.ReadingOrderType) OrderedGroupType(eu.transkribus.core.model.beans.pagecontent.OrderedGroupType)

Aggregations

OrderedGroupType (eu.transkribus.core.model.beans.pagecontent.OrderedGroupType)3 RegionRefIndexedType (eu.transkribus.core.model.beans.pagecontent.RegionRefIndexedType)2 ReadingOrderType (eu.transkribus.core.model.beans.pagecontent.ReadingOrderType)1 ITrpShapeType (eu.transkribus.core.model.beans.pagecontent_trp.ITrpShapeType)1 TrpTextRegionType (eu.transkribus.core.model.beans.pagecontent_trp.TrpTextRegionType)1