⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaultgraphmodelprovider.java

📁 用JGraph编的软件
💻 JAVA
字号:
/*
 * @(#)DefaultGraphModelProvider.java	1.0 17.02.2003
 *
 * Copyright (C) 2003 sven.luzar
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
package org.jgraph.pad;

import java.util.Map;

import javax.swing.tree.DefaultMutableTreeNode;

import org.jgraph.graph.DefaultEdge;
import org.jgraph.graph.DefaultGraphCell;
import org.jgraph.graph.DefaultGraphModel;
import org.jgraph.graph.DefaultPort;
import org.jgraph.graph.GraphModel;
import org.jgraph.pad.resources.Translator;

import org.jgpd.jgraph.*;

/**Graph model provider for the default graph model.
 *
 * @author luzar
 * @version 1.0
 */
public class DefaultGraphModelProvider
    implements GraphModelProvider {

  /** reference to the default xml file format
   */
  DefaultGraphModelFileFormatXML defaultGraphModelFileFormatXML;

  /**
   * Constructor for DefaultGraphModelProvider.
   */
  public DefaultGraphModelProvider() {
    defaultGraphModelFileFormatXML = new DefaultGraphModelFileFormatXML();
  }

  /**Returns <tt>Default Graph Model</tt>
   *
   * @see org.jgraph.pad.GraphModelProvider#getPresentationName()
   */
  public String getPresentationName() {
    return "Default Graph Model";
  }

  /**Creates the Cells for the Default graph model.
   *
   * @see DefaultEdge
   * @see EllipseCell
   * @see ActivityCell
   * @see DecisionCell
   * @see StartCell
   * @see EndCell
   * @see SplitCell
   * @see JoinCell
   * @see DefaultPort
   * @see TextCell
   * @see DefaultGraphCell
   * @see org.jgraph.pad.GraphModelProvider#createCell(GraphModel , int , Object , Map )
   */
  public Object createCell(
      GraphModel model,
      int type,
      Object userObject,
      Map map) {

    switch (type) {
      case CELL_EDGE_DEFAULT:
        return new DefaultEdge(userObject);
      case CELL_VERTEX_ACTIVITY:
        return new ActivityCell(userObject);
      case CELL_VERTEX_DECISION:
        return new DecisionCell(userObject);
        //如果是inclusive通路
      case CELL_VERTEX_INCLUSIVEGATEWAY:
        return new InclusiveGatewayCell(userObject);
        //如果是complex通路
  case CELL_VERTEX_COMPLEXGATEWAY:
    return new ComplexGatewayCell(userObject);
    //如果是parallel通路
case CELL_VERTEX_PARALLELGATEWAY:
 return new ParallelGatewayCell(userObject);


        //如果是dataObj
  case CELL_VERTEX_DATAOBJ:
    return new DataObjCell(userObject);
    //如果是subProcess
case CELL_VERTEX_SUBPROCESS:
 return new SubProcessCell(userObject);
 //如果是textAnnotation
case CELL_VERTEX_TEXTANNOTATION:
  return new TextAnnotationCell(userObject);


      case CELL_VERTEX_POOL:
        return new PoolCell(userObject);

      case CELL_VERTEX_START:
        return new StartCell(userObject);
      case CELL_VERTEX_LANE:
        return new LaneCell(userObject);
      case CELL_VERTEX_INTER:
        return new InterCell(userObject);
      case CELL_VERTEX_END:
        return new EndCell(userObject);
      case CELL_VERTEX_SPLIT:
        return new SplitCell(userObject);
      case CELL_VERTEX_JOIN:
        return new JoinCell(userObject);
      case CELL_PORT_DEFAULT:
        return new DefaultPort(userObject);
      case CELL_VERTEX_TEXT:
        return new TextCell(userObject, true);
    }
    return new DefaultGraphCell(userObject);
  }

  /**
   * Creates a clean default graph model.
   *
   * @see DefaultGraphModel
   * @see org.jgraph.pad.GraphModelProvider#createCleanGraphModel()
   */
  public GraphModel createCleanGraphModel() {
    return new DefaultGraphModel();
  }

  /** Currently returns every time false.
   *
   * @see org.jgraph.pad.GraphModelProvider#isMutateAbleTo(Class)
   */
  public boolean isMutateAbleTo(Class otherGraphModelClass) {
    return false;
  }

  /**
   * Currently returns every time null.
   *
   * @see org.jgraph.pad.GraphModelProvider#mutateTo(GraphModel, Class)
   */
  public GraphModel mutateTo(
      GraphModel sourceGraphModel,
      Class otherGraphModelClass) {
    return null;
  }

  /**
   * Returns the graph model file format objects for this provider
   *
   * @see DefaultGraphModelFileFormatXML
   * @see DefaultGraphModelFileFormatSerial
   * @see org.jgraph.pad.GraphModelProvider#getGraphModelFileFormats()
   */
  public GraphModelFileFormat[] getGraphModelFileFormats() {
    return new GraphModelFileFormat[] {
        defaultGraphModelFileFormatXML,
        //	defaultGraphModelFileFormatSerial
    };
  }

  /**Adds a Port to the model specific vertex object
   *
   * @see org.jgraph.pad.GraphModelProvider#addPort(Object, Object)
   */
  public void addPort(Object vertex, Object port) {
    if (port instanceof DefaultPort) {
      if (vertex instanceof DefaultMutableTreeNode) {
        ( (DefaultMutableTreeNode) vertex).add( (DefaultPort) port);
      }
    }
  }

  /**
   * Creates a new clean graph for this model provider
   *
   * @see org.jgraph.pad.GraphModelProvider#createCleanGraph(GraphModel model)
   */
  public GPGraph createCleanGraph(GraphModel model) {
    GPGraph graph = new GPGraph(model);
    // TODO: Remove this code when VM is fixed on Mac OS X
    if (System.getProperty("os.name").equals("Mac OS X")) {
      String s = Translator.getString("doubleBufferedOnMacOSX");
      if (s != null) {
        graph.setDoubleBuffered(Boolean.getBoolean(s));
      }
    }
    return graph;
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -