- Type Parameters:
TargetT
- the target class to be parameterized
- All Known Implementing Classes:
BernsenThresholder.Parameters
,BilateralF.Parameters
,CannyEdgeDetector.Parameters
,Circle_Make_Random.Parameters
,Ellipse_Make_Random.Parameters
,EllipseGeometricFitCoord.Parameters
,EllipseGeometricFitDist.Parameters
,GradientCornerDetector.Parameters
,HoughTransformLines.Parameters
,KuwaharaF.Parameters
,Line_Make_Random.Parameters
,LucasKanadeMatcher.Parameters
,MserParameters
,MultiGradientEdgeDetector.Parameters
,NagaoMatsuyamaF.Parameters
,NiblackThresholder.Parameters
,PdfExporter.Parameters
,PeronaMalikF.Parameters
,RansacCircleDetector.Parameters
,RansacDetector.RansacParameters
,RansacEllipseDetector.Parameters
,RansacLineDetector.Parameters
,SauvolaThresholder.Parameters
,ScalarMedianFilter.Parameters
,SiftParameters
,TschumperleDericheF.Parameters
,VectorMedianFilter.Parameters
,VectorMedianFilterSharpen.Parameters
public interface ParameterBundle<TargetT>
Interface to be implemented by local 'Parameters' classes. This is part of the 'simple parameter object' scheme,
working with public fields. Only non-static, non-final, public fields are accepted as parameters. Current features
include:
(a) Makes parameter bundles printable by listing all eligible fields.
(b) Parameter bundles can be
added/modified as a whole by ImageJ's GenericDialog
, supported by specific annotations (use methods
DialogUtils.addToDialog(ParameterBundle, GenericDialog)
and
DialogUtils.getFromDialog(ParameterBundle, GenericDialog)
).
See the example in DemoParameters
below. Other functionality may be added in the future.
public class ClassToBeParameterized { enum MyEnum { // local enum type A, B, Cee }; // Sample parameter bundle class: static class DemoParameters implements ParameterBundle<ClassToBeParameterized> { public static int staticInt = 44; // currently static members are listed too! @DialogLabel("Make a decision:") public boolean someBool = true; public int someInt = 39; public float someFloat = 1.99f; @DialogLabel("Math.PI") @DialogDigits(10) public double someDouble = Math.PI; public String someString = "SHOW ME"; @DialogHide public String hiddenString = "HIDE ME"; public MyEnum someEnum = MyEnum.B; } public static void main(String[] args) { ParameterBundle params = new DemoParameters(); System.out.println("p1 = \n" + params.printToString()); GenericDialog gd = new GenericDialog(ParameterBundle.class.getSimpleName()); gd.addNumericField("some single int", 123, 0); params.addToDialog(gd); gd.showDialog(); if (gd.wasCanceled()) return; int singleInt = (int) gd.getNextNumber(); boolean success = params.getFromDialog(gd); System.out.println("success = " + success); System.out.println("p2 = \n" + params.printToString()); } }
- Version:
- 2022/11/23 added generic target type
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends ParameterBundle<?>>
Tduplicate
(T params) Returns a shallow copy of the specifiedParameterBundle
instance.default Field[]
Returns the valid parameter fields as an array.static boolean
Returns true iff the specified field is a valid parameter item.default void
printToStream
(PrintStream strm) Sends a string representation of this parameter bundle to the specified stream.default String
Substitute forObject.toString()
, which cannot be overridden by an interface's default method.default boolean
validate()
Validates the correctness and compatibility of the parameters in this bundle.
-
Method Details
-
getValidParameterFields
Returns the valid parameter fields as an array.- Returns:
- the valid parameter fields
-
printToString
Substitute forObject.toString()
, which cannot be overridden by an interface's default method.- Returns:
- as string representation of theis parameter bundle
-
printToStream
Sends a string representation of this parameter bundle to the specified stream.- Parameters:
strm
- the output stream
-
validate
Validates the correctness and compatibility of the parameters in this bundle. Does nothing by default, implementing classes should override this method.- Returns:
- true if all parameters are OK, false otherwise
-
isValidParameterField
Returns true iff the specified field is a valid parameter item. This applies if the field is neither private nor final or static.- Parameters:
f
- the field- Returns:
- true if a valid parameter field
-
duplicate
Returns a shallow copy of the specifiedParameterBundle
instance.- Type Parameters:
T
- generic type- Parameters:
params
- aParameterBundle
instance- Returns:
- a copy with the same type, fields and values as the original instance
-