Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/imageio/IIOParamController.java
38829 views
/*1* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.imageio;2627/**28* An interface to be implemented by objects that can determine the29* settings of an <code>IIOParam</code> object, either by putting up a30* GUI to obtain values from a user, or by other means. This31* interface merely specifies a generic <code>activate</code> method32* that invokes the controller, without regard for how the controller33* obtains values (<i>i.e.</i>, whether the controller puts up a GUI34* or merely computes a set of values is irrelevant to this35* interface).36*37* <p> Within the <code>activate</code> method, a controller obtains38* initial values by querying the <code>IIOParam</code> object's39* <code>get</code> methods, modifies values by whatever means, then40* invokes the <code>IIOParam</code> object's <code>set</code> methods41* to modify the appropriate settings. Normally, these42* <code>set</code> methods will be invoked all at once at a final43* commit in order that a cancel operation not disturb existing44* values. In general, applications may expect that when the45* <code>activate</code> method returns <code>true</code>, the46* <code>IIOParam</code> object is ready for use in a read or write47* operation.48*49* <p> Vendors may choose to provide GUIs for the50* <code>IIOParam</code> subclasses they define for a particular51* plug-in. These can be set up as default controllers in the52* corresponding <code>IIOParam</code> subclasses.53*54* <p> Applications may override any default GUIs and provide their55* own controllers embedded in their own framework. All that is56* required is that the<code>activate</code> method behave modally57* (not returning until either cancelled or committed), though it need58* not put up an explicitly modal dialog. Such a non-modal GUI59* component would be coded roughly as follows:60*61* <br>62* <pre>63* class MyGUI extends SomeComponent implements IIOParamController {64*65* public MyGUI() {66* // ...67* setEnabled(false);68* }69*70* public boolean activate(IIOParam param) {71* // disable other components if desired72* setEnabled(true);73* // go to sleep until either cancelled or committed74* boolean ret = false;75* if (!cancelled) {76* // set values on param77* ret = true;78* }79* setEnabled(false);80* // enable any components disabled above81* return ret;82* }83* </pre>84*85* <p> Alternatively, an algorithmic process such as a database lookup86* or the parsing of a command line could be used as a controller, in87* which case the <code>activate</code> method would simply look up or88* compute the settings, call the <code>IIOParam.setXXX</code>89* methods, and return <code>true</code>.90*91* @see IIOParam#setController92* @see IIOParam#getController93* @see IIOParam#getDefaultController94* @see IIOParam#hasController95* @see IIOParam#activateController96*97*/98public interface IIOParamController {99100/**101* Activates the controller. If <code>true</code> is returned,102* all settings in the <code>IIOParam</code> object should be103* ready for use in a read or write operation. If104* <code>false</code> is returned, no settings in the105* <code>IIOParam</code> object will be disturbed (<i>i.e.</i>,106* the user canceled the operation).107*108* @param param the <code>IIOParam</code> object to be modified.109*110* @return <code>true</code> if the <code>IIOParam</code> has been111* modified, <code>false</code> otherwise.112*113* @exception IllegalArgumentException if <code>param</code> is114* <code>null</code> or is not an instance of the correct class.115*/116boolean activate(IIOParam param);117}118119120