Package com.neptuny.xgrapher.cli.controller

Source Code of com.neptuny.xgrapher.cli.controller.GenerateVv

/*******************************************************************************
*   Copyright 2007 Neptuny s.r.l. - www.neptuny.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
*   Unless required by applicable law or agreed to in writing, software
*   distributed under the License is distributed on an "AS IS" BASIS,
*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*   See the License for the specific language governing permissions and
*   limitations under the License.
*******************************************************************************/
package com.neptuny.xgrapher.cli.controller;


import com.neptuny.xgrapher.cli.layout.TemporalSpringLayout;
import com.neptuny.xgrapher.cli.mapping.XGrapherJungMapping;
import com.neptuny.xgrapher.gen.model.Graph;

import edu.uci.ics.jung.graph.decorators.NumberVertexValue;
import edu.uci.ics.jung.visualization.PluggableRenderer;
import edu.uci.ics.jung.visualization.VisualizationViewer;
import edu.uci.ics.jung.visualization.SpringLayout.LengthFunction;

/**
* @author Andrea Cusini [andrea.cusini@gmail.com]
* @since 09/ott/07
*/
public class GenerateVv {

  Application app;

  PluggableRenderer pr ;

  DataBindingClient dataBindingClient;

  XGrapherJungMapping mapper = null;

  NumberVertexValue size;

  /**
   * @param app
   */
  public GenerateVv(Application app) {
    super();
                pr = new PluggableRenderer();
    this.app = app ;
                app.getRenderer().configureRenderer(pr);
    mapper = app.getMapper();
    // size = new UserDatumNumberVertexValue(GraphAttributeType.SIZE);

  }

  public VisualizationViewer getVv() {

    dataBindingClient = new DataBindingClient(app.getLoader());
    Graph g = dataBindingClient.getStartGraph();
    edu.uci.ics.jung.graph.Graph jungGraph = mapper.toJung(g);

                LengthFunction f = app.getRenderer().getLengthFunction() ;
                VisualizationViewer vv = null ;
                if ( f == null)
                    vv = new VisualizationViewer(
                                    new TemporalSpringLayout(jungGraph, 50), pr);
                else
                    vv = new VisualizationViewer(
                            new TemporalSpringLayout(jungGraph,f,50),pr);

    return vv;

  }

}
TOP

Related Classes of com.neptuny.xgrapher.cli.controller.GenerateVv

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.