use of eu.transkribus.core.model.beans.pagecontent_trp.observable.TrpObserveEvent.TrpStructureChangedEvent in project TranskribusCore by Transkribus.
the class CustomTagUtil method setStructure.
public static void setStructure(ITrpShapeType shape, String structureType, boolean recursive, Object who) {
if (shape == null)
return;
logger.trace("setting structure: " + structureType + " id: " + shape.getId() + " type: " + shape.getClass().getSimpleName() + " recursive: " + recursive);
if (!isTextregionOrLineOrWord(shape))
return;
if (shape instanceof TrpTextRegionType) {
// if this is a text region, also set PAGE structure field if possible
TextTypeSimpleType s = StructureTag.parseTextType(structureType);
((TrpTextRegionType) shape).setType(s);
}
// set custom tag:
if (structureType == null || structureType.equals(""))
shape.getCustomTagList().removeTags(StructureTag.TAG_NAME);
else {
shape.getCustomTagList().addOrMergeTag(new StructureTag(structureType), null);
}
if (recursive) {
for (ITrpShapeType c : shape.getChildren(recursive)) {
c.setStructure(structureType, recursive, who);
}
}
shape.getObservable().setChangedAndNotifyObservers(new TrpStructureChangedEvent(who));
}
Aggregations