Search in sources :

Example 1 with RegionRefIndexedType

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

the class PAGETypeFactory method createRegionRefIndexed.

public static RegionRefIndexedType createRegionRefIndexed(int index, Object refObject) {
    RegionRefIndexedType r = new RegionRefIndexedType();
    r.setIndex(index);
    r.setRegionRef(refObject);
    return r;
}
Also used : RegionRefIndexedType(eu.transkribus.core.model.beans.pagecontent.RegionRefIndexedType)

Example 2 with RegionRefIndexedType

use of eu.transkribus.core.model.beans.pagecontent.RegionRefIndexedType 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 RegionRefIndexedType

use of eu.transkribus.core.model.beans.pagecontent.RegionRefIndexedType 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)

Example 4 with RegionRefIndexedType

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

the class CustomTagUtil method writeReadingOrderFromPageFormatToCustomTags.

public static void writeReadingOrderFromPageFormatToCustomTags(TrpPageType page) {
    logger.trace("converting reading order from page format to custom tags...");
    ReadingOrderType ro = page.getReadingOrder();
    if (ro == null)
        return;
    for (Object o : ro.getOrderedGroup().getRegionRefIndexedOrOrderedGroupIndexedOrUnorderedGroupIndexed()) {
        logger.trace("ref: " + o);
        if (o instanceof RegionRefIndexedType) {
            RegionRefIndexedType rr = (RegionRefIndexedType) o;
            logger.trace("region ref: " + rr + " ref = " + rr.getRegionRef());
            if (rr.getRegionRef() instanceof TrpTextRegionType) {
                TrpTextRegionType region = (TrpTextRegionType) rr.getRegionRef();
                logger.trace("region: " + region.getId() + " index: " + rr.getIndex());
                region.setReadingOrder(rr.getIndex(), region);
            }
        }
    }
}
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)

Aggregations

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