Search in sources :

Example 51 with XMLElement

use of net.n3.nanoxml.XMLElement in project freeplane by freeplane.

the class ReminderHook method createExtension.

@Override
protected IExtension createExtension(final NodeModel node, final XMLElement element) {
    final ReminderExtension reminderExtension = new ReminderExtension(node);
    final XMLElement parameters = element.getFirstChildNamed("Parameters");
    final String time = parameters.getAttribute(REMINDUSERAT, "0");
    final String unit = parameters.getAttribute(UNIT, "DAY");
    final String period = parameters.getAttribute(PERIOD, "1");
    reminderExtension.setRemindUserAt(Long.parseLong(time));
    reminderExtension.setPeriodUnit(PeriodUnit.valueOf(unit));
    reminderExtension.setPeriod(Integer.parseInt(period));
    final String script = parameters.getAttribute(SCRIPT, null);
    reminderExtension.setScript(script);
    return reminderExtension;
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 52 with XMLElement

use of net.n3.nanoxml.XMLElement in project freeplane by freeplane.

the class EdgeBuilder method writeContent.

private void writeContent(final ITreeWriter writer, final NodeModel node, final EdgeModel model, final boolean forceFormatting) throws IOException {
    final EdgeStyle styleObj = forceFormatting ? ec.getStyle(node) : model.getStyle();
    final String style = EdgeStyle.toString(styleObj);
    final Color color = forceFormatting ? ec.getColor(node) : model.getColor();
    final int width = forceFormatting ? ec.getWidth(node) : model.getWidth();
    final DashVariant dash = forceFormatting ? ec.getDash(node) : model.getDash();
    if (forceFormatting || style != null || color != null || width != EdgeModel.DEFAULT_WIDTH || dash != null) {
        final XMLElement edge = new XMLElement();
        edge.setName("edge");
        boolean relevant = false;
        if (style != null) {
            if (style.equals(EdgeStyle.EDGESTYLE_HIDDEN)) {
                edge.setAttribute("HIDE", "true");
                relevant = true;
            }
            edge.setAttribute("STYLE", style);
            relevant = true;
        }
        if (color != null) {
            ColorUtils.setColorAttributes(edge, "COLOR", "ALPHA", color);
            relevant = true;
        }
        if (width != EdgeModel.WIDTH_PARENT) {
            if (width == EdgeModel.WIDTH_THIN) {
                edge.setAttribute("WIDTH", EdgeModel.EDGEWIDTH_THIN);
            } else {
                edge.setAttribute("WIDTH", Integer.toString(width));
            }
            relevant = true;
        }
        if (dash != null) {
            edge.setAttribute("DASH", dash.name());
            relevant = true;
        }
        if (relevant) {
            writer.addElement(model, edge);
        }
    }
}
Also used : DashVariant(org.freeplane.features.DashVariant) Color(java.awt.Color) XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 53 with XMLElement

use of net.n3.nanoxml.XMLElement in project freeplane by freeplane.

the class OptionPanelWindowConfigurationStorage method decorateDialog.

public static OptionPanelWindowConfigurationStorage decorateDialog(final String marshalled, final JDialog dialog) {
    final OptionPanelWindowConfigurationStorage storage = new OptionPanelWindowConfigurationStorage();
    final XMLElement xml = storage.unmarschall(marshalled, dialog);
    if (xml != null) {
        storage.panel = xml.getAttribute("panel", null);
        return storage;
    }
    return null;
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 54 with XMLElement

use of net.n3.nanoxml.XMLElement in project freeplane by freeplane.

the class UnknownElementWriter method writeAttributes.

public void writeAttributes(final ITreeWriter writer, final Object userObject, final IExtension extension) {
    final UnknownElements elements = (UnknownElements) extension;
    final XMLElement unknownElements = elements.getUnknownElements();
    if (unknownElements != null) {
        final Enumeration<String> unknownAttributes = unknownElements.enumerateAttributeNames();
        while (unknownAttributes.hasMoreElements()) {
            final String name = unknownAttributes.nextElement();
            final String value = unknownElements.getAttribute(name, null);
            writer.addAttribute(name, value);
        }
    }
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 55 with XMLElement

use of net.n3.nanoxml.XMLElement in project freeplane by freeplane.

the class StdXMLBuilder method startElement.

/**
 * This method is called when a new XML element is encountered.
 *
 * @see #endElement
 * @param name
 *            the name of the element.
 * @param nsPrefix
 *            the prefix used to identify the namespace. If no namespace has
 *            been specified, this parameter is null.
 * @param nsURI
 *            the URI associated with the namespace. If no namespace has
 *            been specified, or no URI is associated with nsPrefix, this
 *            parameter is null.
 * @param systemID
 *            the system ID of the XML data source.
 * @param lineNr
 *            the line in the source where the element starts.
 */
public void startElement(final String name, final String nsPrefix, final String nsURI, final String systemID, final int lineNr) {
    String fullName = name;
    if (nsPrefix != null) {
        fullName = nsPrefix + ':' + name;
    }
    final XMLElement elt = new XMLElement(fullName, nsURI, systemID, lineNr);
    last = elt;
    if (stack.empty()) {
        root = elt;
    } else {
        final XMLElement top = (XMLElement) stack.peek();
        top.addChild(elt);
    }
    stack.push(elt);
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Aggregations

XMLElement (org.freeplane.n3.nanoxml.XMLElement)63 IOException (java.io.IOException)8 IXMLParser (org.freeplane.n3.nanoxml.IXMLParser)6 IXMLReader (org.freeplane.n3.nanoxml.IXMLReader)6 StdXMLReader (org.freeplane.n3.nanoxml.StdXMLReader)6 ASelectableCondition (org.freeplane.features.filter.condition.ASelectableCondition)5 NodeModel (org.freeplane.features.map.NodeModel)5 BufferedInputStream (java.io.BufferedInputStream)4 File (java.io.File)4 FileInputStream (java.io.FileInputStream)4 XMLWriter (org.freeplane.n3.nanoxml.XMLWriter)4 Color (java.awt.Color)3 FileWriter (java.io.FileWriter)3 Writer (java.io.Writer)3 IXMLElement (net.n3.nanoxml.IXMLElement)3 XMLElement (net.n3.nanoxml.XMLElement)3 XMLException (org.freeplane.n3.nanoxml.XMLException)3 Point (java.awt.Point)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2