Java Code Examples for java.awt.TextField#setEditable()

The following examples show how to use java.awt.TextField#setEditable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResetToDefaultListener.java    From ij-ridgedetection with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void actionPerformed(ActionEvent arg0) {

	// Set settings to default

	TextField textLineWidth = (TextField) gd.getNumericFields().get(0);
	textLineWidth.setText("" + IJ.d2s(Lines_.lineWidthDefault, 2));
	textLineWidth.setEditable(true);

	TextField textHighCon = (TextField) gd.getNumericFields().get(1);
	textHighCon.setText("" + IJ.d2s(Lines_.contrastHighDefault, 0));
	textHighCon.setEditable(true);

	TextField textLowCon = (TextField) gd.getNumericFields().get(2);
	textLowCon.setText("" + IJ.d2s(Lines_.contrastLowDefault, 0));
	textLowCon.setEditable(true);

	TextField textSigma = (TextField) gd.getNumericFields().get(3);
	textSigma.setText("" + IJ.d2s(Lines_.sigmaDefault, 2));
	textSigma.setEditable(true);

	TextField textLowThresh = (TextField) gd.getNumericFields().get(4);
	textLowThresh.setText("" + IJ.d2s(Lines_.lowerThreshDefault, 2));
	textLowThresh.setEditable(true);

	TextField textUppThresh = (TextField) gd.getNumericFields().get(5);
	textUppThresh.setText("" + IJ.d2s(Lines_.upperThreshDefault, 2));
	textUppThresh.setEditable(true);

	TextField textMinLength = (TextField) gd.getNumericFields().get(6);
	textMinLength.setText("" + IJ.d2s(Lines_.minLengthDefault, 2));
	textMinLength.setEditable(true);

	TextField textMaxLength = (TextField) gd.getNumericFields().get(7);
	textMaxLength.setText("" + IJ.d2s(Lines_.maxLengthDefault, 2));
	textMaxLength.setEditable(true);

	((Checkbox) gd.getCheckboxes().get(0)).setState(Lines_.isDarkLineDefault);
	((Checkbox) gd.getCheckboxes().get(1)).setState(Lines_.doCorrectPositionDefault);
	((Checkbox) gd.getCheckboxes().get(2)).setState(Lines_.doEstimateWidthDefault);
	((Checkbox) gd.getCheckboxes().get(3)).setState(Lines_.doExtendLineDefault);
	((Checkbox) gd.getCheckboxes().get(4)).setState(Lines_.showJunctionPointsDefault);
	((Checkbox) gd.getCheckboxes().get(5)).setState(Lines_.showIDsDefault);
	((Checkbox) gd.getCheckboxes().get(6)).setState(Lines_.verboseDefault);
	((Checkbox) gd.getCheckboxes().get(7)).setState(Lines_.displayResultsDefault);
	((Checkbox) gd.getCheckboxes().get(8)).setState(Lines_.addToRoiManagerDefault);
	((Checkbox) gd.getCheckboxes().get(9)).setState(Lines_.makeBinaryDefault);

	((Choice) gd.getChoices().get(0)).select(0);

}
 
Example 2
Source File: Lines_.java    From ij-ridgedetection with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean dialogItemChanged(GenericDialog gd, AWTEvent e) {
	imp.setOverlay(null);
	boolean lwChanged = false;
	boolean contHighChanged = false;
	boolean contLowChanged = false;
	boolean darklineChanged = false;

	double lwCand = gd.getNextNumber();
	double diff = Math.abs(lwCand - lineWidth);
	if (diff > 0.0001) {
		lineWidth = lwCand;
		lwChanged = true;
	}

	double conCand = gd.getNextNumber();
	diff = Math.abs(conCand - contrastHigh);
	if (diff > 0.0001) {
		contrastHigh = conCand;
		contHighChanged = true;
	}

	conCand = gd.getNextNumber();
	diff = Math.abs(conCand - contrastLow);
	if (diff > 0.0001) {
		contrastLow = conCand;
		contLowChanged = true;
	}

	boolean darklineCand = gd.getNextBoolean();
	if (darklineCand != isDarkLine) {
		isDarkLine = darklineCand;
		darklineChanged = true;
	}

	doCorrectPosition = gd.getNextBoolean();
	doEstimateWidth = gd.getNextBoolean();
	doExtendLine = gd.getNextBoolean();
	showJunctionPoints = gd.getNextBoolean();
	showIDs = gd.getNextBoolean();
	verbose = gd.getNextBoolean();
	displayResults = gd.getNextBoolean();
	addToRoiManager = gd.getNextBoolean();
	makeBinary = gd.getNextBoolean();
	overlapOption = OverlapOption.valueOf(gd.getNextChoice());
	if (lwChanged || contHighChanged || contLowChanged) {
		contrastOrLineWidthChangedOnce = true;
	}

	if (lwChanged || contHighChanged || contLowChanged || (darklineChanged && contrastOrLineWidthChangedOnce)) {
		double estimatedSigma = lineWidth / (2 * Math.sqrt(3)) + 0.5;
		TextField textSigma = (TextField) gd.getNumericFields().get(3);
		textSigma.setText("" + IJ.d2s(estimatedSigma, 2));
		textSigma.setEditable(true);
		double clow = contrastLow;
		if (isDarkLine) {
			clow = 255 - contrastHigh;
		}
		double estimatedLowerThresh = Math.floor(Math.abs(-2 * clow * (lineWidth / 2.0)
				/ (Math.sqrt(2 * Math.PI) * estimatedSigma * estimatedSigma * estimatedSigma)
				* Math.exp(-((lineWidth / 2.0) * (lineWidth / 2.0)) / (2 * estimatedSigma * estimatedSigma))));
		TextField textLowThresh = (TextField) gd.getNumericFields().get(4);
		textLowThresh.setText("" + IJ.d2s(estimatedLowerThresh * 0.17, 2));
		textLowThresh.setEditable(true);
		double chigh = contrastHigh;
		if (isDarkLine) {
			chigh = 255 - contrastLow;
		}
		double estimatedUpperThresh = Math.floor(Math.abs(-2 * chigh * (lineWidth / 2.0)
				/ (Math.sqrt(2 * Math.PI) * estimatedSigma * estimatedSigma * estimatedSigma)
				* Math.exp(-((lineWidth / 2.0) * (lineWidth / 2.0)) / (2 * estimatedSigma * estimatedSigma))));
		TextField textUppThresh = (TextField) gd.getNumericFields().get(5);
		textUppThresh.setText("" + IJ.d2s(estimatedUpperThresh * 0.17, 2));
		textUppThresh.setEditable(true);
	}
	sigma = gd.getNextNumber();
	lowerThresh = gd.getNextNumber();
	upperThresh = gd.getNextNumber();
	if (lowerThresh >= upperThresh || sigma < 0.4 || Double.isNaN(sigma + lowerThresh + upperThresh)) {
		return false;
	}

	minLength = gd.getNextNumber();
	maxLength = gd.getNextNumber();

	isPreview = gd.isPreviewActive();

	return true;
}