/** Constructs ESA Tables, one esa header corresponds to one esa table */
    private void yieldEsaTables() {
      //          algorithm is:
      //          1. acquire the eiaHeader of the current file;
      //          2. construct the ESA table one channel after another;
      //          3. update the status.
      int numberOfOpenedFiles = sourceFiles.size();
      ArrayList<ESATable> esaTables = new ArrayList<ESATable>(numberOfOpenedFiles);

      ESAHeader esaHeader;
      ESATable esaTable;
      for (int i = 0; i < numberOfOpenedFiles; i++) {
        // Get ESAHeader from each EDF file header
        esaHeader = MainWindow.srcEdfFileHeaders.get(i).getEsaHeader(); // 1.
        // Create ESATable using ESAHeader
        esaTable = new ESATable(esaHeader, true);
        esaTables.add(i, esaTable); // 2.
        // configure the status
        Boolean savedOnce = false; // start of 3.
        Boolean updateSinceLastSave = true;
        File workingFile = MainWindow.getWkEdfFiles().get(i);
        int cat = EDFTable.MasterHeaderCategory.ESA_WORKSET;
        esaTable.setStatesAllInOne(
            savedOnce, updateSinceLastSave, workingFile, cat, i); // end of 4.
        esaTable.setSourceMasterFile(sourceFiles.get(i)); // set source file
        // by wei wang
        //                if(readingFileCount < numberOfOpenedFiles) {
        //                	increaseReadingFileCount();
        //                }
      }
      MainWindow.setIniEsaTables(esaTables);
      MainWindow.setDupEsaTables(esaTables);
    }
Exemple #2
0
 public Activity addActivity(
     String activityName, int activityDuration, String predecessors[], int activityResources[]) {
   Activity newActivity = null;
   if (this.isUnique(activityName)) {
     newActivity =
         new Activity(
             activityName, activityDuration, activityResources, this.getMaxNumOfResources());
     // the predecessors of START are NULL
     if (predecessors != null) {
       if (predecessors.length == 0) {
         Activity current = getActivityByName("START");
         newActivity.addPredecessor(current);
         current.addSuccessor(newActivity);
       } else {
         for (int i = 0; i < predecessors.length; i++) {
           Activity current = getActivityByName(predecessors[i]);
           if (current != null) {
             newActivity.addPredecessor(current);
             current.addSuccessor(newActivity);
           } else {
             view.printDebugln(
                 "Cannot add predecessor relation to non-exisiting node " + predecessors[i]);
           }
         }
       }
     }
     activities.add(newActivity);
   } else {
     // activity name is not unique or activity already exists
     view.printDebugln(
         "Cannot add activity " + activityName + " because the name already exists.");
   }
   return newActivity;
 }
Exemple #3
0
 /**
  * Preform the task for the given button
  *
  * @param e Event of the action
  */
 @Override
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == startNewGame) main.getGame().startNewGame();
   else if (e.getSource() == deployTradingWindow) main.deployTradingWindow();
   else if (e.getSource() == deployOptionsWindow) main.deployOptionsWindow();
   else if (e.getSource() == exitProgram) System.exit(0);
 }
 public EkconfEditingSupport(MainWindow mainW) {
   super(mainW.getMenuTree());
   viewer = mainW.getMenuTree();
   this.editor = new TextCellEditor((Composite) viewer.getControl());
   this.editorPart = mainW.getEkconfEditorPart();
   this.window = MainWindow.getActiveWindow();
 }
  private void okActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_okActionPerformed

    try {

      if (txtuser.getText().equals("") || txtpassword.getText().equals("")) {

        JOptionPane.showMessageDialog(this, "Please Enter Username & Password", "Message", WIDTH);
      } else { // connect
        Class.forName("com.mysql.jdbc.Driver");
        Connection conn =
            DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/student_information", "root", "123");
        Statement stm = conn.createStatement();
        String qry = "select password from login where username = '******' ;";
        ResultSet rst = stm.executeQuery(qry);

        Statement stm2 = conn.createStatement();
        String qry2 = "select state from login where username = '******'; ";
        ResultSet rst2 = stm2.executeQuery(qry2);

        if (!rst.next()) { // validate username

          JOptionPane.showMessageDialog(this, "Invalid Username", "Error", WIDTH);
        } else if (rst.getString("password").equals(txtpassword.getText())) { // check password

          MainWindow m = new MainWindow(); // open main
          m.setVisible(true);

          m.lbluser.setText(txtuser.getText());

          if (rst2.next() && rst2.getInt("State") == 1) { // block lecturer

            m.lblState.setText("Admin");
          } else {

            m.lblState.setText("Lecturer");
            /* MainWindow mw1 = new MainWindow();
            mw1.btnStudentm.setVisible(false);
            mw1.btnCoursem.setVisible(false);
            mw1.btnLecturerm.setVisible(false);
            mw1.btnAdmin.setVisible(false);
            mw1.lbllec.setVisible(false);*/
          }

          this.setVisible(false);
          txtuser.setText("");
          txtpassword.setText("");

        } else {

          JOptionPane.showMessageDialog(this, "Invalid Password", "Error", WIDTH);
        }
      }

    } catch (Exception e) {

      JOptionPane.showMessageDialog(this, "Error in Excecution " + e, "Error", WIDTH);
    }
  } // GEN-LAST:event_okActionPerformed
Exemple #6
0
  @SuppressWarnings("deprecation")
  private void initLayout() {

    ExternalResource ico_1 =
        new ExternalResource(
            "http://sphotos-d.ak.fbcdn.net/hphotos-ak-ash3/574636_108340259349575_2027925130_n.jpg");
    Link image1 = new Link(null, new ExternalResource("http://www.uib.no/rg/probe"));
    image1.setIcon(ico_1);
    image1.setTargetName("_blank");

    Link image2 = new Link(null, new ExternalResource("http://www.uib.no/"));
    image2.setIcon(
        new ExternalResource(
            "http://sphotos-d.ak.fbcdn.net/hphotos-ak-prn1/533227_118477988335802_947238298_n.jpg"));
    image2.setTargetName("_blank");
    image2.setWidth("105px");

    Link image3 = new Link(null, new ExternalResource("http://www.stiftkgj.no/"));
    image3.setIcon(
        new ExternalResource(
            "http://sphotos-h.ak.fbcdn.net/hphotos-ak-snc6/188329_108340226016245_257713989_n.jpg"));
    image3.setTargetName("_blank");

    MainWindow mw = new MainWindow(url, dbName, driver, userName, password, image1, image2, image3);
    // mw.setWidth("100%");
    // mw.setHeight("100%");
    mw.setStyle(Reindeer.WINDOW_LIGHT);
    Window w = new Window("CSF Proteome Resource (CSF-PR)", mw);
    setMainWindow(w);

    // mw.setBodyHeight();

  }
 public void testYourselfProgress() {
   // Goes through the list from the last unmemorized word in the word list, testing a character on
   // characters,
   // pinyin and definition.
   if (choice == correct) {
     JOptionPane.showMessageDialog(null, "Correct!");
     if (current < wordIndex) { // Error check to see whether the quiz has reached the final word.
       // Goes through each word, testing the pinyin, character and the definition.
       if (progress % 3 == 0) {
         pinyinLoad();
         progress++;
       } else if (progress % 3 == 1) {
         characterLoad();
         progress++;
       } else if (progress % 3 == 2) {
         definitionLoad();
         progress++;
         // User has memorized the word
         words[current].setMemorized(true);
         current++; // Increments up to test the user on the new word.
       }
     } else {
       // If the test has gone on to the final word, closes the form and goes back to the main
       // form.
       saveWords();
       MainWindow start = new MainWindow();
       start.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       start.setVisible(true);
       this.dispose();
     }
   } else {
     JOptionPane.showMessageDialog(null, "Sorry, you got it wrong.");
   }
 }
  /**
   * This method is relocated and minor modification was made
   *
   * @author wei wang, 5/21/2014
   */
  private void yieldNewEDFHeaders() {
    int numberOfOpenedFiles = sourceFiles.size();
    ArrayList<EDFFileHeader> edfHeaders = new ArrayList<EDFFileHeader>(numberOfOpenedFiles);
    ArrayList<EDFFileHeader> edfHeaderCopies = new ArrayList<EDFFileHeader>(numberOfOpenedFiles);
    MainWindow.srcEdfFileHeaders = new ArrayList<EDFFileHeader>(numberOfOpenedFiles);

    // read each file to build headers
    File currentEDF;
    for (int i = 0; i < numberOfOpenedFiles; i++) {
      // Loop through each of the EDF files read in
      currentEDF = sourceFiles.get(i);
      // For progress bar
      if ((i + 1) % (scale * 2) == 0) {
        task.increaseProgress();
      }

      try {
        RandomAccessFile raf = new RandomAccessFile(currentEDF, "r");
        // EDF headers array:
        edfHeaders.add(i, new EDFFileHeader(raf, currentEDF, false));
        // raf was closed in the 'new EDFFileHeader(raf, currentFile, false)' method
        raf = new RandomAccessFile(currentEDF, "r");
        edfHeaderCopies.add(i, new EDFFileHeader(raf, currentEDF, false));
      } catch (IOException f) {
        JOptionPane.showMessageDialog(
            null,
            "File invalid: wrong format or empty. ",
            "Data read error",
            JOptionPane.ERROR_MESSAGE);
      }
    }
    MainWindow.setSrcEdfFileHeaders(edfHeaders);
    MainWindow.setDupEdfFileHeaders(edfHeaderCopies);
  }
    /** Action performed when adding new files to task */
    public void performActions() {
      if (sourceFiles != null) {
        createWorkingDirectory();
        // generate new edf headers
        MainWindow.getSaveProgressBar().setVisible(true);

        renewFileRecords();
        NewTask_for_ValidityCommandLine.this.yieldNewEDFHeaders();
        // Long running task begin. wei wang, 5/23/2014
        //            	WkEdfFiles = Utility.copyFilestoDirectory(sourceFiles, workingDirectory);
        // Actual long executing task is parsing name confliction.
        //            	System.out.println("Long running task end."); // test
        yieldEiaTable();
        yieldEsaTables();
        updatePrimaryTabs();
        updateTaskTreeWkfileNodes();
        //              root.setCursor(Cursor.getDefaultCursor());
        //              frame.dispose();
        MainWindow.getSaveProgressBar().setVisible(false);

        printMessageToConsole();
        printMessageToInfopane();
        // cleanupErorListTable();

        boolean active = true;
        activateMenuItems(active);
        activateToolBarItems(active);
        displayMainTab(active);

        parseTaskFiles();
      }
    }
  public Game() {

    // ResourceLoader.loadMesh("Gemstone.obj");//new Mesh();
    _material = new Material(new Texture("test.png"), new Vector3f(1, 1, 1), 1, 8);
    _shader = PhongShader.getInstance();
    _camera = new Camera();
    _transform = new Transform();

    float fieldDepth = 10.0f;
    float fieldWidth = 10.0f;

    Vertex[] vertices =
        new Vertex[] {
          new Vertex(new Vector3f(-fieldWidth, 0.0f, -fieldDepth), new Vector2f(0.0f, 0.0f)),
          new Vertex(new Vector3f(-fieldWidth, 0.0f, fieldDepth * 3), new Vector2f(0.0f, 1.0f)),
          new Vertex(new Vector3f(fieldWidth * 3, 0.0f, -fieldDepth), new Vector2f(1.0f, 0.0f)),
          new Vertex(new Vector3f(fieldWidth * 3, 0.0f, fieldDepth * 3), new Vector2f(1.0f, 1.0f))
        };

    int indices[] = {0, 1, 2, 2, 1, 3};

    _mesh = new Mesh(vertices, indices, true);

    Transform.setProjection(70f, MainWindow.getWidth(), MainWindow.getHeight(), 0.1f, 1000f);
    Transform.setCamera(_camera);

    PhongShader.setAmbientLight(new Vector3f(0.1f, 0.1f, 0.1f));
    PhongShader.setDirectionalLight(
        new DirectionalLight(new BaseLight(new Vector3f(1, 1, 1), 0.01f), new Vector3f(1, 1, 1)));

    PhongShader.setPointLight(new PointLight[] {pLight1, pLight2, pLight3});
    PhongShader.setSpotLights(new SpotLight[] {sLight1});
  }
  private void performActions() {
    // do nothing is there is not tab pane at all
    if (MainWindow.tabPane == null || MainWindow.tabPane.getTabCount() == 0) return;

    int n =
        JOptionPane.showConfirmDialog(
            null,
            "Are you sure to discard changes?",
            "Discard changes?",
            JOptionPane.YES_NO_OPTION);
    sourceFiles = MainWindow.getSrcEdfFiles();
    if (sourceFiles != null && n == JOptionPane.YES_OPTION) {
      tabLocation = MainWindow.getSelectedTabIndex();
      selectedEDF = MainWindow.getSelectedEDFIndex() - 2;
      if (tabLocation == 0) {
        yieldEiaTable();
        updatePrimaryEIATab();
        MainWindow.tabPane.setSelectedIndex(0);
      }
      if (tabLocation == 1) {
        yieldEsaTable();
        updatePrimaryESATab();
        MainWindow.tabPane.setSelectedIndex(1);
      }
    }
  }
 public void end(boolean death) {
   String stageName = null;
   stageName = stageChanger.getNextStage(currentStage, totalStages);
   if (death == true) {
     gameOver = true;
     if (gameEnd) {
       gameEnd = false;
       player.deathCount += 1;
     }
     playerSaver.playerSaver(player);
     mainWindow.endGame(death);
   } else if (stageName == null) {
     gameOver = true;
     if (gameEnd) {
       player.victoryCount += 1;
       gameEnd = false;
     }
     playerSaver.playerSaver(player);
     mainWindow.endGame(death);
   }
   currentStage += 1;
   if (stageName != null) {
     player.gameEnd = false;
     Collisions.clearCollisions();
     objectMaker = stageMaker.getFile(stageName, objectMaker);
     imageList = objectMaker.getImages();
     enemyList = objectMaker.getEnemies();
   }
   player.setX(0);
   // TODO: Remove player oval from screen, then present EndScreen
   // TODO: Get fancy by adding a death sound/animation
 }
