
com.mxgraph.io.graphml.mxGraphMlKeyManager 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.3.1.1.tar.gz".
The purpose of this redistribution is to make the library available
to other Maven projects.
The newest version!
/**
* Copyright (c) 2010 David Benson, Gaudenz Alder
*/
package com.mxgraph.io.graphml;
import java.util.HashMap;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
/**
* This is a singleton class that contains a map with the key elements of the
* document. The key elements are wrapped in instances of mxGmlKey and
* may to be access by ID.
*/
public class mxGraphMlKeyManager
{
/**
* Map with the key elements of the document.
* The key is the key's ID.
*/
private HashMap keyMap = new HashMap();
private static mxGraphMlKeyManager keyManager = null;
/**
* Singleton pattern requires private constructor.
*/
private mxGraphMlKeyManager()
{
}
/**
* Returns the instance of mxGmlKeyManager.
* If no instance has been created until the moment, a new instance is
* returned.
* This method don't load the map.
* @return An instance of mxGmlKeyManager.
*/
public static mxGraphMlKeyManager getInstance()
{
if (keyManager == null)
{
keyManager = new mxGraphMlKeyManager();
}
return keyManager;
}
/**
* Load the map with the key elements in the document.
* The keys are wrapped for instances of mxGmlKey.
* @param doc Document with the keys.
*/
public void initialise(Document doc)
{
NodeList gmlKeys = doc.getElementsByTagName(mxGraphMlConstants.KEY);
int keyLength = gmlKeys.getLength();
for (int i = 0; i < keyLength; i++)
{
Element key = (Element) gmlKeys.item(i);
String keyId = key.getAttribute(mxGraphMlConstants.ID);
mxGraphMlKey keyElement = new mxGraphMlKey(key);
keyMap.put(keyId, keyElement);
}
}
public HashMap getKeyMap()
{
return keyMap;
}
public void setKeyMap(HashMap keyMap)
{
this.keyMap = keyMap;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy