Examples of CRSettings


Examples of net.lenkaspace.creeper.model.CRSettings

   * Constructor
   * @param applicationName_ Name of the application that will appear on the application window
   */
  public CRController(String applicationName_) {
    //-- tell CRSettings init hasn't been completed yet
    CRSettings settings = CRSettings.getSingleton();
    settings.setIsInitDone(false);
    boolean consoleOnly = settings.getIsConsoleOnlyBuild();
   
    if (!consoleOnly) {
      mainFrame = new JFrame();
      mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      mainFrame.setTitle(applicationName_);
    }
       
    if (settings.checkSettings()) {
     
      //-- set variables
      updateDelay = settings.getMinUpdateDelay();
     
      //-- create basic parameter object
          CRParameters parameters = CRParameters.getSingleton();
          parameters.setController(this);
          if (parameters.numOfTrials < 0) {
            parameters.numOfTrials = 1;
          }
     
          //-- create UI
      if (!consoleOnly) {
            try {
              mainFrame.getContentPane().setBounds(0, 0, settings.getWindowSize().width, settings.getWindowSize().height);
              mainFrame.setSize(settings.getWindowSize().width, settings.getWindowSize().height);
              mainFrame.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));       
             
            //--- create renderer:
            renderer = new CRRenderer(this);
            mainFrame.add("West", renderer);
            
              //--- create controls panel on the right:
            controlPanelPlaceHolder = CRComponentFactory.createFlowLayoutJPanel(485, 620, mainFrame);
            } catch (Exception e) {
                System.err.println("Cannot initialise GUI");
            }
          
            //-- create reference to basic image provider
            imageProvider = new CRImageProvider();
            this.setImageProvider(imageProvider);
      }
         
          //-- create reference to report controller and register self with it
          reportController = new CRReportController(this);
         
          //-- create basic world and set it to renderer
          world = new CRWorld(0, new CRVector3d(700,650,0), this);
          if (renderer != null) {
            renderer.setWorld(world);
          }
         
          if (!consoleOnly) {
            //-- create control panel
            createDefaultControlPanel();
            //-- show the ui
            mainFrame.setVisible(true);
          }
         
          //-- tell settings that init is done
          settings.setIsInitDone(true);
   
  }
View Full Code Here

Examples of net.lenkaspace.creeper.model.CRSettings

    /**
     * Starts timers
     */
    public void startTime() {
     
      CRSettings settings = CRSettings.getSingleton();
     
      //-- create render thread
      if (renderTimer != null && settings.isTimeRunning()) {
        renderTimer.stop();
      }
      renderTimer = new Timer(settings.getRenderingDelay(), this.renderer);
      renderTimer.setInitialDelay(0);
      renderTimer.start();
     
      //-- create output thread
      if (outputTimer != null && CRSettings.getSingleton().isTimeRunning()) {
        outputTimer.stop();
      }
      if (!CRSettings.getSingleton().getIsConsoleOnlyBuild()) {
        outputTimer = new Timer(settings.getOutputDelay(), CROutputPopup.getSingleton());
        outputTimer.setInitialDelay(0);
        outputTimer.start();
      }
     
      settings.setIsTimeRunning(true);
    }
View Full Code Here

Examples of net.lenkaspace.creeper.model.CRSettings

    /**
     * Sets update timer delay to a value from interval specified by CRSettings's maxUpdateDelay and minUpdateDelay
     * @param value_ <0;1> where 0 = slowest
     */
    public void setTimeSpeed(double value_) {
      CRSettings settings = CRSettings.getSingleton();
      updateDelay = (settings.getMaxUpdateDelay() - (int)((settings.getMaxUpdateDelay()-settings.getMinUpdateDelay())*value_));
    }
View Full Code Here