Exemple #13
0
 public void addResource() {
   if (usedResources < this.resLimits.length) {
     usedResources++;
     view.addResource(usedResources);
   } else {
     view.printDebugln("Cannot add further resources.");
   }
 }
Exemple #14
0
 @Override
 public void setWindowPosition(MainWindow<IT> mainWindow, MaxProjectionZ<IT> maxZWindow) {
   Point windowLoc = mainWindow.getWindow().getLocation();
   imp.getWindow()
       .setLocation(
           windowLoc.x + mainWindow.getWindow().getWidth() + 20,
           windowLoc.y + mainWindow.getWindow().getHeight());
 }
Exemple #15
0
 public void deleteResource() {
   if (usedResources > 1) {
     view.deleteResource(usedResources);
     usedResources--;
   } else {
     view.printDebugln("The project needs at least one resource.");
   }
 }
Exemple #16
0
  /**
   * Handles 'Save As' for a sketch.
   *
   * <p>This basically just duplicates the current sketch folder to a new location, and then calls
   * 'Save'. (needs to take the current state of the open files and save them to the new folder..
   * but not save over the old versions for the old sketch..)
   *
   * <p>Also removes the previously-generated .class and .jar files, because they can cause trouble.
   */
  public boolean saveAs() throws IOException {
    // get new name for folder
    FileDialog fd = new FileDialog(editor, "Save file as...", FileDialog.SAVE);
    if (isReadOnly()) {
      // default to the sketchbook folder
      fd.setDirectory(Base.preferences.get("sketchbook.path", null));
    } else {
      // default to the parent folder of where this was
      fd.setDirectory(folder.getParent());
    }
    fd.setFile(folder.getName());

    fd.setVisible(true);
    String newParentDir = fd.getDirectory();
    String newName = fd.getFile();

    File newFolder = new File(newParentDir);
    // user cancelled selection
    if (newName == null) return false;

    if (!newName.endsWith(".gcode")) newName = newName + ".gcode";

    // grab the contents of the current tab before saving
    // first get the contents of the editor text area
    if (current.modified) {
      current.program = editor.getText();
    }

    // save the other tabs to their new location
    for (int i = 1; i < codeCount; i++) {
      File newFile = new File(newFolder, code[i].file.getName());
      code[i].saveAs(newFile);
    }

    // save the hidden code to its new location
    for (int i = 0; i < hiddenCount; i++) {
      File newFile = new File(newFolder, hidden[i].file.getName());
      hidden[i].saveAs(newFile);
    }

    // save the main tab with its new name
    File newFile = new File(newFolder, newName);
    code[0].saveAs(newFile);

    editor.handleOpenUnchecked(
        newFile.getPath(),
        currentIndex,
        editor.textarea.getSelectionStart(),
        editor.textarea.getSelectionEnd(),
        editor.textarea.getScrollPosition());

    // Name changed, rebuild the sketch menus
    // editor.sketchbook.rebuildMenusAsync();

    // let MainWindow know that the save was successful
    return true;
  }
