Package unbbayes.prs

Examples of unbbayes.prs.Node


    //1.1 get an organized order of UNodes
    searchUNodesOrder( pn, list );
   
    //2. create each node
    for (int i = 0; i < pn.getNodeCount(); i++) {
      Node UNode = pn.getNode(list.get(i));
      createSNode( SNodes, UNode );
    }
   
    //3. create relation
    for (int i = 0; i < pn.getNodeCount(); i++) {
      Node UNode = pn.getNode(list.get(i));
      addParents( SNodes, UNode );
    }
   
    //4. create states
    for (int i = 0; i < pn.getNodeCount(); i++) {
      Node UNode = pn.getNode(list.get(i));
      createStates( SNodes, UNode );
    }
   
    //5. create CPT
    EDBUnit ISA1 = SNodes.getRel("ISA");
    for( String str : ISA1.getMap().keySet() ){
      EDBUnit node = ISA1.map.get(str);
      Node UNode = pn.getNode(str);
     
      if( UNode instanceof GmmNodePluginStub ){
      }else
      if( UNode instanceof ProbabilisticNode ){
        createCPT(node, UNode);
View Full Code Here


    //1. create default nodes
    EDBUnit SNodes = EDB.This().get("ROOT.NODES");
      
    //4. create states
    for (int i = 0; i < pn.getNodeCount(); i++) {
      Node UNode = pn.getNodeAt(i);
      TreeVariable tv = (TreeVariable)UNode;
      EDBUnit SNode = SNodes.get(UNode.getName());
     
      if(tv.hasEvidence()) {
        EDBUnit evidence = SNode.create("EVIDENCE")
        String ev = UNode.getStateAt(tv.getEvidence());
        evidence.setData(ev);
      }
    }
     
  }
View Full Code Here

   */
  public void setLocations( SingleEntityNetwork pn ) {
    EDBUnit SNodes = EDB.This().get("ROOT.NODES");
   
    for (int i = 0; i < pn.getNodeCount(); i++) {
      Node UNode = pn.getNodeAt(i);
      EDBUnit SNode = SNodes.get(UNode.getName());
      EDBUnit info   = SNode.get("INFO");
      EDBUnit X = info.get("X");
      EDBUnit Y = info.get("Y");
             
      Point2D position = UNode.getPosition();
      Double dx = new Double(position.getX());
      Double dy = new Double(position.getY());
      X.setData(dx.toString());
      Y.setData(dy.toString());
    }
View Full Code Here

  public Point2D.Double getBiggestPoint() {
    double maiorX = 0;
    double maiorY = 0;

    for (int i = 0; i < nodeList.size(); i++) {
      Node noAux = (Node) nodeList.get(i);
      if (maiorX < noAux.getPosition().getX() + noAux.getWidth()) {
        maiorX = noAux.getPosition().getX() + noAux.getWidth();
      }

      if (maiorY < noAux.getPosition().getY() + noAux.getHeight()) {
        maiorY = noAux.getPosition().getY() + noAux.getHeight();
      }
    }
    if (maiorX < visibleDimension.getWidth()) {
      maiorX = graphViewport.getViewSize().getWidth();
    }
View Full Code Here

  
  public void mouseClicked(MouseEvent e) {
    // TODO stop using direct access to controller as a field, and start
    // using get/set methods
    if (SwingUtilities.isLeftMouseButton(e)) {
      Node newNode = null;

      switch (getAction()) {

      case CREATE_CONTINUOUS_NODE: {
        newNode = controller.insertContinuousNode(e.getX(), e.getY());
        UShapeProbabilisticNode shape = new UShapeProbabilisticNode(
            this, newNode, (int) newNode.getPosition().x
                - newNode.getWidth() / 2, (int) newNode
                .getPosition().y
                - newNode.getHeight() / 2, newNode.getWidth(),
            newNode.getHeight());
        addShape(shape);
        shape.setState(UShape.STATE_SELECTED, null);
        showCPT(newNode);
      }
        break;
      case CREATE_PROBABILISTIC_NODE: {
        newNode = controller
            .insertProbabilisticNode(e.getX(), e.getY());
        UShapeProbabilisticNode shape = new UShapeProbabilisticNode(
            this, newNode, (int) newNode.getPosition().x
                - newNode.getWidth() / 2, (int) newNode
                .getPosition().y
                - newNode.getHeight() / 2, newNode.getWidth(),
            newNode.getHeight());
        addShape(shape);
        shape.setState(UShape.STATE_SELECTED, null);
        showCPT(newNode);

      }
        break;
      case CREATE_DECISION_NODE: {
        newNode = controller.insertDecisionNode(e.getX(), e.getY());
        UShapeDecisionNode shape = new UShapeDecisionNode(this,
            newNode, (int) newNode.getPosition().x
                - newNode.getWidth() / 2, (int) newNode
                .getPosition().y
                - newNode.getHeight() / 2, newNode.getWidth(),
            newNode.getHeight());
        addShape(shape);
        shape.setState(UShape.STATE_SELECTED, null);
        showCPT(newNode);
      }
        break;
      case CREATE_UTILITY_NODE: {
        newNode = controller.insertUtilityNode(e.getX(), e.getY());
        UShapeUtilityNode shape = new UShapeUtilityNode(
            this,
            newNode,
            (int) newNode.getPosition().x - newNode.getWidth() / 2,
            (int) newNode.getPosition().y - newNode.getHeight() / 2,
            newNode.getWidth(), newNode.getHeight());
        addShape(shape);
        shape.setState(UShape.STATE_SELECTED, null);
        showCPT(newNode);
      }
        break;
      case ADD_PLUGIN_NODE: {
        // build new node
        newNode = this.getNodeDataTransferObject().getNodeBuilder()
            .buildNode();
        newNode.setPosition(e.getX(), e.getY());

        // add new node into network
        this.controller.getNetwork().addNode(newNode);

        // build a new shape for new node
View Full Code Here

  public void compiled(boolean reset, Node selectedNode) {
    setPaneMode(PANEMODE_COMPILE);

    this.removeAll();

    Node n;
    Edge e;
    UShape shape = null;
    // Load all nodes.
    for (int i = 0; i < nodeList.size(); i++) {
View Full Code Here

  public void update() {
    setPaneMode(PANEMODE_NONE);

    this.removeAll();

    Node n;
    Edge e;
    UShape shape = null;

    // Load all nodes.
    for (int i = 0; i < nodeList.size(); i++) {
      n = nodeList.get(i);
      n.updateLabel();

      // create node
      createNode(n);

      if (n instanceof ContinuousNode || n instanceof ProbabilisticNode
          || n instanceof IPluginNode) {

        shape = getNodeUShape(n);

        if (shape != null) {
          shape.shapeTypeChange(UShapeProbabilisticNode.STYPE_NONE);
          shape.setState(UShape.STATE_RESIZED, null);
        }
      }
    }

    // Load all Edges
    for (int i = 0; i < edgeList.size(); i++) {
      e = edgeList.get(i);

      // createLine
      if (getNodeUShape(e.getOriginNode()) != null
          && getNodeUShape(e.getDestinationNode()) != null) {
        UShapeLine line = new UShapeLine(this, getNodeUShape(e
            .getOriginNode()),
            getNodeUShape(e.getDestinationNode()));
        line.setEdge(e);
        // line.setUseSelection();
        // by young 1/23/2010
        line.setLearningLineSelection(this.isToUseSelectionForLines());
        addShape(line);
      }
    }

    // by young4
    setAction(GraphAction.NONE);
    setShapeStateAll(UShape.STATE_NONE, null);
    fitCanvasSizeToAllUShapes();

    if (controller != null){
      Node selectedNode = controller.getSelectedNode();
      if (selectedNode != null) {
        UShape selectedUshape = this.getNodeUShape(selectedNode)
        if (selectedUshape != null) {
          selectedUshape.setState(UShape.STATE_SELECTED, null);
        }
View Full Code Here

    int n = this.getComponentCount();
    for (int i = 0; i < n; i++) {
      UShape shape = (UShape) this.getComponent(i);

      Node node = shape.getNode();
      if (node != null)
        shape.setLabel(node.getName());
    }

    repaint();
  }
View Full Code Here

    int n = this.getComponentCount();
    for (int i = 0; i < n; i++) {
      UShape shape = (UShape) this.getComponent(i);

      Node node = shape.getNode();
      if (node != null)
        shape.setLabel(node.getDescription());
    }

    repaint();
  }
View Full Code Here

    return line;
  }

  public void onShapeChanged(UShape s) {
    if (s instanceof UShapeState) {
      Node n = ((UShape) s.getParent()).getNode();
      controller.getScreen().getEvidenceTree().selectTreeItemByState(n,
          s.getName());
      ((UShapeProbabilisticNode) s.getParent()).update(s.getName());
    } else if (s instanceof UShapeLine) {
View Full Code Here

TOP

Related Classes of unbbayes.prs.Node

Copyright © 2018 www.massapicom. 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.