public void readXMLData() {
   energy = new double[0];
   magnetization = new double[0];
   numberOfPoints = 0;
   String filename = "ising_data.xml";
   JFileChooser chooser = OSPFrame.getChooser();
   int result = chooser.showOpenDialog(null);
   if (result == JFileChooser.APPROVE_OPTION) {
     filename = chooser.getSelectedFile().getAbsolutePath();
   } else {
     return;
   }
   XMLControlElement xmlControl = new XMLControlElement(filename);
   if (xmlControl.failedToRead()) {
     control.println("failed to read: " + filename);
   } else {
     // gets the datasets in the xml file
     Iterator it = xmlControl.getObjects(Dataset.class, false).iterator();
     while (it.hasNext()) {
       Dataset dataset = (Dataset) it.next();
       if (dataset.getName().equals("magnetization")) {
         magnetization = dataset.getYPoints();
       }
       if (dataset.getName().equals("energy")) {
         energy = dataset.getYPoints();
       }
     }
     numberOfPoints = magnetization.length;
     control.println("Reading: " + filename);
     control.println("Number of points = " + numberOfPoints);
   }
   calculate();
   plotFrame.repaint();
 }
Exemplo n.º 2
0
 /** Repaints this on all tracker panels. */
 public void repaint() {
   Iterator<TrackerPanel> it = marks.keySet().iterator();
   while (it.hasNext()) repaint(it.next());
 }