當前位置: 首頁>>代碼示例>>Java>>正文


Java GUIUtils類代碼示例

本文整理匯總了Java中org.opensourcephysics.display.GUIUtils的典型用法代碼示例。如果您正苦於以下問題:Java GUIUtils類的具體用法?Java GUIUtils怎麽用?Java GUIUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GUIUtils類屬於org.opensourcephysics.display包,在下文中一共展示了GUIUtils類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadObject

import org.opensourcephysics.display.GUIUtils; //導入依賴的package包/類
/**
 * Loads data from the control into the LJParticlesApp model.
 *
 * @param element XMLControl
 * @param obj Object
 * @return Object
 */
public Object loadObject(XMLControl control, Object obj) {
  // GUI has been loaded with the saved values; now restore the LJ state
  LJParticlesDemonApp model = (LJParticlesDemonApp) obj;
  model.initialize(); // reads values from the GUI into the LJ model
  model.md.initialConfiguration = control.getString("initial_configuration");
  model.md.state = (double[]) control.getObject("state");
  if(model.md.state!=null) {
    int N = (model.md.state.length-1)/4;
    model.md.ax = new double[N];
    model.md.ay = new double[N];
    model.md.computeAcceleration();
    model.md.resetAverages();
  }
  GUIUtils.clearDrawingFrameData(false); // clears old data from the plot frames
  return obj;
}
 
開發者ID:OpenSourcePhysics,項目名稱:STP,代碼行數:24,代碼來源:LJParticlesDemonLoader.java

示例2: open

import org.opensourcephysics.display.GUIUtils; //導入依賴的package包/類
/**
 * Opens a file using a file chooser.
 */
protected void open() {
  JFileChooser fileChooser = OSPRuntime.getChooser();
  for (javax.swing.filechooser.FileFilter filter: fileChooser.getChoosableFileFilters()) {
  	fileChooser.removeChoosableFileFilter(filter);
  }
  fileChooser.addChoosableFileFilter(filesAndFoldersFilter);
  fileChooser.addChoosableFileFilter(Launcher.getXMLFilter());
  fileChooser.setAcceptAllFileFilterUsed(false);
  fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
  fileChooser.setFileFilter(filesAndFoldersFilter);
  File file = GUIUtils.showOpenDialog(this);
  // reset chooser to original state    
  fileChooser.removeChoosableFileFilter(filesAndFoldersFilter);
  fileChooser.removeChoosableFileFilter(Launcher.getXMLFilter());
  fileChooser.setAcceptAllFileFilterUsed(true);
  fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
if (file!=null) {
	open(file.getAbsolutePath());
}
}
 
開發者ID:OpenSourcePhysics,項目名稱:osp,代碼行數:24,代碼來源:LibraryBrowser.java

示例3: getChooserSavePath

import org.opensourcephysics.display.GUIUtils; //導入依賴的package包/類
/**
 * Uses a file chooser to define a path to which a library or resource file (xml) can be saved.
 * This adds the extension ".xml", if none, and checks for duplicates.
 * @param chooserTitle the title of the file chooser
 * @return the path, or null if canceled by the user
 */
protected String getChooserSavePath(String chooserTitle) {
File file = GUIUtils.showSaveDialog(this, chooserTitle);
if (file ==null) return null;
String path = file.getAbsolutePath();
  String extension = XML.getExtension(path);
  if (extension==null) {
  	path = XML.stripExtension(path)+".xml"; //$NON-NLS-1$
  	file = new File(path);
    if(file.exists()) {
      int response = JOptionPane.showConfirmDialog(this, 
      		ToolsRes.getString("Tool.Dialog.ReplaceFile.Message") //$NON-NLS-1$
      		+" "+file.getName()+"?", //$NON-NLS-1$ //$NON-NLS-2$
      		ToolsRes.getString("Tool.Dialog.ReplaceFile.Title"), //$NON-NLS-1$
          JOptionPane.YES_NO_CANCEL_OPTION);
      if(response!=JOptionPane.YES_OPTION) {
        return null;
      }
    }
  }
  return path;  	
}
 
開發者ID:OpenSourcePhysics,項目名稱:osp,代碼行數:28,代碼來源:LibraryBrowser.java

示例4: run

import org.opensourcephysics.display.GUIUtils; //導入依賴的package包/類
/**
 * Implementation of Runnable interface.  DO NOT access this method directly.
 */
