Package org.gvt.action

Source Code of org.gvt.action.SpringLayoutAction

package org.gvt.action;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.gvt.ChisioMain;
import org.gvt.command.LayoutCommand;
import org.gvt.editpart.ChsRootEditPart;
import org.gvt.layout.SpringLayout;
import org.gvt.model.CompoundModel;

/**
* Action for Spring Layout operation.
*
* @author Cihan Kucukkececi
*
* Copyright: I-Vis Research Group, Bilkent University, 2007
*/
public class SpringLayoutAction extends Action
{
  ChisioMain main = null;

  /**
   * Constructor
   */
  public SpringLayoutAction(ChisioMain main)
  {
    setText("Spring Layout");
    setToolTipText(getText());
    setImageDescriptor(ImageDescriptor.createFromFile(
      ChisioMain.class,
      "icon/layout-spring.gif"));
    this.main = main;

  }

  public void run()
  {
    try
    {
      main.lockWithMessage("Performing layout ...");
      CompoundModel root = (CompoundModel)((ChsRootEditPart) main.getViewer().
          getRootEditPart().getChildren().get(0)).getModel();

      LayoutCommand command = new LayoutCommand(main, new SpringLayout(root));
      command.execute();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    finally
    {
      main.unlock();
    }
  }
}
TOP

Related Classes of org.gvt.action.SpringLayoutAction

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.