예제 #1
0
  /**
   * create a new Spring Layout.
   *
   * @param swingEngine The PathVisio swing engine
   * @param selection Boolean whether to use currently selected nodes or complete pathway
   */
  public Spring(SwingEngine swingEngine, boolean selection) {
    super(swingEngine, selection);
    createDSMultigraph();
    l = new SpringLayout<String, String>(g);
    setDimension(l);
    double fm =
        Double.parseDouble(PreferenceManager.getCurrent().get(PlPreference.PL_LAYOUT_SPRING_FORCE));
    int rep =
        Integer.parseInt(
            PreferenceManager.getCurrent().get(PlPreference.PL_LAYOUT_SPRING_REPULSION));
    double s =
        Double.parseDouble(
            PreferenceManager.getCurrent().get(PlPreference.PL_LAYOUT_SPRING_STRETCH));
    l.setForceMultiplier(fm);
    l.setRepulsionRange(rep);
    l.setStretch(s);

    l.initialize();
    for (int i = 0; i < 1000; i++) {
      l.step();
    }

    drawNodes((AbstractLayout<String, String>) l);
    // re-draw the lines
    drawLines();
  }
예제 #2
0
 public PathwayChooser(
     String taskName, int dialogType, Preference dirPreference, Set<? extends PathwayIO> set) {
   fileDialog = new FileDialog(new Frame(), taskName + " pathway", dialogType);
   fileDialog.setDirectory(
       PreferenceManager.getCurrent().getFile(dirPreference).getAbsolutePath());
   jfc = new JFileChooser();
   this.taskName = taskName;
   this.dirPreference = dirPreference;
   createFileFilters(set);
   jfc.setDialogTitle(taskName + " pathway");
   jfc.setDialogType(dialogType);
   jfc.setCurrentDirectory(PreferenceManager.getCurrent().getFile(dirPreference));
 }
예제 #3
0
 public int show() {
   if (useFileDialog) {
     fileDialog.setVisible(true);
     if (fileDialog.getDirectory() == null) {
       return JFileChooser.CANCEL_OPTION;
     } else {
       PreferenceManager.getCurrent()
           .setFile(dirPreference, new File(fileDialog.getDirectory()));
       return JFileChooser.APPROVE_OPTION;
     }
   }
   int status = jfc.showDialog(getApplicationPanel(), taskName);
   if (status == JFileChooser.APPROVE_OPTION) {
     PreferenceManager.getCurrent().setFile(dirPreference, jfc.getCurrentDirectory());
   }
   return status;
 }
예제 #4
0
  public VPathwaySwing(JScrollPane parent) {
    super();
    if (parent == null) throw new IllegalArgumentException("parent is null");
    this.container = parent;
    addMouseListener(this);
    addMouseMotionListener(this);
    addKeyListener(this);
    addMouseWheelListener(this);

    if (isOSX) {
      try {
        MultiTouchGestureUtilities.addGestureListener(
            this,
            new GestureAdapter() {

              @Override
              public void magnify(MagnifyGestureEvent me) {
                child.zoomToCursor(
                    100 * child.getZoomFactor() * (1 + me.getMagnification()),
                    new Point((int) me.getMouseX(), (int) me.getMouseY()));

                Component comp = container.getParent().getParent();
                if (comp instanceof MainPanel) ((MainPanel) comp).updateZoomCombo();
              }

              @Override
              public void scroll(ScrollGestureEvent e) {
                Rectangle r = container.getViewport().getViewRect();
                int newx = Math.max((int) (r.getMinX() - e.getDeltaX()), 0);
                int newy = Math.max((int) (r.getMinY() - e.getDeltaY()), 0);
                scrollTo(newx, newy);
              }
            });
      } catch (Throwable t) {
        t.printStackTrace();
        isOSX = false;
      }
    }

    setFocusable(true);
    setRequestFocusEnabled(true);
    setTransferHandler(new PathwayImportHandler());

    setDoubleBuffered(
        PreferenceManager.getCurrent().getBoolean(GlobalPreference.ENABLE_DOUBLE_BUFFERING));
  }