public void run() {
  GUIUtils.setAnimatedFrameIgnoreRepaint(true); // animated frames are updated by this thread so no need to repaint
  long sleepTime = delayTime;
  while(animationThread==Thread.currentThread()) {
    long currentTime = System.currentTimeMillis();
    for(int i = 0; i<stepsPerDisplay; i++) {
      doStep();
      stepCounter++;
      if(animationThread!=Thread.currentThread()) {
        break;        // check for stop condition
      }
      Thread.yield(); // give other threads a chance to run if needed
    }
    org.opensourcephysics.display.GUIUtils.renderAnimatedFrames();
    // adjust the sleep time to try and achieve a constant animation rate
    // some VMs will hang if sleep time is less than 10
    sleepTime = Math.max(10, delayTime-(System.currentTimeMillis()-currentTime));
    try {
      Thread.sleep(sleepTime);
    } catch(InterruptedException ie) {}
  }
  GUIUtils.setAnimatedFrameIgnoreRepaint(false); // animated frames are updated by this thread so no need to repaint
}
 
開發者ID:OpenSourcePhysics,項目名稱:osp,代碼行數:27,代碼來源:AbstractSimulation.java

示例5: resetBtnActionPerformed

import org.opensourcephysics.display.GUIUtils; //導入依賴的package包/類
/**
 * Method resetBtnActionPerformed
 *
 * @param e
 */
void resetBtnActionPerformed(ActionEvent e) {
  if(e.getActionCommand().equals(resetText)) {
    GUIUtils.clearDrawingFrameData(true);
    if(model==null) {
      println("This AnimationControl's model is null."); //$NON-NLS-1$
      return;
    }
    ((Animation) model).resetAnimation();
    if(xmlDefault!=null) {
      xmlDefault.loadObject(getOSPApp(), true, true);
    }
    table.refresh();
  } else {                                               // action command = New
    startBtn.setText(initText);
    startBtn.setToolTipText(initToolTipText);
    resetBtn.setText(resetText);
    resetBtn.setToolTipText(resetToolTipText);
    stepBtn.setEnabled(false);
    readItem.setEnabled(true);
    table.setEnabled(true);
    messageTextArea.setEditable(true);
    setCustomButtonsEnabled(true);
  }
}
 
開發者ID:OpenSourcePhysics,項目名稱:osp,代碼行數:30,代碼來源:AnimationControl.java

示例6: clearDefaultXML

import org.opensourcephysics.display.GUIUtils; //導入依賴的package包/類
/**
 * Clears the current XML default.
 */
public void clearDefaultXML() {
  if((xmlDefault==null)||(model==null)) {
    return;
  }
  xmlDefault = null;
  clearItem.setEnabled(false);
  if(model instanceof Calculation) {
    ((Calculation) model).resetCalculation();
    ((Calculation) model).calculate();
  } else if(model instanceof Animation) {
    ((Animation) model).stopAnimation();
    ((Animation) model).resetAnimation();
    ((Animation) model).initializeAnimation();
  }
  GUIUtils.repaintOSPFrames();
}
 
開發者ID:OpenSourcePhysics,項目名稱:osp,代碼行數:20,代碼來源:EjsControlFrame.java

示例7: loadObject

import org.opensourcephysics.display.GUIUtils; //導入依賴的package包/類
/**
 * Loads data from the control into the LJParticlesApp model.
 *
 * @param element XMLControl
 * @param obj Object
 * @return Object
 */
public Object loadObject(XMLControl control, Object obj) {
  // GUI has been loaded with the saved values; now restore the LJ state
  WidomApp model = (WidomApp) obj;
  model.initialize(); // reads values from the GUI into the LJ model
  model.mc.x = (double[]) control.getObject("x");
  model.mc.y = (double[]) control.getObject("y");
  //    int N = model.mc.x.length;
  model.mc.resetAverages();
  GUIUtils.clearDrawingFrameData(false); // clears old data from the plot frames
  return obj;
}
 
開發者ID:OpenSourcePhysics,項目名稱:STP,代碼行數:19,代碼來源:WidomLoader.java

示例8: switchGUI

import org.opensourcephysics.display.GUIUtils; //導入依賴的package包/類
/**
 * Switch to the App user interface.
 */
public void switchGUI() {
 stopSimulation();
  Runnable runner = new Runnable() {
    public synchronized void run() {
      OSPRuntime.disableAllDrawing = true;
      OSPFrame mainFrame = getMainFrame();
      XMLControlElement xml = new XMLControlElement(getOSPApp());
      WindowListener[] listeners = mainFrame.getWindowListeners();
      int closeOperation = mainFrame.getDefaultCloseOperation();
      mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      mainFrame.setKeepHidden(true);
      mainFrame.dispose();
      MultipleCoinTossApp app = new MultipleCoinTossApp();
      SimulationControl c = SimulationControl.createApp(app);
      c.setDefaultCloseOperation(closeOperation);
      for(int i = 0, n = listeners.length; i<n; i++) {
        if(listeners[i].getClass().getName().equals("org.opensourcephysics.tools.Launcher$FrameCloser")) {
          c.addWindowListener(listeners[i]);
        }
      }
      c.loadXML(xml, true);
      c.setValue("model", null);
      app.customize();
      app.initialize();
      System.gc();
      OSPRuntime.disableAllDrawing = false;
      GUIUtils.showDrawingAndTableFrames();
    }

  };
  Thread t = new Thread(runner);
  t.start();
}
 
