forked from jgraph/mxgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmxStyleRegistry.java
More file actions
80 lines (67 loc) · 2.04 KB
/
mxStyleRegistry.java
File metadata and controls
80 lines (67 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
* 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<String, Object> values = new Hashtable<String, Object>();
// 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<Map.Entry<String, Object>> it = values.entrySet().iterator();
while (it.hasNext())
{
Map.Entry<String, Object> entry = it.next();
if (entry.getValue() == value)
{
return entry.getKey();
}
}
return null;
}
}