More AWT/Swing merge from GNU Classpath.

From-SVN: r56148
This commit is contained in:
Bryce McKinlay 2002-08-09 04:29:59 +00:00 committed by Bryce McKinlay
parent 7bde45b2eb
commit 8f5c92a0a3
11 changed files with 1332 additions and 0 deletions

View file

@ -0,0 +1,240 @@
/* InputMethod.java -- defines an interface for complex text input
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.im.spi;
import java.awt.AWTEvent;
import java.awt.Rectangle;
import java.util.Locale;
/**
* This interface supports complex text input, often for situations where
* the text is more complex than a keyboard will accomodate. For example,
* this can be used for Chinese, Japanese, and Korean, where multiple
* keystrokes are necessary to compose text. This could also support things
* like phonetic English, or reordering Thai.
*
* <p>These contexts can be loaded by the input method framework, using
* {@link InputContext#selectInputMethod(Locale)}.
*
* @author Eric Blake <ebb9@email.byu.edu>
* @since 1.3
* @status updated to 1.4
*/
public interface InputMethod
{
/**
* Set the input method context, which ties the input method to a client
* component. This is called once automatically when creating the input
* method.
*
* @param context the context for this input method
* @throws NullPointerException if context is null
*/
void setInputMethodContext(InputMethodContext context);
/**
* Sets the input locale. If the input method supports that locale, it
* changes its behavior to be consistent with the locale and returns true.
* Otherwise, it returns false. This is called by
* {@link InputContext#selectInputMethod(Locale)} when the user specifies
* a locale, or when the previously selected input method had a locale.
*
* @param locale the locale to use for input
* @return true if the change is successful
* @throws NullPointerException if locale is null
*/
boolean setLocale(Locale locale);
/**
* Returns the current input locale, or null if none is defined. This is
* called by {@link InputContext#getLocale()}, or before switching input
* methods.
*
* @return the current input locale, or null
*/
Locale getLocale();
/**
* Sets the allowed Unicode subsets that this input method can use. Null
* indicates that all characters are allowed. This is called after creation,
* or when switching to this input method, by
* {@link InputContext#setCharacterSubsets(Character.Subset[])}.
*
* @param subsets the accepted subsets for this input method, or null for all
*/
void setCharacterSubsets(Character.Subset[] subsets);
/**
* Changes the enabled status of this input method. An enabled input method
* accepts incoming events for composition and control purposes, while a
* disabled input method ignores events (except for control purposes). This
* is called by {@link InputContext#setCompositionEnabled(boolean)} or when
* switching from an input method if the previous input method returned
* without exception on {@link #isCompositionEnabled()}.
*
* @param enable whether to enable this input method
* @throws UnsupportedOperationException if enabling/disabling is unsupported
* @see #isCompositionEnabled()
*/
void setCompositionEnabled(boolean enable);
/**
* Find out if this input method is enabled. This is called by
* {@link InputContext#isCompositionEnabled()}, or when switching input
* methods via {@link InputContext#selectInputMethod(Locale)}.
*
* @return true if this input method is enabled
* @throws UnsupportedOperationException if enabling/disabling is unsupported
* @see #setCompositionEnabled(boolean)
*/
boolean isCompositionEnabled();
/**
* Starts a reconversion operation. The input method gets its text from the
* client, using {@link InputMethodRequests#getSelectedText(Attribute[])}.
* Then the composed and committed text produced by the operation is sent
* back to the client using a sequence of InputMethodEvents. This is called
* by {@link InputContext#reconvert()}.
*
* @throws UnsupportedOperationException if reconversion is unsupported
*/
void reconvert();
/**
* Dispatch an event to the input method. If input method support is enabled,
* certain events are dispatched to the input method before the client
* component or event listeners. The input method must either consume the
* event or pass it on to the component. Instances of InputEvent, including
* KeyEvent and MouseEvent, are given to this input method. This method is
* called by {@link InputContext#dispatchEvent(AWTEvent)}.
*
* @param event the event to dispatch
* @throws NullPointerException if event is null
*/
void dispatchEvent(AWTEvent event);
/**
* Notify this input method of changes in the client window. This is called
* when notifications are enabled (see {@link
* InputMethodContext#enableClientWindowNotification(InputMethod, boolean)},
* if {@link #removeNotify(Component)} has not been called. The following
* situations trigger a notification:<ul>
* <li>The client window changes in location, size, visibility,
* iconification, or is closed.</li>
* <li>When enabling client notification (or on the first activation after
* enabling if no client existed at the time).</li>
* <li>When activating a new client after <code>removeNotify</code> was
* called on a previous client.</li>
* </ul>
*
* @param the client window's current bounds, or null
*/
void notifyClientWindowChange(Rectangle bounds);
/**
* Activate this input method for input processing. If the input method
* provides its own windows, it should make them open and visible at this
* time. This method is called when a client component receives a
* FOCUS_GAINED event, or when switching to this input method from another
* one. It is only called when the input method is inactive, assuming that
* new instances begin in an inactive state.
*/
void activate();
/**
* Deactivate this input method, either temporarily or permanently for the
* given client. If the input method provides its own windows, it should
* only close those related to the current composition (such as a lookup
* choice panel), while leaving more persistant windows (like a control
* panel) open to avoid screen flicker. Before control is given to another
* input method, {@link #hideWindows()} will be called on this instance.
* This method is called when a client component receives a
* FOCUS_LOST event, when switching to another input method, or before
* {@link #removeNotify()} when the client is removed.
*
* @param isTemporary true if the focus change is temporary
*/
void deactivate(boolean isTemporary);
/**
* Close or hide all windows opened by this input method. This is called
* before activating a different input method, and before calling
* {@link #dispose()} on this instance. It is only called when the input
* method is inactive.
*/
void hideWindows();
/**
* Notify the input method that a client component has been removed from its
* hierarchy, or that input method support has been disabled. This is
* called by {@link InputContext#removeNotify()}, and only when the input
* method is inactive.
*/
void removeNotify();
/**
* End any input composition currently taking place. Depending on the
* platform and user preferences, this may commit or delete uncommitted text,
* using input method events. This may be called for a variety of reasons,
* such as when the user moves the insertion point in the client text outside
* the range of the composed text, or when text is saved to file. This is
* called by {@link InputContext#endComposition()}, when switching to a
* new input method, or by {@link InputContext#selectInputMethod(Locale)}.
*/
void endComposition();
/**
* Disposes the input method and release any resources it is using. In
* particular, the input method should dispose windows and close files. This
* is called by {@link InputContext#dispose()}, when the input method is
* inactive; and nothing will be called on this instance afterwards.
*/
void dispose();
/**
* Returns a control object from this input method, or null. A control object
* provides method to control the behavior of this input method, as well as
* query information about it. The object is implementation dependent, so
* clients must compare the result against known input method control
* object types. This is called by
* {@link InputContext#getInputMethodControlObject()}.
*
* @return the control object, or null
*/
Object getControlObject();
} // interface InputMethod

