Search in sources :

Example 1 with StyleString

use of org.freeplane.features.styles.StyleString in project freeplane by freeplane.

the class NodeTextBuilder method writeAttributes.

public void writeAttributes(final ITreeWriter writer, final Object userObject, final String tag) {
    if (!NodeWriter.shouldWriteSharedContent(writer))
        return;
    final NodeModel node = (NodeModel) userObject;
    final Object data = node.getUserObject();
    if (data == null)
        return;
    final Class<? extends Object> dataClass = data.getClass();
    if (dataClass.equals(StyleTranslatedObject.class)) {
        writer.addAttribute(NodeTextBuilder.XML_NODE_LOCALIZED_TEXT, ((StyleTranslatedObject) data).getObject().toString());
        return;
    }
    if (dataClass.equals(TranslatedObject.class)) {
        writer.addAttribute(NodeTextBuilder.XML_NODE_LOCALIZED_TEXT, ((TranslatedObject) data).getObject().toString());
        return;
    }
    final boolean forceFormatting = Boolean.TRUE.equals(writer.getHint(MapWriter.WriterHint.FORCE_FORMATTING));
    if (forceFormatting) {
        final String text = TextController.getController().getTransformedTextNoThrow(data, node, data);
        if (!HtmlUtils.isHtmlNode(text)) {
            writer.addAttribute(NodeTextBuilder.XML_NODE_TEXT, text.replace('\0', ' '));
        } else {
            node.addExtension(new TransformedXMLExtension(text));
        }
    } else {
        final String text = data.toString();
        if (node.getXmlText() == null) {
            writer.addAttribute(NodeTextBuilder.XML_NODE_TEXT, text.replace('\0', ' '));
        }
        if (!(data instanceof String || data instanceof StyleString)) {
            writer.addAttribute(XML_NODE_OBJECT, TypeReference.toSpec(data));
        }
    }
}
Also used : StyleTranslatedObject(org.freeplane.features.styles.StyleTranslatedObject) NodeModel(org.freeplane.features.map.NodeModel) StyleString(org.freeplane.features.styles.StyleString) StyleTranslatedObject(org.freeplane.features.styles.StyleTranslatedObject) TranslatedObject(org.freeplane.core.resources.TranslatedObject) StyleTranslatedObject(org.freeplane.features.styles.StyleTranslatedObject) IFormattedObject(org.freeplane.features.format.IFormattedObject) TranslatedObject(org.freeplane.core.resources.TranslatedObject) StyleString(org.freeplane.features.styles.StyleString)

Aggregations

TranslatedObject (org.freeplane.core.resources.TranslatedObject)1 IFormattedObject (org.freeplane.features.format.IFormattedObject)1 NodeModel (org.freeplane.features.map.NodeModel)1 StyleString (org.freeplane.features.styles.StyleString)1 StyleTranslatedObject (org.freeplane.features.styles.StyleTranslatedObject)1