示例#1
0
  /**
   * This method calculates the size of this compound model and then recursively calculates the size
   * of its parent, which continues until root.
   */
  public void calculateSizeUp() {
    if (getParentModel() != null && !isRoot) {
      if (this.children.size() == 0) {
        setSize(CompoundModel.DEFAULT_SIZE);
      } else {
        Rectangle bound = calculateBounds();
        Dimension diff = getLocationAbs().getDifference(bound.getLocation());

        setLocationAbs(new Point(bound.x - this.MARGIN_SIZE, bound.y - this.MARGIN_SIZE));
        setSize(
            new Dimension(
                bound.width + (2 * this.MARGIN_SIZE),
                bound.height + (2 * this.MARGIN_SIZE) + this.labelHeight));

        Iterator iter = this.children.iterator();

        while (iter.hasNext()) {
          NodeModel child = (NodeModel) iter.next();
          child.setLocationAbs(
              child
                  .getLocationAbs()
                  .translate(diff.width + this.MARGIN_SIZE, diff.height + this.MARGIN_SIZE));
        }
      }

      (getParentModel()).calculateSizeUp();
    }

    updatePolygonsOfChildren();
  }
示例#2
0
  public boolean SetDoc(String strDoc) {
    try {
      SaxDoc sax = new SaxDoc();
      SAXParser sp;
      sp = SAXParserFactory.newInstance().newSAXParser();
      sp.parse(new InputSource(new StringReader(strDoc)), sax);

      headNode = sax.getRootNode();
      rootNode = new NodeModel(true);
      rootNode.SetNext(headNode);
      headNode.SetPre(rootNode);
      pointer = rootNode;

      return true;

    } catch (ParserConfigurationException e) {
      e.printStackTrace();
    } catch (SAXException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (Exception e) {
    }

    return false;
  }
示例#3
0
  private void deleteConnections(NodeModel part) {
    if (part instanceof CompoundModel) {
      List children = ((CompoundModel) part).getChildren();

      for (int i = 0; i < children.size(); i++) deleteConnections((NodeModel) children.get(i));
    }

    sourceConnections.addAll(part.getSourceConnections());

    for (int i = 0; i < sourceConnections.size(); i++) {
      EdgeModel wire = (EdgeModel) sourceConnections.get(i);
      wire.setHighlight(false);
      wire.getTarget().removeTargetConnection(wire);
      wire.getSource().removeSourceConnection(wire);
    }

    targetConnections.addAll(part.getTargetConnections());

    for (int i = 0; i < targetConnections.size(); i++) {
      EdgeModel wire = (EdgeModel) targetConnections.get(i);
      wire.setHighlight(false);
      wire.getTarget().removeTargetConnection(wire);
      wire.getSource().removeSourceConnection(wire);
    }
  }
示例#4
0
  public void removeChild(Object o) {
    if (o instanceof NodeModel) {
      NodeModel nodeModel = (NodeModel) o;
      nodeModel.resetClusters();
    }

    this.children.remove(o);
    firePropertyChange(P_CHILDREN, o, null);
  }
示例#5
0
  public void removeHighlights(CompoundModel mdl) {
    for (int i = 0; i < mdl.getChildren().size(); i++) {
      NodeModel node = (NodeModel) mdl.getChildren().get(i);
      node.setHighlight(false);

      if (node instanceof CompoundModel) {
        removeHighlights((CompoundModel) node);
      }
    }
  }
示例#6
0
  protected void updatePolygonsOfChildren() {
    super.updatePolygonsOfChildren();

    // Call recursively all children
    Iterator<NodeModel> childrenIter = this.children.iterator();

    while (childrenIter.hasNext()) {
      NodeModel childModel = childrenIter.next();

      childModel.updatePolygonsOfChildren();
    }
  }
  public NodeModel saveNode() {
    NodeModel mode = new NodeModel(true);

    // mode.name =;
    // mode.Description = ;
    // mode.advanced_desc = ;
    // mode.father =;
    mode.setParameters(Parameters);
    mode.setVariables(variables);

    return mode;
  }
示例#8
0
  public boolean FindElem(String szName) {

    boolean result = false;
    NodeModel node = pointer.GetNext();
    while (node != null) {
      if (node.GetTagName().equalsIgnoreCase(szName)) {
        result = true;
        pointer = node;
        break;
      }
      node = node.GetNext();
    }
    return result;
  }
示例#9
0
  public void setParentModel(CompoundModel parent) {
    super.setParentModel(parent);

    // if a parent of a model is set as null, do not update ClusterManager
    if (parent != null) {
      setClusterManager(parent.getClusterManager());
    }
  }
示例#10
0
  /**
   * This method removes the given cluster from the cluster list of this compound model, and
   * moreover it removes this compound model from the 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 removeCluster(Cluster cluster) {
    // call super method
    super.removeCluster(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 remove children node models from the cluster
      childModel.removeCluster(cluster);
    }
  }
示例#11
0
  public void resetClusters() {
    List<Cluster> clusters = new ArrayList<Cluster>();
    clusters.addAll(this.clusters);

    super.resetClusters();

    List childrenNodes = this.children;

    Iterator itr = childrenNodes.iterator();

    while (itr.hasNext()) {
      NodeModel childModel = (NodeModel) itr.next();

      for (Cluster cluster : clusters) {
        childModel.removeCluster(cluster);
      }
    }
  }
示例#12
0
  public void execute() {
    child.setHighlight(false);

    if (child instanceof CompoundModel) {
      removeHighlights((CompoundModel) child);
    }

    primExecute();
    parent.calculateSizeUp();
  }
示例#13
0
  public boolean FindElem() {
    boolean result = false;
    if (pointer == null) return result;

    NodeModel node = pointer.GetNext();
    if (node != null) {
      result = true;
      pointer = node;
    }
    return result;
  }
示例#14
0
  /**
   * 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);
    }
  }
示例#15
0
  /** This method calculates sizes of children recursively and then calculates its own size. */
  public void calculateSizeDown() {

    // First, recursively calculate sizes of children compounds
    Iterator iter = this.children.iterator();

    while (iter.hasNext()) {
      NodeModel child = (NodeModel) iter.next();

      if (child instanceof CompoundModel) {
        ((CompoundModel) child).calculateSizeDown();
      }
    }

    if (getParentModel() != null && !isRoot) {
      // Second, calculate size of this compound model
      if (this.children.size() == 0) {
        setSize(CompoundModel.DEFAULT_SIZE);
      } else {
        Rectangle bound = calculateBounds();
        Dimension diff = getLocationAbs().getDifference(bound.getLocation());

        setLocationAbs(new Point(bound.x - this.MARGIN_SIZE, bound.y - this.MARGIN_SIZE));
        setSize(
            new Dimension(
                bound.width + (2 * this.MARGIN_SIZE),
                bound.height + (2 * this.MARGIN_SIZE) + this.labelHeight));

        iter = this.children.iterator();

        while (iter.hasNext()) {
          NodeModel child = (NodeModel) iter.next();
          child.setLocationAbs(
              child
                  .getLocationAbs()
                  .translate(diff.width + this.MARGIN_SIZE, diff.height + this.MARGIN_SIZE));
        }
      }
    }
  }
示例#16
0
  public boolean isAncestorofNode(NodeModel node) {
    CompoundModel root = node.getParentModel();

    while (root != null) {
      if (root == this) {
        return true;
      } else {
        root = root.getParentModel();
      }
    }

    return false;
  }
示例#17
0
 public float GetFloatAttrib(String szAttrib) {
   if (pointer == null) return 0;
   return Float.parseFloat(pointer.GetAttribute(szAttrib));
 }
示例#18
0
  public String GetTagName() {
    if (pointer == null) return "";

    return pointer.GetTagName();
  }
示例#19
0
  public boolean OutOfElem() {
    if (pointer == null) return false;

    pointer = pointer.GetParent();
    return true;
  }
示例#20
0
  public boolean IntoElem() {
    if (pointer == null) return false;

    pointer = pointer.GetChildernHead();
    return true;
  }
示例#21
0
  /** This method finds the boundaries of this compound node. */
  public Rectangle calculateBounds() {
    int top = Integer.MAX_VALUE;
    int left = Integer.MAX_VALUE;
    int right = 0;
    int bottom = 0;
    int nodeTop;
    int nodeLeft;
    int nodeRight;
    int nodeBottom;

    /* Checks the nodes' locations which are children of
     * this compound node.
     */
    Iterator itr = this.getChildren().iterator();

    while (itr.hasNext()) {
      NodeModel node = (NodeModel) itr.next();

      Point locAbs = node.getLocationAbs();
      Dimension size = node.getSize();
      nodeTop = locAbs.y;
      nodeLeft = locAbs.x;
      nodeRight = locAbs.x + size.width;
      nodeBottom = locAbs.y + size.height;

      if (top > nodeTop) {
        top = nodeTop;
      }

      if (left > nodeLeft) {
        left = nodeLeft;
      }

      if (right < nodeRight) {
        right = nodeRight;
      }

      if (bottom < nodeBottom) {
        bottom = nodeBottom;
      }
    }

    // Checks the bendpoints' locations.
    if (this.isRoot) {
      itr = this.getEdges().iterator();
    } else {
      itr = this.getEdgeIterator(ALL_EDGES, true, true);
    }

    while (itr.hasNext()) {
      EdgeModel edge = (EdgeModel) itr.next();
      edge.updateBendpoints();

      for (int i = 0; i < edge.bendpoints.size(); i++) {
        EdgeBendpoint eb = (EdgeBendpoint) edge.bendpoints.get(i);
        Point loc = eb.getLocationFromModel(edge);

        int x = loc.x;
        int y = loc.y;

        if (top > y) {
          top = y;
        }

        if (left > x) {
          left = x;
        }

        if (right < x) {
          right = x;
        }

        if (bottom < y) {
          bottom = y;
        }
      }
    }

    // Do we have any nodes in this graph?
    if (top == Double.MAX_VALUE) {
      return null;
    }

    return new Rectangle(left, top, right - left, bottom - top);
  }
示例#22
0
  public String GetAttrib(String szAttrib) {
    if (pointer == null) return "";

    return pointer.GetAttribute(szAttrib);
  }
示例#23
0
 public TopoSensorModel() {
   super.setName(name);
 }
示例#24
0
  public String GetData() {
    if (pointer == null) return "";

    return pointer.GetData();
  }
示例#25
0
 public void undo() {
   parent.addChild(child);
   child.setParentModel(parent);
   restoreConnections();
 }
示例#26
0
  public int GetIntAttrib(String szAttrib) {
    if (pointer == null) return 0;

    return Integer.parseInt(pointer.GetAttribute(szAttrib));
  }