15 | //
16 | //
17 | // ================================================================
18 |
19 | package gov.nist.isg.mist.lib.common;
20 |
21 | import org.bridj.Pointer;
22 |
23 | import java.util.Comparator;
24 |
25 | /**
26 | * A comparator used for sorting a one-dimensional array of double pointers in ascending order. Used
27 | * to obtain the index of the larger elements.
28 | *
29 | *
30 | *
31 | * Pointer ptr;
32 | * Integer [] indices = new Integer[size];
33 | * for (i = 0; i < size; i++)
34 | * indices[i] = i;
35 | *
36 | * DoublePointerComparator cmp = new DoublePointerComparator(ptr);
37 | *
38 | * Arrays.sort(indices, cmp);
39 | *
40 | *
41 | *
42 | * @author Tim Blattner
43 | * @version 1.0
44 | */
45 | public class DoublePointerComparator implements Comparator {
46 |
47 | private Pointer pointer;
48 |
49 | /**
50 | * Creates a double pointer comparator that is bound to a pointer
51 | *
52 | * @param pointer the pointer that the object is bound to
53 | */
54 | public DoublePointerComparator(Pointer pointer) {
55 | this.pointer = pointer;
56 | }
57 |
58 | /**
59 | * Compares two values at indices i1 and i2 inside of the pointer that was initialized with the
60 | * DoublePointerComparator constructor
61 | *
62 | * @param o1 the first index inside of the pointer to compare
63 | * @param o2 the second index inside of the pointer to compare
64 | */
65 | @Override
66 | public int compare(Integer o1, Integer o2) {
67 | return Double.compare(this.pointer.getDoubleAtIndex(o2), this.pointer.getDoubleAtIndex(o1));
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/gov/nist/isg/mist/gui/components/textfield/textFieldModel/TextFieldModel.java:
--------------------------------------------------------------------------------
1 | // NIST-developed software is provided by NIST as a public service. You may use, copy and distribute copies of the software in any medium, provided that you keep intact this entire notice. You may improve, modify and create derivative works of the software or any portion of the software, and you may copy and distribute such modifications or works. Modified works should carry a notice stating that you changed the software and should note the date and nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the source of the software.
2 |
3 | // NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED, IN FACT OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE.
4 |
5 | // You are solely responsible for determining the appropriateness of using and distributing the software and you assume all risks associated with its use, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of operation. This software is not intended to be used in any situation where a failure could cause risk of injury or damage to property. The software developed by NIST employees is not subject to copyright protection within the United States.
6 |
7 |
8 |
9 | // ================================================================
10 | //
11 | // Author: tjb3
12 | // Date: Apr 18, 2014 12:28:13 PM EST
13 | //
14 | // Time-stamp:
15 | //
16 | //
17 | // ================================================================
18 |
19 | package gov.nist.isg.mist.gui.components.textfield.textFieldModel;
20 |
21 | /**
22 | * Validator is an interface that handles text validation for text fields. Functions for testing the
23 | * text, getting the values, and getting the error text associated with the validation are
24 | * provided.
25 | *
26 | * @param the type of Object for validation
27 | * @author Tim Blattner
28 | * @version 1.0
29 | */
30 | public interface TextFieldModel {
31 | /**
32 | * Tests the text using a specific validator
33 | *
34 | * @param val the text you wish to test
35 | * @return true if the the text is valid
36 | */
37 | public boolean validateText(String val);
38 |
39 | /**
40 | * Gets the error message associated with this validator
41 | *
42 | * @return the error message
43 | */
44 | public String getErrorMessage();
45 |
46 | /**
47 | * Gets the value of the text based on the validation type
48 | *
49 | * @param val the value you wish to parse
50 | * @return the value parsed by the validator
51 | */
52 | public T getModelValue(String val);
53 |
54 | /**
55 | * Gets the value of the text based on the validation type. The value that is returned represents
56 | * the value that is to be used in the text
57 | *
58 | * @param val the value you wish to parse
59 | * @return the value that is to be placed inside the text field
60 | */
61 | public String setModelValue(String val);
62 |
63 | /**
64 | * Updates the view based on the model
65 | */
66 | public void updateTextFields();
67 | }
68 |
--------------------------------------------------------------------------------
/src/test/java/gov/nist/isg/mist/fftw/TestFFTWComputeFFT32.java:
--------------------------------------------------------------------------------
1 | // NIST-developed software is provided by NIST as a public service. You may use, copy and distribute copies of the software in any medium, provided that you keep intact this entire notice. You may improve, modify and create derivative works of the software or any portion of the software, and you may copy and distribute such modifications or works. Modified works should carry a notice stating that you changed the software and should note the date and nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the source of the software.
2 |
3 | // NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED, IN FACT OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE.
4 |
5 | // You are solely responsible for determining the appropriateness of using and distributing the software and you assume all risks associated with its use, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of operation. This software is not intended to be used in any situation where a failure could cause risk of injury or damage to property. The software developed by NIST employees is not subject to copyright protection within the United States.
6 |
7 |
8 |
9 |
10 | package gov.nist.isg.mist.fftw;
11 |
12 | import java.io.File;
13 | import java.io.FileNotFoundException;
14 |
15 | import gov.nist.isg.mist.lib.log.Log;
16 | import gov.nist.isg.mist.lib.log.Log.LogType;
17 | import gov.nist.isg.mist.lib32.imagetile.fftw.FFTW3Library32;
18 | import gov.nist.isg.mist.lib32.imagetile.fftw.FftwImageTile32;
19 | import gov.nist.isg.mist.timing.TimeUtil;
20 |
21 |
22 | public class TestFFTWComputeFFT32 {
23 |
24 | /**
25 | * Computes the FFT for an image using FFTW
26 | */
27 | public static void runTestFFTImage() throws FileNotFoundException {
28 | Log.setLogLevel(LogType.INFO);
29 | Log.msg(LogType.MANDATORY, "Running Test Compute FFT Image using FFTW");
30 |
31 | File file = new File("C:\\majurski\\image-data\\1h_Wet_10Perc\\KB_2012_04_13_1hWet_10Perc_IR_00001.tif");
32 |
33 | FftwImageTile32.initLibrary("C:\\majurski\\NISTGithub\\MISTMain\\lib\\fftw", "", "libfftw3f");
34 |
35 |
36 | FftwImageTile32 tile = new FftwImageTile32(file);
37 |
38 | Log.msg(LogType.INFO, "Loading FFTW plan");
39 |
40 | FftwImageTile32.initPlans(tile.getWidth(), tile.getHeight(), FFTW3Library32.FFTW_MEASURE, true, "test.dat");
41 | FftwImageTile32.savePlan("test.dat");
42 | Log.msg(LogType.INFO, "Computing FFT");
43 | TimeUtil.tick();
44 | tile.computeFft();
45 | Log.msg(LogType.HELPFUL, "Finished Computing FFT in " + TimeUtil.tock() + " ms");
46 |
47 | tile.releaseFftMemory();
48 |
49 | FftwImageTile32.destroyPlans();
50 |
51 | // }
52 |
53 | Log.msg(LogType.MANDATORY, "Test Completed.");
54 | }
55 |
56 | /**
57 | * Executes the test case
58 | *
59 | * @param args not used
60 | */
61 | public static void main(String[] args) {
62 | try {
63 | TestFFTWComputeFFT32.runTestFFTImage();
64 | } catch (FileNotFoundException e) {
65 | Log.msg(LogType.MANDATORY, "Unable to find file: " + e.getMessage());
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/test/java/gov/nist/isg/mist/utilfns/TestUtilFnsNative.java:
--------------------------------------------------------------------------------
1 | // NIST-developed software is provided by NIST as a public service. You may use, copy and distribute copies of the software in any medium, provided that you keep intact this entire notice. You may improve, modify and create derivative works of the software or any portion of the software, and you may copy and distribute such modifications or works. Modified works should carry a notice stating that you changed the software and should note the date and nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the source of the software.
2 |
3 | // NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED, IN FACT OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE.
4 |
5 | // You are solely responsible for determining the appropriateness of using and distributing the software and you assume all risks associated with its use, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of operation. This software is not intended to be used in any situation where a failure could cause risk of injury or damage to property. The software developed by NIST employees is not subject to copyright protection within the United States.
6 |
7 |
8 |
9 |
10 | // ================================================================
11 | //
12 | // Author: tjb3
13 | // Date: Aug 1, 2013 4:20:49 PM EST
14 | //
15 | // Time-stamp:
16 | //
17 | //
18 | // ================================================================
19 |
20 | package gov.nist.isg.mist.utilfns;
21 |
22 | import org.bridj.BridJ;
23 | import org.bridj.Pointer;
24 |
25 | import java.io.File;
26 |
27 | import gov.nist.isg.mist.lib.imagetile.utilfns.UtilFnsLibrary;
28 | import gov.nist.isg.mist.lib.log.Log;
29 | import gov.nist.isg.mist.lib.log.Log.LogType;
30 |
31 | /**
32 | * Test case for loading the util functions native library and running an example.
33 | *
34 | * @author Tim Blattner
35 | * @version 1.0
36 | */
37 | public class TestUtilFnsNative {
38 |
39 | /**
40 | * Tests loading UtilFns native library
41 | */
42 | public static void runTestUtilFnsNative() {
43 | try {
44 | Log.msg(LogType.MANDATORY, "Running testing loading util functions natively");
45 | BridJ.setNativeLibraryActualName("utilfns", "util-fns-windows");
46 | BridJ.addLibraryPath(System.getProperty("user.dir") + File.separator + "util-fns");
47 |
48 | Pointer test = Pointer.allocateDoubles(1000);
49 | UtilFnsLibrary.reduce_max_abs(test, 1000);
50 |
51 | Log.msg(LogType.MANDATORY, "Util FNS library loaded successfully");
52 | } catch (UnsatisfiedLinkError ex) {
53 | Log.msg(LogType.MANDATORY, "Unabled to load UtilFns library: " + ex.toString());
54 | Log.msg(LogType.MANDATORY, ex.getMessage());
55 | } catch (Exception e) {
56 | Log.msg(LogType.MANDATORY, "Unabled to load UtilFns library: " + e.toString());
57 | Log.msg(LogType.MANDATORY, e.getMessage());
58 | }
59 |
60 | }
61 |
62 | /**
63 | * Executes the test case
64 | *
65 | * @param args not used
66 | */
67 | public static void main(String[] args) {
68 | TestUtilFnsNative.runTestUtilFnsNative();
69 |
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/src/test/java/gov/nist/isg/mist/basic/TestReadingImage.java:
--------------------------------------------------------------------------------
1 | // NIST-developed software is provided by NIST as a public service. You may use, copy and distribute copies of the software in any medium, provided that you keep intact this entire notice. You may improve, modify and create derivative works of the software or any portion of the software, and you may copy and distribute such modifications or works. Modified works should carry a notice stating that you changed the software and should note the date and nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the source of the software.
2 |
3 | // NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED, IN FACT OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE.
4 |
5 | // You are solely responsible for determining the appropriateness of using and distributing the software and you assume all risks associated with its use, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of operation. This software is not intended to be used in any situation where a failure could cause risk of injury or damage to property. The software developed by NIST employees is not subject to copyright protection within the United States.
6 |
7 |
8 |
9 |
10 | // ================================================================
11 | //
12 | // Author: tjb3
13 | // Date: May 10, 2013 2:59:20 PM EST
14 | //
15 | // Time-stamp:
16 | //
17 | //
18 | // ================================================================
19 |
20 | package gov.nist.isg.mist.basic;
21 |
22 | import java.io.File;
23 |
24 | import javax.swing.*;
25 |
26 | import gov.nist.isg.mist.lib.imagetile.ImageTile;
27 | import gov.nist.isg.mist.lib.imagetile.fftw.FftwImageTile;
28 | import gov.nist.isg.mist.lib.log.Log;
29 | import gov.nist.isg.mist.lib.log.Log.LogType;
30 | import gov.nist.isg.mist.timing.TimeUtil;
31 |
32 | /**
33 | * Test case for reading an image.
34 | *
35 | * @author Tim Blattner
36 | * @version 1.0
37 | */
38 | public class TestReadingImage {
39 |
40 | /**
41 | * Tests reading an image
42 | */
43 | public static void testReadingImage() {
44 | JFrame frame = new JFrame();
45 |
46 | Log.msg(LogType.MANDATORY, "Running Test Reading Image");
47 |
48 | JFileChooser chooser =
49 | new JFileChooser("F:\\StitchingData\\StitchingTestSlowFileLoad\\SSEA4_5x(1)");
50 | chooser.setDialogTitle("Select File to test reading image.");
51 |
52 | int result = chooser.showOpenDialog(frame);
53 |
54 | // File file = new
55 | // File("C:\\Users\\tjb3\\Desktop\\input_images\\F_0001.tif");
56 |
57 | if (result == JFileChooser.APPROVE_OPTION) {
58 | File file = chooser.getSelectedFile();
59 |
60 | TimeUtil.tick();
61 | ImageTile> tile = new FftwImageTile(file);
62 | Log.msg(LogType.INFO, "Read Complete: " + tile.toString());
63 | } else {
64 | Log.msg(LogType.MANDATORY, "Canceled selecting image.");
65 | }
66 |
67 | Log.msg(LogType.MANDATORY, "Test Completed in " + TimeUtil.tock() + "ms");
68 | }
69 |
70 | /**
71 | * Executes the test case
72 | *
73 | * @param args not used
74 | */
75 | public static void main(String[] args) {
76 | TestReadingImage.testReadingImage();
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/gov/nist/isg/mist/gui/params/interfaces/GUIParamFunctions.java:
--------------------------------------------------------------------------------
1 | // NIST-developed software is provided by NIST as a public service. You may use, copy and distribute copies of the software in any medium, provided that you keep intact this entire notice. You may improve, modify and create derivative works of the software or any portion of the software, and you may copy and distribute such modifications or works. Modified works should carry a notice stating that you changed the software and should note the date and nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the source of the software.
2 |
3 | // NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED, IN FACT OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE.
4 |
5 | // You are solely responsible for determining the appropriateness of using and distributing the software and you assume all risks associated with its use, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of operation. This software is not intended to be used in any situation where a failure could cause risk of injury or damage to property. The software developed by NIST employees is not subject to copyright protection within the United States.
6 |
7 |
8 |
9 | // ================================================================
10 | //
11 | // Author: tjb3
12 | // Date: Apr 18, 2014 1:05:00 PM EST
13 | //
14 | // Time-stamp:
15 | //
16 | //
17 | // ================================================================
18 |
19 | package gov.nist.isg.mist.gui.params.interfaces;
20 |
21 | import gov.nist.isg.mist.gui.params.StitchingAppParams;
22 |
23 | /**
24 | * An interface that represents parameter functions
25 | *
26 | * @author Tim Blattner
27 | * @version 1.0
28 | */
29 | public interface GUIParamFunctions {
30 |
31 | /**
32 | * Loads parameters into the GUI
33 | *
34 | * @param params the params to load
35 | */
36 | public void loadParamsIntoGUI(StitchingAppParams params);
37 |
38 | /**
39 | * Checks and parses the arguments in the GUI, setting the StitchingAppParams
40 | *
41 | * @param params the parameters that the GUI should set
42 | * @return true if the parameters were set
43 | */
44 | public boolean checkAndParseGUI(StitchingAppParams params);
45 |
46 | /**
47 | * Checks the GUI arguments
48 | *
49 | * @return true if the arguments passed
50 | */
51 | public boolean checkGUIArgs();
52 |
53 | /**
54 | * Enables flag to indicate that we are loading parameters
55 | */
56 | public void enableLoadingParams();
57 |
58 | /**
59 | * Disables flag to indicate that we are loading parameters
60 | */
61 | public void disableLoadingParams();
62 |
63 | /**
64 | * Checks if we are loading parameters
65 | *
66 | * @return true if we are laoding parameters
67 | */
68 | public boolean isLoadingParams();
69 |
70 | /**
71 | * Loads parameters from GUI into parameter object that is used to save the parameters to a file
72 | *
73 | * @param params the params that are to be loaded from the GUI and saved
74 | * @param isClosing true if the application is being closed, otherwise false
75 | */
76 | public void saveParamsFromGUI(StitchingAppParams params, boolean isClosing);
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/gov/nist/isg/mist/gui/components/textfield/textFieldModel/CheckSubGridOneBasedModel.java:
--------------------------------------------------------------------------------
1 | // NIST-developed software is provided by NIST as a public service. You may use, copy and distribute copies of the software in any medium, provided that you keep intact this entire notice. You may improve, modify and create derivative works of the software or any portion of the software, and you may copy and distribute such modifications or works. Modified works should carry a notice stating that you changed the software and should note the date and nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the source of the software.
2 |
3 | // NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED, IN FACT OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE.
4 |
5 | // You are solely responsible for determining the appropriateness of using and distributing the software and you assume all risks associated with its use, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of operation. This software is not intended to be used in any situation where a failure could cause risk of injury or damage to property. The software developed by NIST employees is not subject to copyright protection within the United States.
6 |
7 |
8 |
9 | // ================================================================
10 | //
11 | // Author: tjb3
12 | // Date: Apr 18, 2014 12:31:32 PM EST
13 | //
14 | // Time-stamp:
15 | //
16 | //
17 | // ================================================================
18 |
19 | package gov.nist.isg.mist.gui.components.textfield.textFieldModel;
20 |
21 | import gov.nist.isg.mist.gui.panels.subgrid.SubgridPanel;
22 |
23 | /**
24 | * Validator that checks if the subgrid parameters are correct based on the width and height of a
25 | * plate. Also converts the values to enforce 1-based indexing. When getting the value, it will
26 | * convert the value from 1-based to 0-based, and when setting the value it converts from 0-based to
27 | * 1-based.
28 | *
29 | * @author Tim Blattner
30 | * @version 1.0
31 | */
32 | public class CheckSubGridOneBasedModel extends CheckSubGridModel {
33 |
34 | /**
35 | * Creates a sub grid validator.
36 | *
37 | * @param advPanel the panel where the subgrid exists
38 | */
39 | public CheckSubGridOneBasedModel(SubgridPanel advPanel) {
40 | super(advPanel);
41 | }
42 |
43 | /**
44 | * Checks a sub grid validator, also keeping the value in bounds by min (inclusive) and max
45 | * (inclusive)
46 | *
47 | * @param min the minimum value that is valid (inclusive)
48 | * @param max the maximum value that is valid (inclusive)
49 | * @param advPanel the panel where the subgrid exists
50 | */
51 | public CheckSubGridOneBasedModel(int min, int max, SubgridPanel advPanel) {
52 | super(min, max, advPanel);
53 | }
54 |
55 | @Override
56 | public Integer getModelValue(String val) {
57 | int value = super.getModelValue(val);
58 |
59 | return value - 1;
60 |
61 | }
62 |
63 |
64 | @Override
65 | public String setModelValue(String val) {
66 | String valueStr = super.setModelValue(val);
67 |
68 | int zeroBasedVal = Integer.parseInt(valueStr);
69 |
70 | return Integer.toString(zeroBasedVal + 1);
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/gov/nist/isg/mist/gui/components/textfield/textFieldModel/InvalidTextModel.java:
--------------------------------------------------------------------------------
1 | // NIST-developed software is provided by NIST as a public service. You may use, copy and distribute copies of the software in any medium, provided that you keep intact this entire notice. You may improve, modify and create derivative works of the software or any portion of the software, and you may copy and distribute such modifications or works. Modified works should carry a notice stating that you changed the software and should note the date and nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the source of the software.
2 |
3 | // NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED, IN FACT OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE.
4 |
5 | // You are solely responsible for determining the appropriateness of using and distributing the software and you assume all risks associated with its use, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of operation. This software is not intended to be used in any situation where a failure could cause risk of injury or damage to property. The software developed by NIST employees is not subject to copyright protection within the United States.
6 |
7 |
8 |
9 | // ================================================================
10 | //
11 | // Author: tjb3
12 | // Date: Apr 18, 2014 12:37:30 PM EST
13 | //
14 | // Time-stamp:
15 | //
16 | //
17 | // ================================================================
18 |
19 | package gov.nist.isg.mist.gui.components.textfield.textFieldModel;
20 |
21 | import java.util.Arrays;
22 | import java.util.List;
23 |
24 | /**
25 | * Validator that checks values based on a two regex
26 | *
27 | * @author Tim Blattner
28 | * @version 1.0
29 | */
30 | public class InvalidTextModel implements TextFieldModel {
31 |
32 | private List invalidText;
33 | private String errorText;
34 |
35 | /**
36 | * Creates a regex validator based on a given regex
37 | *
38 | * @param invalidStrings the array of invalid strings
39 | * @param errorText the error text associated with this validator
40 | */
41 | public InvalidTextModel(String errorText, String... invalidStrings) {
42 | this.invalidText = Arrays.asList(invalidStrings);
43 | this.errorText = errorText;
44 |
45 | // update the error text to reflect that the invalid strings are invalid
46 | String extraErrorText = "
Invalid Character Sequences:";
47 | for (String str : invalidStrings)
48 | extraErrorText = extraErrorText + "
" + "\"" + str + "\"";
49 |
50 | extraErrorText = extraErrorText + "