Example usage for java.awt Checkbox getState

List of usage examples for java.awt Checkbox getState

Introduction

In this page you can find the example usage for java.awt Checkbox getState.

Prototype

public boolean getState() 

Source Link

Document

Determines whether this check box is in the "on" or "off" state.

Usage

From source file:Sampler.java

private void createUI() {
    setFont(new Font("Serif", Font.PLAIN, 12));
    setLayout(new BorderLayout());
    // Set our location to the left of the image frame.
    setSize(200, 350);//from   ww w  . j  a  v  a 2  s . com
    Point pt = mImageFrame.getLocation();
    setLocation(pt.x - getSize().width, pt.y);

    final Checkbox accumulateCheckbox = new Checkbox("Accumulate", false);
    final Label statusLabel = new Label("");

    // Make a sorted list of the operators.
    Enumeration e = mOps.keys();
    Vector names = new Vector();
    while (e.hasMoreElements())
        names.addElement(e.nextElement());
    Collections.sort(names);
    final java.awt.List list = new java.awt.List();
    for (int i = 0; i < names.size(); i++)
        list.add((String) names.elementAt(i));
    add(list, BorderLayout.CENTER);

    // When an item is selected, do the corresponding transformation.
    list.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ie) {
            if (ie.getStateChange() != ItemEvent.SELECTED)
                return;
            String key = list.getSelectedItem();
            BufferedImageOp op = (BufferedImageOp) mOps.get(key);
            BufferedImage source = mSplitImageComponent.getSecondImage();
            boolean accumulate = accumulateCheckbox.getState();
            if (source == null || accumulate == false)
                source = mSplitImageComponent.getImage();
            String previous = mImageFrame.getTitle() + " + ";
            if (accumulate == false)
                previous = "";
            mImageFrame.setTitle(previous + key);
            statusLabel.setText("Performing " + key + "...");
            list.setEnabled(false);
            accumulateCheckbox.setEnabled(false);
            BufferedImage destination = op.filter(source, null);
            mSplitImageComponent.setSecondImage(destination);
            mSplitImageComponent.setSize(mSplitImageComponent.getPreferredSize());
            mImageFrame.setSize(mImageFrame.getPreferredSize());
            list.setEnabled(true);
            accumulateCheckbox.setEnabled(true);
            statusLabel.setText("Performing " + key + "...done.");
        }
    });

    Button loadButton = new Button("Load...");
    loadButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            FileDialog fd = new FileDialog(Sampler.this);
            fd.show();
            if (fd.getFile() == null)
                return;
            String path = fd.getDirectory() + fd.getFile();
            mSplitImageComponent.setImage(path);
            mSplitImageComponent.setSecondImage(null);
            //            Utilities.sizeContainerToComponent(mImageFrame,
            //               mSplitImageComponent);
            mImageFrame.validate();
            mImageFrame.repaint();
        }
    });

    Panel bottom = new Panel(new GridLayout(2, 1));
    Panel topBottom = new Panel();
    topBottom.add(accumulateCheckbox);
    topBottom.add(loadButton);
    bottom.add(topBottom);
    bottom.add(statusLabel);
    add(bottom, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            mImageFrame.dispose();
            dispose();
            System.exit(0);
        }
    });
}

From source file:mesquite.zephyr.lib.GarliRunner.java