Exemple #17
0
 /**
  * Draw something when the selected room is null
  *
  * @param g
  */
 private void drawIfRoomNull(Graphics g) {
   int width = mainWindow.getModel().getEpisode().getRoomWidth() * fieldSize;
   int height = mainWindow.getModel().getEpisode().getRoomHeight() * fieldSize;
   g.setColor(Color.GRAY);
   g.fillRect(fieldSize * 2, fieldSize * 2, width, height);
   g.setColor(Color.BLACK);
   g.drawString(roomX + "/" + roomY, fieldSize * 4, fieldSize * 4);
   g.drawString("Room not existent. Click to create!", fieldSize * 4, fieldSize * 4 + 30);
 }
 /**
  * Performs actions based on the selected mode. Browse by source directory or browse by source
  * file
  */
 private void performActions() {
   if (dirRadio.isSelected()) {
     browseBySourceDir();
     MainWindow.setSelectionMode(MainWindow.selection_mode_by_dir);
   } else {
     browseBySourceFile();
     MainWindow.setSelectionMode(MainWindow.selection_mode_by_file);
   }
 }
 private void jButton1ActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed
   // Closes this window and restarts the main window.
   MainWindow start = new MainWindow();
   start.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   start.setVisible(true);
   saveWords();
   this.dispose();
 } // GEN-LAST:event_jButton1ActionPerformed
