Search in sources :

Example 1 with TrpTextStyleChangedEvent

use of eu.transkribus.core.model.beans.pagecontent_trp.observable.TrpObserveEvent.TrpTextStyleChangedEvent in project TranskribusCore by Transkribus.

the class TextStyleTypeUtils method addTextStyleTag.

/**
 * Add this text style tag to the given shape. Also checks if the resulting text style tag is covering the whole area and then sets the global text style also if so.
 */
public static void addTextStyleTag(ITrpShapeType shape, TextStyleTag s, String addOnlyThisProperty, /*boolean recursive,*/
Object who) {
    if (!(shape instanceof TrpTextRegionType || shape instanceof TrpTextLineType || shape instanceof TrpWordType))
        return;
    // add text style tag to custom list:
    shape.getCustomTagList().addOrMergeTag(s, addOnlyThisProperty);
    logger.debug("customtaglist=" + shape.getCustomTagList());
    // apply text style tag to global text style if the text style tag is a single index tag over the whole range of the shape:
    boolean isS = shape.getCustomTagList().isSingleIndexedTagOverShapeRange(TextStyleTag.TAG_NAME);
    logger.debug("isSingleIndexedTagOverShapeRange: " + isS);
    // deactivate observer to avoid excessive events...
    boolean isActive = shape.getObservable().isActive();
    shape.getObservable().setActive(false);
    // if (USE_GLOBAL_TEXT_STYLE) {
    if (isS) {
        // logger.debug("HERE");
        shape.setTextStyle(s.getTextStyle(), false, shape);
    } else {
        shape.setTextStyle(null, false, shape);
    }
    // }
    // else {
    // //			shape.setTextStyle(null);
    // shape.setTextStyle(null, false, shape); // erase global text style
    // }
    logger.debug("CUSTOM AFTER: " + shape.getCustom());
    shape.getObservable().setActive(isActive);
    // apply recursively:
    // if (recursive) {
    // for (ITrpShapeType c : shape.getChildren(recursive)) {
    // c.getObservable().setActive(false);
    // c.addTextStyleTag(s, addOnlyThisProperty, /*recursive,*/ who);
    // c.getObservable().setActive(true);
    // }
    // }
    // send text style changed event:
    shape.getObservable().setChangedAndNotifyObservers(new TrpTextStyleChangedEvent(who));
}
Also used : TrpTextLineType(eu.transkribus.core.model.beans.pagecontent_trp.TrpTextLineType) TrpTextStyleChangedEvent(eu.transkribus.core.model.beans.pagecontent_trp.observable.TrpObserveEvent.TrpTextStyleChangedEvent) TrpTextRegionType(eu.transkribus.core.model.beans.pagecontent_trp.TrpTextRegionType) TrpWordType(eu.transkribus.core.model.beans.pagecontent_trp.TrpWordType)

Example 2 with TrpTextStyleChangedEvent

use of eu.transkribus.core.model.beans.pagecontent_trp.observable.TrpObserveEvent.TrpTextStyleChangedEvent in project TranskribusCore by Transkribus.

the class TextStyleTypeUtils method setTextStyleTag.

/**
 * Sets the <em>global</em> text style for the given shape.
 */
public static void setTextStyleTag(ITrpShapeType shape, TextStyleType s, boolean recursive, Object who) {
    shape.setTextStyle(TextStyleTypeUtils.addTextStyleTypeFields(s, shape.getTextStyle(), true));
    TextStyleTypeUtils.applyTextStyleToCustomTag(shape);
    if (recursive) {
        for (ITrpShapeType c : shape.getChildren(recursive)) {
            c.getObservable().setActive(false);
            c.setTextStyle(s, recursive, who);
            c.getObservable().setActive(true);
        }
    }
    shape.getObservable().setChangedAndNotifyObservers(new TrpTextStyleChangedEvent(who));
}
Also used : TrpTextStyleChangedEvent(eu.transkribus.core.model.beans.pagecontent_trp.observable.TrpObserveEvent.TrpTextStyleChangedEvent) ITrpShapeType(eu.transkribus.core.model.beans.pagecontent_trp.ITrpShapeType)

Aggregations

TrpTextStyleChangedEvent (eu.transkribus.core.model.beans.pagecontent_trp.observable.TrpObserveEvent.TrpTextStyleChangedEvent)2 ITrpShapeType (eu.transkribus.core.model.beans.pagecontent_trp.ITrpShapeType)1 TrpTextLineType (eu.transkribus.core.model.beans.pagecontent_trp.TrpTextLineType)1 TrpTextRegionType (eu.transkribus.core.model.beans.pagecontent_trp.TrpTextRegionType)1 TrpWordType (eu.transkribus.core.model.beans.pagecontent_trp.TrpWordType)1