Search in sources :

Example 1 with TrpStructureChangedEvent

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));
}
Also used : TextTypeSimpleType(eu.transkribus.core.model.beans.pagecontent.TextTypeSimpleType) TrpStructureChangedEvent(eu.transkribus.core.model.beans.pagecontent_trp.observable.TrpObserveEvent.TrpStructureChangedEvent) TrpTextRegionType(eu.transkribus.core.model.beans.pagecontent_trp.TrpTextRegionType) ITrpShapeType(eu.transkribus.core.model.beans.pagecontent_trp.ITrpShapeType)

Aggregations

TextTypeSimpleType (eu.transkribus.core.model.beans.pagecontent.TextTypeSimpleType)1 ITrpShapeType (eu.transkribus.core.model.beans.pagecontent_trp.ITrpShapeType)1 TrpTextRegionType (eu.transkribus.core.model.beans.pagecontent_trp.TrpTextRegionType)1 TrpStructureChangedEvent (eu.transkribus.core.model.beans.pagecontent_trp.observable.TrpObserveEvent.TrpStructureChangedEvent)1