Exemple #20
0
  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    this.imageLoader = mainWindow.getImageLoader();

    if (mainWindow.getModel().getEpisode() == null) return;
    if (floor == null) return;

    // NO ROOM SELECTED
    if (currentRoom == null) {
      drawIfRoomNull(g);
    }

    // DRAW ROOM INCLUDING NEIGHBORS
    for (int x = -2; x < roomWidth + 2; x++) {
      for (int y = -2; y < roomHeight + 2; y++) {
        int fieldRoomX = roomX;
        int fieldRoomY = roomY;
        int fieldX = x;
        int fieldY = y;
        boolean outside = false;
        if (x < 0) {
          fieldRoomX--;
          fieldX += roomWidth;
          outside = true;
        } else if (x >= roomWidth) {
          fieldRoomX++;
          fieldX -= roomWidth;
          outside = true;
        }
        if (y < 0) {
          fieldRoomY--;
          fieldY += roomHeight;
          outside = true;
        } else if (y >= roomHeight) {
          fieldRoomY++;
          fieldY -= roomHeight;
          outside = true;
        }

        Room roomOfThisField = floor.getRoom(fieldRoomX, fieldRoomY);
        drawFieldWithAllLayers(g, roomOfThisField, fieldX, fieldY, x, y);

        if (outside) {
          g.setColor(new Color(128, 128, 128, 128));
          g.fillRect((x + 2) * fieldSize, (y + 2) * fieldSize, fieldSize, fieldSize);
        }
      }
    }

    // DRAW GRID
    if (drawGrid) drawGrid(g);

    // DRAW FRAME
    drawFrame(g);
  }
 /** Validates the ESA table and stores corresponding incompliances */
 public void validateEsaTable() {
   ArrayList<ESATable> tables = MainWindow.getIniEsaTables();
   ArrayList<Incompliance> incomps = new ArrayList<Incompliance>();
   ArrayList<Incompliance> inserted = new ArrayList<Incompliance>();
   for (int i = 0; i < tables.size(); i++) {
     incomps = tables.get(i).parseESATable();
     for (Incompliance incomp : incomps) inserted.add(incomp);
   }
   MainWindow.setEsaIncompliances(inserted);
 }
 private void parseTaskFiles() {
   // cleanupErrorListTable();
   // must clear, otherwise, the data might displayed twice
   MainWindow.getEiaIncompliances().clear();
   MainWindow.getEsaIncompliances().clear();
   // update eia and esa incompliances
   validateEiaTable();
   validateEsaTable();
   outputValidationToErrorListTable();
   switchToErrorListTable();
 }
    private void outputValidationToErrorListTable() {
      ErrorListTable errorTable = MainWindow.getErrorListTable();
      errorTable.blankOut();
      ArrayList<Incompliance> incompliances = MainWindow.aggregateIncompliances();

      int count = incompliances.size();
      outputMessage(count);

      if (count != 0) errorTable.yieldTableFrom(incompliances);

      ErrorListTable.setIcon(errorTable, count);
    }
 @Override
 protected void setValue(Object element, Object value) {
   Menu menu = (Menu) element;
   Symbol sym = menu.getSymbol();
   if (value instanceof String) {
     if (sym.setStringValue((String) value)) {
       viewer.update(menu, new String[] {MainWindow.OPTION, MainWindow.VALUE});
       if (editorPart != null) editorPart.fireDirty();
       window.getMenuTree().refresh(menu);
       window.updateHelp();
     }
   }
 }