開發者ID:OpenSourcePhysics,項目名稱:STP,代碼行數:37,代碼來源:MultipleCoinTossWRApp.java

示例9: switchGUI

import org.opensourcephysics.display.GUIUtils; //導入依賴的package包/類
/**
  * Switch to the WRApp user interface.
  */
 public void switchGUI() {
stopSimulation();
   Runnable runner = new Runnable() {
     public synchronized void run() {
       OSPRuntime.disableAllDrawing = true;
       OSPFrame mainFrame = getMainFrame();
       XMLControlElement xml = new XMLControlElement(getOSPApp());
       WindowListener[] listeners = mainFrame.getWindowListeners();
       int closeOperation = mainFrame.getDefaultCloseOperation();
       mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
       mainFrame.setKeepHidden(true);
       mainFrame.dispose();
       MultipleCoinTossWRApp app = new MultipleCoinTossWRApp();
       MultipleCoinTossWRAppControl c = new MultipleCoinTossWRAppControl(app, app.histogramFrame, null);
       c.getMainFrame().setDefaultCloseOperation(closeOperation);
       for(int i = 0, n = listeners.length; i<n; i++) {
         if(listeners[i].getClass().getName().equals("org.opensourcephysics.tools.Launcher$FrameCloser")) {
           c.getMainFrame().addWindowListener(listeners[i]);
         }
       }
       c.loadXML(xml, true);
       app.customize();
       c.resetSimulation();
       System.gc();
       OSPRuntime.disableAllDrawing = false;
       GUIUtils.showDrawingAndTableFrames();
     }

   };
   Thread t = new Thread(runner);
   t.start();
 }
 
開發者ID:OpenSourcePhysics,項目名稱:STP,代碼行數:36,代碼來源:MultipleCoinTossApp.java

示例10: resetData

import org.opensourcephysics.display.GUIUtils; //導入依賴的package包/類
/**
   * Resets the LJ model and the data graphs.
   *
   * This method is invoked using a custom button.
   */
  public void resetData() {
    GUIUtils.clearDrawingFrameData(false); // clears old data from the plot frames
    gr.reset();
    mc.steps = 0;
    mc.mcs = 0;
    mc.totalPotentialEnergyAccumulator = 0;
    mc.totalPotentialEnergyAccumulator2 = 0;
    mc.virialAccumulator = 0;
}
 
開發者ID:OpenSourcePhysics,項目名稱:STP,代碼行數:15,代碼來源:LJMCApp.java

示例11: switchGUI

import org.opensourcephysics.display.GUIUtils; //導入依賴的package包/類
/**
 * Switch to the WRApp user interface.
 */
public void switchGUI() {
  stopSimulation();
  Runnable runner = new Runnable() {
    public synchronized void run() {
      OSPRuntime.disableAllDrawing = true;
      OSPFrame mainFrame = getMainFrame();
      XMLControlElement xml = new XMLControlElement(getOSPApp());
      WindowListener[] listeners = mainFrame.getWindowListeners();
      int closeOperation = mainFrame.getDefaultCloseOperation();
      mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      mainFrame.setKeepHidden(true);
      mainFrame.dispose();
      LJfluidWRApp app = new LJfluidWRApp();
      LJfluidControl c = new LJfluidControl(app, app.displayFrame, null);
      c.getMainFrame().setDefaultCloseOperation(closeOperation);
      for(int i = 0, n = listeners.length; i<n; i++) {
        if(listeners[i].getClass().getName().equals("org.opensourcephysics.tools.Launcher$FrameCloser")) {
          c.getMainFrame().addWindowListener(listeners[i]);
        }
      }
      c.loadXML(xml, true);
      app.customize();
      c.resetSimulation();
      System.gc();
      OSPRuntime.disableAllDrawing = false;
      GUIUtils.showDrawingAndTableFrames();
    }

  };
  Thread t = new Thread(runner);
  t.start();
}
 
開發者ID:OpenSourcePhysics,項目名稱:STP,代碼行數:36,代碼來源:LJfluidApp.java

示例12: switchGUI

