1. /*
  2. * @(#)IIOParamController.java 1.12 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.imageio;
  8. /**
  9. * An interface to be implemented by objects that can determine the
  10. * settings of an <code>IIOParam</code> object, either by putting up a
  11. * GUI to obtain values from a user, or by other means. This
  12. * interface merely specifies a generic <code>activate</code> method
  13. * that invokes the controller, without regard for how the controller
  14. * obtains values (<i>i.e.</i>, whether the controller puts up a GUI
  15. * or merely computes a set of values is irrelevant to this
  16. * interface).
  17. *
  18. * <p> Within the <code>activate</code> method, a controller obtains
  19. * initial values by querying the <code>IIOParam</code> object's
  20. * <code>get</code> methods, modifies values by whatever means, then
  21. * invokes the <code>IIOParam</code> object's <code>set</code> methods
  22. * to modify the appropriate settings. Normally, these
  23. * <code>set</code> methods will be invoked all at once at a final
  24. * commit in order that a cancel operation not disturb existing
  25. * values. In general, applications may expect that when the
  26. * <code>activate</code> method returns <code>true</code>, the
  27. * <code>IIOParam</code> object is ready for use in a read or write
  28. * operation.
  29. *
  30. * <p> Vendors may choose to provide GUIs for the
  31. * <code>IIOParam</code> subclasses they define for a particular
  32. * plug-in. These can be set up as default controllers in the
  33. * corresponding <code>IIOParam</code> subclasses.
  34. *
  35. * <p> Applications may override any default GUIs and provide their
  36. * own controllers embedded in their own framework. All that is
  37. * required is that the<code>activate</code> method behave modally
  38. * (not returning until either cancelled or committed), though it need
  39. * not put up an explicitly modal dialog. Such a non-modal GUI
  40. * component would be coded roughly as follows:
  41. *
  42. * <br>
  43. * <pre>
  44. * class MyGUI extends SomeComponent implements IIOParamController {
  45. *
  46. * public MyGUI() {
  47. * // ...
  48. * setEnabled(false);
  49. * }
  50. *
  51. * public boolean activate(IIOParam param) {
  52. * // disable other components if desired
  53. * setEnabled(true);
  54. * // go to sleep until either cancelled or committed
  55. * boolean ret = false;
  56. * if (!cancelled) {
  57. * // set values on param
  58. * ret = true;
  59. * }
  60. * setEnabled(false);
  61. * // enable any components disabled above
  62. * return ret;
  63. * }
  64. * </pre>
  65. *
  66. * <p> Alternatively, an algorithmic process such as a database lookup
  67. * or the parsing of a command line could be used as a controller, in
  68. * which case the <code>activate</code> method would simply look up or
  69. * compute the settings, call the <code>IIOParam.setXXX</code>
  70. * methods, and return <code>true</code>.
  71. *
  72. * @see IIOParam#setController
  73. * @see IIOParam#getController
  74. * @see IIOParam#getDefaultController
  75. * @see IIOParam#hasController
  76. * @see IIOParam#activateController
  77. *
  78. * @version 0.5
  79. */
  80. public interface IIOParamController {
  81. /**
  82. * Activates the controller. If <code>true</code> is returned,
  83. * all settings in the <code>IIOParam</code> object should be
  84. * ready for use in a read or write operation. If
  85. * <code>false</code> is returned, no settings in the
  86. * <code>IIOParam</code> object will be disturbed (<i>i.e.</i>,
  87. * the user canceled the operation).
  88. *
  89. * @param param the <code>IIOParam</code> object to be modified.
  90. *
  91. * @return <code>true</code> if the <code>IIOParam</code> has been
  92. * modified, <code>false</code> otherwise.
  93. *
  94. * @exception IllegalArgumentException if <code>param</code> is
  95. * <code>null</code> or is not an instance of the correct class.
  96. */
  97. boolean activate(IIOParam param);
  98. }