Package unbbayes.draw

Examples of unbbayes.draw.UShape


  public void setGraphDimension(Dimension graphDimension) {
    this.graphDimension = graphDimension;
  }
  public Object getSelected() {
    UShape selectedShape = getSelectedShape();
    if (selectedShape instanceof IEdgeHolderShape) {
      return ((IEdgeHolderShape) selectedShape).getEdge();
    }
    if (selectedShape instanceof INodeHolderShape) {
      return ((INodeHolderShape) selectedShape).getNode();
View Full Code Here


  public List<Node> getSelectedGroup() {
    selectedGroup.clear();

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

      if (shape.getState() == UShape.STATE_SELECTED
          && shape.getNode() != null) {
        controller.selectNode(shape.getNode());

        selectedGroup.add(shape.getNode());
      }
    }

    return selectedGroup;
  }
View Full Code Here

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

        // build a new shape for new node
        UShape shape = null;
        try {
          shape = this.getNodeDataTransferObject().getShapeBuilder()
              .build().getUShape(newNode, this);
        } catch (IllegalAccessException e1) {
          throw new RuntimeException(e1);
        } catch (InstantiationException e1) {
          throw new RuntimeException(e1);
        }

        // add shape into this pane (canvas)
        addShape(shape);

        // set this node/shape as selected
        shape.setState(UShape.STATE_SELECTED, null);

        shape.update();

        // notify the probability function panel's builder that a new
        // node is currently "selected" as owner
        this.getNodeDataTransferObject()
            .getProbabilityFunctionPanelBuilder()
View Full Code Here

      }
    }
  }

  public void selectNode(Node n) {
    UShape shape = null;
    shape = getNodeUShape(n);
    shape.setState(UShape.STATE_SELECTED, null);

  }
View Full Code Here

    return action;
  }
  public void createNode(Node newNode) {

    UShape shape = null;

    if (newNode instanceof IPluginNode) {
      try {
        INodeClassDataTransferObject q = this.getPluginNodeManager().getPluginNodeInformation(newNode.getClass());
        IPluginUShapeBuilder a = q.getShapeBuilder();
        IPluginUShape f = this.getPluginNodeManager().getPluginNodeInformation(newNode.getClass()).getShapeBuilder().build();
        shape =
           
  this.getPluginNodeManager().getPluginNodeInformation(newNode.getClass()).getShapeBuilder().build()
            .getUShape(newNode, this);
      } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
      } catch (InstantiationException e) {
        throw new RuntimeException(e);
      }
    }

    // TODO stop using if-instanceof structure and start using object
    // binding to a UShape builder.
    if (shape == null) {
      // if we could not find a plugin node, start testing ordinal nodes
      if (newNode instanceof ContinuousNode) {
        shape = new UShapeGMMNode(this, newNode,
            (int) newNode.getPosition().x, (int) newNode
                .getPosition().y, newNode.getWidth(), newNode
                .getHeight());
      } else if (newNode instanceof ProbabilisticNode) {
        shape = new UShapeProbabilisticNode(this, newNode,
            (int) newNode.getPosition().x, (int) newNode
                .getPosition().y, newNode.getWidth(), newNode
                .getHeight());
      } else if (newNode instanceof DecisionNode) {
        shape = new UShapeDecisionNode(this, newNode, (int) newNode
            .getPosition().x, (int) newNode.getPosition().y,
            newNode.getWidth(), newNode.getHeight());
      } else if (newNode instanceof UtilityNode) {
        shape = new UShapeUtilityNode(this, newNode, (int) newNode
            .getPosition().x, (int) newNode.getPosition().y,
            newNode.getWidth(), newNode.getHeight());
      }
    }

    if (shape != null) {
      try {
        addShape(shape);
        shape.setState(UShape.STATE_SELECTED, null);
      } catch (NullPointerException e) {
        throw new RuntimeException(
            "Could not find or set a shape for node: "
                + newNode.getName(), e);
      }
View Full Code Here

 
  public void resizeAllToFitText() {
    int n = this.getComponentCount();

    for (int i = 0; i < n; i++) {
      UShape shape = (UShape) this.getComponent(i);
        shape.resizeToFitText();
        shape.repaint();
    }
   
    updateLines();
   
    setShapeStateAll(UShape.STATE_NONE, null);
View Full Code Here

    this.removeAll();

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

      createNode(n);

      if (reset == true && n instanceof ProbabilisticNode) {
        shape = getNodeUShape(n);
      }

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

        shape = getNodeUShape(n);
        shape.shapeTypeChange(UShapeProbabilisticNode.STYPE_BAR);
        shape.setState(UShape.STATE_RESIZED, null);
      }

    }

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

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

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

    if (selectedNode != null) {
      shape = getNodeUShape(selectedNode);
      if (shape != null) {
        shape.setState(UShape.STATE_SELECTED, null);
      }
    }
  }
View Full Code Here

    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

    controller.getScreen().getEvidenceTree().setTextOutputMode(
        TEXTOUTPUTMODEMODE_USE_NAME);

    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

    controller.getScreen().getEvidenceTree().setTextOutputMode(
        TEXTOUTPUTMODEMODE_USE_DESC);

    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

TOP

Related Classes of unbbayes.draw.UShape

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.