Search in sources :

Example 26 with Savable

use of com.jme3.export.Savable in project jmonkeyengine by jMonkeyEngine.

the class DOMOutputCapsule method writeIntSavableMap.

@Override
public void writeIntSavableMap(IntMap<? extends Savable> map, String name, IntMap<? extends Savable> defVal) throws IOException {
    if (map == null) {
        return;
    }
    if (map.equals(defVal)) {
        return;
    }
    Element stringMap = appendElement(name);
    for (Entry<? extends Savable> entry : map) {
        int key = entry.getKey();
        Element mapEntry = appendElement("MapEntry");
        mapEntry.setAttribute("key", Integer.toString(key));
        Savable s = entry.getValue();
        write(s, "Savable", null);
        currentElement = stringMap;
    }
    currentElement = (Element) stringMap.getParentNode();
}
Also used : Savable(com.jme3.export.Savable) Element(org.w3c.dom.Element)

Example 27 with Savable

use of com.jme3.export.Savable in project jmonkeyengine by jMonkeyEngine.

the class DOMOutputCapsule method writeSavableArrayList.

@Override
public void writeSavableArrayList(ArrayList array, String name, ArrayList defVal) throws IOException {
    if (array == null) {
        return;
    }
    if (array.equals(defVal)) {
        return;
    }
    Element old = currentElement;
    Element el = appendElement(name);
    currentElement = el;
    el.setAttribute(XMLExporter.ATTRIBUTE_SIZE, String.valueOf(array.size()));
    for (Object o : array) {
        if (o == null) {
            continue;
        } else if (o instanceof Savable) {
            Savable s = (Savable) o;
            write(s, s.getClass().getName(), null);
        } else {
            throw new ClassCastException("Not a Savable instance: " + o);
        }
    }
    currentElement = old;
}
Also used : Savable(com.jme3.export.Savable) Element(org.w3c.dom.Element)

Aggregations

Savable (com.jme3.export.Savable)22 IOException (java.io.IOException)8 Element (org.w3c.dom.Element)6 MatParamOverride (com.jme3.material.MatParamOverride)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 InputCapsule (com.jme3.export.InputCapsule)1 BinaryExporter (com.jme3.export.binary.BinaryExporter)1 BinaryImporter (com.jme3.export.binary.BinaryImporter)1 AmbientLight (com.jme3.light.AmbientLight)1 Material (com.jme3.material.Material)1 Bucket (com.jme3.renderer.queue.RenderQueue.Bucket)1 ShadowMode (com.jme3.renderer.queue.RenderQueue.ShadowMode)1 Node (com.jme3.scene.Node)1 Spatial (com.jme3.scene.Spatial)1 Control (com.jme3.scene.control.Control)1 SafeArrayList (com.jme3.util.SafeArrayList)1 BufferedInputStream (java.io.BufferedInputStream)1 BufferedOutputStream (java.io.BufferedOutputStream)1 FileOutputStream (java.io.FileOutputStream)1