Package de.hwrberlin.it11.tsp.gui

Examples of de.hwrberlin.it11.tsp.gui.GUI


  /**
   * Testet das Laden von .tsp Dateien.
   */
  public void testWriteAndReadTSP() {
    File file = new File("tspTemp.tsp");
    TSPData data = new TSPData();
    data.addNode(new Node(12.5425235464, 52352.245252));
    data.addNode(new Node(535252.52352352, 25252523.52352352));

    Persister.saveTSPFile(file, data);

    TSPData otherData = Persister.loadTSPFile(file);

    assertEquals(data.getComment(), otherData.getComment());
    assertEquals(data.getEdgeWeightType(), otherData.getEdgeWeightType());
    assertEquals(data.getName(), otherData.getName());
    assertEquals(data.getType(), otherData.getType());
    for (int i = 0; i < data.getNodeList().size(); i++) {
      Node node = data.getNodeList().get(i);
      Node otherNode = otherData.getNodeList().get(i);
      assertEquals(node.getxCoordinate(), otherNode.getxCoordinate());
      assertEquals(node.getyCoordinate(), otherNode.getyCoordinate());
    }

    file.delete();
View Full Code Here


        if (!_currentTabContent.getController().isRunning()) {
          String path = new FileDialogFactory().setParent(pParent).setStyle(SWT.OPEN).setFilter(FileDialogFilter.TSP).open();
          if (path != null) {
            try {
              File file = new File(path);
              TSPData data = Persister.loadTSPFile(file);
              _currentTabContent.setTSPFile(file);
              _tabFolder.getSelection().setText(data.getName());
              _currentTabContent.getController().getProject().setTSPData(data);
            }
            catch (IllegalArgumentException pEx) {
              MessageDialog.openError(pParent, "Ung�ltige Datei", pEx.getMessage());
            }
          }
        }
        else {
          MessageDialog.openError(pParent, "TSP Datei �ffnen", "Es kann keine TSP Datei ge�ffnet werden, wenn der Algorithmus l�uft.");
        }
      }
    });

    fileMenuItemSaveTSPFile.addSelectionListener(new SelectionAdapter() {

      @Override
      public void widgetSelected(SelectionEvent pE) {
        File file = _currentTabContent.getTSPFile();
        if (file == null) {
          String path = new FileDialogFactory().setParent(pParent).setStyle(SWT.SAVE).setFilter(FileDialogFilter.TSP).open();
          if (path != null) {
            file = new File(path);
            _currentTabContent.setTSPFile(file);
          }
        }
        if (file != null) {
          Persister.saveTSPFile(file, _currentTabContent.getController().getProject().getTSPData());
        }
      }
    });

    fileMenuItemSaveTSPFileAs.addSelectionListener(new SelectionAdapter() {

      @Override
      public void widgetSelected(SelectionEvent pE) {
        String path = new FileDialogFactory().setParent(pParent).setStyle(SWT.SAVE).setFilter(FileDialogFilter.TSP).open();
        if (path != null) {
          File file = new File(path);
          _currentTabContent.setTSPFile(file);
          Persister.saveTSPFile(file, _currentTabContent.getController().getProject().getTSPData());
        }
      }
    });

    fileMenuItemOpenConfigFile.addSelectionListener(new SelectionAdapter() {

      @Override
      public void widgetSelected(SelectionEvent pE) {
        if (!_currentTabContent.getController().isRunning()) {
          String path = new FileDialogFactory().setParent(pParent).setStyle(SWT.OPEN).setFilter(FileDialogFilter.TSPCONFIG).open();
          if (path != null) {
            try {
              File file = new File(path);
              Parameter parameter = Persister.loadParameterFile(file);
              _currentTabContent.setTSPConfigFile(file);
              _currentTabContent.getController().getProject().setParameter(parameter);
            }
            catch (IllegalArgumentException pEx) {
              MessageDialog.openError(pParent, "Ung�ltige Datei", pEx.getMessage());
            }
          }
        }
        else {
          MessageDialog.openError(pParent, "Konfigurationsdatei �ffnen",
              "Es kann keine Konfigurationsdatei ge�ffnet werden, wenn der Algorithmus l�uft.");
        }
      }
    });

    fileMenuItemSaveConfigFile.addSelectionListener(new SelectionAdapter() {

      @Override
      public void widgetSelected(SelectionEvent pE) {
        File file = _currentTabContent.getTSPConfigFile();
        if (file == null) {
          String path = new FileDialogFactory().setParent(pParent).setStyle(SWT.SAVE).setFilter(FileDialogFilter.TSPCONFIG).open();
          if (path != null) {
            file = new File(path);
            _currentTabContent.setTSPConfigFile(file);
          }
        }
        if (file != null) {
          Persister.saveParameterFile(file, _currentTabContent.getController().getProject().getParameter());
        }
      }
    });

    fileMenuItemSaveConfigFileAs.addSelectionListener(new SelectionAdapter() {

      @Override
      public void widgetSelected(SelectionEvent pE) {
        String path = new FileDialogFactory().setParent(pParent).setStyle(SWT.SAVE).setFilter(FileDialogFilter.TSPCONFIG).open();
        if (path != null) {
          File file = new File(path);
          _currentTabContent.setTSPConfigFile(file);
          Persister.saveParameterFile(file, _currentTabContent.getController().getProject().getParameter());
        }
      }
    });

    fileMenuItemClose.addSelectionListener(new SelectionAdapter() {

      @Override
      public void widgetSelected(SelectionEvent pE) {
        pParent.close();
      }
    });

    editMenuItemCreateRandomProject.addSelectionListener(new SelectionAdapter() {

      @Override
      public void widgetSelected(SelectionEvent pE) {
        if (!_currentTabContent.getController().isRunning()) {
          RandomProjectDialog randomProjectDialog = new RandomProjectDialog(pParent, _currentTabContent.getController().getProject());
          TSPData data = randomProjectDialog.open();
          if (data != null) {
            _currentTabContent.getController().getProject().setTSPData(data);
          }
        }
        else {
View Full Code Here

TOP

Related Classes of de.hwrberlin.it11.tsp.gui.GUI

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.