1 package com.jgraph.io.svg;
2 
3 import java.util.Map;
4 
5 public class SVGGraphConstants {
6 
7 	/** Represents the lack of allocation of a shape */
8 	public static final int NO_SHAPE_SPECIFIED = -1;
9 
10 	/** Represents a rectangle shape type */
11 	public static final int SHAPE_RECTANGLE = 0;
12 
13 	/** Represents an ellipse shape type */
14 	public static final int SHAPE_ELLIPSE = 1;
15 
16 	/** Represents an rounded rectangle shape type */
17 	public static final int SHAPE_ROUNDRECT = 2;
18 
19 	/** Represents an cylinder shape type */
20 	public static final int SHAPE_CYLINDER = 3;
21 
22 	/** Represents an diamond shape type */
23 	public static final int SHAPE_DIAMOND = 4;
24 
25 	/** The current default shape to be used */
26 	protected static int defaultShape = SHAPE_RECTANGLE;
27 
28 	/**
29 	 * Key for the <code>vertexShape</code> attribute. Use instances of int as
30 	 * values for this key.
31 	 */
32 	public final static String VERTEXSHAPE = "vertexShape";
33 
34 	/**
35 	 * Key for the <code>hexBorderColor</code> attribute. Use instances of
36 	 * String as values for this key.
37 	 */
38 	public final static String VERTEXSHADOW = "vertexShadow";
39 
40 	/**
41 	 * Sets the value attribute in the specified map to the specified shape type
42 	 * value.
43 	 *
44 	 * @param map
45 	 *            The map to store the shape attribute in.
46 	 * @param shapeType
47 	 *            The value to set the share tpye attribute to. The possible
48 	 *            values for this are defined near the top of this file
49 	 */
setShape(Map map, int shapeType)50 	public static void setShape(Map map, int shapeType) {
51 		Integer wrapperInt = new Integer(shapeType);
52 		map.put(VERTEXSHAPE, wrapperInt);
53 	}
54 
55 	/**
56 	 * Returns the font for the specified attribute map. Uses default font if no
57 	 * font is specified in the attribute map.
58 	 */
getShape(Map map)59 	public static int getShape(Map map) {
60 		Integer wrapperInt = (Integer) map.get(VERTEXSHAPE);
61 		if (wrapperInt != null) {
62 			return wrapperInt.intValue();
63 		}
64 		return NO_SHAPE_SPECIFIED;
65 	}
66 
67 	/**
68 	 * Sets the value attribute in the specified map to the specified shadow
69 	 * value.
70 	 *
71 	 * @param map
72 	 *            The map to store the shape attribute in.
73 	 * @param isShadow
74 	 *            The value to set the shadow attribute to.
75 	 */
setShadow(Map map, boolean isShadow)76 	public static void setShadow(Map map, boolean isShadow) {
77 		map.put(VERTEXSHADOW, new Boolean(isShadow));
78 	}
79 
80 	/**
81 	 * Returns the shadow for the specified attribute map. Uses no shadow by
82 	 * default if none set
83 	 */
isShadow(Map map)84 	public static boolean isShadow(Map map) {
85 		Boolean bool = (Boolean) map.get(VERTEXSHADOW);
86 		if (bool != null)
87 			return bool.booleanValue();
88 		return false;
89 	}
90 
91 }