|
VRJConfig UI API |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.vrjuggler.vrjconfig.commoneditors.devicegraph.GraphHelpers
public abstract class GraphHelpers
A collection of helper functions that can be helpful in extending JGraph.
The basic structure of a device graph is relatively straightfoward. There
are three types of cells: edges, proxy vertices, and device vertices.
Edges must always be of type ProxyToDeviceEdge. Proxy vertices
have the following characteristics:
org.jgraph.graph.DefaultGraphCell
ProxyInfo
DefaultPort) with at most one
out-going edge
org.jgraph.graph.DefaultGraphCell
DeviceInfo
DefaultPort), each of which
contains a user object of type UnitInfo
The functions included in this class take care of all the details related to creating and connecting cells. In particular, there are functions that know about all the default device and device proxy config element types in VR Juggler and know how to create cells and proxies for those types.
DeviceInfo,
ProxyInfo,
UnitInfo,
ProxyToDeviceEdge,
DefaultGraphCell,
DefaultPort| Field Summary |
|---|
| Constructor Summary | |
|---|---|
GraphHelpers()
|
|
| Method Summary | |
|---|---|
static void |
addDevicePorts(DefaultGraphCell cell,
Integer unitType,
int numUnits)
Adds the given number of ports to the given graph cell as children. |
static boolean |
autoSizeCellView(Dimension size,
CellView view,
Hashtable table)
Changes the size of the given CellView reference to be the
given dimensions. |
static void |
autoSizeCellView(JGraph graph,
Dimension size,
CellView view)
Changes the size of the given CellView reference to be the
given dimensions. |
static boolean |
checkProxyDeviceConnection(ProxyInfo proxyInfo,
BaseDeviceInfo deviceInfo,
UnitInfo unitInfo)
Determines whether the given proxy and device can be connected through the given device unit. |
static DefaultEdge |
connectProxyToDevice(DefaultGraphCell proxyCell,
DefaultGraphCell deviceCell,
ConnectionSet cs,
Map attributes)
Creates a connection between proxyCell and
deviceCell using the appropriate port in
deviceCell. |
static DefaultEdge |
connectProxyToDevice(DefaultPort proxyPort,
DefaultPort devicePort,
ConnectionSet cs,
Map attributes)
Creates a connection between proxyPort and
devicePort. |
static DefaultGraphCell |
createBaseDeviceCell(BaseDeviceInfo devInfo,
Map attributes,
int x,
int y,
boolean autoSize)
Creates a basic device graph cell by creating an attribute map using org.vrjuggler.vrjconfig.commoneditors.DeviceGraph.createDeviceAttributes()
and the given parameters. |
static DefaultGraphCell |
createDeviceCell(ConfigElement devElt,
ConfigContext context,
int numUnits,
Map attributes,
int x,
int y,
boolean autoSize)
Creates a new graph cell for the given config element that is used to configure an input device. |
static DefaultGraphCell |
createDeviceCell(ConfigElement devElt,
ConfigContext context,
List proxyTypes,
Map attributes,
int x,
int y,
boolean autoSize)
Creates a new graph cell for the given config element that is used to configure an input device using "artificial" input sources (units). |
static DefaultGraphCell |
createDeviceCell(ConfigElement devElt,
ConfigContext context,
Map attributes)
Creates a new graph cell for the given config element that is used to configure an input device. |
static DefaultGraphCell |
createDeviceCell(ConfigElement devElt,
ConfigContext context,
Map attributes,
int x,
int y,
boolean autoSize)
Creates a new graph cell for the given config element that is used to configure an input device, which has exactly one input source (unit) at all times. |
static DefaultGraphCell |
createDeviceCell(ConfigElement devElt,
ConfigContext context,
String unitPropName,
Map attributes,
int x,
int y,
boolean autoSize)
Creates a new graph cell for the given config element that is used to configure an input device. |
static DefaultPort |
createDevicePort(Integer unitType,
int unitNumber)
Creates a new port for a device cell. |
static DefaultPort |
createDevicePort(Integer unitType,
Integer unitNumber)
Creates a new port for a device cell. |
static DefaultPort |
createDevicePort(UnitInfo unitInfo)
Creates a new port for a device cell. |
static DefaultGraphCell |
createProxyCell(ConfigElement proxyElt,
ConfigContext context,
List aliases,
Map attributes)
Creates a new graph cell for the given config element that is used to configure a device proxy. |
static DefaultGraphCell |
createProxyCell(ConfigElement proxyElt,
ConfigContext context,
List aliases,
Map attributes,
int x,
int y,
boolean autoSize)
Creates a graph cell for a device proxy that has a single port as a child. |
static void |
registerGraphCellCreator(ConfigDefinition def,
DeviceGraphCellCreator c)
Registers the given device graph cell creator as the creator for the given config definition. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GraphHelpers()
| Method Detail |
|---|
public static void registerGraphCellCreator(ConfigDefinition def,
DeviceGraphCellCreator c)
createDeviceCell(ConfigElement,ConfigContext,Map) will be
able to create device graph cells for the given config definition.
def - the config definition that uniquely identifies which
creator to be usedc - the device graph cell creatorcreateDeviceCell(ConfigElement,ConfigContext,Map)
public static void autoSizeCellView(JGraph graph,
Dimension size,
CellView view)
CellView reference to be the
given dimensions. The graph cell associated with the given view must be
in the given graph. If the cell view is resized successfully, an edit is
posted with the graph's layout cache, and the graph is repainted.
graph - the graph that knows about the cell view and its cellsize - the new dimensions for the cell viewview - the cell view to be resizedautoSizeCellView(Dimension,CellView,Hashtable)
public static boolean autoSizeCellView(Dimension size,
CellView view,
Hashtable table)
CellView reference to be the
given dimensions. The resizing is done by modifying the bounds in the
cell view's attributes. The position of the cell view is left unchanged,
but the width and height are changed to the values given in
size. The new attributes are placed into the given
Hashtable object using the view's cell as the key.
size - the new dimensions for the cell viewview - the cell view to be resizedtable - a non-null hashtable used for storing the modified cell
view attributesGraphConstants.setBounds(Map,Rectangle2D),
CellView.getCell()
public static DefaultGraphCell createDeviceCell(ConfigElement devElt,
ConfigContext context,
Map attributes)
DefaultGraphCell instance (with its ports)
that is returned. The creator to use is determined using the config
definition of the given config element. This method is intended to be
used for ensuring correct and easy graph cell creation for config
elements used to configure devices. Creators must be registered prior
to calling this function.
devElt - the config element for the device being represented by
the vertex cell to be createdcontext - the config context where devElt existsattributes - the attribute map where the vertex cell's default
attribute map will be stored by this function
IllegalArgumentException - thrown when the graph cell cannot be created due to one of two
causes: there is no creator known for the config definition of
devElt or the registered creator failedregisterGraphCellCreator(ConfigDefinition,DeviceGraphCellCreator)
public static DefaultGraphCell createDeviceCell(ConfigElement devElt,
ConfigContext context,
Map attributes,
int x,
int y,
boolean autoSize)
devElt - the config element for the device being
represented by the vertex cell to be createdcontext - the config context where devElt
existsattributes - the attribute map where the vertex cell's
default attribute map will be stored by this
functionx - the X coordinate for the initial positionaing
of the new vertexy - the Y coordinate for the initial positionaing
of the new vertexautoSize - flag indicating whether the new cell should be
auto-sizedcreateDeviceCell(ConfigElement,ConfigContext,int,Map,int,int,boolean),
createBaseDeviceCell(BaseDeviceInfo,Map,int,int,boolean)
public static DefaultGraphCell createDeviceCell(ConfigElement devElt,
ConfigContext context,
String unitPropName,
Map attributes,
int x,
int y,
boolean autoSize)
unitPropName. If it is non-null, then
devElt is queried for the number of values of the named
property. Further, a non-null value for unitPropName
indicates that the number of values is variable. If
unitPropName is null, then the number of units is set to 1
and is treated as non-variable. The number of units indicates how many
ports the new graph cell should have initially.
devElt - the config element for the device being
represented by the vertex cell to be createdcontext - the config context where devElt
existsunitPropName - the name of the property that indicates the
number of available units for the represented
deviceattributes - the attribute map where the vertex cell's
default attribute map will be stored by this
functionx - the X coordinate for the initial positionaing
of the new vertexy - the Y coordinate for the initial positionaing
of the new vertexautoSize - flag indicating whether the new cell should be
auto-sizedcreateBaseDeviceCell(BaseDeviceInfo,Map,int,int,boolean)
public static DefaultGraphCell createDeviceCell(ConfigElement devElt,
ConfigContext context,
int numUnits,
Map attributes,
int x,
int y,
boolean autoSize)
numUnits parameter) indicates the fixed number of ports
the new graph cell has.
devElt - the config element for the device being
represented by the vertex cell to be createdcontext - the config context where devElt
existsnumUnits - the fixed number of units this device hasattributes - the attribute map where the vertex cell's
default attribute map will be stored by this
functionx - the X coordinate for the initial positionaing
of the new vertexy - the Y coordinate for the initial positionaing
of the new vertexautoSize - flag indicating whether the new cell should be
auto-sizedcreateBaseDeviceCell(BaseDeviceInfo,Map,int,int,boolean)
public static DefaultGraphCell createDeviceCell(ConfigElement devElt,
ConfigContext context,
List proxyTypes,
Map attributes,
int x,
int y,
boolean autoSize)
devElt - the config element for the device being
represented by the vertex cell to be createdcontext - the config context where devElt existsproxyTypes - the list of proxy types that can point at the deviceattributes - the attribute map where the vertex cell's default
attribute map will be stored by this functionx - the X coordinate for the initial positionaing of the
new vertexy - the Y coordinate for the initial positionaing of the
new vertexautoSize - flag indicating whether the new cell should be
auto-sizedcreateBaseDeviceCell(BaseDeviceInfo,Map,int,int,boolean)
public static DefaultGraphCell createBaseDeviceCell(BaseDeviceInfo devInfo,
Map attributes,
int x,
int y,
boolean autoSize)
org.vrjuggler.vrjconfig.commoneditors.DeviceGraph.createDeviceAttributes()
and the given parameters. The freshly created attribute map is stored
in the given attribute map using the new DefaultGraphCell
instance as its key. In general, user code should not be using this
method directly, but it is made public so that instances of
DeviceGraphCellCreator can utilize it when necessary.
devInfo - the informational object describing the deviceattributes - the attribute map where the vertex cell's default
attribute map will be stored by this functionx - the X coordinate for the initial positionaing of the
new vertexy - the Y coordinate for the initial positionaing of the
new vertexautoSize - flag indicating whether the new cell should be
auto-sizedDeviceGraph.createDeviceAttributes(int,int,boolean),
DeviceGraphCellCreator,
GraphConstants,
AttributeMap
public static void addDevicePorts(DefaultGraphCell cell,
Integer unitType,
int numUnits)
createDevicePort(Integer,int).
cell - the device graph cell to which the ports will be
addedunitType - the type of the input source (unit) for the new
portsnumUnits - the number of ports that will be adddedcreateDevicePort(Integer,int)
public static DefaultGraphCell createProxyCell(ConfigElement proxyElt,
ConfigContext context,
List aliases,
Map attributes)
DefaultGraphCell (with its ports) are
determined based on the type of the config element passed in. This
method is intended to be used for ensuring correct and easy graph cell
creation for config elements used to configure proxies. However, the
config element type must be known a priori in order for this
method to be able to do its job.
proxyElt - the config element for the device proxy being
represented by the vertex cell to be createdcontext - the config context where proxyElt
existsaliases - all the aliases (zero or more) that exist for
proxyEltattributes - the attribute map where the vertex cell's
default attribute map will be stored by this
function
IllegalArgumentException - thrown when the type of proxyElt is unknown to this
method, thus preventing correct creation of a
DefaultGraphCell instance.
public static DefaultGraphCell createProxyCell(ConfigElement proxyElt,
ConfigContext context,
List aliases,
Map attributes,
int x,
int y,
boolean autoSize)
org.vrjuggler.vrjconfig.commoneditors.DeviceGraph.createProxyAttributes(),
and it is stored in the given attribute map.
proxyElt - the config element for the device proxy being
represented by the vertex cell to be createdcontext - the config context where proxyElt
existsaliases - all the aliases (zero or more) that exist for
proxyEltattributes - the attribute map where the vertex cell's
default attribute map will be stored by this
functionx - the X coordinate for the initial positionaing
of the new vertexy - the Y coordinate for the initial positionaing
of the new vertexautoSize - flag indicating whether the new cell should be
auto-sizedDeviceGraph.createProxyAttributes(int,int,boolean)
public static DefaultEdge connectProxyToDevice(DefaultGraphCell proxyCell,
DefaultGraphCell deviceCell,
ConnectionSet cs,
Map attributes)
throws NoSuchPortException
proxyCell and
deviceCell using the appropriate port in
deviceCell. The port to use is determined by the user
object contained in proxyCell, which must be of type
ProxyInfo. The proxy cell's user object will contain the
ConfigElement for the proxy, which in turn provides a unit
number for the device to which the proxy should refer. The proxy config
element and the device config element will remain unchanged.
NoSuchPortException - thrown If the two cells cannot be connected
because no appropriate port exists in
deviceCellProxyInfo,
createProxyCell(ConfigElement,ConfigContext,List,Map,int,int,boolean)
public static DefaultEdge connectProxyToDevice(DefaultPort proxyPort,
DefaultPort devicePort,
ConnectionSet cs,
Map attributes)
throws IllegalArgumentException
proxyPort and
devicePort. The parent of the proxy port must contain a
ProxyInfo object, and the parent of the device port must
contain a DeviceInfo object. The config element in the
ProxyInfo object is changed to reflect the connection.
IllegalArgumentException - thrown If the two ports cannot be connected as a result of a unit
type mismatch between the proxy's allowed type and the device port's
unit typecreateProxyCell(ConfigElement,ConfigContext,List,Map,int,int,boolean)
public static DefaultPort createDevicePort(Integer unitType,
int unitNumber)
unitType - the type of input source for the new portunitNumber - the index of this input source in the device
public static DefaultPort createDevicePort(Integer unitType,
Integer unitNumber)
unitType - the type of input source for the new portunitNumber - the index of this input source in the devicepublic static DefaultPort createDevicePort(UnitInfo unitInfo)
unitInfo - a UnitInfo object containing the
information necessary to create a new port for the
device cell that accurately represents the input
source
public static boolean checkProxyDeviceConnection(ProxyInfo proxyInfo,
BaseDeviceInfo deviceInfo,
UnitInfo unitInfo)
|
VRJConfig UI API |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||