Package ch.rakudave.jnetmap.model

Examples of ch.rakudave.jnetmap.model.Map


    plusButton.setContentAreaFilled(false);
    plusButton.setBorder(BorderFactory.createEmptyBorder());
    plusButton.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        openTab(new Map());
      }
    });
    setTabComponentAt(0, plusButton);
  }
View Full Code Here


  }
 
  @SuppressWarnings({ "unchecked", "rawtypes" })
  public static void setLayout(Class<Layout<Device, Connection>> layout) {
    if (currentTab == null) return;
    final Map map = currentTab.map;
    final VisualizationViewer<Device, Connection> vv = currentTab.vv;
    final Layout<Device, Connection> oldLayout = map.getGraphLayout();
    try {
      Class<? extends Layout<Device, Connection>> layoutC =  (Class<? extends Layout<Device, Connection>>) layout;
          Constructor constructor = layoutC.getConstructor(new Class[] {Graph.class});
          Object o = constructor.newInstance(map);
          final Layout<Device, Connection> newLayout = (Layout<Device, Connection>) o;
          newLayout.setInitializer(vv.getGraphLayout());
          newLayout.setSize(vv.getSize());
      map.getHistory().execute(new Command() {
        @Override
        public Object undo() {
          map.setLayout(oldLayout);
          new Animator(new LayoutTransition<Device, Connection>(vv, newLayout, oldLayout)).start();
          vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
          vv.repaint();
          return null;
        }
       
        @Override
        public Object redo() {
          map.setLayout(newLayout);
          new Animator(new LayoutTransition<Device, Connection>(vv,  oldLayout, newLayout)).start();
          vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
          vv.repaint();
          return null;
        }
View Full Code Here

  // New file
  public static Action newMap(String label) {
    return new AbstractAction(label, Icons.get("new")) {
      @Override
      public void actionPerformed(ActionEvent e) {
        Controller.getView().openMap(new Map());
      }
    };
  }
View Full Code Here

      public void actionPerformed(ActionEvent e) {
        Object[] o = SwingHelper.openDialog((Component) Controller.getView(), new FileNameExtensionFilter("jNetMap file *.jnm", "jnm"), true);
        if (o == null) return;
        File f = (File) o[0];
        if (f == null) return;
        Map map = Controller.getMapFromFile(f.getAbsolutePath(), (String) o[1]);
        if (map != null) {
          Controller.open(map);
        } else {
          JOptionPane.showMessageDialog((Component) Controller.getView(), Lang.getNoHTML("message.fail.open"),
              Lang.getNoHTML("message.error"), JOptionPane.ERROR_MESSAGE);
View Full Code Here

  // Save file
  public static Action save() {
    return new AbstractAction(Lang.getNoHTML("menu.file.save"), Icons.get("save")) {
      @Override
      public void actionPerformed(ActionEvent e) {
        Map map = Controller.getCurrentMap();
        if (map == null) {
          return;
        } else if (Lang.getNoHTML("map.unsaved").equals(map.getFilePath())) {
          saveAs().actionPerformed(null);
        } else {
          if (!map.save()) {
            JOptionPane.showMessageDialog((Component) Controller.getView(), Lang.getNoHTML("message.fail.save"),
                Lang.getNoHTML("message.error"), JOptionPane.ERROR_MESSAGE);
          }
        }
      }
View Full Code Here

  // Save As...
  public static Action saveAs() {
    return new AbstractAction(Lang.getNoHTML("menu.file.saveas"), Icons.get("save-as")) {
      @Override
      public void actionPerformed(ActionEvent e) {
        Map map = Controller.getCurrentMap();
        if (map == null) return;
        Object[] o = SwingHelper.saveDialog((Component) Controller.getView(), new FileNameExtensionFilter("jNetMap file *.jnm", "jnm"), true);
        if (o == null) return;
        File f = (File) o[0];
        if (f == null) return;
        map.setFile(f);
        map.setPassword((String) o[1]);
        if (!map.save()) {
          JOptionPane.showMessageDialog((Component) Controller.getView(), Lang.getNoHTML("message.fail.save"),
              Lang.getNoHTML("message.error"), JOptionPane.ERROR_MESSAGE);
        }
      }
    };
View Full Code Here

        if (password == null) return null;
      }
      if (password != null && !password.isEmpty()) {
        xml = Crypto.decrypt(xml, password);
      }
      Map m = (Map) XStreamHelper.getXStream().fromXML(xml);
      m.setFile(mapFile);
      m.setPassword(password);
      return m;
    } catch (Exception e) {
      Logger.error("Could not open file '" + filePath + "'", e);
      return null;
    }
View Full Code Here

TOP

Related Classes of ch.rakudave.jnetmap.model.Map

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.