com.mxgraph.io.mxGenericChangeCodec Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jgraphx Show documentation
Show all versions of jgraphx Show documentation
JGraphX Swing Component - Java Graph Visualization Library
This is a binary & source redistribution of the original, unmodified JGraphX library originating from:
"https://github.com/jgraph/jgraphx/archive/v3.4.1.3.zip".
The purpose of this redistribution is to make the library available to other Maven projects.
/**
* $Id: mxGenericChangeCodec.java,v 1.1 2010/09/15 09:11:19 gaudenz Exp $
* Copyright (c) 2006, Gaudenz Alder
*/
package com.mxgraph.io;
import java.util.Map;
import org.w3c.dom.Node;
/**
* Codec for mxChildChanges. This class is created and registered
* dynamically at load time and used implicitely via mxCodec
* and the mxCodecRegistry.
*/
public class mxGenericChangeCodec extends mxObjectCodec
{
/**
*
*/
protected String fieldname;
/**
* Constructs a new model codec.
*/
public mxGenericChangeCodec(Object template, String fieldname)
{
this(template, new String[] { "model", "previous" },
new String[] { "cell" }, null, fieldname);
}
/**
* Constructs a new model codec for the given arguments.
*/
public mxGenericChangeCodec(Object template, String[] exclude,
String[] idrefs, Map mapping, String fieldname)
{
super(template, exclude, idrefs, mapping);
this.fieldname = fieldname;
}
/* (non-Javadoc)
* @see com.mxgraph.io.mxObjectCodec#afterDecode(com.mxgraph.io.mxCodec, org.w3c.dom.Node, java.lang.Object)
*/
@Override
public Object afterDecode(mxCodec dec, Node node, Object obj)
{
Object cell = getFieldValue(obj, "cell");
if (cell instanceof Node)
{
setFieldValue(obj, "cell", dec.decodeCell((Node) cell, false));
}
setFieldValue(obj, "previous", getFieldValue(obj, fieldname));
return obj;
}
}