View file

@ -0,0 +1,122 @@
/* InputMethodContext.java -- communication between an input method and client
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.im.spi;
import java.awt.HeadlessException;
import java.awt.Window;
import java.awt.font.TextHitInfo;
import java.awt.im.InputMethodRequests;
import java.text.AttributedCharacterIterator;
import javax.swing.JFrame;
/**
* Provides methods for the communication context between an input method
* and the client component. This should be passed to
* {@link InputMethod#setInputMethodContext(InputMethodContext)}.
*
* @author Eric Blake <ebb9@email.byu.edu>
* @since 1.3
* @status updated to 1.4
*/
public interface InputMethodContext extends InputMethodRequests
{
/**
* Create an input method event and dispatch it to the client.
*
* @param id the event type
* @param text an iterator over the text to be committed
* @param count the count of characters to be committed
* @param caret the insertion point of the commit, or null
* @param visiblePosition the best location to make visible, or null
*/
void dispatchInputMethodEvent(int id, AttributedCharacterIterator text,
int count, TextHitInfo caret,
TextHitInfo visiblePosition);
/**
* Creates a top-level window for use by the input method. This window should
* float above all document windows and dialogs, not receive focus, and have
* lightweight decorations (such as no title, reduced drag regions). But
* this behavior may be modified to meet the platform style. The title may
* or may not be displayed, depending on the platform.
*
* <p>If attachToInputContext is true, the new window will share the input
* context of the input method, so that events in the new window are
* dispatched to the input method. Also, this supresses deactivate and
* activate calls to the input method caused by setVisible.
*
* @param title the window title, if one is displayed; null becomes ""
* @param attachToInputContext true for the window to share context with
* the input method
* @return the new window for use by the input method
* @throws HeadlessException if GraphicsEnvironment.isHeadless is true
*/
Window createInputMethodWindow(String title, boolean attachToInputContext);
/**
* Creates a top-level Swing JFrame for use by the input method. This frame
* should float above all document windows and dialogs, not receive focus,
* and have lightweight decorations (such as no title, reduced drag
* regions). But this behavior may be modified to meet the platform style.
* The title may or may not be displayed, depending on the platform.
*
* <p>If attachToInputContext is true, the new window will share the input
* context of the input method, so that events in the new window are
* dispatched to the input method. Also, this supresses deactivate and
* activate calls to the input method caused by setVisible.
*
* @param title the window title, if one is displayed; null becomes ""
* @param attachToInputContext true for the window to share context with
* the input method
* @return the new window for use by the input method
* @throws HeadlessException if GraphicsEnvironment.isHeadless is true
* @since 1.4
*/
JFrame createInputMethodJFrame(String title, boolean attachToInputContext);
/**
* Sets whether notification of the client window's location and state should
* be enabled for the input method. When enabled, the input method's
* {@link #notifyClientWindowChange(Rectangle)} method is called.
* Notification is automatically disabled when the input method is disposed.
*
* @param inputMethod the method to change status of
* @param enable true to enable notification
*/
void enableClientWindowNotification(InputMethod inputMethod, boolean enable);
} // interface InputMethodContext

