use of eu.transkribus.core.model.beans.pagecontent.ReadingOrderType 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);
}
use of eu.transkribus.core.model.beans.pagecontent.ReadingOrderType 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);
}
}
}
}
Aggregations