Exemple #25
0
  /** @param args the command line arguments */
  public static void main(String[] args) {
    Grid g = Grid.getInstance();
    System.out.println(g.toString());

    MainWindow mainWindow = new MainWindow();
    mainWindow.setVisible(true);
    mainWindow.drawGrid(g);
    System.out.println(g);
    mainWindow.setSpeed(Agent.getSpeed());
    g.startAgents();

    long start = System.currentTimeMillis();
    while (true) {
      if (System.currentTimeMillis() - start > 10) {
        int car = g.nbCarriedItem();
        int ongrid = g.nbItemsOnGrid();
        MainWindow.getInstance().drawGrid(g);

        mainWindow.setCarried(car);

        mainWindow.setOngrid(ongrid);

        mainWindow.setTotal(car + ongrid);

        start = System.currentTimeMillis();
      }
    }
  }
  /**
   * Change internal settings based on what was chosen in the prefs, then send a message to the
   * editor saying that it's time to do the same.
   */
  public void applyFrame() {
    // put each of the settings into the table
    String newSizeText = fontSizeField.getText();
    try {
      int newSize = Integer.parseInt(newSizeText.trim());
      String fontName = Base.preferences.get("editor.font", "Monospaced,plain,12");
      if (fontName != null) {
        String pieces[] = fontName.split(",");
        pieces[2] = String.valueOf(newSize);
        StringBuffer buf = new StringBuffer();
        for (String piece : pieces) {
          if (buf.length() > 0) buf.append(",");
          buf.append(piece);
        }
        Base.preferences.put("editor.font", buf.toString());
      }

    } catch (Exception e) {
      Base.logger.warning("ignoring invalid font size " + newSizeText);
    }
    String origUpdateUrl = Base.preferences.get("replicatorg.updates.url", "");
    if (!origUpdateUrl.equals(firmwareUpdateUrlField.getText())) {
      FirmwareUploader.invalidateFirmware();
      Base.preferences.put("replicatorg.updates.url", firmwareUpdateUrlField.getText());
      FirmwareUploader.checkFirmware(); // Initiate a new firmware check
    }

    String logPath = logPathField.getText();
    Base.preferences.put("replicatorg.logpath", logPath);
    Base.setLogFile(logPath);

    editor.applyPreferences();
  }
Exemple #27
0
  /** Save all code in the current sketch. */
  public boolean save() throws IOException {
    // make sure the user didn't hide the sketch folder
    ensureExistence();

    // first get the contents of the editor text area
    if (current.modified) {
      current.program = editor.getText();
    }

    // don't do anything if not actually modified
    // if (!modified) return false;

    if (isReadOnly()) {
      // if the files are read-only, need to first do a "save as".
      Base.showMessage(
          "Sketch is read-only",
          "Some files are marked \"read-only\", so you'll\n"
              + "need to re-save this sketch to another location.");
      // if the user cancels, give up on the save()
      if (!saveAs()) return false;
    }

    for (int i = 0; i < codeCount; i++) {
      if (code[i].modified) code[i].save();
    }
    calcModified();
    return true;
  }
