コード例 #1
0
 /**
  * Constructor EjsSimulationControl
  *
  * @param model
  * @param frame
  * @param args
  */
 public EjsSimulationControl(Simulation model, DrawingFrame frame, String[] args) {
   super(
       model,
       "name=controlFrame;title=OSP Simulation;location=400,0;layout=border;exit=true; visible=false"); //$NON-NLS-1$
   this.model = model;
   addTarget("control", this); // $NON-NLS-1$
   addTarget("model", model); // $NON-NLS-1$
   if (frame != null) {
     getMainFrame().setAnimated(frame.isAnimated());
     getMainFrame().setAutoclear(frame.isAutoclear());
     getMainFrame().setBackground(frame.getBackground());
     getMainFrame().setTitle(frame.getTitle());
     drawingPanel = frame.getDrawingPanel();
     addObject(
         drawingPanel,
         "Panel",
         "name=drawingPanel; parent=controlFrame; position=center"); //$NON-NLS-1$ //$NON-NLS-2$
     frame.setDrawingPanel(null);
     frame.dispose();
   }
   add(
       "Panel",
       "name=controlPanel; parent=controlFrame; layout=border; position=south"); //$NON-NLS-1$
                                                                                 // //$NON-NLS-2$
   add(
       "Panel",
       "name=buttonPanel;position=west;parent=controlPanel;layout=flow"); //$NON-NLS-1$
                                                                          // //$NON-NLS-2$
   // add("Button", "parent=buttonPanel; text=Start;
   // action=control.runSimulation();name=runButton");
   // add("Button", "parent=buttonPanel; text=Step; action=control.stepAnimation()");
   // add("Button", "parent=buttonPanel; text=Reset; action=control.resetAnimation()");
   add(
       "Button",
       "parent=buttonPanel;tooltip=Start and stop simulation;image=/org/opensourcephysics/resources/controls/images/play.gif; action=control.runSimulation();name=runButton"); //$NON-NLS-1$ //$NON-NLS-2$
   add(
       "Button",
       "parent=buttonPanel;tooltip=Step simulation;image=/org/opensourcephysics/resources/controls/images/step.gif; action=control.stepSimulation();name=stepButton"); //$NON-NLS-1$ //$NON-NLS-2$
   add(
       "Button",
       "parent=buttonPanel; tooltip=Reset simulation;image=/org/opensourcephysics/resources/controls/images/reset.gif; action=control.resetSimulation();name=resetButton"); //$NON-NLS-1$ //$NON-NLS-2$
   controlPanel = ((JPanel) getElement("controlPanel").getComponent()); // $NON-NLS-1$
   controlPanel.setBorder(new EtchedBorder());
   customize();
   model.setControl(this);
   initialize();
   loadXML(args);
   java.awt.Container cont =
       (java.awt.Container) getElement("controlFrame").getComponent(); // $NON-NLS-1$
   if (!org.opensourcephysics.display.OSPRuntime.appletMode) {
     cont.setVisible(true);
   }
   if (model instanceof PropertyChangeListener) {
     addPropertyChangeListener((PropertyChangeListener) model);
   }
   getMainFrame().pack(); // make sure everything is showing
   getMainFrame().doLayout();
   GUIUtils.showDrawingAndTableFrames();
 }