com.mxgraph.view.mxStyleRegistry 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: mxStyleRegistry.java,v 1.7 2013/02/20 11:41:04 gaudenz Exp $
* Copyright (c) 2007, Gaudenz Alder
*/
package com.mxgraph.view;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import com.mxgraph.util.mxConstants;
/**
* Singleton class that acts as a global converter from string to object values
* in a style. This is currently only used to perimeters and edge styles.
*/
public class mxStyleRegistry
{
/**
* Maps from strings to objects.
*/
protected static Map values = new Hashtable();
// Registers the known object styles
static
{
putValue(mxConstants.EDGESTYLE_ELBOW, mxEdgeStyle.ElbowConnector);
putValue(mxConstants.EDGESTYLE_ENTITY_RELATION,
mxEdgeStyle.EntityRelation);
putValue(mxConstants.EDGESTYLE_LOOP, mxEdgeStyle.Loop);
putValue(mxConstants.EDGESTYLE_SIDETOSIDE, mxEdgeStyle.SideToSide);
putValue(mxConstants.EDGESTYLE_TOPTOBOTTOM, mxEdgeStyle.TopToBottom);
putValue(mxConstants.EDGESTYLE_ORTHOGONAL, mxEdgeStyle.OrthConnector);
putValue(mxConstants.EDGESTYLE_SEGMENT, mxEdgeStyle.SegmentConnector);
putValue(mxConstants.PERIMETER_ELLIPSE, mxPerimeter.EllipsePerimeter);
putValue(mxConstants.PERIMETER_RECTANGLE,
mxPerimeter.RectanglePerimeter);
putValue(mxConstants.PERIMETER_RHOMBUS, mxPerimeter.RhombusPerimeter);
putValue(mxConstants.PERIMETER_TRIANGLE, mxPerimeter.TrianglePerimeter);
putValue(mxConstants.PERIMETER_HEXAGON, mxPerimeter.HexagonPerimeter);
}
/**
* Puts the given object into the registry under the given name.
*/
public static void putValue(String name, Object value)
{
values.put(name, value);
}
/**
* Returns the value associated with the given name.
*/
public static Object getValue(String name)
{
return values.get(name);
}
/**
* Returns the name for the given value.
*/
public static String getName(Object value)
{
Iterator> it = values.entrySet().iterator();
while (it.hasNext())
{
Map.Entry entry = it.next();
if (entry.getValue() == value)
{
return entry.getKey();
}
}
return null;
}
}