001: /*
002: * $Id: JGraphpadGraphConstants.java,v 1.1.1.1 2005/08/04 11:21:58 gaudenz Exp $
003: * Copyright (c) 2001-2005, Gaudenz Alder
004: *
005: * All rights reserved.
006: *
007: * See LICENSE file for license details. If you are unable to locate
008: * this file please contact info (at) jgraph (dot) com.
009: */
010: package com.jgraph.pad.graph;
011:
012: import java.awt.geom.Point2D;
013: import java.util.Map;
014:
015: import org.jgraph.graph.Edge;
016: import org.jgraph.graph.GraphConstants;
017:
018: import com.jgraph.pad.util.JGraphpadParallelEdgeRouter;
019: import com.jgraph.pad.util.JGraphpadParallelSplineRouter;
020:
021: /**
022: * JGraphpad graph constants. Contains special constants supported by the
023: * renderers or other functionality.
024: */
025: public class JGraphpadGraphConstants extends GraphConstants {
026:
027: /**
028: * Shared routing instance for parallel routing.
029: */
030: public final static Edge.Routing ROUTING_PARALLEL = JGraphpadParallelEdgeRouter.sharedInstance;
031:
032: /**
033: * Shared routing instance for parallel spline routing.
034: */
035: public final static Edge.Routing ROUTING_PARALLELSPLINE = JGraphpadParallelSplineRouter.sharedInstance;
036:
037: /**
038: * Key for the <code>stretchImage</code> attribute. This special attribute
039: * contains a Boolean instance indicating whether the background image
040: * should be stretched.
041: */
042: public final static String STRETCHIMAGE = "stretchImage";
043:
044: /**
045: * Key for the <code>groupResize</code> attribute. This special attribute
046: * contains a Boolean instance indicating if the group should be resized
047: * when it is collapsed. This is usually set to true before the first
048: * collapse and then removed.
049: */
050: public final static String GROUPRESIZE = "groupResize";
051:
052: /**
053: * Key for the <code>groupReposition</code> attribute. This special
054: * attribute contains a Boolean instance indicating if the collapsed group
055: * should be moved to the top left corner of it's child area when it is
056: * collapsed.
057: */
058: public final static String GROUPREPOSITION = "groupReposition";
059:
060: /**
061: * Key for the <code>vertexShape</code> attribute. This special attribute
062: * contains an Integer instance indicating which shape should be drawn by
063: * the renderer.
064: */
065: public final static String VERTEXSHAPE = "vertexShape";
066:
067: /**
068: * Key for the <code>sourcePortOffset</code> attribute. This special
069: * attribute contains a Point2D instance indicating the relative position of
070: * a port in its parents coordinate space seen from a specific edge.
071: */
072: public final static String SOURCEPORTOFFSET = "sourcePortOffset";
073:
074: /**
075: * Key for the <code>targetPortOffset</code> attribute. This special
076: * attribute contains a Point2D instance indicating the relative position of
077: * a port in its parents coordinate space seen from a specific edge.
078: */
079: public final static String TARGETPORTOFFSET = "targetPortOffset";
080:
081: /**
082: * Returns true if stretchImage in this map is true. Default is false.
083: */
084: public static final boolean isStretchImage(Map map) {
085: Boolean boolObj = (Boolean) map.get(STRETCHIMAGE);
086: if (boolObj != null)
087: return boolObj.booleanValue();
088: return false;
089: }
090:
091: /**
092: * Sets stretchImage in the specified map to the specified value.
093: */
094: public static final void setStretchImage(Map map,
095: boolean stretchImage) {
096: map.put(STRETCHIMAGE, new Boolean(stretchImage));
097: }
098:
099: /**
100: * Returns true if groupResize in this map is true. Default is false.
101: */
102: public static final boolean isGroupResize(Map map) {
103: Boolean boolObj = (Boolean) map.get(GROUPRESIZE);
104: if (boolObj != null)
105: return boolObj.booleanValue();
106: return false;
107: }
108:
109: /**
110: * Sets groupResize in the specified map to the specified value.
111: */
112: public static final void setGroupResize(Map map,
113: boolean stretchImage) {
114: map.put(GROUPRESIZE, new Boolean(stretchImage));
115: }
116:
117: /**
118: * Returns true if groupReposition in this map is true. Default is true.
119: */
120: public static final boolean isGroupReposition(Map map) {
121: Boolean boolObj = (Boolean) map.get(GROUPREPOSITION);
122: if (boolObj != null)
123: return boolObj.booleanValue();
124: return true;
125: }
126:
127: /**
128: * Sets groupReposition in the specified map to the specified value.
129: */
130: public static final void setGroupReposition(Map map,
131: boolean stretchImage) {
132: map.put(GROUPREPOSITION, new Boolean(stretchImage));
133: }
134:
135: /**
136: * Sets vertexShape in the specified map to the specified value.
137: */
138: public static final void setVertexShape(Map map, int shape) {
139: map.put(VERTEXSHAPE, new Integer(shape));
140: }
141:
142: /**
143: * Returns vertexShape from the specified map.
144: */
145: public static final int getVertexShape(Map map) {
146: Integer intObj = (Integer) map.get(VERTEXSHAPE);
147: if (intObj != null)
148: return intObj.intValue();
149: return 0;
150: }
151:
152: /**
153: * Sets sourcePortOffset in the specified map to the specified value.
154: */
155: public static final void setSourcePortOffset(Map map, Point2D offset) {
156: map.put(SOURCEPORTOFFSET, offset);
157: }
158:
159: /**
160: * Returns sourcePortOffset from the specified map.
161: */
162: public static final Point2D getSourcePortOffset(Map map) {
163: return (Point2D) map.get(SOURCEPORTOFFSET);
164: }
165:
166: /**
167: * Sets targetPortOffset in the specified map to the specified value.
168: */
169: public static final void setTargetPortOffset(Map map, Point2D offset) {
170: map.put(TARGETPORTOFFSET, offset);
171: }
172:
173: /**
174: * Returns targetPortOffset from the specified map.
175: */
176: public static final Point2D getTargetPortOffset(Map map) {
177: return (Point2D) map.get(TARGETPORTOFFSET);
178: }
179:
180: /**
181: * Returns the shared instance of the parallel routing.
182: */
183: public static Edge.Routing getParallelEdgeRouting() {
184: return ROUTING_PARALLEL;
185: }
186:
187: /**
188: * Returns the shared instance of the parallel spline routing.
189: */
190: public static Edge.Routing getParallelSplineRouting() {
191: return ROUTING_PARALLELSPLINE;
192: }
193:
194: }
|