Package ca.nengo.ui.lib.world

Examples of ca.nengo.ui.lib.world.WorldObject


     
      return viewer;
    }
   
    public static UINetwork getActiveNetwork(boolean toplevel) {
      WorldObject wo = getActiveObject();
      UINetwork net = null;
    if (wo instanceof UINetwork) {
      net = (UINetwork)wo;
    } else {
      net = getParentNetwork(wo);
View Full Code Here


      marquee.removeFromParent();
      marquee = null;
    }
    if (!shouldStartMarqueeMode()) {
      // store the parent, in case pressNode is destroyed and we want to select it
      WorldObject parent = null;
      if (pressNode != null)
        parent = pressNode.getParent();
     
      // end the drag action
      if (dragAction != null) {
        dragAction.setFinalPositions();
        dragAction.doAction();
        dragAction = null;
      }
     
      // if pressNode is destroyed, unselect it and try to find a valid parent to select
      if (pressNode != null && pressNode.isDestroyed()) {
        while (parent != null && (parent.isDestroyed() || !isSelectable(parent))) {
          parent = parent.getParent();
        }
        if (parent instanceof WorldObjectImpl) {
          internalUnselect(pressNode);
          select((WorldObjectImpl)parent);
        } else {
View Full Code Here

    while (it.hasPrevious()) {
      Object node = it.previous();

      if (node instanceof PiccoloNodeInWorld) {
        WorldObject wo = ((PiccoloNodeInWorld) node).getWorldObject();

        if (wo != null) {
          if (type.isInstance(wo)) {
            return wo;
          }
View Full Code Here

   * Stores the final positions based on the node offsets... called from
   * selection handler after dragging has ended
   */
  public void setFinalPositions() {
    for (WeakReference<WorldObject> object : selectedObjectsRef) {
      WorldObject node = object.get();

      if (node != null) {
        ObjectState state = objectStates.get(object);
        if (state != null) {
          state.setFinalState(node.getParent(), node.getOffset());
        }
      }
    }
  }
View Full Code Here

  @Override
  protected void action() throws ActionException {

    for (WeakReference<WorldObject> object : selectedObjectsRef) {
      WorldObject node = object.get();

      if (node != null) {
        ObjectState state = objectStates.get(object);
        WorldObject fParent = state.getFinalParentRef().get();
        if (fParent != null) {

          fParent.addChild(node);
          node.setOffset(state.getFinalOffset());

          try {
            dropNode(node);
          } catch (UserCancelledException e) {
View Full Code Here

    }
  }

  public static void dropNode(WorldObject node) throws UserCancelledException {
    if (node instanceof DroppableX || node instanceof Droppable) {
      WorldObject worldLayer = node.getWorldLayer();

      Collection<WorldObject> allTargets = worldLayer.findIntersectingNodes(node
          .localToGlobal(node.getBounds()));

      Collection<WorldObject> goodTargets = new ArrayList<WorldObject>(allTargets.size());

      // Do not allow a Node to be dropped on a child of itself
      for (WorldObject target : allTargets) {
        if (!node.isAncestorOf(target)) {
          goodTargets.add(target);
        }
      }

      if (node instanceof DroppableX) {
        DroppableX droppable = (DroppableX) node;
        droppable.droppedOnTargets(goodTargets);
      }
      if (node instanceof Droppable) {
        Droppable droppable = (Droppable) node;
        WorldObject target = null;
        for (WorldObject potentialTarget : goodTargets) {
          if (droppable.acceptTarget(potentialTarget)) {
            target = potentialTarget;
          }
        }
        if (target == null) {
          if (droppable.acceptTarget(worldLayer)) {
            target = worldLayer;
          }
        }
        if (target != null) {
          Point2D position = target.globalToLocal(node.localToGlobal(new Point2D.Double(
              0, 0)));

          node.setOffset(position);
          target.addChild(node);
          droppable.justDropped();
        }

      }
    }
View Full Code Here

  }

  @Override
  protected void undo() throws ActionException {
    for (WeakReference<WorldObject> woRef : selectedObjectsRef) {
      WorldObject wo = woRef.get();
      if (wo != null) {
        if (isObjectDragUndoable(wo)) {
          ObjectState state = objectStates.get(woRef);

          WorldObject iParent = state.getInitialParentRef().get();

          if (iParent != null) {

            iParent.addChild(wo);
            wo.setOffset(state.getInitialOffset());

            dropNode(wo);
          }
        }
View Full Code Here

    }

    private World getTopWorld() {
        Window window = getTopWindow();
        if (window != null) {
            WorldObject wo = window.getContents();
            if (wo instanceof World) {
                return (World) wo;
            } else {
                return null;
            }
View Full Code Here

    private NodeContainer getTopNodeContainer() {
        Window window = getTopWindow();
        NodeContainer nodeContainer = null;

        if (window != null) {
            WorldObject wo = window.getContents();
            if (wo instanceof NodeContainer) {
                nodeContainer = (NodeContainer) wo;
            }
        } else {
            nodeContainer = this;
View Full Code Here

        super.updateRunMenu();

        StandardAction simulateAction = null;
        StandardAction interactivePlotsAction = null;
        UINeoNode node = null;
        WorldObject selectedObj = SelectionHandler.getActiveObject();

        if (selectedObj != null) {
            if (selectedObj instanceof UINeoNode) {
                node = (UINeoNode) selectedObj;
            } else if (selectedObj instanceof UIProjection) {
View Full Code Here

TOP

Related Classes of ca.nengo.ui.lib.world.WorldObject

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.