Exemple #28
0
  private void drawJuliaDot() {
    int x0, y0, list_size;

    Graphics2D full_image_g = image.createGraphics();

    pixel_orbit.calculateJuliaOrbit();

    full_image_g.setColor(orbit_color);

    full_image_g.setFont(new Font("Arial", 1, 11));
    list_size = complex_orbit.size();

    double size = pixel_orbit.getSize();
    int image_size = ptr.getImageSize();

    double temp_xcenter_size = pixel_orbit.getXCenter() - size / 2;
    double temp_ycenter_size = pixel_orbit.getYCenter() - size / 2;
    double temp_size_image_size = size / image_size;

    for (int i = 0; i < list_size; i++) {
      x0 = (int) ((complex_orbit.get(i).getRe() - temp_xcenter_size) / temp_size_image_size);
      y0 = (int) ((complex_orbit.get(i).getIm() - temp_ycenter_size) / temp_size_image_size);
      full_image_g.drawString(".", x0 - 1, y0 + 1);
    }
  }
Exemple #29
0
  private void drawJuliaLine() {
    int x0, y0, x1 = 0, y1 = 0, list_size;

    Graphics2D full_image_g = image.createGraphics();

    pixel_orbit.calculateJuliaOrbit();

    full_image_g.setColor(orbit_color);

    full_image_g.setRenderingHint(
        RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    list_size = complex_orbit.size() - 1;

    double size = pixel_orbit.getSize();
    int image_size = ptr.getImageSize();

    double temp_xcenter_size = pixel_orbit.getXCenter() - size / 2;
    double temp_ycenter_size = pixel_orbit.getYCenter() - size / 2;
    double temp_size_image_size = size / image_size;

    for (int i = 0; i < list_size; i++) {
      x0 = (int) ((complex_orbit.get(i).getRe() - temp_xcenter_size) / temp_size_image_size);
      y0 = (int) ((complex_orbit.get(i).getIm() - temp_ycenter_size) / temp_size_image_size);
      x1 = (int) ((complex_orbit.get(i + 1).getRe() - temp_xcenter_size) / temp_size_image_size);
      y1 = (int) ((complex_orbit.get(i + 1).getIm() - temp_ycenter_size) / temp_size_image_size);
      full_image_g.drawLine(x0, y0, x1, y1);
      full_image_g.fillOval(x0, y0, 3, 3);
    }

    full_image_g.fillOval(x1, y1, 3, 3);
  }
  /**
   * Initialize toolbars. Crates a tool bar to show when selecting an alive agent, another for dead
   * agents, and a third one when no agent is selected.
   *
   * <p>I'm not sure if this is the best way to create the tool bars.
   *
   * <p>To add a new toolbar for new types of agents, see MultipleToolBar and ActionFactory.
   */
  private void initToolBar() {
    MultipleToolBar toolBar = mainWindow.getToolBar();
    ActionFactory actionFactory = ActionFactory.getInstance();
    Action[] normalActions = {
      actionFactory.getNewGameAction(),
      actionFactory.getStartStopAction(),
      actionFactory.getSaveGameAction(),
      actionFactory.getIncreaseCO2Action(),
      actionFactory.getDecreaseCO2Action(),
      actionFactory.getManageConnectionsAction(),
      actionFactory.getAbortTrackingAction(),
      actionFactory.getZoomInAction(),
      actionFactory.getZoomOutAction(),
      actionFactory.getToggleEfficiencyModeAction()
    };
    Action[] aliveActions = {
      actionFactory.getFeedAction(),
      actionFactory.getWeakenAction(),
      actionFactory.getKillAction(),
      actionFactory.getCopyAction(),
      actionFactory.getSaveImageAction(),
      actionFactory.getTrackAction(),
      actionFactory.getAbortTrackingAction(),
      actionFactory.getZoomInAction(),
      actionFactory.getZoomOutAction()
    };
    Action[] deadActions = {actionFactory.getReviveAction(), actionFactory.getDisperseAction()};

    toolBar.addActionArray("normal", normalActions);
    toolBar.selectActionArray("normal");
    toolBar.addActionArray("alive", aliveActions);
    toolBar.addActionArray("dead", deadActions);
  }