Examples of net.lenkaspace.creeper.model.CRSettings

   * Create a window of the report. Optionally show it on screen as well
   * @param printToFileName_ String file name to print report into, without extension
   * @param show_ boolean if false, report is hidden immediately after printed
   */
  public void createSelf(String printToFileName_, boolean show_) {
    CRSettings settings = CRSettings.getSingleton();
   
    if (!settings.getIsConsoleOnlyBuild()) {
      //-- create frame
      if (baseFrame == null) {
        baseFrame = new JFrame(title)
        baseFrame.setSize((int)size.width,(int)size.height);
        baseFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        baseFrame.setLocation((int)(settings.getWindowSize().width/2 - size.width/2),(int)(settings.getWindowSize().height/2- size.height/2));
        baseFrame.setEnabled(true);
        baseFrame.setFocusable(true);
        baseFrame.setResizable(false);
       
      }
View Full Code Here

Examples of net.lenkaspace.creeper.model.CRSettings

      public void actionPerformed(ActionEvent e) {
        helpPopup.open();
      }
    }, helpPanel)

    CRSettings settings = CRSettings.getSingleton();
   
    //---- create report folder panel if this is not build for online applet
    reportFolderPanel = CRComponentFactory.createFlowLayoutJPanel(-1, 80, this);
    CRComponentFactory.createJLabel("Saved reports folder name: ", reportFolderPanel);
    DateFormat dateFormat = new SimpleDateFormat("yyMMdd-HHmmss");
    Date date = new Date();
    reportFolderField = CRComponentFactory.createJTextField("reports" + dateFormat.format(date) , this.getSize().width - 190, reportFolderPanel);
   
    CRComponentFactory.createFlowLayoutJPanel(-1, 10, reportFolderPanel);
   
    CRComponentFactory.createJCheckBox("Save graphic reports ", settings.getShouldPrintGraphicReports(), new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        CRSettings.getSingleton().setShouldPrintGraphicReports(((JCheckBox)e.getSource()).isSelected())
      }
    }, reportFolderPanel);
    CRComponentFactory.createJCheckBox("Save text reports       ", settings.getShouldPrintTextReports(), new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        CRSettings.getSingleton().setShouldPrintTextReports(((JCheckBox)e.getSource()).isSelected())
      }
    }, reportFolderPanel);
    CRComponentFactory.createJCheckBox("Quit when done", settings.getShouldQuitAfterDone(), new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        CRSettings.getSingleton().setShouldQuitAfterDone(((JCheckBox)e.getSource()).isSelected())
      }
    }, reportFolderPanel);
   
      //---- create panel with selection of world types
    if (controller.getWorld().getHasScenarios()) {
      scenarioPanel = CRComponentFactory.createFlowLayoutJPanel(-1, 40, this);
      CRComponentFactory.createJLabel("Scenario: ", scenarioPanel);
      scenarioComboBox = CRComponentFactory.createJComboBox(300, controller.getWorld().getScenariosAsArray(), 0, null, scenarioPanel);
    }
   
    //---- create panel above the start simulation panel
    preStartSimulationPanel = CRComponentFactory.createFlowLayoutJPanel(-1, 0, this);
   
    //---- create the start simulation button in a separate panel
    startSimulationPanel = CRComponentFactory.createFlowLayoutJPanel(-1, 40, this);
   
    //-- number of runs
    CRComponentFactory.createJLabel("Number of runs: ", startSimulationPanel);
    numberOfRunsField = CRComponentFactory.createJTextField("1", 50, startSimulationPanel);
   
    //-- trial duration
    CRComponentFactory.createJLabel("  Trial duration: ", startSimulationPanel);
    trialDurationField = CRComponentFactory.createJTextField("120", 50, startSimulationPanel);
   
    //-- start button
    CRComponentFactory.createJLabel("     ", startSimulationPanel);
    CRComponentFactory.createJButton("Start simulation", new ActionListener() {  public void actionPerformed(ActionEvent e) {
                onStartSimulationClicked(e);
        }}, startSimulationPanel);
   
    //---- create divider
    CRComponentFactory.createDividerJPanel(-1, 5, this);
           
    //---- create time settings
    timeSettingsPanel = CRComponentFactory.createFlowLayoutJPanel(-1, 60, this);
   
    //-- play / pause
    timeStartPauseButton = CRComponentFactory.createJButton(">", new ActionListener() {  public void actionPerformed(ActionEvent e) {
      CRSettings settings = CRSettings.getSingleton();
      if (settings.isTimeRunning()) {
        //---- pause clicked:
        controller.stopTime();
        settings.setIsTimeRunning(false);
        onTimePaused()
      } else {
        //----- play clicked: 
        controller.startTime();
        settings.setIsTimeRunning(true);
        onTimeStarted();
      }
    }}, timeSettingsPanel);
    timeStartPauseButton.setEnabled(false);
   
    CRComponentFactory.createJLabel("   Time speed:", timeSettingsPanel);
   
    //-- slider
    timeSpeedSlider = CRComponentFactory.createJSlider(this.getSize().width - 170, 0, 100, settings.getInitialTimeSpeed(), new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (CRSettings.getSingleton().isTimeRunning()) {
              controller.setTimeSpeed(timeSpeedSlider.getValue()/100.0);
            }
          }
View Full Code Here

Examples of net.lenkaspace.creeper.model.CRSettings

  public CRTextPopup(String title_, Dimension size_) {
    size = size_;
    title = title_;
    isOpen = false;
    outputText = "";
    CRSettings settings = CRSettings.getSingleton();
    location = new Point((int)(settings.getWindowSize().width/2 - size.width/2),(int)(settings.getWindowSize().height/2- size.height/2));
   
    baseFrame = new JFrame(title);
    baseFrame.setSize(size.width,size.height);
    baseFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    baseFrame.setLocation(location);     
View Full Code Here

Examples of net.lenkaspace.creeper.model.CRSettings

      Dimension size = getSize();
      //-------- draw background
       g.setColor(Color.WHITE);  
       g.fillRect(0, 0, size.width, size.height);
 
      CRSettings settings = CRSettings.getSingleton();
      if ((settings.getIsInitDone() && settings.getShouldDraw() && settings.isTimeRunning()) || shouldOverrideNoPaint) {
        if (shouldOverrideNoPaint) {
          //make sure only paints once..
          shouldOverrideNoPaint = false;
        }
        //-- draw all renderable objects in the world
View Full Code Here

Examples of net.lenkaspace.creeper.model.CRSettings

   * Save self to an image if allowed
   * @param trialNumber_ int ending trial number
   * @param runNumber_ int current run number
   */
  public void onTrialEnd(int trialNumber_, int runNumber_) {
    CRSettings settings = CRSettings.getSingleton();
    if (settings.getShouldPrintGraphicReports()) {
      createSelf(reportController.getCurrentFilePath() + "_" + this.getFileName(), false);
    }
    if (CRSettings.getSingleton().getShouldPrintTextReports()) {
          createSelfAsText(reportController.getCurrentFilePath() + "_" + this.getFileName());
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.