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

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended bycom.yworks.yfiles.server.tiles.servlet.BaseServlet
              extended bycom.yworks.yfiles.server.tiles.servlet.LayoutServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.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

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
LayoutServlet()
           
 
Method Summary
protected  Layouter createLayouter(javax.servlet.http.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 doLayout(Graph2D graph, Layouter layouter)
          does the actual layout.
protected  void handlePostRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          handles "layout" requests.
 
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

LayoutServlet

public LayoutServlet()
Method Detail

handlePostRequest

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

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

createLayouter

protected Layouter createLayouter(javax.servlet.http.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

doLayout

protected void doLayout(Graph2D graph,
                        Layouter layouter)
does the actual layout. This implementation uses a BufferedLayouter.

Parameters:
graph - the graph
layouter - the layouter to be used


Copyright © 2006-2013 yWorks GmbH. All rights reserved