import org.opensourcephysics.display.GUIUtils; //導入依賴的package包/類
/**
  * Switch to the App user interface.
  */
 public void switchGUI() {
stopSimulation();
   Runnable runner = new Runnable() {
     public synchronized void run() {
       OSPRuntime.disableAllDrawing = true;
       OSPFrame mainFrame = getMainFrame();
       XMLControlElement xml = new XMLControlElement(getOSPApp());
       WindowListener[] listeners = mainFrame.getWindowListeners();
       int closeOperation = mainFrame.getDefaultCloseOperation();
       mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
       mainFrame.setKeepHidden(true);
       mainFrame.dispose();
       LJfluidApp app = new LJfluidApp();
       SimulationControl c = SimulationControl.createApp(app);
       c.setDefaultCloseOperation(closeOperation);
       for(int i = 0, n = listeners.length; i<n; i++) {
         if(listeners[i].getClass().getName().equals("org.opensourcephysics.tools.Launcher$FrameCloser")) {
           c.addWindowListener(listeners[i]);
         }
       }
       c.loadXML(xml, true);
       app.customize();
       System.gc();
       OSPRuntime.disableAllDrawing = false;
       GUIUtils.showDrawingAndTableFrames();
     }

   };
   Thread t = new Thread(runner);
   t.start();
 }
 
開發者ID:OpenSourcePhysics,項目名稱:STP,代碼行數:35,代碼來源:LJfluidWRApp.java

示例13: switchGUI

import org.opensourcephysics.display.GUIUtils; //導入依賴的package包/類
/**
  * Switch to the App user interface.
  */
 public void switchGUI() {
stopSimulation();
   Runnable runner = new Runnable() {
     public synchronized void run() {
       OSPRuntime.disableAllDrawing = true;
       OSPFrame mainFrame = getMainFrame();
       XMLControlElement xml = new XMLControlElement(getOSPApp());
       WindowListener[] listeners = mainFrame.getWindowListeners();
       int closeOperation = mainFrame.getDefaultCloseOperation();
       mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
       mainFrame.setKeepHidden(true);
       mainFrame.dispose();
       DemonApp app = new DemonApp();
       SimulationControl c = SimulationControl.createApp(app);
       c.setDefaultCloseOperation(closeOperation);
       c.addButton("zeroAverages", "Zero averages");
       for(int i = 0, n = listeners.length; i<n; i++) {
         if(listeners[i].getClass().getName().equals("org.opensourcephysics.tools.Launcher$FrameCloser")) {
           c.addWindowListener(listeners[i]);
         }
       }
       c.loadXML(xml, true);
       c.setValue("model", null);
       app.customize();
       app.initialize();
       System.gc();
       OSPRuntime.disableAllDrawing = false;
       GUIUtils.showDrawingAndTableFrames();
     }

   };
   Thread t = new Thread(runner);
   t.start();
 }
 
開發者ID:OpenSourcePhysics,項目名稱:STP,代碼行數:38,代碼來源:DemonWRApp.java

示例14: setParameter

import org.opensourcephysics.display.GUIUtils; //導入依賴的package包/類
public void setParameter() {
  zeroAverages();
  histogramFrame.clearData();
  vhistogramFrame.clearData();
  initialize();
  GUIUtils.repaintOSPFrames();
}
 
開發者ID:OpenSourcePhysics,項目名稱:STP,代碼行數:8,代碼來源:DemonWRApp.java

示例15: switchGUI

import org.opensourcephysics.display.GUIUtils; //導入依賴的package包/類
/**
 * Switch to the WRApp user interface.
 */
public void switchGUI() {
  stopSimulation();
  Runnable runner = new Runnable() {
    public synchronized void run() {
      OSPRuntime.disableAllDrawing = true;
      OSPFrame mainFrame = getMainFrame();
      XMLControlElement xml = new XMLControlElement(getOSPApp());
      WindowListener[] listeners = mainFrame.getWindowListeners();
      int closeOperation = mainFrame.getDefaultCloseOperation();
      mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      mainFrame.setKeepHidden(true);
      mainFrame.dispose();
      LJParticlesDemonWRApp app = new LJParticlesDemonWRApp();
      LJParticlesDemonAppControl c = new LJParticlesDemonAppControl(app, app.display, null);
      c.getMainFrame().setDefaultCloseOperation(closeOperation);
      for(int i = 0, n = listeners.length; i<n; i++) {
        if(listeners[i].getClass().getName().equals("org.opensourcephysics.tools.Launcher$FrameCloser")) {
          c.getMainFrame().addWindowListener(listeners[i]);
        }
      }
      c.loadXML(xml, true);
      app.customize();
      c.resetSimulation();
      System.gc();
      OSPRuntime.disableAllDrawing = false;
      GUIUtils.showDrawingAndTableFrames();
    }

  };
  Thread t = new Thread(runner);
  t.start();
}
 
開發者ID:OpenSourcePhysics,項目名稱:STP,代碼行數:36,代碼來源:LJParticlesDemonApp.java


注:本文中的org.opensourcephysics.display.GUIUtils類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。