Esempio n. 1
0
  protected ConnectionFigure createConnection() {
    try {
      Class cLayer = Class.forName(objType);
      LayerConnection lc = (LayerConnection) cLayer.newInstance();
      lc.setParams(params);
      // Each component is provided with a pointer to the parent NeuralNet object
      NeuralNetDrawing nnd = (NeuralNetDrawing) view.drawing();
      lc.setParam("NeuralNet", nnd.getNeuralNet());
      return lc;
    } catch (ClassNotFoundException cnfe) {
      log.warn(
          "ClassNotFoundException exception thrown while ConnectionFigure. Message is : "
              + cnfe.getMessage(),
          cnfe);
    } catch (InstantiationException ie) {
      log.warn(
          "InstantiationException exception thrown while ConnectionFigure. Message is : "
              + ie.getMessage(),
          ie);

    } catch (IllegalAccessException iae) {
      log.warn(
          "IllegalAccessException exception thrown while ConnectionFigure. Message is : "
              + iae.getMessage(),
          iae);
    }
    return null;
  }
  /**
   * Connects the figure to the new target. If there is no new target the connection reverts to its
   * original one.
   */
  public void invokeEnd(int x, int y, int anchorX, int anchorY, DrawingView view) {
    Connector target = findConnectionTarget(x, y, view.drawing());
    if (target == null) {
      target = fOriginalTarget;
    }

    setPoint(x, y);
    connect(target);
    getConnection().updateConnection();

    Connector oldConnector =
        ((ChangeConnectionHandle.UndoActivity) getUndoActivity()).getOldConnector();
    // there has been no change so there is nothing to undo
    if ((oldConnector == null)
        || (target() == null)
        || (oldConnector.owner() == target().owner())) {
      setUndoActivity(null);
    } else {
      getUndoActivity().setAffectedFigures(new SingleFigureEnumerator(getConnection()));
    }

    if (getTargetFigure() != null) {
      getTargetFigure().connectorVisibility(false);
      setTargetFigure(null);
    }
  }
 /** Connects the figures if the mouse is released over another figure. */
 public void invokeEnd(int x, int y, int anchorX, int anchorY, DrawingView view) {
   Connector target = findConnectionTarget(x, y, view.drawing());
   if (target != null) {
     getConnection().connectStart(startConnector());
     getConnection().connectEnd(target);
     getConnection().updateConnection();
   } else {
     view.drawing().remove(getConnection());
     setUndoActivity(null);
   }
   setConnection(null);
   if (getTargetFigure() != null) {
     getTargetFigure().connectorVisibility(false, null);
     setTargetFigure(null);
   }
 }
  /** Finds a new target of the connection. */
  public void invokeStep(int x, int y, int anchorX, int anchorY, DrawingView view) {
    Point p = new Point(x, y);
    Figure f = findConnectableFigure(x, y, view.drawing());
    // track the figure containing the mouse
    if (f != getTargetFigure()) {
      if (getTargetFigure() != null) {
        getTargetFigure().connectorVisibility(false);
      }
      setTargetFigure(f);
      if (getTargetFigure() != null) {
        getTargetFigure().connectorVisibility(true);
      }
    }

    Connector target = findConnectionTarget(p.x, p.y, view.drawing());
    if (target != null) {
      p = Geom.center(target.displayBox());
    }
    setPoint(p.x, p.y);
  }
  /** Creates the connection */
  public void invokeStart(int x, int y, DrawingView view) {
    setConnection(createConnection());

    setUndoActivity(createUndoActivity(view));
    Vector v = new Vector();
    v.add(getConnection());
    getUndoActivity().setAffectedFigures(new FigureEnumerator(v));

    Point p = locate();
    getConnection().startPoint(p.x, p.y);
    getConnection().endPoint(p.x, p.y);
    view.drawing().add(getConnection());
  }
Esempio n. 6
0
 /**
  * Tracks the end of the interaction.
  *
  * @param x the current x position
  * @param y the current y position
  * @param anchorX the x position where the interaction started
  * @param anchorY the y position where the interaction started
  */
 public void invokeEnd(int x, int y, int anchorX, int anchorY, DrawingView view) {
   invokeEnd(x - anchorX, y - anchorY, view.drawing());
 }
Esempio n. 7
0
 /**
  * @param x the x position where the interaction started
  * @param y the y position where the interaction started
  * @param view the handles container
  */
 public void invokeStart(int x, int y, DrawingView view) {
   invokeStart(x, y, view.drawing());
 }
 /** Deletes the selection from the drawing. */
 protected void deleteSelection() {
   fView.drawing().removeAll(fView.selection());
   fView.clearSelection();
 }
 /**
  * Creates the drawing view used in this application. You need to override this method to use a
  * DrawingView subclass in your application. By default a standard DrawingView is returned.
  */
 protected DrawingView createDrawingView() {
   DrawingView createdDrawingView = createDrawingView(createDrawing());
   createdDrawingView.drawing().setTitle(getDefaultDrawingTitle());
   return createdDrawingView;
 }