public boolean queryOptions() {
    if (!okToInteractWithUser(CAN_PROCEED_ANYWAY, "Querying Options")) // Debugg.println needs to check that options set well enough to proceed anyway

        return true;

    boolean closeWizard = false;

    if ((MesquiteTrunk.isMacOSXBeforeSnowLeopard()) && MesquiteDialog.currentWizard == null) {
        CommandRecord cRec = null;//w  ww  .  j a v  a 2  s  .c o m
        cRec = MesquiteThread.getCurrentCommandRecordDefIfNull(null);
        if (cRec != null) {
            cRec.requestEstablishWizard(true);
            closeWizard = true;
        }
    }

    MesquiteInteger buttonPressed = new MesquiteInteger(1);
    ExtensibleDialog dialog = new ExtensibleDialog(containerOfModule(), "GARLI Options & Locations",
            buttonPressed);

    // dialog.addLabel("GARLI - Options and Locations");

    String helpString = "This module will prepare a matrix for GARLI, and ask GARLI do to an analysis.  A command-line version of GARLI must be installed. "
            + "You can ask it to do multiple searches for optimal trees, OR to do a bootstrap analysis (but not both). "
            + "Mesquite will read in the trees found by GARLI, and, for non-bootstrap analyses, also read in the value of the GARLI score (-ln L) of the tree. "
            + "You can see the GARLI score by choosing Taxa&Trees>List of Trees, and then in the List of Trees for that trees block, choose "
            + "Columns>Number for Tree>Other Choices, and then in the Other Choices dialog, choose GARLI Score.";

    dialog.appendToHelpString(helpString);
    dialog.setHelpURL(zephyrRunnerEmployer.getProgramURL());

    MesquiteTabbedPanel tabbedPanel = dialog.addMesquiteTabbedPanel();

    tabbedPanel.addPanel("GARLI Program Details", true);
    addRunnerOptions(dialog);
    dialog.addLabelSmallText(
            "This version of Zephyr tested on the following GARLI version(s): " + getTestedProgramVersions());
    if (treeInferer != null)
        treeInferer.addItemsToDialogPanel(dialog);

    tabbedPanel.addPanel("Search Replicates & Bootstrap", true);
    doBootstrapCheckbox = dialog.addCheckBox("do bootstrap analysis", doBootstrap);
    dialog.addHorizontalLine(1);
    dialog.addLabel("Bootstrap Options", Label.LEFT, false, true);
    doBootstrapCheckbox.addItemListener(this);
    IntegerField bootStrapRepsField = dialog.addIntegerField("Bootstrap Reps", bootstrapreps, 8, 0,
            MesquiteInteger.infinite);
    dialog.addHorizontalLine(1);
    dialog.addLabel("Maximum Likelihood Tree Search Options", Label.LEFT, false, true);
    IntegerField numRunsField = dialog.addIntegerField("Number of Search Replicates", numRuns, 8, 1,
            MesquiteInteger.infinite);
    onlyBestBox = dialog.addCheckBox("save only best tree", onlyBest);

    dialog.addHorizontalLine(1);
    dialog.addLabel("Constraint tree:", Label.LEFT, false, true);
    constraintButtons = dialog.addRadioButtons(
            new String[] { "No Constraint", "Positive Constraint", "Negative Constraint" }, useConstraintTree);
    constraintButtons.addItemListener(this);

    tabbedPanel.addPanel("Character Models", true);
    if (!data.hasCharacterGroups()) {
        if (partitionScheme == partitionByCharacterGroups)
            partitionScheme = noPartition;
    }
    if (!(data instanceof DNAData && ((DNAData) data).someCoding())) {
        if (partitionScheme == partitionByCodonPosition)
            partitionScheme = noPartition;
    }
    if (data instanceof ProteinData)
        charPartitionButtons = dialog
                .addRadioButtons(new String[] { "don't partition", "use character groups" }, partitionScheme);
    else
        charPartitionButtons = dialog.addRadioButtons(
                new String[] { "don't partition", "use character groups", "use codon positions" },
                partitionScheme);

    charPartitionButtons.addItemListener(this);
    if (!data.hasCharacterGroups()) {
        charPartitionButtons.setEnabled(1, false);
    }
    if (!(data instanceof DNAData && ((DNAData) data).someCoding())) {
        charPartitionButtons.setEnabled(2, false);
    }

    Checkbox linkModelsBox = dialog.addCheckBox("use same set of model parameters for all partition subsets",
            linkModels);
    Checkbox subsetSpecificRatesBox = dialog
            .addCheckBox("infer overall rate multipliers for each partition subset", subsetSpecificRates);

    dialog.addHorizontalLine(1);
    partitionChoice = dialog.addPopUpMenu("Edit model for this partition subset:",
            new String[] { "All Characters" }, 0);
    preparePartitionChoice(partitionChoice, partitionScheme);
    partitionChoice.addItemListener(this);

    if (data instanceof ProteinData)
        rateMatrixChoice = dialog.addPopUpMenu("Rate Matrix",
                new String[] { "poisson", "jones", "dayhoff", "wag", "mtmam", "mtrev" }, 2);
    else {
        rateMatrixChoice = dialog.addPopUpMenu("Rate Matrix",
                new String[] { "Equal Rates", "2-Parameter", "GTR       ", "Custom" }, 2); //corresponding to 1rate, 2rate, 6rate, custom
        customMatrix = dialog.addTextField("6rate", 20); // since 2 is selected

        // as default in
        // previous
        customMatrix.setEditable(false);
        customMatrix.setBackground(ColorDistribution.veryLightGray);
    }
    rateMatrixChoice.addItemListener(this);
    invarSitesChoice = dialog.addPopUpMenu("Invariant Sites", new String[] { "none", "Estimate Proportion" },
            1);
    rateHetChoice = dialog.addPopUpMenu("Gamma Site-to-Site Rate Model",
            new String[] { "none", "Estimate Shape Parameter" }, 1);
    numRateCatField = dialog.addIntegerField("Number of Rate Categories for Gamma", numratecats, 4, 1, 20);

    tabbedPanel.addPanel("Other options", true);
    Checkbox showConfigDetailsBox = dialog.addCheckBox("show config file", showConfigDetails);

    tabbedPanel.cleanup();
    dialog.nullifyAddPanel();

    dialog.completeAndShowDialog(true);

    if (buttonPressed.getValue() == 0) {
        boolean infererOK = (treeInferer == null || treeInferer.optionsChosen());
        if (externalProcRunner.optionsChosen() && infererOK) {
            numRuns = numRunsField.getValue();
            bootstrapreps = bootStrapRepsField.getValue();
            onlyBest = onlyBestBox.getState();
            doBootstrap = doBootstrapCheckbox.getState();
            showConfigDetails = showConfigDetailsBox.getState();
            partitionScheme = charPartitionButtons.getValue();
            useConstraintTree = constraintButtons.getValue();
            linkModels = linkModelsBox.getState();
            subsetSpecificRates = subsetSpecificRatesBox.getState();
            processRunnerOptions();

            // garliOptions = garliOptionsField.getText();

            processCharacterModels();

            storeRunnerPreferences();
        }
    }
    dialog.dispose();
    if (closeWizard)
        MesquiteDialog.closeWizard();

    return (buttonPressed.getValue() == 0);
}

