|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.yworks.yfiles.server.tiles.servlet.BaseServlet
com.yworks.yfiles.server.tiles.servlet.UpdateServlet
This servlet performs updates on server side graphs. See
handlePostRequest(HttpServletRequest, HttpServletResponse)
and
BaseServlet.handleGetRequest(HttpServletRequest, HttpServletResponse)
for details.
There are several protected methods acting on the graph level which are called for handling requests,
e.g. createNode(Graph2D, double, double, String)
. These can be customized in a subclass.
The appaerance of created graph elements can be influenced by setting the defaults, e.g.
setDefaultNodeRealizer(NodeRealizer)
, or by registering custom node realizers
(registerNodeRealizer(String, NodeRealizer)
).
Field Summary |
Fields inherited from class com.yworks.yfiles.server.tiles.servlet.BaseServlet |
EDGE_DESCRIPTION_KEY, EDGE_URL_KEY, NODE_DESCRIPTION_KEY, NODE_URL_KEY |
Constructor Summary | |
UpdateServlet()
|
Method Summary | |
protected void |
adjustPortOffsets(Graph2D graph,
Node node,
double wOld,
double hOld,
double wNew,
double hNew)
|
protected void |
closeGroup(Graph2D graph,
Node node)
converts the given group node to a folder node. |
protected Edge |
createEdge(Graph2D graph,
Node source,
Node target,
int route)
is called for creating a new edge. |
protected String |
createFolderName(Graph2D graph,
Node groupNode)
is used to provide a an initial name for a newly created folder node. |
protected Node |
createFolderNode(Graph2D graph,
double x,
double y,
String nodeType,
String parentNodeId)
creates a new folder node. |
protected String |
createGroupName(Graph2D graph,
Node groupNode)
is used to provide a an initial name for a newly created group node. |
protected Node |
createGroupNode(Graph2D graph,
double x,
double y,
String nodeType,
String parentNodeId)
creates a new group node. |
protected Node |
createNode(Graph2D graph,
double x,
double y,
String nodeType)
is called for creating a node. |
static EdgeRealizer |
getDefaultEdgeRealizer()
Gets the default realizer used to create new edges. |
static NodeRealizer |
getDefaultFolderNodeRealizer()
Gets the default realizer used to create new folder nodes. |
static NodeRealizer |
getDefaultGroupNodeRealizer()
Gets the default realizer used to create new group nodes. |
static NodeRealizer |
getDefaultNodeRealizer()
Gets the default realizer used to create new nodes. |
int |
getGraphBoundsMargin()
Get the margin that is added to the graph bounds reported in the servlet response. |
static NodeRealizer |
getNodeRealizer(String type)
Returns the node realizer registered for the given symbolic name or null . |
static String[] |
getNodeRealizerTypes()
Returns the symbolic names of all registered node realizers. |
protected void |
handlePostRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
handles update requests. |
protected void |
moveBends(BendList bendsToMove,
double deltaX,
double deltaY)
moves the given bends by the given offset. |
protected void |
moveNodes(Graph2D graph,
NodeList nodeList,
double deltaX,
double deltaY,
int route)
Moves a set of nodes by the given vector. |
protected void |
moveToSubgraph(Graph2D graph,
Node parentNode,
NodeList subNodes)
moves a set of nodes to the inner graph of the given parent folder or group node. |
protected void |
openFolder(Graph2D graph,
Node node)
converts the given folder node to a group node. |
static void |
registerNodeRealizer(String type,
NodeRealizer defaultNodeRealizer)
Registers the given node realizers for the given symbolic name. |
protected void |
removeEdge(Graph2D graph,
Edge edge)
removes the given edge from the graph. |
protected void |
removeEdgeLabel(Graph2D graph,
EdgeLabel edgeLabel)
removes the given edge label from the graph. |
protected void |
removeNode(Graph2D graph,
Node node)
removes the given node from the graph. |
protected void |
removeNodeLabel(Graph2D graph,
NodeLabel nodeLabel)
removes the given node label from the graph. |
protected void |
resizeNodes(Graph2D graph,
NodeList nodeList,
String mode,
double deltaWidth,
double deltaHeight,
int route)
resizes a set of nodes by given deltas. |
protected void |
routeEdges(Graph2D graph)
routes the edges of the given graph specified by the data provider with the key Layouter.SELECTED_EDGES . |
static void |
setDefaultEdgeRealizer(EdgeRealizer edgeRealizer)
Sets the default realizer used to create new edges. |
static void |
setDefaultFolderNodeRealizer(NodeRealizer nodeRealizer)
Sets the default realizer used to create new folder nodes. |
static void |
setDefaultGroupNodeRealizer(NodeRealizer nodeRealizer)
Sets the default realizer used to create new group nodes. |
static void |
setDefaultNodeRealizer(NodeRealizer nodeRealizer)
Sets the default realizer used to create new nodes. |
void |
setGraphBoundsMargin(int graphBoundsMargin)
Set the margin that is added to the graph bounds reported in the servlet response. |
protected void |
setLabelText(Graph2D graph,
Node node,
String text)
sets the text of the first label of the given node. |
protected void |
setText(Graph2D graph,
NodeLabel nl,
String text)
sets the text of the given node label. |
protected void |
switchToSubgraph(javax.servlet.http.HttpSession session,
String graphName,
Graph2D newGraph,
Graph2D oldGraph)
switches from an old subgraph to a new subgraph in the same hierarchically organized graph (structure). |
Methods inherited from class com.yworks.yfiles.server.tiles.servlet.BaseServlet |
addViewConfigurator, cachedGraphs, cacheGraph, doGet, doPost, getEdgeDescription, getEdgeURL, getForId, getGraph, getGraphBounds, getGraphContentBounds, getId, getId, getId, getId, getNodeDescription, getNodeURL, getReadWriteLock, getSessionMonitor, getViewConfigurators, getWriter, handleGetRequest, hasDescriptions, hasURLs, init, initialize, isUseJSONPrefixing, lookupId, lookupId, lookupId, lookupId, newGraph, readLock, registerLicense, removeViewConfigurator, setEdgeDescription, setEdgeURL, setNodeDescription, setNodeURL, uncacheGraph, unlockRead, unlockWrite, updateEdgePaths, validateIds, writeContentBounds, writeLock, writeWorldBounds |
Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public UpdateServlet()
Method Detail |
public static NodeRealizer getDefaultNodeRealizer()
setDefaultNodeRealizer(NodeRealizer)
public static void setDefaultNodeRealizer(NodeRealizer nodeRealizer)
nodeRealizer
- the default node realizergetDefaultNodeRealizer()
public static EdgeRealizer getDefaultEdgeRealizer()
setDefaultEdgeRealizer(EdgeRealizer)
public static void setDefaultEdgeRealizer(EdgeRealizer edgeRealizer)
edgeRealizer
- the default edge realizergetDefaultEdgeRealizer()
public static NodeRealizer getDefaultFolderNodeRealizer()
setDefaultFolderNodeRealizer(NodeRealizer)
public static void setDefaultFolderNodeRealizer(NodeRealizer nodeRealizer)
nodeRealizer
- the default folder node realizergetDefaultFolderNodeRealizer()
public static NodeRealizer getDefaultGroupNodeRealizer()
setDefaultGroupNodeRealizer(NodeRealizer)
public static void setDefaultGroupNodeRealizer(NodeRealizer nodeRealizer)
nodeRealizer
- the default group node realizergetDefaultGroupNodeRealizer()
public int getGraphBoundsMargin()
0
).
For backwards compatibility, this property can be set to 10.
public void setGraphBoundsMargin(int graphBoundsMargin)
0
).
For backwards compatibility, this property can be set to 10.
protected void handlePostRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
createNode(Graph2D, double, double, String)
.
handlePostRequest
in class BaseServlet
request
- the requestresponse
- the response to write to
javax.servlet.ServletException
IOException
protected void moveNodes(Graph2D graph, NodeList nodeList, double deltaX, double deltaY, int route)
graph
- the current graphnodeList
- the nodes to be moveddeltaX
- x-coordinate of movement vector (world units)deltaY
- y-coordinate of movement vector (world units)route
- whether to route the affected edgesprotected void moveBends(BendList bendsToMove, double deltaX, double deltaY)
moveNodes(y.view.Graph2D, y.base.NodeList, double, double, int)
unless an edge router
is used to reroute the affected edges.
bendsToMove
- the bends to movedeltaX
- x-coordinate of movement vector (world units)deltaY
- y-coordinate of movement vector (world units)protected void routeEdges(Graph2D graph)
Layouter.SELECTED_EDGES
. This method is called by
moveNodes(y.view.Graph2D, y.base.NodeList, double, double, int)
if using an
edge router was requested.
graph
- a graphprotected void resizeNodes(Graph2D graph, NodeList nodeList, String mode, double deltaWidth, double deltaHeight, int route)
resizes a set of nodes by given deltas. The size change is specified by the mode and the delta values for width and height. The mode specifies the changing corner or side of the bounding boxes of the resized nodes.
Resizing a non-empty group node with the auto bounds feature may not have the desired effect, since its bounds are calculated from its children. Each node will have a width and height of at least 1.0 after the resize even if the corresponding delta is larger.
graph
- the current graphnodeList
- the nodes to be movedmode
- either "NW", "N", "NE", "W", "E", "SW", "S" or "SE"deltaWidth
- the change of the width (world units)deltaHeight
- the change of the height (world units)route
- whether to route the affected edgesprotected void setText(Graph2D graph, NodeLabel nl, String text)
graph
- the current graphnl
- the node labeltext
- the new text for the labelprotected void setLabelText(Graph2D graph, Node node, String text)
graph
- the current graphnode
- the nodetext
- the new text for the first node labelprotected Node createNode(Graph2D graph, double x, double y, String nodeType)
null
the default node
realizer is used. Subclasses can overwrite this method.
graph
- the graph to add a node tox
- the x coordinate of the new node in world coordinatesy
- the y coordinate of the new node in world coordinatesnodeType
- the type of node to be created (may be null
)
getDefaultNodeRealizer()
,
registerNodeRealizer(String, NodeRealizer)
,
getNodeRealizerTypes()
protected Node createGroupNode(Graph2D graph, double x, double y, String nodeType, String parentNodeId)
graph
- the current subgraphx
- x-coordinate of the center of the new group nodey
- y-coordinate of the center of the new group nodenodeType
- a symbolic name for a type of node to create, if null
the default is usedparentNodeId
- id of the parent node of the new group node (may be null
)
getDefaultGroupNodeRealizer()
protected Node createFolderNode(Graph2D graph, double x, double y, String nodeType, String parentNodeId)
graph
- the current subgraphx
- x-coordinate of the center of the new folder nodey
- y-coordinate of the center of the new folder nodenodeType
- a symbolic name for a type of node to create, if null
the default is usedparentNodeId
- the id of the parent node for the new folder node (may be null
)
getDefaultFolderNodeRealizer()
protected String createGroupName(Graph2D graph, Node groupNode)
graph
- the current subgraphgroupNode
- the node to be named
protected String createFolderName(Graph2D graph, Node groupNode)
graph
- the current subgraphgroupNode
- the node to be named
protected void openFolder(Graph2D graph, Node node)
graph
- the current subgraph.node
- the folder to be openedprotected void closeGroup(Graph2D graph, Node node)
graph
- the current subgraph.node
- the group to be closedprotected void switchToSubgraph(javax.servlet.http.HttpSession session, String graphName, Graph2D newGraph, Graph2D oldGraph)
session
- the session for the requestgraphName
- the symbolic name of the whole hierarchically organized graphnewGraph
- the subgraph to switch tooldGraph
- the subgraph before serving the requestprotected void moveToSubgraph(Graph2D graph, Node parentNode, NodeList subNodes)
graph
- the current graphparentNode
- the new parent for the nodes to be moved, null
for the root graphsubNodes
- the nodes to be movedprotected Edge createEdge(Graph2D graph, Node source, Node target, int route)
graph
- the graph to add an edge tosource
- the source node for the edgetarget
- the target node for the edgeroute
- if this is not equal to zero, the new edge should be routed
protected void removeNode(Graph2D graph, Node node)
graph
- the current graphnode
- the node to be removedprotected void removeEdge(Graph2D graph, Edge edge)
graph
- the current graphedge
- the edge to be removedprotected void removeNodeLabel(Graph2D graph, NodeLabel nodeLabel)
graph
- the current graphnodeLabel
- the node label to be removedprotected void removeEdgeLabel(Graph2D graph, EdgeLabel edgeLabel)
graph
- the current graphedgeLabel
- the node label to be removedpublic static void registerNodeRealizer(String type, NodeRealizer defaultNodeRealizer)
createNode(Graph2D, double, double, String)
. No node realizers are registered
initially.
type
- a symbolic namedefaultNodeRealizer
- a node realizercreateNode(Graph2D, double, double, String)
,
getNodeRealizer(String)
,
getNodeRealizerTypes()
public static NodeRealizer getNodeRealizer(String type)
null
.
type
- a symbolic name
null
registerNodeRealizer(String, NodeRealizer)
public static String[] getNodeRealizerTypes()
registerNodeRealizer(String, NodeRealizer)
protected void adjustPortOffsets(Graph2D graph, Node node, double wOld, double hOld, double wNew, double hNew)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |