|
|||||||||
| 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.demos.TreeCollapserServlet
public class TreeCollapserServlet
This servlet implements expanding and collapsing of subtrees of a rooted tree.
This servlet initially creates a rooted tree with several nodes. However, most of the nodes are not shown, because their subtrees are collapsed. The user can explore parts of the tree by expanding and collapsing subtrees. Collapsed subtrees are indicated by a plus sign in the upper right corner of the still visible root node. Collapsible nodes, those which have child nodes, are indicated by a minus sign.
After a change of the visible nodes of the tree, the tree is redrawn using either a
TreeLayouter or an OrganicLayouter.
| Constructor Summary | |
|---|---|
TreeCollapserServlet()
|
|
| Method Summary | |
|---|---|
protected Rectangle2D.Double |
getDoubleBounds(HttpSession session)
returns the world bounds of the current tree as a Rectangle2D. |
protected void |
handlePostRequest(HttpServletRequest request,
HttpServletResponse response)
this method handles "POST" requests for this servlet. |
void |
initialize()
This method initializes the layouter objects used for redrawing the tree after an expand or collapse operation. |
| Methods inherited from class com.yworks.yfiles.server.tiles.servlet.BaseServlet |
|---|
cachedGraphs, cacheGraph, doGet, doPost, getEdgeDescription, getEdgeURL, getForId, getGraph, getGraphBounds, getId, getId, getId, getId, getNodeDescription, getNodeURL, getWriter, handleGetRequest, hasDescriptions, hasURLs, init, newGraph, setEdgeDescription, setEdgeURL, setNodeDescription, setNodeURL, uncacheGraph, 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 TreeCollapserServlet()
| Method Detail |
|---|
public void initialize()
throws ServletException
initialize in class BaseServletServletException
protected void handlePostRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,
IOException
this method handles "POST" requests for this servlet.
There are requests for expanding a node or a whole subtree, "expandNode", "expandSubtree". There are their counterparts for collapsing a node or a subtree, "collapseNode" and "collpaseSubtree". Moreover, there are two requests for toggling the expanded/collapsed state of a node or a subtree, "toggleNode" and "toggleSubtree".
Initially, a graph is created and cached for the session of the request by calling "initialize".
"initialize" has no parameters. All other requests have a parameter "id" and a parameter "layout". The value of the "id" parameter determines the node (or the subtree rooted at that node) to be expanded or collapsed. The value of the "layout" parameter determines the layout algorithm used for redrawing the tree after the expand or collapse operation.
Since the cached graph gets initialized or changed by each request, all of the requests are handled by handlePostRequest().
If an operation succeeds, the bounds of the area of the graph, which changed due to redrawing, are returned together with a shift vector, which describes the movement of the given root node of the expand or collapse operation due to redrawing ((0,0) for "initialize"). This information can be used in the client to request updated graph tiles and to move the viewport such that the root node of the expand or collapse operation stays at the same view position.
handlePostRequest in class BaseServletrequest - the requestresponse - the response for the request
ServletException
IOExceptionprotected Rectangle2D.Double getDoubleBounds(HttpSession session)
Rectangle2D.
session - the current session
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||