public class IlvSDMUtilitiesFactory extends Object implements Serializable
IlvSDMUtilitiesFactory
is a factory that creates the various utility objects
used by an IlvSDMView
.
You can derive this class if you want to create modified instances of these utility objects.
Example:
Suppose you want to prevent users from connecting links
to nodes of a given type. The following code sample
shows how to do this using a factory that creates subclasses of
IlvMakeSDMLinkInteractor
and IlvSDMLinkReconnector
.
public void setFactory(IlvSDMView view) { final IlvSDMEngine engine = view.getSDMEngine(); view.setUtilitiesFactory(new IlvSDMUtilitiesFactory(){ // Tests if a node can be connected. // private boolean acceptNode(Object obj) { return !engine.getModel().getTag(obj).equals("not_connectable"); } // Creates a link creation interactor that calls acceptNode. // public IlvMakeSDMLinkInteractor createMakeSDMLinkInteractor(final IlvSDMEngine engine, IlvManagerView paletteView) { return new IlvMakeSDMLinkInteractor(){ protected boolean acceptOrigin(IlvPoint p, IlvGraphic g){ if(!super.acceptOrigin(p, g)) return false; return acceptNode(engine.getObject(g)); } protected boolean acceptDestination(IlvPoint p, IlvGraphic g){ if(!super.acceptOrigin(p, g)) return false; return acceptNode(engine.getObject(g)); } protected void highlight(IlvGraphic g) { if(acceptNode(engine.getObject(g))){ super.highlight(g); } } }; } // Creates a link reconnector that calls acceptNode. // public IlvSDMLinkReconnector createLinkReconnector(IlvSDMEngine engine, IlvManagerView view) { return new IlvSDMLinkReconnector(engine, view){ protected boolean acceptOrigin(Object link, Object obj){ return acceptNode(obj); } protected boolean acceptDestination(Object link, Object obj){ return acceptNode(obj); } }; } }); }
IlvSDMView.setUtilitiesFactory(ilog.views.sdm.util.IlvSDMUtilitiesFactory)
,
Serialized FormConstructor and Description |
---|
IlvSDMUtilitiesFactory()
Creates a new
IlvSDMUtilitiesFactory . |
Modifier and Type | Method and Description |
---|---|
IlvSDMDragSource |
createDragSource(IlvSDMEngine engine,
IlvManagerView view)
Returns a new instance of
IlvSDMDragSource . |
IlvSDMDropTarget |
createDropTarget(IlvSDMEngine engine,
IlvManagerView view)
Returns a new instance of
IlvSDMDropTarget . |
IlvSDMLinkReconnector |
createLinkReconnector(IlvSDMEngine engine,
IlvManagerView view)
Returns a new instance of
IlvSDMLinkReconnector . |
IlvMakeSDMLinkInteractor |
createMakeSDMLinkInteractor(IlvSDMEngine engine,
IlvManagerView targetView)
Returns a new instance of
IlvMakeSDMLinkInteractor . |
IlvMakeSDMNodeInteractor |
createMakeSDMNodeInteractor(IlvSDMEngine engine,
IlvManagerView targetView)
Returns a new instance of
IlvMakeSDMNodeInteractor . |
IlvSDMPaletteConnector |
createPaletteConnector(IlvSDMEngine engine,
IlvManagerView paletteView)
Returns a new instance of
IlvSDMPaletteConnector . |
public IlvSDMUtilitiesFactory()
IlvSDMUtilitiesFactory
.public IlvSDMDragSource createDragSource(IlvSDMEngine engine, IlvManagerView view)
IlvSDMDragSource
.
This method is called the first time the method
IlvSDMView.setDragEnabled(boolean)
is called, to create the drag source.
engine
- The SDM engine.view
- The SDM view.public IlvSDMDropTarget createDropTarget(IlvSDMEngine engine, IlvManagerView view)
IlvSDMDropTarget
.
This method is called the first time the method
IlvSDMView.setDropEnabled(boolean)
is called, to create the drop target.
engine
- The SDM engine.view
- The SDM view.public IlvSDMLinkReconnector createLinkReconnector(IlvSDMEngine engine, IlvManagerView view)
IlvSDMLinkReconnector
.
This method is called the first time the method
IlvSDMView.setLinkReconnectionEnabled(boolean)
is called, to create the link reconnector.
engine
- The SDM engine.view
- The SDM view.public IlvSDMPaletteConnector createPaletteConnector(IlvSDMEngine engine, IlvManagerView paletteView)
IlvSDMPaletteConnector
.
This method is called the first time the method
setTargetView
is called, to create the palette connector.
engine
- The SDM engine.paletteView
- The SDM view used as a palette for the IlvSDMPaletteConnector
.public IlvMakeSDMNodeInteractor createMakeSDMNodeInteractor(IlvSDMEngine engine, IlvManagerView targetView)
IlvMakeSDMNodeInteractor
.
This method is called by the method
setTargetView
each time the target view of a palette is changed.
engine
- The SDM engine.targetView
- The target view used by the IlvSDMPaletteConnector
.public IlvMakeSDMLinkInteractor createMakeSDMLinkInteractor(IlvSDMEngine engine, IlvManagerView targetView)
IlvMakeSDMLinkInteractor
.
This method is called by the method
setTargetView
each time the target view of a palette is changed.
engine
- The SDM engine.targetView
- The target view used by the IlvSDMPaletteConnector
.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.