001: /*
002: * $RCSfile: RemoteDescriptorImpl.java,v $
003: *
004: * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
005: *
006: * Use is subject to license terms.
007: *
008: * $Revision: 1.1 $
009: * $Date: 2005/02/11 04:57:52 $
010: * $State: Exp $
011: */package javax.media.jai.remote;
012:
013: import java.awt.RenderingHints;
014: import java.awt.image.renderable.ParameterBlock;
015: import java.net.URL;
016: import javax.media.jai.PropertyGenerator;
017: import javax.media.jai.ParameterListDescriptor;
018: import javax.media.jai.OperationNode;
019:
020: /**
021: * This abstract class provides a partial implementation of the
022: * <code>RemoteDescriptor</code> interface, and is suitable for
023: * subclassing.
024: *
025: * @see RemoteDescriptor
026: *
027: * @since JAI 1.1
028: */
029: public abstract class RemoteDescriptorImpl implements RemoteDescriptor {
030:
031: /**
032: * The name of the protocol that this descriptor describes.
033: */
034: protected String protocolName;
035:
036: /**
037: * The <code>URL</code> pointing to the documentation regarding
038: * the format of the server name <code>String</code>.
039: */
040: protected URL serverNameDocURL;
041:
042: /**
043: * Creates a <code>RemoteDescriptorImpl</code> given the protocol name
044: * and the <code>URL</code> that points to documentation regarding the
045: * format of the server name <code>String</code>.
046: *
047: * <p> While the <code>serverNameDocURL</code> argument is allowed to
048: * be null, this is strongly discouraged, since this <code>URL</code>
049: * is the only description available to the user to help with creating
050: * a serverName <code>String</code> correctly.
051: *
052: * @param protocolName The name of the protocol.
053: * @param serverNameDocURL The <code>URL</code> pointing to server name
054: * format documentation.
055: * @throws IllegalArgumentException if protocolName is null.
056: */
057: public RemoteDescriptorImpl(String protocolName,
058: URL serverNameDocURL) {
059:
060: if (protocolName == null) {
061: throw new IllegalArgumentException(JaiI18N
062: .getString("Generic1"));
063: }
064:
065: this .protocolName = protocolName;
066: this .serverNameDocURL = serverNameDocURL;
067: }
068:
069: /**
070: * Returns the name of the remote imaging protocol under which this
071: * <code>RemoteDescriptor</code> will be registered in the
072: * <code>OperationRegistry</code>.
073: */
074: public String getName() {
075: return protocolName;
076: }
077:
078: /**
079: * The registry modes supported by this descriptor. The default
080: * implementation in this class returns two modes - "remoteRendered"
081: * and "remoteRenderable". If the subclass does not support both
082: * these modes it should override this method to reflect that.
083: *
084: * @see javax.media.jai.RegistryMode
085: */
086: public String[] getSupportedModes() {
087: return new String[] { "remoteRendered", "remoteRenderable" };
088: }
089:
090: /**
091: * Returns true if the supplied modeName is supported by this
092: * descriptor. The default implementation in this class returns true
093: * only if the supplied modeName is one of either "remoteRendered"
094: * or "remoteRenderable".
095: *
096: * @param modeName The mode name to check support for.
097: *
098: * @return true, if the implementation of this descriptor supports
099: * the specified mode. false otherwise.
100: *
101: * @throws IllegalArgumentException if <code>modeName</code> is null.
102: */
103: public boolean isModeSupported(String modeName) {
104:
105: if (modeName == null) {
106: throw new IllegalArgumentException(JaiI18N
107: .getString("RemoteDescriptorImpl1"));
108: }
109:
110: if (modeName.equalsIgnoreCase("remoteRendered")
111: || modeName.equalsIgnoreCase("remoteRenderable")) {
112: return true;
113: }
114:
115: return false;
116: }
117:
118: /**
119: * Returns true, if the implementation of this descriptor supports
120: * properties, false otherwise. The default implementation in this class
121: * returns false, signifying that no properties are supported independent
122: * of the operations themselves.
123: *
124: * @see PropertyGenerator
125: */
126: public boolean arePropertiesSupported() {
127: return false;
128: }
129:
130: /**
131: * Returns an array of <code>PropertyGenerator</code>s implementing
132: * the property inheritance for this descriptor. Since neither the
133: * "remoteRendered" or "remoteRendered" modes support properties
134: * independent of the operations themselves, the default
135: * implementation throws an <code>UnsupportedOperationException</code>.
136: * Subclasses should override this method if they wish to produce
137: * inherited properties.
138: *
139: * @param modeName The mode name to get <code>PropertyGenerator</code>s
140: * for.
141: * @throws IllegalArgumentException if <code>modeName</code> is null.
142: * @throws UnsupportedOperationException if
143: * <code>arePropertiesSupported()</code> returns <code>false</code>
144: *
145: * @return An array of <code>PropertyGenerator</code>s, or
146: * <code>null</code> if this operation does not have any of
147: * its own <code>PropertyGenerator</code>s.
148: */
149: public PropertyGenerator[] getPropertyGenerators(String modeName) {
150:
151: if (modeName == null) {
152: throw new IllegalArgumentException(JaiI18N
153: .getString("RemoteDescriptorImpl1"));
154: }
155:
156: throw new UnsupportedOperationException(JaiI18N
157: .getString("RemoteDescriptorImpl2"));
158: }
159:
160: /**
161: * Returns a <code>URL</code> that points to an HTML page containing
162: * instructions on constructing a server name string for the protocol
163: * with which this class is associated.
164: */
165: public URL getServerNameDocs() {
166: return serverNameDocURL;
167: }
168:
169: /**
170: * Calculates the region over which two distinct remote renderings
171: * of an operation may be expected to differ. The operation is
172: * represented by the <code>OperationNode</code> argument to this
173: * method. The <code>String</code> that identifies the operation
174: * can be retrieved via the <code>OperationNode</code>'s
175: * <code>getOperationName()</code> method.
176: *
177: * <p> The class of the returned object will vary as a function of
178: * the nature of the operation. For rendered and renderable two-
179: * dimensional images this should be an instance of a class which
180: * implements <code>java.awt.Shape</code>.
181: *
182: * <p> The implementation in this class always returns null as the
183: * invalid region signifying that there is no common region of validity.
184: * Since null is always returned, in the interests of efficiency, none
185: * of the checks for ensuring that the <code>ParameterBlock</code>
186: * arguments passed to this method contain the correct number and
187: * <code>Class</code> of sources and parameters are performed in this
188: * implementation.
189: *
190: * @param registryModeName The name of the mode.
191: * @param oldServerName The previous server name.
192: * @param oldParamBlock The previous sources and parameters.
193: * @param oldHints The previous hints.
194: * @param newServerName The current server name.
195: * @param newParamBlock The current sources and parameters.
196: * @param newHints The current hints.
197: * @param node The affected node in the processing chain.
198: *
199: * @return The region over which the data of two renderings of this
200: * operation may be expected to be invalid or <code>null</code>
201: * if there is no common region of validity. If an empty
202: * <code>java.awt.Shape</code> is returned, this indicates
203: * that all pixels within the bounds of the old rendering
204: * remain valid.
205: *
206: * @throws IllegalArgumentException if <code>registryModeName</code>
207: * is <code>null</code> or if the operation requires either
208: * sources or parameters and either <code>oldParamBlock</code>
209: * or <code>newParamBlock</code> is <code>null</code>.
210: * @throws IllegalArgumentException if there is no OperationDescriptor
211: * for the specified operationName on any one or both of the
212: * servers identified by <code>oldServerName</code> and
213: * <code>newServerName</code>, or if the number of sources or
214: * the name, number and <code>Class</code> of the operation's
215: * parameters is not the same on both the servers.
216: * @throws IllegalArgumentException if <code>oldParamBlock</code> or
217: * <code>newParamBlock</code> do not contain sufficient sources
218: * or parameters for the operation in question.
219: */
220: public Object getInvalidRegion(String registryModeName,
221: String oldServerName, ParameterBlock oldParamBlock,
222: RenderingHints oldHints, String newServerName,
223: ParameterBlock newParamBlock, RenderingHints newHints,
224: OperationNode node) throws RemoteImagingException {
225: return null;
226: }
227:
228: /**
229: * The two modes supported by this descriptor are "remoteRendered" and
230: * "remoteRenderable". Since neither of these modes supports any
231: * parameters, this default implementation always returns null.
232: *
233: * @param modeName The mode name to get the
234: * <code>ParameterListDescriptor</code> for.
235: *
236: * @throws IllegalArgumentException if modeName is null.
237: */
238: public ParameterListDescriptor getParameterListDescriptor(
239: String modeName) {
240: if (modeName == null) {
241: throw new IllegalArgumentException(JaiI18N
242: .getString("RemoteDescriptorImpl1"));
243: }
244:
245: return null;
246: }
247: }
|