View file

@ -0,0 +1,111 @@
/* InputMethodDescriptor.java -- enables loading and use of an input method
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.im.spi;
import java.awt.AWTException;
import java.awt.Image;
import java.util.Locale;
/**
* This interface provides information about an InputMethod before it is
* loaded.
*
* @author Eric Blake <ebb9@email.byu.edu>
* @since 1.3
* @status updated to 1.4
*/
public interface InputMethodDescriptor
{
/**
* Returns the locales supported by the input method this describes. This
* allows the selection of input methods by locale (by language only, or
* also by country and variant), via
* {@link InputContext#selectInputMethod(Locale)}. The returned list should
* ignore pass-through locales, so it is usually a subset of locales for
* which {@link InputMethod#setContext(Locale)} returns true. If
* {@link #hasDynamicLocaleList()} returns true, this is called each time
* information is needed, allowing dynamic addition or removal of supported
* locales.
*
* @return the list of supported locales
* @throws AWTException if the input method is not available
*/
Locale[] getAvailableLocales() throws AWTException;
/**
* Test whether the input method this describes has a static or dynamic
* locale list. For example, this would return true if the list of supported
* locales depends on adapters currently loaded over a network.
*
* @return true if the locale list is dynamic
*/
boolean hasDynamicLocaleList();
/**
* Returns a user visible name of the input locale, displayed in the
* specified locale. The inputLocale parameter must be one obtained from
* the list in {@link #getAvailableLocales()}, or null for a
* locale-independent description of the input method. If a translation to
* the desired display language is not available, another language may be
* used.
*
* @param inputLocale the locale of the input method, or null
* @param displayLanguage the language of the result
* @return the name of the input method when using the given inputLocale
*/
public String getInputMethodDisplayName(Locale inputLocale,
Locale displayLanguage);
/**
* Returns a 16x16 icon for the input locale. The inputLocale parameter
* must be one obtained from the list in {@link #getAvailableLocales()}, or
* null for a locale-independent icon for the input method.
*
* @param inputLocale the locale of the input method, or null
* @return a 16x16 icon for the input method when using the given inputLocale
*/
public Image getInputMethodIcon(Locale inputLocale);
/**
* Creates a new instance of the input method.
*
* @return the newly created input method
* @throws Exception if anything goes wrong
*/
public InputMethod createInputMethod() throws Exception;
} // interface InputMethodDescriptor

