コード例 #1
0
ファイル: CompoundModel.java プロジェクト: yenaoh90/chibe
  /**
   * This method adds the given cluster into cluster list of this compound model, and moreover it
   * adds this compound model into set of clustered nodes of the given cluster. This is done by
   * calling super method. Since this is a compound model, this operation is done recursively.
   */
  public void addCluster(Cluster cluster) {
    // call super method
    super.addCluster(cluster);

    // get all children node models
    List childrenNodes = this.children;

    Iterator itr = childrenNodes.iterator();

    // iterate over each child node model
    while (itr.hasNext()) {
      NodeModel childModel = (NodeModel) itr.next();

      // recursively add children node models to the cluster
      childModel.addCluster(cluster);
    }
  }
コード例 #2
0
ファイル: CompoundModel.java プロジェクト: yenaoh90/chibe
  /**
   * This method add this compound model into a cluster with given cluster ID. If such cluster
   * doesn't exist in ClusterManager, it creates a new cluster. This is done by calling super
   * method. Since this is a compound model, this operation is done recursively for every child.
   */
  public void addCluster(int clusterID) {
    super.addCluster(clusterID);

    // It is guaranteed here that a cluster with clusterID exists.
    // Therefore, instead of iterating for each child, use the other
    // addCluster(cluster) method for recursion.
    Cluster cluster = this.eClusterManager.getClusterByID(clusterID);

    // get all children node models
    List childrenNodes = this.children;

    Iterator itr = childrenNodes.iterator();

    // iterate over each child node model
    while (itr.hasNext()) {
      NodeModel childModel = (NodeModel) itr.next();

      // recursively add children node models to the cluster
      childModel.addCluster(cluster);
    }
  }