From source file:mesquite.chromaseq.InterpretASNGenBank.InterpretASNGenBank.java

public boolean getExportOptions(boolean dataSelected, boolean taxaSelected) {
    MesquiteInteger buttonPressed = new MesquiteInteger(1);
    ExporterDialog exportDialog = new ExporterDialog(this, containerOfModule(),
            "Export ASN for GenBank Options", buttonPressed);
    exportDialog.appendToHelpString(//  www.  j a va2s. c  om
            "Choose the options for exporting the matrix as a ASN file prepared for submission NCBI's Sequin.");
    exportDialog.appendToHelpString(
            "<br><br><b>SeqID Suffix</b>: this will be added to each taxon name to form the unique SeqID.");
    exportDialog.appendToHelpString(
            "<br><b>Description of gene fragment</b>: this will be added to each sequence's DEFINITION.");
    exportDialog.appendToHelpString(
            "<br><b>Text before VoucherCode in DEFINITION</b>: this will inserted between the organism name and the VoucherCode in the DEFINITION.");

    SingleLineTextField uniqueSuffixField = exportDialog.addTextField("SeqID Suffix", "", 20);
    TextArea fsText = null;
    exportDialog.addLabel("Description of gene fragment:", Label.LEFT);
    fsText = exportDialog.addTextAreaSmallFont(addendum, 4);
    SingleLineTextField codeLabelField = exportDialog.addTextField("Text before VoucherCode in DEFINITION",
            "DNAVoucher", 20);

    Checkbox includeGapsCheckBox = exportDialog.addCheckBox("include gaps", includeGaps);
    exportDialog.addHorizontalLine(1);
    int releaseB = 1;
    if (releaseImmediately)
        releaseB = 0;
    RadioButtons releaseButtons = exportDialog
            .addRadioButtons(new String[] { "release immediately", "release date:" }, releaseB);
    IntegerField releaseYearField = exportDialog.addIntegerField("Release Year", releaseYear, 6);
    IntegerField releaseMonthField = exportDialog.addIntegerField("Release Month", releaseMonth, 4);
    IntegerField releaseDayField = exportDialog.addIntegerField("Release Day", releaseDay, 4);

    exportDialog.completeAndShowDialog(dataSelected, taxaSelected);

    addendum = fsText.getText();
    codeLabel = codeLabelField.getText();
    uniqueSuffix = uniqueSuffixField.getText();

    boolean ok = (exportDialog.query(dataSelected, taxaSelected) == 0);

    if (ok) {
        includeGaps = includeGapsCheckBox.getState();
        if (releaseButtons.getValue() == 0) {
            releaseImmediately = true;
        } else {
            releaseYear = releaseYearField.getValue();
            releaseMonth = releaseMonthField.getValue();
            releaseDay = releaseDayField.getValue();
            releaseImmediately = false;
        }
    }

    exportDialog.dispose();
    if (ok)
        ok = contact.queryValues();
    if (ok)
        ok = authors.queryValues();
    if (ok)
        ok = affiliation.queryValues();
    if (ok)
        storePreferences();
    return ok;

}

From source file:gdsc.smlm.ij.plugins.PeakFit.java

public void itemStateChanged(ItemEvent e) {
    Checkbox cb = (Checkbox) e.getSource();
    if (cb.getState()) {
        cb.setState(false);//from  w  w w .  j a  v  a  2s.  c  om
        PSFCalculator calculator = new PSFCalculator();
        calculatorSettings.pixelPitch = calibration.nmPerPixel / 1000.0;
        calculatorSettings.magnification = 1;
        calculatorSettings.beamExpander = 1;
        double sd = calculator.calculate(calculatorSettings, true);
        if (sd > 0)
            textInitialPeakStdDev0.setText(Double.toString(sd));
    }
}

From source file:gdsc.smlm.ij.plugins.CreateData.java

public void itemStateChanged(ItemEvent e) {
    // When the checkbox is clicked, output example compounds to the ImageJ log
    Checkbox cb = (Checkbox) e.getSource();
    if (cb.getState()) {
        cb.setState(false);/*from  w  ww .  j a v a  2  s  . c  o  m*/

        logExampleCompounds();
    }
}