View file

@ -0,0 +1,56 @@
/* ContextualRenderedImageFactory.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.image.renderable;
import java.awt.geom.Rectangle2D;
import java.awt.image.RenderedImage;
/**
* STUBBED
*/
public interface ContextualRenderedImageFactory extends RenderedImageFactory
{
RenderContext mapRenderContext(int i, RenderContext context,
ParameterBlock block, RenderableImage image);
RenderedImage create(RenderContext context, ParameterBlock block);
Rectangle2D getBounds2D(ParameterBlock block);
Object getProperty(ParameterBlock block, String name);
String[] getPropertyNames();
boolean isDynamic();
} // interface ContextualRenderedImageFactory

View file

@ -0,0 +1,308 @@
/* ParameterBlock.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.image.renderable;
import java.awt.image.RenderedImage;
import java.io.Serializable;
import java.util.Vector;
public class ParameterBlock implements Cloneable, Serializable
{
private static final long serialVersionUID = -7577115551785240750L;
protected Vector sources;
protected Vector parameters;
public ParameterBlock()
{
this(new Vector(), new Vector());
}
public ParameterBlock(Vector sources)
{
this(sources, new Vector());
}
public ParameterBlock(Vector sources, Vector parameters)
{
this.sources = sources;
this.parameters = parameters;
}
public Object shallowClone()
{
try
{
return super.clone();
}
catch (CloneNotSupportedException e)
{
throw (Error) new InternalError().initCause(e); // impossible
}
}
public Object clone()
{
ParameterBlock pb = (ParameterBlock) shallowClone();
if (sources != null)
pb.sources = (Vector) sources.clone();
if (parameters != null)
pb.parameters = (Vector) parameters.clone();
return pb;
}
public ParameterBlock addSource(Object source)
{
sources.add(source);
return this;
}
public Object getSource(int index)
{
return sources.get(index);
}
public ParameterBlock setSource(Object source, int index)
{
sources.ensureCapacity(index);
sources.set(index, source);
return this;
}
public RenderedImage getRenderedSource(int index)
{
return (RenderedImage) sources.get(index);
}
public RenderableImage getRenderableSource(int index)
{
return (RenderableImage) sources.get(index);
}
public int getNumSources()
{
return sources.size();
}
public Vector getSources()
{
return sources;
}
public void setSources(Vector sources)
{
this.sources = sources;
}
public void removeSources()
{
if (sources != null)
sources.clear();
}
public int getNumParameters()
{
return parameters.size();
}
public Vector getParameters()
{
return parameters;
}
public void setParameters(Vector parameters)
{
this.parameters = parameters;
}
public void removeParameters()
{
if (parameters != null)
parameters.clear();
}
public ParameterBlock add(Object o)
{
parameters.add(o);
return this;
}
public ParameterBlock add(byte b)
{
return add(new Byte(b));
}
public ParameterBlock add(char c)
{
return add(new Character(c));
}
public ParameterBlock add(short s)
{
return add(new Short(s));
}
public ParameterBlock add(int i)
{
return add(new Integer(i));
}
public ParameterBlock add(long l)
{
return add(new Long(l));
}
public ParameterBlock add(float f)
{
return add(new Float(f));
}
public ParameterBlock add(double d)
{
return add(new Double(d));
}
public ParameterBlock set(Object o, int index)
{
parameters.ensureCapacity(index);
parameters.set(index, o);
return this;
}
public ParameterBlock set(byte b, int index)
{
return set(new Byte(b), index);
}
public ParameterBlock set(char c, int index)
{
return set(new Character(c), index);
}
public ParameterBlock set(short s, int index)
{
return set(new Short(s), index);
}
public ParameterBlock set(int i, int index)
{
return set(new Integer(i), index);
}
public ParameterBlock set(long l, int index)
{
return set(new Long(l), index);
}
public ParameterBlock set(float f, int index)
{
return set(new Float(f), index);
}
public ParameterBlock set(double d, int index)
{
return set(new Double(d), index);
}
public Object getObjectParameter(int index)
{
return parameters.get(index);
}
public byte getByteParameter(int index)
{
return ((Byte) parameters.get(index)).byteValue();
}
public char getCharParameter(int index)
{
return ((Character) parameters.get(index)).charValue();
}
public short getShortParameter(int index)
{
return ((Short) parameters.get(index)).shortValue();
}
public int getIntParameter(int index)
{
return ((Integer) parameters.get(index)).intValue();
}
public long getLongParameter(int index)
{
return ((Long) parameters.get(index)).longValue();
}
public float getFloatParameter(int index)
{
return ((Float) parameters.get(index)).floatValue();
}
public double getDoubleParameter(int index)
{
return ((Double) parameters.get(index)).doubleValue();
}
public Class[] getParamClasses()
{
int i = parameters.size();
Class[] result = new Class[i];
while (--i >= 0)
{
Class c = parameters.get(i).getClass();
if (c == Byte.class)
result[i] = byte.class;
else if (c == Character.class)
result[i] = char.class;
else if (c == Short.class)
result[i] = short.class;
else if (c == Integer.class)
result[i] = int.class;
else if (c == Long.class)
result[i] = long.class;
else if (c == Float.class)
result[i] = float.class;
else if (c == Double.class)
result[i] = double.class;
else
result[i] = c;
}
return result;
}
} // class ParameterBlock

View file

@ -0,0 +1,141 @@
/* RenderContext.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.image.renderable;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
public class RenderContext implements Cloneable
{
private AffineTransform xform;
private Shape aoi;
private RenderingHints hints;
public RenderContext(AffineTransform xform, Shape aoi, RenderingHints hints)
{
this.xform = xform;
this.aoi = aoi;
this.hints = hints;
}
public RenderContext(AffineTransform xform)
{
this(xform, null, null);
}
public RenderContext(AffineTransform xform, RenderingHints hints)
{
this(xform, null, hints);
}
public RenderContext(AffineTransform xform, Shape aoi)
{
this(xform, aoi, null);
}
public RenderingHints getRenderingHints()
{
return hints;
}
public void setRenderingHints(RenderingHints hints)
{
this.hints = hints;
}
public void setTransform(AffineTransform xform)
{
this.xform = xform;
}
public void preConcatenateTransform(AffineTransform pre)
{
xform.preConcatenate(pre);
}
/** @deprecated Sun can't spell concatenate */
public void preConcetenateTransform(AffineTransform pre)
{
preConcetenateTransform(pre);
}
public void concatenateTransform(AffineTransform post)
{
xform.concatenate(post);
}
/** @deprecated Sun can't spell concatenate */
public void concetenateTransform(AffineTransform post)
{
concatenateTransform(post);
}
public AffineTransform getTransform()
{
return xform;
}
public void setAreaOfInterest(Shape aoi)
{
this.aoi = aoi;
}
public Shape getAreaOfInterest()
{
return aoi;
}
public Object clone()
{
try
{
RenderContext copy = (RenderContext) super.clone();
if (xform != null)
copy.xform = (AffineTransform) xform.clone();
if (hints != null)
copy.hints = (RenderingHints) hints.clone();
return copy;
}
catch (CloneNotSupportedException e)
{
throw (Error) new InternalError().initCause(e); // impossible
}
}
} // class RenderContext

