/* * Copyright (c) 2009 The Jackson Laboratory * * This software was developed by Gary Churchill's Lab at The Jackson * Laboratory (see http://research.jax.org/faculty/churchill). * * This is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software. If not, see <http://www.gnu.org/licenses/>. */ package org.jax.r.rintegration.gui; import javax.swing.SpinnerNumberModel; import org.jax.util.TypeSafeSystemProperties; import org.jax.util.TypeSafeSystemProperties.OsFamily; /** * A panel for configuring the R and java memory limits * @author <A HREF="mailto:keith.sheppard@jax.org">Keith Sheppard</A> */ public class MemoryConfigurationPanel extends javax.swing.JPanel { /** * every {@link java.io.Serializable} is supposed to have one of these */ private static final long serialVersionUID = -3809762180268997705L; private static final int INITIAL_MEMORY_ALLOCATION = 1024; private static final int MEMORY_INCREMENT_SIZE = 128; private final SpinnerNumberModel rMemoryLimitSpinnerNumberModel; private final SpinnerNumberModel javaMemoryLimitSpinnerNumberModel; /** * Constructor */ public MemoryConfigurationPanel() { this(INITIAL_MEMORY_ALLOCATION, INITIAL_MEMORY_ALLOCATION); } /** * Constructor * @param initialRMemoryLimitMegabytes * the initial limit for R in megabytes * @param initialJavaMemoryLimitMegabytes * the initial limit for java in megabytes */ public MemoryConfigurationPanel( int initialRMemoryLimitMegabytes, int initialJavaMemoryLimitMegabytes) { this.initComponents(); this.rMemoryLimitSpinnerNumberModel = new SpinnerNumberModel( initialRMemoryLimitMegabytes, MEMORY_INCREMENT_SIZE, Integer.MAX_VALUE, MEMORY_INCREMENT_SIZE); this.javaMemoryLimitSpinnerNumberModel = new SpinnerNumberModel( initialJavaMemoryLimitMegabytes, MEMORY_INCREMENT_SIZE, Integer.MAX_VALUE, MEMORY_INCREMENT_SIZE); this.rMemoryLimitSpinner.setModel(this.rMemoryLimitSpinnerNumberModel); this.javaMemoryLimitSpinner.setModel( this.javaMemoryLimitSpinnerNumberModel); if(TypeSafeSystemProperties.getOsFamily() != OsFamily.WINDOWS_OS_FAMILY) { this.rMemoryLimitLabel.setEnabled(false); this.rMemoryLimitSpinner.setEnabled(false); this.rMegabytesLabel.setEnabled(false); } } /** * Getter for the r memory limit in megabytes * @return * the R memory limit */ public int getRMemoryLimitMegabytes() { return this.rMemoryLimitSpinnerNumberModel.getNumber().intValue(); } /** * Getter for the java memory limit in MB * @return * the java memory limit */ public int getJavaMemoryLimitMegabytes() { return this.javaMemoryLimitSpinnerNumberModel.getNumber().intValue(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("all") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { javaMemoryLimitLabel = new javax.swing.JLabel(); javaMemoryLimitSpinner = new javax.swing.JSpinner(); javaMegabytesLabel = new javax.swing.JLabel(); rMemoryLimitLabel = new javax.swing.JLabel(); rMemoryLimitSpinner = new javax.swing.JSpinner(); rMegabytesLabel = new javax.swing.JLabel(); javaMemoryLimitLabel.setText("Java Memory Limit:"); javaMegabytesLabel.setText("Megabytes"); rMemoryLimitLabel.setText("R Memory Limit (Windows Only)"); rMegabytesLabel.setText("Megabytes"); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(javaMemoryLimitLabel) .add(rMemoryLimitLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(rMemoryLimitSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 82, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(rMegabytesLabel)) .add(layout.createSequentialGroup() .add(javaMemoryLimitSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 82, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(javaMegabytesLabel))) .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(javaMemoryLimitLabel) .add(javaMemoryLimitSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(javaMegabytesLabel)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(rMemoryLimitLabel) .add(rMemoryLimitSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(rMegabytesLabel)) .addContainerGap(45, Short.MAX_VALUE)) ); }// </editor-fold>//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel javaMegabytesLabel; private javax.swing.JLabel javaMemoryLimitLabel; private javax.swing.JSpinner javaMemoryLimitSpinner; private javax.swing.JLabel rMegabytesLabel; private javax.swing.JLabel rMemoryLimitLabel; private javax.swing.JSpinner rMemoryLimitSpinner; // End of variables declaration//GEN-END:variables }