com.yworks.yfiles.server.tiles.servlet
Class LayoutServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.yworks.yfiles.server.tiles.servlet.BaseServlet
              extended by com.yworks.yfiles.server.tiles.servlet.LayoutServlet
All Implemented Interfaces:
Serializable, Servlet, ServletConfig

public class LayoutServlet
extends BaseServlet

This servlet handles layout requests for server side graphs. You can customize this servlet by overriding createLayouter(HttpServletRequest, Graph2D, boolean, Object) in a subclass.

See Also:
Serialized Form

Constructor Summary
LayoutServlet()
           
 
Method Summary
protected  Layouter createLayouter(HttpServletRequest request, Graph2D graph, boolean hasGroups, Object selectionKey)
          returns a layouter to do the layout of the given graph as specified by the request.
protected  void handlePostRequest(HttpServletRequest request, HttpServletResponse response)
          handles "layout" requests.
 
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, initialize, 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

LayoutServlet

public LayoutServlet()
Method Detail

handlePostRequest

protected void handlePostRequest(HttpServletRequest request,
                                 HttpServletResponse response)
                          throws ServletException,
                                 IOException
handles "layout" requests.

Overrides:
handlePostRequest in class BaseServlet
Parameters:
request - the request
response - the response
Throws:
ServletException
IOException

createLayouter

protected Layouter createLayouter(HttpServletRequest request,
                                  Graph2D graph,
                                  boolean hasGroups,
                                  Object selectionKey)

returns a layouter to do the layout of the given graph as specified by the request. The layout is performed by the calling code using the layouter returned by this method. If this method returns null, then the calling code leaves the graph unchanged and returns a 404 response to the client. Subclasses can override this method to achieve custom layouts.

Parameters for the layout can be transferred from the client via the request object if necessary.

The calling code takes care of setting up the grouping keys for the graph using a GroupLayoutConfigurator if necessary. A custom implementation of this method does not have to care about this. However, you may want to choose a specialized layouter for graphs with group nodes, since some Layouters do not support graphs with group nodes (e.g. OrthogonalLayouter ignores grouping information, so this method uses OrthogonalGroupLayouter for an orthogonal layout, if the graph contains group nodes).

The calling code sets up a data provider containing all labels, which are not internal node labels. These are the labels which normally need to be laid out. It is up to the needs of a custom implementation in a subclass, whether the data provider is used (e.g. labeling.setSelection(selectionKey)) or not.

This implementation uses the "type" parameter of the request to either do an orthogonal, organic or hierarchic layout with generic settings. If the graph has groups, this is taken into account. It also honors the data provider for labels.

Parameters:
request - the layout request
graph - the graph to be laid out
hasGroups - is true, if the graph has groups
selectionKey - is the key of a data provider for the labels to be laid out
Returns:
a layouter suitable for the request or null


Copyright © 2006-2008 yWorks GmbH. All rights reserved