View file

@ -0,0 +1,59 @@
/* RenderableImage.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.image.renderable;
import java.awt.RenderingHints;
import java.awt.image.RenderedImage;
import java.util.Vector;
public interface RenderableImage
{
String HINTS_OBSERVED = "HINTS_OBSERVED";
Vector getSources();
Object getProperty(String name);
String[] getPropertyNames();
boolean isDynamic();
float getWidth();
float getHeight();
float getMinX();
float getMinY();
RenderedImage createScaledRendering(int w, int h, RenderingHints hints);
RenderedImage createDefaultRendering();
RenderedImage createRendering(RenderContext context);
} // interface RenderableImage

View file

@ -0,0 +1,157 @@
/* RenderableImageOp.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.image.renderable;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.image.RenderedImage;
import java.util.Vector;
public class RenderableImageOp implements RenderableImage
{
private final ContextualRenderedImageFactory crif;
private ParameterBlock block;
public RenderableImageOp(ContextualRenderedImageFactory crif,
ParameterBlock block)
{
this.crif = crif;
this.block = (ParameterBlock) block.clone();
}
public Vector getSources()
{
if (block.sources == null)
return null;
int size = block.sources.size();
Vector v = new Vector();
for (int i = 0; i < size; i++)
{
Object o = block.sources.get(i);
if (o instanceof RenderableImage)
v.add(o);
}
return v;
}
public Object getProperty(String name)
{
return crif.getProperty(block, name);
}
public String[] getPropertyNames()
{
return crif.getPropertyNames();
}
public boolean isDynamic()
{
return crif.isDynamic();
}
public float getWidth()
{
return (float) crif.getBounds2D(block).getWidth();
}
public float getHeight()
{
return (float) crif.getBounds2D(block).getHeight();
}
public float getMinX()
{
return (float) crif.getBounds2D(block).getX();
}
public float getMinY()
{
return (float) crif.getBounds2D(block).getY();
}
public ParameterBlock setParameterBlock(ParameterBlock block)
{
ParameterBlock result = this.block;
this.block = (ParameterBlock) block.clone();
return result;
}
public ParameterBlock getParameterBlock()
{
return block;
}
public RenderedImage createScaledRendering(int w, int h,
RenderingHints hints)
{
if (w == 0)
if (h == 0)
throw new IllegalArgumentException();
else
w = Math.round(h * getWidth() / getHeight());
if (h == 0)
h = Math.round(w * getHeight() / getWidth());
AffineTransform xform = AffineTransform.getScaleInstance(w * getWidth(),
h * getHeight());
return createRendering(new RenderContext(xform, hints));
}
public RenderedImage createDefaultRendering()
{
return createRendering(new RenderContext(new AffineTransform()));
}
public RenderedImage createRendering(RenderContext context)
{
ParameterBlock copy = (ParameterBlock) block.clone();
int i = block.sources.size();
while (--i >= 0)
{
Object o = block.sources.get(i);
if (o instanceof RenderableImage)
{
RenderableImage ri = (RenderableImage) o;
RenderContext rc = crif.mapRenderContext(i, context, block, ri);
copy.sources.set(i, ri.createRendering(rc));
}
}
// Now copy.sources should be only RenderedImages.
return crif.create(context, copy);
}
} // class RenderableImageOp

View file

@ -0,0 +1,79 @@
/* RenderableImageProducer.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.image.renderable;
import java.awt.image.ImageConsumer;
import java.awt.image.ImageProducer;
public class RenderableImageProducer implements ImageProducer, Runnable
{
public RenderableImageProducer(RenderableImage image, RenderContext context)
{
throw new Error("not implemented");
}
public void setRenderContext(RenderContext context)
{
}
public void addConsumer(ImageConsumer consumer)
{
}
public boolean isConsumer(ImageConsumer consumer)
{
return false;
}
public void removeConsumer(ImageConsumer consumer)
{
}
public void startProduction(ImageConsumer consumer)
{
}
public void requestTopDownLeftRightResend(ImageConsumer consumer)
{
}
public void run()
{
}
} // class RenderableImageProducer

View file

@ -0,0 +1,47 @@
/* RenderedImageFactory.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.awt.image.renderable;
import java.awt.RenderingHints;
import java.awt.image.RenderedImage;
public interface RenderedImageFactory
{
RenderedImage create(ParameterBlock block, RenderingHints hints);
} // interface RenderedImageFactory