jdk/src/java.desktop/share/classes/javax/imageio/IIOParamController.java
author alanb
Fri, 07 Apr 2017 08:05:54 +0000
changeset 44545 83b611b88ac8
parent 35667 ed476aba94de
permissions -rw-r--r--
8177530: Module system implementation refresh (4/2017) Reviewed-by: mchung, alanb Contributed-by: alan.bateman@oracle.com, mandy.chung@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.imageio;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * An interface to be implemented by objects that can determine the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    30
 * settings of an {@code IIOParam} object, either by putting up a
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * GUI to obtain values from a user, or by other means.  This
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    32
 * interface merely specifies a generic {@code activate} method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * that invokes the controller, without regard for how the controller
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * obtains values (<i>i.e.</i>, whether the controller puts up a GUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * or merely computes a set of values is irrelevant to this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * interface).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    38
 * <p> Within the {@code activate} method, a controller obtains
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    39
 * initial values by querying the {@code IIOParam} object's
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    40
 * {@code get} methods, modifies values by whatever means, then
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    41
 * invokes the {@code IIOParam} object's {@code set} methods
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * to modify the appropriate settings.  Normally, these
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    43
 * {@code set} methods will be invoked all at once at a final
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * commit in order that a cancel operation not disturb existing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * values.  In general, applications may expect that when the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    46
 * {@code activate} method returns {@code true}, the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    47
 * {@code IIOParam} object is ready for use in a read or write
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <p> Vendors may choose to provide GUIs for the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    51
 * {@code IIOParam} subclasses they define for a particular
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * plug-in.  These can be set up as default controllers in the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    53
 * corresponding {@code IIOParam} subclasses.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <p> Applications may override any default GUIs and provide their
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * own controllers embedded in their own framework.  All that is
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    57
 * required is that the {@code activate} method behave modally
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * (not returning until either cancelled or committed), though it need
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * not put up an explicitly modal dialog.  Such a non-modal GUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * component would be coded roughly as follows:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * class MyGUI extends SomeComponent implements IIOParamController {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *    public MyGUI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *        // ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *        setEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *    public boolean activate(IIOParam param) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *        // disable other components if desired
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *        setEnabled(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *        // go to sleep until either cancelled or committed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *        boolean ret = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *        if (!cancelled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *            // set values on param
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *            ret = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *        setEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 *        // enable any components disabled above
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 *        return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 *    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * <p> Alternatively, an algorithmic process such as a database lookup
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * or the parsing of a command line could be used as a controller, in
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    88
 * which case the {@code activate} method would simply look up or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    89
 * compute the settings, call the {@code IIOParam.setXXX}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    90
 * methods, and return {@code true}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * @see IIOParam#setController
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * @see IIOParam#getController
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * @see IIOParam#getDefaultController
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * @see IIOParam#hasController
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * @see IIOParam#activateController
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
public interface IIOParamController {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   102
     * Activates the controller.  If {@code true} is returned,
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   103
     * all settings in the {@code IIOParam} object should be
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * ready for use in a read or write operation.  If
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   105
     * {@code false} is returned, no settings in the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   106
     * {@code IIOParam} object will be disturbed (<i>i.e.</i>,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * the user canceled the operation).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   109
     * @param param the {@code IIOParam} object to be modified.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   111
     * @return {@code true} if the {@code IIOParam} has been
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   112
     * modified, {@code false} otherwise.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   114
     * @exception IllegalArgumentException if {@code param} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   115
     * {@code null} or is not an instance of the correct class.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    boolean activate(IIOParam param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
}