[llvm-commits] [llvm-gcc-4.2] r43913 [33/80] - in /llvm-gcc-4.2/trunk: boehm-gc/ boehm-gc/Mac_files/ boehm-gc/cord/ boehm-gc/doc/ boehm-gc/include/ boehm-gc/include/private/ boehm-gc/tests/ libffi/ libffi/include/ libffi/src/ libffi/src/alpha/ libffi/src/arm/ libffi/src/cris/ libffi/src/frv/ libffi/src/ia64/ libffi/src/m32r/ libffi/src/m68k/ libffi/src/mips/ libffi/src/pa/ libffi/src/powerpc/ libffi/src/s390/ libffi/src/sh/ libffi/src/sh64/ libffi/src/sparc/ libffi/src/x86/ libffi/testsuite/ libffi/testsuite/config/ li...
Bill Wendling
isanbard at gmail.com
Thu Nov 8 14:57:11 PST 2007
Added: llvm-gcc-4.2/trunk/libjava/classpath/include/jvmti.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/include/jvmti.h?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/include/jvmti.h (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/include/jvmti.h Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1819 @@
+/* jvmti.h - Java Virtual Machine Tool Interface
+ Copyright (C) 2006 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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. */
+
+
+/* Note: this file must be compilable by the C compiler (for now,
+ assuming GNU C is ok). This means you must never use `//'
+ comments, and all C++-specific code must be conditional on
+ __cplusplus. */
+
+#ifndef _CLASSPATH_JVMTI_H
+#define _CLASSPATH_JVMTI_H
+#include <jni.h>
+
+#include "jvmti_md.h"
+
+/* The VM might define JVMTI base types */
+#ifndef _CLASSPATH_VM_JVMTI_TYPES_DEFINED
+
+typedef jobject jthread;
+typedef jobject jthreadGroup;
+typedef jlong jlocation;
+typedef struct _Jv_rawMonitorID *jrawMonitorID;
+
+#endif /* !_CLASSPATH_VM_JVMTI_TYPES_DEFINED */
+
+/* JVMTI Version */
+#define JVMTI_VERSION_1_0 0x30010000
+#define JVMTI_VERSION (JVMTI_VERSION_1_0 + 38) /* Spec version is 1.0.38 */
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* These functions might be defined in libraries which we load; the
+ JVMTI implementation calls them at the appropriate times. */
+extern JNIEXPORT jint JNICALL Agent_OnLoad (JavaVM *vm, char *options,
+ void *reserved);
+extern JNIEXPORT void JNICALL Agent_OnUnload (JavaVM *vm);
+
+#ifdef __cplusplus
+}
+#endif
+
+/* Forward declarations */
+typedef struct _jvmtiAddrLocationMap jvmtiAddrLocationMap;
+#ifdef __cplusplus
+typedef struct _Jv_JVMTIEnv jvmtiEnv;
+#else
+typedef const struct _Jv_jvmtiEnv *jvmtiEnv;
+#endif
+
+/*
+ * Error constants
+ */
+
+typedef enum
+{
+ /* Universal Errors */
+ JVMTI_ERROR_NONE = 0,
+ JVMTI_ERROR_NULL_POINTER = 100,
+ JVMTI_ERROR_OUT_OF_MEMORY = 110,
+ JVMTI_ERROR_ACCESS_DENIED = 111,
+ JVMTI_ERROR_WRONG_PHASE = 112,
+ JVMTI_ERROR_INTERNAL = 113,
+ JVMTI_ERROR_UNATTACHED_THREAD = 115,
+ JVMTI_ERROR_INVALID_ENVIRONMENT = 116,
+
+ /* Function-specific Required Errors */
+ JVMTI_ERROR_INVALID_PRIORITY = 12,
+ JVMTI_ERROR_THREAD_NOT_SUSPENDED = 13,
+ JVMTI_ERROR_THREAD_SUSPENDED = 14,
+ JVMTI_ERROR_THREAD_NOT_ALIVE = 15,
+ JVMTI_ERROR_CLASS_NOT_PREPARED = 22,
+ JVMTI_ERROR_NO_MORE_FRAMES = 31,
+ JVMTI_ERROR_OPAQUE_FRAME = 32,
+ JVMTI_ERROR_DUPLICATE = 40,
+ JVMTI_ERROR_NOT_FOUND = 41,
+ JVMTI_ERROR_NOT_MONITOR_OWNER = 51,
+ JVMTI_ERROR_INTERRUPT = 52,
+ JVMTI_ERROR_UNMODIFIABLE_CLASS = 79,
+ JVMTI_ERROR_NOT_AVAILABLE = 98,
+ JVMTI_ERROR_ABSENT_INFORMATION = 101,
+ JVMTI_ERROR_INVALID_EVENT_TYPE = 102,
+ JVMTI_ERROR_NATIVE_METHOD = 104,
+
+ /* Function-specific Agent Errors */
+ JVMTI_ERROR_INVALID_THREAD = 10,
+ JVMTI_ERROR_INVALID_THREAD_GROUP = 11,
+ JVMTI_ERROR_INVALID_OBJECT = 20,
+ JVMTI_ERROR_INVALID_CLASS = 21,
+ JVMTI_ERROR_INVALID_METHODID = 23,
+ JVMTI_ERROR_INVALID_LOCATION = 24,
+ JVMTI_ERROR_INVALID_FIELDID = 25,
+ JVMTI_ERROR_TYPE_MISMATCH = 34,
+ JVMTI_ERROR_INVALID_SLOT = 35,
+ JVMTI_ERROR_INVALID_MONITOR = 50,
+ JVMTI_ERROR_INVALID_CLASS_FORMAT = 60,
+ JVMTI_ERROR_CIRCULAR_CLASS_DEFINITION = 61,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_ADDED = 63,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED = 64,
+ JVMTI_ERROR_INVALID_TYPESTATE = 65,
+ JVMTI_ERROR_FAILS_VERIFICATION = 62,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED = 66,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_DELETED = 67,
+ JVMTI_ERROR_UNSUPPORTED_VERSION = 68,
+ JVMTI_ERROR_NAMES_DONT_MATCH = 69,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED = 70,
+ JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED = 71,
+ JVMTI_ERROR_MUST_POSSESS_CAPABILITY = 99,
+ JVMTI_ERROR_ILLEGAL_ARGUMENT = 103
+} jvmtiError;
+
+/*
+ * Enumeration Definitions
+ */
+
+typedef enum
+{
+ JVMTI_DISABLE = 0,
+ JVMTI_ENABLE = 1
+} jvmtiEventMode;
+
+typedef enum
+{
+ JVMTI_HEAP_OBJECT_TAGGED = 1,
+ JVMTI_HEAP_OBJECT_UNTAGGED = 2,
+ JVMTI_HEAP_OBJECT_EITHER = 3
+} jvmtiHeapObjectFilter;
+
+typedef enum
+{
+ JVMTI_HEAP_ROOT_JNI_GLOBAL = 1,
+ JVMTI_HEAP_ROOT_SYSTEM_CLASS = 2,
+ JVMTI_HEAP_ROOT_MONITOR = 3,
+ JVMTI_HEAP_ROOT_STACK_LOCAL = 4,
+ JVMTI_HEAP_ROOT_JNI_LOCAL = 5,
+ JVMTI_HEAP_ROOT_THREAD = 6,
+ JVMTI_HEAP_ROOT_OTHER = 7
+} jvmtiHeapRootKind;
+
+typedef enum
+{
+ JVMTI_ITERATION_ABORT = 0,
+ JVMTI_ITERATION_CONTINUE = 1,
+ JVMTI_ITERATION_IGNORE = 2
+} jvmtiIterationControl;
+
+typedef enum
+{
+ JVMTI_JLOCATION_OTHER = 0,
+ JVMTI_JLOCATION_JVMBCI = 1,
+ JVMTI_JLOCATION_MACHINEPC = 2
+} jvmtiJlocationFormat;
+
+typedef enum
+{
+ JVMTI_REFERENCE_CLASS = 1,
+ JVMTI_REFERENCE_FIELD = 2,
+ JVMTI_REFERENCE_ARRAY_ELEMENT = 3,
+ JVMTI_REFERENCE_CLASS_LOADER = 4,
+ JVMTI_REFERENCE_SIGNERS = 5,
+ JVMTI_REFERENCE_PROTECTION_DOMAIN = 6,
+ JVMTI_REFERENCE_INTERFACE = 7,
+ JVMTI_REFERENCE_STATIC_FIELD = 8,
+ JVMTI_REFERENCE_CONSTANT_POOL = 9
+} jvmtiObjectReferenceKind;
+
+typedef enum
+{
+ JVMTI_KIND_IN = 91,
+ JVMTI_KIND_IN_PTR = 92,
+ JVMTI_KIND_IN_BUF = 93,
+ JVMTI_KIND_ALLOC_BUF = 94,
+ JVMTI_KIND_ALLOC_ALLOC_BUF = 95,
+ JVMTI_KIND_OUT = 96,
+ JVMTI_KIND_OUT_BUF = 97
+} jvmtiParamKind;
+
+typedef enum
+{
+ JVMTI_TYPE_JBYTE = 101,
+ JVMTI_TYPE_JCHAR = 102,
+ JVMTI_TYPE_JSHORT = 103,
+ JVMTI_TYPE_JINT = 104,
+ JVMTI_TYPE_JLONG = 105,
+ JVMTI_TYPE_JFLOAT = 106,
+ JVMTI_TYPE_JDOUBLE = 107,
+ JVMTI_TYPE_JBOOLEAN = 108,
+ JVMTI_TYPE_JOBJECT = 109,
+ JVMTI_TYPE_JTHREAD = 110,
+ JVMTI_TYPE_JCLASS = 111,
+ JVMTI_TYPE_JVALUE = 112,
+ JVMTI_TYPE_JFIELDID = 113,
+ JVMTI_TYPE_JMETHODID = 114,
+ JVMTI_TYPE_CCHAR = 115,
+ JVMTI_TYPE_CVOID = 116,
+ JVMTI_TYPE_JNIENV = 117
+} jvmtiParamTypes;
+
+typedef enum
+{
+ JVMTI_PHASE_ONLOAD = 1,
+ JVMTI_PHASE_PRIMORDIAL = 2,
+ JVMTI_PHASE_LIVE = 4,
+ JVMTI_PHASE_START = 6,
+ JVMTI_PHASE_DEAD = 8
+} jvmtiPhase;
+
+typedef enum
+{
+ JVMTI_TIMER_USER_CPU = 30,
+ JVMTI_TIMER_TOTAL_CPU = 31,
+ JVMTI_TIMER_ELAPSED = 32
+} jvmtiTimerKind;
+
+typedef enum
+{
+ JVMTI_VERBOSE_OTHER = 0,
+ JVMTI_VERBOSE_GC = 1,
+ JVMTI_VERBOSE_CLASS = 2,
+ JVMTI_VERBOSE_JNI = 4
+} jvmtiVerboseFlag;
+
+/* Version information */
+#define JVMTI_VERSION_INTERFACE_JNI 0x00000000
+#define JVMTI_VERSION_INTERFACE_JVMTI 0x30000000
+#define JVMTI_VERSION_MASK_INTERFACE_TYPE 0x70000000
+#define JVMTI_VERSION_MASK_MAJOR 0x0FFF0000
+#define JVMTI_VERSION_MASK_MINOR 0x0000FF00
+#define JVMTI_VERSION_MASK_MICRO 0x000000FF
+#define JVMTI_VERSION_SHIFT_MAJOR 16
+#define JVMTI_VERSION_SHIFT_MINOR 8
+#define JVMTI_VERSION_SHIFT_MICRO 0
+
+/*
+ * Events and event callbacks
+ */
+
+typedef enum
+{
+ JVMTI_EVENT_VM_INIT = 50,
+ JVMTI_EVENT_VM_DEATH = 51,
+ JVMTI_EVENT_THREAD_START = 52,
+ JVMTI_EVENT_THREAD_END = 53,
+ JVMTI_EVENT_CLASS_FILE_LOAD_HOOK = 54,
+ JVMTI_EVENT_CLASS_LOAD = 55,
+ JVMTI_EVENT_CLASS_PREPARE = 56,
+ JVMTI_EVENT_VM_START = 57,
+ JVMTI_EVENT_EXCEPTION = 58,
+ JVMTI_EVENT_EXCEPTION_CATCH = 59,
+ JVMTI_EVENT_SINGLE_STEP = 60,
+ JVMTI_EVENT_FRAME_POP = 61,
+ JVMTI_EVENT_BREAKPOINT = 62,
+ JVMTI_EVENT_FIELD_ACCESS = 63,
+ JVMTI_EVENT_FIELD_MODIFICATION = 64,
+ JVMTI_EVENT_METHOD_ENTRY = 65,
+ JVMTI_EVENT_METHOD_EXIT = 66,
+ JVMTI_EVENT_NATIVE_METHOD_BIND = 67,
+ JVMTI_EVENT_COMPILED_METHOD_LOAD = 68,
+ JVMTI_EVENT_COMPILED_METHOD_UNLOAD = 69,
+ JVMTI_EVENT_DYNAMIC_CODE_GENERATED = 70,
+ JVMTI_EVENT_DATA_DUMP_REQUEST = 71,
+ JVMTI_EVENT_MONITOR_WAIT = 73,
+ JVMTI_EVENT_MONITOR_WAITED = 74,
+ JVMTI_EVENT_MONITOR_CONTENDED_ENTER = 75,
+ JVMTI_EVENT_MONITOR_CONTENDED_ENTERED = 76,
+ JVMTI_EVENT_GARBAGE_COLLECTION_START = 81,
+ JVMTI_EVENT_GARBAGE_COLLECTION_FINISH = 82,
+ JVMTI_EVENT_OBJECT_FREE = 83,
+ JVMTI_EVENT_VM_OBJECT_ALLOC = 84
+} jvmtiEvent;
+
+typedef void *jvmtiEventReserved;
+
+typedef void (JNICALL *jvmtiEventSingleStep)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jlocation location);
+
+typedef void (JNICALL *jvmtiEventBreakpoint)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jlocation location);
+
+typedef void (JNICALL *jvmtiEventFieldAccess)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jlocation location, jclass field_klass, jobject object, jfieldID field);
+
+typedef void (JNICALL *jvmtiEventFieldModification)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jlocation location, jclass field_klass, jobject object, jfieldID field,
+ char signature_type, jvalue new_value);
+
+typedef void (JNICALL *jvmtiEventFramePop)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jboolean was_popped_by_exception);
+
+typedef void (JNICALL *jvmtiEventMethodEntry)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method);
+
+typedef void (JNICALL *jvmtiEventMethodExit)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jboolean was_popped_by_exception, jvalue return_value);
+
+typedef void (JNICALL *jvmtiEventNativeMethodBind)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ void *address, void **new_address_ptr);
+
+typedef void (JNICALL *jvmtiEventException)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jlocation location, jobject exception, jmethodID catch_method,
+ jlocation catch_location);
+
+typedef void (JNICALL *jvmtiEventExceptionCatch)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jmethodID method,
+ jlocation location, jobject exception);
+
+typedef void (JNICALL *jvmtiEventThreadStart)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread);
+
+typedef void (JNICALL *jvmtiEventThreadEnd)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread);
+
+typedef void (JNICALL *jvmtiEventClassLoad)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jclass klass);
+
+typedef void (JNICALL *jvmtiEventClassPrepare)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thraed, jclass klass);
+
+typedef void (JNICALL *jvmtiEventClassFileLoadHook)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jclass class_being_redefined,
+ jobject loader, const char *name, jobject protection_domain,
+ jint class_data_len, const unsigned char *class_data,
+ jint *new_class_data_len, unsigned char **new_class_data);
+
+typedef void (JNICALL *jvmtiEventVMStart)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env);
+
+typedef void (JNICALL *jvmtiEventVMInit)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread);
+
+typedef void (JNICALL *jvmtiEventVMDeath)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env);
+
+typedef void (JNICALL *jvmtiEventCompiledMethodLoad)
+ (jvmtiEnv *jvmti_env, jmethodID method, jint code_size,
+ const void *code_addr, jint map_length, const jvmtiAddrLocationMap *map,
+ const void *compile_info);
+
+typedef void (JNICALL *jvmtiEventCompiledMethodUnload)
+ (jvmtiEnv *jvmti_env, jmethodID method, const void *code_addr);
+
+typedef void (JNICALL *jvmtiEventDynamicCodeGenerated)
+ (jvmtiEnv *jvmti_env, const char *name, const void *address, jint length);
+
+typedef void (JNICALL *jvmtiEventDataDumpRequest)
+ (jvmtiEnv *jvmti_env);
+
+typedef void (JNICALL *jvmtiEventMonitorContendedEnter)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jobject object);
+
+typedef void (JNICALL *jvmtiEventMonitorContendedEntered)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jobject object);
+
+typedef void (JNICALL *jvmtiEventMonitorWait)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jobject object,
+ jlong timeout);
+
+typedef void (JNICALL *jvmtiEventMonitorWaited)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jobject object,
+ jboolean timed_out);
+
+typedef void (JNICALL *jvmtiEventVMObjectAlloc)
+ (jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread, jobject object,
+ jclass object_klass, jlong size);
+
+typedef void (JNICALL *jvmtiEventObjectFree)
+ (jvmtiEnv *jvmti_env, jlong tag);
+
+typedef void (JNICALL *jvmtiEventGarbageCollectionStart)
+ (jvmtiEnv *jvmti_env);
+
+typedef void (JNICALL *jvmtiEventGarbageCollectionFinish)
+ (jvmtiEnv *jvmti_env);
+
+typedef struct
+{
+ jvmtiEventVMInit VMInit;
+ jvmtiEventVMDeath VMDeath;
+ jvmtiEventThreadStart ThreadStart;
+ jvmtiEventThreadEnd ThreadEnd;
+ jvmtiEventClassFileLoadHook ClassFileLoadHook;
+ jvmtiEventClassLoad ClassLoad;
+ jvmtiEventClassPrepare ClassPrepare;
+ jvmtiEventVMStart VMStart;
+ jvmtiEventException Exception;
+ jvmtiEventExceptionCatch ExceptionCatch;
+ jvmtiEventSingleStep SingleStep;
+ jvmtiEventFramePop FramePop;
+ jvmtiEventBreakpoint Breakpoint;
+ jvmtiEventFieldAccess FieldAccess;
+ jvmtiEventFieldModification FieldModification;
+ jvmtiEventMethodEntry MethodEntry;
+ jvmtiEventMethodExit MethodExit;
+ jvmtiEventNativeMethodBind NativeMethodBind;
+ jvmtiEventCompiledMethodLoad CompiledMethodLoad;
+ jvmtiEventCompiledMethodUnload CompiledMethodUnload;
+ jvmtiEventDynamicCodeGenerated DynamicCodeGenerated;
+ jvmtiEventDataDumpRequest DataDumpRequest;
+ jvmtiEventReserved reserved72;
+ jvmtiEventMonitorWait MonitorWait;
+ jvmtiEventMonitorWaited MonitorWaited;
+ jvmtiEventMonitorContendedEnter MonitorContendedEnter;
+ jvmtiEventMonitorContendedEntered MonitorContendedEntered;
+ jvmtiEventReserved reserved77;
+ jvmtiEventReserved reserved78;
+ jvmtiEventReserved reserved79;
+ jvmtiEventReserved reserved80;
+ jvmtiEventGarbageCollectionStart GarbageCollectionStart;
+ jvmtiEventGarbageCollectionFinish GarbageCollectionFinish;
+ jvmtiEventObjectFree ObjectFree;
+ jvmtiEventVMObjectAlloc VMObjectAlloc;
+} jvmtiEventCallbacks;
+
+/*
+ * Function and Structure Type Definitions
+ */
+
+struct _jvmtiAddrLocationMap
+{
+ const void *start_address;
+ jlocation location;
+};
+
+typedef struct
+{
+ unsigned int can_tag_objects : 1;
+ unsigned int can_generate_field_modification_events : 1;
+ unsigned int can_generate_field_access_events : 1;
+ unsigned int can_get_bytecodes : 1;
+ unsigned int can_get_synthetic_attribute : 1;
+ unsigned int can_get_owned_monitor_info : 1;
+ unsigned int can_get_current_contended_monitor : 1;
+ unsigned int can_get_monitor_info : 1;
+ unsigned int can_pop_frame : 1;
+ unsigned int can_redefine_classes : 1;
+ unsigned int can_signal_thread : 1;
+ unsigned int can_get_source_file_name : 1;
+ unsigned int can_get_line_numbers : 1;
+ unsigned int can_get_source_debug_extension : 1;
+ unsigned int can_access_local_variables : 1;
+ unsigned int can_maintain_original_method_order : 1;
+ unsigned int can_generate_single_step_events : 1;
+ unsigned int can_generate_exception_events : 1;
+ unsigned int can_generate_frame_pop_events : 1;
+ unsigned int can_generate_breakpoint_events : 1;
+ unsigned int can_suspend : 1;
+ unsigned int can_redefine_any_class : 1;
+ unsigned int can_get_current_thread_cpu_time : 1;
+ unsigned int can_get_thread_cpu_time : 1;
+ unsigned int can_generate_method_entry_events : 1;
+ unsigned int can_generate_method_exit_events : 1;
+ unsigned int can_generate_all_class_hook_events : 1;
+ unsigned int can_generate_compiled_method_load_events : 1;
+ unsigned int can_generate_monitor_events : 1;
+ unsigned int can_generate_vm_object_alloc_events : 1;
+ unsigned int can_generate_native_method_bind_events : 1;
+ unsigned int can_generate_garbage_collection_events : 1;
+ unsigned int can_generate_object_free_events : 1;
+ unsigned int : 15;
+ unsigned int : 16;
+ unsigned int : 16;
+ unsigned int : 16;
+ unsigned int : 16;
+ unsigned int : 16;
+} jvmtiCapabilities;
+
+typedef struct
+{
+ jclass klass;
+ jint class_byte_count;
+ const unsigned char *class_bytes;
+} jvmtiClassDefinition;
+
+typedef struct
+{
+ char *name;
+ jvmtiParamKind kind;
+ jvmtiParamTypes base_type;
+ jboolean null_ok;
+} jvmtiParamInfo;
+
+typedef struct
+{
+ jint extension_event_index;
+ char *id;
+ char *short_description;
+ jint param_count;
+ jvmtiParamInfo* params;
+} jvmtiExtensionEventInfo;
+
+typedef jvmtiError (JNICALL *jvmtiExtensionFunction)
+ (jvmtiEnv *jvmti_enf, ...);
+
+typedef struct
+{
+ jvmtiExtensionFunction func;
+ char *id;
+ char *short_description;
+ jint param_count;
+ jvmtiParamInfo *params;
+ jint error_count;
+ jvmtiError *errors;
+} jvmtiExtensionFunctionInfo;
+
+typedef struct
+{
+ jmethodID method;
+ jlocation location;
+} jvmtiFrameInfo;
+
+typedef struct
+{
+ jlocation start_location;
+ jint line_number;
+} jvmtiLineNumberEntry;
+
+typedef struct
+{
+ jlocation start_location;
+ jint length;
+ char *name;
+ char *signature;
+ char *generic_signature;
+ jint slot;
+} jvmtiLocalVariableEntry;
+
+typedef struct
+{
+ jthread owner;
+ jint entry_count;
+ jint waiter_count;
+ jthread *waiters;
+ jint notify_waiter_count;
+ jthread *notify_waiters;
+} jvmtiMonitorUsage;
+
+typedef struct
+{
+ jthread thread;
+ jint state;
+ jvmtiFrameInfo *frame_buffer;
+ jint frame_count;
+} jvmtiStackInfo;
+
+typedef struct
+{
+ jthreadGroup parent;
+ char *name;
+ jint max_priority;
+ jboolean is_daemon;
+} jvmtiThreadGroupInfo;
+
+typedef struct
+{
+ char *name;
+ jint priority;
+ jboolean is_daemon;
+ jthreadGroup thread_group;
+ jobject context_class_loader;
+} jvmtiThreadInfo;
+
+typedef struct
+{
+ jlong max_value;
+ jboolean may_skip_forward;
+ jboolean may_skip_backward;
+ jvmtiTimerKind kind;
+ jlong reserved1;
+ jlong reserved2;
+} jvmtiTimerInfo;
+
+typedef void (JNICALL *jvmtiExtensionEvent)
+ (jvmtiEnv *jvmti_env, ...);
+
+typedef jvmtiIterationControl (JNICALL *jvmtiHeapObjectCallback)
+ (jlong class_tag, jlong size, jlong *tag_ptr, void *user_data);
+
+typedef jvmtiIterationControl (JNICALL *jvmtiHeapRootCallback)
+ (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong *tag_ptr,
+ void *user_data);
+
+typedef jvmtiIterationControl (JNICALL *jvmtiObjectReferenceCallback)
+ (jvmtiObjectReferenceKind reference_kind, jlong class_tag, jlong size,
+ jlong *tag_ptr, jlong referrer_tag, jint referrer_index, void *user_data);
+
+typedef jvmtiIterationControl (JNICALL *jvmtiStackReferenceCallback)
+ (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong *tag_ptr,
+ jlong thread_tag, jint depth, jmethodID method, jint slot, void *user_data);
+
+typedef void (JNICALL *jvmtiStartFunction)
+ (jvmtiEnv *env, JNIEnv *jni_env, void *arg);
+
+/*
+ * JVM Tool Interface Base Types
+ */
+typedef struct JNINativeInterface jniNativeInterface;
+
+struct _Jv_jvmtiEnv
+{
+ void *reserved1;
+
+ jvmtiError (JNICALL *SetEventNotificationMode) (jvmtiEnv *env,
+ jvmtiEventMode mode,
+ jvmtiEvent event_type,
+ jthread event_thread, ...);
+ void *reserved3;
+
+ jvmtiError (JNICALL *GetAllThreads) (jvmtiEnv *env,
+ jint *threads_count_ptr,
+ jthread **threads_ptr);
+
+ jvmtiError (JNICALL *SuspendThread) (jvmtiEnv *env,
+ jthread thread);
+
+ jvmtiError (JNICALL *ResumeThread) (jvmtiEnv *env,
+ jthread thread);
+
+ jvmtiError (JNICALL *StopThread) (jvmtiEnv *env,
+ jthread thread,
+ jobject exception);
+
+ jvmtiError (JNICALL *InterruptThread) (jvmtiEnv *env,
+ jthread thread);
+
+ jvmtiError (JNICALL *GetThreadInfo) (jvmtiEnv *env,
+ jthread thread,
+ jvmtiThreadInfo *info_ptr);
+
+ jvmtiError (JNICALL *GetOwnedMonitorInfo) (jvmtiEnv *env,
+ jthread thread,
+ jint *owned_monitor_count_ptr,
+ jobject **owned_monitors_ptr);
+
+ jvmtiError (JNICALL *GetCurrentContendedMonitor) (jvmtiEnv *env,
+ jthread thread,
+ jobject *monitor_ptr);
+
+ jvmtiError (JNICALL *RunAgentThread) (jvmtiEnv *env,
+ jthread thread,
+ jvmtiStartFunction proc,
+ const void *arg,
+ jint priority);
+
+ jvmtiError (JNICALL *GetTopThreadGroups) (jvmtiEnv *env,
+ jint *group_count_ptr,
+ jthreadGroup **groups_ptr);
+
+ jvmtiError (JNICALL *GetThreadGroupInfo) (jvmtiEnv *env,
+ jthreadGroup group,
+ jvmtiThreadGroupInfo *info_ptr);
+
+ jvmtiError (JNICALL *GetThreadGroupChildren) (jvmtiEnv *env,
+ jthreadGroup group,
+ jint *thread_count_ptr,
+ jthread **threads_ptr,
+ jint *group_count_ptr,
+ jthreadGroup **groups_ptr);
+ jvmtiError (JNICALL *GetFrameCount) (jvmtiEnv *env,
+ jthread thread,
+ jint *count_ptr);
+
+ jvmtiError (JNICALL *GetThreadState) (jvmtiEnv *env,
+ jthread thread,
+ jint *thread_state_ptr);
+
+ void *reserved18;
+
+ jvmtiError (JNICALL *GetFrameLocation) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jmethodID *method_ptr,
+ jlocation *location_ptr);
+
+ jvmtiError (JNICALL *NotifyPopFrame) (jvmtiEnv *env,
+ jthread thread,
+ jint depth);
+
+ jvmtiError (JNICALL *GetLocalObject) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jobject *value_ptr);
+
+ jvmtiError (JNICALL *GetLocalInt) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jint *value_ptr);
+
+ jvmtiError (JNICALL *GetLocalLong) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jlong *value_ptr);
+
+ jvmtiError (JNICALL *GetLocalFloat) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jfloat *value_ptr);
+
+ jvmtiError (JNICALL *GetLocalDouble) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jdouble *value_ptr);
+
+ jvmtiError (JNICALL *SetLocalObject) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jobject value);
+
+ jvmtiError (JNICALL *SetLocalInt) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jint value);
+
+ jvmtiError (JNICALL *SetLocalLong) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jlong value);
+
+ jvmtiError (JNICALL *SetLocalFloat) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jfloat value);
+
+ jvmtiError (JNICALL *SetLocalDouble) (jvmtiEnv *env,
+ jthread thread,
+ jint depth,
+ jint slot,
+ jdouble value);
+
+ jvmtiError (JNICALL *CreateRawMonitor) (jvmtiEnv *env,
+ const char *name,
+ jrawMonitorID *monitor_ptr);
+
+ jvmtiError (JNICALL *DestroyRawMonitor) (jvmtiEnv *env,
+ jrawMonitorID monitor);
+
+ jvmtiError (JNICALL *RawMonitorEnter) (jvmtiEnv *env,
+ jrawMonitorID monitor);
+
+ jvmtiError (JNICALL *RawMonitorExit) (jvmtiEnv *env,
+ jrawMonitorID monitor);
+
+ jvmtiError (JNICALL *RawMonitorWait) (jvmtiEnv *env,
+ jrawMonitorID monitor,
+ jlong millis);
+
+ jvmtiError (JNICALL *RawMonitorNotify) (jvmtiEnv *env,
+ jrawMonitorID monitor);
+
+ jvmtiError (JNICALL *RawMonitorNotifyAll) (jvmtiEnv *env,
+ jrawMonitorID monitor);
+
+ jvmtiError (JNICALL *SetBreakpoint) (jvmtiEnv *env,
+ jmethodID method,
+ jlocation location);
+
+ jvmtiError (JNICALL *ClearBreakpoint) (jvmtiEnv *env,
+ jmethodID method,
+ jlocation location);
+
+ void *reserved40;
+
+ jvmtiError (JNICALL *SetFieldAccessWatch) (jvmtiEnv *env,
+ jclass klass,
+ jfieldID field);
+
+ jvmtiError (JNICALL *ClearFieldAccessWatch) (jvmtiEnv *env,
+ jclass klass,
+ jfieldID field);
+
+ jvmtiError (JNICALL *SetFieldModificationWatch) (jvmtiEnv *env,
+ jclass klass,
+ jfieldID field);
+
+ jvmtiError (JNICALL *ClearFieldModificationWatch) (jvmtiEnv *env,
+ jclass klass,
+ jfieldID field);
+
+ void *reserved45;
+
+ jvmtiError (JNICALL *Allocate) (jvmtiEnv *env,
+ jlong size,
+ unsigned char **mem_ptr);
+
+ jvmtiError (JNICALL *Deallocate) (jvmtiEnv *env,
+ unsigned char *mem);
+
+ jvmtiError (JNICALL *GetClassSignature) (jvmtiEnv *env,
+ jclass klass,
+ char **signature_ptr,
+ char **generic_ptr);
+
+ jvmtiError (JNICALL *GetClassStatus) (jvmtiEnv *env,
+ jclass klass,
+ jint *status_ptr);
+
+ jvmtiError (JNICALL *GetSourceFileName) (jvmtiEnv *env,
+ jclass klass,
+ char **source_name_ptr);
+
+ jvmtiError (JNICALL *GetClassModifiers) (jvmtiEnv *env,
+ jclass klass,
+ jint *modifiers_ptr);
+
+ jvmtiError (JNICALL *GetClassMethods) (jvmtiEnv *env,
+ jclass klass,
+ jint *method_count_ptr,
+ jmethodID **methods_ptr);
+
+ jvmtiError (JNICALL *GetClassFields) (jvmtiEnv *env,
+ jclass klass,
+ jint *field_count_ptr,
+ jfieldID **fields_ptr);
+
+ jvmtiError (JNICALL *GetImplementedInterfaces) (jvmtiEnv *env,
+ jclass klass,
+ jint *interface_count_ptr,
+ jclass **interfaces_ptr);
+
+ jvmtiError (JNICALL *IsInterface) (jvmtiEnv *env,
+ jclass klass,
+ jboolean *is_interface_ptr);
+
+ jvmtiError (JNICALL *IsArrayClass) (jvmtiEnv *env,
+ jclass klass,
+ jboolean *is_array_class_ptr);
+
+ jvmtiError (JNICALL *GetClassLoader) (jvmtiEnv *env,
+ jclass klass,
+ jobject *classloader_ptr);
+
+ jvmtiError (JNICALL *GetObjectHashCode) (jvmtiEnv *env,
+ jobject object,
+ jint *hash_code_ptr);
+
+ jvmtiError (JNICALL *GetObjectMonitorUsage) (jvmtiEnv *env,
+ jobject object,
+ jvmtiMonitorUsage *info_ptr);
+
+ jvmtiError (JNICALL *GetFieldName) (jvmtiEnv *env,
+ jclass klass,
+ jfieldID field,
+ char **name_ptr,
+ char **signature_ptr,
+ char **generic_ptr);
+
+ jvmtiError (JNICALL *GetFieldDeclaringClass) (jvmtiEnv *env,
+ jclass klass,
+ jfieldID field,
+ jclass *declaring_class_ptr);
+
+ jvmtiError (JNICALL *GetFieldModifiers) (jvmtiEnv *env,
+ jclass klass,
+ jfieldID field,
+ jint *modifiers_ptr);
+
+ jvmtiError (JNICALL *IsFieldSynthetic) (jvmtiEnv *env,
+ jclass klass,
+ jfieldID field,
+ jboolean *is_synthetic_ptr);
+
+ jvmtiError (JNICALL *GetMethodName) (jvmtiEnv *env,
+ jmethodID method,
+ char **name_ptr,
+ char **signature_ptr,
+ char **generic_ptr);
+
+ jvmtiError (JNICALL *GetMethodDeclaringClass) (jvmtiEnv *env,
+ jmethodID method,
+ jclass *declaring_class_ptr);
+
+
+ jvmtiError (JNICALL *GetMethodModifiers) (jvmtiEnv *env,
+ jmethodID method,
+ jint *modifiers_ptr);
+
+ void *reserved67;
+
+ jvmtiError (JNICALL *GetMaxLocals) (jvmtiEnv *env,
+ jmethodID method,
+ jint *max_ptr);
+
+ jvmtiError (JNICALL *GetArgumentsSize) (jvmtiEnv *env,
+ jmethodID method,
+ jint *size_ptr);
+
+ jvmtiError (JNICALL *GetLineNumberTable) (jvmtiEnv *env,
+ jmethodID method,
+ jint *entry_count_ptr,
+ jvmtiLineNumberEntry **table_ptr);
+
+ jvmtiError (JNICALL *GetMethodLocation) (jvmtiEnv *env,
+ jmethodID method,
+ jlocation *start_location_ptr,
+ jlocation *end_location_ptr);
+
+ jvmtiError (JNICALL *GetLocalVariableTable) (jvmtiEnv *env,
+ jmethodID method,
+ jint *entry_count_ptr,
+ jvmtiLocalVariableEntry **table_ptr);
+
+ void *reserved73;
+
+ void *reserved74;
+
+ jvmtiError (JNICALL *GetBytecodes) (jvmtiEnv *env,
+ jmethodID method,
+ jint *bytecode_count_ptr,
+ unsigned char **bytecodes_ptr);
+
+ jvmtiError (JNICALL *IsMethodNative) (jvmtiEnv *env,
+ jmethodID method,
+ jboolean *is_native_ptr);
+
+ jvmtiError (JNICALL *IsMethodSynthetic) (jvmtiEnv *env,
+ jmethodID method,
+ jboolean *is_synthetic_ptr);
+
+ jvmtiError (JNICALL *GetLoadedClasses) (jvmtiEnv *env,
+ jint *class_count_ptr,
+ jclass **classes_ptr);
+
+ jvmtiError (JNICALL *GetClassLoaderClasses) (jvmtiEnv *env,
+ jobject initiating_loader,
+ jint *class_count_ptr,
+ jclass **classes_ptr);
+
+ jvmtiError (JNICALL *PopFrame) (jvmtiEnv *env,
+ jthread thread);
+
+ void *reserved81;
+
+ void *reserved82;
+
+ void *reserved83;
+
+ void *reserved84;
+
+ void *reserved85;
+
+ void *reserved86;
+
+ jvmtiError (JNICALL *RedefineClasses) (jvmtiEnv *env,
+ jint class_count,
+ const jvmtiClassDefinition* class_definitions);
+
+ jvmtiError (JNICALL *GetVersionNumber) (jvmtiEnv *env,
+ jint *version_ptr);
+
+ jvmtiError (JNICALL *GetCapabilities) (jvmtiEnv *env,
+ jvmtiCapabilities *capabilities_ptr);
+
+ jvmtiError (JNICALL *GetSourceDebugExtension) (jvmtiEnv *env,
+ jclass klass,
+ char **source_debug_extension_ptr);
+
+ jvmtiError (JNICALL *IsMethodObsolete) (jvmtiEnv *env,
+ jmethodID method,
+ jboolean *is_obsolete_ptr);
+
+ jvmtiError (JNICALL *SuspendThreadList) (jvmtiEnv *env,
+ jint request_count,
+ const jthread *request_list,
+ jvmtiError *results);
+
+ jvmtiError (JNICALL *ResumeThreadList) (jvmtiEnv *env,
+ jint request_count,
+ const jthread *request_list,
+ jvmtiError *results);
+
+ void *reserved94;
+
+ void *reserved95;
+
+ void *reserved96;
+
+ void *reserved97;
+
+ void *reserved98;
+
+ void *reserved99;
+
+ jvmtiError (JNICALL *GetAllStackTraces) (jvmtiEnv *env,
+ jint max_frame_count,
+ jvmtiStackInfo **stack_info_ptr,
+ jint *thread_count_ptr);
+
+ jvmtiError (JNICALL *GetThreadListStackTraces) (jvmtiEnv *env,
+ jint thread_count,
+ const jthread *thread_list,
+ jint max_frame_count,
+ jvmtiStackInfo **stack_info_ptr);
+
+ jvmtiError (JNICALL *GetThreadLocalStorage) (jvmtiEnv *env,
+ jthread thread,
+ void **data_ptr);
+
+ jvmtiError (JNICALL *SetThreadLocalStorage) (jvmtiEnv *env,
+ jthread thread,
+ const void *data);
+
+ jvmtiError (JNICALL *GetStackTrace) (jvmtiEnv *env,
+ jthread thread,
+ jint start_depth,
+ jint max_frame_count,
+ jvmtiFrameInfo *frame_buffer,
+ jint *count_ptr);
+
+ void *reserved105;
+
+ jvmtiError (JNICALL *GetTag) (jvmtiEnv *env,
+ jobject object,
+ jlong *tag_ptr);
+
+ jvmtiError (JNICALL *SetTag) (jvmtiEnv *env,
+ jobject object,
+ jlong tag);
+
+ jvmtiError (JNICALL *ForceGarbageCollection) (jvmtiEnv *env);
+
+ jvmtiError (JNICALL *IterateOverObjectsReachableFromObject) (jvmtiEnv *env,
+ jobject object,
+ jvmtiObjectReferenceCallback object_reference_callback,
+ void *user_data);
+
+ jvmtiError (JNICALL *IterateOverReachableObjects) (jvmtiEnv *env,
+ jvmtiHeapRootCallback heap_root_callback,
+ jvmtiStackReferenceCallback stack_ref_callback,
+ jvmtiObjectReferenceCallback object_ref_callback,
+ void *user_data);
+
+ jvmtiError (JNICALL *IterateOverHeap) (jvmtiEnv *env,
+ jvmtiHeapObjectFilter object_filter,
+ jvmtiHeapObjectCallback heap_object_callback,
+ void *user_data);
+
+ jvmtiError (JNICALL *IterateOverInstanceOfClass) (jvmtiEnv *env,
+ jclass klass,
+ jvmtiHeapObjectFilter object_filter,
+ jvmtiHeapObjectCallback heap_object_callback,
+ void *user_data);
+
+ void *reserved113;
+
+ jvmtiError (JNICALL *GetObjectsWithTags) (jvmtiEnv *env,
+ jint tag_count,
+ const jlong *tags,
+ jint *count_ptr,
+ jobject **object_result_ptr,
+ jlong **tag_result_ptr);
+
+ void *reserved115;
+
+ void *reserved116;
+
+ void *reserved117;
+
+ void *reserved118;
+
+ void *reserved119;
+
+ jvmtiError (JNICALL *SetJNIFunctionTable) (jvmtiEnv *env,
+ const jniNativeInterface *function_table);
+
+ jvmtiError (JNICALL *GetJNIFunctionTable) (jvmtiEnv *env,
+ jniNativeInterface **function_table_ptr);
+
+ jvmtiError (JNICALL *SetEventCallbacks) (jvmtiEnv *env,
+ const jvmtiEventCallbacks *callbacks,
+ jint size_of_callbacks);
+
+ jvmtiError (JNICALL *GenerateEvents) (jvmtiEnv *env,
+ jvmtiEvent event_type);
+
+ jvmtiError (JNICALL *GetExtensionFunctions) (jvmtiEnv *env,
+ jint *extension_count_ptr,
+ jvmtiExtensionFunctionInfo **extensions);
+
+ jvmtiError (JNICALL *GetExtensionEvents) (jvmtiEnv *env,
+ jint *extension_count_ptr,
+ jvmtiExtensionEventInfo **extensions);
+
+ jvmtiError (JNICALL *SetExtensionEventCallback) (jvmtiEnv *env,
+ jint extension_event_index,
+ jvmtiExtensionEvent callback);
+
+ jvmtiError (JNICALL *DisposeEnvironment) (jvmtiEnv *env);
+
+ jvmtiError (JNICALL *GetErrorName) (jvmtiEnv *env,
+ jvmtiError error,
+ char **name_ptr);
+
+ jvmtiError (JNICALL *GetJLocationFormat) (jvmtiEnv *env,
+ jvmtiJlocationFormat *format_ptr);
+
+ jvmtiError (JNICALL *GetSystemProperties) (jvmtiEnv *env,
+ jint *count_ptr,
+ char ***property_ptr);
+
+ jvmtiError (JNICALL *GetSystemProperty) (jvmtiEnv *env,
+ const char *property,
+ char **value_ptr);
+
+ jvmtiError (JNICALL *SetSystemProperty) (jvmtiEnv *env,
+ const char *property,
+ const char *value);
+
+ jvmtiError (JNICALL *GetPhase) (jvmtiEnv *env,
+ jvmtiPhase *phase_ptr);
+
+ jvmtiError (JNICALL *GetCurrentThreadCpuTimerInfo) (jvmtiEnv *env,
+ jvmtiTimerInfo *info_ptr);
+
+ jvmtiError (JNICALL *GetCurrentThreadCpuTime) (jvmtiEnv *env,
+ jlong *nanos_ptr);
+
+ jvmtiError (JNICALL *GetThreadCpuTimerInfo) (jvmtiEnv *env,
+ jvmtiTimerInfo *info_ptr);
+
+ jvmtiError (JNICALL *GetThreadCpuTime) (jvmtiEnv *env,
+ jthread thread,
+ jlong *nanos_ptr);
+
+ jvmtiError (JNICALL *GetTimerInfo) (jvmtiEnv *env,
+ jvmtiTimerInfo *info_ptr);
+
+ jvmtiError (JNICALL *GetTime) (jvmtiEnv *env,
+ jlong *nanos_ptr);
+
+ jvmtiError (JNICALL *GetPotentialCapabilities) (jvmtiEnv *env,
+ jvmtiCapabilities *capabilities_ptr);
+
+ void *reserved141;
+
+ jvmtiError (JNICALL *AddCapabilities) (jvmtiEnv *env,
+ const jvmtiCapabilities *capabilities_ptr);
+
+ jvmtiError (JNICALL *RelinquishCapabilities) (jvmtiEnv *env,
+ const jvmtiCapabilities *capabilities_ptr);
+
+ jvmtiError (JNICALL *GetAvailableProcessors) (jvmtiEnv *env,
+ jint *processor_count_ptr);
+
+ void *reserved145;
+
+ void *reserved146;
+
+ jvmtiError (JNICALL *GetEnvironmentLocalStorage) (jvmtiEnv *env,
+ void **data_ptr);
+
+ jvmtiError (JNICALL *SetEnvironmentLocalStorage) (jvmtiEnv *env,
+ const void *data);
+
+ jvmtiError (JNICALL *AddToBootstrapClassLoaderSearch) (jvmtiEnv *env,
+ const char *segment);
+
+ jvmtiError (JNICALL *SetVerboseFlag) (jvmtiEnv *env,
+ jvmtiVerboseFlag flag,
+ jboolean value);
+
+ void *reserved151;
+
+ void *reserved152;
+
+ void *reserved153;
+
+ jvmtiError (JNICALL *GetObjectSize) (jvmtiEnv *env,
+ jobject object,
+ jlong *size_ptr);
+};
+
+#ifdef __cplusplus
+class _Jv_JVMTIEnv
+{
+ public:
+ /* Method table */
+ struct _Jv_jvmtiEnv *p;
+
+#ifdef _CLASSPATH_JVMTIENV_CONTENTS
+ _CLASSPATH_JVMTIENV_CONTENTS
+#endif
+
+ jvmtiError SetEventNotificationMode (jvmtiEventMode mode,
+ jvmtiEvent event_type,
+ jthread event_thread, ...)
+ {
+ va_list args;
+ va_start (args, event_thread);
+ jvmtiError result = p->SetEventNotificationMode (this, mode, event_type,
+ event_thread, args);
+ va_end (args);
+ return result;
+ }
+
+ jvmtiError GetAllThreads (jint *threads_count_ptr, jthread **threads_ptr)
+ { return p->GetAllThreads (this, threads_count_ptr, threads_ptr); }
+
+ jvmtiError SuspendThread (jthread thread)
+ { return p->SuspendThread (this, thread); }
+
+ jvmtiError ResumeThread (jthread thread)
+ { return p->ResumeThread (this, thread); }
+
+ jvmtiError StopThread (jthread thread, jobject exception)
+ { return p->StopThread (this, thread, exception); }
+
+ jvmtiError InterruptThread (jthread thread)
+ { return p->InterruptThread (this, thread); }
+
+ jvmtiError GetThreadInfo (jthread thread, jvmtiThreadInfo *info_ptr)
+ { return p->GetThreadInfo (this, thread, info_ptr); }
+
+ jvmtiError GetOwnedMonitorInfo (jthread thread,
+ jint *owned_monitor_count_ptr,
+ jobject **owned_monitors_ptr)
+ {
+ return p->GetOwnedMonitorInfo (this, thread, owned_monitor_count_ptr,
+ owned_monitors_ptr);
+ }
+
+ jvmtiError GetCurrentContendedMonitor (jthread thread, jobject *monitor_ptr)
+ { return p->GetCurrentContendedMonitor (this, thread, monitor_ptr); }
+
+ jvmtiError RunAgentThread (jthread thread, jvmtiStartFunction proc,
+ const void *arg, jint priority)
+ { return p->RunAgentThread (this, thread, proc, arg, priority); }
+
+ jvmtiError GetTopThreadGroups (jint *group_count_ptr,
+ jthreadGroup **groups_ptr)
+ { return p->GetTopThreadGroups (this, group_count_ptr, groups_ptr); }
+
+ jvmtiError GetThreadGroupInfo (jthreadGroup group,
+ jvmtiThreadGroupInfo *info_ptr)
+ { return p->GetThreadGroupInfo (this, group, info_ptr); }
+
+ jvmtiError GetThreadGroupChildren (jthreadGroup group,
+ jint *thread_count_ptr,
+ jthread **threads_ptr,
+ jint *group_count_ptr,
+ jthreadGroup **groups_ptr)
+ {
+ return p->GetThreadGroupChildren (this, group, thread_count_ptr,
+ threads_ptr, group_count_ptr,
+ groups_ptr);
+ }
+
+ jvmtiError GetFrameCount (jthread thread, jint *count_ptr)
+ { return p->GetFrameCount (this, thread, count_ptr); }
+
+ jvmtiError GetThreadState (jthread thread, jint *thread_state_ptr)
+ { return p->GetThreadState (this, thread, thread_state_ptr); }
+
+ jvmtiError GetFrameLocation (jthread thread, jint depth,
+ jmethodID *method_ptr, jlocation *location_ptr)
+ {
+ return p->GetFrameLocation (this, thread, depth, method_ptr,
+ location_ptr);
+ }
+
+ jvmtiError NotifyPopFrame (jthread thread, jint depth)
+ { return p->NotifyPopFrame (this, thread, depth); }
+
+ jvmtiError GetLocalObject (jthread thread, jint depth, jint slot,
+ jobject *value_ptr)
+ { return p->GetLocalObject (this, thread, depth, slot, value_ptr); }
+
+ jvmtiError GetLocalInt (jthread thread, jint depth, jint slot,
+ jint *value_ptr)
+ { return p->GetLocalInt (this, thread, depth, slot, value_ptr); }
+
+ jvmtiError GetLocalLong (jthread thread, jint depth, jint slot,
+ jlong *value_ptr)
+ { return p->GetLocalLong (this, thread, depth, slot, value_ptr); }
+
+ jvmtiError GetLocalFloat (jthread thread, jint depth, jint slot,
+ jfloat *value_ptr)
+ { return p->GetLocalFloat (this, thread, depth, slot, value_ptr); }
+
+ jvmtiError GetLocalDouble (jthread thread, jint depth, jint slot,
+ jdouble *value_ptr)
+ { return p->GetLocalDouble (this, thread, depth, slot, value_ptr); }
+
+ jvmtiError SetLocalObject (jthread thread, jint depth, jint slot,
+ jobject value)
+ { return p->SetLocalObject (this, thread, depth, slot, value); }
+
+ jvmtiError SetLocalInt (jthread thread, jint depth, jint slot,
+ jint value)
+ { return p->SetLocalInt (this, thread, depth, slot, value); }
+
+ jvmtiError SetLocalLong (jthread thread, jint depth, jint slot,
+ jlong value)
+ { return p->SetLocalLong (this, thread, depth, slot, value); }
+
+ jvmtiError SetLocalFloat (jthread thread, jint depth, jint slot,
+ jfloat value)
+ { return p->SetLocalFloat (this, thread, depth, slot, value); }
+
+ jvmtiError SetLocalDouble (jthread thread, jint depth, jint slot,
+ jdouble value)
+ { return p->SetLocalDouble (this, thread, depth, slot, value); }
+
+ jvmtiError CreateRawMonitor (const char *name, jrawMonitorID *monitor_ptr)
+ { return p->CreateRawMonitor (this, name, monitor_ptr); }
+
+ jvmtiError DestroyRawMonitor (jrawMonitorID monitor)
+ { return p->DestroyRawMonitor (this, monitor); }
+
+ jvmtiError RawMonitorEnter (jrawMonitorID monitor)
+ { return p->RawMonitorEnter (this, monitor); }
+
+ jvmtiError RawMonitorExit (jrawMonitorID monitor)
+ { return p->RawMonitorExit (this, monitor); }
+
+ jvmtiError RawMonitorWait (jrawMonitorID monitor, jlong millis)
+ { return p->RawMonitorWait (this, monitor, millis); }
+
+ jvmtiError RawMonitorNotify (jrawMonitorID monitor)
+ { return p->RawMonitorNotify (this, monitor); }
+
+ jvmtiError RawMonitorNotifyAll (jrawMonitorID monitor)
+ { return p->RawMonitorNotifyAll (this, monitor); }
+
+ jvmtiError SetBreakpoint (jmethodID method, jlocation location)
+ { return p->SetBreakpoint (this, method, location); }
+
+ jvmtiError ClearBreakpoint (jmethodID method, jlocation location)
+ { return p->ClearBreakpoint (this, method, location); }
+
+ jvmtiError SetFieldAccessWatch (jclass klass, jfieldID field)
+ { return p->SetFieldAccessWatch (this, klass, field); }
+
+ jvmtiError ClearFieldAccessWatch (jclass klass, jfieldID field)
+ { return p->ClearFieldAccessWatch (this, klass, field); }
+
+ jvmtiError SetFieldModificationWatch (jclass klass, jfieldID field)
+ { return p->SetFieldModificationWatch (this, klass, field); }
+
+ jvmtiError ClearFieldModificationWatch (jclass klass, jfieldID field)
+ { return p->ClearFieldModificationWatch (this, klass, field); }
+
+ jvmtiError Allocate (jlong size, unsigned char **mem_ptr)
+ { return p->Allocate (this, size, mem_ptr); }
+
+ jvmtiError Deallocate (unsigned char *mem)
+ { return p->Deallocate (this, mem); }
+
+ jvmtiError GetClassSignature (jclass klass, char **signature_ptr,
+ char **generic_ptr)
+ { return p->GetClassSignature (this, klass, signature_ptr, generic_ptr); }
+
+ jvmtiError GetClassStatus (jclass klass, jint *status_ptr)
+ { return p->GetClassStatus (this, klass, status_ptr); }
+
+ jvmtiError GetSourceFileName (jclass klass, char **source_name_ptr)
+ { return p->GetSourceFileName (this, klass, source_name_ptr); }
+
+ jvmtiError GetClassModifiers (jclass klass, jint *modifiers_ptr)
+ { return p->GetClassModifiers (this, klass, modifiers_ptr); }
+
+ jvmtiError GetClassMethods (jclass klass, jint *method_count_ptr,
+ jmethodID **methods_ptr)
+ { return p->GetClassMethods (this, klass, method_count_ptr, methods_ptr); }
+
+ jvmtiError GetClassFields (jclass klass, jint *field_count_ptr,
+ jfieldID **fields_ptr)
+ { return p->GetClassFields (this, klass, field_count_ptr, fields_ptr); }
+
+ jvmtiError GetImplementedInterfaces (jclass klass,
+ jint *interface_count_ptr,
+ jclass **interfaces_ptr)
+ {
+ return p->GetImplementedInterfaces (this, klass, interface_count_ptr,
+ interfaces_ptr);
+ }
+
+ jvmtiError IsInterface (jclass klass, jboolean *is_interface_ptr)
+ { return p->IsInterface (this, klass, is_interface_ptr); }
+
+ jvmtiError IsArrayClass (jclass klass, jboolean *is_array_class_ptr)
+ { return p->IsArrayClass (this, klass, is_array_class_ptr); }
+
+ jvmtiError GetClassLoader (jclass klass, jobject *classloader_ptr)
+ { return p->GetClassLoader (this, klass, classloader_ptr); }
+
+ jvmtiError GetObjectHashCode (jobject object, jint *hash_code_ptr)
+ { return p->GetObjectHashCode (this, object, hash_code_ptr); }
+
+ jvmtiError GetObjectMonitorUsage (jobject object,
+ jvmtiMonitorUsage *info_ptr)
+ { return p->GetObjectMonitorUsage (this, object, info_ptr); }
+
+ jvmtiError GetFieldName (jclass klass, jfieldID field, char **name_ptr,
+ char **signature_ptr, char **generic_ptr)
+ {
+ return p->GetFieldName (this, klass, field, name_ptr,
+ signature_ptr, generic_ptr);
+ }
+
+ jvmtiError GetFieldDeclaringClass (jclass klass, jfieldID field,
+ jclass *declaring_class_ptr)
+ {
+ return p->GetFieldDeclaringClass (this, klass, field,
+ declaring_class_ptr);
+ }
+
+ jvmtiError GetFieldModifiers (jclass klass, jfieldID field,
+ jint *modifiers_ptr)
+ { return p->GetFieldModifiers (this, klass, field, modifiers_ptr); }
+
+ jvmtiError IsFieldSynthetic (jclass klass, jfieldID field,
+ jboolean *is_synthetic_ptr)
+ { return p->IsFieldSynthetic (this, klass, field, is_synthetic_ptr); }
+
+ jvmtiError GetMethodName (jmethodID method, char **name_ptr,
+ char **signature_ptr, char **generic_ptr)
+ {
+ return p->GetMethodName (this, method, name_ptr, signature_ptr,
+ generic_ptr);
+ }
+
+ jvmtiError GetMethodDeclaringClass (jmethodID method,
+ jclass *declaring_class_ptr)
+ { return p->GetMethodDeclaringClass (this, method, declaring_class_ptr); }
+
+
+ jvmtiError GetMethodModifiers (jmethodID method, jint *modifiers_ptr)
+ { return p->GetMethodModifiers (this, method, modifiers_ptr); }
+
+ jvmtiError GetMaxLocals (jmethodID method, jint *max_ptr)
+ { return p->GetMaxLocals (this, method, max_ptr); }
+
+ jvmtiError GetArgumentsSize (jmethodID method, jint *size_ptr)
+ { return p->GetArgumentsSize (this, method, size_ptr); }
+
+ jvmtiError GetLineNumberTable (jmethodID method, jint *entry_count_ptr,
+ jvmtiLineNumberEntry **table_ptr)
+ { return p->GetLineNumberTable (this, method, entry_count_ptr, table_ptr); }
+
+ jvmtiError GetMethodLocation (jmethodID method,
+ jlocation *start_location_ptr,
+ jlocation *end_location_ptr)
+ {
+ return p->GetMethodLocation (this, method, start_location_ptr,
+ end_location_ptr);
+ }
+
+ jvmtiError GetLocalVariableTable (jmethodID method, jint *entry_count_ptr,
+ jvmtiLocalVariableEntry **table_ptr)
+ {
+ return p->GetLocalVariableTable (this, method, entry_count_ptr,
+ table_ptr);
+ }
+
+ jvmtiError GetBytecodes (jmethodID method, jint *bytecode_count_ptr,
+ unsigned char **bytecodes_ptr)
+ {
+ return p->GetBytecodes (this, method, bytecode_count_ptr,
+ bytecodes_ptr);
+ }
+
+ jvmtiError IsMethodNative (jmethodID method, jboolean *is_native_ptr)
+ { return p->IsMethodNative (this, method, is_native_ptr); }
+
+ jvmtiError IsMethodSynthetic (jmethodID method, jboolean *is_synthetic_ptr)
+ { return p->IsMethodSynthetic (this, method, is_synthetic_ptr); }
+
+ jvmtiError GetLoadedClasses (jint *class_count_ptr, jclass **classes_ptr)
+ { return p->GetLoadedClasses (this, class_count_ptr, classes_ptr); }
+
+ jvmtiError GetClassLoaderClasses (jobject initiating_loader,
+ jint *class_count_ptr,
+ jclass **classes_ptr)
+ {
+ return p->GetClassLoaderClasses (this, initiating_loader,
+ class_count_ptr, classes_ptr);
+ }
+
+ jvmtiError PopFrame (jthread thread)
+ { return p->PopFrame (this, thread); }
+
+ jvmtiError RedefineClasses (jint class_count,
+ const jvmtiClassDefinition* class_definitions)
+ { return p->RedefineClasses (this, class_count, class_definitions); }
+
+ jvmtiError GetVersionNumber (jint *version_ptr)
+ { return p->GetVersionNumber (this, version_ptr); }
+
+ jvmtiError GetCapabilities (jvmtiCapabilities *capabilities_ptr)
+ { return p->GetCapabilities (this, capabilities_ptr); }
+
+ jvmtiError GetSourceDebugExtension (jclass klass,
+ char **source_debug_extension_ptr)
+ {
+ return p->GetSourceDebugExtension (this, klass,
+ source_debug_extension_ptr);
+ }
+
+ jvmtiError IsMethodObsolete (jmethodID method, jboolean *is_obsolete_ptr)
+ { return p->IsMethodObsolete (this, method, is_obsolete_ptr); }
+
+
+ jvmtiError SuspendThreadList (jint request_count,
+ const jthread *request_list,
+ jvmtiError *results)
+ { return p->SuspendThreadList (this, request_count, request_list, results); }
+
+ jvmtiError ResumeThreadList (jint request_count,
+ const jthread *request_list,
+ jvmtiError *results)
+ { return p->ResumeThreadList (this, request_count, request_list, results); }
+
+ jvmtiError GetAllStackTraces (jint max_frame_count,
+ jvmtiStackInfo **stack_info_ptr,
+ jint *thread_count_ptr)
+ {
+ return p->GetAllStackTraces (this, max_frame_count, stack_info_ptr,
+ thread_count_ptr);
+ }
+
+ jvmtiError GetThreadListStackTraces (jint thread_count,
+ const jthread *thread_list,
+ jint max_frame_count,
+ jvmtiStackInfo **stack_info_ptr)
+ {
+ return p->GetThreadListStackTraces (this, thread_count, thread_list,
+ max_frame_count, stack_info_ptr);
+ }
+
+ jvmtiError GetThreadLocalStorage (jthread thread, void **data_ptr)
+ { return p->GetThreadLocalStorage (this, thread, data_ptr); }
+
+ jvmtiError SetThreadLocalStorage (jthread thread, const void *data)
+ { return p->SetThreadLocalStorage (this, thread, data); }
+
+ jvmtiError GetStackTrace (jthread thread, jint start_depth,
+ jint max_frame_count,
+ jvmtiFrameInfo *frame_buffer, jint *count_ptr)
+ {
+ return p->GetStackTrace (this, thread, start_depth, max_frame_count,
+ frame_buffer, count_ptr);
+ }
+
+ jvmtiError GetTag (jobject object, jlong *tag_ptr)
+ { return p->GetTag (this, object, tag_ptr); }
+
+ jvmtiError SetTag (jobject object, jlong tag)
+ { return p->SetTag (this, object, tag); }
+
+ jvmtiError ForceGarbageCollection (void)
+ { return p->ForceGarbageCollection (this); }
+
+ jvmtiError IterateOverObjectsReachableFromObject (jobject object,
+ jvmtiObjectReferenceCallback object_reference_callback,
+ void *user_data)
+ {
+ return p->IterateOverObjectsReachableFromObject (this, object,
+ object_reference_callback,
+ user_data);
+ }
+
+ jvmtiError IterateOverReachableObjects (jvmtiHeapRootCallback heap_root_callback,
+ jvmtiStackReferenceCallback stack_ref_callback,
+ jvmtiObjectReferenceCallback object_ref_callback,
+ void *user_data)
+ {
+ return p->IterateOverReachableObjects (this, heap_root_callback,
+ stack_ref_callback,
+ object_ref_callback,
+ user_data);
+ }
+
+ jvmtiError IterateOverHeap (jvmtiHeapObjectFilter object_filter,
+ jvmtiHeapObjectCallback heap_object_callback,
+ void *user_data)
+ {
+ return p->IterateOverHeap (this, object_filter, heap_object_callback,
+ user_data);
+ }
+
+ jvmtiError IterateOverInstanceOfClass (jclass klass,
+ jvmtiHeapObjectFilter object_filter,
+ jvmtiHeapObjectCallback heap_object_callback,
+ void *user_data)
+ {
+ return p->IterateOverInstanceOfClass (this, klass, object_filter,
+ heap_object_callback, user_data);
+ }
+
+ jvmtiError GetObjectsWithTags (jint tag_count, const jlong *tags,
+ jint *count_ptr, jobject **object_result_ptr,
+ jlong **tag_result_ptr)
+ {
+ return p->GetObjectsWithTags (this, tag_count, tags, count_ptr,
+ object_result_ptr, tag_result_ptr);
+ }
+
+ jvmtiError SetJNIFunctionTable (const jniNativeInterface *function_table)
+ { return p->SetJNIFunctionTable (this, function_table); }
+
+ jvmtiError GetJNIFunctionTable (jniNativeInterface **function_table_ptr)
+ { return p->GetJNIFunctionTable (this, function_table_ptr); }
+
+ jvmtiError SetEventCallbacks (const jvmtiEventCallbacks *callbacks,
+ jint size_of_callbacks)
+ { return p->SetEventCallbacks (this, callbacks, size_of_callbacks); }
+
+ jvmtiError GenerateEvents (jvmtiEvent event_type)
+ { return p->GenerateEvents (this, event_type); }
+
+ jvmtiError GetExtensionFunctions (jint *extension_count_ptr,
+ jvmtiExtensionFunctionInfo **extensions)
+ { return p->GetExtensionFunctions (this, extension_count_ptr, extensions); }
+
+ jvmtiError GetExtensionEvents (jint *extension_count_ptr,
+ jvmtiExtensionEventInfo **extensions)
+ { return p->GetExtensionEvents (this, extension_count_ptr, extensions); }
+
+ jvmtiError SetExtensionEventCallback (jint extension_event_index,
+ jvmtiExtensionEvent callback)
+ {
+ return p->SetExtensionEventCallback (this, extension_event_index,
+ callback);
+ }
+
+ jvmtiError DisposeEnvironment (void)
+ { return p->DisposeEnvironment (this); }
+
+ jvmtiError GetErrorName (jvmtiError error, char **name_ptr)
+ { return p->GetErrorName (this, error, name_ptr); }
+
+ jvmtiError GetJLocationFormat (jvmtiJlocationFormat *format_ptr)
+ { return p->GetJLocationFormat (this, format_ptr); }
+
+ jvmtiError GetSystemProperties (jint *count_ptr, char ***property_ptr)
+ { return p->GetSystemProperties (this, count_ptr, property_ptr); }
+
+ jvmtiError GetSystemProperty (const char *property, char **value_ptr)
+ { return p->GetSystemProperty (this, property, value_ptr); }
+
+ jvmtiError SetSystemProperty (const char *property, const char *value)
+ { return p->SetSystemProperty (this, property, value); }
+
+ jvmtiError GetPhase (jvmtiPhase *phase_ptr)
+ { return p->GetPhase (this, phase_ptr); }
+
+ jvmtiError GetCurrentThreadCpuTimerInfo (jvmtiTimerInfo *info_ptr)
+ { return p->GetCurrentThreadCpuTimerInfo (this, info_ptr); }
+
+ jvmtiError GetCurrentThreadCpuTime (jlong *nanos_ptr)
+ { return p->GetCurrentThreadCpuTime (this, nanos_ptr); }
+
+ jvmtiError GetThreadCpuTimerInfo (jvmtiTimerInfo *info_ptr)
+ { return p->GetThreadCpuTimerInfo (this, info_ptr); }
+
+ jvmtiError GetThreadCpuTime (jthread thread, jlong *nanos_ptr)
+ { return p->GetThreadCpuTime (this, thread, nanos_ptr); }
+
+ jvmtiError GetTimerInfo (jvmtiTimerInfo *info_ptr)
+ { return p->GetTimerInfo (this, info_ptr); }
+
+ jvmtiError GetTime (jlong *nanos_ptr)
+ {return p->GetTime (this, nanos_ptr); }
+
+ jvmtiError GetPotentialCapabilities (jvmtiCapabilities *capabilities_ptr)
+ { return p->GetPotentialCapabilities (this, capabilities_ptr); }
+
+ jvmtiError AddCapabilities (const jvmtiCapabilities *capabilities_ptr)
+ { return p->AddCapabilities (this, capabilities_ptr); }
+
+ jvmtiError RelinquishCapabilities (const jvmtiCapabilities *capabilities_ptr)
+ { return p->RelinquishCapabilities (this, capabilities_ptr); }
+
+ jvmtiError GetAvailableProcessors (jint *processor_count_ptr)
+ { return p->GetAvailableProcessors (this, processor_count_ptr); }
+
+ jvmtiError GetEnvironmentLocalStorage (void **data_ptr)
+ { return p->GetEnvironmentLocalStorage (this, data_ptr); }
+
+ jvmtiError SetEnvironmentLocalStorage (const void *data)
+ { return p->SetEnvironmentLocalStorage (this, data); }
+
+ jvmtiError AddToBootstrapClassLoaderSearch (const char *segment)
+ { return p->AddToBootstrapClassLoaderSearch (this, segment); }
+
+ jvmtiError SetVerboseFlag (jvmtiVerboseFlag flag, jboolean value)
+ { return p->SetVerboseFlag (this, flag, value); }
+
+ jvmtiError GetObjectSize (jobject object, jlong *size_ptr)
+ { return p->GetObjectSize (this, object, size_ptr); }
+};
+#endif /* __cplusplus */
+
+/*
+ * Miscellaneous flags, constants, etc
+ */
+
+/* Class status flags */
+#define JVMTI_CLASS_STATUS_VERIFIED 1
+#define JVMTI_CLASS_STATUS_PREPARED 2
+#define JVMTI_CLASS_STATUS_INITIALIZED 4
+#define JVMTI_CLASS_STATUS_ERROR 8
+#define JVMTI_CLASS_STATUS_ARRAY 16
+#define JVMTI_CLASS_STATUS_PRIMITIVE 32
+
+/* Thread state flags */
+#define JVMTI_THREAD_STATE_ALIVE 0x0001
+#define JVMTI_THREAD_STATE_TERMINATED 0x0002
+#define JVMTI_THREAD_STATE_RUNNABLE 0x0004
+#define JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER 0x0400
+#define JVMTI_THREAD_STATE_WAITING 0x0080
+#define JVMTI_THREAD_STATE_WAITING_INDEFINITELY 0x0010
+#define JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT 0x0020
+#define JVMTI_THREAD_STATE_SLEEPING 0x0040
+#define JVMTI_THREAD_STATE_IN_OBJECT_WAIT 0x0100
+#define JVMTI_THREAD_STATE_PARKED 0x0200
+#define JVMTI_THREAD_STATE_SUSPENDED 0x100000
+#define JVMTI_THREAD_STATE_INTERRUPTED 0x200000
+#define JVMTI_THREAD_STATE_IN_NATIVE 0x400000
+#define JVMTI_THREAD_STATE_VENDOR_1 0x10000000
+#define JVMTI_THREAD_STATE_VENDOR_2 0x20000000
+#define JVMTI_THREAD_STATE_VENDOR_3 0x40000000
+
+/* java.lang.Thread.State conversion masks */
+#define JVMTI_JAVA_LANG_THREAD_STATE_MASK \
+ (JVMTI_THREAD_STATE_TERMINATED \
+ | JVMTI_THREAD_STATE_ALIVE \
+ | JVMTI_THREAD_STATE_RUNNABLE \
+ | JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER \
+ | JVMTI_THREAD_STATE_WAITING \
+ | JVMTI_THREAD_STATE_WAITING_INDEFINITELY \
+ | JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT)
+#define JVMTI_JAVA_LANG_THREAD_STATE_NEW 0
+#define JVMTI_JAVA_LANG_THREAD_STATE_TERMINATED JVMTI_THREAD_STATE_TERMINATED
+#define JVMTI_JAVA_LANG_THREAD_STATE_RUNNABLE \
+ (JVMTI_THREAD_STATE_ALIVE \
+ | JVMTI_THREAD_STATE_RUNNABLE)
+#define JVMTI_JAVA_LANG_THREAD_STATE_BLOCKED \
+ (JVMTI_THREAD_STATE_ALIVE \
+ | JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER)
+#define JVMTI_JAVA_LANG_THREAD_STATE_WAITING \
+ (JVMTI_THREAD_STATE_ALIVE \
+ | JVMTI_THREAD_STATE_WAITING \
+ | JVMTI_THREAD_STATE_WAITING_INDEFINITELY)
+#define JVMTI_JAVA_LANG_THREAD_STATE_TIMED_WAITING \
+ (JVMTI_THREAD_STATE_ALIVE \
+ | JVMTI_THREAD_STATE_WAITING \
+ | JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT)
+
+/* Thread priorities */
+#define JVMTI_THREAD_MIN_PRIORITY 1
+#define JVMTI_THREAD_NORM_PRIORITY 5
+#define JVMTI_THREAD_MAX_PRIORITY 10
+
+/* Keep c-font-lock-extra-types in order: JNI followed by JVMTI,
+ all in alphabetical order */
+/* Local Variables: */
+/* c-font-lock-extra-types: ("\\sw+_t"
+ "JNIEnv" "JNINativeMethod" "JavaVM" "JavaVMOption" "jarray"
+ "jboolean" "jbooleanArray" "jbyte" "jbyteArray" "jchar" "jcharArray"
+ "jclass" "jdouble" "jdoubleArray" "jfieldID" "jfloat" "jfloatArray"
+ "jint" "jintArray" "jlong" "jlongArray" "jmethodID" "jobject" "jstring" "jthrowable"
+ "jvalue" "jweak"
+ "jvmtiEnv" "jvmtiError"
+ "jthread" "jthreadGroup" "jlocation" "jrawMonitorID") */
+/* End: */
+#endif /* !_CLASSPATH_JVMTI_H */
Added: llvm-gcc-4.2/trunk/libjava/classpath/install-sh
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/install-sh?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/install-sh (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/install-sh Thu Nov 8 16:56:19 2007
@@ -0,0 +1,251 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission. M.I.T. makes no representations about the
+# suitability of this software for any purpose. It is provided "as is"
+# without express or implied warranty.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch. It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "install: no input file specified"
+ exit 1
+else
+ :
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -d $dst ]; then
+ instcmd=:
+ chmodcmd=""
+ else
+ instcmd=$mkdirprog
+ fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f "$src" ] || [ -d "$src" ]
+ then
+ :
+ else
+ echo "install: $src does not exist"
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "install: no destination specified"
+ exit 1
+ else
+ :
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d $dst ]
+ then
+ dst="$dst"/`basename $src`
+ else
+ :
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+ '
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp="${pathcomp}${1}"
+ shift
+
+ if [ ! -d "${pathcomp}" ] ;
+ then
+ $mkdirprog "${pathcomp}"
+ else
+ :
+ fi
+
+ pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd $dst &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ dstfile=`basename $dst $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ :
+ fi
+
+# Make a temp file name in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd $src $dsttmp &&
+
+ trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi &&
+
+# Now rename the file to the real destination.
+
+ $doit $rmcmd -f $dstdir/$dstfile &&
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
+
+fi &&
+
+
+exit 0
Propchange: llvm-gcc-4.2/trunk/libjava/classpath/install-sh
------------------------------------------------------------------------------
svn:executable = *
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/applet/Applet.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/applet/Applet.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/applet/Applet.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/applet/Applet.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,592 @@
+/* Applet.java -- Java base applet class
+ Copyright (C) 1999, 2002, 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.applet;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.GraphicsEnvironment;
+import java.awt.HeadlessException;
+import java.awt.Image;
+import java.awt.Panel;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Locale;
+
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
+import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.Clip;
+import javax.sound.sampled.LineUnavailableException;
+import javax.sound.sampled.UnsupportedAudioFileException;
+
+/**
+ * This is the base applet class. An applet is a Java program that
+ * runs inside a web browser or other applet viewer in a restricted
+ * environment.
+ *
+ * <p>To be useful, a subclass should override at least start(). Also useful
+ * are init, stop, and destroy for control purposes, and getAppletInfo and
+ * getParameterInfo for descriptive purposes.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public class Applet extends Panel
+{
+ /**
+ * Compatible with JDK 1.0+.
+ */
+ private static final long serialVersionUID = -5836846270535785031L;
+
+ /** The applet stub for this applet. */
+ private transient AppletStub stub;
+
+ /** Some applets call setSize in their constructors. In that case,
+ these fields are used to store width and height values until a
+ stub is set. */
+ private transient int width;
+ private transient int height;
+
+ /**
+ * The accessibility context for this applet.
+ *
+ * @serial the accessibleContext for this
+ * @since 1.2
+ */
+ private AccessibleContext accessibleContext;
+
+ /**
+ * Default constructor for subclasses.
+ *
+ * @throws HeadlessException if in a headless environment
+ */
+ public Applet()
+ {
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException();
+ }
+
+ /**
+ * The browser calls this method to set the applet's stub, which is the
+ * low level interface to the browser. Manually setting this to null is
+ * asking for problems down the road.
+ *
+ * @param stub the applet stub for this applet
+ */
+ public final void setStub(AppletStub stub)
+ {
+ this.stub = stub;
+
+ if (width != 0 && height != 0)
+ stub.appletResize (width, height);
+ }
+
+ /**
+ * Tests whether or not this applet is currently active. An applet is active
+ * just before the browser invokes start(), and becomes inactive just
+ * before the browser invokes stop().
+ *
+ * @return <code>true</code> if this applet is active
+ */
+ public boolean isActive()
+ {
+ return stub.isActive();
+ }
+
+ /**
+ * Returns the basename URL of the document this applet is embedded in. This
+ * is everything up to the final '/'.
+ *
+ * @return the URL of the document this applet is embedded in
+ * @see #getCodeBase()
+ */
+ public URL getDocumentBase()
+ {
+ return stub.getDocumentBase();
+ }
+
+ /**
+ * Returns the URL of the code base for this applet.
+ *
+ * @return the URL of the code base for this applet
+ */
+ public URL getCodeBase()
+ {
+ return stub.getCodeBase();
+ }
+
+ /**
+ * Returns the value of the specified parameter that was specified in
+ * the <code><APPLET></code> tag for this applet.
+ *
+ * @param name the parameter name
+ * @return the parameter value, or null if the parameter does not exist
+ * @throws NullPointerException if name is null
+ */
+ public String getParameter(String name)
+ {
+ return stub.getParameter(name);
+ }
+
+ /**
+ * Returns the applet context for this applet.
+ *
+ * @return the applet context for this applet
+ */
+ public AppletContext getAppletContext()
+ {
+ return stub.getAppletContext();
+ }
+
+ /**
+ * Requests that the applet window for this applet be resized.
+ *
+ * @param width the new width in pixels
+ * @param height the new height in pixels
+ */
+ public void resize(int width, int height)
+ {
+ if (stub == null)
+ {
+ this.width = width;
+ this.height = height;
+ }
+ else
+ stub.appletResize(width, height);
+ }
+
+ /**
+ * Requests that the applet window for this applet be resized.
+ *
+ * @param dim the requested dimensions
+ * @throws NullPointerException if dim is null
+ */
+ public void resize(Dimension dim)
+ {
+ resize(dim.width, dim.height);
+ }
+
+ /**
+ * Displays the specified message in the status window if that window
+ * exists.
+ *
+ * @param message the status message, may be null
+ */
+ public void showStatus(String message)
+ {
+ getAppletContext().showStatus(message);
+ }
+
+ /**
+ * Returns an image from the specified URL. Note that the image is not
+ * actually retrieved until the applet attempts to display it, so this
+ * method returns immediately.
+ *
+ * @param url the URL of the image
+ * @return the retrieved image
+ * @throws NullPointerException if url is null
+ */
+ public Image getImage(URL url)
+ {
+ return getAppletContext().getImage(url);
+ }
+
+ /**
+ * Returns an image from the specified absolute URL, and relative path
+ * from that URL. Note that the image is not actually retrieved until the
+ * applet attempts to display it, so this method returns immediately.
+ * This calls <code>getImage(new URL(url, name))</code>, but if building
+ * the new URL fails, this returns null.
+ *
+ * @param url the base URL of the image
+ * @param name the name of the image relative to the URL
+ * @return the retrieved image, or null on failure
+ * @see #getImage(URL)
+ */
+ public Image getImage(URL url, String name)
+ {
+ try
+ {
+ return getImage(new URL(url, name));
+ }
+ catch (MalformedURLException e)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Returns an audio clip from the specified URL. This clip is not tied to
+ * any particular applet.
+ *
+ * @param url the URL of the audio clip
+ * @return the retrieved audio clip
+ * @throws NullPointerException if url is null
+ * @see #getAudioClip(URL)
+ * @since 1.2
+ */
+ public static final AudioClip newAudioClip(URL url)
+ {
+ return new URLAudioClip(url);
+ }
+
+ /**
+ * Returns an audio clip from the specified URL. Note that the clip is not
+ * actually retrieved until the applet attempts to play it, so this method
+ * returns immediately.
+ *
+ * @param url the URL of the audio clip
+ * @return the retrieved audio clip
+ * @throws NullPointerException if url is null
+ */
+ public AudioClip getAudioClip(URL url)
+ {
+ return getAppletContext().getAudioClip(url);
+ }
+
+ /**
+ * Returns an audio clip from the specified absolute URL, and relative path
+ * from that URL. Note that the clip is not actually retrieved until the
+ * applet attempts to play it, so this method returns immediately. This
+ * calls <code>getAudioClip(new URL(url, name))</code>, but if building
+ * the new URL fails, this returns null.
+ *
+ * @param url the base URL of the audio clip
+ * @param name the name of the clip relative to the URL
+ * @return the retrieved audio clip, or null on failure
+ * @see #getAudioClip(URL)
+ */
+ public AudioClip getAudioClip(URL url, String name)
+ {
+ try
+ {
+ return getAudioClip(new URL(url, name));
+ }
+ catch (MalformedURLException e)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Returns a descriptive string with applet defined information. The
+ * implementation in this class returns <code>null</code>, so subclasses
+ * must override to return information.
+ *
+ * @return a string describing the author, version, and applet copyright
+ */
+ public String getAppletInfo()
+ {
+ return null;
+ }
+
+ /**
+ * Returns the locale for this applet, if it has been set. If no applet
+ * specific locale has been set, the default locale is returned.
+ *
+ * @return the locale for this applet
+ * @see Component#setLocale(Locale)
+ * @since 1.1
+ */
+ public Locale getLocale()
+ {
+ return super.getLocale();
+ }
+
+ /**
+ * Returns a list of parameters this applet supports. Each element of
+ * the outer array is an array of three strings with the name of the
+ * parameter, the data type or valid values, and a description. This
+ * method is optional and the default implementation returns null.
+ *
+ * @return the list of parameters supported by this applet
+ */
+ public String[][] getParameterInfo()
+ {
+ return null;
+ }
+
+ /**
+ * Loads and plays the audio clip pointed to by the specified URL. This does
+ * nothing if the URL does not point to a valid audio clip.
+ *
+ * @param url the URL of the audio clip
+ * @throws NullPointerException if url is null
+ * @see #getAudioClip(URL)
+ */
+ public void play(URL url)
+ {
+ AudioClip ac = getAudioClip(url);
+ try
+ {
+ ac.play();
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+
+ /**
+ * Loads and plays the audio clip pointed to by the specified absolute URL,
+ * and relative path from that URL. This does nothing if the URL cannot be
+ * constructed, or if it does not point to a valid audio clip.
+ *
+ * @param url the base URL of the audio clip
+ * @param name the name of the audio clip relative to the URL
+ * @see #getAudioClip(URL, String)
+ * @see #play(URL)
+ */
+ public void play(URL url, String name)
+ {
+ try
+ {
+ getAudioClip(url, name).play();
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+
+ /**
+ * This method is called when the applet is first loaded, before start().
+ * The default implementation does nothing; override to do any one-time
+ * initialization.
+ *
+ * @see #start()
+ * @see #stop()
+ * @see #destroy()
+ */
+ public void init()
+ {
+ }
+
+ /**
+ * This method is called when the applet should start running. This is
+ * normally each time a web page containing it is loaded. The default
+ * implemention does nothing; override for your applet to be useful.
+ *
+ * @see #init()
+ * @see #stop()
+ * @see #destroy()
+ */
+ public void start()
+ {
+ }
+
+ /**
+ * This method is called when the applet should stop running. This is
+ * normally when the next web page is loaded. The default implementation
+ * does nothing; override for your applet to stop using resources when
+ * it is no longer visible, but may be restarted soon.
+ *
+ * @see #init()
+ * @see #start()
+ * @see #destroy()
+ */
+ public void stop()
+ {
+ }
+
+ /**
+ * This method is called when the applet is being unloaded. The default
+ * implementation does nothing; override for your applet to clean up
+ * resources on exit.
+ *
+ * @see #init()
+ * @see #start()
+ * @see #stop()
+ */
+ public void destroy()
+ {
+ }
+
+ /**
+ * Gets the AccessibleContext associated with this applet, creating one if
+ * necessary. This always returns an instance of {@link AccessibleApplet}.
+ *
+ * @return the accessibility context of this applet
+ * @since 1.3
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ if (accessibleContext == null)
+ accessibleContext = new AccessibleApplet();
+ return accessibleContext;
+ }
+
+ /**
+ * Read an applet from an object stream. This checks for a headless
+ * environment, then does the normal read.
+ *
+ * @param s the stream to read from
+ * @throws ClassNotFoundException if a class is not found
+ * @throws IOException if deserialization fails
+ * @throws HeadlessException if this is a headless environment
+ * @see GraphicsEnvironment#isHeadless()
+ * @since 1.4
+ */
+ private void readObject(ObjectInputStream s)
+ throws ClassNotFoundException, IOException
+ {
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException();
+ s.defaultReadObject();
+ }
+
+ /**
+ * This class provides accessibility support for Applets, and is the
+ * runtime type returned by {@link #getAccessibleContext()}.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.3
+ */
+ protected class AccessibleApplet extends AccessibleAWTPanel
+ {
+ /**
+ * Compatible with JDK 1.4+.
+ */
+ private static final long serialVersionUID = 8127374778187708896L;
+
+ /**
+ * The default constructor.
+ */
+ protected AccessibleApplet()
+ {
+ }
+
+ /**
+ * Get the role of this accessible object, a frame.
+ *
+ * @return the role of the object
+ * @see AccessibleRole#FRAME
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.FRAME;
+ }
+
+ /**
+ * Get the state set of this accessible object. In addition to the default
+ * states of a Component, the applet can also be active.
+ *
+ * @return the role of the object
+ * @see AccessibleState
+ */
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ AccessibleStateSet s = super.getAccessibleStateSet();
+ if (isActive())
+ s.add(AccessibleState.ACTIVE);
+ return s;
+ }
+ } // class AccessibleApplet
+
+ private static class URLAudioClip implements AudioClip
+ {
+ // The URL we will try to play.
+ // This is null if we have already tried to create an
+ // audio input stream from this URL.
+ private URL url;
+
+ // The real audio clip. This is null before the URL is read,
+ // and might be null afterward if we were unable to read the URL
+ // for some reason.
+ private Clip clip;
+
+ public URLAudioClip(URL url)
+ {
+ this.url = url;
+ }
+
+ private synchronized Clip getClip()
+ {
+ if (url == null)
+ return clip;
+ try
+ {
+ clip = AudioSystem.getClip();
+ clip.open(AudioSystem.getAudioInputStream(url));
+ }
+ catch (LineUnavailableException _)
+ {
+ // Ignore.
+ }
+ catch (IOException _)
+ {
+ // Ignore.
+ }
+ catch (UnsupportedAudioFileException _)
+ {
+ // Ignore.
+ }
+ url = null;
+ return clip;
+ }
+
+ public void loop()
+ {
+ Clip myclip = getClip();
+ if (myclip != null)
+ myclip.loop(Clip.LOOP_CONTINUOUSLY);
+ }
+
+ public void play()
+ {
+ Clip myclip = getClip();
+ if (myclip != null)
+ myclip.start();
+ }
+
+ public void stop()
+ {
+ Clip myclip = getClip();
+ if (myclip != null)
+ {
+ myclip.stop();
+ myclip.setFramePosition(0);
+ }
+ }
+ }
+} // class Applet
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/applet/AppletContext.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/applet/AppletContext.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/applet/AppletContext.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/applet/AppletContext.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,154 @@
+/* AppletContext.java -- access the applet's runtime environment
+ Copyright (C) 1999, 2002, 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.applet;
+
+import java.awt.Image;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Iterator;
+
+/**
+ * This interface allows an applet access to the browser to retrieve
+ * additional data files and display documents. It also allows the
+ * applet to find out other applets in the same document.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public interface AppletContext
+{
+ /**
+ * Returns an audio clip from the specified URL.
+ *
+ * @param url the URL of the audio clip
+ * @return the retrieved audio clip
+ * @throws NullPointerException if url is null
+ */
+ AudioClip getAudioClip(URL url);
+
+ /**
+ * Returns an image from the specified URL. Note that the image is not
+ * actually retrieved until the applet attempts to display it, so this
+ * method returns immediately.
+ *
+ * @param url the absolute URL of the image
+ * @return the retrieved image
+ * @throws NullPointerException if url is null
+ */
+ Image getImage(URL url);
+
+ /**
+ * Returns the applet in the document for this object that has the
+ * specified name.
+ *
+ * @param name the applet name
+ * @return the requested applet, or <code>null</code> if not found
+ */
+ Applet getApplet(String name);
+
+ /**
+ * Returns a list of all the applets in the document for this object.
+ *
+ * @return a list of all the applets
+ */
+ Enumeration getApplets();
+
+ /**
+ * Displays the web page pointed to by the specified URL in the window
+ * for this object. This page replaces the document that is currently
+ * there.
+ *
+ * @param url the URL of the web page to load; unspecified on an error
+ */
+ void showDocument(URL url);
+
+ /**
+ * Displays the web page pointed to be the sepcified URL in the window
+ * with the specified name. The standard names "_top", "_blank",
+ * "_parent", and "_self" are allowed. An applet viewer may disregard
+ * this request.
+ *
+ * @param url the URL of the web page to load
+ * @param target the target window
+ */
+ void showDocument(URL url, String target);
+
+ /**
+ * Displays the specified message in the status window if that window
+ * exists.
+ *
+ * @param message the status message, may be null
+ */
+ void showStatus(String message);
+
+ /**
+ * Associate a stream to a key for this applet context, possibly replacing
+ * the old value. Stream associations are local to the applet context, for
+ * security purposes.
+ *
+ * @param key the key to associate with
+ * @param stream the stream value to tie to the key, or null to remove
+ * @throws IOException if the stream is too large
+ * @since 1.4
+ */
+ void setStream(String key, InputStream stream) throws IOException;
+
+ /**
+ * Return the stream associated with a given key in this applet context, or
+ * null if nothing is associated. Stream associations are local to the
+ * applet context, for security purposes.
+ *
+ * @param key the key to look up
+ * @return the associated stream, or null
+ * @since 1.4
+ */
+ InputStream getStream(String key);
+
+ /**
+ * Iterate over all keys that have associated streams. Stream associated
+ * are local to the applet context, for security purposes.
+ *
+ * @return an iterator over the association keys
+ * @since 1.4
+ */
+ Iterator getStreamKeys();
+} // interface AppletContext
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/applet/AppletStub.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/applet/AppletStub.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/applet/AppletStub.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/applet/AppletStub.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,103 @@
+/* AppletStub.java -- low level interface to the browser
+ Copyright (C) 1999, 2002, 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.applet;
+
+import java.net.URL;
+
+/**
+ * This interface is the low level interface between the applet and the
+ * browser.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @see Applet#setStub(AppletStub)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public interface AppletStub
+{
+ /**
+ * Tests whether or not this applet is currently active. An applet is active
+ * just before the browser invokes start(), and becomes inactive just
+ * before the browser invokes stop().
+ *
+ * @return <code>true</code> if this applet is active
+ */
+ boolean isActive();
+
+ /**
+ * Returns the basename URL of the document this applet is embedded in. This
+ * is everything up to the final '/'.
+ *
+ * @return the URL of the document this applet is embedded in
+ * @see #getCodeBase()
+ */
+ URL getDocumentBase();
+
+ /**
+ * Returns the URL of the code base for this applet.
+ *
+ * @return the URL of the code base for this applet
+ */
+ URL getCodeBase();
+
+ /**
+ * Returns the value of the specified parameter that was specified in
+ * the <code><APPLET></code> tag for this applet.
+ *
+ * @param name the parameter name
+ * @return the parameter value, or null if the parameter does not exist
+ * @throws NullPointerException if name is null
+ */
+ String getParameter(String name);
+
+ /**
+ * Returns the applet context for this applet.
+ *
+ * @return the applet context for this applet
+ */
+ AppletContext getAppletContext();
+
+ /**
+ * Requests that the applet window for this applet be resized.
+ *
+ * @param width the new width in pixels
+ * @param height the new height in pixels
+ */
+ void appletResize(int width, int height);
+} // interface AppletStub
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/applet/AudioClip.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/applet/AudioClip.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/applet/AudioClip.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/applet/AudioClip.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,68 @@
+/* AudioClip.java -- play an audio clip in an applet
+ Copyright (C) 1999, 2002, 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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.applet;
+
+
+/**
+ * This interface provides a simple mechanism for playing audio clips.
+ * If multiple clips are played at once, the browser combines them into a
+ * composite clip.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public interface AudioClip
+{
+ /**
+ * Plays the audio clip starting from the beginning.
+ */
+ void play();
+
+ /**
+ * Stops playing this audio clip. There is no mechanism for restarting
+ * at the point where the clip is stopped.
+ */
+ void stop();
+
+ /**
+ * Plays this audio clip in a continuous loop.
+ */
+ void loop();
+} // interface AudioClip
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/applet/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/applet/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/applet/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/applet/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.applet package.
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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. -->
+
+<html>
+<head><title>GNU Classpath - java.applet</title></head>
+
+<body>
+<p>Classes and interfaces for small embeddable applications
+often used in web pages.</p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTError.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTError.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTError.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTError.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,64 @@
+/* AWTError.java -- A serious AWT error occurred.
+ Copyright (C) 1999, 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * This error is thrown when a critical Abstract Window Toolkit (AWT) error
+ * occurs.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @status updated to 1.4
+ */
+public class AWTError extends Error
+{
+ /**
+ * Compatible with JDK 1.0+.
+ */
+ private static final long serialVersionUID = -1819846354050686206L;
+
+ /**
+ * Create a new instance with the specified descriptive error message.
+ *
+ * @param message the descriptive error message
+ */
+ public AWTError(String message)
+ {
+ super(message);
+ }
+} // class AWTError
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTEvent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTEvent.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTEvent.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,386 @@
+
+/* AWTEvent.java -- the root event in AWT
+ Copyright (C) 1999, 2000, 2002, 2005 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.AdjustmentEvent;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ContainerEvent;
+import java.awt.event.FocusEvent;
+import java.awt.event.InputMethodEvent;
+import java.awt.event.InvocationEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.awt.event.PaintEvent;
+import java.awt.event.TextEvent;
+import java.awt.event.WindowEvent;
+import java.util.EventObject;
+
+/**
+ * AWTEvent is the root event class for all AWT events in the JDK 1.1 event
+ * model. It supersedes the Event class from JDK 1.0. Subclasses outside of
+ * the java.awt package should have IDs greater than RESERVED_ID_MAX.
+ *
+ * <p>Event masks defined here are used by components in
+ * <code>enableEvents</code> to select event types not selected by registered
+ * listeners. Event masks are appropriately set when registering on
+ * components.
+ *
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public abstract class AWTEvent extends EventObject
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = -1825314779160409405L;
+
+ /**
+ * The ID of the event.
+ *
+ * @see #getID()
+ * @see #AWTEvent(Object, int)
+ * @serial the identifier number of this event
+ */
+ protected int id;
+
+ /**
+ * Indicates if the event has been consumed. False mean it is passed to
+ * the peer, true means it has already been processed. Semantic events
+ * generated by low-level events always have the value true.
+ *
+ * @see #consume()
+ * @see #isConsumed()
+ * @serial whether the event has been consumed
+ */
+ protected boolean consumed;
+
+ /**
+ * Who knows? It's in the serial version.
+ *
+ * @serial No idea what this is for.
+ */
+ byte[] bdata;
+
+ /**
+ * Indicates if this event is dispatched by the KeyboardFocusManager.
+ */
+ boolean isFocusManagerEvent = false;
+
+ /** Mask for selecting component events. */
+ public static final long COMPONENT_EVENT_MASK = 0x00001;
+
+ /** Mask for selecting container events. */
+ public static final long CONTAINER_EVENT_MASK = 0x00002;
+
+ /** Mask for selecting component focus events. */
+ public static final long FOCUS_EVENT_MASK = 0x00004;
+
+ /** Mask for selecting keyboard events. */
+ public static final long KEY_EVENT_MASK = 0x00008;
+
+ /** Mask for mouse button events. */
+ public static final long MOUSE_EVENT_MASK = 0x00010;
+
+ /** Mask for mouse motion events. */
+ public static final long MOUSE_MOTION_EVENT_MASK = 0x00020;
+
+ /** Mask for window events. */
+ public static final long WINDOW_EVENT_MASK = 0x00040;
+
+ /** Mask for action events. */
+ public static final long ACTION_EVENT_MASK = 0x00080;
+
+ /** Mask for adjustment events. */
+ public static final long ADJUSTMENT_EVENT_MASK = 0x00100;
+
+ /** Mask for item events. */
+ public static final long ITEM_EVENT_MASK = 0x00200;
+
+ /** Mask for text events. */
+ public static final long TEXT_EVENT_MASK = 0x00400;
+
+ /**
+ * Mask for input method events.
+ * @since 1.3
+ */
+ public static final long INPUT_METHOD_EVENT_MASK = 0x00800;
+
+ /**
+ * Mask if input methods are enabled. Package visible only.
+ */
+ static final long INPUT_ENABLED_EVENT_MASK = 0x01000;
+
+ /**
+ * Mask for paint events.
+ * @since 1.3
+ */
+ public static final long PAINT_EVENT_MASK = 0x02000;
+
+ /**
+ * Mask for invocation events.
+ * @since 1.3
+ */
+ public static final long INVOCATION_EVENT_MASK = 0x04000;
+
+ /**
+ * Mask for hierarchy events.
+ * @since 1.3
+ */
+ public static final long HIERARCHY_EVENT_MASK = 0x08000;
+
+ /**
+ * Mask for hierarchy bounds events.
+ * @since 1.3
+ */
+ public static final long HIERARCHY_BOUNDS_EVENT_MASK = 0x10000;
+
+ /**
+ * Mask for mouse wheel events.
+ * @since 1.4
+ */
+ public static final long MOUSE_WHEEL_EVENT_MASK = 0x20000;
+
+ /**
+ * Mask for window state events.
+ * @since 1.4
+ */
+ public static final long WINDOW_STATE_EVENT_MASK = 0x40000;
+
+ /**
+ * Mask for window focus events.
+ * @since 1.4
+ */
+ public static final long WINDOW_FOCUS_EVENT_MASK = 0x80000;
+
+ /**
+ * This is the highest number for event ids that are reserved for use by
+ * the AWT system itself. Subclasses outside of java.awt should use higher
+ * ids.
+ */
+ public static final int RESERVED_ID_MAX = 1999;
+
+
+ /**
+ * Initializes a new AWTEvent from the old Java 1.0 event object.
+ *
+ * @param event the old-style event
+ * @throws NullPointerException if event is null
+ */
+ public AWTEvent(Event event)
+ {
+ this(event.target, event.id);
+ consumed = event.consumed;
+ }
+
+ /**
+ * Create an event on the specified source object and id.
+ *
+ * @param source the object that caused the event
+ * @param id the event id
+ * @throws IllegalArgumentException if source is null
+ */
+ public AWTEvent(Object source, int id)
+ {
+ super(source);
+ this.id = id;
+ }
+
+ /**
+ * Retarget the event, such as converting a heavyweight component to a
+ * lightweight child of the original. This is not for general use, but
+ * is for event targeting systems like KeyboardFocusManager.
+ *
+ * @param source the new source
+ */
+ public void setSource(Object source)
+ {
+ this.source = source;
+ }
+
+ /**
+ * Returns the event type id.
+ *
+ * @return the id number of this event
+ */
+ public int getID()
+ {
+ return id;
+ }
+
+ /**
+ * Create a string that represents this event in the format
+ * <code>classname[eventstring] on sourcecomponentname</code>.
+ *
+ * @return a string representing this event
+ */
+ public String toString ()
+ {
+ String string = getClass ().getName () + "[" + paramString () + "] on "
+ + source;
+
+ return string;
+ }
+
+ /**
+ * Returns a string representation of the state of this event. It may be
+ * empty, but must not be null; it is implementation defined.
+ *
+ * @return a string representation of this event
+ */
+ public String paramString()
+ {
+ return "";
+ }
+
+ /**
+ * Consumes this event so that it will not be processed in the default
+ * manner.
+ */
+ protected void consume()
+ {
+ consumed = true;
+ }
+
+ /**
+ * Tests whether not not this event has been consumed. A consumed event
+ * is not processed in the default manner.
+ *
+ * @return true if this event has been consumed
+ */
+ protected boolean isConsumed()
+ {
+ return consumed;
+ }
+
+ /**
+ * Converts an event id to the appropriate event mask.
+ *
+ * @param id the event id
+ *
+ * @return the event mask for the specified id
+ */
+ static long eventIdToMask(int id)
+ {
+ long mask = 0;
+ switch (id)
+ {
+ case ActionEvent.ACTION_PERFORMED:
+ mask = ACTION_EVENT_MASK;
+ break;
+ case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
+ mask = ADJUSTMENT_EVENT_MASK;
+ break;
+ case ComponentEvent.COMPONENT_MOVED:
+ case ComponentEvent.COMPONENT_RESIZED:
+ case ComponentEvent.COMPONENT_SHOWN:
+ case ComponentEvent.COMPONENT_HIDDEN:
+ mask = COMPONENT_EVENT_MASK;
+ break;
+ case ContainerEvent.COMPONENT_ADDED:
+ case ContainerEvent.COMPONENT_REMOVED:
+ mask = CONTAINER_EVENT_MASK;
+ break;
+ case FocusEvent.FOCUS_GAINED:
+ case FocusEvent.FOCUS_LOST:
+ mask = FOCUS_EVENT_MASK;
+ break;
+ case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
+ case InputMethodEvent.CARET_POSITION_CHANGED:
+ mask = INPUT_METHOD_EVENT_MASK;
+ break;
+ case InvocationEvent.INVOCATION_DEFAULT:
+ mask = INVOCATION_EVENT_MASK;
+ break;
+ case ItemEvent.ITEM_STATE_CHANGED:
+ mask = ITEM_EVENT_MASK;
+ break;
+ case KeyEvent.KEY_TYPED:
+ case KeyEvent.KEY_PRESSED:
+ case KeyEvent.KEY_RELEASED:
+ mask = KEY_EVENT_MASK;
+ break;
+ case MouseEvent.MOUSE_CLICKED:
+ case MouseEvent.MOUSE_PRESSED:
+ case MouseEvent.MOUSE_RELEASED:
+ mask = MOUSE_EVENT_MASK;
+ break;
+ case MouseEvent.MOUSE_MOVED:
+ case MouseEvent.MOUSE_ENTERED:
+ case MouseEvent.MOUSE_EXITED:
+ case MouseEvent.MOUSE_DRAGGED:
+ mask = MOUSE_MOTION_EVENT_MASK;
+ break;
+ case MouseEvent.MOUSE_WHEEL:
+ mask = MOUSE_WHEEL_EVENT_MASK;
+ break;
+ case PaintEvent.PAINT:
+ case PaintEvent.UPDATE:
+ mask = PAINT_EVENT_MASK;
+ break;
+ case TextEvent.TEXT_VALUE_CHANGED:
+ mask = TEXT_EVENT_MASK;
+ break;
+ case WindowEvent.WINDOW_OPENED:
+ case WindowEvent.WINDOW_CLOSING:
+ case WindowEvent.WINDOW_CLOSED:
+ case WindowEvent.WINDOW_ICONIFIED:
+ case WindowEvent.WINDOW_DEICONIFIED:
+ case WindowEvent.WINDOW_ACTIVATED:
+ case WindowEvent.WINDOW_DEACTIVATED:
+ mask = WINDOW_EVENT_MASK;
+ break;
+ case WindowEvent.WINDOW_GAINED_FOCUS:
+ case WindowEvent.WINDOW_LOST_FOCUS:
+ mask = WINDOW_FOCUS_EVENT_MASK;
+ break;
+ case WindowEvent.WINDOW_STATE_CHANGED:
+ mask = WINDOW_STATE_EVENT_MASK;
+ break;
+ default:
+ mask = 0;
+ }
+ return mask;
+ }
+} // class AWTEvent
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTEventMulticaster.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTEventMulticaster.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTEventMulticaster.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTEventMulticaster.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1209 @@
+/* AWTEventMulticaster.java -- allows multicast chaining of listeners
+ Copyright (C) 1999, 2000, 2002 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.AdjustmentEvent;
+import java.awt.event.AdjustmentListener;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.ContainerEvent;
+import java.awt.event.ContainerListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.HierarchyBoundsListener;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
+import java.awt.event.InputMethodEvent;
+import java.awt.event.InputMethodListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
+import java.awt.event.TextEvent;
+import java.awt.event.TextListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowFocusListener;
+import java.awt.event.WindowListener;
+import java.awt.event.WindowStateListener;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.EventListener;
+
+/**
+ * This class is used to implement a chain of event handlers. Dispatching
+ * using this class is thread safe. Here is a quick example of how to
+ * add and delete listeners using this class. For this example, we will
+ * assume are firing <code>AdjustmentEvent</code>'s. However, this
+ * same approach is useful for all events in the <code>java.awt.event</code>
+ * package, and more if this class is subclassed.
+ *
+ * <p><code>
+ * AdjustmentListener al;
+ * public void addAdjustmentListener(AdjustmentListener listener)
+ * {
+ * al = AWTEventMulticaster.add(al, listener);
+ * }
+ * public void removeAdjustmentListener(AdjustmentListener listener)
+ * {
+ * al = AWTEventMulticaster.remove(al, listener);
+ * }
+ * </code>
+ *
+ * <p>When it come time to process an event, simply call <code>al</code>,
+ * assuming it is not <code>null</code>, and all listeners in the chain will
+ * be fired.
+ *
+ * <p>The first time <code>add</code> is called it is passed
+ * <code>null</code> and <code>listener</code> as its arguments. This
+ * starts building the chain. This class returns <code>listener</code>
+ * which becomes the new <code>al</code>. The next time, <code>add</code>
+ * is called with <code>al</code> and <code>listener</code> and the
+ * new listener is then chained to the old.
+ *
+ * @author Bryce McKinlay
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class AWTEventMulticaster
+ implements ComponentListener, ContainerListener, FocusListener, KeyListener,
+ MouseListener, MouseMotionListener, WindowListener,
+ WindowFocusListener, WindowStateListener, ActionListener,
+ ItemListener, AdjustmentListener, TextListener,
+ InputMethodListener, HierarchyListener, HierarchyBoundsListener,
+ MouseWheelListener
+{
+ /**
+ * A variable in the event chain.
+ */
+ protected final EventListener a;
+
+ /**
+ * A variable in the event chain.
+ */
+ protected final EventListener b;
+
+ /**
+ * Initializes a new instance of <code>AWTEventMulticaster</code> with
+ * the specified event listener parameters. The parameters should not be
+ * null, although it is not required to enforce this with a
+ * NullPointerException.
+ *
+ * @param a the "a" listener object
+ * @param b the "b" listener object
+ */
+ protected AWTEventMulticaster(EventListener a, EventListener b)
+ {
+ this.a = a;
+ this.b = b;
+ }
+
+ /**
+ * Removes one instance of the specified listener from this multicaster
+ * chain. This descends recursively if either child is a multicaster, and
+ * returns a multicaster chain with the old listener removed.
+ *
+ * @param oldl the object to remove from this multicaster
+ * @return the resulting multicaster with the specified listener removed
+ */
+ protected EventListener remove(EventListener oldl)
+ {
+ // If oldl is an immediate child, return the other child.
+ if (a == oldl)
+ return b;
+ if (b == oldl)
+ return a;
+ // If a and/or b are Multicaster's, search them recursively.
+ if (a instanceof AWTEventMulticaster)
+ {
+ EventListener newa = ((AWTEventMulticaster) a).remove(oldl);
+ if (newa != a)
+ return new AWTEventMulticaster(newa, b);
+ }
+ if (b instanceof AWTEventMulticaster)
+ {
+ EventListener newb = ((AWTEventMulticaster) b).remove(oldl);
+ if (newb != b)
+ return new AWTEventMulticaster(a, newb);
+ }
+ // oldl was not found.
+ return this;
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void componentResized(ComponentEvent e)
+ {
+ ((ComponentListener) a).componentResized(e);
+ ((ComponentListener) b).componentResized(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void componentMoved(ComponentEvent e)
+ {
+ ((ComponentListener) a).componentMoved(e);
+ ((ComponentListener) b).componentMoved(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void componentShown(ComponentEvent e)
+ {
+ ((ComponentListener) a).componentShown(e);
+ ((ComponentListener) b).componentShown(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void componentHidden(ComponentEvent e)
+ {
+ ((ComponentListener) a).componentHidden(e);
+ ((ComponentListener) b).componentHidden(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void componentAdded(ContainerEvent e)
+ {
+ ((ContainerListener) a).componentAdded(e);
+ ((ContainerListener) b).componentAdded(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void componentRemoved(ContainerEvent e)
+ {
+ ((ContainerListener) a).componentRemoved(e);
+ ((ContainerListener) b).componentRemoved(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void focusGained(FocusEvent e)
+ {
+ ((FocusListener) a).focusGained(e);
+ ((FocusListener) b).focusGained(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void focusLost(FocusEvent e)
+ {
+ ((FocusListener) a).focusLost(e);
+ ((FocusListener) b).focusLost(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void keyTyped(KeyEvent e)
+ {
+ ((KeyListener) a).keyTyped(e);
+ ((KeyListener) b).keyTyped(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void keyPressed(KeyEvent e)
+ {
+ ((KeyListener) a).keyPressed(e);
+ ((KeyListener) b).keyPressed(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void keyReleased(KeyEvent e)
+ {
+ ((KeyListener) a).keyReleased(e);
+ ((KeyListener) b).keyReleased(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void mouseClicked(MouseEvent e)
+ {
+ ((MouseListener) a).mouseClicked(e);
+ ((MouseListener) b).mouseClicked(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void mousePressed(MouseEvent e)
+ {
+ ((MouseListener) a).mousePressed(e);
+ ((MouseListener) b).mousePressed(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void mouseReleased(MouseEvent e)
+ {
+ ((MouseListener) a).mouseReleased(e);
+ ((MouseListener) b).mouseReleased(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void mouseEntered(MouseEvent e)
+ {
+ ((MouseListener) a).mouseEntered(e);
+ ((MouseListener) b).mouseEntered(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void mouseExited(MouseEvent e)
+ {
+ ((MouseListener) a).mouseExited(e);
+ ((MouseListener) b).mouseExited(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void mouseDragged(MouseEvent e)
+ {
+ ((MouseMotionListener) a).mouseDragged(e);
+ ((MouseMotionListener) b).mouseDragged(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void mouseMoved(MouseEvent e)
+ {
+ ((MouseMotionListener) a).mouseMoved(e);
+ ((MouseMotionListener) b).mouseMoved(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void windowOpened(WindowEvent e)
+ {
+ ((WindowListener) a).windowOpened(e);
+ ((WindowListener) b).windowOpened(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void windowClosing(WindowEvent e)
+ {
+ ((WindowListener) a).windowClosing(e);
+ ((WindowListener) b).windowClosing(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void windowClosed(WindowEvent e)
+ {
+ ((WindowListener) a).windowClosed(e);
+ ((WindowListener) b).windowClosed(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void windowIconified(WindowEvent e)
+ {
+ ((WindowListener) a).windowIconified(e);
+ ((WindowListener) b).windowIconified(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void windowDeiconified(WindowEvent e)
+ {
+ ((WindowListener) a).windowDeiconified(e);
+ ((WindowListener) b).windowDeiconified(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void windowActivated(WindowEvent e)
+ {
+ ((WindowListener) a).windowActivated(e);
+ ((WindowListener) b).windowActivated(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void windowDeactivated(WindowEvent e)
+ {
+ ((WindowListener) a).windowDeactivated(e);
+ ((WindowListener) b).windowDeactivated(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ * @since 1.4
+ */
+ public void windowStateChanged(WindowEvent e)
+ {
+ ((WindowStateListener) a).windowStateChanged(e);
+ ((WindowStateListener) b).windowStateChanged(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ * @since 1.4
+ */
+ public void windowGainedFocus(WindowEvent e)
+ {
+ ((WindowFocusListener) a).windowGainedFocus(e);
+ ((WindowFocusListener) b).windowGainedFocus(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ * @since 1.4
+ */
+ public void windowLostFocus(WindowEvent e)
+ {
+ ((WindowFocusListener) a).windowLostFocus(e);
+ ((WindowFocusListener) b).windowLostFocus(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ ((ActionListener) a).actionPerformed(e);
+ ((ActionListener) b).actionPerformed(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void itemStateChanged(ItemEvent e)
+ {
+ ((ItemListener) a).itemStateChanged(e);
+ ((ItemListener) b).itemStateChanged(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void adjustmentValueChanged(AdjustmentEvent e)
+ {
+ ((AdjustmentListener) a).adjustmentValueChanged(e);
+ ((AdjustmentListener) b).adjustmentValueChanged(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ */
+ public void textValueChanged(TextEvent e)
+ {
+ ((TextListener) a).textValueChanged(e);
+ ((TextListener) b).textValueChanged(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ * @since 1.2
+ */
+ public void inputMethodTextChanged(InputMethodEvent e)
+ {
+ ((InputMethodListener) a).inputMethodTextChanged(e);
+ ((InputMethodListener) b).inputMethodTextChanged(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ * @since 1.2
+ */
+ public void caretPositionChanged(InputMethodEvent e)
+ {
+ ((InputMethodListener) a).caretPositionChanged(e);
+ ((InputMethodListener) b).caretPositionChanged(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ * @since 1.3
+ */
+ public void hierarchyChanged(HierarchyEvent e)
+ {
+ ((HierarchyListener) a).hierarchyChanged(e);
+ ((HierarchyListener) b).hierarchyChanged(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ * @since 1.3
+ */
+ public void ancestorMoved(HierarchyEvent e)
+ {
+ ((HierarchyBoundsListener) a).ancestorMoved(e);
+ ((HierarchyBoundsListener) b).ancestorMoved(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ * @since 1.3
+ */
+ public void ancestorResized(HierarchyEvent e)
+ {
+ ((HierarchyBoundsListener) a).ancestorResized(e);
+ ((HierarchyBoundsListener) b).ancestorResized(e);
+ }
+
+ /**
+ * Handles this event by dispatching it to the "a" and "b" listener
+ * instances.
+ *
+ * @param e the event to handle
+ * @since 1.4
+ */
+ public void mouseWheelMoved(MouseWheelEvent e)
+ {
+ ((MouseWheelListener) a).mouseWheelMoved(e);
+ ((MouseWheelListener) b).mouseWheelMoved(e);
+ }
+
+ /**
+ * Chain <code>ComponentListener</code> a and b.
+ *
+ * @param a the "a" listener, may be null
+ * @param b the "b" listener, may be null
+ * @return latest entry in the chain
+ */
+ public static ComponentListener add(ComponentListener a, ComponentListener b)
+ {
+ return (ComponentListener) addInternal(a, b);
+ }
+
+ /**
+ * Chain <code>ContainerListener</code> a and b.
+ *
+ * @param a the "a" listener, may be null
+ * @param b the "b" listener, may be null
+ * @return latest entry in the chain
+ */
+ public static ContainerListener add(ContainerListener a, ContainerListener b)
+ {
+ return (ContainerListener) addInternal(a, b);
+ }
+
+ /**
+ * Chain <code>FocusListener</code> a and b.
+ *
+ * @param a the "a" listener, may be null
+ * @param b the "b" listener, may be null
+ * @return latest entry in the chain
+ */
+ public static FocusListener add(FocusListener a, FocusListener b)
+ {
+ return (FocusListener) addInternal(a, b);
+ }
+
+ /**
+ * Chain <code>KeyListener</code> a and b.
+ *
+ * @param a the "a" listener, may be null
+ * @param b the "b" listener, may be null
+ * @return latest entry in the chain
+ */
+ public static KeyListener add(KeyListener a, KeyListener b)
+ {
+ return (KeyListener) addInternal(a, b);
+ }
+
+ /**
+ * Chain <code>MouseListener</code> a and b.
+ *
+ * @param a the "a" listener, may be null
+ * @param b the "b" listener, may be null
+ * @return latest entry in the chain
+ */
+ public static MouseListener add(MouseListener a, MouseListener b)
+ {
+ return (MouseListener) addInternal(a, b);
+ }
+
+ /**
+ * Chain <code>MouseMotionListener</code> a and b.
+ *
+ * @param a the "a" listener, may be null
+ * @param b the "b" listener, may be null
+ * @return latest entry in the chain
+ */
+ public static MouseMotionListener add(MouseMotionListener a,
+ MouseMotionListener b)
+ {
+ return (MouseMotionListener) addInternal(a, b);
+ }
+
+ /**
+ * Chain <code>WindowListener</code> a and b.
+ *
+ * @param a the "a" listener, may be null
+ * @param b the "b" listener, may be null
+ * @return latest entry in the chain
+ */
+ public static WindowListener add(WindowListener a, WindowListener b)
+ {
+ return (WindowListener) addInternal(a, b);
+ }
+
+ /**
+ * Chain <code>WindowStateListener</code> a and b.
+ *
+ * @param a the "a" listener, may be null
+ * @param b the "b" listener, may be null
+ * @return latest entry in the chain
+ * @since 1.4
+ */
+ public static WindowStateListener add(WindowStateListener a,
+ WindowStateListener b)
+ {
+ return (WindowStateListener) addInternal(a, b);
+ }
+
+ /**
+ * Chain <code>WindowFocusListener</code> a and b.
+ *
+ * @param a the "a" listener, may be null
+ * @param b the "b" listener, may be null
+ * @return latest entry in the chain
+ * @since 1.4
+ */
+ public static WindowFocusListener add(WindowFocusListener a,
+ WindowFocusListener b)
+ {
+ return (WindowFocusListener) addInternal(a, b);
+ }
+
+ /**
+ * Chain <code>ActionListener</code> a and b.
+ *
+ * @param a the "a" listener, may be null
+ * @param b the "b" listener, may be null
+ * @return latest entry in the chain
+ */
+ public static ActionListener add(ActionListener a, ActionListener b)
+ {
+ return (ActionListener) addInternal(a, b);
+ }
+
+ /**
+ * Chain <code>ItemListener</code> a and b.
+ *
+ * @param a the "a" listener, may be null
+ * @param b the "b" listener, may be null
+ * @return latest entry in the chain
+ */
+ public static ItemListener add(ItemListener a, ItemListener b)
+ {
+ return (ItemListener) addInternal(a, b);
+ }
+
+ /**
+ * Chain <code>AdjustmentListener</code> a and b.
+ *
+ * @param a the "a" listener, may be null
+ * @param b the "b" listener, may be null
+ * @return latest entry in the chain
+ */
+ public static AdjustmentListener add(AdjustmentListener a,
+ AdjustmentListener b)
+ {
+ return (AdjustmentListener) addInternal(a, b);
+ }
+
+ /**
+ * Chain <code>AdjustmentListener</code> a and b.
+ *
+ * @param a the "a" listener, may be null
+ * @param b the "b" listener, may be null
+ * @return latest entry in the chain
+ */
+ public static TextListener add(TextListener a, TextListener b)
+ {
+ return (TextListener) addInternal(a, b);
+ }
+
+ /**
+ * Chain <code>InputMethodListener</code> a and b.
+ *
+ * @param a the "a" listener, may be null
+ * @param b the "b" listener, may be null
+ * @return latest entry in the chain
+ * @since 1.2
+ */
+ public static InputMethodListener add(InputMethodListener a,
+ InputMethodListener b)
+ {
+ return (InputMethodListener) addInternal(a, b);
+ }
+
+ /**
+ * Chain <code>HierarchyListener</code> a and b.
+ *
+ * @param a the "a" listener, may be null
+ * @param b the "b" listener, may be null
+ * @return latest entry in the chain
+ * @since 1.3
+ */
+ public static HierarchyListener add(HierarchyListener a, HierarchyListener b)
+ {
+ return (HierarchyListener) addInternal(a, b);
+ }
+
+ /**
+ * Chain <code>HierarchyBoundsListener</code> a and b.
+ *
+ * @param a the "a" listener, may be null
+ * @param b the "b" listener, may be null
+ * @return latest entry in the chain
+ * @since 1.3
+ */
+ public static HierarchyBoundsListener add(HierarchyBoundsListener a,
+ HierarchyBoundsListener b)
+ {
+ return (HierarchyBoundsListener) addInternal(a, b);
+ }
+
+ /**
+ * Chain <code>MouseWheelListener</code> a and b.
+ *
+ * @param a the "a" listener, may be null
+ * @param b the "b" listener, may be null
+ * @return latest entry in the chain
+ * @since 1.4
+ */
+ public static MouseWheelListener add(MouseWheelListener a,
+ MouseWheelListener b)
+ {
+ return (MouseWheelListener) addInternal(a, b);
+ }
+
+ /**
+ * Removes the listener <code>oldl</code> from the listener <code>l</code>.
+ *
+ * @param l the listener chain to reduce
+ * @param oldl the listener to remove
+ * @return the resulting listener chain
+ */
+ public static ComponentListener remove(ComponentListener l,
+ ComponentListener oldl)
+ {
+ return (ComponentListener) removeInternal(l, oldl);
+ }
+
+ /**
+ * Removes the listener <code>oldl</code> from the listener <code>l</code>.
+ *
+ * @param l the listener chain to reduce
+ * @param oldl the listener to remove
+ * @return the resulting listener chain
+ */
+ public static ContainerListener remove(ContainerListener l,
+ ContainerListener oldl)
+ {
+ return (ContainerListener) removeInternal(l, oldl);
+ }
+
+ /**
+ * Removes the listener <code>oldl</code> from the listener <code>l</code>.
+ *
+ * @param l the listener chain to reduce
+ * @param oldl the listener to remove
+ * @return the resulting listener chain
+ */
+ public static FocusListener remove(FocusListener l, FocusListener oldl)
+ {
+ return (FocusListener) removeInternal(l, oldl);
+ }
+
+ /**
+ * Removes the listener <code>oldl</code> from the listener <code>l</code>.
+ *
+ * @param l the listener chain to reduce
+ * @param oldl the listener to remove
+ * @return the resulting listener chain
+ */
+ public static KeyListener remove(KeyListener l, KeyListener oldl)
+ {
+ return (KeyListener) removeInternal(l, oldl);
+ }
+
+ /**
+ * Removes the listener <code>oldl</code> from the listener <code>l</code>.
+ *
+ * @param l the listener chain to reduce
+ * @param oldl the listener to remove
+ * @return the resulting listener chain
+ */
+ public static MouseListener remove(MouseListener l, MouseListener oldl)
+ {
+ return (MouseListener) removeInternal(l, oldl);
+ }
+
+ /**
+ * Removes the listener <code>oldl</code> from the listener <code>l</code>.
+ *
+ * @param l the listener chain to reduce
+ * @param oldl the listener to remove
+ * @return the resulting listener chain
+ */
+ public static MouseMotionListener remove(MouseMotionListener l,
+ MouseMotionListener oldl)
+ {
+ return (MouseMotionListener) removeInternal(l, oldl);
+ }
+
+ /**
+ * Removes the listener <code>oldl</code> from the listener <code>l</code>.
+ *
+ * @param l the listener chain to reduce
+ * @param oldl the listener to remove
+ * @return the resulting listener chain
+ */
+ public static WindowListener remove(WindowListener l, WindowListener oldl)
+ {
+ return (WindowListener) removeInternal(l, oldl);
+ }
+
+ /**
+ * Removes the listener <code>oldl</code> from the listener <code>l</code>.
+ *
+ * @param l the listener chain to reduce
+ * @param oldl the listener to remove
+ * @return the resulting listener chain
+ * @since 1.4
+ */
+ public static WindowStateListener remove(WindowStateListener l,
+ WindowStateListener oldl)
+ {
+ return (WindowStateListener) removeInternal(l, oldl);
+ }
+
+ /**
+ * Removes the listener <code>oldl</code> from the listener <code>l</code>.
+ *
+ * @param l the listener chain to reduce
+ * @param oldl the listener to remove
+ * @return the resulting listener chain
+ * @since 1.4
+ */
+ public static WindowFocusListener remove(WindowFocusListener l,
+ WindowFocusListener oldl)
+ {
+ return (WindowFocusListener) removeInternal(l, oldl);
+ }
+
+ /**
+ * Removes the listener <code>oldl</code> from the listener <code>l</code>.
+ *
+ * @param l the listener chain to reduce
+ * @param oldl the listener to remove
+ * @return the resulting listener chain
+ */
+ public static ActionListener remove(ActionListener l, ActionListener oldl)
+ {
+ return (ActionListener) removeInternal(l, oldl);
+ }
+
+ /**
+ * Removes the listener <code>oldl</code> from the listener <code>l</code>.
+ *
+ * @param l the listener chain to reduce
+ * @param oldl the listener to remove
+ * @return the resulting listener chain
+ */
+ public static ItemListener remove(ItemListener l, ItemListener oldl)
+ {
+ return (ItemListener) removeInternal(l, oldl);
+ }
+
+ /**
+ * Removes the listener <code>oldl</code> from the listener <code>l</code>.
+ *
+ * @param l the listener chain to reduce
+ * @param oldl the listener to remove
+ * @return the resulting listener chain
+ */
+ public static AdjustmentListener remove(AdjustmentListener l,
+ AdjustmentListener oldl)
+ {
+ return (AdjustmentListener) removeInternal(l, oldl);
+ }
+
+ /**
+ * Removes the listener <code>oldl</code> from the listener <code>l</code>.
+ *
+ * @param l the listener chain to reduce
+ * @param oldl the listener to remove
+ * @return the resulting listener chain
+ */
+ public static TextListener remove(TextListener l, TextListener oldl)
+ {
+ return (TextListener) removeInternal(l, oldl);
+ }
+
+ /**
+ * Removes the listener <code>oldl</code> from the listener <code>l</code>.
+ *
+ * @param l the listener chain to reduce
+ * @param oldl the listener to remove
+ * @return the resulting listener chain
+ * @since 1.2
+ */
+ public static InputMethodListener remove(InputMethodListener l,
+ InputMethodListener oldl)
+ {
+ return (InputMethodListener) removeInternal(l, oldl);
+ }
+
+ /**
+ * Removes the listener <code>oldl</code> from the listener <code>l</code>.
+ *
+ * @param l the listener chain to reduce
+ * @param oldl the listener to remove
+ * @return the resulting listener chain
+ * @since 1.3
+ */
+ public static HierarchyListener remove(HierarchyListener l,
+ HierarchyListener oldl)
+ {
+ return (HierarchyListener) removeInternal(l, oldl);
+ }
+
+ /**
+ * Removes the listener <code>oldl</code> from the listener <code>l</code>.
+ *
+ * @param l the listener chain to reduce
+ * @param oldl the listener to remove
+ * @return the resulting listener chain
+ * @since 1.3
+ */
+ public static HierarchyBoundsListener remove(HierarchyBoundsListener l,
+ HierarchyBoundsListener oldl)
+ {
+ return (HierarchyBoundsListener) removeInternal(l, oldl);
+ }
+
+ /**
+ * Removes the listener <code>oldl</code> from the listener <code>l</code>.
+ *
+ * @param l the listener chain to reduce
+ * @param oldl the listener to remove
+ * @return the resulting listener chain
+ * @since 1.4
+ */
+ public static MouseWheelListener remove(MouseWheelListener l,
+ MouseWheelListener oldl)
+ {
+ return (MouseWheelListener) removeInternal(l, oldl);
+ }
+
+ /**
+ * Chain <code>EventListener</code> a and b.
+ *
+ * @param a the "a" listener, may be null
+ * @param b the "b" listener, may be null
+ * @return latest entry in the chain
+ */
+ protected static EventListener addInternal(EventListener a, EventListener b)
+ {
+ if (a == null)
+ return b;
+ if (b == null)
+ return a;
+ return new AWTEventMulticaster(a, b);
+ }
+
+ /**
+ * Removes the listener <code>oldl</code> from the listener <code>l</code>.
+ *
+ * @param l the listener chain to reduce
+ * @param oldl the listener to remove
+ * @return the resulting listener chain
+ */
+ protected static EventListener removeInternal(EventListener l,
+ EventListener oldl)
+ {
+ if (l == oldl)
+ return null;
+ if (l instanceof AWTEventMulticaster)
+ return ((AWTEventMulticaster) l).remove(oldl);
+ return l;
+ }
+
+ /**
+ * Saves all Serializable listeners to a serialization stream.
+ *
+ * @param s the stream to save to
+ * @param k a prefix stream put before each serializable listener
+ * @throws IOException if serialization fails
+ */
+ protected void saveInternal(ObjectOutputStream s, String k)
+ throws IOException
+ {
+ // This is not documented by Sun, but I think it is correct.
+ if (a instanceof AWTEventMulticaster)
+ ((AWTEventMulticaster) a).saveInternal(s, k);
+ else if (a instanceof Serializable)
+ {
+ s.writeObject(k);
+ s.writeObject(a);
+ }
+ if (b instanceof AWTEventMulticaster)
+ ((AWTEventMulticaster) b).saveInternal(s, k);
+ else if (b instanceof Serializable)
+ {
+ s.writeObject(k);
+ s.writeObject(b);
+ }
+ }
+
+ /**
+ * Saves a Serializable listener chain to a serialization stream.
+ *
+ * @param s the stream to save to
+ * @param k a prefix stream put before each serializable listener
+ * @param l the listener chain to save
+ * @throws IOException if serialization fails
+ */
+ protected static void save(ObjectOutputStream s, String k, EventListener l)
+ throws IOException
+ {
+ // This is not documented by Sun, but I think it is correct.
+ if (l instanceof AWTEventMulticaster)
+ ((AWTEventMulticaster) l).saveInternal(s, k);
+ else if (l instanceof Serializable)
+ {
+ s.writeObject(k);
+ s.writeObject(l);
+ }
+ }
+
+ /**
+ * Returns an array of all chained listeners of the specified type in the
+ * given chain. A null listener returns an empty array, and a listener
+ * which is not an AWTEventMulticaster returns an array of one element. If
+ * no listeners in the chain are of the specified type, an empty array is
+ * returned.
+ *
+ * @param l the listener chain to convert to an array
+ * @param type the type of listeners to collect
+ * @return an array of the listeners of that type in the chain
+ * @throws ClassCastException if type is not assignable from EventListener
+ * @throws NullPointerException if type is null
+ * @throws IllegalArgumentException if type is Void.TYPE
+ * @since 1.4
+ */
+ public static EventListener[] getListeners(EventListener l, Class type)
+ {
+ ArrayList list = new ArrayList();
+ if (l instanceof AWTEventMulticaster)
+ ((AWTEventMulticaster) l).getListeners(list, type);
+ else if (type.isInstance(l))
+ list.add(l);
+ EventListener[] r = (EventListener[]) Array.newInstance(type, list.size());
+ list.toArray(r);
+ return r;
+ }
+
+ /**
+ * Collects all instances of the given type in the chain into the list.
+ *
+ * @param l the list to collect into
+ * @param type the type of listeners to collect
+ * @throws NullPointerException if type is null
+ * @see #getListeners(EventListener, Class)
+ */
+ private void getListeners(ArrayList l, Class type)
+ {
+ if (a instanceof AWTEventMulticaster)
+ ((AWTEventMulticaster) a).getListeners(l, type);
+ else if (type.isInstance(a))
+ l.add(a);
+ if (b instanceof AWTEventMulticaster)
+ ((AWTEventMulticaster) b).getListeners(l, type);
+ else if (type.isInstance(b))
+ l.add(b);
+ }
+} // class AWTEventMulticaster
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,64 @@
+/* AWTException.java -- Generic AWT exception
+ Copyright (C) 1999, 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * This is a generic exception that indicates an exception occurred in the
+ * Abstract Window Toolkit (AWT) system.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @status updated to 1.4
+ */
+public class AWTException extends Exception
+{
+ /**
+ * Compatible with JDK 1.0+.
+ */
+ private static final long serialVersionUID = -1900414231151323879L;
+
+ /**
+ * Create a new instance with the specified detailed error message.
+ *
+ * @param message the detailed error message
+ */
+ public AWTException(String message)
+ {
+ super(message);
+ }
+} // class AWTException
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTKeyStroke.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTKeyStroke.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTKeyStroke.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTKeyStroke.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,672 @@
+/* AWTKeyStroke.java -- an immutable key stroke
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+/**
+ * This class mirrors KeyEvents, representing both low-level key presses and
+ * key releases, and high level key typed inputs. However, this class forms
+ * immutable strokes, and can be efficiently reused via the factory methods
+ * for creating them.
+ *
+ * <p>For backwards compatibility with Swing, this supports a way to build
+ * instances of a subclass, using reflection, provided the subclass has a
+ * no-arg constructor (of any accessibility).
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see #getAWTKeyStroke(char)
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public class AWTKeyStroke implements Serializable
+{
+ /**
+ * Compatible with JDK 1.4+.
+ */
+ private static final long serialVersionUID = -6430539691155161871L;
+
+ /** The mask for modifiers. */
+ private static final int MODIFIERS_MASK = 0x3fef;
+
+ /**
+ * The cache of recently created keystrokes. This maps KeyStrokes to
+ * KeyStrokes in a cache which removes the least recently accessed entry,
+ * under the assumption that garbage collection of a new keystroke is
+ * easy when we find the old one that it matches in the cache.
+ */
+ private static final LinkedHashMap cache = new LinkedHashMap(11, 0.75f, true)
+ {
+ /** The largest the keystroke cache can grow. */
+ private static final int MAX_CACHE_SIZE = 2048;
+
+ /** Prune stale entries. */
+ protected boolean removeEldestEntry(Map.Entry eldest)
+ { // XXX - FIXME Use Map.Entry, not just Entry as gcj 3.1 workaround.
+ return size() > MAX_CACHE_SIZE;
+ }
+ };
+
+ /** The most recently generated keystroke, or null. */
+ private static AWTKeyStroke recent;
+
+ /**
+ * The no-arg constructor of a subclass, or null to use AWTKeyStroke. Note
+ * that this will be left accessible, to get around private access; but
+ * it should not be a security risk as it is highly unlikely that creating
+ * protected instances of the subclass via reflection will do much damage.
+ */
+ private static Constructor ctor;
+
+ /**
+ * A table of keyCode names to values. This is package-private to
+ * avoid an accessor method.
+ *
+ * @see #getAWTKeyStroke(String)
+ */
+ static final HashMap vktable = new HashMap();
+ static
+ {
+ // Using reflection saves the hassle of keeping this in sync with KeyEvent,
+ // at the price of an expensive initialization.
+ AccessController.doPrivileged(new PrivilegedAction()
+ {
+ public Object run()
+ {
+ Field[] fields = KeyEvent.class.getFields();
+ int i = fields.length;
+ try
+ {
+ while (--i >= 0)
+ {
+ Field f = fields[i];
+ String name = f.getName();
+ if (name.startsWith("VK_"))
+ vktable.put(name.substring(3), f.get(null));
+ }
+ }
+ catch (Exception e)
+ {
+ throw (Error) new InternalError().initCause(e);
+ }
+ return null;
+ }
+ });
+ }
+
+ /**
+ * The typed character, or CHAR_UNDEFINED for key presses and releases.
+ *
+ * @serial the keyChar
+ */
+ private char keyChar;
+
+ /**
+ * The virtual key code, or VK_UNDEFINED for key typed. Package visible for
+ * use by Component.
+ *
+ * @serial the keyCode
+ */
+ int keyCode;
+
+ /**
+ * The modifiers in effect. To match Sun, this stores the old style masks
+ * for shift, control, alt, meta, and alt-graph (but not button1); as well
+ * as the new style of extended modifiers for all modifiers.
+ *
+ * @serial bitwise or of the *_DOWN_MASK modifiers
+ */
+ private int modifiers;
+
+ /**
+ * True if this is a key release; should only be true if keyChar is
+ * CHAR_UNDEFINED.
+ *
+ * @serial true to distinguish key pressed from key released
+ */
+ private boolean onKeyRelease;
+
+ /**
+ * Construct a keystroke with default values: it will be interpreted as a
+ * key typed event with an invalid character and no modifiers. Client code
+ * should use the factory methods instead.
+ *
+ * @see #getAWTKeyStroke(char)
+ * @see #getAWTKeyStroke(Character, int)
+ * @see #getAWTKeyStroke(int, int, boolean)
+ * @see #getAWTKeyStroke(int, int)
+ * @see #getAWTKeyStrokeForEvent(KeyEvent)
+ * @see #getAWTKeyStroke(String)
+ */
+ protected AWTKeyStroke()
+ {
+ keyChar = KeyEvent.CHAR_UNDEFINED;
+ }
+
+ /**
+ * Construct a keystroke with the given values. Client code should use the
+ * factory methods instead.
+ *
+ * @param keyChar the character entered, if this is a key typed
+ * @param keyCode the key pressed or released, or VK_UNDEFINED for key typed
+ * @param modifiers the modifier keys for the keystroke, in old or new style
+ * @param onKeyRelease true if this is a key release instead of a press
+ * @see #getAWTKeyStroke(char)
+ * @see #getAWTKeyStroke(Character, int)
+ * @see #getAWTKeyStroke(int, int, boolean)
+ * @see #getAWTKeyStroke(int, int)
+ * @see #getAWTKeyStrokeForEvent(KeyEvent)
+ * @see #getAWTKeyStroke(String)
+ */
+ protected AWTKeyStroke(char keyChar, int keyCode, int modifiers,
+ boolean onKeyRelease)
+ {
+ this.keyChar = keyChar;
+ this.keyCode = keyCode;
+ // No need to call extend(), as only trusted code calls this constructor.
+ this.modifiers = modifiers;
+ this.onKeyRelease = onKeyRelease;
+ }
+
+ /**
+ * Registers a new subclass as being the type of keystrokes to generate in
+ * the factory methods. This operation flushes the cache of stored keystrokes
+ * if the class differs from the current one. The new class must be
+ * AWTKeyStroke or a subclass, and must have a no-arg constructor (which may
+ * be private).
+ *
+ * @param subclass the new runtime type of generated keystrokes
+ * @throws IllegalArgumentException subclass doesn't have no-arg constructor
+ * @throws ClassCastException subclass doesn't extend AWTKeyStroke
+ */
+ protected static void registerSubclass(final Class subclass)
+ {
+ if (subclass == null)
+ throw new IllegalArgumentException();
+ if (subclass.equals(ctor == null ? AWTKeyStroke.class
+ : ctor.getDeclaringClass()))
+ return;
+ if (subclass.equals(AWTKeyStroke.class))
+ {
+ cache.clear();
+ recent = null;
+ ctor = null;
+ return;
+ }
+ try
+ {
+ ctor = (Constructor) AccessController.doPrivileged
+ (new PrivilegedExceptionAction()
+ {
+ public Object run()
+ throws NoSuchMethodException, InstantiationException,
+ IllegalAccessException, InvocationTargetException
+ {
+ Constructor c = subclass.getDeclaredConstructor(null);
+ c.setAccessible(true);
+ // Create a new instance, to make sure that we can, and
+ // to cause any ClassCastException.
+ AWTKeyStroke dummy = (AWTKeyStroke) c.newInstance(null);
+ return c;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ // e.getCause() will not ever be ClassCastException; that should
+ // escape on its own.
+ throw (RuntimeException)
+ new IllegalArgumentException().initCause(e.getCause());
+ }
+ cache.clear();
+ recent = null;
+ }
+
+ /**
+ * Returns a keystroke representing a typed character.
+ *
+ * @param keyChar the typed character
+ * @return the specified keystroke
+ */
+ public static AWTKeyStroke getAWTKeyStroke(char keyChar)
+ {
+ return getAWTKeyStroke(keyChar, KeyEvent.VK_UNDEFINED, 0, false);
+ }
+
+ /**
+ * Returns a keystroke representing a typed character with the given
+ * modifiers. Note that keyChar is a <code>Character</code> instead of a
+ * <code>char</code> to avoid accidental ambiguity with
+ * <code>getAWTKeyStroke(int, int)</code>. The modifiers are the bitwise
+ * or of the masks found in {@link InputEvent}; the new style (*_DOWN_MASK)
+ * is preferred, but the old style will work.
+ *
+ * @param keyChar the typed character
+ * @param modifiers the modifiers, or 0
+ * @return the specified keystroke
+ * @throws IllegalArgumentException if keyChar is null
+ */
+ public static AWTKeyStroke getAWTKeyStroke(Character keyChar, int modifiers)
+ {
+ if (keyChar == null)
+ throw new IllegalArgumentException();
+ return getAWTKeyStroke(keyChar.charValue(), KeyEvent.VK_UNDEFINED,
+ extend(modifiers), false);
+ }
+
+ /**
+ * Returns a keystroke representing a pressed or released key event, with
+ * the given modifiers. The "virtual key" should be one of the VK_*
+ * constants in {@link KeyEvent}. The modifiers are the bitwise or of the
+ * masks found in {@link InputEvent}; the new style (*_DOWN_MASK) is
+ * preferred, but the old style will work.
+ *
+ * @param keyCode the virtual key
+ * @param modifiers the modifiers, or 0
+ * @param release true if this is a key release instead of a key press
+ * @return the specified keystroke
+ */
+ public static AWTKeyStroke getAWTKeyStroke(int keyCode, int modifiers,
+ boolean release)
+ {
+ return getAWTKeyStroke(KeyEvent.CHAR_UNDEFINED, keyCode,
+ extend(modifiers), release);
+ }
+
+ /**
+ * Returns a keystroke representing a pressed key event, with the given
+ * modifiers. The "virtual key" should be one of the VK_* constants in
+ * {@link KeyEvent}. The modifiers are the bitwise or of the masks found
+ * in {@link InputEvent}; the new style (*_DOWN_MASK) is preferred, but the
+ * old style will work.
+ *
+ * @param keyCode the virtual key
+ * @param modifiers the modifiers, or 0
+ * @return the specified keystroke
+ */
+ public static AWTKeyStroke getAWTKeyStroke(int keyCode, int modifiers)
+ {
+ return getAWTKeyStroke(KeyEvent.CHAR_UNDEFINED, keyCode,
+ extend(modifiers), false);
+ }
+
+ /**
+ * Returns a keystroke representing what caused the key event.
+ *
+ * @param event the key event to convert
+ * @return the specified keystroke, or null if the event is invalid
+ * @throws NullPointerException if event is null
+ */
+ public static AWTKeyStroke getAWTKeyStrokeForEvent(KeyEvent event)
+ {
+ switch (event.id)
+ {
+ case KeyEvent.KEY_TYPED:
+ return getAWTKeyStroke(event.getKeyChar(), KeyEvent.VK_UNDEFINED,
+ extend(event.getModifiersEx()), false);
+ case KeyEvent.KEY_PRESSED:
+ return getAWTKeyStroke(KeyEvent.CHAR_UNDEFINED, event.getKeyCode(),
+ extend(event.getModifiersEx()), false);
+ case KeyEvent.KEY_RELEASED:
+ return getAWTKeyStroke(KeyEvent.CHAR_UNDEFINED, event.getKeyCode(),
+ extend(event.getModifiersEx()), true);
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Parses a string and returns the keystroke that it represents. The syntax
+ * for keystrokes is listed below, with tokens separated by an arbitrary
+ * number of spaces:
+ * <pre>
+ * keyStroke := <modifiers>* ( <typedID> | <codeID> )
+ * modifiers := ( shift | control | ctrl | meta | alt
+ * | button1 | button2 | button3 )
+ * typedID := typed <single Unicode character>
+ * codeID := ( pressed | released )? <name>
+ * name := <the KeyEvent field name less the leading "VK_">
+ * </pre>
+ *
+ * <p>Note that the grammar is rather weak, and not all valid keystrokes
+ * can be generated in this manner (for example, a typed space, or anything
+ * with the alt-graph modifier!). The output of AWTKeyStroke.toString()
+ * will not meet the grammar. If pressed or released is not specified,
+ * pressed is assumed. Examples:<br>
+ * <code>
+ * "INSERT" => getAWTKeyStroke(KeyEvent.VK_INSERT, 0);<br>
+ * "control DELETE" =>
+ * getAWTKeyStroke(KeyEvent.VK_DELETE, InputEvent.CTRL_MASK);<br>
+ * "alt shift X" => getAWTKeyStroke(KeyEvent.VK_X,
+ * InputEvent.ALT_MASK | InputEvent.SHIFT_MASK);<br>
+ * "alt shift released X" => getAWTKeyStroke(KeyEvent.VK_X,
+ * InputEvent.ALT_MASK | InputEvent.SHIFT_MASK, true);<br>
+ * "typed a" => getAWTKeyStroke('a');
+ * </code>
+ *
+ * @param s the string to parse
+ * @throws IllegalArgumentException if s is null or cannot be parsed
+ * @return the specified keystroke
+ */
+ public static AWTKeyStroke getAWTKeyStroke(String s)
+ {
+ if (s == null)
+ throw new IllegalArgumentException("null argument");
+ StringTokenizer t = new StringTokenizer(s, " ");
+ if (! t.hasMoreTokens())
+ throw new IllegalArgumentException("no tokens '" + s + "'");
+ int modifiers = 0;
+ boolean released = false;
+ String token = null;
+ do
+ {
+ token = t.nextToken();
+ if ("shift".equals(token))
+ {
+ modifiers |= KeyEvent.SHIFT_MASK;
+ modifiers |= KeyEvent.SHIFT_DOWN_MASK;
+ }
+ else if ("ctrl".equals(token) || "control".equals(token))
+ {
+ modifiers |= KeyEvent.CTRL_MASK;
+ modifiers |= KeyEvent.CTRL_DOWN_MASK;
+ }
+ else if ("meta".equals(token))
+ {
+ modifiers |= KeyEvent.META_MASK;
+ modifiers |= KeyEvent.META_DOWN_MASK;
+ }
+ else if ("alt".equals(token))
+ {
+ modifiers |= KeyEvent.ALT_MASK;
+ modifiers |= KeyEvent.ALT_DOWN_MASK;
+ }
+ else if ("button1".equals(token))
+ modifiers |= KeyEvent.BUTTON1_DOWN_MASK;
+ else if ("button2".equals(token))
+ modifiers |= KeyEvent.BUTTON2_DOWN_MASK;
+ else if ("button3".equals(token))
+ modifiers |= KeyEvent.BUTTON3_DOWN_MASK;
+ else if ("typed".equals(token))
+ {
+ if (t.hasMoreTokens())
+ {
+ token = t.nextToken();
+ if (! t.hasMoreTokens() && token.length() == 1)
+ return getAWTKeyStroke(token.charAt(0),
+ KeyEvent.VK_UNDEFINED, modifiers,
+ false);
+ }
+ throw new IllegalArgumentException("Invalid 'typed' argument '"
+ + s + "'");
+ }
+ else if ("pressed".equals(token))
+ {
+ if (t.hasMoreTokens())
+ token = t.nextToken();
+ break;
+ }
+ else if ("released".equals(token))
+ {
+ released = true;
+ if (t.hasMoreTokens())
+ token = t.nextToken();
+ break;
+ }
+ else
+ break;
+ }
+ while (t.hasMoreTokens());
+ // Now token contains the VK name we must parse.
+ Integer code = (Integer) vktable.get(token);
+ if (code == null)
+ throw new IllegalArgumentException("Unknown token '" + token
+ + "' in '" + s + "'");
+ if (t.hasMoreTokens())
+ throw new IllegalArgumentException("Too many tokens: " + s);
+ return getAWTKeyStroke(KeyEvent.CHAR_UNDEFINED, code.intValue(),
+ modifiers, released);
+ }
+
+ /**
+ * Returns the character of this keystroke, if it was typed.
+ *
+ * @return the character value, or CHAR_UNDEFINED
+ * @see #getAWTKeyStroke(char)
+ */
+ public final char getKeyChar()
+ {
+ return keyChar;
+ }
+
+ /**
+ * Returns the virtual key code of this keystroke, if it was pressed or
+ * released. This will be a VK_* constant from KeyEvent.
+ *
+ * @return the virtual key code value, or VK_UNDEFINED
+ * @see #getAWTKeyStroke(int, int)
+ */
+ public final int getKeyCode()
+ {
+ return keyCode;
+ }
+
+ /**
+ * Returns the modifiers for this keystroke. This will be a bitwise or of
+ * constants from InputEvent; it includes the old style masks for shift,
+ * control, alt, meta, and alt-graph (but not button1); as well as the new
+ * style of extended modifiers for all modifiers.
+ *
+ * @return the modifiers
+ * @see #getAWTKeyStroke(Character, int)
+ * @see #getAWTKeyStroke(int, int)
+ */
+ public final int getModifiers()
+ {
+ return modifiers;
+ }
+
+ /**
+ * Tests if this keystroke is a key release.
+ *
+ * @return true if this is a key release
+ * @see #getAWTKeyStroke(int, int, boolean)
+ */
+ public final boolean isOnKeyRelease()
+ {
+ return onKeyRelease;
+ }
+
+ /**
+ * Returns the AWT event type of this keystroke. This is one of
+ * {@link KeyEvent#KEY_TYPED}, {@link KeyEvent#KEY_PRESSED}, or
+ * {@link KeyEvent#KEY_RELEASED}.
+ *
+ * @return the key event type
+ */
+ public final int getKeyEventType()
+ {
+ return keyCode == KeyEvent.VK_UNDEFINED ? KeyEvent.KEY_TYPED
+ : onKeyRelease ? KeyEvent.KEY_RELEASED : KeyEvent.KEY_PRESSED;
+ }
+
+ /**
+ * Returns a hashcode for this key event. It is not documented, but appears
+ * to be: <code>(getKeyChar() + 1) * (getKeyCode() + 1)
+ * * (getModifiers() + 1) * 2 + (isOnKeyRelease() ? 1 : 2)</code>.
+ *
+ * @return the hashcode
+ */
+ public int hashCode()
+ {
+ return (keyChar + 1) * (keyCode + 1) * (modifiers + 1) * 2
+ + (onKeyRelease ? 1 : 2);
+ }
+
+ /**
+ * Tests two keystrokes for equality.
+ *
+ * @param o the object to test
+ * @return true if it is equal
+ */
+ public final boolean equals(Object o)
+ {
+ if (! (o instanceof AWTKeyStroke))
+ return false;
+ AWTKeyStroke s = (AWTKeyStroke) o;
+ return this == o || (keyChar == s.keyChar && keyCode == s.keyCode
+ && modifiers == s.modifiers
+ && onKeyRelease == s.onKeyRelease);
+ }
+
+ /**
+ * Returns a string representation of this keystroke. For typed keystrokes,
+ * this is <code>"keyChar " + KeyEvent.getKeyModifiersText(getModifiers())
+ + getKeyChar()</code>; for pressed and released keystrokes, this is
+ * <code>"keyCode " + KeyEvent.getKeyModifiersText(getModifiers())
+ * + KeyEvent.getKeyText(getKeyCode())
+ * + (isOnKeyRelease() ? "-R" : "-P")</code>.
+ *
+ * @return a string representation
+ */
+ public String toString()
+ {
+ if (keyCode == KeyEvent.VK_UNDEFINED)
+ return "keyChar " + KeyEvent.getKeyModifiersText(modifiers) + keyChar;
+ return "keyCode " + KeyEvent.getKeyModifiersText(modifiers)
+ + KeyEvent.getKeyText(keyCode) + (onKeyRelease ? "-R" : "-P");
+ }
+
+ /**
+ * Returns a cached version of the deserialized keystroke, if available.
+ *
+ * @return a cached replacement
+ * @throws ObjectStreamException if something goes wrong
+ */
+ protected Object readResolve() throws ObjectStreamException
+ {
+ AWTKeyStroke s = (AWTKeyStroke) cache.get(this);
+ if (s != null)
+ return s;
+ cache.put(this, this);
+ return this;
+ }
+
+ /**
+ * Gets the appropriate keystroke, creating one if necessary.
+ *
+ * @param keyChar the keyChar
+ * @param keyCode the keyCode
+ * @param modifiers the modifiers
+ * @param release true for key release
+ * @return the specified keystroke
+ */
+ private static AWTKeyStroke getAWTKeyStroke(char keyChar, int keyCode,
+ int modifiers, boolean release)
+ {
+ // Check level 0 cache.
+ AWTKeyStroke stroke = recent; // Avoid thread races.
+ if (stroke != null && stroke.keyChar == keyChar
+ && stroke.keyCode == keyCode && stroke.modifiers == modifiers
+ && stroke.onKeyRelease == release)
+ return stroke;
+ // Create a new object, on the assumption that if it has a match in the
+ // cache, the VM can easily garbage collect it as it is temporary.
+ Constructor c = ctor; // Avoid thread races.
+ if (c == null)
+ stroke = new AWTKeyStroke(keyChar, keyCode, modifiers, release);
+ else
+ try
+ {
+ stroke = (AWTKeyStroke) c.newInstance(null);
+ stroke.keyChar = keyChar;
+ stroke.keyCode = keyCode;
+ stroke.modifiers = modifiers;
+ stroke.onKeyRelease = release;
+ }
+ catch (Exception e)
+ {
+ throw (Error) new InternalError().initCause(e);
+ }
+ // Check level 1 cache.
+ AWTKeyStroke cached = (AWTKeyStroke) cache.get(stroke);
+ if (cached == null)
+ cache.put(stroke, stroke);
+ else
+ stroke = cached;
+ return recent = stroke;
+ }
+
+ /**
+ * Converts the modifiers to the appropriate format.
+ *
+ * @param mod the modifiers to convert
+ * @return the adjusted modifiers
+ */
+ private static int extend(int mod)
+ {
+ if ((mod & (KeyEvent.SHIFT_MASK | KeyEvent.SHIFT_DOWN_MASK)) != 0)
+ mod |= KeyEvent.SHIFT_MASK | KeyEvent.SHIFT_DOWN_MASK;
+ if ((mod & (KeyEvent.CTRL_MASK | KeyEvent.CTRL_DOWN_MASK)) != 0)
+ mod |= KeyEvent.CTRL_MASK | KeyEvent.CTRL_DOWN_MASK;
+ if ((mod & (KeyEvent.META_MASK | KeyEvent.META_DOWN_MASK)) != 0)
+ mod |= KeyEvent.META_MASK | KeyEvent.META_DOWN_MASK;
+ if ((mod & (KeyEvent.ALT_MASK | KeyEvent.ALT_DOWN_MASK)) != 0)
+ mod |= KeyEvent.ALT_MASK | KeyEvent.ALT_DOWN_MASK;
+ if ((mod & (KeyEvent.ALT_GRAPH_MASK | KeyEvent.ALT_GRAPH_DOWN_MASK)) != 0)
+ mod |= KeyEvent.ALT_GRAPH_MASK | KeyEvent.ALT_GRAPH_DOWN_MASK;
+ if ((mod & KeyEvent.BUTTON1_MASK) != 0)
+ mod |= KeyEvent.BUTTON1_DOWN_MASK;
+ return mod & MODIFIERS_MASK;
+ }
+} // class AWTKeyStroke
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTPermission.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTPermission.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTPermission.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AWTPermission.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,121 @@
+/* AWTPermission.java -- AWT related permissions
+ Copyright (C) 2000, 2002 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.security.BasicPermission;
+
+/**
+ * This class implements permissions for AWT. This is a named
+ * permission. No actions are defined.
+ *
+ * <p>The following table provides a list of all the possible AWTPermission
+ * permission names with a description of what that permission allows.<br>
+ * <table border=1>
+ * <tr><th>Permission Name</th><th>Permission Allows</th><th>Risks</th</tr>
+ * <tr>
+ * <td><code>accessClipboard</code></td>
+ * <td>posting and reading the AWT clipboard</td>
+ * <td>the clipboard may contain sensitive data</td></tr>
+ * <tr>
+ * <td><code>accessEventQueue</code></td>
+ * <td>access to the AWT event queue</td>
+ * <td>malicious code could remove real events and replace them with bogus
+ * ones, including simulating the user granting permission</td></tr>
+ * <tr>
+ * <td><code>listenToAllAWTEvents</code></td>
+ * <td>listen to system-wide AWT events</td>
+ * <td>malicious code can read passwords entered in an AWT event, and in
+ * combination with accessEventQueue, could fake system events</td></tr>
+ * <tr>
+ * <td><code>showWindowWithoutWarningBanner</code></td>
+ * <td>display a window without a banner notification of insecurity</td>
+ * <td>malicious code could install a Trojan horse applet that looks like
+ * a normal window, and thus steal data like passwords</td></tr>
+ * <tr>
+ * <td><code>readDisplayPixels</code></td>
+ * <td>read back pixels from the display screen</td>
+ * <td>malicious code could snoop on the user's actions</td></tr>
+ * <tr>
+ * <td><code>createRobot</code></td>
+ * <td>create an instance of java.awt.Robot</td>
+ * <td>these objects can generate events as though they were the user; so
+ * malicious code could control the system</td></tr>
+ * <tr>
+ * <td><code>fullScreenExclusive</code></td>
+ * <td>enter full-screen exclusive mode</td>
+ * <td>malicious code could masquerade as a trusted program</td></tr>
+ * </table>
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public final class AWTPermission extends BasicPermission
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = 8890392402588814465L;
+
+ /**
+ * Construct a AWTPermission with the given name.
+ *
+ * @param name the permission name
+ * @throws NullPointerException if name is null
+ * @throws IllegalArgumentException if name is invalid
+ */
+ public AWTPermission(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Create a new permission with the specified name. The actions argument
+ * is ignored, as AWT permissions have no actions.
+ *
+ * @param name the permission name
+ * @param actions ignored
+ * @throws NullPointerException if name is null
+ * @throws IllegalArgumentException if name is invalid
+ */
+ public AWTPermission(String name, String actions)
+ {
+ super(name);
+ }
+} // class AWTPermission
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ActiveEvent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ActiveEvent.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ActiveEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ActiveEvent.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,61 @@
+/* ActiveEvent.java -- a self-dispatching event
+ Copyright (C) 2000, 2002 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * An interface for events which can dispatch themselves in another thread.
+ * This has two uses: first, if your code is in a critical section, calling a
+ * synchronized method might deadlock. But by using an ActiveEvent to call
+ * the second section, it will not obtain the lock until you have left the
+ * critical section, avoiding deadlock. The second use is for calling
+ * untrusted code. For example, system code should use an ActiveEvent to
+ * invoke user code securely.
+ *
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface ActiveEvent
+{
+ /**
+ * Dispatch the event, according to what the event needs done. Invoked
+ * automatically if this is placed on the <code>EventDispatchQueue</code>.
+ */
+ void dispatch();
+} // interface ActiveEvent
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Adjustable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Adjustable.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Adjustable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Adjustable.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,171 @@
+/* Adjustable.java -- Objects with a numeric adjustment scale
+ Copyright (C) 1999, 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.event.AdjustmentListener;
+
+/**
+ * This interface is for objects that take a numeric value that can be
+ * adjusted within a bounded range. For example, a scroll bar.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public interface Adjustable
+{
+ /** Constant for an adjustable object with horizontal orientation. */
+ int HORIZONTAL = 0;
+
+ /** Constant for an adjustable object with vertical orientation. */
+ int VERTICAL = 1;
+
+ /** Constant for an adjustable object with no orientation. */
+ int NO_ORIENTATION = 2;
+
+ /**
+ * Returns a constant representing the orientation of the object.
+ *
+ * @return the orientation of this object
+ * @see #HORIZONTAL
+ * @see #VERTICAL
+ * @see #NO_ORIENTATION
+ */
+ int getOrientation();
+
+ /**
+ * Sets the minimum value this object can have.
+ *
+ * @param minimum the new minimum value
+ */
+ void setMinimum(int minimum);
+
+ /**
+ * Returns the minimum value this object can have.
+ *
+ * @return the minimum value
+ */
+ int getMinimum();
+
+ /**
+ * Sets the maximum value this object can have.
+ *
+ * @param maximum the new maximum value
+ */
+ void setMaximum(int maximum);
+
+ /**
+ * Returns the maximum value this object can have.
+ *
+ * @return the maximum value
+ */
+ int getMaximum();
+
+ /**
+ * Sets the increment value for incrementing the value by units.
+ *
+ * @param increment the unit increment value
+ */
+ void setUnitIncrement(int increment);
+
+ /**
+ * Returns the increment value for incrementing the value by units.
+ *
+ * @return the unit increment value
+ */
+ int getUnitIncrement();
+
+ /**
+ * Sets the increment value for incrementing the value by blocks.
+ *
+ * @param increment the block increment value
+ */
+ void setBlockIncrement(int increment);
+
+ /**
+ * Returns the increment value for incrementing the value by blocks.
+ *
+ * @return the block increment value
+ */
+ int getBlockIncrement();
+
+ /**
+ * Sets the length of the indicator for this object to the specified value.
+ *
+ * @param length the indicator length
+ */
+ void setVisibleAmount(int length);
+
+ /**
+ * Returns the length of the indicator for this object.
+ *
+ * @return the indicator length
+ */
+ int getVisibleAmount();
+
+ /**
+ * Sets the current value of the object.
+ *
+ * @param value the new value
+ */
+ void setValue(int value);
+
+ /**
+ * Returns the current value of the object.
+ *
+ * @return the current value
+ */
+ int getValue();
+
+ /**
+ * Adds a listener that will receive adjustment events for this object.
+ *
+ * @param listener the adjustment listener to add
+ * @see java.awt.event.AdjustmentEvent
+ */
+ void addAdjustmentListener(AdjustmentListener listener);
+
+ /**
+ * Removes an adjustment listener from this object.
+ *
+ * @param listener the adjustment listener to remove
+ * @see java.awt.event.AdjustmentEvent
+ */
+ void removeAdjustmentListener(AdjustmentListener listener);
+} // interface Adjustable
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AlphaComposite.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AlphaComposite.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AlphaComposite.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AlphaComposite.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,180 @@
+/* AlphaComposite.java -- provides a context for performing alpha compositing
+ Copyright (C) 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import gnu.java.awt.java2d.AlphaCompositeContext;
+
+import java.awt.image.ColorModel;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Composite
+ * @see CompositeContext
+ * @since 1.3
+ * @status updated to 1.4 except for createContext, needs documentation
+ */
+public final class AlphaComposite implements Composite
+{
+ /** Map Long to AlphaComposites. See getInstance for details. */
+ private static final LinkedHashMap cache = new LinkedHashMap(11, 0.75f, true)
+ {
+ /** The largest the alpha composite cache can grow. */
+ private static final int MAX_CACHE_SIZE = 2048;
+
+ /** Prune stale entries. */
+ protected boolean removeEldestEntry(Map.Entry eldest)
+ { // XXX - FIXME Use Map.Entry, not just Entry as gcj 3.1 workaround.
+ return size() > MAX_CACHE_SIZE;
+ }
+ };
+
+ public static final int CLEAR = 1;
+ public static final int SRC = 2;
+ public static final int DST = 9;
+ public static final int SRC_OVER = 3;
+ public static final int DST_OVER = 4;
+ public static final int SRC_IN = 5;
+ public static final int DST_IN = 6;
+ public static final int SRC_OUT = 7;
+ public static final int DST_OUT = 8;
+ public static final int SRC_ATOP = 10;
+ public static final int DST_ATOP = 11;
+ public static final int XOR = 12;
+ public static final AlphaComposite Clear = getInstance(CLEAR);
+ public static final AlphaComposite Src = getInstance(SRC);
+ public static final AlphaComposite Dst = getInstance(DST);
+ public static final AlphaComposite SrcOver = getInstance(SRC_OVER);
+ public static final AlphaComposite DstOver = getInstance(DST_OVER);
+ public static final AlphaComposite SrcIn = getInstance(SRC_IN);
+ public static final AlphaComposite DstIn = getInstance(DST_IN);
+ public static final AlphaComposite SrcOut = getInstance(SRC_OUT);
+ public static final AlphaComposite DstOut = getInstance(DST_OUT);
+ public static final AlphaComposite SrcAtop = getInstance(SRC_ATOP);
+ public static final AlphaComposite DstAtop = getInstance(DST_ATOP);
+ public static final AlphaComposite Xor = getInstance(XOR);
+
+ private final int rule;
+ private final float alpha;
+ private AlphaComposite(int rule, float alpha)
+ {
+ this.rule = rule;
+ this.alpha = alpha;
+ }
+
+ /**
+ * Creates an AlphaComposite object with the specified rule.
+ *
+ * @param rule The compositing rule.
+ *
+ * @exception IllegalArgumentException If rule is not one of the following:
+ * CLEAR, SRC, DST, SRC_OVER, DST_OVER, SRC_IN, DST_IN, SRC_OUT, DST_OUT,
+ * SRC_ATOP, DST_ATOP, or XOR.
+ */
+ public static AlphaComposite getInstance(int rule)
+ {
+ return getInstance(rule, 1);
+ }
+
+ /**
+ * Creates an AlphaComposite object with the specified rule and the constant
+ * alpha to multiply with the alpha of the source. The source is multiplied
+ * with the specified alpha before being composited with the destination.
+ *
+ * @param rule The compositing rule.
+ *
+ * @exception IllegalArgumentException If rule is not one of the following:
+ * CLEAR, SRC, DST, SRC_OVER, DST_OVER, SRC_IN, DST_IN, SRC_OUT, DST_OUT,
+ * SRC_ATOP, DST_ATOP, or XOR.
+ */
+ public static AlphaComposite getInstance(int rule, float alpha)
+ {
+ if (rule < CLEAR || rule > XOR || ! (alpha >= 0 && alpha <= 1))
+ throw new IllegalArgumentException();
+ // This long is guaranteed unique for all valid alpha composites.
+ Long l = new Long(rule + Double.doubleToLongBits(alpha));
+ AlphaComposite a = (AlphaComposite) cache.get(l);
+ if (a == null)
+ {
+ a = new AlphaComposite(rule, alpha);
+ cache.put(l, a);
+ }
+ return a;
+ }
+
+ /**
+ * Creates a {@link CompositeContext} that can be used to perform
+ * compositing operations according to this AlphaComposite settings.
+ *
+ * @param srcColorModel the color model of the source raster
+ * @param dstColorModel the color model of the destination raster
+ * @param hints the rendering hints to use
+ *
+ * @return a {@link CompositeContext} that can be used to perform
+ * compositing operations according to this AlphaComposite settings
+ */
+ public CompositeContext createContext(ColorModel srcColorModel,
+ ColorModel dstColorModel,
+ RenderingHints hints)
+ {
+ return new AlphaCompositeContext(this, srcColorModel, dstColorModel);
+ }
+
+ public float getAlpha()
+ {
+ return alpha;
+ }
+ public int getRule()
+ {
+ return rule;
+ }
+ public int hashCode()
+ {
+ return 31 * Float.floatToIntBits(alpha) + rule;
+ }
+ public boolean equals(Object o)
+ {
+ if (! (o instanceof AlphaComposite))
+ return false;
+ AlphaComposite a = (AlphaComposite) o;
+ return rule == a.rule && alpha == a.alpha;
+ }
+} // class AlphaComposite
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AttributeValue.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AttributeValue.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AttributeValue.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/AttributeValue.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,98 @@
+/* AttributeValue.java -- parent of type-safe enums of attributes
+ Copyright (C) 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * This class is undocumented by Sun, but it is the parent of several other
+ * classes, all of which are type-safe enumerations. This takes care of
+ * <code>equals</code>, <code>toString</code>, and <code>hashCode</code>, so
+ * that you don't have to (although hashCode is commonly overridden).
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ */
+class AttributeValue
+{
+ /** The value of the enumeration. Package visible for speed. */
+ final int value;
+
+ /** The list of enumeration names for the given subclass. */
+ private final String[] names;
+
+ /**
+ * Construct a type-safe enumeration element. For example,<br>
+ * <pre>
+ * class Foo extends AttributeValue
+ * {
+ * private static final String[] names = { "one", "two" }
+ * public static final Foo ONE = new Foo(0);
+ * public static final Foo TWO = new Foo(1);
+ * private Foo(int value) { super(value, names); }
+ * }
+ * </pre>
+ *
+ * @param value the position of this enumeration element, consecutive from 0
+ * @param names the constant list of enumeration names for the subclass
+ */
+ AttributeValue(int value, String[] names)
+ {
+ this.value = value;
+ this.names = names;
+ }
+
+ /**
+ * Returns the hashcode of this element. This is the index of the element
+ * in the enumeration. Note that equals defaults to the == relation.
+ *
+ * @return the hashcode
+ */
+ public int hashCode()
+ {
+ return value;
+ }
+
+ /**
+ * Returns the name of this enumeration element.
+ *
+ * @return the element name
+ */
+ public String toString()
+ {
+ return names[value];
+ }
+} // class AttributeValue
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/BasicStroke.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/BasicStroke.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/BasicStroke.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/BasicStroke.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,748 @@
+/* BasicStroke.java --
+ Copyright (C) 2002, 2003, 2004, 2005, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import gnu.java.awt.java2d.CubicSegment;
+import gnu.java.awt.java2d.LineSegment;
+import gnu.java.awt.java2d.QuadSegment;
+import gnu.java.awt.java2d.Segment;
+
+import java.awt.geom.GeneralPath;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Point2D;
+import java.util.Arrays;
+
+/**
+ * A general purpose {@link Stroke} implementation that can represent a wide
+ * variety of line styles for use with subclasses of {@link Graphics2D}.
+ * <p>
+ * The line cap and join styles can be set using the options illustrated
+ * here:
+ * <p>
+ * <img src="doc-files/capjoin.png" width="350" height="180"
+ * alt="Illustration of line cap and join styles" />
+ * <p>
+ * A dash array can be used to specify lines with alternating opaque and
+ * transparent sections.
+ */
+public class BasicStroke implements Stroke
+{
+ /**
+ * Indicates a mitered line join style. See the class overview for an
+ * illustration.
+ */
+ public static final int JOIN_MITER = 0;
+
+ /**
+ * Indicates a rounded line join style. See the class overview for an
+ * illustration.
+ */
+ public static final int JOIN_ROUND = 1;
+
+ /**
+ * Indicates a bevelled line join style. See the class overview for an
+ * illustration.
+ */
+ public static final int JOIN_BEVEL = 2;
+
+ /**
+ * Indicates a flat line cap style. See the class overview for an
+ * illustration.
+ */
+ public static final int CAP_BUTT = 0;
+
+ /**
+ * Indicates a rounded line cap style. See the class overview for an
+ * illustration.
+ */
+ public static final int CAP_ROUND = 1;
+
+ /**
+ * Indicates a square line cap style. See the class overview for an
+ * illustration.
+ */
+ public static final int CAP_SQUARE = 2;
+
+ /** The stroke width. */
+ private final float width;
+
+ /** The line cap style. */
+ private final int cap;
+
+ /** The line join style. */
+ private final int join;
+
+ /** The miter limit. */
+ private final float limit;
+
+ /** The dash array. */
+ private final float[] dash;
+
+ /** The dash phase. */
+ private final float phase;
+
+ // The inner and outer paths of the stroke
+ private Segment start, end;
+
+ /**
+ * Creates a new <code>BasicStroke</code> instance with the given attributes.
+ *
+ * @param width the line width (>= 0.0f).
+ * @param cap the line cap style (one of {@link #CAP_BUTT},
+ * {@link #CAP_ROUND} or {@link #CAP_SQUARE}).
+ * @param join the line join style (one of {@link #JOIN_ROUND},
+ * {@link #JOIN_BEVEL}, or {@link #JOIN_MITER}).
+ * @param miterlimit the limit to trim the miter join. The miterlimit must be
+ * greater than or equal to 1.0f.
+ * @param dash The array representing the dashing pattern. There must be at
+ * least one non-zero entry.
+ * @param dashPhase is negative and dash is not null.
+ *
+ * @throws IllegalArgumentException If one input parameter doesn't meet
+ * its needs.
+ */
+ public BasicStroke(float width, int cap, int join, float miterlimit,
+ float[] dash, float dashPhase)
+ {
+ if (width < 0.0f )
+ throw new IllegalArgumentException("width " + width + " < 0");
+ else if (cap < CAP_BUTT || cap > CAP_SQUARE)
+ throw new IllegalArgumentException("cap " + cap + " out of range ["
+ + CAP_BUTT + ".." + CAP_SQUARE + "]");
+ else if (miterlimit < 1.0f && join == JOIN_MITER)
+ throw new IllegalArgumentException("miterlimit " + miterlimit
+ + " < 1.0f while join == JOIN_MITER");
+ else if (join < JOIN_MITER || join > JOIN_BEVEL)
+ throw new IllegalArgumentException("join " + join + " out of range ["
+ + JOIN_MITER + ".." + JOIN_BEVEL
+ + "]");
+ else if (dashPhase < 0.0f && dash != null)
+ throw new IllegalArgumentException("dashPhase " + dashPhase
+ + " < 0.0f while dash != null");
+ else if (dash != null)
+ if (dash.length == 0)
+ throw new IllegalArgumentException("dash.length is 0");
+ else
+ {
+ boolean allZero = true;
+
+ for ( int i = 0; i < dash.length; ++i)
+ {
+ if (dash[i] != 0.0f)
+ {
+ allZero = false;
+ break;
+ }
+ }
+
+ if (allZero)
+ throw new IllegalArgumentException("all dashes are 0.0f");
+ }
+
+ this.width = width;
+ this.cap = cap;
+ this.join = join;
+ limit = miterlimit;
+ this.dash = dash == null ? null : (float[]) dash.clone();
+ phase = dashPhase;
+ }
+
+ /**
+ * Creates a new <code>BasicStroke</code> instance with the given attributes.
+ *
+ * @param width the line width (>= 0.0f).
+ * @param cap the line cap style (one of {@link #CAP_BUTT},
+ * {@link #CAP_ROUND} or {@link #CAP_SQUARE}).
+ * @param join the line join style (one of {@link #JOIN_ROUND},
+ * {@link #JOIN_BEVEL}, or {@link #JOIN_MITER}).
+ * @param miterlimit the limit to trim the miter join. The miterlimit must be
+ * greater than or equal to 1.0f.
+ *
+ * @throws IllegalArgumentException If one input parameter doesn't meet
+ * its needs.
+ */
+ public BasicStroke(float width, int cap, int join, float miterlimit)
+ {
+ this(width, cap, join, miterlimit, null, 0);
+ }
+
+ /**
+ * Creates a new <code>BasicStroke</code> instance with the given attributes.
+ * The miter limit defaults to <code>10.0</code>.
+ *
+ * @param width the line width (>= 0.0f).
+ * @param cap the line cap style (one of {@link #CAP_BUTT},
+ * {@link #CAP_ROUND} or {@link #CAP_SQUARE}).
+ * @param join the line join style (one of {@link #JOIN_ROUND},
+ * {@link #JOIN_BEVEL}, or {@link #JOIN_MITER}).
+ *
+ * @throws IllegalArgumentException If one input parameter doesn't meet
+ * its needs.
+ */
+ public BasicStroke(float width, int cap, int join)
+ {
+ this(width, cap, join, 10, null, 0);
+ }
+
+ /**
+ * Creates a new <code>BasicStroke</code> instance with the given line
+ * width. The default values are:
+ * <ul>
+ * <li>line cap style: {@link #CAP_SQUARE};</li>
+ * <li>line join style: {@link #JOIN_MITER};</li>
+ * <li>miter limit: <code>10.0f</code>.
+ * </ul>
+ *
+ * @param width the line width (>= 0.0f).
+ *
+ * @throws IllegalArgumentException If <code>width</code> is negative.
+ */
+ public BasicStroke(float width)
+ {
+ this(width, CAP_SQUARE, JOIN_MITER, 10, null, 0);
+ }
+
+ /**
+ * Creates a new <code>BasicStroke</code> instance. The default values are:
+ * <ul>
+ * <li>line width: <code>1.0f</code>;</li>
+ * <li>line cap style: {@link #CAP_SQUARE};</li>
+ * <li>line join style: {@link #JOIN_MITER};</li>
+ * <li>miter limit: <code>10.0f</code>.
+ * </ul>
+ */
+ public BasicStroke()
+ {
+ this(1, CAP_SQUARE, JOIN_MITER, 10, null, 0);
+ }
+
+ /**
+ * Creates a shape representing the stroked outline of the given shape.
+ * THIS METHOD IS NOT YET IMPLEMENTED.
+ *
+ * @param s the shape.
+ */
+ public Shape createStrokedShape(Shape s)
+ {
+ PathIterator pi = s.getPathIterator(null);
+
+ if( dash == null )
+ return solidStroke( pi );
+
+ return dashedStroke( pi );
+ }
+
+ /**
+ * Returns the line width.
+ *
+ * @return The line width.
+ */
+ public float getLineWidth()
+ {
+ return width;
+ }
+
+ /**
+ * Returns a code indicating the line cap style (one of {@link #CAP_BUTT},
+ * {@link #CAP_ROUND}, {@link #CAP_SQUARE}).
+ *
+ * @return A code indicating the line cap style.
+ */
+ public int getEndCap()
+ {
+ return cap;
+ }
+
+ /**
+ * Returns a code indicating the line join style (one of {@link #JOIN_BEVEL},
+ * {@link #JOIN_MITER} or {@link #JOIN_ROUND}).
+ *
+ * @return A code indicating the line join style.
+ */
+ public int getLineJoin()
+ {
+ return join;
+ }
+
+ /**
+ * Returns the miter limit.
+ *
+ * @return The miter limit.
+ */
+ public float getMiterLimit()
+ {
+ return limit;
+ }
+
+ /**
+ * Returns the dash array, which defines the length of alternate opaque and
+ * transparent sections in lines drawn with this stroke. If
+ * <code>null</code>, a continuous line will be drawn.
+ *
+ * @return The dash array (possibly <code>null</code>).
+ */
+ public float[] getDashArray()
+ {
+ return dash;
+ }
+
+ /**
+ * Returns the dash phase for the stroke. This is the offset from the start
+ * of a path at which the pattern defined by {@link #getDashArray()} is
+ * rendered.
+ *
+ * @return The dash phase.
+ */
+ public float getDashPhase()
+ {
+ return phase;
+ }
+
+ /**
+ * Returns the hash code for this object. The hash is calculated by
+ * xoring the hash, cap, join, limit, dash array and phase values
+ * (converted to <code>int</code> first with
+ * <code>Float.floatToIntBits()</code> if the value is a
+ * <code>float</code>).
+ *
+ * @return The hash code.
+ */
+ public int hashCode()
+ {
+ int hash = Float.floatToIntBits(width);
+ hash ^= cap;
+ hash ^= join;
+ hash ^= Float.floatToIntBits(limit);
+
+ if (dash != null)
+ for (int i = 0; i < dash.length; i++)
+ hash ^= Float.floatToIntBits(dash[i]);
+
+ hash ^= Float.floatToIntBits(phase);
+
+ return hash;
+ }
+
+ /**
+ * Compares this <code>BasicStroke</code> for equality with an arbitrary
+ * object. This method returns <code>true</code> if and only if:
+ * <ul>
+ * <li><code>o</code> is an instanceof <code>BasicStroke</code>;</li>
+ * <li>this object has the same width, line cap style, line join style,
+ * miter limit, dash array and dash phase as <code>o</code>.</li>
+ * </ul>
+ *
+ * @param o the object (<code>null</code> permitted).
+ *
+ * @return <code>true</code> if this stroke is equal to <code>o</code> and
+ * <code>false</code> otherwise.
+ */
+ public boolean equals(Object o)
+ {
+ if (! (o instanceof BasicStroke))
+ return false;
+ BasicStroke s = (BasicStroke) o;
+ return width == s.width && cap == s.cap && join == s.join
+ && limit == s.limit && Arrays.equals(dash, s.dash) && phase == s.phase;
+ }
+
+ private Shape solidStroke(PathIterator pi)
+ {
+ double[] coords = new double[6];
+ double x, y, x0, y0;
+ boolean pathOpen = false;
+ GeneralPath output = new GeneralPath( );
+ Segment[] p;
+ x = x0 = y = y0 = 0;
+
+ while( !pi.isDone() )
+ {
+ switch( pi.currentSegment(coords) )
+ {
+ case PathIterator.SEG_MOVETO:
+ x0 = x = coords[0];
+ y0 = y = coords[1];
+ if( pathOpen )
+ {
+ capEnds();
+ convertPath(output, start);
+ start = end = null;
+ pathOpen = false;
+ }
+ break;
+
+ case PathIterator.SEG_LINETO:
+ p = (new LineSegment(x, y, coords[0], coords[1])).
+ getDisplacedSegments(width/2.0);
+ if( !pathOpen )
+ {
+ start = p[0];
+ end = p[1];
+ pathOpen = true;
+ }
+ else
+ addSegments(p);
+
+ x = coords[0];
+ y = coords[1];
+ break;
+
+ case PathIterator.SEG_QUADTO:
+ p = (new QuadSegment(x, y, coords[0], coords[1], coords[2],
+ coords[3])).getDisplacedSegments(width/2.0);
+ if( !pathOpen )
+ {
+ start = p[0];
+ end = p[1];
+ pathOpen = true;
+ }
+ else
+ addSegments(p);
+
+ x = coords[2];
+ y = coords[3];
+ break;
+
+ case PathIterator.SEG_CUBICTO:
+ p = new CubicSegment(x, y, coords[0], coords[1],
+ coords[2], coords[3],
+ coords[4], coords[5]).getDisplacedSegments(width/2.0);
+ if( !pathOpen )
+ {
+ start = p[0];
+ end = p[1];
+ pathOpen = true;
+ }
+ else
+ addSegments(p);
+
+ x = coords[4];
+ y = coords[5];
+ break;
+
+ case PathIterator.SEG_CLOSE:
+ if (x == x0 && y == y0)
+ {
+ joinSegments(new Segment[] { start.first, end.first });
+ }
+ else
+ {
+ p = (new LineSegment(x, y, x0, y0)).getDisplacedSegments(width / 2.0);
+ addSegments(p);
+ }
+ convertPath(output, start);
+ convertPath(output, end);
+ start = end = null;
+ pathOpen = false;
+ output.setWindingRule(GeneralPath.WIND_EVEN_ODD);
+ break;
+ }
+ pi.next();
+ }
+
+ if( pathOpen )
+ {
+ capEnds();
+ convertPath(output, start);
+ }
+ return output;
+ }
+
+ private Shape dashedStroke(PathIterator pi)
+ {
+ GeneralPath out = new GeneralPath();
+ return out;
+ }
+
+ /**
+ * Cap the ends of the path (joining the start and end list of segments)
+ */
+ private void capEnds()
+ {
+ Segment returnPath = end.last;
+
+ end.reverseAll(); // reverse the path.
+ end = null;
+ capEnd(start, returnPath);
+ start.last = returnPath.last;
+ end = null;
+
+ capEnd(start, start);
+ }
+
+ /**
+ * Append the Segments in s to the GeneralPath p
+ */
+ private void convertPath(GeneralPath p, Segment s)
+ {
+ Segment v = s;
+ p.moveTo((float)s.P1.getX(), (float)s.P1.getY());
+
+ do
+ {
+ if(v instanceof LineSegment)
+ p.lineTo((float)v.P2.getX(), (float)v.P2.getY());
+ else if(v instanceof QuadSegment)
+ p.quadTo((float)((QuadSegment)v).cp.getX(),
+ (float)((QuadSegment)v).cp.getY(),
+ (float)v.P2.getX(),
+ (float)v.P2.getY());
+ else if(v instanceof CubicSegment)
+ p.curveTo((float)((CubicSegment)v).cp1.getX(),
+ (float)((CubicSegment)v).cp1.getY(),
+ (float)((CubicSegment)v).cp2.getX(),
+ (float)((CubicSegment)v).cp2.getY(),
+ (float)v.P2.getX(),
+ (float)v.P2.getY());
+ v = v.next;
+ } while(v != s && v != null);
+
+ p.closePath();
+ }
+
+ /**
+ * Add the segments to start and end (the inner and outer edges of the stroke)
+ */
+ private void addSegments(Segment[] segments)
+ {
+ joinSegments(segments);
+ start.add(segments[0]);
+ end.add(segments[1]);
+ }
+
+ private void joinSegments(Segment[] segments)
+ {
+ double[] p0 = start.last.cp2();
+ double[] p1 = new double[]{start.last.P2.getX(), start.last.P2.getY()};
+ double[] p2 = new double[]{segments[0].first.P1.getX(), segments[0].first.P1.getY()};
+ double[] p3 = segments[0].cp1();
+ Point2D p;
+
+ p = lineIntersection(p0[0],p0[1],p1[0],p1[1],
+ p2[0],p2[1],p3[0],p3[1], false);
+
+ double det = (p1[0] - p0[0])*(p3[1] - p2[1]) -
+ (p3[0] - p2[0])*(p1[1] - p0[1]);
+
+ if( det > 0 )
+ {
+ // start and segment[0] form the 'inner' part of a join,
+ // connect the overlapping segments
+ joinInnerSegments(start, segments[0], p);
+ joinOuterSegments(end, segments[1], p);
+ }
+ else
+ {
+ // end and segment[1] form the 'inner' part
+ joinInnerSegments(end, segments[1], p);
+ joinOuterSegments(start, segments[0], p);
+ }
+ }
+
+ /**
+ * Make a cap between a and b segments,
+ * where a-->b is the direction of iteration.
+ */
+ private void capEnd(Segment a, Segment b)
+ {
+ double[] p0, p1;
+ double dx, dy, l;
+ Point2D c1,c2;
+
+ switch( cap )
+ {
+ case CAP_BUTT:
+ a.add(new LineSegment(a.last.P2, b.P1));
+ break;
+
+ case CAP_SQUARE:
+ p0 = a.last.cp2();
+ p1 = new double[]{a.last.P2.getX(), a.last.P2.getY()};
+ dx = p1[0] - p0[0];
+ dy = p1[1] - p0[1];
+ l = Math.sqrt(dx * dx + dy * dy);
+ dx = 0.5*width*dx/l;
+ dy = 0.5*width*dy/l;
+ c1 = new Point2D.Double(p1[0] + dx, p1[1] + dy);
+ c2 = new Point2D.Double(b.P1.getX() + dx, b.P1.getY() + dy);
+ a.add(new LineSegment(a.last.P2, c1));
+ a.add(new LineSegment(c1, c2));
+ a.add(new LineSegment(c2, b.P1));
+ break;
+
+ case CAP_ROUND:
+ p0 = a.last.cp2();
+ p1 = new double[]{a.last.P2.getX(), a.last.P2.getY()};
+ dx = p1[0] - p0[0];
+ dy = p1[1] - p0[1];
+ l = Math.sqrt(dx * dx + dy * dy);
+ dx = (2.0/3.0)*width*dx/l;
+ dy = (2.0/3.0)*width*dy/l;
+ c1 = new Point2D.Double(p1[0] + dx, p1[1] + dy);
+ c2 = new Point2D.Double(b.P1.getX() + dx, b.P1.getY() + dy);
+ a.add(new CubicSegment(a.last.P2, c1, c2, b.P1));
+ break;
+ }
+ a.add(b);
+ }
+
+ /**
+ * Returns the intersection of two lines, or null if there isn't one.
+ * @param infinite - true if the lines should be regarded as infinite, false
+ * if the intersection must be within the given segments.
+ * @return a Point2D or null.
+ */
+ private Point2D lineIntersection(double X1, double Y1,
+ double X2, double Y2,
+ double X3, double Y3,
+ double X4, double Y4,
+ boolean infinite)
+ {
+ double x1 = X1;
+ double y1 = Y1;
+ double rx = X2 - x1;
+ double ry = Y2 - y1;
+
+ double x2 = X3;
+ double y2 = Y3;
+ double sx = X4 - x2;
+ double sy = Y4 - y2;
+
+ double determinant = sx * ry - sy * rx;
+ double nom = (sx * (y2 - y1) + sy * (x1 - x2));
+
+ // lines can be considered parallel.
+ if (Math.abs(determinant) < 1E-6)
+ return null;
+
+ nom = nom / determinant;
+
+ // check if lines are within the bounds
+ if(!infinite && (nom > 1.0 || nom < 0.0))
+ return null;
+
+ return new Point2D.Double(x1 + nom * rx, y1 + nom * ry);
+ }
+
+ /**
+ * Join a and b segments, where a-->b is the direction of iteration.
+ *
+ * insideP is the inside intersection point of the join, needed for
+ * calculating miter lengths.
+ */
+ private void joinOuterSegments(Segment a, Segment b, Point2D insideP)
+ {
+ double[] p0, p1;
+ double dx, dy, l;
+ Point2D c1,c2;
+
+ switch( join )
+ {
+ case JOIN_MITER:
+ p0 = a.last.cp2();
+ p1 = new double[]{a.last.P2.getX(), a.last.P2.getY()};
+ double[] p2 = new double[]{b.P1.getX(), b.P1.getY()};
+ double[] p3 = b.cp1();
+ Point2D p = lineIntersection(p0[0],p0[1],p1[0],p1[1],p2[0],p2[1],p3[0],p3[1], true);
+ if( p == null || insideP == null )
+ a.add(new LineSegment(a.last.P2, b.P1));
+ else if((p.distance(insideP)/width) < limit)
+ {
+ a.add(new LineSegment(a.last.P2, p));
+ a.add(new LineSegment(p, b.P1));
+ }
+ else
+ {
+ // outside miter limit, do a bevel join.
+ a.add(new LineSegment(a.last.P2, b.P1));
+ }
+ break;
+
+ case JOIN_ROUND:
+ p0 = a.last.cp2();
+ p1 = new double[]{a.last.P2.getX(), a.last.P2.getY()};
+ dx = p1[0] - p0[0];
+ dy = p1[1] - p0[1];
+ l = Math.sqrt(dx * dx + dy * dy);
+ dx = 0.5*width*dx/l;
+ dy = 0.5*width*dy/l;
+ c1 = new Point2D.Double(p1[0] + dx, p1[1] + dy);
+
+ p0 = new double[]{b.P1.getX(), b.P1.getY()};
+ p1 = b.cp1();
+
+ dx = p0[0] - p1[0]; // backwards direction.
+ dy = p0[1] - p1[1];
+ l = Math.sqrt(dx * dx + dy * dy);
+ dx = 0.5*width*dx/l;
+ dy = 0.5*width*dy/l;
+ c2 = new Point2D.Double(p0[0] + dx, p0[1] + dy);
+ a.add(new CubicSegment(a.last.P2, c1, c2, b.P1));
+ break;
+
+ case JOIN_BEVEL:
+ a.add(new LineSegment(a.last.P2, b.P1));
+ break;
+ }
+ }
+
+ /**
+ * Join a and b segments, removing any overlap
+ */
+ private void joinInnerSegments(Segment a, Segment b, Point2D p)
+ {
+ double[] p0 = a.last.cp2();
+ double[] p1 = new double[] { a.last.P2.getX(), a.last.P2.getY() };
+ double[] p2 = new double[] { b.P1.getX(), b.P1.getY() };
+ double[] p3 = b.cp1();
+
+ if (p == null)
+ {
+ // Dodgy.
+ a.add(new LineSegment(a.last.P2, b.P1));
+ p = new Point2D.Double((b.P1.getX() + a.last.P2.getX()) / 2.0,
+ (b.P1.getY() + a.last.P2.getY()) / 2.0);
+ }
+ else
+ // This assumes segments a and b are single segments, which is
+ // incorrect - if they are a linked list of segments (ie, passed in
+ // from a flattening operation), this produces strange results!!
+ a.last.P2 = b.P1 = p;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/BorderLayout.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/BorderLayout.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/BorderLayout.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/BorderLayout.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,742 @@
+/* BorderLayout.java -- A layout manager class
+ Copyright (C) 1999, 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+
+/**
+ * This class implements a layout manager that positions components
+ * in certain sectors of the parent container.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Rolf W. Rasmussen (rolfwr at ii.uib.no)
+ */
+public class BorderLayout implements LayoutManager2, java.io.Serializable
+{
+
+ /**
+ * Constant indicating the top of the container
+ */
+ public static final String NORTH = "North";
+
+ /**
+ * Constant indicating the bottom of the container
+ */
+ public static final String SOUTH = "South";
+
+ /**
+ * Constant indicating the right side of the container
+ */
+ public static final String EAST = "East";
+
+ /**
+ * Constant indicating the left side of the container
+ */
+ public static final String WEST = "West";
+
+ /**
+ * Constant indicating the center of the container
+ */
+ public static final String CENTER = "Center";
+
+
+ /**
+ * The constant indicating the position before the first line of the
+ * layout. The exact position depends on the writing system: For a
+ * top-to-bottom orientation, it is the same as {@link #NORTH}, for
+ * a bottom-to-top orientation, it is the same as {@link #SOUTH}.
+ *
+ * <p>This constant is an older name for {@link #PAGE_START} which
+ * has exactly the same value.
+ *
+ * @since 1.2
+ */
+ public static final String BEFORE_FIRST_LINE = "First";
+
+ /**
+ * The constant indicating the position after the last line of the
+ * layout. The exact position depends on the writing system: For a
+ * top-to-bottom orientation, it is the same as {@link #SOUTH}, for
+ * a bottom-to-top orientation, it is the same as {@link #NORTH}.
+ *
+ * <p>This constant is an older name for {@link #PAGE_END} which
+ * has exactly the same value.
+ *
+ * @since 1.2
+ */
+ public static final String AFTER_LAST_LINE = "Last";
+
+ /**
+ * The constant indicating the position before the first item of the
+ * layout. The exact position depends on the writing system: For a
+ * left-to-right orientation, it is the same as {@link #WEST}, for
+ * a right-to-left orientation, it is the same as {@link #EAST}.
+ *
+ * <p>This constant is an older name for {@link #LINE_START} which
+ * has exactly the same value.
+ *
+ * @since 1.2
+ */
+ public static final String BEFORE_LINE_BEGINS = "Before";
+
+ /**
+ * The constant indicating the position after the last item of the
+ * layout. The exact position depends on the writing system: For a
+ * left-to-right orientation, it is the same as {@link #EAST}, for
+ * a right-to-left orientation, it is the same as {@link #WEST}.
+ *
+ * <p>This constant is an older name for {@link #LINE_END} which
+ * has exactly the same value.
+ *
+ * @since 1.2
+ */
+ public static final String AFTER_LINE_ENDS = "After";
+
+ /**
+ * The constant indicating the position before the first line of the
+ * layout. The exact position depends on the writing system: For a
+ * top-to-bottom orientation, it is the same as {@link #NORTH}, for
+ * a bottom-to-top orientation, it is the same as {@link #SOUTH}.
+ *
+ * @since 1.4
+ */
+ public static final String PAGE_START = BEFORE_FIRST_LINE;
+
+ /**
+ * The constant indicating the position after the last line of the
+ * layout. The exact position depends on the writing system: For a
+ * top-to-bottom orientation, it is the same as {@link #SOUTH}, for
+ * a bottom-to-top orientation, it is the same as {@link #NORTH}.
+ *
+ * @since 1.4
+ */
+ public static final String PAGE_END = AFTER_LAST_LINE;
+
+ /**
+ * The constant indicating the position before the first item of the
+ * layout. The exact position depends on the writing system: For a
+ * left-to-right orientation, it is the same as {@link #WEST}, for
+ * a right-to-left orientation, it is the same as {@link #EAST}.
+ *
+ * @since 1.4
+ */
+ public static final String LINE_START = BEFORE_LINE_BEGINS;
+
+ /**
+ * The constant indicating the position after the last item of the
+ * layout. The exact position depends on the writing system: For a
+ * left-to-right orientation, it is the same as {@link #EAST}, for
+ * a right-to-left orientation, it is the same as {@link #WEST}.
+ *
+ * @since 1.4
+ */
+ public static final String LINE_END = AFTER_LINE_ENDS;
+
+
+ /**
+ * Serialization constant.
+ */
+ private static final long serialVersionUID = -8658291919501921765L;
+
+
+ /**
+ * @serial
+ */
+ private Component north;
+
+ /**
+ * @serial
+ */
+ private Component south;
+
+ /**
+ * @serial
+ */
+ private Component east;
+
+ /**
+ * @serial
+ */
+ private Component west;
+
+ /**
+ * @serial
+ */
+ private Component center;
+
+ /**
+ * @serial
+ */
+ private Component firstLine;
+
+ /**
+ * @serial
+ */
+ private Component lastLine;
+
+ /**
+ * @serial
+ */
+ private Component firstItem;
+
+ /**
+ * @serial
+ */
+ private Component lastItem;
+
+ /**
+ * @serial The horizontal gap between components
+ */
+ private int hgap;
+
+ /**
+ * @serial The vertical gap between components
+ */
+ private int vgap;
+
+
+ // Some constants for use with calcSize().
+ private static final int MIN = 0;
+ private static final int MAX = 1;
+ private static final int PREF = 2;
+
+
+ /**
+ * Initializes a new instance of <code>BorderLayout</code> with no
+ * horiztonal or vertical gaps between components.
+ */
+ public BorderLayout()
+ {
+ this(0,0);
+ }
+
+ /**
+ * Initializes a new instance of <code>BorderLayout</code> with the
+ * specified horiztonal and vertical gaps between components.
+ *
+ * @param hgap The horizontal gap between components.
+ * @param vgap The vertical gap between components.
+ */
+ public BorderLayout(int hgap, int vgap)
+ {
+ this.hgap = hgap;
+ this.vgap = vgap;
+ }
+
+ /**
+ * Returns the horitzontal gap value.
+ *
+ * @return The horitzontal gap value.
+ */
+ public int getHgap()
+ {
+ return(hgap);
+ }
+
+ /**
+ * Sets the horizontal gap to the specified value.
+ *
+ * @param hgap The new horizontal gap.
+ */
+ public void setHgap(int hgap)
+ {
+ this.hgap = hgap;
+ }
+
+ /**
+ * Returns the vertical gap value.
+ *
+ * @return The vertical gap value.
+ */
+ public int getVgap()
+ {
+ return(vgap);
+ }
+
+ /**
+ * Sets the vertical gap to the specified value.
+ *
+ * @param vgap The new vertical gap value.
+ */
+ public void setVgap(int vgap)
+ {
+ this.vgap = vgap;
+ }
+
+ /**
+ * Adds a component to the layout in the specified constraint position,
+ * which must be one of the string constants defined in this class.
+ *
+ * @param component The component to add.
+ * @param constraints The constraint string.
+ *
+ * @exception IllegalArgumentException If the constraint object is not
+ * a string, or is not one of the specified constants in this class.
+ */
+ public void addLayoutComponent(Component component, Object constraints)
+ {
+ if (constraints != null && ! (constraints instanceof String))
+ throw new IllegalArgumentException("Constraint must be a string");
+
+ addLayoutComponent((String) constraints, component);
+ }
+
+ /**
+ * Adds a component to the layout in the specified constraint position,
+ * which must be one of the string constants defined in this class.
+ *
+ * @param constraints The constraint string.
+ * @param component The component to add.
+ *
+ * @exception IllegalArgumentException If the constraint object is not
+ * one of the specified constants in this class.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>addLayoutComponent(Component, Object)</code>.
+ */
+ public void addLayoutComponent(String constraints, Component component)
+ {
+ String str = constraints;
+
+ if (str == null || str.equals(CENTER))
+ center = component;
+ else if (str.equals(NORTH))
+ north = component;
+ else if (str.equals(SOUTH))
+ south = component;
+ else if (str.equals(EAST))
+ east = component;
+ else if (str.equals(WEST))
+ west = component;
+ else if (str.equals(BEFORE_FIRST_LINE))
+ firstLine = component;
+ else if (str.equals(AFTER_LAST_LINE))
+ lastLine = component;
+ else if (str.equals(BEFORE_LINE_BEGINS))
+ firstItem = component;
+ else if (str.equals(AFTER_LINE_ENDS))
+ lastItem = component;
+ else
+ throw new IllegalArgumentException("Constraint value not valid: " + str);
+ }
+
+ /**
+ * Removes the specified component from the layout.
+ *
+ * @param component The component to remove from the layout.
+ */
+ public void removeLayoutComponent(Component component)
+ {
+ if (north == component)
+ north = null;
+ if (south == component)
+ south = null;
+ if (east == component)
+ east = null;
+ if (west == component)
+ west = null;
+ if (center == component)
+ center = null;
+ if (firstItem == component)
+ firstItem = null;
+ if (lastItem == component)
+ lastItem = null;
+ if (firstLine == component)
+ firstLine = null;
+ if (lastLine == component)
+ lastLine = null;
+ }
+
+ /**
+ * Returns the minimum size of the specified container using this layout.
+ *
+ * @param target The container to calculate the minimum size for.
+ *
+ * @return The minimum size of the container
+ */
+ public Dimension minimumLayoutSize(Container target)
+ {
+ return calcSize(target, MIN);
+ }
+
+ /**
+ * Returns the preferred size of the specified container using this layout.
+ *
+ * @param target The container to calculate the preferred size for.
+ *
+ * @return The preferred size of the container
+ */
+ public Dimension preferredLayoutSize(Container target)
+ {
+ return calcSize(target, PREF);
+ }
+
+ /**
+ * Returns the maximum size of the specified container using this layout.
+ *
+ * @param target The container to calculate the maximum size for.
+ *
+ * @return The maximum size of the container
+ */
+ public Dimension maximumLayoutSize(Container target)
+ {
+ return new Dimension (Integer.MAX_VALUE, Integer.MAX_VALUE);
+ }
+
+ /**
+ * Returns the X axis alignment, which is a <code>float</code> indicating
+ * where along the X axis this container wishs to position its layout.
+ * 0 indicates align to the left, 1 indicates align to the right, and 0.5
+ * indicates align to the center.
+ *
+ * @param parent The parent container.
+ *
+ * @return The X alignment value.
+ */
+ public float getLayoutAlignmentX(Container parent)
+ {
+ return 0.5F;
+ }
+
+ /**
+ * Returns the Y axis alignment, which is a <code>float</code> indicating
+ * where along the Y axis this container wishs to position its layout.
+ * 0 indicates align to the top, 1 indicates align to the bottom, and 0.5
+ * indicates align to the center.
+ *
+ * @param parent The parent container.
+ *
+ * @return The Y alignment value.
+ */
+ public float getLayoutAlignmentY(Container parent)
+ {
+ return 0.5F;
+ }
+
+ /**
+ * Instructs this object to discard any layout information it might
+ * have cached.
+ *
+ * @param parent The parent container.
+ */
+ public void invalidateLayout(Container parent)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Lays out the specified container according to the constraints in this
+ * object.
+ *
+ * @param target The container to lay out.
+ */
+ public void layoutContainer(Container target)
+ {
+ synchronized (target.getTreeLock())
+ {
+ Insets i = target.getInsets();
+ int top = i.top;
+ int bottom = target.height - i.bottom;
+ int left = i.left;
+ int right = target.width - i.right;
+
+ boolean left_to_right = target.getComponentOrientation().isLeftToRight();
+
+ Component my_north = north;
+ Component my_east = east;
+ Component my_south = south;
+ Component my_west = west;
+
+ // Note that we currently don't handle vertical layouts.
+ // Neither does JDK 1.3.
+ if (firstLine != null)
+ my_north = firstLine;
+ if (lastLine != null)
+ my_south = lastLine;
+ if (firstItem != null)
+ {
+ if (left_to_right)
+ my_west = firstItem;
+ else
+ my_east = firstItem;
+ }
+ if (lastItem != null)
+ {
+ if (left_to_right)
+ my_east = lastItem;
+ else
+ my_west = lastItem;
+ }
+
+ if (my_north != null)
+ {
+ Dimension n = calcCompSize(my_north, PREF);
+ my_north.setBounds(left, top, right - left, n.height);
+ top += n.height + vgap;
+ }
+
+ if (my_south != null)
+ {
+ Dimension s = calcCompSize(my_south, PREF);
+ my_south.setBounds(left, bottom - s.height, right - left, s.height);
+ bottom -= s.height + vgap;
+ }
+
+ if (my_east != null)
+ {
+ Dimension e = calcCompSize(my_east, PREF);
+ my_east.setBounds(right - e.width, top, e.width, bottom - top);
+ right -= e.width + hgap;
+ }
+
+ if (my_west != null)
+ {
+ Dimension w = calcCompSize(my_west, PREF);
+ my_west.setBounds(left, top, w.width, bottom - top);
+ left += w.width + hgap;
+ }
+
+ if (center != null)
+ center.setBounds(left, top, right - left, bottom - top);
+ }
+ }
+
+ /**
+ * Returns a string representation of this layout manager.
+ *
+ * @return A string representation of this object.
+ */
+ public String toString()
+ {
+ return getClass().getName() + "[hgap=" + hgap + ",vgap=" + vgap + "]";
+ }
+
+ private Dimension calcCompSize(Component comp, int what)
+ {
+ if (comp == null || ! comp.isVisible())
+ return new Dimension(0, 0);
+ if (what == MIN)
+ return comp.getMinimumSize();
+ else if (what == MAX)
+ return comp.getMaximumSize();
+ return comp.getPreferredSize();
+ }
+
+ /**
+ * This is a helper function used to compute the various sizes for this
+ * layout.
+ */
+ private Dimension calcSize(Container target, int what)
+ {
+ synchronized (target.getTreeLock())
+ {
+ Insets ins = target.getInsets();
+
+ ComponentOrientation orient = target.getComponentOrientation ();
+ boolean left_to_right = orient.isLeftToRight ();
+
+ Component my_north = north;
+ Component my_east = east;
+ Component my_south = south;
+ Component my_west = west;
+
+ // Note that we currently don't handle vertical layouts. Neither
+ // does JDK 1.3.
+ if (firstLine != null)
+ my_north = firstLine;
+ if (lastLine != null)
+ my_south = lastLine;
+ if (firstItem != null)
+ {
+ if (left_to_right)
+ my_west = firstItem;
+ else
+ my_east = firstItem;
+ }
+ if (lastItem != null)
+ {
+ if (left_to_right)
+ my_east = lastItem;
+ else
+ my_west = lastItem;
+ }
+
+ Dimension ndim = calcCompSize(my_north, what);
+ Dimension sdim = calcCompSize(my_south, what);
+ Dimension edim = calcCompSize(my_east, what);
+ Dimension wdim = calcCompSize(my_west, what);
+ Dimension cdim = calcCompSize(center, what);
+
+ int width = edim.width + cdim.width + wdim.width + (hgap * 2);
+ // Check for overflow.
+ if (width < edim.width || width < cdim.width || width < cdim.width)
+ width = Integer.MAX_VALUE;
+
+ if (ndim.width > width)
+ width = ndim.width;
+ if (sdim.width > width)
+ width = sdim.width;
+
+ width += (ins.left + ins.right);
+
+ int height = edim.height;
+ if (cdim.height > height)
+ height = cdim.height;
+ if (wdim.height > height)
+ height = wdim.height;
+
+ int addedHeight = height + (ndim.height + sdim.height + (vgap * 2)
+ + ins.top + ins.bottom);
+ // Check for overflow.
+ if (addedHeight < height)
+ height = Integer.MAX_VALUE;
+ else
+ height = addedHeight;
+
+ return(new Dimension(width, height));
+ }
+ }
+
+ /**
+ * Return the component at the indicated location, or null if no component
+ * is at that location. The constraints argument must be one of the
+ * location constants specified by this class.
+ * @param constraints the location
+ * @return the component at that location, or null
+ * @throws IllegalArgumentException if the constraints argument is not
+ * recognized
+ * @since 1.5
+ */
+ public Component getLayoutComponent(Object constraints)
+ {
+ if (constraints == CENTER)
+ return center;
+ if (constraints == NORTH)
+ return north;
+ if (constraints == EAST)
+ return east;
+ if (constraints == SOUTH)
+ return south;
+ if (constraints == WEST)
+ return west;
+ if (constraints == PAGE_START)
+ return firstLine;
+ if (constraints == PAGE_END)
+ return lastLine;
+ if (constraints == LINE_START)
+ return firstItem;
+ if (constraints == LINE_END)
+ return lastItem;
+ throw new IllegalArgumentException("constraint " + constraints
+ + " is not recognized");
+ }
+
+ /**
+ * Return the component at the specified location, which must be one
+ * of the absolute constants such as CENTER or SOUTH. The container's
+ * orientation is used to map this location to the correct corresponding
+ * component, so for instance in a right-to-left container, a request
+ * for the EAST component could return the LINE_END component. This will
+ * return null if no component is available at the given location.
+ * @param container the container whose orientation is used
+ * @param constraints the absolute location of the component
+ * @return the component at the location, or null
+ * @throws IllegalArgumentException if the constraint is not recognized
+ */
+ public Component getLayoutComponent(Container container, Object constraints)
+ {
+ ComponentOrientation orient = container.getComponentOrientation();
+ if (constraints == CENTER)
+ return center;
+ // Note that we don't support vertical layouts.
+ if (constraints == NORTH)
+ return north;
+ if (constraints == SOUTH)
+ return south;
+ if (constraints == WEST)
+ {
+ // Note that relative layout takes precedence.
+ if (orient.isLeftToRight())
+ return firstItem == null ? west : firstItem;
+ return lastItem == null ? west : lastItem;
+ }
+ if (constraints == EAST)
+ {
+ // Note that relative layout takes precedence.
+ if (orient.isLeftToRight())
+ return lastItem == null ? east : lastItem;
+ return firstItem == null ? east : firstItem;
+ }
+ throw new IllegalArgumentException("constraint " + constraints
+ + " is not recognized");
+ }
+
+ /**
+ * Return the constraint corresponding to a component in this layout.
+ * If the component is null, or is not in this layout, returns null.
+ * Otherwise, this will return one of the constraint constants defined
+ * in this class.
+ * @param c the component
+ * @return the constraint, or null
+ * @since 1.5
+ */
+ public Object getConstraints(Component c)
+ {
+ if (c == null)
+ return null;
+ if (c == center)
+ return CENTER;
+ if (c == north)
+ return NORTH;
+ if (c == east)
+ return EAST;
+ if (c == south)
+ return SOUTH;
+ if (c == west)
+ return WEST;
+ if (c == firstLine)
+ return PAGE_START;
+ if (c == lastLine)
+ return PAGE_END;
+ if (c == firstItem)
+ return LINE_START;
+ if (c == lastItem)
+ return LINE_END;
+ return null;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/BufferCapabilities.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/BufferCapabilities.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/BufferCapabilities.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/BufferCapabilities.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,253 @@
+/* BufferCapabilities.java -- double-buffering capabilities descriptor
+ Copyright (C) 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.image.BufferStrategy;
+
+/**
+ * A double-buffering capability descriptor. This class exposes
+ * details about the double-buffering algorithms used by image
+ * buffers.
+ *
+ * BufferCapabilities represents algorithms that involve at least two
+ * buffers but it can also specify so-called "multi-buffer" schemes
+ * involving more than two buffers. This class describes the
+ * capabilities of the front and back buffers as well as the results
+ * of "flipping" -- that is, what happens when an image is transferred
+ * from the back buffer to the front buffer.
+ *
+ * Flipping may or may not be supported or may be supported only in
+ * fullscreen mode. If it is not supported then "blitting" is implied
+ * -- that is, the contents of the back buffer are copied using a fast
+ * block transfer operation from the back buffer to the front buffer.
+ *
+ * The front buffer is the one that is displayed.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ *
+ * @see BufferStrategy#getCapabilities()
+ * @see GraphicsConfiguration#getBufferCapabilities()
+ *
+ * @since 1.4
+ */
+public class BufferCapabilities implements Cloneable
+{
+ /**
+ * A type-safe enumeration of buffer flipping results.
+ *
+ * @see AttributeValue
+ */
+ public static final class FlipContents extends AttributeValue
+ {
+ /**
+ * The names of the different flipping results.
+ */
+ private static final String[] NAMES
+ = { "undefined", "background", "prior", "copied" };
+
+ /**
+ * The contents of the back buffer are undefined after flipping.
+ */
+ public static final FlipContents UNDEFINED = new FlipContents(0);
+
+ /**
+ * The back buffer is cleared with the background color after
+ * flipping.
+ */
+ public static final FlipContents BACKGROUND = new FlipContents(1);
+
+ /**
+ * The back buffer contains the pre-flipping contents of the front
+ * buffer after flipping. In other words a true "flip" has been
+ * performed.
+ */
+ public static final FlipContents PRIOR = new FlipContents(2);
+
+ /**
+ * The back buffer has the same contents as the front buffer after
+ * flipping.
+ */
+ public static final FlipContents COPIED = new FlipContents(3);
+
+ /**
+ * Create a new flipping result descriptor.
+ *
+ * @param value the enumeration value
+ */
+ private FlipContents(int value)
+ {
+ super(value, NAMES);
+ }
+ }
+
+ /**
+ * Front buffer capabilities descriptor.
+ */
+ private final ImageCapabilities front;
+
+ /**
+ * Back buffer capabilities descriptor.
+ */
+ private final ImageCapabilities back;
+
+ /**
+ * Describes the results of a "flip" operation.
+ */
+ private final FlipContents flip;
+
+ /**
+ * Creates a buffer capabilities object.
+ *
+ * @param frontCaps front buffer capabilities descriptor
+ * @param backCaps back buffer capabilities descriptor
+ * @param flip the results of a flip operation or null if
+ * flipping is not supported
+ *
+ * @exception IllegalArgumentException if frontCaps or backCaps is
+ * null
+ */
+ public BufferCapabilities(ImageCapabilities frontCaps,
+ ImageCapabilities backCaps,
+ FlipContents flip)
+ {
+ if (frontCaps == null || backCaps == null)
+ throw new IllegalArgumentException();
+ this.front = frontCaps;
+ this.back = backCaps;
+ this.flip = flip;
+ }
+
+ /**
+ * Retrieve the front buffer's image capabilities.
+ *
+ * @return the front buffer's image capabilities
+ */
+ public ImageCapabilities getFrontBufferCapabilities()
+ {
+ return front;
+ }
+
+ /**
+ * Retrieve the back buffer's image capabilities.
+ *
+ * @return the back buffer's image capabilities
+ */
+ public ImageCapabilities getBackBufferCapabilities()
+ {
+ return back;
+ }
+
+ /**
+ * Return whether or not flipping is supported.
+ *
+ * @return true if flipping is supported, false otherwise
+ */
+ public boolean isPageFlipping()
+ {
+ return flip != null;
+ }
+
+ /**
+ * Retrieve the result of a flipping operation. If this method
+ * returns null then flipping is not supported. This implies that
+ * "blitting", a fast block transfer, is used to copy the contents
+ * of the back buffer to the front buffer. Other possible return
+ * values are:
+ * <ul>
+ * <li><code>FlipContents.UNDEFINED</code> the contents of the
+ * back buffer are undefined after flipping.</li>
+ * <li><code>FlipContents.BACKGROUND</code> the contents of the
+ * back buffer are cleared to the background color after
+ * flipping.</li>
+ * <li><code>FlipContents.PRIOR</code> the back buffer contains
+ * the pre-flipping contents of the front * buffer after
+ * flipping.</li>
+ * <li><code>FlipContents.COPIED</code> the back buffer has the
+ * same contents as the front buffer after flipping.</li>
+ * </ul>
+ *
+ * @return the result of a flipping operation or null if flipping is
+ * not supported
+ */
+ public FlipContents getFlipContents()
+ {
+ return flip;
+ }
+
+ /**
+ * Returns true if flipping is only supported in fullscreen mode.
+ *
+ * @return true if flipping is only supported in fullscreen mode,
+ * false otherwise
+ */
+ public boolean isFullScreenRequired()
+ {
+ return true;
+ }
+
+ /**
+ * Returns true if flipping can involve more than two buffers. One
+ * or more intermediate buffers may be available in addition to the
+ * front and back buffers.
+ *
+ * @return true if there are more than two buffers available for
+ * flipping, false otherwise
+ */
+ public boolean isMultiBufferAvailable()
+ {
+ return false;
+ }
+
+ /**
+ * Clone this buffering capability descriptor.
+ *
+ * @return a clone of this buffer capability descriptor
+ */
+ public Object clone()
+ {
+ try
+ {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw (Error) new InternalError().initCause(e);
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Button.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Button.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Button.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Button.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,468 @@
+/* Button.java -- AWT button widget
+ Copyright (C) 1999, 2002, 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.peer.ButtonPeer;
+import java.lang.reflect.Array;
+import java.util.EventListener;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleAction;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleValue;
+
+/**
+ * This class provides a button widget for the AWT.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Tom Tromey (tromey at cygnus.com)
+ */
+public class Button extends Component
+ implements java.io.Serializable, Accessible
+{
+
+/*
+ * Static Variables
+ */
+
+// FIXME: Need readObject/writeObject for serialization
+
+// Serialization version constant
+private static final long serialVersionUID = -8774683716313001058L;
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+/**
+ * @serial The action command name for this button.
+ * This is package-private to avoid an accessor method.
+ */
+String actionCommand;
+
+/**
+ * @serial The label for this button.
+ * This is package-private to avoid an accessor method.
+ */
+String label;
+
+// List of ActionListeners for this class.
+private transient ActionListener action_listeners;
+
+ /*
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_button_number;
+
+ protected class AccessibleAWTButton extends AccessibleAWTComponent
+ implements AccessibleAction, AccessibleValue
+ {
+ private static final long serialVersionUID = -5932203980244017102L;
+
+ protected AccessibleAWTButton()
+ {
+ // Do nothing here.
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleAction#getAccessibleActionCount()
+ */
+ public int getAccessibleActionCount()
+ {
+ // Only 1 action possible
+ return 1;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleAction#getAccessibleActionDescription(int)
+ */
+ public String getAccessibleActionDescription(int i)
+ {
+ // JDK 1.4.2 returns the string "click" for action 0. However, the API
+ // docs don't say what the string to be returned is, beyond being a
+ // description of the action. So we return the same thing for
+ // compatibility with 1.4.2.
+ if (i == 0)
+ return "click";
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleAction#doAccessibleAction(int)
+ */
+ public boolean doAccessibleAction(int i)
+ {
+ if (i != 0)
+ return false;
+ processActionEvent(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, actionCommand));
+ return true;
+ }
+
+ public String getAccessibleName()
+ {
+ return label;
+ }
+
+ public AccessibleAction getAccessibleAction()
+ {
+ return this;
+ }
+
+ public AccessibleValue getAccessibleValue()
+ {
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleValue#getCurrentAccessibleValue()
+ */
+ public Number getCurrentAccessibleValue()
+ {
+ // Docs say return 1 if selected, but buttons can't be selected, right?
+ return new Integer(0);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleValue#setCurrentAccessibleValue(java.lang.Number)
+ */
+ public boolean setCurrentAccessibleValue(Number number)
+ {
+ // Since there's no selection with buttons, we're ignoring this.
+ // TODO someone who knows shoulw check this.
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleValue#getMinimumAccessibleValue()
+ */
+ public Number getMinimumAccessibleValue()
+ {
+ return new Integer(0);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleValue#getMaximumAccessibleValue()
+ */
+ public Number getMaximumAccessibleValue()
+ {
+ return new Integer(0);
+ }
+
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.PUSH_BUTTON;
+ }
+ }
+
+/*************************************************************************/
+
+/*
+ * Constructors
+ */
+
+/**
+ * Initializes a new instance of <code>Button</code> with no label.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true
+ */
+public
+Button()
+{
+ this("");
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>Button</code> with the specified
+ * label. The action command name is also initialized to this value.
+ *
+ * @param label The label to display on the button.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true
+ */
+public
+Button(String label)
+{
+ this.label = label;
+ actionCommand = label;
+
+ if (GraphicsEnvironment.isHeadless ())
+ throw new HeadlessException ();
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+/**
+ * Returns the label for this button.
+ *
+ * @return The label for this button.
+ */
+public String
+getLabel()
+{
+ return(label);
+}
+
+/*************************************************************************/
+
+/**
+ * Sets the label for this button to the specified value.
+ *
+ * @param label The new label for this button.
+ */
+public synchronized void
+setLabel(String label)
+{
+ this.label = label;
+ actionCommand = label;
+ if (peer != null)
+ {
+ ButtonPeer bp = (ButtonPeer) peer;
+ bp.setLabel (label);
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the action command name for this button.
+ *
+ * @return The action command name for this button.
+ */
+public String
+getActionCommand()
+{
+ return(actionCommand);
+}
+
+/*************************************************************************/
+
+/**
+ * Sets the action command name for this button to the specified value.
+ *
+ * @param actionCommand The new action command name.
+ */
+public void
+setActionCommand(String actionCommand)
+{
+ this.actionCommand = actionCommand == null ? label : actionCommand;
+}
+
+/*************************************************************************/
+
+/**
+ * Adds a new entry to the list of listeners that will receive
+ * action events from this button.
+ *
+ * @param listener The listener to add.
+ */
+public synchronized void
+addActionListener(ActionListener listener)
+{
+ action_listeners = AWTEventMulticaster.add(action_listeners, listener);
+}
+
+/*************************************************************************/
+
+/**
+ * Removes the specified listener from the list of listeners that will
+ * receive action events from this button.
+ *
+ * @param listener The listener to remove.
+ */
+public synchronized void
+removeActionListener(ActionListener listener)
+{
+ action_listeners = AWTEventMulticaster.remove(action_listeners, listener);
+}
+
+ /**
+ * Returns all added <code>ActionListener</code> objects.
+ *
+ * @return an array of listeners
+ *
+ * @since 1.4
+ */
+ public synchronized ActionListener[] getActionListeners()
+ {
+ return (ActionListener[])
+ AWTEventMulticaster.getListeners(action_listeners,
+ ActionListener.class);
+ }
+
+/**
+ * Returns all registered EventListers of the given listenerType.
+ * listenerType must be a subclass of EventListener, or a
+ * ClassClassException is thrown.
+ *
+ * @param listenerType the listener type to return
+ *
+ * @return an array of listeners
+ *
+ * @exception ClassCastException If listenerType doesn't specify a class or
+ * interface that implements @see java.util.EventListener.
+ *
+ * @since 1.3
+ */
+ public EventListener[] getListeners(Class listenerType)
+ {
+ if (listenerType == ActionListener.class)
+ return getActionListeners();
+ return (EventListener[]) Array.newInstance(listenerType, 0);
+ }
+
+/*************************************************************************/
+
+/**
+ * Notifies this button that it should create its native peer object.
+ */
+public void
+addNotify()
+{
+ if (peer == null)
+ peer = getToolkit ().createButton (this);
+ super.addNotify();
+}
+
+/*************************************************************************/
+
+/**
+ * Processes an event for this button. If the specified event is an
+ * instance of <code>ActionEvent</code>, then the
+ * <code>processActionEvent()</code> method is called to dispatch it
+ * to any registered listeners. Otherwise, the superclass method
+ * will be invoked. Note that this method will not be called at all
+ * unless <code>ActionEvent</code>'s are enabled. This will be done
+ * implicitly if any listeners are added.
+ *
+ * @param event The event to process.
+ */
+protected void
+processEvent(AWTEvent event)
+{
+ if (event instanceof ActionEvent)
+ processActionEvent((ActionEvent)event);
+ else
+ super.processEvent(event);
+}
+
+/*************************************************************************/
+
+/**
+ * This method dispatches an action event for this button to any
+ * registered listeners.
+ *
+ * @param event The event to process.
+ */
+protected void
+processActionEvent(ActionEvent event)
+{
+ if (action_listeners != null)
+ action_listeners.actionPerformed(event);
+}
+
+void
+dispatchEventImpl(AWTEvent e)
+{
+ if (e.id <= ActionEvent.ACTION_LAST
+ && e.id >= ActionEvent.ACTION_FIRST
+ && (action_listeners != null
+ || (eventMask & AWTEvent.ACTION_EVENT_MASK) != 0))
+ processEvent(e);
+ else
+ super.dispatchEventImpl(e);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns a debugging string for this button.
+ *
+ * @return A debugging string for this button.
+ */
+protected String
+paramString()
+{
+ return getName () + "," + getX () + "," + getY () + ","
+ + getWidth () + "x" + getHeight () + ",label=" + getLabel ();
+}
+
+/**
+ * Gets the AccessibleContext associated with this <code>Button</code>.
+ * The context is created, if necessary.
+ *
+ * @return the associated context
+ */
+public AccessibleContext getAccessibleContext()
+{
+ /* Create the context if this is the first request */
+ if (accessibleContext == null)
+ accessibleContext = new AccessibleAWTButton();
+ return accessibleContext;
+}
+
+ /**
+ * Generate a unique name for this button.
+ *
+ * @return A unique name for this button.
+ */
+ String generateName ()
+ {
+ return "button" + getUniqueLong ();
+ }
+
+ private static synchronized long getUniqueLong ()
+ {
+ return next_button_number++;
+ }
+
+} // class Button
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Canvas.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Canvas.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Canvas.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Canvas.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,366 @@
+/* Canvas.java --
+ Copyright (C) 1999, 2000, 2002, 2004 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.image.BufferStrategy;
+import java.awt.peer.ComponentPeer;
+import java.io.Serializable;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+
+/**
+ * The <code>Canvas</code> component provides a blank rectangular
+ * area, which the client application can use for drawing and for
+ * capturing events. By overriding the <code>paint()</code> method,
+ * the canvas can be used for anything from simple line drawings to
+ * full-scale custom components.
+ *
+ * @author Original author unknown
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.0
+ */
+
+public class Canvas
+ extends Component
+ implements Serializable, Accessible
+{
+
+ /**
+ * Compatible with Sun's JDK.
+ */
+ private static final long serialVersionUID = -2284879212465893870L;
+
+ /**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_canvas_number;
+
+ /**
+ * The graphics configuration associated with the canvas.
+ */
+ transient GraphicsConfiguration graphicsConfiguration;
+
+ /**
+ * The buffer strategy associated with this canvas.
+ */
+ transient BufferStrategy bufferStrategy;
+
+ /**
+ * Initializes a new instance of <code>Canvas</code>.
+ */
+ public Canvas()
+ {
+ }
+
+ /**
+ * Initializes a new instance of <code>Canvas</code>
+ * with the supplied graphics configuration.
+ *
+ * @param graphicsConfiguration the graphics configuration to use
+ * for this particular canvas.
+ */
+ public Canvas(GraphicsConfiguration graphicsConfiguration)
+ {
+ this.graphicsConfiguration = graphicsConfiguration;
+ }
+
+ GraphicsConfiguration getGraphicsConfigurationImpl()
+ {
+ if (graphicsConfiguration != null)
+ return graphicsConfiguration;
+ return super.getGraphicsConfigurationImpl();
+ }
+
+ /**
+ * Creates the native peer for this object.
+ */
+ public void addNotify()
+ {
+ if (peer == null)
+ peer = (ComponentPeer) getToolkit().createCanvas(this);
+ super.addNotify();
+ }
+
+ /**
+ * Repaints the canvas window. This method should be overridden by
+ * a subclass to do something useful, as this method simply paints
+ * the window with the background color.
+ *
+ * @param gfx the <code>Graphics</code> to use for painting
+ */
+ public void paint(Graphics gfx)
+ {
+ /* This implementation doesn't make much sense since the filling
+ of background color is guaranteed for heavyweight components
+ such as this. But there's no need to worry, since paint() is
+ usually overridden anyway. */
+ gfx.setColor(getBackground());
+ Dimension size = getSize();
+ gfx.fillRect(0, 0, size.width, size.height);
+ }
+
+ /**
+ * This class provides accessibility support for the canvas.
+ */
+ protected class AccessibleAWTCanvas
+ extends AccessibleAWTComponent
+ {
+ /**
+ * For compatability with Sun's JDK
+ */
+ private static final long serialVersionUID = -6325592262103146699L;
+
+ /**
+ * Constructor for the accessible canvas.
+ */
+ protected AccessibleAWTCanvas()
+ {
+ }
+
+ /**
+ * Returns the accessible role for the canvas.
+ *
+ * @return an instance of <code>AccessibleRole</code>, describing
+ * the role of the canvas.
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.CANVAS;
+ }
+
+ }
+
+ /**
+ * Gets the AccessibleContext associated with this <code>Canvas</code>.
+ * The context is created, if necessary.
+ *
+ * @return the associated context
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ /* Create the context if this is the first request */
+ if (accessibleContext == null)
+ accessibleContext = new AccessibleAWTCanvas();
+ return accessibleContext;
+ }
+
+ /**
+ * A BltBufferStrategy for canvases.
+ */
+ private class CanvasBltBufferStrategy extends BltBufferStrategy
+ {
+ /**
+ * Creates a block transfer strategy for this canvas.
+ *
+ * @param numBuffers the number of buffers in this strategy
+ * @param accelerated true if the buffer should be accelerated,
+ * false otherwise
+ */
+ CanvasBltBufferStrategy(int numBuffers, boolean accelerated)
+ {
+ super(numBuffers,
+ new BufferCapabilities(new ImageCapabilities(accelerated),
+ new ImageCapabilities(accelerated),
+ BufferCapabilities.FlipContents.COPIED));
+ }
+ }
+
+ /**
+ * A FlipBufferStrategy for canvases.
+ */
+ private class CanvasFlipBufferStrategy extends FlipBufferStrategy
+ {
+ /**
+ * Creates a flip buffer strategy for this canvas.
+ *
+ * @param numBuffers the number of buffers in this strategy
+ *
+ * @throws AWTException if the requested number of buffers is not
+ * supported
+ */
+ CanvasFlipBufferStrategy(int numBuffers)
+ throws AWTException
+ {
+ super(numBuffers,
+ new BufferCapabilities(new ImageCapabilities(true),
+ new ImageCapabilities(true),
+ BufferCapabilities.FlipContents.COPIED));
+ }
+ }
+
+ /**
+ * Creates a buffering strategy that manages how this canvas is
+ * repainted. This method attempts to create the optimum strategy
+ * based on the desired number of buffers. Hardware or software
+ * acceleration may be used.
+ *
+ * createBufferStrategy attempts different levels of optimization,
+ * but guarantees that some strategy with the requested number of
+ * buffers will be created even if it is not optimal. First it
+ * attempts to create a page flipping strategy, then an accelerated
+ * blitting strategy, then an unaccelerated blitting strategy.
+ *
+ * Calling this method causes any existing buffer strategy to be
+ * destroyed.
+ *
+ * @param numBuffers the number of buffers in this strategy
+ *
+ * @throws IllegalArgumentException if requested number of buffers
+ * is less than one
+ * @throws IllegalStateException if this canvas is not displayable
+ *
+ * @since 1.4
+ */
+ public void createBufferStrategy(int numBuffers)
+ {
+ if (numBuffers < 1)
+ throw new IllegalArgumentException("Canvas.createBufferStrategy: number"
+ + " of buffers is less than one");
+
+ if (!isDisplayable())
+ throw new IllegalStateException("Canvas.createBufferStrategy: canvas is"
+ + " not displayable");
+
+ BufferStrategy newStrategy = null;
+
+ // try a flipping strategy
+ try
+ {
+ newStrategy = new CanvasFlipBufferStrategy(numBuffers);
+ }
+ catch (AWTException e)
+ {
+ }
+
+ // fall back to an accelerated blitting strategy
+ if (newStrategy == null)
+ newStrategy = new CanvasBltBufferStrategy(numBuffers, true);
+
+ bufferStrategy = newStrategy;
+ }
+
+ /**
+ * Creates a buffering strategy that manages how this canvas is
+ * repainted. This method attempts to create a strategy based on
+ * the specified capabilities and throws an exception if the
+ * requested strategy is not supported.
+ *
+ * Calling this method causes any existing buffer strategy to be
+ * destroyed.
+ *
+ * @param numBuffers the number of buffers in this strategy
+ * @param caps the requested buffering capabilities
+ *
+ * @throws AWTException if the requested capabilities are not
+ * supported
+ * @throws IllegalArgumentException if requested number of buffers
+ * is less than one or if caps is null
+ *
+ * @since 1.4
+ */
+ public void createBufferStrategy(int numBuffers, BufferCapabilities caps)
+ throws AWTException
+ {
+ if (numBuffers < 1)
+ throw new IllegalArgumentException("Canvas.createBufferStrategy: number"
+ + " of buffers is less than one");
+
+ if (caps == null)
+ throw new IllegalArgumentException("Canvas.createBufferStrategy:"
+ + " capabilities object is null");
+
+ // a flipping strategy was requested
+ if (caps.isPageFlipping())
+ bufferStrategy = new CanvasFlipBufferStrategy(numBuffers);
+ else
+ bufferStrategy = new CanvasBltBufferStrategy(numBuffers, true);
+ }
+
+ /**
+ * Returns the buffer strategy used by the canvas.
+ *
+ * @return the buffer strategy.
+ * @since 1.4
+ */
+ public BufferStrategy getBufferStrategy()
+ {
+ return bufferStrategy;
+ }
+
+ /**
+ * Updates the canvas in response to a request to
+ * <code>repaint()</code> it. The canvas is cleared
+ * with the current background colour, before <code>paint()</code>
+ * is called to add the new contents. Subclasses
+ * which override this method should either call this
+ * method via <code>super.update(graphics)</code> or re-implement
+ * this behaviour, so as to ensure that the canvas is
+ * clear before painting takes place.
+ *
+ * @param graphics the graphics context.
+ */
+ public void update(Graphics graphics)
+ {
+ Dimension size;
+
+ /* Clear the canvas */
+ size = getSize();
+ graphics.clearRect(0, 0, size.width, size.height);
+ /* Call the paint method */
+ paint(graphics);
+ }
+
+ /**
+ * Generate a unique name for this <code>Canvas</code>.
+ *
+ * @return A unique name for this <code>Canvas</code>.
+ */
+ String generateName()
+ {
+ return "canvas" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_canvas_number++;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/CardLayout.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/CardLayout.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/CardLayout.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/CardLayout.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,496 @@
+/* CardLayout.java -- Card-based layout engine
+ Copyright (C) 1999, 2000, 2002, 2003, 2004 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.io.Serializable;
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+/**
+ * This class implements a card-based layout scheme. Each included
+ * component is treated as a card. Only one card can be shown at a
+ * time. This class includes methods for changing which card is
+ * shown.
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class CardLayout implements LayoutManager2, Serializable
+{
+ private static final long serialVersionUID = -4328196481005934313L;
+
+ /**
+ * Initializes a new instance of <code>CardLayout</code> with horizontal
+ * and vertical gaps of 0.
+ */
+ public CardLayout ()
+ {
+ this (0, 0);
+ }
+
+ /**
+ * Create a new <code>CardLayout</code> object with the specified
+ * horizontal and vertical gaps.
+ *
+ * @param hgap The horizontal gap
+ * @param vgap The vertical gap
+ */
+ public CardLayout (int hgap, int vgap)
+ {
+ this.hgap = hgap;
+ this.vgap = vgap;
+ this.tab = new Hashtable ();
+ }
+
+ /**
+ * Add a new component to the layout. The constraint must be a
+ * string which is used to name the component. This string can
+ * later be used to refer to the particular component.
+ *
+ * @param comp The component to add
+ * @param constraints The name by which the component can later be called
+ *
+ * @exception IllegalArgumentException If `constraints' is not a
+ * <code>String</code>
+ */
+ public void addLayoutComponent (Component comp, Object constraints)
+ {
+ if (! (constraints instanceof String))
+ throw new IllegalArgumentException ("Object " + constraints
+ + " is not a string");
+ addLayoutComponent ((String) constraints, comp);
+ }
+
+ /**
+ * Add a new component to the layout. The name can be used later
+ * to refer to the component.
+ *
+ * @param name The name by which the component can later be called
+ * @param comp The component to add
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>addLayoutComponent(Component, Object)</code>.
+ */
+ public void addLayoutComponent (String name, Component comp)
+ {
+ tab.put (name, comp);
+ // First component added is the default component.
+ comp.setVisible(tab.size() == 1);
+ }
+
+ /**
+ * Cause the first component in the container to be displayed.
+ *
+ * @param parent The parent container, not <code>null</code>.
+ */
+ public void first (Container parent)
+ {
+ gotoComponent (parent, FIRST);
+ }
+
+ /**
+ * Return this layout manager's horizontal gap.
+ *
+ * @return the horizontal gap
+ */
+ public int getHgap ()
+ {
+ return hgap;
+ }
+
+ /**
+ * Return this layout manager's x alignment. This method always
+ * returns Component.CENTER_ALIGNMENT.
+ *
+ * @param parent Container using this layout manager instance
+ *
+ * @return the x-axis alignment
+ */
+ public float getLayoutAlignmentX (Container parent)
+ {
+ return Component.CENTER_ALIGNMENT;
+ }
+
+ /**
+ * Returns this layout manager's y alignment. This method always
+ * returns Component.CENTER_ALIGNMENT.
+ *
+ * @param parent Container using this layout manager instance
+ *
+ * @return the y-axis alignment
+ */
+ public float getLayoutAlignmentY (Container parent)
+ {
+ return Component.CENTER_ALIGNMENT;
+ }
+
+ /**
+ * Return this layout manager's vertical gap.
+ *
+ * @return the vertical gap
+ */
+ public int getVgap ()
+ {
+ return vgap;
+ }
+
+ /**
+ * Invalidate this layout manager's state.
+ */
+ public void invalidateLayout (Container target)
+ {
+ // Do nothing.
+ }
+
+ /**
+ * Cause the last component in the container to be displayed.
+ *
+ * @param parent The parent container, not <code>null</code>.
+ */
+ public void last (Container parent)
+ {
+ gotoComponent (parent, LAST);
+ }
+
+ /**
+ * Lays out the container. This is done by resizing the child components
+ * to be the same size as the parent, less insets and gaps.
+ *
+ * @param parent The parent container.
+ */
+ public void layoutContainer (Container parent)
+ {
+ synchronized (parent.getTreeLock ())
+ {
+ int width = parent.width;
+ int height = parent.height;
+
+ Insets ins = parent.getInsets ();
+
+ int num = parent.ncomponents;
+ Component[] comps = parent.component;
+
+ int x = ins.left + hgap;
+ int y = ins.top + vgap;
+ width = width - 2 * hgap - ins.left - ins.right;
+ height = height - 2 * vgap - ins.top - ins.bottom;
+
+ for (int i = 0; i < num; ++i)
+ comps[i].setBounds (x, y, width, height);
+ }
+ }
+
+ /**
+ * Get the maximum layout size of the container.
+ *
+ * @param target The parent container
+ *
+ * @return the maximum layout size
+ */
+ public Dimension maximumLayoutSize (Container target)
+ {
+ // The JCL says that this returns Integer.MAX_VALUE for both
+ // dimensions. But that just seems wrong to me.
+ return getSize (target, MAX);
+ }
+
+ /**
+ * Get the minimum layout size of the container.
+ *
+ * @param target The parent container
+ *
+ * @return the minimum layout size
+ */
+ public Dimension minimumLayoutSize (Container target)
+ {
+ return getSize (target, MIN);
+ }
+
+ /**
+ * Cause the next component in the container to be displayed. If
+ * this current card is the last one in the deck, the first
+ * component is displayed.
+ *
+ * @param parent The parent container, not <code>null</code>.
+ */
+ public void next (Container parent)
+ {
+ gotoComponent (parent, NEXT);
+ }
+
+ /**
+ * Get the preferred layout size of the container.
+ *
+ * @param parent The parent container
+ *
+ * @return the preferred layout size
+ */
+ public Dimension preferredLayoutSize (Container parent)
+ {
+ return getSize (parent, PREF);
+ }
+
+ /**
+ * Cause the previous component in the container to be displayed.
+ * If this current card is the first one in the deck, the last
+ * component is displayed.
+ *
+ * @param parent The parent container, not <code>null</code>.
+ */
+ public void previous (Container parent)
+ {
+ gotoComponent (parent, PREV);
+ }
+
+ /**
+ * Remove the indicated component from this layout manager.
+ *
+ * @param comp The component to remove
+ */
+ public void removeLayoutComponent (Component comp)
+ {
+ Enumeration e = tab.keys ();
+ while (e.hasMoreElements ())
+ {
+ Object key = e.nextElement ();
+ if (tab.get (key) == comp)
+ {
+ tab.remove (key);
+ Container parent = comp.getParent();
+ next(parent);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Set this layout manager's horizontal gap.
+ *
+ * @param hgap The new gap
+ */
+ public void setHgap (int hgap)
+ {
+ this.hgap = hgap;
+ }
+
+ /**
+ * Set this layout manager's vertical gap.
+ *
+ * @param vgap The new gap
+ */
+ public void setVgap (int vgap)
+ {
+ this.vgap = vgap;
+ }
+
+ /**
+ * Cause the named component to be shown. If the component name is
+ * unknown or <code>null</code>, this method does nothing.
+ *
+ * @param parent The parent container, not <code>null</code>.
+ * @param name The name of the component to show
+ */
+ public void show (Container parent, String name)
+ {
+ if (name == null)
+ return;
+
+ if (parent.getLayout() != this)
+ throw new IllegalArgumentException("parent's layout is not this CardLayout");
+
+ Object target = tab.get (name);
+ if (target != null)
+ {
+ int num = parent.ncomponents;
+ // This is more efficient than calling getComponents().
+ Component[] comps = parent.component;
+ for (int i = 0; i < num; ++i)
+ {
+ if (comps[i].isVisible())
+ {
+ if (target == comps[i])
+ return;
+ comps[i].setVisible (false);
+ }
+ }
+ ((Component) target).setVisible (true);
+ parent.validate();
+ }
+ }
+
+ /**
+ * Returns a string representation of this layout manager.
+ *
+ * @return A string representation of this object.
+ */
+ public String toString ()
+ {
+ return getClass ().getName () + "[" + hgap + "," + vgap + "]";
+ }
+
+ /**
+ * This implements first(), last(), next(), and previous().
+ *
+ * @param parent The parent container
+ * @param what The type of goto: FIRST, LAST, NEXT or PREV
+ *
+ * @throws IllegalArgumentException if parent has not this
+ * CardLayout set as its layout.
+ */
+ private void gotoComponent (Container parent, int what)
+ {
+ if (parent.getLayout() != this)
+ throw new IllegalArgumentException("parent's layout is not this CardLayout");
+
+ synchronized (parent.getTreeLock ())
+ {
+ int num = parent.ncomponents;
+ // This is more efficient than calling getComponents().
+ Component[] comps = parent.component;
+
+ if (num == 1)
+ {
+ comps[0].setVisible(true);
+ return;
+ }
+
+ int choice = -1;
+
+ if (what == FIRST)
+ choice = 0;
+ else if (what == LAST)
+ choice = num - 1;
+
+ for (int i = 0; i < num; ++i)
+ {
+ if (comps[i].isVisible ())
+ {
+ if (what == NEXT)
+ {
+ choice = i + 1;
+ if (choice == num)
+ choice = 0;
+ }
+ else if (what == PREV)
+ {
+ choice = i - 1;
+ if (choice < 0)
+ choice = num - 1;
+ }
+ else if (choice == i)
+ {
+ // Do nothing if we're already looking at the right
+ // component.
+ return;
+ }
+ comps[i].setVisible (false);
+
+ if (choice >= 0)
+ break;
+ }
+ }
+
+ if (choice >= 0 && choice < num)
+ comps[choice].setVisible (true);
+ }
+ }
+
+ // Compute the size according to WHAT.
+ private Dimension getSize (Container parent, int what)
+ {
+ synchronized (parent.getTreeLock ())
+ {
+ int w = 0, h = 0, num = parent.ncomponents;
+ Component[] comps = parent.component;
+
+ for (int i = 0; i < num; ++i)
+ {
+ Dimension d;
+
+ if (what == MIN)
+ d = comps[i].getMinimumSize ();
+ else if (what == MAX)
+ d = comps[i].getMaximumSize ();
+ else
+ d = comps[i].getPreferredSize ();
+
+ w = Math.max (d.width, w);
+ h = Math.max (d.height, h);
+ }
+
+ Insets i = parent.getInsets ();
+ w += 2 * hgap + i.right + i.left;
+ h += 2 * vgap + i.bottom + i.top;
+
+ // Handle overflow.
+ if (w < 0)
+ w = Integer.MAX_VALUE;
+ if (h < 0)
+ h = Integer.MAX_VALUE;
+
+ return new Dimension (w, h);
+ }
+ }
+
+ /**
+ * @serial Horizontal gap value.
+ */
+ private int hgap;
+
+ /**
+ * @serial Vertical gap value.
+ */
+ private int vgap;
+
+ /**
+ * @serial Table of named components.
+ */
+ private Hashtable tab;
+
+ // These constants are used by the private gotoComponent method.
+ private static final int FIRST = 0;
+ private static final int LAST = 1;
+ private static final int NEXT = 2;
+ private static final int PREV = 3;
+
+ // These constants are used by the private getSize method.
+ private static final int MIN = 0;
+ private static final int MAX = 1;
+ private static final int PREF = 2;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Checkbox.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Checkbox.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Checkbox.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Checkbox.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,665 @@
+/* Checkbox.java -- An AWT checkbox widget
+ Copyright (C) 1999, 2000, 2001, 2002, 2005, 2006
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.peer.CheckboxPeer;
+import java.io.Serializable;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleAction;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
+import javax.accessibility.AccessibleValue;
+
+/**
+ * This class implements a component which has an on/off state. Two
+ * or more Checkboxes can be grouped by a CheckboxGroup.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Tom Tromey (tromey at redhat.com)
+ */
+public class Checkbox extends Component
+ implements ItemSelectable, Accessible, Serializable
+{
+
+// FIXME: Need readObject/writeObject for this.
+
+/*
+ * Static Variables
+ */
+
+// Serialization Constant
+private static final long serialVersionUID = 7270714317450821763L;
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+/**
+ * @serial The checkbox group for this checkbox.
+ */
+private CheckboxGroup group;
+
+/**
+ * @serial The label on this checkbox.
+ */
+private String label;
+
+/**
+ * @serial The state of this checkbox.
+ * This is package-private to avoid an accessor method.
+ */
+boolean state;
+
+// The list of listeners for this object.
+private transient ItemListener item_listeners;
+
+ /*
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_checkbox_number;
+
+/**
+ * This class provides accessibility support for the
+ * checkbox.
+ *
+ * @author Jerry Quinn (jlquinn at optonline.net)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ */
+protected class AccessibleAWTCheckbox
+ extends AccessibleAWTComponent
+ implements ItemListener, AccessibleAction, AccessibleValue
+{
+ /**
+ * Serialization constant to match JDK 1.5
+ */
+ private static final long serialVersionUID = 7881579233144754107L;
+
+ /**
+ * Default constructor which simply calls the
+ * super class for generic component accessibility
+ * handling.
+ */
+ public AccessibleAWTCheckbox()
+ {
+ super();
+ }
+
+ /**
+ * Captures changes to the state of the checkbox and
+ * fires appropriate accessible property change events.
+ *
+ * @param event the event fired.
+ * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
+ */
+ public void itemStateChanged(ItemEvent event)
+ {
+ firePropertyChange(ACCESSIBLE_STATE_PROPERTY,
+ state ? null : AccessibleState.CHECKED,
+ state ? AccessibleState.CHECKED : null);
+ }
+
+ /**
+ * Returns an implementation of the <code>AccessibleAction</code>
+ * interface for this accessible object. In this case, the
+ * current instance is simply returned (with a more appropriate
+ * type), as it also implements the accessible action as well as
+ * the context.
+ *
+ * @return the accessible action associated with this context.
+ * @see javax.accessibility.AccessibleAction
+ */
+ public AccessibleAction getAccessibleAction()
+ {
+ return this;
+ }
+
+ /**
+ * Returns an implementation of the <code>AccessibleValue</code>
+ * interface for this accessible object. In this case, the
+ * current instance is simply returned (with a more appropriate
+ * type), as it also implements the accessible value as well as
+ * the context.
+ *
+ * @return the accessible value associated with this context.
+ * @see javax.accessibility.AccessibleValue
+ */
+ public AccessibleValue getAccessibleValue()
+ {
+ return this;
+ }
+
+ /*
+ * The following methods are implemented in the JDK (up to
+ * 1.5) as stubs. We do likewise here.
+ */
+
+ /**
+ * Returns the number of actions associated with this accessible
+ * object. This default implementation returns 0.
+ *
+ * @return the number of accessible actions available.
+ * @see javax.accessibility.AccessibleAction#getAccessibleActionCount()
+ */
+ public int getAccessibleActionCount()
+ {
+ // 1.4.1 and 1.5 do this
+ return 0;
+ }
+
+ /**
+ * Returns a description of the action with the supplied id.
+ * This default implementation always returns null.
+ *
+ * @param i the id of the action whose description should be
+ * retrieved.
+ * @return a <code>String</code> describing the action.
+ * @see javax.accessibility.AccessibleAction#getAccessibleActionDescription(int)
+ */
+ public String getAccessibleActionDescription(int i)
+ {
+ // 1.5 does this
+ return null;
+ }
+
+ /**
+ * Executes the action with the specified id. This
+ * default implementation simply returns false.
+ *
+ * @param i the id of the action to perform.
+ * @return true if the action was performed.
+ * @see javax.accessibility.AccessibleAction#doAccessibleAction(int)
+ */
+ public boolean doAccessibleAction(int i)
+ {
+ // 1.5 does this
+ return false;
+ }
+
+ /**
+ * Returns the current value of this accessible object.
+ * If no value has been set, null is returned. This
+ * default implementation always returns null, regardless.
+ *
+ * @return the numeric value of this object, or null if
+ * no value has been set.
+ * @see javax.accessibility.AccessibleValue#getCurrentAccessibleValue()
+ */
+ public Number getCurrentAccessibleValue()
+ {
+ // 1.5 does this
+ return null;
+ }
+
+ /**
+ * Sets the current value of this accessible object
+ * to that supplied. In this default implementation,
+ * the value is never set and the method always returns
+ * false.
+ *
+ * @param number the new accessible value.
+ * @return true if the value was set.
+ * @see javax.accessibility.AccessibleValue#setCurrentAccessibleValue(java.lang.Number)
+ */
+ public boolean setCurrentAccessibleValue(Number number)
+ {
+ // 1.5 does this
+ return false;
+ }
+
+ /**
+ * Returns the minimum acceptable accessible value used
+ * by this object, or null if no minimum value exists.
+ * This default implementation always returns null.
+ *
+ * @return the minimum acceptable accessible value, or null
+ * if there is no minimum.
+ * @see javax.accessibility.AccessibleValue#getMinimumAccessibleValue()
+ */
+ public Number getMinimumAccessibleValue()
+ {
+ return null;
+ }
+
+ /**
+ * Returns the maximum acceptable accessible value used
+ * by this object, or null if no maximum value exists.
+ * This default implementation always returns null.
+ *
+ * @return the maximum acceptable accessible value, or null
+ * if there is no maximum.
+ * @see javax.accessibility.AccessibleValue#getMaximumAccessibleValue()
+ */
+ public Number getMaximumAccessibleValue()
+ {
+ return null;
+ }
+
+ /**
+ * Returns the role of this accessible object.
+ *
+ * @return the instance of <code>AccessibleRole</code>,
+ * which describes this object.
+ * @see javax.accessibility.AccessibleRole
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.CHECK_BOX;
+ }
+
+ /**
+ * Returns the state set of this accessible object.
+ *
+ * @return a set of <code>AccessibleState</code>s
+ * which represent the current state of the
+ * accessible object.
+ * @see javax.accessibility.AccessibleState
+ * @see javax.accessibility.AccessibleStateSet
+ */
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ AccessibleStateSet set = super.getAccessibleStateSet();
+ if (state)
+ set.add(AccessibleState.CHECKED);
+ return set;
+ }
+
+}
+
+/*************************************************************************/
+
+/*
+ * Constructors
+ */
+
+/**
+ * Initializes a new instance of <code>Checkbox</code> with no label,
+ * an initial state of off, and that is not part of any checkbox group.
+ */
+public
+Checkbox()
+{
+ this("", false, null);
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>Checkbox</code> with the specified
+ * label, an initial state of off, and that is not part of any checkbox
+ * group.
+ *
+ * @param label The label for this checkbox.
+ */
+public
+Checkbox(String label)
+{
+ this(label, false, null);
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>Checkbox</code> with the specified
+ * label and initial state, and that is not part of any checkbox
+ * group.
+ *
+ * @param label The label for this checkbox.
+ * @param state The initial state of the checkbox, <code>true</code> for
+ * on, <code>false</code> for off.
+ */
+public
+Checkbox(String label, boolean state)
+{
+ this(label, state, null);
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>Checkbox</code> with the specified
+ * label, initial state, and checkbox group.
+ *
+ * @param label The label for this checkbox.
+ * @param group The checkbox group for this box, or <code>null</code>
+ * if there is no checkbox group.
+ * @param state The initial state of the checkbox, <code>true</code> for
+ * on, <code>false</code> for off.
+ */
+public
+Checkbox(String label, CheckboxGroup group, boolean state)
+{
+ this(label, state, group);
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>Checkbox</code> with the specified
+ * label, initial state, and checkbox group.
+ *
+ * @param label The label for this checkbox.
+ * @param state The initial state of the checkbox, <code>true</code> for
+ * on, <code>false</code> for off.
+ * @param group The checkbox group for this box, or <code>null</code>
+ * if there is no checkbox group.
+ */
+public
+Checkbox(String label, boolean state, CheckboxGroup group)
+{
+ this.label = label;
+ this.state = state;
+ this.group = group;
+
+ if ( state && group != null )
+ {
+ group.setSelectedCheckbox(this);
+ }
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+/**
+ * Returns the label for this checkbox.
+ *
+ * @return The label for this checkbox.
+ */
+public String
+getLabel()
+{
+ return(label);
+}
+
+/*************************************************************************/
+
+/**
+ * Sets the label for this checkbox to the specified value.
+ *
+ * @param label The new checkbox label.
+ */
+public synchronized void
+setLabel(String label)
+{
+ this.label = label;
+ if (peer != null)
+ {
+ CheckboxPeer cp = (CheckboxPeer) peer;
+ cp.setLabel(label);
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the state of this checkbox.
+ *
+ * @return The state of this checkbox, which will be <code>true</code> for
+ * on and <code>false</code> for off.
+ */
+public boolean
+getState()
+{
+ return(state);
+}
+
+/*************************************************************************/
+
+/**
+ * Sets the state of this checkbox to the specified value.
+ *
+ * @param state The new state of the checkbox, which will be <code>true</code>
+ * for on or <code>false</code> for off.
+ */
+public synchronized void
+setState(boolean state)
+{
+ if (this.state != state)
+ {
+ this.state = state;
+ if (peer != null)
+ {
+ CheckboxPeer cp = (CheckboxPeer) peer;
+ cp.setState (state);
+ }
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * Returns an array of length one containing the checkbox label if this
+ * checkbox is selected. Otherwise <code>null</code> is returned.
+ *
+ * @return The selection state of this checkbox.
+ */
+public Object[]
+getSelectedObjects()
+{
+ if (state == false)
+ return(null);
+
+ Object[] objs = new Object[1];
+ objs[0] = label;
+
+ return(objs);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the checkbox group this object is a member of, if any.
+ *
+ * @return This object's checkbox group, of <code>null</code> if it is
+ * not a member of any group.
+ */
+public CheckboxGroup
+getCheckboxGroup()
+{
+ return(group);
+}
+
+/*************************************************************************/
+
+/**
+ * Sets this object's checkbox group to the specified group.
+ *
+ * @param group The new checkbox group, or <code>null</code> to make this
+ * object part of no checkbox group.
+ */
+public synchronized void
+setCheckboxGroup(CheckboxGroup group)
+{
+ this.group = group;
+ if (peer != null)
+ {
+ CheckboxPeer cp = (CheckboxPeer) peer;
+ cp.setCheckboxGroup (group);
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * Creates this object's native peer.
+ */
+public void
+addNotify()
+{
+ if (peer == null)
+ peer = getToolkit ().createCheckbox (this);
+ super.addNotify ();
+}
+
+ public ItemListener[] getItemListeners ()
+ {
+ return (ItemListener[])
+ AWTEventMulticaster.getListeners (item_listeners, ItemListener.class);
+ }
+
+/**
+ * Adds a new listeners to the list of registered listeners for this object.
+ *
+ * @param listener The new listener to add.
+ */
+public synchronized void
+addItemListener(ItemListener listener)
+{
+ item_listeners = AWTEventMulticaster.add(item_listeners, listener);
+}
+
+/*************************************************************************/
+
+/**
+ * Removes a listener from the list of registered listeners for this object.
+ *
+ * @param listener The listener to remove.
+ */
+public synchronized void
+removeItemListener(ItemListener listener)
+{
+ item_listeners = AWTEventMulticaster.remove(item_listeners, listener);
+}
+
+/*************************************************************************/
+
+/**
+ * Processes this event by calling <code>processItemEvent()</code> if it
+ * is any instance of <code>ItemEvent</code>. Otherwise it is passed to
+ * the superclass for processing.
+ *
+ * @param event The event to process.
+ */
+protected void
+processEvent(AWTEvent event)
+{
+ if (event instanceof ItemEvent)
+ processItemEvent((ItemEvent)event);
+ else
+ super.processEvent(event);
+}
+
+/*************************************************************************/
+
+/**
+ * Processes this event by dispatching it to any registered listeners.
+ *
+ * @param event The <code>ItemEvent</code> to process.
+ */
+protected void
+processItemEvent(ItemEvent event)
+{
+ if (item_listeners != null)
+ item_listeners.itemStateChanged(event);
+}
+
+void
+dispatchEventImpl(AWTEvent e)
+{
+ if (e.id <= ItemEvent.ITEM_LAST
+ && e.id >= ItemEvent.ITEM_FIRST)
+ {
+ ItemEvent ie = (ItemEvent) e;
+ int itemState = ie.getStateChange();
+ setState(itemState == ItemEvent.SELECTED ? true : false);
+ if (item_listeners != null
+ || (eventMask & AWTEvent.ITEM_EVENT_MASK) != 0)
+ processEvent(e);
+ }
+ else
+ super.dispatchEventImpl(e);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns a debugging string for this object.
+ */
+protected String
+paramString()
+{
+ // Note: We cannot add the checkbox group information here because this
+ // would trigger infinite recursion when CheckboxGroup.toString() is
+ // called and the box is in its selected state.
+ return ("label=" + label + ",state=" + state + "," + super.paramString());
+}
+
+/**
+ * Gets the AccessibleContext associated with this <code>Checkbox</code>.
+ * The context is created, if necessary.
+ *
+ * @return the associated context
+ */
+public AccessibleContext getAccessibleContext()
+{
+ /* Create the context if this is the first request */
+ if (accessibleContext == null)
+ {
+ AccessibleAWTCheckbox ac = new AccessibleAWTCheckbox();
+ accessibleContext = ac;
+ addItemListener(ac);
+ }
+ return accessibleContext;
+}
+
+ /**
+ * Generate a unique name for this checkbox.
+ *
+ * @return A unique name for this checkbox.
+ */
+ String generateName()
+ {
+ return "checkbox" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_checkbox_number++;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/CheckboxGroup.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/CheckboxGroup.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/CheckboxGroup.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/CheckboxGroup.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,173 @@
+/* CheckboxGroup.java -- A grouping class for checkboxes.
+ Copyright (C) 1999, 2000, 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * This class if for combining checkboxes into groups so that only
+ * one checkbox in the group can be selected at any one time.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Tom Tromey (tromey at redhat.com)
+ */
+public class CheckboxGroup implements java.io.Serializable
+{
+
+/*
+ * Static Variables
+ */
+
+// Serialization constant
+private static final long serialVersionUID = 3729780091441768983L;
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+/**
+ * @serial The currently selected checkbox.
+ */
+private Checkbox selectedCheckbox;
+
+/*************************************************************************/
+
+/*
+ * Constructors
+ */
+
+/**
+ * Initializes a new instance of <code>CheckboxGroup</code>.
+ */
+public
+CheckboxGroup()
+{
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Methods
+ */
+
+/**
+ * Returns the currently selected checkbox, or <code>null</code> if none
+ * of the checkboxes in this group are selected.
+ *
+ * @return The selected checkbox.
+ */
+public Checkbox
+getSelectedCheckbox()
+{
+ return getCurrent ();
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the currently selected checkbox, or <code>null</code> if none
+ * of the checkboxes in this group are selected.
+ *
+ * @return The selected checkbox.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getSelectedCheckbox()</code>.
+ */
+public Checkbox
+getCurrent()
+{
+ return(selectedCheckbox);
+}
+
+/*************************************************************************/
+
+/**
+ * This method sets the specified checkbox to be the selected on in this
+ * group, and unsets all others.
+ *
+ * @param selectedCheckbox The new selected checkbox.
+ */
+public void
+setSelectedCheckbox(Checkbox selectedCheckbox)
+{
+ setCurrent (selectedCheckbox);
+}
+
+/*************************************************************************/
+
+/**
+ * This method sets the specified checkbox to be the selected on in this
+ * group, and unsets all others.
+ *
+ * @param selectedCheckbox The new selected checkbox.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>setSelectedCheckbox()</code>.
+ */
+public void
+setCurrent(Checkbox selectedCheckbox)
+{
+ if (this.selectedCheckbox != null)
+ {
+ if (this.selectedCheckbox.getCheckboxGroup() != this)
+ return;
+
+ this.selectedCheckbox.setState(false);
+ }
+
+ this.selectedCheckbox = selectedCheckbox;
+ if (selectedCheckbox != null)
+ selectedCheckbox.setState(true);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns a string representation of this checkbox group.
+ *
+ * @return A string representation of this checkbox group.
+ */
+public String
+toString()
+{
+ return(getClass().getName() + "[selectedCheckbox=" + selectedCheckbox + "]");
+}
+
+} // class CheckboxGroup
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/CheckboxMenuItem.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/CheckboxMenuItem.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/CheckboxMenuItem.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/CheckboxMenuItem.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,377 @@
+/* CheckboxMenuItem.java -- A menu option with a checkbox on it.
+ Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.peer.CheckboxMenuItemPeer;
+import java.util.EventListener;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleAction;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleValue;
+
+/**
+ * This class implements a menu item that has a checkbox on it indicating
+ * the selected state of some option.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Tom Tromey (tromey at redhat.com)
+ */
+public class CheckboxMenuItem extends MenuItem
+ implements ItemSelectable, Accessible
+{
+
+/*
+ * Static Variables
+ */
+
+/**
+ * The number used to generate the name returned by getName.
+ */
+private static transient long next_chkmenuitem_number;
+
+// Serialization constant
+private static final long serialVersionUID = 6190621106981774043L;
+
+/*
+ * Instance Variables
+ */
+
+/**
+ * @serial The state of the checkbox, with <code>true</code> being on and
+ * <code>false</code> being off.
+ */
+private boolean state;
+
+// List of registered ItemListeners
+private transient ItemListener item_listeners;
+
+/*************************************************************************/
+
+/*
+ * Constructors
+ */
+
+/**
+ * Initializes a new instance of <code>CheckboxMenuItem</code> with no
+ * label and an initial state of off.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true.
+ */
+public
+CheckboxMenuItem()
+{
+ this("", false);
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>CheckboxMenuItem</code> with the
+ * specified label and an initial state of off.
+ *
+ * @param label The label of the menu item.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true.
+ */
+public
+CheckboxMenuItem(String label)
+{
+ this(label, false);
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>CheckboxMenuItem</code> with the
+ * specified label and initial state.
+ *
+ * @param label The label of the menu item.
+ * @param state The initial state of the menu item, where <code>true</code>
+ * is on, and <code>false</code> is off.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true.
+ */
+public
+CheckboxMenuItem(String label, boolean state)
+{
+ super(label);
+ this.state = state;
+
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException ();
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Methods
+ */
+
+/**
+ * Returns the state of this menu item.
+ *
+ * @return The state of this menu item.
+ */
+public boolean
+getState()
+{
+ return(state);
+}
+
+/*************************************************************************/
+
+/**
+ * Sets the state of this menu item.
+ *
+ * @param state The initial state of the menu item, where <code>true</code>
+ * is on, and <code>false</code> is off.
+ */
+public synchronized void
+setState(boolean state)
+{
+ this.state = state;
+ if (peer != null)
+ {
+ CheckboxMenuItemPeer cp = (CheckboxMenuItemPeer) peer;
+ cp.setState (state);
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * Returns an array of length 1 with the menu item label for this object
+ * if the state is on. Otherwise <code>null</code> is returned.
+ *
+ * @return An array with this menu item's label if it has a state of on,
+ * or <code>null</code> otherwise.
+ */
+public Object[]
+getSelectedObjects()
+{
+ if (state == false)
+ return(null);
+
+ Object[] obj = new Object[1];
+ obj[0] = getLabel();
+
+ return(obj);
+}
+
+/*************************************************************************/
+
+/**
+ * Create's this object's native peer
+ */
+public synchronized void
+addNotify()
+{
+ if (peer == null)
+ peer = getToolkit().createCheckboxMenuItem(this);
+
+ super.addNotify ();
+}
+
+/*************************************************************************/
+
+/**
+ * Adds the specified listener to the list of registered item listeners
+ * for this object.
+ *
+ * @param listener The listener to add.
+ */
+public synchronized void
+addItemListener(ItemListener listener)
+{
+ item_listeners = AWTEventMulticaster.add(item_listeners, listener);
+
+ enableEvents(AWTEvent.ITEM_EVENT_MASK);
+}
+
+/*************************************************************************/
+
+/**
+ * Removes the specified listener from the list of registered item
+ * listeners for this object.
+ *
+ * @param listener The listener to remove.
+ */
+public synchronized void
+removeItemListener(ItemListener listener)
+{
+ item_listeners = AWTEventMulticaster.remove(item_listeners, listener);
+}
+
+/*************************************************************************/
+
+/**
+ * Processes the specified event by calling <code>processItemEvent()</code>
+ * if it is an instance of <code>ItemEvent</code> or calling the superclass
+ * method otherwise.
+ *
+ * @param event The event to process.
+ */
+protected void
+processEvent(AWTEvent event)
+{
+ if (event instanceof ItemEvent)
+ processItemEvent((ItemEvent)event);
+ else
+ super.processEvent(event);
+}
+
+/*************************************************************************/
+
+/**
+ * Processes the specified event by dispatching it to any registered listeners.
+ *
+ * @param event The event to process.
+ */
+protected void
+processItemEvent(ItemEvent event)
+{
+ if (item_listeners != null)
+ item_listeners.itemStateChanged(event);
+}
+
+void
+dispatchEventImpl(AWTEvent e)
+{
+ if (e instanceof ItemEvent)
+ {
+ synchronized (this)
+ {
+ state = (((ItemEvent) e).getStateChange() == ItemEvent.SELECTED);
+ }
+ }
+
+ if (e.id <= ItemEvent.ITEM_LAST
+ && e.id >= ItemEvent.ITEM_FIRST
+ && (item_listeners != null
+ || (eventMask & AWTEvent.ITEM_EVENT_MASK) != 0))
+ processEvent(e);
+ else
+ super.dispatchEventImpl(e);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns a debugging string for this object.
+ *
+ * @return A debugging string for this object.
+ */
+public String
+paramString()
+{
+ return ("label=" + getLabel() + ",state=" + state
+ + "," + super.paramString());
+}
+
+ /**
+ * Returns an array of all the objects currently registered as FooListeners
+ * upon this <code>CheckboxMenuItem</code>. FooListeners are registered using
+ * the addFooListener method.
+ *
+ * @exception ClassCastException If listenerType doesn't specify a class or
+ * interface that implements java.util.EventListener.
+ */
+ public EventListener[] getListeners (Class listenerType)
+ {
+ if (listenerType == ItemListener.class)
+ return AWTEventMulticaster.getListeners (item_listeners, listenerType);
+
+ return super.getListeners (listenerType);
+ }
+
+ /**
+ * Returns an aray of all item listeners currently registered to this
+ * <code>CheckBoxMenuItem</code>.
+ */
+ public ItemListener[] getItemListeners ()
+ {
+ return (ItemListener[]) getListeners (ItemListener.class);
+ }
+
+
+ protected class AccessibleAWTCheckboxMenuItem extends AccessibleAWTMenuItem
+ implements AccessibleAction, AccessibleValue
+ {
+ // I think the base class provides the necessary implementation
+
+ private static final long serialVersionUID = -1122642964303476L;
+ }
+
+ /**
+ * Gets the AccessibleContext associated with this <code>CheckboxMenuItem</code>.
+ * The context is created, if necessary.
+ *
+ * @return the associated context
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ /* Create the context if this is the first request */
+ if (accessibleContext == null)
+ accessibleContext = new AccessibleAWTCheckboxMenuItem();
+ return accessibleContext;
+ }
+
+ /**
+ * Generate a unique name for this <code>CheckboxMenuItem</code>.
+ *
+ * @return A unique name for this <code>CheckboxMenuItem</code>.
+ */
+ String generateName()
+ {
+ return "chkmenuitem" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_chkmenuitem_number++;
+ }
+
+} // class CheckboxMenuItem
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Choice.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Choice.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Choice.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Choice.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,572 @@
+/* Choice.java -- Java choice button widget.
+ Copyright (C) 1999, 2000, 2001, 2002, 2004, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.peer.ChoicePeer;
+import java.io.Serializable;
+import java.util.EventListener;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleAction;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+
+/**
+ * This class implements a drop down choice list.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class Choice extends Component
+ implements ItemSelectable, Serializable, Accessible
+{
+ /**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_choice_number;
+
+ // Serialization constant
+ private static final long serialVersionUID = -4075310674757313071L;
+
+ /**
+ * @serial A list of items for the choice box, which can be <code>null</code>.
+ * This is package-private to avoid an accessor method.
+ */
+ Vector pItems = new Vector();
+
+ /**
+ * @serial The index of the selected item in the choice box.
+ */
+ private int selectedIndex = -1;
+
+ /**
+ * ItemListener chain
+ */
+ private ItemListener item_listeners;
+
+ /**
+ * This class provides accessibility support for the
+ * combo box.
+ *
+ * @author Jerry Quinn (jlquinn at optonline.net)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ */
+ protected class AccessibleAWTChoice
+ extends AccessibleAWTComponent
+ implements AccessibleAction
+ {
+
+ /**
+ * Serialization constant to match JDK 1.5
+ */
+ private static final long serialVersionUID = 7175603582428509322L;
+
+ /**
+ * Default constructor which simply calls the
+ * super class for generic component accessibility
+ * handling.
+ */
+ public AccessibleAWTChoice()
+ {
+ super();
+ }
+
+ /**
+ * Returns an implementation of the <code>AccessibleAction</code>
+ * interface for this accessible object. In this case, the
+ * current instance is simply returned (with a more appropriate
+ * type), as it also implements the accessible action as well as
+ * the context.
+ *
+ * @return the accessible action associated with this context.
+ * @see javax.accessibility.AccessibleAction
+ */
+ public AccessibleAction getAccessibleAction()
+ {
+ return this;
+ }
+
+ /**
+ * Returns the role of this accessible object.
+ *
+ * @return the instance of <code>AccessibleRole</code>,
+ * which describes this object.
+ * @see javax.accessibility.AccessibleRole
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.COMBO_BOX;
+ }
+
+ /**
+ * Returns the number of actions associated with this accessible
+ * object. In this case, it is the number of choices available.
+ *
+ * @return the number of choices available.
+ * @see javax.accessibility.AccessibleAction#getAccessibleActionCount()
+ */
+ public int getAccessibleActionCount()
+ {
+ return pItems.size();
+ }
+
+ /**
+ * Returns a description of the action with the supplied id.
+ * In this case, it is the text used in displaying the particular
+ * choice on-screen.
+ *
+ * @param i the id of the choice whose description should be
+ * retrieved.
+ * @return the <code>String</code> used to describe the choice.
+ * @see javax.accessibility.AccessibleAction#getAccessibleActionDescription(int)
+ */
+ public String getAccessibleActionDescription(int i)
+ {
+ return (String) pItems.get(i);
+ }
+
+ /**
+ * Executes the action with the specified id. In this case,
+ * calling this method provides the same behaviour as would
+ * choosing a choice from the list in a visual manner.
+ *
+ * @param i the id of the choice to select.
+ * @return true if a valid choice was specified.
+ * @see javax.accessibility.AccessibleAction#doAccessibleAction(int)
+ */
+ public boolean doAccessibleAction(int i)
+ {
+ if (i < 0 || i >= pItems.size())
+ return false;
+
+ Choice.this.select( i );
+
+ return true;
+ }
+ }
+
+ /**
+ * Initializes a new instance of <code>Choice</code>.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true
+ */
+ public Choice()
+ {
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException ();
+ }
+
+ /**
+ * Returns the number of items in the list.
+ *
+ * @return The number of items in the list.
+ */
+ public int getItemCount()
+ {
+ return countItems ();
+ }
+
+ /**
+ * Returns the number of items in the list.
+ *
+ * @return The number of items in the list.
+ *
+ * @deprecated This method is deprecated in favor of <code>getItemCount</code>.
+ */
+ public int countItems()
+ {
+ return pItems.size();
+ }
+
+ /**
+ * Returns the item at the specified index in the list.
+ *
+ * @param index The index into the list to return the item from.
+ *
+ * @exception ArrayIndexOutOfBoundsException If the index is invalid.
+ */
+ public String getItem(int index)
+ {
+ return (String)pItems.elementAt(index);
+ }
+
+ /**
+ * Adds the specified item to this choice box.
+ *
+ * @param item The item to add.
+ *
+ * @exception NullPointerException If the item's value is null
+ *
+ * @since 1.1
+ */
+ public synchronized void add(String item)
+ {
+ if (item == null)
+ throw new NullPointerException ("item must be non-null");
+
+ pItems.addElement(item);
+
+ if (peer != null)
+ ((ChoicePeer) peer).add(item, getItemCount() - 1);
+
+ if (selectedIndex == -1)
+ select( 0 );
+ }
+
+ /**
+ * Adds the specified item to this choice box.
+ *
+ * This method is oboslete since Java 2 platform 1.1. Please use @see add
+ * instead.
+ *
+ * @param item The item to add.
+ *
+ * @exception NullPointerException If the item's value is equal to null
+ */
+ public synchronized void addItem(String item)
+ {
+ add(item);
+ }
+
+ /** Inserts an item into this Choice. Existing items are shifted
+ * upwards. If the new item is the only item, then it is selected.
+ * If the currently selected item is shifted, then the first item is
+ * selected. If the currently selected item is not shifted, then it
+ * remains selected.
+ *
+ * @param item The item to add.
+ * @param index The index at which the item should be inserted.
+ *
+ * @exception IllegalArgumentException If index is less than 0
+ */
+ public synchronized void insert(String item, int index)
+ {
+ if (index < 0)
+ throw new IllegalArgumentException ("index may not be less then 0");
+
+ if (index > getItemCount ())
+ index = getItemCount ();
+
+ pItems.insertElementAt(item, index);
+
+ if (peer != null)
+ ((ChoicePeer) peer).add (item, index);
+
+ if (selectedIndex == -1 || selectedIndex >= index)
+ select(0);
+ }
+
+ /**
+ * Removes the specified item from the choice box.
+ *
+ * @param item The item to remove.
+ *
+ * @exception IllegalArgumentException If the specified item doesn't exist.
+ */
+ public synchronized void remove(String item)
+ {
+ int index = pItems.indexOf(item);
+ if (index == -1)
+ throw new IllegalArgumentException ("item \""
+ + item + "\" not found in Choice");
+ remove(index);
+ }
+
+ /**
+ * Removes the item at the specified index from the choice box.
+ *
+ * @param index The index of the item to remove.
+ *
+ * @exception IndexOutOfBoundsException If the index is not valid.
+ */
+ public synchronized void remove(int index)
+ {
+ if ((index < 0) || (index > getItemCount()))
+ throw new IllegalArgumentException("Bad index: " + index);
+
+ pItems.removeElementAt(index);
+
+ if (peer != null)
+ ((ChoicePeer) peer).remove( index );
+
+ if( getItemCount() == 0 )
+ selectedIndex = -1;
+ else
+ {
+ if( selectedIndex > index )
+ selectedIndex--;
+ else if( selectedIndex == index )
+ selectedIndex = 0;
+
+ if( peer != null )
+ ((ChoicePeer)peer).select( selectedIndex );
+ }
+ }
+
+ /**
+ * Removes all of the objects from this choice box.
+ */
+ public synchronized void removeAll()
+ {
+ if (getItemCount() <= 0)
+ return;
+
+ pItems.removeAllElements ();
+
+ if (peer != null)
+ {
+ ChoicePeer cp = (ChoicePeer) peer;
+ cp.removeAll ();
+ }
+
+ selectedIndex = -1;
+ }
+
+ /**
+ * Returns the currently selected item, or null if no item is
+ * selected.
+ *
+ * @return The currently selected item.
+ */
+ public synchronized String getSelectedItem()
+ {
+ return (selectedIndex == -1
+ ? null
+ : ((String)pItems.elementAt(selectedIndex)));
+ }
+
+ /**
+ * Returns an array with one row containing the selected item.
+ *
+ * @return An array containing the selected item.
+ */
+ public synchronized Object[] getSelectedObjects()
+ {
+ if (selectedIndex == -1)
+ return null;
+
+ Object[] objs = new Object[1];
+ objs[0] = pItems.elementAt(selectedIndex);
+
+ return objs;
+ }
+
+ /**
+ * Returns the index of the selected item.
+ *
+ * @return The index of the selected item.
+ */
+ public int getSelectedIndex()
+ {
+ return selectedIndex;
+ }
+
+ /**
+ * Forces the item at the specified index to be selected.
+ *
+ * @param index The index of the row to make selected.
+ *
+ * @exception IllegalArgumentException If the specified index is invalid.
+ */
+ public synchronized void select(int index)
+ {
+ if ((index < 0) || (index >= getItemCount()))
+ throw new IllegalArgumentException("Bad index: " + index);
+
+ if( selectedIndex == index )
+ return;
+
+ selectedIndex = index;
+ if( peer != null )
+ ((ChoicePeer)peer).select( index );
+ }
+
+ /**
+ * Forces the named item to be selected.
+ *
+ * @param item The item to be selected.
+ *
+ * @exception IllegalArgumentException If the specified item does not exist.
+ */
+ public synchronized void select(String item)
+ {
+ int index = pItems.indexOf(item);
+ if( index >= 0 )
+ select( index );
+ }
+
+ /**
+ * Creates the native peer for this object.
+ */
+ public void addNotify()
+ {
+ if (peer == null)
+ peer = getToolkit ().createChoice (this);
+ super.addNotify ();
+ }
+
+ /**
+ * Adds the specified listener to the list of registered listeners for
+ * this object.
+ *
+ * @param listener The listener to add.
+ */
+ public synchronized void addItemListener(ItemListener listener)
+ {
+ item_listeners = AWTEventMulticaster.add(item_listeners, listener);
+ }
+
+ /**
+ * Removes the specified listener from the list of registered listeners for
+ * this object.
+ *
+ * @param listener The listener to remove.
+ */
+ public synchronized void removeItemListener(ItemListener listener)
+ {
+ item_listeners = AWTEventMulticaster.remove(item_listeners, listener);
+ }
+
+ /**
+ * Processes this event by invoking <code>processItemEvent()</code> if the
+ * event is an instance of <code>ItemEvent</code>, otherwise the event
+ * is passed to the superclass.
+ *
+ * @param event The event to process.
+ */
+ protected void processEvent(AWTEvent event)
+ {
+ if (event instanceof ItemEvent)
+ processItemEvent((ItemEvent)event);
+ else
+ super.processEvent(event);
+ }
+
+ void dispatchEventImpl(AWTEvent e)
+ {
+ super.dispatchEventImpl(e);
+
+ if( e.id <= ItemEvent.ITEM_LAST && e.id >= ItemEvent.ITEM_FIRST &&
+ ( item_listeners != null ||
+ ( eventMask & AWTEvent.ITEM_EVENT_MASK ) != 0 ) )
+ processEvent(e);
+ }
+
+ /**
+ * Processes item event by dispatching to any registered listeners.
+ *
+ * @param event The event to process.
+ */
+ protected void processItemEvent(ItemEvent event)
+ {
+ int index = pItems.indexOf((String) event.getItem());
+ if (item_listeners != null)
+ item_listeners.itemStateChanged(event);
+ }
+
+ /**
+ * Returns a debugging string for this object.
+ *
+ * @return A debugging string for this object.
+ */
+ protected String paramString()
+ {
+ return "selectedIndex=" + selectedIndex + "," + super.paramString();
+ }
+
+ /**
+ * Returns an array of all the objects currently registered as FooListeners
+ * upon this Choice. FooListeners are registered using the addFooListener
+ * method.
+ *
+ * @exception ClassCastException If listenerType doesn't specify a class or
+ * interface that implements java.util.EventListener.
+ *
+ * @since 1.3
+ */
+ public EventListener[] getListeners (Class listenerType)
+ {
+ if (listenerType == ItemListener.class)
+ return AWTEventMulticaster.getListeners (item_listeners, listenerType);
+
+ return super.getListeners (listenerType);
+ }
+
+ /**
+ * Returns all registered item listeners.
+ *
+ * @since 1.4
+ */
+ public ItemListener[] getItemListeners ()
+ {
+ return (ItemListener[]) getListeners (ItemListener.class);
+ }
+
+ /**
+ * Gets the AccessibleContext associated with this <code>Choice</code>.
+ * The context is created, if necessary.
+ *
+ * @return the associated context
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ /* Create the context if this is the first request */
+ if (accessibleContext == null)
+ accessibleContext = new AccessibleAWTChoice();
+ return accessibleContext;
+ }
+
+ /**
+ * Generate a unique name for this <code>Choice</code>.
+ *
+ * @return A unique name for this <code>Choice</code>.
+ */
+ String generateName()
+ {
+ return "choice" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_choice_number++;
+ }
+} // class Choice
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Color.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Color.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Color.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Color.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1008 @@
+/* Color.java -- represents a color in Java
+ Copyright (C) 1999, 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.color.ColorSpace;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.ColorModel;
+import java.io.Serializable;
+
+/**
+ * This class represents a color value in the AWT system. It uses the sRGB
+ * (standard Red-Green-Blue) system, along with an alpha value ranging from
+ * transparent (0.0f or 0) and opaque (1.0f or 255). The color is not
+ * pre-multiplied by the alpha value an any of the accessor methods. Further
+ * information about sRGB can be found at
+ * <a href="http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html">
+ * http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html</a>.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @see ColorSpace
+ * @see AlphaComposite
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public class Color implements Paint, Serializable
+{
+ /**
+ * Compatible with JDK 1.0+.
+ */
+ private static final long serialVersionUID = 118526816881161077L;
+
+ /** Constant for the color white: R=255, G=255, B=255. */
+ public static final Color white = new Color(0xffffff, false);
+
+ /**
+ * Constant for the color white: R=255, G=255, B=255.
+ *
+ * @since 1.4
+ */
+ public static final Color WHITE = white;
+
+ /** Constant for the color light gray: R=192, G=192, B=192. */
+ public static final Color lightGray = new Color(0xc0c0c0, false);
+
+ /**
+ * Constant for the color light gray: R=192, G=192, B=192.
+ *
+ * @since 1.4
+ */
+ public static final Color LIGHT_GRAY = lightGray;
+
+ /** Constant for the color gray: R=128, G=128, B=128. */
+ public static final Color gray = new Color(0x808080, false);
+
+ /**
+ * Constant for the color gray: R=128, G=128, B=128.
+ *
+ * @since 1.4
+ */
+ public static final Color GRAY = gray;
+
+ /** Constant for the color dark gray: R=64, G=64, B=64. */
+ public static final Color darkGray = new Color(0x404040, false);
+
+ /**
+ * Constant for the color dark gray: R=64, G=64, B=64.
+ *
+ * @since 1.4
+ */
+ public static final Color DARK_GRAY = darkGray;
+
+ /** Constant for the color black: R=0, G=0, B=0. */
+ public static final Color black = new Color(0x000000, false);
+
+ /**
+ * Constant for the color black: R=0, G=0, B=0.
+ *
+ * @since 1.4
+ */
+ public static final Color BLACK = black;
+
+ /** Constant for the color red: R=255, G=0, B=0. */
+ public static final Color red = new Color(0xff0000, false);
+
+ /**
+ * Constant for the color red: R=255, G=0, B=0.
+ *
+ * @since 1.4
+ */
+ public static final Color RED = red;
+
+ /** Constant for the color pink: R=255, G=175, B=175. */
+ public static final Color pink = new Color(0xffafaf, false);
+
+ /**
+ * Constant for the color pink: R=255, G=175, B=175.
+ *
+ * @since 1.4
+ */
+ public static final Color PINK = pink;
+
+ /** Constant for the color orange: R=255, G=200, B=0. */
+ public static final Color orange = new Color(0xffc800, false);
+
+ /**
+ * Constant for the color orange: R=255, G=200, B=0.
+ *
+ * @since 1.4
+ */
+ public static final Color ORANGE = orange;
+
+ /** Constant for the color yellow: R=255, G=255, B=0. */
+ public static final Color yellow = new Color(0xffff00, false);
+
+ /**
+ * Constant for the color yellow: R=255, G=255, B=0.
+ *
+ * @since 1.4
+ */
+ public static final Color YELLOW = yellow;
+
+ /** Constant for the color green: R=0, G=255, B=0. */
+ public static final Color green = new Color(0x00ff00, false);
+
+ /**
+ * Constant for the color green: R=0, G=255, B=0.
+ *
+ * @since 1.4
+ */
+ public static final Color GREEN = green;
+
+ /** Constant for the color magenta: R=255, G=0, B=255. */
+ public static final Color magenta = new Color(0xff00ff, false);
+
+ /**
+ * Constant for the color magenta: R=255, G=0, B=255.
+ *
+ * @since 1.4
+ */
+ public static final Color MAGENTA = magenta;
+
+ /** Constant for the color cyan: R=0, G=255, B=255. */
+ public static final Color cyan = new Color(0x00ffff, false);
+
+ /**
+ * Constant for the color cyan: R=0, G=255, B=255.
+ *
+ * @since 1.4
+ */
+ public static final Color CYAN = cyan;
+
+ /** Constant for the color blue: R=0, G=0, B=255. */
+ public static final Color blue = new Color(0x0000ff, false);
+
+ /**
+ * Constant for the color blue: R=0, G=0, B=255.
+ *
+ * @since 1.4
+ */
+ public static final Color BLUE = blue;
+
+ /** Internal mask for red. */
+ private static final int RED_MASK = 255 << 16;
+
+ /** Internal mask for green. */
+ private static final int GREEN_MASK = 255 << 8;
+
+ /** Internal mask for blue. */
+ private static final int BLUE_MASK = 255;
+
+ /** Internal mask for alpha. Package visible for use in subclass. */
+ static final int ALPHA_MASK = 255 << 24;
+
+ /** Amount to scale a color by when brightening or darkening. */
+ private static final float BRIGHT_SCALE = 0.7f;
+
+ /**
+ * The color value, in sRGB. Note that the actual color may be more
+ * precise if frgbvalue or fvalue is non-null. This class stores alpha, red,
+ * green, and blue, each 0-255, packed in an int. However, the subclass
+ * SystemColor stores an index into an array. Therefore, for serial
+ * compatibility (and because of poor design on Sun's part), this value
+ * cannot be used directly; instead you must use <code>getRGB()</code>.
+ *
+ * @see #getRGB()
+ * @serial the value of the color, whether an RGB literal or array index
+ */
+ final int value;
+
+ /**
+ * The color value, in sRGB. This may be null if the color was constructed
+ * with ints; and it does not include alpha. This stores red, green, and
+ * blue, in the range 0.0f - 1.0f.
+ *
+ * @see #getRGBColorComponents(float[])
+ * @see #getRGBComponents(float[])
+ * @serial the rgb components of the value
+ * @since 1.2
+ */
+ private float[] frgbvalue;
+
+ /**
+ * The color value, in the native ColorSpace components. This may be null
+ * if the color was constructed with ints or in the sRGB color space; and
+ * it does not include alpha.
+ *
+ * @see #getRGBColorComponents(float[])
+ * @see #getRGBComponents(float[])
+ * @serial the original color space components of the color
+ * @since 1.2
+ */
+ private float[] fvalue;
+
+ /**
+ * The alpha value. This is in the range 0.0f - 1.0f, but is invalid if
+ * deserialized as 0.0 when frgbvalue is null.
+ *
+ * @see #getRGBComponents(float[])
+ * @see #getComponents(float[])
+ * @serial the alpha component of this color
+ * @since 1.2
+ */
+ private final float falpha;
+
+ /**
+ * The ColorSpace. Null means the default sRGB space.
+ *
+ * @see #getColor(String)
+ * @see #getColorSpace()
+ * @see #getColorComponents(float[])
+ * @serial the color space for this color
+ * @since 1.2
+ */
+ private final ColorSpace cs;
+
+ /**
+ * The paint context for this solid color. Package visible for use in
+ * subclass.
+ */
+ transient ColorPaintContext context;
+
+ /**
+ * Initializes a new instance of <code>Color</code> using the specified
+ * red, green, and blue values, which must be given as integers in the
+ * range of 0-255. Alpha will default to 255 (opaque). When drawing to
+ * screen, the actual color may be adjusted to the best match of hardware
+ * capabilities.
+ *
+ * @param red the red component of the RGB value
+ * @param green the green component of the RGB value
+ * @param blue the blue component of the RGB value
+ * @throws IllegalArgumentException if the values are out of range 0-255
+ * @see #getRed()
+ * @see #getGreen()
+ * @see #getBlue()
+ * @see #getRGB()
+ * @see #Color(int, int, int, int)
+ */
+ public Color(int red, int green, int blue)
+ {
+ this(red, green, blue, 255);
+ }
+
+ /**
+ * Initializes a new instance of <code>Color</code> using the specified
+ * red, green, blue, and alpha values, which must be given as integers in
+ * the range of 0-255. When drawing to screen, the actual color may be
+ * adjusted to the best match of hardware capabilities.
+ *
+ * @param red the red component of the RGB value
+ * @param green the green component of the RGB value
+ * @param blue the blue component of the RGB value
+ * @param alpha the alpha value of the color
+ * @throws IllegalArgumentException if the values are out of range 0-255
+ * @see #getRed()
+ * @see #getGreen()
+ * @see #getBlue()
+ * @see #getAlpha()
+ * @see #getRGB()
+ */
+ public Color(int red, int green, int blue, int alpha)
+ {
+ if ((red & 255) != red || (green & 255) != green || (blue & 255) != blue
+ || (alpha & 255) != alpha)
+ throw new IllegalArgumentException("Bad RGB values"
+ +" red=0x"+Integer.toHexString(red)
+ +" green=0x"+Integer.toHexString(green)
+ +" blue=0x"+Integer.toHexString(blue)
+ +" alpha=0x"+Integer.toHexString(alpha) );
+
+ value = (alpha << 24) | (red << 16) | (green << 8) | blue;
+ falpha = 1;
+ cs = null;
+ }
+
+ /**
+ * Initializes a new instance of <code>Color</code> using the specified
+ * RGB value. The blue value is in bits 0-7, green in bits 8-15, and
+ * red in bits 16-23. The other bits are ignored. The alpha value is set
+ * to 255 (opaque). When drawing to screen, the actual color may be
+ * adjusted to the best match of hardware capabilities.
+ *
+ * @param value the RGB value
+ * @see ColorModel#getRGBdefault()
+ * @see #getRed()
+ * @see #getGreen()
+ * @see #getBlue()
+ * @see #getRGB()
+ * @see #Color(int, boolean)
+ */
+ public Color(int value)
+ {
+ this(value, false);
+ }
+
+ /**
+ * Initializes a new instance of <code>Color</code> using the specified
+ * RGB value. The blue value is in bits 0-7, green in bits 8-15, and
+ * red in bits 16-23. The alpha value is in bits 24-31, unless hasalpha
+ * is false, in which case alpha is set to 255. When drawing to screen, the
+ * actual color may be adjusted to the best match of hardware capabilities.
+ *
+ * @param value the RGB value
+ * @param hasalpha true if value includes the alpha
+ * @see ColorModel#getRGBdefault()
+ * @see #getRed()
+ * @see #getGreen()
+ * @see #getBlue()
+ * @see #getAlpha()
+ * @see #getRGB()
+ */
+ public Color(int value, boolean hasalpha)
+ {
+ // Note: SystemColor calls this constructor, setting falpha to 0; but
+ // code in getRGBComponents correctly reports falpha as 1.0 to the user
+ // for all instances of SystemColor since frgbvalue is left null here.
+ if (hasalpha)
+ falpha = ((value & ALPHA_MASK) >> 24) / 255f;
+ else
+ {
+ value |= ALPHA_MASK;
+ falpha = 1;
+ }
+ this.value = value;
+ cs = null;
+ }
+
+ /**
+ * Initializes a new instance of <code>Color</code> using the specified
+ * RGB values. These must be in the range of 0.0-1.0. Alpha is assigned
+ * the value of 1.0 (opaque). When drawing to screen, the actual color may
+ * be adjusted to the best match of hardware capabilities.
+ *
+ * @param red the red component of the RGB value
+ * @param green the green component of the RGB value
+ * @param blue the blue component of the RGB value
+ * @throws IllegalArgumentException tf the values are out of range 0.0f-1.0f
+ * @see #getRed()
+ * @see #getGreen()
+ * @see #getBlue()
+ * @see #getRGB()
+ * @see #Color(float, float, float, float)
+ */
+ public Color(float red, float green, float blue)
+ {
+ this(red, green, blue, 1.0f);
+ }
+
+ /**
+ * Initializes a new instance of <code>Color</code> using the specified
+ * RGB and alpha values. These must be in the range of 0.0-1.0. When drawing
+ * to screen, the actual color may be adjusted to the best match of
+ * hardware capabilities.
+ *
+ * @param red the red component of the RGB value
+ * @param green the green component of the RGB value
+ * @param blue the blue component of the RGB value
+ * @param alpha the alpha value of the color
+ * @throws IllegalArgumentException tf the values are out of range 0.0f-1.0f
+ * @see #getRed()
+ * @see #getGreen()
+ * @see #getBlue()
+ * @see #getAlpha()
+ * @see #getRGB()
+ */
+ public Color(float red, float green, float blue, float alpha)
+ {
+ value = convert(red, green, blue, alpha);
+ frgbvalue = new float[] {red, green, blue};
+ falpha = alpha;
+ cs = null;
+ }
+
+ /**
+ * Creates a color in the given ColorSpace with the specified alpha. The
+ * array must be non-null and have enough elements for the color space
+ * (for example, RGB requires 3 elements, CMYK requires 4). When drawing
+ * to screen, the actual color may be adjusted to the best match of
+ * hardware capabilities.
+ *
+ * @param space the color space of components
+ * @param components the color components, except alpha
+ * @param alpha the alpha value of the color
+ * @throws NullPointerException if cpsace or components is null
+ * @throws ArrayIndexOutOfBoundsException if components is too small
+ * @throws IllegalArgumentException if alpha or any component is out of range
+ * @see #getComponents(float[])
+ * @see #getColorComponents(float[])
+ */
+ public Color(ColorSpace space, float[] components, float alpha)
+ {
+ frgbvalue = space.toRGB(components);
+ fvalue = components;
+ falpha = alpha;
+ cs = space;
+ value = convert(frgbvalue[0], frgbvalue[1], frgbvalue[2], alpha);
+ }
+
+ /**
+ * Returns the red value for this color, as an integer in the range 0-255
+ * in the sRGB color space.
+ *
+ * @return the red value for this color
+ * @see #getRGB()
+ */
+ public int getRed()
+ {
+ // Do not inline getRGB() to value, because of SystemColor.
+ return (getRGB() & RED_MASK) >> 16;
+ }
+
+ /**
+ * Returns the green value for this color, as an integer in the range 0-255
+ * in the sRGB color space.
+ *
+ * @return the green value for this color
+ * @see #getRGB()
+ */
+ public int getGreen()
+ {
+ // Do not inline getRGB() to value, because of SystemColor.
+ return (getRGB() & GREEN_MASK) >> 8;
+ }
+
+ /**
+ * Returns the blue value for this color, as an integer in the range 0-255
+ * in the sRGB color space.
+ *
+ * @return the blue value for this color
+ * @see #getRGB()
+ */
+ public int getBlue()
+ {
+ // Do not inline getRGB() to value, because of SystemColor.
+ return getRGB() & BLUE_MASK;
+ }
+
+ /**
+ * Returns the alpha value for this color, as an integer in the range 0-255.
+ *
+ * @return the alpha value for this color
+ * @see #getRGB()
+ */
+ public int getAlpha()
+ {
+ // Do not inline getRGB() to value, because of SystemColor.
+ return (getRGB() & ALPHA_MASK) >>> 24;
+ }
+
+ /**
+ * Returns the RGB value for this color, in the sRGB color space. The blue
+ * value will be in bits 0-7, green in 8-15, red in 16-23, and alpha value in
+ * 24-31.
+ *
+ * @return the RGB value for this color
+ * @see ColorModel#getRGBdefault()
+ * @see #getRed()
+ * @see #getGreen()
+ * @see #getBlue()
+ * @see #getAlpha()
+ */
+ public int getRGB()
+ {
+ return value;
+ }
+
+ /**
+ * Returns a brighter version of this color. This is done by increasing the
+ * RGB values by an arbitrary scale factor. The new color is opaque (an
+ * alpha of 255). Note that this method and the <code>darker()</code>
+ * method are not necessarily inverses.
+ *
+ * @return a brighter version of this color
+ * @see #darker()
+ */
+ public Color brighter()
+ {
+ // Do not inline getRGB() to this.value, because of SystemColor.
+ int value = getRGB();
+ int red = (value & RED_MASK) >> 16;
+ int green = (value & GREEN_MASK) >> 8;
+ int blue = value & BLUE_MASK;
+ // We have to special case 0-2 because they won't scale by division.
+ red = red < 3 ? 3 : (int) Math.min(255, red / BRIGHT_SCALE);
+ green = green < 3 ? 3 : (int) Math.min(255, green / BRIGHT_SCALE);
+ blue = blue < 3 ? 3 : (int) Math.min(255, blue / BRIGHT_SCALE);
+ return new Color(red, green, blue, 255);
+ }
+
+ /**
+ * Returns a darker version of this color. This is done by decreasing the
+ * RGB values by an arbitrary scale factor. The new color is opaque (an
+ * alpha of 255). Note that this method and the <code>brighter()</code>
+ * method are not necessarily inverses.
+ *
+ * @return a darker version of this color
+ * @see #brighter()
+ */
+ public Color darker()
+ {
+ // Do not inline getRGB() to this.value, because of SystemColor.
+ int value = getRGB();
+ return new Color((int) (((value & RED_MASK) >> 16) * BRIGHT_SCALE),
+ (int) (((value & GREEN_MASK) >> 8) * BRIGHT_SCALE),
+ (int) ((value & BLUE_MASK) * BRIGHT_SCALE), 255);
+ }
+
+ /**
+ * Returns a hash value for this color. This is simply the color in 8-bit
+ * precision, in the format 0xAARRGGBB (alpha, red, green, blue).
+ *
+ * @return a hash value for this color
+ */
+ public int hashCode()
+ {
+ return value;
+ }
+
+ /**
+ * Tests this object for equality against the specified object. This will
+ * be true if and only if the specified object is an instance of
+ * <code>Color</code> and has the same 8-bit integer red, green, and blue
+ * values as this object. Note that two colors may be slightly different
+ * as float values, but round to the same integer values. Also note that
+ * this does not accurately compare SystemColors, since that class does
+ * not store its internal data in RGB format like regular colors.
+ *
+ * @param obj the object to compare to
+ * @return true if the specified object is semantically equal to this one
+ */
+ public boolean equals(Object obj)
+ {
+ return obj instanceof Color && ((Color) obj).value == value;
+ }
+
+ /**
+ * Returns a string representation of this object. Subclasses may return
+ * any desired format, except for null, but this implementation returns
+ * <code>getClass().getName() + "[r=" + getRed() + ",g=" + getGreen()
+ * + ",b=" + getBlue() + ']'</code>.
+ *
+ * @return a string representation of this object
+ */
+ public String toString()
+ {
+ return getClass().getName() + "[r=" + ((value & RED_MASK) >> 16)
+ + ",g=" + ((value & GREEN_MASK) >> 8) + ",b=" + (value & BLUE_MASK)
+ + ']';
+ }
+
+ /**
+ * Converts the specified string to a number, using Integer.decode, and
+ * creates a new instance of <code>Color</code> from the value. The alpha
+ * value will be 255 (opaque).
+ *
+ * @param str the numeric color string
+ * @return a new instance of <code>Color</code> for the string
+ * @throws NumberFormatException if the string cannot be parsed
+ * @throws NullPointerException if the string is null
+ * @see Integer#decode(String)
+ * @see #Color(int)
+ * @since 1.1
+ */
+ public static Color decode(String str)
+ {
+ return new Color(Integer.decode(str).intValue(), false);
+ }
+
+ /**
+ * Returns a new instance of <code>Color</code> from the value of the
+ * system property named by the specified string. If the property does not
+ * exist, or cannot be parsed, then <code>null</code> will be returned.
+ *
+ * @param prop the system property to retrieve
+ * @throws SecurityException if getting the property is denied
+ * @see #getColor(String, Color)
+ * @see Integer#getInteger(String)
+ */
+ public static Color getColor(String prop)
+ {
+ return getColor(prop, null);
+ }
+
+ /**
+ * Returns a new instance of <code>Color</code> from the value of the
+ * system property named by the specified string. If the property does
+ * not exist, or cannot be parsed, then the default color value will be
+ * returned.
+ *
+ * @param prop the system property to retrieve
+ * @param defcolor the default color
+ * @throws SecurityException if getting the property is denied
+ * @see Integer#getInteger(String)
+ */
+ public static Color getColor(String prop, Color defcolor)
+ {
+ Integer val = Integer.getInteger(prop, null);
+ return val == null ? defcolor
+ : new Color(val.intValue(), false);
+ }
+
+ /**
+ * Returns a new instance of <code>Color</code> from the value of the
+ * system property named by the specified string. If the property does
+ * not exist, or cannot be parsed, then the default RGB value will be
+ * used to create a return value.
+ *
+ * @param prop the system property to retrieve
+ * @param defrgb the default RGB value
+ * @throws SecurityException if getting the property is denied
+ * @see #getColor(String, Color)
+ * @see Integer#getInteger(String, int)
+ */
+ public static Color getColor(String prop, int defrgb)
+ {
+ Color c = getColor(prop, null);
+ return c == null ? new Color(defrgb, false) : c;
+ }
+
+ /**
+ * Converts from the HSB (hue, saturation, brightness) color model to the
+ * RGB (red, green, blue) color model. The hue may be any floating point;
+ * it's fractional portion is used to select the angle in the HSB model.
+ * The saturation and brightness must be between 0 and 1. The result is
+ * suitable for creating an RGB color with the one-argument constructor.
+ *
+ * @param hue the hue of the HSB value
+ * @param saturation the saturation of the HSB value
+ * @param brightness the brightness of the HSB value
+ * @return the RGB value
+ * @see #getRGB()
+ * @see #Color(int)
+ * @see ColorModel#getRGBdefault()
+ */
+ public static int HSBtoRGB(float hue, float saturation, float brightness)
+ {
+ if (saturation == 0)
+ return convert(brightness, brightness, brightness, 0);
+ if (saturation < 0 || saturation > 1 || brightness < 0 || brightness > 1)
+ throw new IllegalArgumentException();
+ hue = hue - (float) Math.floor(hue);
+ int i = (int) (6 * hue);
+ float f = 6 * hue - i;
+ float p = brightness * (1 - saturation);
+ float q = brightness * (1 - saturation * f);
+ float t = brightness * (1 - saturation * (1 - f));
+ switch (i)
+ {
+ case 0:
+ return convert(brightness, t, p, 0);
+ case 1:
+ return convert(q, brightness, p, 0);
+ case 2:
+ return convert(p, brightness, t, 0);
+ case 3:
+ return convert(p, q, brightness, 0);
+ case 4:
+ return convert(t, p, brightness, 0);
+ case 5:
+ return convert(brightness, p, q, 0);
+ default:
+ throw new InternalError("impossible");
+ }
+ }
+
+ /**
+ * Converts from the RGB (red, green, blue) color model to the HSB (hue,
+ * saturation, brightness) color model. If the array is null, a new one
+ * is created, otherwise it is recycled. The results will be in the range
+ * 0.0-1.0 if the inputs are in the range 0-255.
+ *
+ * @param red the red part of the RGB value
+ * @param green the green part of the RGB value
+ * @param blue the blue part of the RGB value
+ * @param array an array for the result (at least 3 elements), or null
+ * @return the array containing HSB value
+ * @throws ArrayIndexOutOfBoundsException of array is too small
+ * @see #getRGB()
+ * @see #Color(int)
+ * @see ColorModel#getRGBdefault()
+ */
+ public static float[] RGBtoHSB(int red, int green, int blue, float array[])
+ {
+ if (array == null)
+ array = new float[3];
+ // Calculate brightness.
+ int min;
+ int max;
+ if (red < green)
+ {
+ min = red;
+ max = green;
+ }
+ else
+ {
+ min = green;
+ max = red;
+ }
+ if (blue > max)
+ max = blue;
+ else if (blue < min)
+ min = blue;
+ array[2] = max / 255f;
+ // Calculate saturation.
+ if (max == 0)
+ array[1] = 0;
+ else
+ array[1] = ((float) (max - min)) / ((float) max);
+ // Calculate hue.
+ if (array[1] == 0)
+ array[0] = 0;
+ else
+ {
+ float delta = (max - min) * 6;
+ if (red == max)
+ array[0] = (green - blue) / delta;
+ else if (green == max)
+ array[0] = 1f / 3 + (blue - red) / delta;
+ else
+ array[0] = 2f / 3 + (red - green) / delta;
+ if (array[0] < 0)
+ array[0]++;
+ }
+ return array;
+ }
+
+ /**
+ * Returns a new instance of <code>Color</code> based on the specified
+ * HSB values. The hue may be any floating point; it's fractional portion
+ * is used to select the angle in the HSB model. The saturation and
+ * brightness must be between 0 and 1.
+ *
+ * @param hue the hue of the HSB value
+ * @param saturation the saturation of the HSB value
+ * @param brightness the brightness of the HSB value
+ * @return the new <code>Color</code> object
+ */
+ public static Color getHSBColor(float hue, float saturation,
+ float brightness)
+ {
+ return new Color(HSBtoRGB(hue, saturation, brightness), false);
+ }
+
+ /**
+ * Returns a float array with the red, green, and blue components, and the
+ * alpha value, in the default sRGB space, with values in the range 0.0-1.0.
+ * If the array is null, a new one is created, otherwise it is recycled.
+ *
+ * @param array the array to put results into (at least 4 elements), or null
+ * @return the RGB components and alpha value
+ * @throws ArrayIndexOutOfBoundsException if array is too small
+ */
+ public float[] getRGBComponents(float[] array)
+ {
+ if (array == null)
+ array = new float[4];
+ getRGBColorComponents(array);
+ // Stupid serialization issues require this check.
+ array[3] = (falpha == 0 && frgbvalue == null
+ ? ((getRGB() & ALPHA_MASK) >> 24) / 255f : falpha);
+ return array;
+ }
+
+ /**
+ * Returns a float array with the red, green, and blue components, in the
+ * default sRGB space, with values in the range 0.0-1.0. If the array is
+ * null, a new one is created, otherwise it is recycled.
+ *
+ * @param array the array to put results into (at least 3 elements), or null
+ * @return the RGB components
+ * @throws ArrayIndexOutOfBoundsException if array is too small
+ */
+ public float[] getRGBColorComponents(float[] array)
+ {
+ if (array == null)
+ array = new float[3];
+ else if (array == frgbvalue)
+ return array; // Optimization for getColorComponents(float[]).
+ if (frgbvalue == null)
+ {
+ // Do not inline getRGB() to this.value, because of SystemColor.
+ int value = getRGB();
+ frgbvalue = new float[] { ((value & RED_MASK) >> 16) / 255f,
+ ((value & GREEN_MASK) >> 8) / 255f,
+ (value & BLUE_MASK) / 255f };
+ }
+ array[0] = frgbvalue[0];
+ array[1] = frgbvalue[1];
+ array[2] = frgbvalue[2];
+ return array;
+ }
+
+ /**
+ * Returns a float array containing the color and alpha components of this
+ * color in the ColorSpace it was created with (the constructors which do
+ * not take a ColorSpace parameter use a default sRGB ColorSpace). If the
+ * array is null, a new one is created, otherwise it is recycled, and must
+ * have at least one more position than components used in the color space.
+ *
+ * @param array the array to put results into, or null
+ * @return the original color space components and alpha value
+ * @throws ArrayIndexOutOfBoundsException if array is too small
+ */
+ public float[] getComponents(float[] array)
+ {
+ int numComponents = cs == null ? 3 : cs.getNumComponents();
+ if (array == null)
+ array = new float[1 + numComponents];
+ getColorComponents(array);
+ // Stupid serialization issues require this check.
+ array[numComponents] = (falpha == 0 && frgbvalue == null
+ ? ((getRGB() & ALPHA_MASK) >> 24) / 255f : falpha);
+ return array;
+ }
+
+ /**
+ * Returns a float array containing the color components of this color in
+ * the ColorSpace it was created with (the constructors which do not take
+ * a ColorSpace parameter use a default sRGB ColorSpace). If the array is
+ * null, a new one is created, otherwise it is recycled, and must have at
+ * least as many positions as used in the color space.
+ *
+ * @param array the array to put results into, or null
+ * @return the original color space components
+ * @throws ArrayIndexOutOfBoundsException if array is too small
+ */
+ public float[] getColorComponents(float[] array)
+ {
+ int numComponents = cs == null ? 3 : cs.getNumComponents();
+ if (array == null)
+ array = new float[numComponents];
+ if (fvalue == null) // If fvalue is null, cs should be null too.
+ fvalue = getRGBColorComponents(frgbvalue);
+ System.arraycopy(fvalue, 0, array, 0, numComponents);
+ return array;
+ }
+
+ /**
+ * Returns a float array containing the color and alpha components of this
+ * color in the given ColorSpace. If the array is null, a new one is
+ * created, otherwise it is recycled, and must have at least one more
+ * position than components used in the color space.
+ *
+ * @param space the color space to translate to
+ * @param array the array to put results into, or null
+ * @return the color space components and alpha value
+ * @throws ArrayIndexOutOfBoundsException if array is too small
+ * @throws NullPointerException if space is null
+ */
+ public float[] getComponents(ColorSpace space, float[] array)
+ {
+ int numComponents = space.getNumComponents();
+ if (array == null)
+ array = new float[1 + numComponents];
+ getColorComponents(space, array);
+ // Stupid serialization issues require this check.
+ array[numComponents] = (falpha == 0 && frgbvalue == null
+ ? ((getRGB() & ALPHA_MASK) >> 24) / 255f : falpha);
+ return array;
+ }
+
+ /**
+ * Returns a float array containing the color components of this color in
+ * the given ColorSpace. If the array is null, a new one is created,
+ * otherwise it is recycled, and must have at least as many positions as
+ * used in the color space.
+ *
+ * @param space the color space to translate to
+ * @return the color space components
+ * @throws ArrayIndexOutOfBoundsException if array is too small
+ * @throws NullPointerException if space is null
+ */
+ public float[] getColorComponents(ColorSpace space, float[] array)
+ {
+ float[] components = space.fromRGB(getRGBColorComponents(frgbvalue));
+ if (array == null)
+ return components;
+ System.arraycopy(components, 0, array, 0, components.length);
+ return array;
+ }
+
+ /**
+ * Returns the color space of this color. Except for the constructor which
+ * takes a ColorSpace argument, this will be an implementation of
+ * ColorSpace.CS_sRGB.
+ *
+ * @return the color space
+ */
+ public ColorSpace getColorSpace()
+ {
+ return cs == null ? ColorSpace.getInstance(ColorSpace.CS_sRGB) : cs;
+ }
+
+ /**
+ * Returns a paint context, used for filling areas of a raster scan with
+ * this color. Since the color is constant across the entire rectangle, and
+ * since it is always in sRGB space, this implementation returns the same
+ * object, regardless of the parameters. Subclasses, however, may have a
+ * mutable result.
+ *
+ * @param cm the requested color model
+ * @param deviceBounds the bounding box in device coordinates, ignored
+ * @param userBounds the bounding box in user coordinates, ignored
+ * @param xform the bounds transformation, ignored
+ * @param hints any rendering hints, ignored
+ * @return a context for painting this solid color
+ */
+ public PaintContext createContext(ColorModel cm, Rectangle deviceBounds,
+ Rectangle2D userBounds,
+ AffineTransform xform,
+ RenderingHints hints)
+ {
+ if (context == null || !context.getColorModel().equals(cm))
+ context = new ColorPaintContext(cm,value);
+ return context;
+ }
+
+ /**
+ * Returns the transparency level of this color.
+ *
+ * @return one of {@link #OPAQUE}, {@link #BITMASK}, or {@link #TRANSLUCENT}
+ */
+ public int getTransparency()
+ {
+ // Do not inline getRGB() to this.value, because of SystemColor.
+ int alpha = getRGB() & ALPHA_MASK;
+ return alpha == (255 << 24) ? OPAQUE : alpha == 0 ? BITMASK : TRANSLUCENT;
+ }
+
+ /**
+ * Converts float values to integer value.
+ *
+ * @param red the red value
+ * @param green the green value
+ * @param blue the blue value
+ * @param alpha the alpha value
+ * @return the integer value made of 8-bit sections
+ * @throws IllegalArgumentException if parameters are out of range 0.0-1.0
+ */
+ private static int convert(float red, float green, float blue, float alpha)
+ {
+ if (red < 0 || red > 1 || green < 0 || green > 1 || blue < 0 || blue > 1
+ || alpha < 0 || alpha > 1)
+ throw new IllegalArgumentException("Bad RGB values");
+ int redval = Math.round(255 * red);
+ int greenval = Math.round(255 * green);
+ int blueval = Math.round(255 * blue);
+ int alphaval = Math.round(255 * alpha);
+ return (alphaval << 24) | (redval << 16) | (greenval << 8) | blueval;
+ }
+} // class Color
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ColorPaintContext.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ColorPaintContext.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ColorPaintContext.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ColorPaintContext.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,195 @@
+/* ColorPaintContext.java -- context for painting solid colors
+ Copyright (C) 2002, 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.image.ColorModel;
+import java.awt.image.Raster;
+
+/**
+ * This class provides a paint context which will fill a rectanglar region of
+ * a raster scan with the given color. However, it is not yet completely
+ * implemented.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ */
+class ColorPaintContext implements PaintContext
+{
+ /**
+ * The color to fill any raster with. Package visible for use in
+ * SystemColor.
+ */
+ final int color;
+ final ColorModel colorModel;
+
+ private ColorRaster cachedRaster;
+
+
+ /**
+ * Create the context for a given color.
+ *
+ * @param colorRGB The solid color to use.
+ */
+ ColorPaintContext(int colorRGB)
+ {
+ this(ColorModel.getRGBdefault(), colorRGB);
+ }
+
+ /**
+ * Create the context for a given color.
+ *
+ * @param cm The color model of this context.
+ * @param colorRGB The solid color to use.
+ */
+ ColorPaintContext(ColorModel cm,int colorRGB)
+ {
+ color = colorRGB;
+ colorModel = cm;
+ }
+
+ /**
+ * Release the resources allocated for the paint. As the color is constant,
+ * there aren't any resources.
+ */
+ public void dispose()
+ {
+ }
+
+ /**
+ * Return the color model of this context.
+ *
+ * @return the context color model
+ */
+ public ColorModel getColorModel()
+ {
+ return colorModel;
+ }
+
+ /**
+ * Return a raster containing the colors for the graphics operation.
+ *
+ * @param x the x-coordinate, in device space
+ * @param y the y-coordinate, in device space
+ * @param width the width, in device space
+ * @param height the height, in device space
+ * @return a raster for the given area and color
+ */
+ public Raster getRaster(int x, int y, int width, int height)
+ {
+ if( cachedRaster == null
+ || cachedRaster.getWidth() < width
+ || cachedRaster.getHeight() < height)
+ {
+ cachedRaster = new ColorRaster(colorModel, 0, 0, width, height, color);
+ }
+ return cachedRaster.createChild(0 ,0 ,width ,height ,0 ,0 , null);
+ }
+
+ /**
+ * A ColorRaster is a raster that is completely filled with one color. The
+ * data layout is taken from the color model given to the constructor.
+ */
+ private class ColorRaster extends Raster
+ {
+
+ /**
+ * Create a raster that is compaltible with the given color model and
+ * filled with the given color.
+ * @param cm The color model for this raster.
+ * @param x The smallest horizontal corrdinate in the raster.
+ * @param y The smallest vertical coordinate in the raster.
+ * @param width The width of the raster.
+ * @param height The height of the raster.
+ * @param rgbPixel The RGB value of the color for this raster.
+ */
+ ColorRaster(ColorModel cm,int x, int y, int width, int height, int rgbPixel)
+ {
+ super(cm.createCompatibleSampleModel(width,height),new Point(x,y));
+ Object pixel = cm.getDataElements(rgbPixel,null);
+ int[] pixelComps = cm.getComponents(pixel, null, 0);
+ int[] d = (int[]) multiplyData(pixelComps,null,width*height);
+ getSampleModel().setPixels(0, 0, width, height, d,
+ dataBuffer);
+ }
+
+
+
+ private Object multiplyData(Object src, Object dest, int factor)
+ {
+ Object from;
+ int srcLength = 0;
+ if (src instanceof byte[])
+ {
+ srcLength = ((byte[])src).length;
+
+ if (dest == null) dest = new byte[factor * srcLength];
+ }
+ else if (src instanceof short[])
+ {
+ srcLength = ((short[])src).length;
+ if (dest == null) dest = new short[factor * srcLength];
+ }
+ else if (src instanceof int[])
+ {
+ srcLength = ((int[]) src).length;
+ if (dest == null) dest = new int[factor * srcLength];
+ }
+ else
+ {
+ throw new ClassCastException("Unknown data buffer type");
+ }
+
+ System.arraycopy(src,0,dest,0,srcLength);
+
+ int count = 1;
+ while(count*2 < factor)
+ {
+ System.arraycopy(dest, 0, dest, count * srcLength, count*srcLength);
+ count *= 2;
+ }
+
+ if(factor > count)
+ System.arraycopy(dest,0, dest, count * srcLength,
+ (factor - count) * srcLength );
+
+ return dest;
+ }
+
+ }
+
+} // class ColorPaintContext
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Component.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Component.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Component.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Component.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,6739 @@
+/* Component.java -- a graphics component
+ Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2006
+ Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.dnd.DropTarget;
+import java.awt.event.ActionEvent;
+import java.awt.event.AdjustmentEvent;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.HierarchyBoundsListener;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
+import java.awt.event.InputEvent;
+import java.awt.event.InputMethodEvent;
+import java.awt.event.InputMethodListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
+import java.awt.event.PaintEvent;
+import java.awt.event.WindowEvent;
+import java.awt.im.InputContext;
+import java.awt.im.InputMethodRequests;
+import java.awt.image.BufferStrategy;
+import java.awt.image.ColorModel;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.image.VolatileImage;
+import java.awt.peer.ComponentPeer;
+import java.awt.peer.LightweightPeer;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.util.Collections;
+import java.util.EventListener;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleComponent;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
+
+/**
+ * The root of all evil. All graphical representations are subclasses of this
+ * giant class, which is designed for screen display and user interaction.
+ * This class can be extended directly to build a lightweight component (one
+ * not associated with a native window); lightweight components must reside
+ * inside a heavyweight window.
+ *
+ * <p>This class is Serializable, which has some big implications. A user can
+ * save the state of all graphical components in one VM, and reload them in
+ * another. Note that this class will only save Serializable listeners, and
+ * ignore the rest, without causing any serialization exceptions. However, by
+ * making a listener serializable, and adding it to another element, you link
+ * in that entire element to the state of this component. To get around this,
+ * use the idiom shown in the example below - make listeners non-serializable
+ * in inner classes, rather than using this object itself as the listener, if
+ * external objects do not need to save the state of this object.
+ *
+ * <pre>
+ * import java.awt.*;
+ * import java.awt.event.*;
+ * import java.io.Serializable;
+ * class MyApp implements Serializable
+ * {
+ * BigObjectThatShouldNotBeSerializedWithAButton bigOne;
+ * // Serializing aButton will not suck in an instance of MyApp, with its
+ * // accompanying field bigOne.
+ * Button aButton = new Button();
+ * class MyActionListener implements ActionListener
+ * {
+ * public void actionPerformed(ActionEvent e)
+ * {
+ * System.out.println("Hello There");
+ * }
+ * }
+ * MyApp()
+ * {
+ * aButton.addActionListener(new MyActionListener());
+ * }
+ * }
+ * </pre>
+ *
+ * <p>Status: Incomplete. The event dispatch mechanism is implemented. All
+ * other methods defined in the J2SE 1.3 API javadoc exist, but are mostly
+ * incomplete or only stubs; except for methods relating to the Drag and
+ * Drop, Input Method, and Accessibility frameworks: These methods are
+ * present but commented out.
+ *
+ * @author original author unknown
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.0
+ * @status still missing 1.4 support
+ */
+public abstract class Component
+ implements ImageObserver, MenuContainer, Serializable
+{
+ // Word to the wise - this file is huge. Search for '\f' (^L) for logical
+ // sectioning by fields, public API, private API, and nested classes.
+
+
+ /**
+ * Compatible with JDK 1.0+.
+ */
+ private static final long serialVersionUID = -7644114512714619750L;
+
+ /**
+ * Constant returned by the <code>getAlignmentY</code> method to indicate
+ * that the component wishes to be aligned to the top relative to
+ * other components.
+ *
+ * @see #getAlignmentY()
+ */
+ public static final float TOP_ALIGNMENT = 0;
+
+ /**
+ * Constant returned by the <code>getAlignmentY</code> and
+ * <code>getAlignmentX</code> methods to indicate
+ * that the component wishes to be aligned to the center relative to
+ * other components.
+ *
+ * @see #getAlignmentX()
+ * @see #getAlignmentY()
+ */
+ public static final float CENTER_ALIGNMENT = 0.5f;
+
+ /**
+ * Constant returned by the <code>getAlignmentY</code> method to indicate
+ * that the component wishes to be aligned to the bottom relative to
+ * other components.
+ *
+ * @see #getAlignmentY()
+ */
+ public static final float BOTTOM_ALIGNMENT = 1;
+
+ /**
+ * Constant returned by the <code>getAlignmentX</code> method to indicate
+ * that the component wishes to be aligned to the right relative to
+ * other components.
+ *
+ * @see #getAlignmentX()
+ */
+ public static final float RIGHT_ALIGNMENT = 1;
+
+ /**
+ * Constant returned by the <code>getAlignmentX</code> method to indicate
+ * that the component wishes to be aligned to the left relative to
+ * other components.
+ *
+ * @see #getAlignmentX()
+ */
+ public static final float LEFT_ALIGNMENT = 0;
+
+ /**
+ * Make the treelock a String so that it can easily be identified
+ * in debug dumps. We clone the String in order to avoid a conflict in
+ * the unlikely event that some other package uses exactly the same string
+ * as a lock object.
+ */
+ static final Object treeLock = new String("AWT_TREE_LOCK");
+
+ /**
+ * The default maximum size.
+ */
+ private static final Dimension DEFAULT_MAX_SIZE
+ = new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
+
+ // Serialized fields from the serialization spec.
+
+ /**
+ * The x position of the component in the parent's coordinate system.
+ *
+ * @see #getLocation()
+ * @serial the x position
+ */
+ int x;
+
+ /**
+ * The y position of the component in the parent's coordinate system.
+ *
+ * @see #getLocation()
+ * @serial the y position
+ */
+ int y;
+
+ /**
+ * The component width.
+ *
+ * @see #getSize()
+ * @serial the width
+ */
+ int width;
+
+ /**
+ * The component height.
+ *
+ * @see #getSize()
+ * @serial the height
+ */
+ int height;
+
+ /**
+ * The foreground color for the component. This may be null.
+ *
+ * @see #getForeground()
+ * @see #setForeground(Color)
+ * @serial the foreground color
+ */
+ Color foreground;
+
+ /**
+ * The background color for the component. This may be null.
+ *
+ * @see #getBackground()
+ * @see #setBackground(Color)
+ * @serial the background color
+ */
+ Color background;
+
+ /**
+ * The default font used in the component. This may be null.
+ *
+ * @see #getFont()
+ * @see #setFont(Font)
+ * @serial the font
+ */
+ Font font;
+
+ /**
+ * The font in use by the peer, or null if there is no peer.
+ *
+ * @serial the peer's font
+ */
+ Font peerFont;
+
+ /**
+ * The cursor displayed when the pointer is over this component. This may
+ * be null.
+ *
+ * @see #getCursor()
+ * @see #setCursor(Cursor)
+ */
+ Cursor cursor;
+
+ /**
+ * The locale for the component.
+ *
+ * @see #getLocale()
+ * @see #setLocale(Locale)
+ */
+ Locale locale = Locale.getDefault ();
+
+ /**
+ * True if the object should ignore repaint events (usually because it is
+ * not showing).
+ *
+ * @see #getIgnoreRepaint()
+ * @see #setIgnoreRepaint(boolean)
+ * @serial true to ignore repaints
+ * @since 1.4
+ */
+ boolean ignoreRepaint;
+
+ /**
+ * True when the object is visible (although it is only showing if all
+ * ancestors are likewise visible). For component, this defaults to true.
+ *
+ * @see #isVisible()
+ * @see #setVisible(boolean)
+ * @serial true if visible
+ */
+ boolean visible = true;
+
+ /**
+ * True if the object is enabled, meaning it can interact with the user.
+ * For component, this defaults to true.
+ *
+ * @see #isEnabled()
+ * @see #setEnabled(boolean)
+ * @serial true if enabled
+ */
+ boolean enabled = true;
+
+ /**
+ * True if the object is valid. This is set to false any time a size
+ * adjustment means the component need to be layed out again.
+ *
+ * @see #isValid()
+ * @see #validate()
+ * @see #invalidate()
+ * @serial true if layout is valid
+ */
+ boolean valid;
+
+ /**
+ * The DropTarget for drag-and-drop operations.
+ *
+ * @see #getDropTarget()
+ * @see #setDropTarget(DropTarget)
+ * @serial the drop target, or null
+ * @since 1.2
+ */
+ DropTarget dropTarget;
+
+ /**
+ * The list of popup menus for this component.
+ *
+ * @see #add(PopupMenu)
+ * @serial the list of popups
+ */
+ Vector popups;
+
+ /**
+ * The component's name. May be null, in which case a default name is
+ * generated on the first use.
+ *
+ * @see #getName()
+ * @see #setName(String)
+ * @serial the name
+ */
+ String name;
+
+ /**
+ * True once the user has set the name. Note that the user may set the name
+ * to null.
+ *
+ * @see #name
+ * @see #getName()
+ * @see #setName(String)
+ * @serial true if the name has been explicitly set
+ */
+ boolean nameExplicitlySet;
+
+ /**
+ * Indicates if the object can be focused. Defaults to true for components.
+ *
+ * @see #isFocusable()
+ * @see #setFocusable(boolean)
+ * @since 1.4
+ */
+ boolean focusable = true;
+
+ /**
+ * Tracks whether this component's {@link #isFocusTraversable}
+ * method has been overridden.
+ *
+ * @since 1.4
+ */
+ int isFocusTraversableOverridden;
+
+ /**
+ * The focus traversal keys, if not inherited from the parent or
+ * default keyboard focus manager. These sets will contain only
+ * AWTKeyStrokes that represent press and release events to use as
+ * focus control.
+ *
+ * @see #getFocusTraversalKeys(int)
+ * @see #setFocusTraversalKeys(int, Set)
+ * @since 1.4
+ */
+ Set[] focusTraversalKeys;
+
+ /**
+ * True if focus traversal keys are enabled. This defaults to true for
+ * Component. If this is true, keystrokes in focusTraversalKeys are trapped
+ * and processed automatically rather than being passed on to the component.
+ *
+ * @see #getFocusTraversalKeysEnabled()
+ * @see #setFocusTraversalKeysEnabled(boolean)
+ * @since 1.4
+ */
+ boolean focusTraversalKeysEnabled = true;
+
+ /**
+ * Cached information on the minimum size. Should have been transient.
+ *
+ * @serial ignore
+ */
+ Dimension minSize;
+
+ /**
+ * Flag indicating whether the minimum size for the component has been set
+ * by a call to {@link #setMinimumSize(Dimension)} with a non-null value.
+ */
+ boolean minSizeSet;
+
+ /**
+ * The maximum size for the component.
+ * @see #setMaximumSize(Dimension)
+ */
+ Dimension maxSize;
+
+ /**
+ * A flag indicating whether the maximum size for the component has been set
+ * by a call to {@link #setMaximumSize(Dimension)} with a non-null value.
+ */
+ boolean maxSizeSet;
+
+ /**
+ * Cached information on the preferred size. Should have been transient.
+ *
+ * @serial ignore
+ */
+ Dimension prefSize;
+
+ /**
+ * Flag indicating whether the preferred size for the component has been set
+ * by a call to {@link #setPreferredSize(Dimension)} with a non-null value.
+ */
+ boolean prefSizeSet;
+
+ /**
+ * Set to true if an event is to be handled by this component, false if
+ * it is to be passed up the hierarcy.
+ *
+ * @see #dispatchEvent(AWTEvent)
+ * @serial true to process event locally
+ */
+ boolean newEventsOnly;
+
+ /**
+ * Set by subclasses to enable event handling of particular events, and
+ * left alone when modifying listeners. For component, this defaults to
+ * enabling only input methods.
+ *
+ * @see #enableInputMethods(boolean)
+ * @see AWTEvent
+ * @serial the mask of events to process
+ */
+ long eventMask = AWTEvent.INPUT_ENABLED_EVENT_MASK;
+
+ /**
+ * Describes all registered PropertyChangeListeners.
+ *
+ * @see #addPropertyChangeListener(PropertyChangeListener)
+ * @see #removePropertyChangeListener(PropertyChangeListener)
+ * @see #firePropertyChange(String, Object, Object)
+ * @serial the property change listeners
+ * @since 1.2
+ */
+ PropertyChangeSupport changeSupport;
+
+ /**
+ * True if the component has been packed (layed out).
+ *
+ * @serial true if this is packed
+ */
+ boolean isPacked;
+
+ /**
+ * The serialization version for this class. Currently at version 4.
+ *
+ * XXX How do we handle prior versions?
+ *
+ * @serial the serialization version
+ */
+ int componentSerializedDataVersion = 4;
+
+ /**
+ * The accessible context associated with this component. This is only set
+ * by subclasses.
+ *
+ * @see #getAccessibleContext()
+ * @serial the accessibility context
+ * @since 1.2
+ */
+ AccessibleContext accessibleContext;
+
+
+ // Guess what - listeners are special cased in serialization. See
+ // readObject and writeObject.
+
+ /** Component listener chain. */
+ transient ComponentListener componentListener;
+
+ /** Focus listener chain. */
+ transient FocusListener focusListener;
+
+ /** Key listener chain. */
+ transient KeyListener keyListener;
+
+ /** Mouse listener chain. */
+ transient MouseListener mouseListener;
+
+ /** Mouse motion listener chain. */
+ transient MouseMotionListener mouseMotionListener;
+
+ /**
+ * Mouse wheel listener chain.
+ *
+ * @since 1.4
+ */
+ transient MouseWheelListener mouseWheelListener;
+
+ /**
+ * Input method listener chain.
+ *
+ * @since 1.2
+ */
+ transient InputMethodListener inputMethodListener;
+
+ /**
+ * Hierarcy listener chain.
+ *
+ * @since 1.3
+ */
+ transient HierarchyListener hierarchyListener;
+
+ /**
+ * Hierarcy bounds listener chain.
+ *
+ * @since 1.3
+ */
+ transient HierarchyBoundsListener hierarchyBoundsListener;
+
+ // Anything else is non-serializable, and should be declared "transient".
+
+ /** The parent. */
+ transient Container parent;
+
+ /** The associated native peer. */
+ transient ComponentPeer peer;
+
+ /** The preferred component orientation. */
+ transient ComponentOrientation orientation = ComponentOrientation.UNKNOWN;
+
+ /**
+ * The associated graphics configuration.
+ *
+ * @since 1.4
+ */
+ transient GraphicsConfiguration graphicsConfig;
+
+ /**
+ * The buffer strategy for repainting.
+ *
+ * @since 1.4
+ */
+ transient BufferStrategy bufferStrategy;
+
+ /**
+ * The number of hierarchy listeners of this container plus all of its
+ * children. This is needed for efficient handling of HierarchyEvents.
+ * These must be propagated to all child components with HierarchyListeners
+ * attached. To avoid traversal of the whole subtree, we keep track of
+ * the number of HierarchyListeners here and only walk the paths that
+ * actually have listeners.
+ */
+ int numHierarchyListeners;
+ int numHierarchyBoundsListeners;
+
+ /**
+ * true if requestFocus was called on this component when its
+ * top-level ancestor was not focusable.
+ */
+ private transient FocusEvent pendingFocusRequest = null;
+
+ /**
+ * The system properties that affect image updating.
+ */
+ private static transient boolean incrementalDraw;
+ private static transient Long redrawRate;
+
+ static
+ {
+ incrementalDraw = Boolean.getBoolean ("awt.image.incrementalDraw");
+ redrawRate = Long.getLong ("awt.image.redrawrate");
+ }
+
+ // Public and protected API.
+
+ /**
+ * Default constructor for subclasses. When Component is extended directly,
+ * it forms a lightweight component that must be hosted in an opaque native
+ * container higher in the tree.
+ */
+ protected Component()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the name of this component.
+ *
+ * @return the name of this component
+ * @see #setName(String)
+ * @since 1.1
+ */
+ public String getName()
+ {
+ if (name == null && ! nameExplicitlySet)
+ name = generateName();
+ return name;
+ }
+
+ /**
+ * Sets the name of this component to the specified name (this is a bound
+ * property with the name 'name').
+ *
+ * @param name the new name (<code>null</code> permitted).
+ * @see #getName()
+ * @since 1.1
+ */
+ public void setName(String name)
+ {
+ nameExplicitlySet = true;
+ String old = this.name;
+ this.name = name;
+ firePropertyChange("name", old, name);
+ }
+
+ /**
+ * Returns the parent of this component.
+ *
+ * @return the parent of this component
+ */
+ public Container getParent()
+ {
+ return parent;
+ }
+
+ /**
+ * Returns the native windowing system peer for this component. Only the
+ * platform specific implementation code should call this method.
+ *
+ * @return the peer for this component
+ * @deprecated user programs should not directly manipulate peers; use
+ * {@link #isDisplayable()} instead
+ */
+ // Classpath's Gtk peers rely on this.
+ public ComponentPeer getPeer()
+ {
+ return peer;
+ }
+
+ /**
+ * Set the associated drag-and-drop target, which receives events when this
+ * is enabled.
+ *
+ * @param dt the new drop target
+ * @see #isEnabled()
+ */
+ public void setDropTarget(DropTarget dt)
+ {
+ this.dropTarget = dt;
+ }
+
+ /**
+ * Gets the associated drag-and-drop target, if there is one.
+ *
+ * @return the drop target
+ */
+ public DropTarget getDropTarget()
+ {
+ return dropTarget;
+ }
+
+ /**
+ * Returns the graphics configuration of this component, if there is one.
+ * If it has not been set, it is inherited from the parent.
+ *
+ * @return the graphics configuration, or null
+ * @since 1.3
+ */
+ public GraphicsConfiguration getGraphicsConfiguration()
+ {
+ return getGraphicsConfigurationImpl();
+ }
+
+ /**
+ * Returns the object used for synchronization locks on this component
+ * when performing tree and layout functions.
+ *
+ * @return the synchronization lock for this component
+ */
+ public final Object getTreeLock()
+ {
+ return treeLock;
+ }
+
+ /**
+ * Returns the toolkit in use for this component. The toolkit is associated
+ * with the frame this component belongs to.
+ *
+ * @return the toolkit for this component
+ */
+ public Toolkit getToolkit()
+ {
+ if (peer != null)
+ {
+ Toolkit tk = peer.getToolkit();
+ if (tk != null)
+ return tk;
+ }
+ // Get toolkit for lightweight component.
+ if (parent != null)
+ return parent.getToolkit();
+ return Toolkit.getDefaultToolkit();
+ }
+
+ /**
+ * Tests whether or not this component is valid. A invalid component needs
+ * to have its layout redone.
+ *
+ * @return true if this component is valid
+ * @see #validate()
+ * @see #invalidate()
+ */
+ public boolean isValid()
+ {
+ // Tests show that components are invalid as long as they are not showing, even after validate()
+ // has been called on them.
+ return peer != null && valid;
+ }
+
+ /**
+ * Tests if the component is displayable. It must be connected to a native
+ * screen resource. This reduces to checking that peer is not null. A
+ * containment hierarchy is made displayable when a window is packed or
+ * made visible.
+ *
+ * @return true if the component is displayable
+ * @see Container#add(Component)
+ * @see Container#remove(Component)
+ * @see Window#pack()
+ * @see Window#show()
+ * @see Window#dispose()
+ * @since 1.2
+ */
+ public boolean isDisplayable()
+ {
+ return peer != null;
+ }
+
+ /**
+ * Tests whether or not this component is visible. Except for top-level
+ * frames, components are initially visible.
+ *
+ * @return true if the component is visible
+ * @see #setVisible(boolean)
+ */
+ public boolean isVisible()
+ {
+ return visible;
+ }
+
+ /**
+ * Tests whether or not this component is actually being shown on
+ * the screen. This will be true if and only if it this component is
+ * visible and its parent components are all visible.
+ *
+ * @return true if the component is showing on the screen
+ * @see #setVisible(boolean)
+ */
+ public boolean isShowing()
+ {
+ if (! visible || peer == null)
+ return false;
+
+ return parent == null ? false : parent.isShowing();
+ }
+
+ /**
+ * Tests whether or not this component is enabled. Components are enabled
+ * by default, and must be enabled to receive user input or generate events.
+ *
+ * @return true if the component is enabled
+ * @see #setEnabled(boolean)
+ */
+ public boolean isEnabled()
+ {
+ return enabled;
+ }
+
+ /**
+ * Enables or disables this component. The component must be enabled to
+ * receive events (except that lightweight components always receive mouse
+ * events).
+ *
+ * @param enabled true to enable this component
+ *
+ * @see #isEnabled()
+ * @see #isLightweight()
+ *
+ * @since 1.1
+ */
+ public void setEnabled(boolean enabled)
+ {
+ enable(enabled);
+ }
+
+ /**
+ * Enables this component.
+ *
+ * @deprecated use {@link #setEnabled(boolean)} instead
+ */
+ public void enable()
+ {
+ if (! enabled)
+ {
+ // Need to lock the tree here, because the peers are involved.
+ synchronized (getTreeLock())
+ {
+ enabled = true;
+ ComponentPeer p = peer;
+ if (p != null)
+ p.enable();
+ }
+ }
+ }
+
+ /**
+ * Enables or disables this component.
+ *
+ * @param enabled true to enable this component
+ *
+ * @deprecated use {@link #setEnabled(boolean)} instead
+ */
+ public void enable(boolean enabled)
+ {
+ if (enabled)
+ enable();
+ else
+ disable();
+ }
+
+ /**
+ * Disables this component.
+ *
+ * @deprecated use {@link #setEnabled(boolean)} instead
+ */
+ public void disable()
+ {
+ if (enabled)
+ {
+ // Need to lock the tree here, because the peers are involved.
+ synchronized (getTreeLock())
+ {
+ enabled = false;
+ ComponentPeer p = peer;
+ if (p != null)
+ p.disable();
+ }
+ }
+ }
+
+ /**
+ * Checks if this image is painted to an offscreen image buffer that is
+ * later copied to screen (double buffering reduces flicker). This version
+ * returns false, so subclasses must override it if they provide double
+ * buffering.
+ *
+ * @return true if this is double buffered; defaults to false
+ */
+ public boolean isDoubleBuffered()
+ {
+ return false;
+ }
+
+ /**
+ * Enables or disables input method support for this component. By default,
+ * components have this enabled. Input methods are given the opportunity
+ * to process key events before this component and its listeners.
+ *
+ * @param enable true to enable input method processing
+ * @see #processKeyEvent(KeyEvent)
+ * @since 1.2
+ */
+ public void enableInputMethods(boolean enable)
+ {
+ if (enable)
+ eventMask |= AWTEvent.INPUT_ENABLED_EVENT_MASK;
+ else
+ eventMask &= ~AWTEvent.INPUT_ENABLED_EVENT_MASK;
+ }
+
+ /**
+ * Makes this component visible or invisible. Note that it wtill might
+ * not show the component, if a parent is invisible.
+ *
+ * @param visible true to make this component visible
+ *
+ * @see #isVisible()
+ *
+ * @since 1.1
+ */
+ public void setVisible(boolean visible)
+ {
+ // Inspection by subclassing shows that Sun's implementation calls
+ // show(boolean) which then calls show() or hide(). It is the show()
+ // method that is overriden in subclasses like Window.
+ show(visible);
+ }
+
+ /**
+ * Makes this component visible on the screen.
+ *
+ * @deprecated use {@link #setVisible(boolean)} instead
+ */
+ public void show()
+ {
+ // We must set visible before showing the peer. Otherwise the
+ // peer could post paint events before visible is true, in which
+ // case lightweight components are not initially painted --
+ // Container.paint first calls isShowing () before painting itself
+ // and its children.
+ if(!isVisible())
+ {
+ // Need to lock the tree here to avoid races and inconsistencies.
+ synchronized (getTreeLock())
+ {
+ visible = true;
+ // Avoid NullPointerExceptions by creating a local reference.
+ ComponentPeer currentPeer=peer;
+ if (currentPeer != null)
+ {
+ currentPeer.show();
+
+ // Fire HierarchyEvent.
+ fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED,
+ this, parent,
+ HierarchyEvent.SHOWING_CHANGED);
+
+ // The JDK repaints the component before invalidating the parent.
+ // So do we.
+ if (isLightweight())
+ repaint();
+ }
+
+ // Only post an event if this component actually has a listener
+ // or has this event explicitly enabled.
+ if (componentListener != null
+ || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0)
+ {
+ ComponentEvent ce =
+ new ComponentEvent(this,ComponentEvent.COMPONENT_SHOWN);
+ getToolkit().getSystemEventQueue().postEvent(ce);
+ }
+ }
+
+ // Invalidate the parent if we have one. The component itself must
+ // not be invalidated. We also avoid NullPointerException with
+ // a local reference here.
+ Container currentParent = parent;
+ if (currentParent != null)
+ currentParent.invalidate();
+
+ }
+ }
+
+ /**
+ * Makes this component visible or invisible.
+ *
+ * @param visible true to make this component visible
+ *
+ * @deprecated use {@link #setVisible(boolean)} instead
+ */
+ public void show(boolean visible)
+ {
+ if (visible)
+ show();
+ else
+ hide();
+ }
+
+ /**
+ * Hides this component so that it is no longer shown on the screen.
+ *
+ * @deprecated use {@link #setVisible(boolean)} instead
+ */
+ public void hide()
+ {
+ if (isVisible())
+ {
+ // Need to lock the tree here to avoid races and inconsistencies.
+ synchronized (getTreeLock())
+ {
+ visible = false;
+
+ // Avoid NullPointerExceptions by creating a local reference.
+ ComponentPeer currentPeer=peer;
+ if (currentPeer != null)
+ {
+ currentPeer.hide();
+
+ // Fire hierarchy event.
+ fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED,
+ this, parent,
+ HierarchyEvent.SHOWING_CHANGED);
+ // The JDK repaints the component before invalidating the
+ // parent. So do we. This only applies for lightweights.
+ if (peer instanceof LightweightPeer)
+ repaint();
+ }
+
+ // Only post an event if this component actually has a listener
+ // or has this event explicitly enabled.
+ if (componentListener != null
+ || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0)
+ {
+ ComponentEvent ce =
+ new ComponentEvent(this,ComponentEvent.COMPONENT_HIDDEN);
+ getToolkit().getSystemEventQueue().postEvent(ce);
+ }
+ }
+
+ // Invalidate the parent if we have one. The component itself need
+ // not be invalidated. We also avoid NullPointerException with
+ // a local reference here.
+ Container currentParent = parent;
+ if (currentParent != null)
+ currentParent.invalidate();
+
+ }
+ }
+
+ /**
+ * Returns this component's foreground color. If not set, this is inherited
+ * from the parent.
+ *
+ * @return this component's foreground color, or null
+ * @see #setForeground(Color)
+ */
+ public Color getForeground()
+ {
+ if (foreground != null)
+ return foreground;
+ return parent == null ? null : parent.getForeground();
+ }
+
+ /**
+ * Sets this component's foreground color to the specified color. This is a
+ * bound property.
+ *
+ * @param c the new foreground color
+ * @see #getForeground()
+ */
+ public void setForeground(Color c)
+ {
+ if (peer != null)
+ peer.setForeground(c);
+
+ Color previous = foreground;
+ foreground = c;
+ firePropertyChange("foreground", previous, c);
+ }
+
+ /**
+ * Tests if the foreground was explicitly set, or just inherited from the
+ * parent.
+ *
+ * @return true if the foreground has been set
+ * @since 1.4
+ */
+ public boolean isForegroundSet()
+ {
+ return foreground != null;
+ }
+
+ /**
+ * Returns this component's background color. If not set, this is inherited
+ * from the parent.
+ *
+ * @return the background color of the component, or null
+ * @see #setBackground(Color)
+ */
+ public Color getBackground()
+ {
+ if (background != null)
+ return background;
+ return parent == null ? null : parent.getBackground();
+ }
+
+ /**
+ * Sets this component's background color to the specified color. The parts
+ * of the component affected by the background color may by system dependent.
+ * This is a bound property.
+ *
+ * @param c the new background color
+ * @see #getBackground()
+ */
+ public void setBackground(Color c)
+ {
+ // return if the background is already set to that color.
+ if ((c != null) && c.equals(background))
+ return;
+
+ Color previous = background;
+ background = c;
+ if (peer != null && c != null)
+ peer.setBackground(c);
+ firePropertyChange("background", previous, c);
+ }
+
+ /**
+ * Tests if the background was explicitly set, or just inherited from the
+ * parent.
+ *
+ * @return true if the background has been set
+ * @since 1.4
+ */
+ public boolean isBackgroundSet()
+ {
+ return background != null;
+ }
+
+ /**
+ * Returns the font in use for this component. If not set, this is inherited
+ * from the parent.
+ *
+ * @return the font for this component
+ * @see #setFont(Font)
+ */
+ public Font getFont()
+ {
+ Font f = font;
+ if (f != null)
+ return f;
+
+ Component p = parent;
+ if (p != null)
+ return p.getFont();
+ return null;
+ }
+
+ /**
+ * Sets the font for this component to the specified font. This is a bound
+ * property.
+ *
+ * @param newFont the new font for this component
+ *
+ * @see #getFont()
+ */
+ public void setFont(Font newFont)
+ {
+ Font oldFont = font;
+ font = newFont;
+ if (peer != null)
+ peer.setFont(font);
+ firePropertyChange("font", oldFont, newFont);
+ if (valid)
+ invalidate();
+ }
+
+ /**
+ * Tests if the font was explicitly set, or just inherited from the parent.
+ *
+ * @return true if the font has been set
+ * @since 1.4
+ */
+ public boolean isFontSet()
+ {
+ return font != null;
+ }
+
+ /**
+ * Returns the locale for this component. If this component does not
+ * have a locale, the locale of the parent component is returned.
+ *
+ * @return the locale for this component
+ * @throws IllegalComponentStateException if it has no locale or parent
+ * @see #setLocale(Locale)
+ * @since 1.1
+ */
+ public Locale getLocale()
+ {
+ if (locale != null)
+ return locale;
+ if (parent == null)
+ throw new IllegalComponentStateException
+ ("Component has no parent: can't determine Locale");
+ return parent.getLocale();
+ }
+
+ /**
+ * Sets the locale for this component to the specified locale. This is a
+ * bound property.
+ *
+ * @param newLocale the new locale for this component
+ */
+ public void setLocale(Locale newLocale)
+ {
+ if (locale == newLocale)
+ return;
+
+ Locale oldLocale = locale;
+ locale = newLocale;
+ firePropertyChange("locale", oldLocale, newLocale);
+ // New writing/layout direction or more/less room for localized labels.
+ invalidate();
+ }
+
+ /**
+ * Returns the color model of the device this componet is displayed on.
+ *
+ * @return this object's color model
+ * @see Toolkit#getColorModel()
+ */
+ public ColorModel getColorModel()
+ {
+ GraphicsConfiguration config = getGraphicsConfiguration();
+ return config != null ? config.getColorModel()
+ : getToolkit().getColorModel();
+ }
+
+ /**
+ * Returns the location of this component's top left corner relative to
+ * its parent component. This may be outdated, so for synchronous behavior,
+ * you should use a component listner.
+ *
+ * @return the location of this component
+ * @see #setLocation(int, int)
+ * @see #getLocationOnScreen()
+ * @since 1.1
+ */
+ public Point getLocation()
+ {
+ return location ();
+ }
+
+ /**
+ * Returns the location of this component's top left corner in screen
+ * coordinates.
+ *
+ * @return the location of this component in screen coordinates
+ * @throws IllegalComponentStateException if the component is not showing
+ */
+ public Point getLocationOnScreen()
+ {
+ if (! isShowing())
+ throw new IllegalComponentStateException("component "
+ + getClass().getName()
+ + " not showing");
+
+ // Need to lock the tree here. We get crazy races and explosions when
+ // the tree changes while we are trying to find the location of this
+ // component.
+ synchronized (getTreeLock())
+ {
+ // We know peer != null here.
+ return peer.getLocationOnScreen();
+ }
+ }
+
+ /**
+ * Returns the location of this component's top left corner relative to
+ * its parent component.
+ *
+ * @return the location of this component
+ * @deprecated use {@link #getLocation()} instead
+ */
+ public Point location()
+ {
+ return new Point (x, y);
+ }
+
+ /**
+ * Moves this component to the specified location, relative to the parent's
+ * coordinates. The coordinates are the new upper left corner of this
+ * component.
+ *
+ * @param x the new X coordinate of this component
+ * @param y the new Y coordinate of this component
+ * @see #getLocation()
+ * @see #setBounds(int, int, int, int)
+ */
+ public void setLocation(int x, int y)
+ {
+ move (x, y);
+ }
+
+ /**
+ * Moves this component to the specified location, relative to the parent's
+ * coordinates. The coordinates are the new upper left corner of this
+ * component.
+ *
+ * @param x the new X coordinate of this component
+ * @param y the new Y coordinate of this component
+ * @deprecated use {@link #setLocation(int, int)} instead
+ */
+ public void move(int x, int y)
+ {
+ setBounds(x, y, this.width, this.height);
+ }
+
+ /**
+ * Moves this component to the specified location, relative to the parent's
+ * coordinates. The coordinates are the new upper left corner of this
+ * component.
+ *
+ * @param p new coordinates for this component
+ * @throws NullPointerException if p is null
+ * @see #getLocation()
+ * @see #setBounds(int, int, int, int)
+ * @since 1.1
+ */
+ public void setLocation(Point p)
+ {
+ setLocation(p.x, p.y);
+ }
+
+ /**
+ * Returns the size of this object.
+ *
+ * @return the size of this object
+ * @see #setSize(int, int)
+ * @since 1.1
+ */
+ public Dimension getSize()
+ {
+ return size ();
+ }
+
+ /**
+ * Returns the size of this object.
+ *
+ * @return the size of this object
+ * @deprecated use {@link #getSize()} instead
+ */
+ public Dimension size()
+ {
+ return new Dimension (width, height);
+ }
+
+ /**
+ * Sets the size of this component to the specified width and height.
+ *
+ * @param width the new width of this component
+ * @param height the new height of this component
+ * @see #getSize()
+ * @see #setBounds(int, int, int, int)
+ */
+ public void setSize(int width, int height)
+ {
+ resize (width, height);
+ }
+
+ /**
+ * Sets the size of this component to the specified value.
+ *
+ * @param width the new width of the component
+ * @param height the new height of the component
+ * @deprecated use {@link #setSize(int, int)} instead
+ */
+ public void resize(int width, int height)
+ {
+ setBounds(this.x, this.y, width, height);
+ }
+
+ /**
+ * Sets the size of this component to the specified value.
+ *
+ * @param d the new size of this component
+ * @throws NullPointerException if d is null
+ * @see #setSize(int, int)
+ * @see #setBounds(int, int, int, int)
+ * @since 1.1
+ */
+ public void setSize(Dimension d)
+ {
+ resize (d);
+ }
+
+ /**
+ * Sets the size of this component to the specified value.
+ *
+ * @param d the new size of this component
+ * @throws NullPointerException if d is null
+ * @deprecated use {@link #setSize(Dimension)} instead
+ */
+ public void resize(Dimension d)
+ {
+ resize (d.width, d.height);
+ }
+
+ /**
+ * Returns a bounding rectangle for this component. Note that the
+ * returned rectange is relative to this component's parent, not to
+ * the screen.
+ *
+ * @return the bounding rectangle for this component
+ * @see #setBounds(int, int, int, int)
+ * @see #getLocation()
+ * @see #getSize()
+ */
+ public Rectangle getBounds()
+ {
+ return bounds ();
+ }
+
+ /**
+ * Returns a bounding rectangle for this component. Note that the
+ * returned rectange is relative to this component's parent, not to
+ * the screen.
+ *
+ * @return the bounding rectangle for this component
+ * @deprecated use {@link #getBounds()} instead
+ */
+ public Rectangle bounds()
+ {
+ return new Rectangle (x, y, width, height);
+ }
+
+ /**
+ * Sets the bounding rectangle for this component to the specified values.
+ * Note that these coordinates are relative to the parent, not to the screen.
+ *
+ * @param x the X coordinate of the upper left corner of the rectangle
+ * @param y the Y coordinate of the upper left corner of the rectangle
+ * @param w the width of the rectangle
+ * @param h the height of the rectangle
+ * @see #getBounds()
+ * @see #setLocation(int, int)
+ * @see #setLocation(Point)
+ * @see #setSize(int, int)
+ * @see #setSize(Dimension)
+ * @since 1.1
+ */
+ public void setBounds(int x, int y, int w, int h)
+ {
+ reshape (x, y, w, h);
+ }
+
+ /**
+ * Sets the bounding rectangle for this component to the specified values.
+ * Note that these coordinates are relative to the parent, not to the screen.
+ *
+ * @param x the X coordinate of the upper left corner of the rectangle
+ * @param y the Y coordinate of the upper left corner of the rectangle
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
+ * @deprecated use {@link #setBounds(int, int, int, int)} instead
+ */
+ public void reshape(int x, int y, int width, int height)
+ {
+ // We need to lock the tree here, otherwise we risk races and
+ // inconsistencies.
+ synchronized (getTreeLock())
+ {
+ int oldx = this.x;
+ int oldy = this.y;
+ int oldwidth = this.width;
+ int oldheight = this.height;
+
+ boolean resized = oldwidth != width || oldheight != height;
+ boolean moved = oldx != x || oldy != y;
+
+ if (resized || moved)
+ {
+ // Update the fields.
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+
+ if (peer != null)
+ {
+ peer.setBounds (x, y, width, height);
+ if (resized)
+ invalidate();
+ if (parent != null && parent.valid)
+ parent.invalidate();
+ }
+
+ // Send some events to interested listeners.
+ notifyReshape(resized, moved);
+
+ // Repaint this component and the parent if appropriate.
+ if (parent != null && peer instanceof LightweightPeer
+ && isShowing())
+ {
+ // The parent repaints the area that we occupied before.
+ parent.repaint(oldx, oldy, oldwidth, oldheight);
+ // This component repaints the area that we occupy now.
+ repaint();
+ }
+ }
+ }
+ }
+
+ private void notifyReshape(boolean resized, boolean moved)
+ {
+ // Only post an event if this component actually has a listener
+ // or has this event explicitly enabled.
+ if (componentListener != null
+ || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0)
+ {
+ // Fire component event on this component.
+ if (moved)
+ {
+ ComponentEvent ce = new ComponentEvent(this,
+ ComponentEvent.COMPONENT_MOVED);
+ getToolkit().getSystemEventQueue().postEvent(ce);
+ }
+ if (resized)
+ {
+ ComponentEvent ce = new ComponentEvent(this,
+ ComponentEvent.COMPONENT_RESIZED);
+ getToolkit().getSystemEventQueue().postEvent(ce);
+ }
+ }
+ else
+ {
+ // Otherwise we might need to notify child components when this is
+ // a Container.
+ if (this instanceof Container)
+ {
+ Container cont = (Container) this;
+ if (resized)
+ {
+ for (int i = 0; i < cont.getComponentCount(); i++)
+ {
+ Component child = cont.getComponent(i);
+ child.fireHierarchyEvent(HierarchyEvent.ANCESTOR_RESIZED,
+ this, parent, 0);
+ }
+ }
+ if (moved)
+ {
+ for (int i = 0; i < cont.getComponentCount(); i++)
+ {
+ Component child = cont.getComponent(i);
+ child.fireHierarchyEvent(HierarchyEvent.ANCESTOR_MOVED,
+ this, parent, 0);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Sets the bounding rectangle for this component to the specified
+ * rectangle. Note that these coordinates are relative to the parent, not
+ * to the screen.
+ *
+ * @param r the new bounding rectangle
+ * @throws NullPointerException if r is null
+ * @see #getBounds()
+ * @see #setLocation(Point)
+ * @see #setSize(Dimension)
+ * @since 1.1
+ */
+ public void setBounds(Rectangle r)
+ {
+ setBounds (r.x, r.y, r.width, r.height);
+ }
+
+ /**
+ * Gets the x coordinate of the upper left corner. This is more efficient
+ * than getBounds().x or getLocation().x.
+ *
+ * @return the current x coordinate
+ * @since 1.2
+ */
+ public int getX()
+ {
+ return x;
+ }
+
+ /**
+ * Gets the y coordinate of the upper left corner. This is more efficient
+ * than getBounds().y or getLocation().y.
+ *
+ * @return the current y coordinate
+ * @since 1.2
+ */
+ public int getY()
+ {
+ return y;
+ }
+
+ /**
+ * Gets the width of the component. This is more efficient than
+ * getBounds().width or getSize().width.
+ *
+ * @return the current width
+ * @since 1.2
+ */
+ public int getWidth()
+ {
+ return width;
+ }
+
+ /**
+ * Gets the height of the component. This is more efficient than
+ * getBounds().height or getSize().height.
+ *
+ * @return the current width
+ * @since 1.2
+ */
+ public int getHeight()
+ {
+ return height;
+ }
+
+ /**
+ * Returns the bounds of this component. This allows reuse of an existing
+ * rectangle, if r is non-null.
+ *
+ * @param r the rectangle to use, or null
+ * @return the bounds
+ */
+ public Rectangle getBounds(Rectangle r)
+ {
+ if (r == null)
+ r = new Rectangle();
+ r.x = x;
+ r.y = y;
+ r.width = width;
+ r.height = height;
+ return r;
+ }
+
+ /**
+ * Returns the size of this component. This allows reuse of an existing
+ * dimension, if d is non-null.
+ *
+ * @param d the dimension to use, or null
+ * @return the size
+ */
+ public Dimension getSize(Dimension d)
+ {
+ if (d == null)
+ d = new Dimension();
+ d.width = width;
+ d.height = height;
+ return d;
+ }
+
+ /**
+ * Returns the location of this component. This allows reuse of an existing
+ * point, if p is non-null.
+ *
+ * @param p the point to use, or null
+ * @return the location
+ */
+ public Point getLocation(Point p)
+ {
+ if (p == null)
+ p = new Point();
+ p.x = x;
+ p.y = y;
+ return p;
+ }
+
+ /**
+ * Tests if this component is opaque. All "heavyweight" (natively-drawn)
+ * components are opaque. A component is opaque if it draws all pixels in
+ * the bounds; a lightweight component is partially transparent if it lets
+ * pixels underneath show through. Subclasses that guarantee that all pixels
+ * will be drawn should override this.
+ *
+ * @return true if this is opaque
+ * @see #isLightweight()
+ * @since 1.2
+ */
+ public boolean isOpaque()
+ {
+ return ! isLightweight();
+ }
+
+ /**
+ * Return whether the component is lightweight. That means the component has
+ * no native peer, but is displayable. This applies to subclasses of
+ * Component not in this package, such as javax.swing.
+ *
+ * @return true if the component has a lightweight peer
+ * @see #isDisplayable()
+ * @since 1.2
+ */
+ public boolean isLightweight()
+ {
+ return peer instanceof LightweightPeer;
+ }
+
+ /**
+ * Returns the component's preferred size.
+ *
+ * @return the component's preferred size
+ * @see #getMinimumSize()
+ * @see #setPreferredSize(Dimension)
+ * @see LayoutManager
+ */
+ public Dimension getPreferredSize()
+ {
+ return preferredSize();
+ }
+
+ /**
+ * Sets the preferred size that will be returned by
+ * {@link #getPreferredSize()} always, and sends a
+ * {@link PropertyChangeEvent} (with the property name 'preferredSize') to
+ * all registered listeners.
+ *
+ * @param size the preferred size (<code>null</code> permitted).
+ *
+ * @since 1.5
+ *
+ * @see #getPreferredSize()
+ */
+ public void setPreferredSize(Dimension size)
+ {
+ Dimension old = prefSizeSet ? prefSize : null;
+ prefSize = size;
+ prefSizeSet = (size != null);
+ firePropertyChange("preferredSize", old, size);
+ }
+
+ /**
+ * Returns <code>true</code> if the current preferred size is not
+ * <code>null</code> and was set by a call to
+ * {@link #setPreferredSize(Dimension)}, otherwise returns <code>false</code>.
+ *
+ * @return A boolean.
+ *
+ * @since 1.5
+ */
+ public boolean isPreferredSizeSet()
+ {
+ return prefSizeSet;
+ }
+
+ /**
+ * Returns the component's preferred size.
+ *
+ * @return the component's preferred size
+ * @deprecated use {@link #getPreferredSize()} instead
+ */
+ public Dimension preferredSize()
+ {
+ // Create a new Dimension object, so that the application doesn't mess
+ // with the actual values.
+ return new Dimension(preferredSizeImpl());
+ }
+
+ /**
+ * The actual calculation is pulled out of preferredSize() so that
+ * we can call it from Container.preferredSize() and avoid creating a
+ * new intermediate Dimension object.
+ *
+ * @return the preferredSize of the component
+ */
+ Dimension preferredSizeImpl()
+ {
+ Dimension size = prefSize;
+ // Try to use a cached value.
+ if (size == null || !(valid || prefSizeSet))
+ {
+ // We need to lock here, because the calculation depends on the
+ // component structure not changing.
+ synchronized (getTreeLock())
+ {
+ ComponentPeer p = peer;
+ if (p != null)
+ size = peer.preferredSize();
+ else
+ size = minimumSizeImpl();
+ }
+ }
+ return size;
+ }
+
+ /**
+ * Returns the component's minimum size.
+ *
+ * @return the component's minimum size
+ * @see #getPreferredSize()
+ * @see #setMinimumSize(Dimension)
+ * @see LayoutManager
+ */
+ public Dimension getMinimumSize()
+ {
+ return minimumSize();
+ }
+
+ /**
+ * Sets the minimum size that will be returned by {@link #getMinimumSize()}
+ * always, and sends a {@link PropertyChangeEvent} (with the property name
+ * 'minimumSize') to all registered listeners.
+ *
+ * @param size the minimum size (<code>null</code> permitted).
+ *
+ * @since 1.5
+ *
+ * @see #getMinimumSize()
+ */
+ public void setMinimumSize(Dimension size)
+ {
+ Dimension old = minSizeSet ? minSize : null;
+ minSize = size;
+ minSizeSet = (size != null);
+ firePropertyChange("minimumSize", old, size);
+ }
+
+ /**
+ * Returns <code>true</code> if the current minimum size is not
+ * <code>null</code> and was set by a call to
+ * {@link #setMinimumSize(Dimension)}, otherwise returns <code>false</code>.
+ *
+ * @return A boolean.
+ *
+ * @since 1.5
+ */
+ public boolean isMinimumSizeSet()
+ {
+ return minSizeSet;
+ }
+
+ /**
+ * Returns the component's minimum size.
+ *
+ * @return the component's minimum size
+ * @deprecated use {@link #getMinimumSize()} instead
+ */
+ public Dimension minimumSize()
+ {
+ // Create a new Dimension object, so that the application doesn't mess
+ // with the actual values.
+ return new Dimension(minimumSizeImpl());
+ }
+
+ /**
+ * The actual calculation is pulled out of minimumSize() so that
+ * we can call it from Container.preferredSize() and
+ * Component.preferredSizeImpl and avoid creating a
+ * new intermediate Dimension object.
+ *
+ * @return the minimum size of the component
+ */
+ Dimension minimumSizeImpl()
+ {
+ Dimension size = minSize;
+ if (size == null || !(valid || minSizeSet))
+ {
+ // We need to lock here, because the calculation depends on the
+ // component structure not changing.
+ synchronized (getTreeLock())
+ {
+ ComponentPeer p = peer;
+ if (p != null)
+ size = peer.minimumSize();
+ else
+ size = size();
+ }
+ }
+ return size;
+ }
+
+ /**
+ * Returns the component's maximum size.
+ *
+ * @return the component's maximum size
+ * @see #getMinimumSize()
+ * @see #setMaximumSize(Dimension)
+ * @see #getPreferredSize()
+ * @see LayoutManager
+ */
+ public Dimension getMaximumSize()
+ {
+ return new Dimension(maximumSizeImpl());
+ }
+
+ /**
+ * This is pulled out from getMaximumSize(), so that we can access it
+ * from Container.getMaximumSize() without creating an additional
+ * intermediate Dimension object.
+ *
+ * @return the maximum size of the component
+ */
+ Dimension maximumSizeImpl()
+ {
+ Dimension size;
+ if (maxSizeSet)
+ size = maxSize;
+ else
+ size = DEFAULT_MAX_SIZE;
+ return size;
+ }
+
+ /**
+ * Sets the maximum size that will be returned by {@link #getMaximumSize()}
+ * always, and sends a {@link PropertyChangeEvent} (with the property name
+ * 'maximumSize') to all registered listeners.
+ *
+ * @param size the maximum size (<code>null</code> permitted).
+ *
+ * @since 1.5
+ *
+ * @see #getMaximumSize()
+ */
+ public void setMaximumSize(Dimension size)
+ {
+ Dimension old = maxSizeSet ? maxSize : null;
+ maxSize = size;
+ maxSizeSet = (size != null);
+ firePropertyChange("maximumSize", old, size);
+ }
+
+ /**
+ * Returns <code>true</code> if the current maximum size is not
+ * <code>null</code> and was set by a call to
+ * {@link #setMaximumSize(Dimension)}, otherwise returns <code>false</code>.
+ *
+ * @return A boolean.
+ *
+ * @since 1.5
+ */
+ public boolean isMaximumSizeSet()
+ {
+ return maxSizeSet;
+ }
+
+ /**
+ * Returns the preferred horizontal alignment of this component. The value
+ * returned will be between {@link #LEFT_ALIGNMENT} and
+ * {@link #RIGHT_ALIGNMENT}, inclusive.
+ *
+ * @return the preferred horizontal alignment of this component
+ */
+ public float getAlignmentX()
+ {
+ return CENTER_ALIGNMENT;
+ }
+
+ /**
+ * Returns the preferred vertical alignment of this component. The value
+ * returned will be between {@link #TOP_ALIGNMENT} and
+ * {@link #BOTTOM_ALIGNMENT}, inclusive.
+ *
+ * @return the preferred vertical alignment of this component
+ */
+ public float getAlignmentY()
+ {
+ return CENTER_ALIGNMENT;
+ }
+
+ /**
+ * Calls the layout manager to re-layout the component. This is called
+ * during validation of a container in most cases.
+ *
+ * @see #validate()
+ * @see LayoutManager
+ */
+ public void doLayout()
+ {
+ layout ();
+ }
+
+ /**
+ * Calls the layout manager to re-layout the component. This is called
+ * during validation of a container in most cases.
+ *
+ * @deprecated use {@link #doLayout()} instead
+ */
+ public void layout()
+ {
+ // Nothing to do unless we're a container.
+ }
+
+ /**
+ * Called to ensure that the layout for this component is valid. This is
+ * usually called on containers.
+ *
+ * @see #invalidate()
+ * @see #doLayout()
+ * @see LayoutManager
+ * @see Container#validate()
+ */
+ public void validate()
+ {
+ valid = true;
+ }
+
+ /**
+ * Invalidates this component and all of its parent components. This will
+ * cause them to have their layout redone. This is called frequently, so
+ * make it fast.
+ */
+ public void invalidate()
+ {
+ // Need to lock here, to avoid races and other ugly stuff when doing
+ // layout or structure changes in other threads.
+ synchronized (getTreeLock())
+ {
+ // Invalidate.
+ valid = false;
+
+ // Throw away cached layout information.
+ if (! minSizeSet)
+ minSize = null;
+ if (! prefSizeSet)
+ prefSize = null;
+ if (! maxSizeSet)
+ maxSize = null;
+
+ // Also invalidate the parent, if it hasn't already been invalidated.
+ if (parent != null && parent.isValid())
+ parent.invalidate();
+ }
+ }
+
+ /**
+ * Returns a graphics object for this component. Returns <code>null</code>
+ * if this component is not currently displayed on the screen.
+ *
+ * @return a graphics object for this component
+ * @see #paint(Graphics)
+ */
+ public Graphics getGraphics()
+ {
+ if (peer != null)
+ {
+ Graphics gfx = peer.getGraphics();
+ // Create peer for lightweights.
+ if (gfx == null && parent != null)
+ {
+ gfx = parent.getGraphics();
+ gfx.clipRect(getX(), getY(), getWidth(), getHeight());
+ gfx.translate(getX(), getY());
+ return gfx;
+ }
+ gfx.setFont(font);
+ return gfx;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the font metrics for the specified font in this component.
+ *
+ * @param font the font to retrieve metrics for
+ * @return the font metrics for the specified font
+ * @throws NullPointerException if font is null
+ * @see #getFont()
+ * @see Toolkit#getFontMetrics(Font)
+ */
+ public FontMetrics getFontMetrics(Font font)
+ {
+ return peer == null ? getToolkit().getFontMetrics(font)
+ : peer.getFontMetrics(font);
+ }
+
+ /**
+ * Sets the cursor for this component to the specified cursor. The cursor
+ * is displayed when the point is contained by the component, and the
+ * component is visible, displayable, and enabled. This is inherited by
+ * subcomponents unless they set their own cursor.
+ *
+ * @param cursor the new cursor for this component
+ * @see #isEnabled()
+ * @see #isShowing()
+ * @see #getCursor()
+ * @see #contains(int, int)
+ * @see Toolkit#createCustomCursor(Image, Point, String)
+ */
+ public void setCursor(Cursor cursor)
+ {
+ this.cursor = cursor;
+ if (peer != null)
+ peer.setCursor(cursor);
+ }
+
+ /**
+ * Returns the cursor for this component. If not set, this is inherited
+ * from the parent, or from Cursor.getDefaultCursor().
+ *
+ * @return the cursor for this component
+ */
+ public Cursor getCursor()
+ {
+ if (cursor != null)
+ return cursor;
+ return parent != null ? parent.getCursor() : Cursor.getDefaultCursor();
+ }
+
+ /**
+ * Tests if the cursor was explicitly set, or just inherited from the parent.
+ *
+ * @return true if the cursor has been set
+ * @since 1.4
+ */
+ public boolean isCursorSet()
+ {
+ return cursor != null;
+ }
+
+ /**
+ * Paints this component on the screen. The clipping region in the graphics
+ * context will indicate the region that requires painting. This is called
+ * whenever the component first shows, or needs to be repaired because
+ * something was temporarily drawn on top. It is not necessary for
+ * subclasses to call <code>super.paint(g)</code>. Components with no area
+ * are not painted.
+ *
+ * @param g the graphics context for this paint job
+ * @see #update(Graphics)
+ */
+ public void paint(Graphics g)
+ {
+ // This is a callback method and is meant to be overridden by subclasses
+ // that want to perform custom painting.
+ }
+
+ /**
+ * Updates this component. This is called for heavyweight components in
+ * response to {@link #repaint()}. The default implementation simply forwards
+ * to {@link #paint(Graphics)}. The coordinates of the graphics are
+ * relative to this component. Subclasses should call either
+ * <code>super.update(g)</code> or <code>paint(g)</code>.
+ *
+ * @param g the graphics context for this update
+ *
+ * @see #paint(Graphics)
+ * @see #repaint()
+ */
+ public void update(Graphics g)
+ {
+ // Note 1: We used to clear the background here for lightweights and
+ // toplevel components. Tests show that this is not what the JDK does
+ // here. Note that there is some special handling and background
+ // clearing code in Container.update(Graphics).
+
+ // Note 2 (for peer implementors): The JDK doesn't seem call update() for
+ // toplevel components, even when an UPDATE event is sent (as a result
+ // of repaint).
+ paint(g);
+ }
+
+ /**
+ * Paints this entire component, including any sub-components.
+ *
+ * @param g the graphics context for this paint job
+ *
+ * @see #paint(Graphics)
+ */
+ public void paintAll(Graphics g)
+ {
+ if (! visible)
+ return;
+ paint(g);
+ }
+
+ /**
+ * Repaint this entire component. The <code>update()</code> method
+ * on this component will be called as soon as possible.
+ *
+ * @see #update(Graphics)
+ * @see #repaint(long, int, int, int, int)
+ */
+ public void repaint()
+ {
+ repaint(0, 0, 0, width, height);
+ }
+
+ /**
+ * Repaint this entire component. The <code>update()</code> method on this
+ * component will be called in approximate the specified number of
+ * milliseconds.
+ *
+ * @param tm milliseconds before this component should be repainted
+ * @see #paint(Graphics)
+ * @see #repaint(long, int, int, int, int)
+ */
+ public void repaint(long tm)
+ {
+ repaint(tm, 0, 0, width, height);
+ }
+
+ /**
+ * Repaints the specified rectangular region within this component. The
+ * <code>update</code> method on this component will be called as soon as
+ * possible. The coordinates are relative to this component.
+ *
+ * @param x the X coordinate of the upper left of the region to repaint
+ * @param y the Y coordinate of the upper left of the region to repaint
+ * @param w the width of the region to repaint
+ * @param h the height of the region to repaint
+ * @see #update(Graphics)
+ * @see #repaint(long, int, int, int, int)
+ */
+ public void repaint(int x, int y, int w, int h)
+ {
+ repaint(0, x, y, w, h);
+ }
+
+ /**
+ * Repaints the specified rectangular region within this component. The
+ * <code>update</code> method on this component will be called in
+ * approximately the specified number of milliseconds. The coordinates
+ * are relative to this component.
+ *
+ * @param tm milliseconds before this component should be repainted
+ * @param x the X coordinate of the upper left of the region to repaint
+ * @param y the Y coordinate of the upper left of the region to repaint
+ * @param width the width of the region to repaint
+ * @param height the height of the region to repaint
+ * @see #update(Graphics)
+ */
+ public void repaint(long tm, int x, int y, int width, int height)
+ {
+ // The repaint() call has previously been delegated to
+ // {@link ComponentPeer.repaint()}. Testing on the JDK using some
+ // dummy peers show that this methods is never called. I think it makes
+ // sense to actually perform the tasks below here, since it's pretty
+ // much peer independent anyway, and makes sure only heavyweights are
+ // bothered by this.
+ ComponentPeer p = peer;
+
+ // Let the nearest heavyweight parent handle repainting for lightweight
+ // components.
+ // This goes up the hierarchy until we hit
+ // a heavyweight component that handles this and translates the
+ // rectangle while doing so.
+
+ // We perform some boundary checking to restrict the paint
+ // region to this component.
+ int px = (x < 0 ? 0 : x);
+ int py = (y < 0 ? 0 : y);
+ int pw = width;
+ int ph = height;
+ Component par = this;
+ while (par != null && p instanceof LightweightPeer)
+ {
+ px += par.x;
+ py += par.y;
+ // We perform some boundary checking to restrict the paint
+ // region to this component.
+ pw = Math.min(pw, par.width);
+ ph = Math.min(ph, par.height);
+ par = par.parent;
+ p = par.peer;
+ }
+
+ // Now send an UPDATE event to the heavyweight component that we've found.
+ if (par != null && par.isVisible() && p != null && pw > 0 && ph > 0)
+ {
+ assert ! (p instanceof LightweightPeer);
+ PaintEvent pe = new PaintEvent(par, PaintEvent.UPDATE,
+ new Rectangle(px, py, pw, ph));
+ getToolkit().getSystemEventQueue().postEvent(pe);
+ }
+ }
+
+ /**
+ * Prints this component. This method is provided so that printing can be
+ * done in a different manner from painting. However, the implementation
+ * in this class simply calls the <code>paint()</code> method.
+ *
+ * @param g the graphics context of the print device
+ *
+ * @see #paint(Graphics)
+ */
+ public void print(Graphics g)
+ {
+ paint(g);
+ }
+
+ /**
+ * Prints this component, including all sub-components.
+ *
+ * @param g the graphics context of the print device
+ *
+ * @see #paintAll(Graphics)
+ */
+ public void printAll(Graphics g)
+ {
+ if( peer != null )
+ peer.print( g );
+ paintAll( g );
+ }
+
+ /**
+ * Called when an image has changed so that this component is repainted.
+ * This incrementally draws an image as more bits are available, when
+ * possible. Incremental drawing is enabled if the system property
+ * <code>awt.image.incrementalDraw</code> is not present or is true, in which
+ * case the redraw rate is set to 100ms or the value of the system property
+ * <code>awt.image.redrawrate</code>.
+ *
+ * <p>The coordinate system used depends on the particular flags.
+ *
+ * @param img the image that has been updated
+ * @param flags tlags as specified in <code>ImageObserver</code>
+ * @param x the X coordinate
+ * @param y the Y coordinate
+ * @param w the width
+ * @param h the height
+ * @return false if the image is completely loaded, loading has been
+ * aborted, or an error has occurred. true if more updates are
+ * required.
+ * @see ImageObserver
+ * @see Graphics#drawImage(Image, int, int, Color, ImageObserver)
+ * @see Graphics#drawImage(Image, int, int, ImageObserver)
+ * @see Graphics#drawImage(Image, int, int, int, int, Color, ImageObserver)
+ * @see Graphics#drawImage(Image, int, int, int, int, ImageObserver)
+ * @see ImageObserver#imageUpdate(Image, int, int, int, int, int)
+ */
+ public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h)
+ {
+ if ((flags & (FRAMEBITS | ALLBITS)) != 0)
+ repaint();
+ else if ((flags & SOMEBITS) != 0)
+ {
+ if (incrementalDraw)
+ {
+ if (redrawRate != null)
+ {
+ long tm = redrawRate.longValue();
+ if (tm < 0)
+ tm = 0;
+ repaint(tm);
+ }
+ else
+ repaint(100);
+ }
+ }
+ return (flags & (ALLBITS | ABORT | ERROR)) == 0;
+ }
+
+ /**
+ * Creates an image from the specified producer.
+ *
+ * @param producer the image procedure to create the image from
+ * @return the resulting image
+ */
+ public Image createImage(ImageProducer producer)
+ {
+ // Sun allows producer to be null.
+ if (peer != null)
+ return peer.createImage(producer);
+ else
+ return getToolkit().createImage(producer);
+ }
+
+ /**
+ * Creates an image with the specified width and height for use in
+ * double buffering. Headless environments do not support images.
+ *
+ * @param width the width of the image
+ * @param height the height of the image
+ * @return the requested image, or null if it is not supported
+ */
+ public Image createImage (int width, int height)
+ {
+ Image returnValue = null;
+ if (!GraphicsEnvironment.isHeadless ())
+ {
+ if (isLightweight () && parent != null)
+ returnValue = parent.createImage (width, height);
+ else if (peer != null)
+ returnValue = peer.createImage (width, height);
+ }
+ return returnValue;
+ }
+
+ /**
+ * Creates an image with the specified width and height for use in
+ * double buffering. Headless environments do not support images.
+ *
+ * @param width the width of the image
+ * @param height the height of the image
+ * @return the requested image, or null if it is not supported
+ * @since 1.4
+ */
+ public VolatileImage createVolatileImage(int width, int height)
+ {
+ if (peer != null)
+ return peer.createVolatileImage(width, height);
+ return null;
+ }
+
+ /**
+ * Creates an image with the specified width and height for use in
+ * double buffering. Headless environments do not support images. The image
+ * will support the specified capabilities.
+ *
+ * @param width the width of the image
+ * @param height the height of the image
+ * @param caps the requested capabilities
+ * @return the requested image, or null if it is not supported
+ * @throws AWTException if a buffer with the capabilities cannot be created
+ * @since 1.4
+ */
+ public VolatileImage createVolatileImage(int width, int height,
+ ImageCapabilities caps)
+ throws AWTException
+ {
+ if (peer != null)
+ return peer.createVolatileImage(width, height);
+ return null;
+ }
+
+ /**
+ * Prepares the specified image for rendering on this component.
+ *
+ * @param image the image to prepare for rendering
+ * @param observer the observer to notify of image preparation status
+ * @return true if the image is already fully prepared
+ * @throws NullPointerException if image is null
+ */
+ public boolean prepareImage(Image image, ImageObserver observer)
+ {
+ return prepareImage(image, image.getWidth(observer),
+ image.getHeight(observer), observer);
+ }
+
+ /**
+ * Prepares the specified image for rendering on this component at the
+ * specified scaled width and height
+ *
+ * @param image the image to prepare for rendering
+ * @param width the scaled width of the image
+ * @param height the scaled height of the image
+ * @param observer the observer to notify of image preparation status
+ * @return true if the image is already fully prepared
+ */
+ public boolean prepareImage(Image image, int width, int height,
+ ImageObserver observer)
+ {
+ if (peer != null)
+ return peer.prepareImage(image, width, height, observer);
+ else
+ return getToolkit().prepareImage(image, width, height, observer);
+ }
+
+ /**
+ * Returns the status of the loading of the specified image. The value
+ * returned will be those flags defined in <code>ImageObserver</code>.
+ *
+ * @param image the image to check on
+ * @param observer the observer to notify of image loading progress
+ * @return the image observer flags indicating the status of the load
+ * @see #prepareImage(Image, int, int, ImageObserver)
+ * @see Toolkit#checkImage(Image, int, int, ImageObserver)
+ * @throws NullPointerException if image is null
+ */
+ public int checkImage(Image image, ImageObserver observer)
+ {
+ return checkImage(image, -1, -1, observer);
+ }
+
+ /**
+ * Returns the status of the loading of the specified image. The value
+ * returned will be those flags defined in <code>ImageObserver</code>.
+ *
+ * @param image the image to check on
+ * @param width the scaled image width
+ * @param height the scaled image height
+ * @param observer the observer to notify of image loading progress
+ * @return the image observer flags indicating the status of the load
+ * @see #prepareImage(Image, int, int, ImageObserver)
+ * @see Toolkit#checkImage(Image, int, int, ImageObserver)
+ */
+ public int checkImage(Image image, int width, int height,
+ ImageObserver observer)
+ {
+ if (peer != null)
+ return peer.checkImage(image, width, height, observer);
+ return getToolkit().checkImage(image, width, height, observer);
+ }
+
+ /**
+ * Sets whether paint messages delivered by the operating system should be
+ * ignored. This does not affect messages from AWT, except for those
+ * triggered by OS messages. Setting this to true can allow faster
+ * performance in full-screen mode or page-flipping.
+ *
+ * @param ignoreRepaint the new setting for ignoring repaint events
+ * @see #getIgnoreRepaint()
+ * @see BufferStrategy
+ * @see GraphicsDevice#setFullScreenWindow(Window)
+ * @since 1.4
+ */
+ public void setIgnoreRepaint(boolean ignoreRepaint)
+ {
+ this.ignoreRepaint = ignoreRepaint;
+ }
+
+ /**
+ * Test whether paint events from the operating system are ignored.
+ *
+ * @return the status of ignoring paint events
+ * @see #setIgnoreRepaint(boolean)
+ * @since 1.4
+ */
+ public boolean getIgnoreRepaint()
+ {
+ return ignoreRepaint;
+ }
+
+ /**
+ * Tests whether or not the specified point is contained within this
+ * component. Coordinates are relative to this component.
+ *
+ * @param x the X coordinate of the point to test
+ * @param y the Y coordinate of the point to test
+ * @return true if the point is within this component
+ * @see #getComponentAt(int, int)
+ */
+ public boolean contains(int x, int y)
+ {
+ return inside (x, y);
+ }
+
+ /**
+ * Tests whether or not the specified point is contained within this
+ * component. Coordinates are relative to this component.
+ *
+ * @param x the X coordinate of the point to test
+ * @param y the Y coordinate of the point to test
+ * @return true if the point is within this component
+ * @deprecated use {@link #contains(int, int)} instead
+ */
+ public boolean inside(int x, int y)
+ {
+ return x >= 0 && y >= 0 && x < width && y < height;
+ }
+
+ /**
+ * Tests whether or not the specified point is contained within this
+ * component. Coordinates are relative to this component.
+ *
+ * @param p the point to test
+ * @return true if the point is within this component
+ * @throws NullPointerException if p is null
+ * @see #getComponentAt(Point)
+ * @since 1.1
+ */
+ public boolean contains(Point p)
+ {
+ return contains (p.x, p.y);
+ }
+
+ /**
+ * Returns the component occupying the position (x,y). This will either
+ * be this component, an immediate child component, or <code>null</code>
+ * if neither of the first two occupies the specified location.
+ *
+ * @param x the X coordinate to search for components at
+ * @param y the Y coordinate to search for components at
+ * @return the component at the specified location, or null
+ * @see #contains(int, int)
+ */
+ public Component getComponentAt(int x, int y)
+ {
+ return locate (x, y);
+ }
+
+ /**
+ * Returns the component occupying the position (x,y). This will either
+ * be this component, an immediate child component, or <code>null</code>
+ * if neither of the first two occupies the specified location.
+ *
+ * @param x the X coordinate to search for components at
+ * @param y the Y coordinate to search for components at
+ * @return the component at the specified location, or null
+ * @deprecated use {@link #getComponentAt(int, int)} instead
+ */
+ public Component locate(int x, int y)
+ {
+ return contains (x, y) ? this : null;
+ }
+
+ /**
+ * Returns the component occupying the position (x,y). This will either
+ * be this component, an immediate child component, or <code>null</code>
+ * if neither of the first two occupies the specified location.
+ *
+ * @param p the point to search for components at
+ * @return the component at the specified location, or null
+ * @throws NullPointerException if p is null
+ * @see #contains(Point)
+ * @since 1.1
+ */
+ public Component getComponentAt(Point p)
+ {
+ return getComponentAt (p.x, p.y);
+ }
+
+ /**
+ * AWT 1.0 event delivery.
+ *
+ * Deliver an AWT 1.0 event to this Component. This method simply
+ * calls {@link #postEvent}.
+ *
+ * @param e the event to deliver
+ * @deprecated use {@link #dispatchEvent (AWTEvent)} instead
+ */
+ public void deliverEvent (Event e)
+ {
+ postEvent (e);
+ }
+
+ /**
+ * Forwards AWT events to processEvent() if:<ul>
+ * <li>Events have been enabled for this type of event via
+ * <code>enableEvents()</code></li>,
+ * <li>There is at least one registered listener for this type of event</li>
+ * </ul>
+ *
+ * @param e the event to dispatch
+ */
+ public final void dispatchEvent(AWTEvent e)
+ {
+ Event oldEvent = translateEvent(e);
+ if (oldEvent != null)
+ postEvent (oldEvent);
+
+ // Give toolkit a chance to dispatch the event
+ // to globally registered listeners.
+ Toolkit.getDefaultToolkit().globalDispatchEvent(e);
+
+ // Some subclasses in the AWT package need to override this behavior,
+ // hence the use of dispatchEventImpl().
+ dispatchEventImpl(e);
+ }
+
+ /**
+ * By default, no old mouse events should be ignored.
+ * This can be overridden by subclasses.
+ *
+ * @return false, no mouse events are ignored.
+ */
+ static boolean ignoreOldMouseEvents()
+ {
+ return false;
+ }
+
+ /**
+ * AWT 1.0 event handler.
+ *
+ * This method simply calls handleEvent and returns the result.
+ *
+ * @param e the event to handle
+ * @return true if the event was handled, false otherwise
+ * @deprecated use {@link #dispatchEvent(AWTEvent)} instead
+ */
+ public boolean postEvent (Event e)
+ {
+ boolean handled = handleEvent (e);
+
+ if (!handled && getParent() != null)
+ // FIXME: need to translate event coordinates to parent's
+ // coordinate space.
+ handled = getParent ().postEvent (e);
+
+ return handled;
+ }
+
+ /**
+ * Adds the specified listener to this component. This is harmless if the
+ * listener is null, but if the listener has already been registered, it
+ * will now be registered twice.
+ *
+ * @param listener the new listener to add
+ * @see ComponentEvent
+ * @see #removeComponentListener(ComponentListener)
+ * @see #getComponentListeners()
+ * @since 1.1
+ */
+ public synchronized void addComponentListener(ComponentListener listener)
+ {
+ componentListener = AWTEventMulticaster.add(componentListener, listener);
+ if (componentListener != null)
+ enableEvents(AWTEvent.COMPONENT_EVENT_MASK);
+ }
+
+ /**
+ * Removes the specified listener from the component. This is harmless if
+ * the listener was not previously registered.
+ *
+ * @param listener the listener to remove
+ * @see ComponentEvent
+ * @see #addComponentListener(ComponentListener)
+ * @see #getComponentListeners()
+ * @since 1.1
+ */
+ public synchronized void removeComponentListener(ComponentListener listener)
+ {
+ componentListener = AWTEventMulticaster.remove(componentListener, listener);
+ }
+
+ /**
+ * Returns an array of all specified listeners registered on this component.
+ *
+ * @return an array of listeners
+ * @see #addComponentListener(ComponentListener)
+ * @see #removeComponentListener(ComponentListener)
+ * @since 1.4
+ */
+ public synchronized ComponentListener[] getComponentListeners()
+ {
+ return (ComponentListener[])
+ AWTEventMulticaster.getListeners(componentListener,
+ ComponentListener.class);
+ }
+
+ /**
+ * Adds the specified listener to this component. This is harmless if the
+ * listener is null, but if the listener has already been registered, it
+ * will now be registered twice.
+ *
+ * @param listener the new listener to add
+ * @see FocusEvent
+ * @see #removeFocusListener(FocusListener)
+ * @see #getFocusListeners()
+ * @since 1.1
+ */
+ public synchronized void addFocusListener(FocusListener listener)
+ {
+ focusListener = AWTEventMulticaster.add(focusListener, listener);
+ if (focusListener != null)
+ enableEvents(AWTEvent.FOCUS_EVENT_MASK);
+ }
+
+ /**
+ * Removes the specified listener from the component. This is harmless if
+ * the listener was not previously registered.
+ *
+ * @param listener the listener to remove
+ * @see FocusEvent
+ * @see #addFocusListener(FocusListener)
+ * @see #getFocusListeners()
+ * @since 1.1
+ */
+ public synchronized void removeFocusListener(FocusListener listener)
+ {
+ focusListener = AWTEventMulticaster.remove(focusListener, listener);
+ }
+
+ /**
+ * Returns an array of all specified listeners registered on this component.
+ *
+ * @return an array of listeners
+ * @see #addFocusListener(FocusListener)
+ * @see #removeFocusListener(FocusListener)
+ * @since 1.4
+ */
+ public synchronized FocusListener[] getFocusListeners()
+ {
+ return (FocusListener[])
+ AWTEventMulticaster.getListeners(focusListener, FocusListener.class);
+ }
+
+ /**
+ * Adds the specified listener to this component. This is harmless if the
+ * listener is null, but if the listener has already been registered, it
+ * will now be registered twice.
+ *
+ * @param listener the new listener to add
+ * @see HierarchyEvent
+ * @see #removeHierarchyListener(HierarchyListener)
+ * @see #getHierarchyListeners()
+ * @since 1.3
+ */
+ public synchronized void addHierarchyListener(HierarchyListener listener)
+ {
+ hierarchyListener = AWTEventMulticaster.add(hierarchyListener, listener);
+ if (hierarchyListener != null)
+ enableEvents(AWTEvent.HIERARCHY_EVENT_MASK);
+
+ // Need to lock the tree, otherwise we might end up inconsistent.
+ synchronized (getTreeLock())
+ {
+ numHierarchyListeners++;
+ if (parent != null)
+ parent.updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK, 1);
+ }
+ }
+
+ /**
+ * Removes the specified listener from the component. This is harmless if
+ * the listener was not previously registered.
+ *
+ * @param listener the listener to remove
+ * @see HierarchyEvent
+ * @see #addHierarchyListener(HierarchyListener)
+ * @see #getHierarchyListeners()
+ * @since 1.3
+ */
+ public synchronized void removeHierarchyListener(HierarchyListener listener)
+ {
+ hierarchyListener = AWTEventMulticaster.remove(hierarchyListener, listener);
+
+ // Need to lock the tree, otherwise we might end up inconsistent.
+ synchronized (getTreeLock())
+ {
+ numHierarchyListeners--;
+ if (parent != null)
+ parent.updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
+ -1);
+ }
+ }
+
+ /**
+ * Returns an array of all specified listeners registered on this component.
+ *
+ * @return an array of listeners
+ * @see #addHierarchyListener(HierarchyListener)
+ * @see #removeHierarchyListener(HierarchyListener)
+ * @since 1.4
+ */
+ public synchronized HierarchyListener[] getHierarchyListeners()
+ {
+ return (HierarchyListener[])
+ AWTEventMulticaster.getListeners(hierarchyListener,
+ HierarchyListener.class);
+ }
+
+ /**
+ * Adds the specified listener to this component. This is harmless if the
+ * listener is null, but if the listener has already been registered, it
+ * will now be registered twice.
+ *
+ * @param listener the new listener to add
+ * @see HierarchyEvent
+ * @see #removeHierarchyBoundsListener(HierarchyBoundsListener)
+ * @see #getHierarchyBoundsListeners()
+ * @since 1.3
+ */
+ public synchronized void
+ addHierarchyBoundsListener(HierarchyBoundsListener listener)
+ {
+ hierarchyBoundsListener =
+ AWTEventMulticaster.add(hierarchyBoundsListener, listener);
+ if (hierarchyBoundsListener != null)
+ enableEvents(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK);
+
+ // Need to lock the tree, otherwise we might end up inconsistent.
+ synchronized (getTreeLock())
+ {
+ numHierarchyBoundsListeners++;
+ if (parent != null)
+ parent.updateHierarchyListenerCount
+ (AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
+ 1);
+ }
+ }
+
+ /**
+ * Removes the specified listener from the component. This is harmless if
+ * the listener was not previously registered.
+ *
+ * @param listener the listener to remove
+ * @see HierarchyEvent
+ * @see #addHierarchyBoundsListener(HierarchyBoundsListener)
+ * @see #getHierarchyBoundsListeners()
+ * @since 1.3
+ */
+ public synchronized void
+ removeHierarchyBoundsListener(HierarchyBoundsListener listener)
+ {
+ hierarchyBoundsListener =
+ AWTEventMulticaster.remove(hierarchyBoundsListener, listener);
+
+ // Need to lock the tree, otherwise we might end up inconsistent.
+ synchronized (getTreeLock())
+ {
+ numHierarchyBoundsListeners--;
+ if (parent != null)
+ parent.updateHierarchyListenerCount
+ (AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
+ -1);
+ }
+ }
+
+ /**
+ * Returns an array of all specified listeners registered on this component.
+ *
+ * @return an array of listeners
+ * @see #addHierarchyBoundsListener(HierarchyBoundsListener)
+ * @see #removeHierarchyBoundsListener(HierarchyBoundsListener)
+ * @since 1.4
+ */
+ public synchronized HierarchyBoundsListener[] getHierarchyBoundsListeners()
+ {
+ return (HierarchyBoundsListener[])
+ AWTEventMulticaster.getListeners(hierarchyBoundsListener,
+ HierarchyBoundsListener.class);
+ }
+
+ /**
+ * Fires a HierarchyEvent or HierarchyChangeEvent on this component.
+ *
+ * @param id the event id
+ * @param changed the changed component
+ * @param parent the parent
+ * @param flags the event flags
+ */
+ void fireHierarchyEvent(int id, Component changed, Container parent,
+ long flags)
+ {
+ boolean enabled = false;
+ switch (id)
+ {
+ case HierarchyEvent.HIERARCHY_CHANGED:
+ enabled = hierarchyListener != null
+ || (eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0;
+ break;
+ case HierarchyEvent.ANCESTOR_MOVED:
+ case HierarchyEvent.ANCESTOR_RESIZED:
+ enabled = hierarchyBoundsListener != null
+ || (eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0;
+ break;
+ default:
+ assert false : "Should not reach here";
+ }
+ if (enabled)
+ {
+ HierarchyEvent ev = new HierarchyEvent(this, id, changed, parent,
+ flags);
+ dispatchEvent(ev);
+ }
+ }
+
+ /**
+ * Adds the specified listener to this component. This is harmless if the
+ * listener is null, but if the listener has already been registered, it
+ * will now be registered twice.
+ *
+ * @param listener the new listener to add
+ * @see KeyEvent
+ * @see #removeKeyListener(KeyListener)
+ * @see #getKeyListeners()
+ * @since 1.1
+ */
+ public synchronized void addKeyListener(KeyListener listener)
+ {
+ keyListener = AWTEventMulticaster.add(keyListener, listener);
+ if (keyListener != null)
+ enableEvents(AWTEvent.KEY_EVENT_MASK);
+ }
+
+ /**
+ * Removes the specified listener from the component. This is harmless if
+ * the listener was not previously registered.
+ *
+ * @param listener the listener to remove
+ * @see KeyEvent
+ * @see #addKeyListener(KeyListener)
+ * @see #getKeyListeners()
+ * @since 1.1
+ */
+ public synchronized void removeKeyListener(KeyListener listener)
+ {
+ keyListener = AWTEventMulticaster.remove(keyListener, listener);
+ }
+
+ /**
+ * Returns an array of all specified listeners registered on this component.
+ *
+ * @return an array of listeners
+ * @see #addKeyListener(KeyListener)
+ * @see #removeKeyListener(KeyListener)
+ * @since 1.4
+ */
+ public synchronized KeyListener[] getKeyListeners()
+ {
+ return (KeyListener[])
+ AWTEventMulticaster.getListeners(keyListener, KeyListener.class);
+ }
+
+ /**
+ * Adds the specified listener to this component. This is harmless if the
+ * listener is null, but if the listener has already been registered, it
+ * will now be registered twice.
+ *
+ * @param listener the new listener to add
+ * @see MouseEvent
+ * @see #removeMouseListener(MouseListener)
+ * @see #getMouseListeners()
+ * @since 1.1
+ */
+ public synchronized void addMouseListener(MouseListener listener)
+ {
+ mouseListener = AWTEventMulticaster.add(mouseListener, listener);
+ if (mouseListener != null)
+ enableEvents(AWTEvent.MOUSE_EVENT_MASK);
+ }
+
+ /**
+ * Removes the specified listener from the component. This is harmless if
+ * the listener was not previously registered.
+ *
+ * @param listener the listener to remove
+ * @see MouseEvent
+ * @see #addMouseListener(MouseListener)
+ * @see #getMouseListeners()
+ * @since 1.1
+ */
+ public synchronized void removeMouseListener(MouseListener listener)
+ {
+ mouseListener = AWTEventMulticaster.remove(mouseListener, listener);
+ }
+
+ /**
+ * Returns an array of all specified listeners registered on this component.
+ *
+ * @return an array of listeners
+ * @see #addMouseListener(MouseListener)
+ * @see #removeMouseListener(MouseListener)
+ * @since 1.4
+ */
+ public synchronized MouseListener[] getMouseListeners()
+ {
+ return (MouseListener[])
+ AWTEventMulticaster.getListeners(mouseListener, MouseListener.class);
+ }
+
+ /**
+ * Adds the specified listener to this component. This is harmless if the
+ * listener is null, but if the listener has already been registered, it
+ * will now be registered twice.
+ *
+ * @param listener the new listener to add
+ * @see MouseEvent
+ * @see #removeMouseMotionListener(MouseMotionListener)
+ * @see #getMouseMotionListeners()
+ * @since 1.1
+ */
+ public synchronized void addMouseMotionListener(MouseMotionListener listener)
+ {
+ mouseMotionListener = AWTEventMulticaster.add(mouseMotionListener, listener);
+ if (mouseMotionListener != null)
+ enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK);
+ }
+
+ /**
+ * Removes the specified listener from the component. This is harmless if
+ * the listener was not previously registered.
+ *
+ * @param listener the listener to remove
+ * @see MouseEvent
+ * @see #addMouseMotionListener(MouseMotionListener)
+ * @see #getMouseMotionListeners()
+ * @since 1.1
+ */
+ public synchronized void removeMouseMotionListener(MouseMotionListener listener)
+ {
+ mouseMotionListener = AWTEventMulticaster.remove(mouseMotionListener, listener);
+ }
+
+ /**
+ * Returns an array of all specified listeners registered on this component.
+ *
+ * @return an array of listeners
+ * @see #addMouseMotionListener(MouseMotionListener)
+ * @see #removeMouseMotionListener(MouseMotionListener)
+ * @since 1.4
+ */
+ public synchronized MouseMotionListener[] getMouseMotionListeners()
+ {
+ return (MouseMotionListener[])
+ AWTEventMulticaster.getListeners(mouseMotionListener,
+ MouseMotionListener.class);
+ }
+
+ /**
+ * Adds the specified listener to this component. This is harmless if the
+ * listener is null, but if the listener has already been registered, it
+ * will now be registered twice.
+ *
+ * @param listener the new listener to add
+ * @see MouseEvent
+ * @see MouseWheelEvent
+ * @see #removeMouseWheelListener(MouseWheelListener)
+ * @see #getMouseWheelListeners()
+ * @since 1.4
+ */
+ public synchronized void addMouseWheelListener(MouseWheelListener listener)
+ {
+ mouseWheelListener = AWTEventMulticaster.add(mouseWheelListener, listener);
+ if (mouseWheelListener != null)
+ enableEvents(AWTEvent.MOUSE_WHEEL_EVENT_MASK);
+ }
+
+ /**
+ * Removes the specified listener from the component. This is harmless if
+ * the listener was not previously registered.
+ *
+ * @param listener the listener to remove
+ * @see MouseEvent
+ * @see MouseWheelEvent
+ * @see #addMouseWheelListener(MouseWheelListener)
+ * @see #getMouseWheelListeners()
+ * @since 1.4
+ */
+ public synchronized void removeMouseWheelListener(MouseWheelListener listener)
+ {
+ mouseWheelListener = AWTEventMulticaster.remove(mouseWheelListener, listener);
+ }
+
+ /**
+ * Returns an array of all specified listeners registered on this component.
+ *
+ * @return an array of listeners
+ * @see #addMouseWheelListener(MouseWheelListener)
+ * @see #removeMouseWheelListener(MouseWheelListener)
+ * @since 1.4
+ */
+ public synchronized MouseWheelListener[] getMouseWheelListeners()
+ {
+ return (MouseWheelListener[])
+ AWTEventMulticaster.getListeners(mouseWheelListener,
+ MouseWheelListener.class);
+ }
+
+ /**
+ * Adds the specified listener to this component. This is harmless if the
+ * listener is null, but if the listener has already been registered, it
+ * will now be registered twice.
+ *
+ * @param listener the new listener to add
+ * @see InputMethodEvent
+ * @see #removeInputMethodListener(InputMethodListener)
+ * @see #getInputMethodListeners()
+ * @see #getInputMethodRequests()
+ * @since 1.2
+ */
+ public synchronized void addInputMethodListener(InputMethodListener listener)
+ {
+ inputMethodListener = AWTEventMulticaster.add(inputMethodListener, listener);
+ if (inputMethodListener != null)
+ enableEvents(AWTEvent.INPUT_METHOD_EVENT_MASK);
+ }
+
+ /**
+ * Removes the specified listener from the component. This is harmless if
+ * the listener was not previously registered.
+ *
+ * @param listener the listener to remove
+ * @see InputMethodEvent
+ * @see #addInputMethodListener(InputMethodListener)
+ * @see #getInputMethodRequests()
+ * @since 1.2
+ */
+ public synchronized void removeInputMethodListener(InputMethodListener listener)
+ {
+ inputMethodListener = AWTEventMulticaster.remove(inputMethodListener, listener);
+ }
+
+ /**
+ * Returns an array of all specified listeners registered on this component.
+ *
+ * @return an array of listeners
+ * @see #addInputMethodListener(InputMethodListener)
+ * @see #removeInputMethodListener(InputMethodListener)
+ * @since 1.4
+ */
+ public synchronized InputMethodListener[] getInputMethodListeners()
+ {
+ return (InputMethodListener[])
+ AWTEventMulticaster.getListeners(inputMethodListener,
+ InputMethodListener.class);
+ }
+
+ /**
+ * Returns all registered {@link EventListener}s of the given
+ * <code>listenerType</code>.
+ *
+ * @param listenerType the class of listeners to filter (<code>null</code>
+ * not permitted).
+ *
+ * @return An array of registered listeners.
+ *
+ * @throws ClassCastException if <code>listenerType</code> does not implement
+ * the {@link EventListener} interface.
+ * @throws NullPointerException if <code>listenerType</code> is
+ * <code>null</code>.
+ *
+ * @see #getComponentListeners()
+ * @see #getFocusListeners()
+ * @see #getHierarchyListeners()
+ * @see #getHierarchyBoundsListeners()
+ * @see #getKeyListeners()
+ * @see #getMouseListeners()
+ * @see #getMouseMotionListeners()
+ * @see #getMouseWheelListeners()
+ * @see #getInputMethodListeners()
+ * @see #getPropertyChangeListeners()
+ * @since 1.3
+ */
+ public EventListener[] getListeners(Class listenerType)
+ {
+ if (listenerType == ComponentListener.class)
+ return getComponentListeners();
+ if (listenerType == FocusListener.class)
+ return getFocusListeners();
+ if (listenerType == HierarchyListener.class)
+ return getHierarchyListeners();
+ if (listenerType == HierarchyBoundsListener.class)
+ return getHierarchyBoundsListeners();
+ if (listenerType == KeyListener.class)
+ return getKeyListeners();
+ if (listenerType == MouseListener.class)
+ return getMouseListeners();
+ if (listenerType == MouseMotionListener.class)
+ return getMouseMotionListeners();
+ if (listenerType == MouseWheelListener.class)
+ return getMouseWheelListeners();
+ if (listenerType == InputMethodListener.class)
+ return getInputMethodListeners();
+ if (listenerType == PropertyChangeListener.class)
+ return getPropertyChangeListeners();
+ return (EventListener[]) Array.newInstance(listenerType, 0);
+ }
+
+ /**
+ * Returns the input method request handler, for subclasses which support
+ * on-the-spot text input. By default, input methods are handled by AWT,
+ * and this returns null.
+ *
+ * @return the input method handler, null by default
+ * @since 1.2
+ */
+ public InputMethodRequests getInputMethodRequests()
+ {
+ return null;
+ }
+
+ /**
+ * Gets the input context of this component, which is inherited from the
+ * parent unless this is overridden.
+ *
+ * @return the text input context
+ * @since 1.2
+ */
+ public InputContext getInputContext()
+ {
+ return parent == null ? null : parent.getInputContext();
+ }
+
+ /**
+ * Enables the specified events. The events to enable are specified
+ * by OR-ing together the desired masks from <code>AWTEvent</code>.
+ *
+ * <p>Events are enabled by default when a listener is attached to the
+ * component for that event type. This method can be used by subclasses
+ * to ensure the delivery of a specified event regardless of whether
+ * or not a listener is attached.
+ *
+ * @param eventsToEnable the desired events to enable
+ * @see #processEvent(AWTEvent)
+ * @see #disableEvents(long)
+ * @see AWTEvent
+ * @since 1.1
+ */
+ protected final void enableEvents(long eventsToEnable)
+ {
+ eventMask |= eventsToEnable;
+ // TODO: Unlike Sun's implementation, I think we should try and
+ // enable/disable events at the peer (gtk/X) level. This will avoid
+ // clogging the event pipeline with useless mousemove events that
+ // we arn't interested in, etc. This will involve extending the peer
+ // interface, but thats okay because the peer interfaces have been
+ // deprecated for a long time, and no longer feature in the
+ // API specification at all.
+ if (isLightweight() && parent != null)
+ parent.enableEvents(eventsToEnable);
+ else if (peer != null)
+ peer.setEventMask(eventMask);
+ }
+
+ /**
+ * Disables the specified events. The events to disable are specified
+ * by OR-ing together the desired masks from <code>AWTEvent</code>.
+ *
+ * @param eventsToDisable the desired events to disable
+ * @see #enableEvents(long)
+ * @since 1.1
+ */
+ protected final void disableEvents(long eventsToDisable)
+ {
+ eventMask &= ~eventsToDisable;
+ // forward new event mask to peer?
+ }
+
+ /**
+ * This is called by the EventQueue if two events with the same event id
+ * and owner component are queued. Returns a new combined event, or null if
+ * no combining is done. The coelesced events are currently mouse moves
+ * (intermediate ones are discarded) and paint events (a merged paint is
+ * created in place of the two events).
+ *
+ * @param existingEvent the event on the queue
+ * @param newEvent the new event that might be entered on the queue
+ * @return null if both events are kept, or the replacement coelesced event
+ */
+ protected AWTEvent coalesceEvents(AWTEvent existingEvent, AWTEvent newEvent)
+ {
+ switch (existingEvent.id)
+ {
+ case MouseEvent.MOUSE_MOVED:
+ case MouseEvent.MOUSE_DRAGGED:
+ // Just drop the old (intermediate) event and return the new one.
+ return newEvent;
+ case PaintEvent.PAINT:
+ case PaintEvent.UPDATE:
+ return coalescePaintEvents((PaintEvent) existingEvent,
+ (PaintEvent) newEvent);
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Processes the specified event. In this class, this method simply
+ * calls one of the more specific event handlers.
+ *
+ * @param e the event to process
+ * @throws NullPointerException if e is null
+ * @see #processComponentEvent(ComponentEvent)
+ * @see #processFocusEvent(FocusEvent)
+ * @see #processKeyEvent(KeyEvent)
+ * @see #processMouseEvent(MouseEvent)
+ * @see #processMouseMotionEvent(MouseEvent)
+ * @see #processInputMethodEvent(InputMethodEvent)
+ * @see #processHierarchyEvent(HierarchyEvent)
+ * @see #processMouseWheelEvent(MouseWheelEvent)
+ * @since 1.1
+ */
+ protected void processEvent(AWTEvent e)
+ {
+ /* Note: the order of these if statements are
+ important. Subclasses must be checked first. Eg. MouseEvent
+ must be checked before ComponentEvent, since a MouseEvent
+ object is also an instance of a ComponentEvent. */
+
+ if (e instanceof FocusEvent)
+ processFocusEvent((FocusEvent) e);
+ else if (e instanceof MouseWheelEvent)
+ processMouseWheelEvent((MouseWheelEvent) e);
+ else if (e instanceof MouseEvent)
+ {
+ if (e.id == MouseEvent.MOUSE_MOVED
+ || e.id == MouseEvent.MOUSE_DRAGGED)
+ processMouseMotionEvent((MouseEvent) e);
+ else
+ processMouseEvent((MouseEvent) e);
+ }
+ else if (e instanceof KeyEvent)
+ processKeyEvent((KeyEvent) e);
+ else if (e instanceof InputMethodEvent)
+ processInputMethodEvent((InputMethodEvent) e);
+ else if (e instanceof ComponentEvent)
+ processComponentEvent((ComponentEvent) e);
+ else if (e instanceof HierarchyEvent)
+ {
+ if (e.id == HierarchyEvent.HIERARCHY_CHANGED)
+ processHierarchyEvent((HierarchyEvent) e);
+ else
+ processHierarchyBoundsEvent((HierarchyEvent) e);
+ }
+ }
+
+ /**
+ * Called when a component event is dispatched and component events are
+ * enabled. This method passes the event along to any listeners
+ * that are attached.
+ *
+ * @param e the <code>ComponentEvent</code> to process
+ * @throws NullPointerException if e is null
+ * @see ComponentListener
+ * @see #addComponentListener(ComponentListener)
+ * @see #enableEvents(long)
+ * @since 1.1
+ */
+ protected void processComponentEvent(ComponentEvent e)
+ {
+ if (componentListener == null)
+ return;
+ switch (e.id)
+ {
+ case ComponentEvent.COMPONENT_HIDDEN:
+ componentListener.componentHidden(e);
+ break;
+ case ComponentEvent.COMPONENT_MOVED:
+ componentListener.componentMoved(e);
+ break;
+ case ComponentEvent.COMPONENT_RESIZED:
+ componentListener.componentResized(e);
+ break;
+ case ComponentEvent.COMPONENT_SHOWN:
+ componentListener.componentShown(e);
+ break;
+ }
+ }
+
+ /**
+ * Called when a focus event is dispatched and component events are
+ * enabled. This method passes the event along to any listeners
+ * that are attached.
+ *
+ * @param e the <code>FocusEvent</code> to process
+ * @throws NullPointerException if e is null
+ * @see FocusListener
+ * @see #addFocusListener(FocusListener)
+ * @see #enableEvents(long)
+ * @since 1.1
+ */
+ protected void processFocusEvent(FocusEvent e)
+ {
+ if (focusListener == null)
+ return;
+
+ switch (e.id)
+ {
+ case FocusEvent.FOCUS_GAINED:
+ focusListener.focusGained(e);
+ break;
+ case FocusEvent.FOCUS_LOST:
+ focusListener.focusLost(e);
+ break;
+ }
+ }
+
+ /**
+ * Called when a key event is dispatched and component events are
+ * enabled. This method passes the event along to any listeners
+ * that are attached.
+ *
+ * @param e the <code>KeyEvent</code> to process
+ * @throws NullPointerException if e is null
+ * @see KeyListener
+ * @see #addKeyListener(KeyListener)
+ * @see #enableEvents(long)
+ * @since 1.1
+ */
+ protected void processKeyEvent(KeyEvent e)
+ {
+ if (keyListener == null)
+ return;
+ switch (e.id)
+ {
+ case KeyEvent.KEY_PRESSED:
+ keyListener.keyPressed(e);
+ break;
+ case KeyEvent.KEY_RELEASED:
+ keyListener.keyReleased(e);
+ break;
+ case KeyEvent.KEY_TYPED:
+ keyListener.keyTyped(e);
+ break;
+ }
+ }
+
+ /**
+ * Called when a regular mouse event is dispatched and component events are
+ * enabled. This method passes the event along to any listeners
+ * that are attached.
+ *
+ * @param e the <code>MouseEvent</code> to process
+ * @throws NullPointerException if e is null
+ * @see MouseListener
+ * @see #addMouseListener(MouseListener)
+ * @see #enableEvents(long)
+ * @since 1.1
+ */
+ protected void processMouseEvent(MouseEvent e)
+ {
+ if (mouseListener == null)
+ return;
+ switch (e.id)
+ {
+ case MouseEvent.MOUSE_CLICKED:
+ mouseListener.mouseClicked(e);
+ break;
+ case MouseEvent.MOUSE_ENTERED:
+ if( isLightweight() )
+ setCursor( getCursor() );
+ mouseListener.mouseEntered(e);
+ break;
+ case MouseEvent.MOUSE_EXITED:
+ mouseListener.mouseExited(e);
+ break;
+ case MouseEvent.MOUSE_PRESSED:
+ mouseListener.mousePressed(e);
+ break;
+ case MouseEvent.MOUSE_RELEASED:
+ mouseListener.mouseReleased(e);
+ break;
+ }
+ }
+
+ /**
+ * Called when a mouse motion event is dispatched and component events are
+ * enabled. This method passes the event along to any listeners
+ * that are attached.
+ *
+ * @param e the <code>MouseMotionEvent</code> to process
+ * @throws NullPointerException if e is null
+ * @see MouseMotionListener
+ * @see #addMouseMotionListener(MouseMotionListener)
+ * @see #enableEvents(long)
+ * @since 1.1
+ */
+ protected void processMouseMotionEvent(MouseEvent e)
+ {
+ if (mouseMotionListener == null)
+ return;
+ switch (e.id)
+ {
+ case MouseEvent.MOUSE_DRAGGED:
+ mouseMotionListener.mouseDragged(e);
+ break;
+ case MouseEvent.MOUSE_MOVED:
+ mouseMotionListener.mouseMoved(e);
+ break;
+ }
+ e.consume();
+ }
+
+ /**
+ * Called when a mouse wheel event is dispatched and component events are
+ * enabled. This method passes the event along to any listeners that are
+ * attached.
+ *
+ * @param e the <code>MouseWheelEvent</code> to process
+ * @throws NullPointerException if e is null
+ * @see MouseWheelListener
+ * @see #addMouseWheelListener(MouseWheelListener)
+ * @see #enableEvents(long)
+ * @since 1.4
+ */
+ protected void processMouseWheelEvent(MouseWheelEvent e)
+ {
+ if (mouseWheelListener != null
+ && e.id == MouseEvent.MOUSE_WHEEL)
+ {
+ mouseWheelListener.mouseWheelMoved(e);
+ e.consume();
+ }
+ }
+
+ /**
+ * Called when an input method event is dispatched and component events are
+ * enabled. This method passes the event along to any listeners that are
+ * attached.
+ *
+ * @param e the <code>InputMethodEvent</code> to process
+ * @throws NullPointerException if e is null
+ * @see InputMethodListener
+ * @see #addInputMethodListener(InputMethodListener)
+ * @see #enableEvents(long)
+ * @since 1.2
+ */
+ protected void processInputMethodEvent(InputMethodEvent e)
+ {
+ if (inputMethodListener == null)
+ return;
+ switch (e.id)
+ {
+ case InputMethodEvent.CARET_POSITION_CHANGED:
+ inputMethodListener.caretPositionChanged(e);
+ break;
+ case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
+ inputMethodListener.inputMethodTextChanged(e);
+ break;
+ }
+ }
+
+ /**
+ * Called when a hierarchy change event is dispatched and component events
+ * are enabled. This method passes the event along to any listeners that are
+ * attached.
+ *
+ * @param e the <code>HierarchyEvent</code> to process
+ * @throws NullPointerException if e is null
+ * @see HierarchyListener
+ * @see #addHierarchyListener(HierarchyListener)
+ * @see #enableEvents(long)
+ * @since 1.3
+ */
+ protected void processHierarchyEvent(HierarchyEvent e)
+ {
+ if (hierarchyListener == null)
+ return;
+ if (e.id == HierarchyEvent.HIERARCHY_CHANGED)
+ hierarchyListener.hierarchyChanged(e);
+ }
+
+ /**
+ * Called when a hierarchy bounds event is dispatched and component events
+ * are enabled. This method passes the event along to any listeners that are
+ * attached.
+ *
+ * @param e the <code>HierarchyEvent</code> to process
+ * @throws NullPointerException if e is null
+ * @see HierarchyBoundsListener
+ * @see #addHierarchyBoundsListener(HierarchyBoundsListener)
+ * @see #enableEvents(long)
+ * @since 1.3
+ */
+ protected void processHierarchyBoundsEvent(HierarchyEvent e)
+ {
+ if (hierarchyBoundsListener == null)
+ return;
+ switch (e.id)
+ {
+ case HierarchyEvent.ANCESTOR_MOVED:
+ hierarchyBoundsListener.ancestorMoved(e);
+ break;
+ case HierarchyEvent.ANCESTOR_RESIZED:
+ hierarchyBoundsListener.ancestorResized(e);
+ break;
+ }
+ }
+
+ /**
+ * AWT 1.0 event handler.
+ *
+ * This method calls one of the event-specific handler methods. For
+ * example for key events, either {@link #keyDown(Event,int)}
+ * or {@link #keyUp(Event,int)} is called. A derived
+ * component can override one of these event-specific methods if it
+ * only needs to handle certain event types. Otherwise it can
+ * override handleEvent itself and handle any event.
+ *
+ * @param evt the event to handle
+ * @return true if the event was handled, false otherwise
+ * @deprecated use {@link #processEvent(AWTEvent)} instead
+ */
+ public boolean handleEvent (Event evt)
+ {
+ switch (evt.id)
+ {
+ // Handle key events.
+ case Event.KEY_ACTION:
+ case Event.KEY_PRESS:
+ return keyDown (evt, evt.key);
+ case Event.KEY_ACTION_RELEASE:
+ case Event.KEY_RELEASE:
+ return keyUp (evt, evt.key);
+
+ // Handle mouse events.
+ case Event.MOUSE_DOWN:
+ return mouseDown (evt, evt.x, evt.y);
+ case Event.MOUSE_UP:
+ return mouseUp (evt, evt.x, evt.y);
+ case Event.MOUSE_MOVE:
+ return mouseMove (evt, evt.x, evt.y);
+ case Event.MOUSE_DRAG:
+ return mouseDrag (evt, evt.x, evt.y);
+ case Event.MOUSE_ENTER:
+ return mouseEnter (evt, evt.x, evt.y);
+ case Event.MOUSE_EXIT:
+ return mouseExit (evt, evt.x, evt.y);
+
+ // Handle focus events.
+ case Event.GOT_FOCUS:
+ return gotFocus (evt, evt.arg);
+ case Event.LOST_FOCUS:
+ return lostFocus (evt, evt.arg);
+
+ // Handle action event.
+ case Event.ACTION_EVENT:
+ return action (evt, evt.arg);
+ }
+ // Unknown event.
+ return false;
+ }
+
+ /**
+ * AWT 1.0 MOUSE_DOWN event handler. This method is meant to be
+ * overridden by components providing their own MOUSE_DOWN handler.
+ * The default implementation simply returns false.
+ *
+ * @param evt the event to handle
+ * @param x the x coordinate, ignored
+ * @param y the y coordinate, ignored
+ * @return false
+ * @deprecated use {@link #processMouseEvent(MouseEvent)} instead
+ */
+ public boolean mouseDown(Event evt, int x, int y)
+ {
+ return false;
+ }
+
+ /**
+ * AWT 1.0 MOUSE_DRAG event handler. This method is meant to be
+ * overridden by components providing their own MOUSE_DRAG handler.
+ * The default implementation simply returns false.
+ *
+ * @param evt the event to handle
+ * @param x the x coordinate, ignored
+ * @param y the y coordinate, ignored
+ * @return false
+ * @deprecated use {@link #processMouseMotionEvent(MouseEvent)} instead
+ */
+ public boolean mouseDrag(Event evt, int x, int y)
+ {
+ return false;
+ }
+
+ /**
+ * AWT 1.0 MOUSE_UP event handler. This method is meant to be
+ * overridden by components providing their own MOUSE_UP handler.
+ * The default implementation simply returns false.
+ *
+ * @param evt the event to handle
+ * @param x the x coordinate, ignored
+ * @param y the y coordinate, ignored
+ * @return false
+ * @deprecated use {@link #processMouseEvent(MouseEvent)} instead
+ */
+ public boolean mouseUp(Event evt, int x, int y)
+ {
+ return false;
+ }
+
+ /**
+ * AWT 1.0 MOUSE_MOVE event handler. This method is meant to be
+ * overridden by components providing their own MOUSE_MOVE handler.
+ * The default implementation simply returns false.
+ *
+ * @param evt the event to handle
+ * @param x the x coordinate, ignored
+ * @param y the y coordinate, ignored
+ * @return false
+ * @deprecated use {@link #processMouseMotionEvent(MouseEvent)} instead
+ */
+ public boolean mouseMove(Event evt, int x, int y)
+ {
+ return false;
+ }
+
+ /**
+ * AWT 1.0 MOUSE_ENTER event handler. This method is meant to be
+ * overridden by components providing their own MOUSE_ENTER handler.
+ * The default implementation simply returns false.
+ *
+ * @param evt the event to handle
+ * @param x the x coordinate, ignored
+ * @param y the y coordinate, ignored
+ * @return false
+ * @deprecated use {@link #processMouseEvent(MouseEvent)} instead
+ */
+ public boolean mouseEnter(Event evt, int x, int y)
+ {
+ return false;
+ }
+
+ /**
+ * AWT 1.0 MOUSE_EXIT event handler. This method is meant to be
+ * overridden by components providing their own MOUSE_EXIT handler.
+ * The default implementation simply returns false.
+ *
+ * @param evt the event to handle
+ * @param x the x coordinate, ignored
+ * @param y the y coordinate, ignored
+ * @return false
+ * @deprecated use {@link #processMouseEvent(MouseEvent)} instead
+ */
+ public boolean mouseExit(Event evt, int x, int y)
+ {
+ return false;
+ }
+
+ /**
+ * AWT 1.0 KEY_PRESS and KEY_ACTION event handler. This method is
+ * meant to be overridden by components providing their own key
+ * press handler. The default implementation simply returns false.
+ *
+ * @param evt the event to handle
+ * @param key the key pressed, ignored
+ * @return false
+ * @deprecated use {@link #processKeyEvent(KeyEvent)} instead
+ */
+ public boolean keyDown(Event evt, int key)
+ {
+ return false;
+ }
+
+ /**
+ * AWT 1.0 KEY_RELEASE and KEY_ACTION_RELEASE event handler. This
+ * method is meant to be overridden by components providing their
+ * own key release handler. The default implementation simply
+ * returns false.
+ *
+ * @param evt the event to handle
+ * @param key the key pressed, ignored
+ * @return false
+ * @deprecated use {@link #processKeyEvent(KeyEvent)} instead
+ */
+ public boolean keyUp(Event evt, int key)
+ {
+ return false;
+ }
+
+ /**
+ * AWT 1.0 ACTION_EVENT event handler. This method is meant to be
+ * overridden by components providing their own action event
+ * handler. The default implementation simply returns false.
+ *
+ * @param evt the event to handle
+ * @param what the object acted on, ignored
+ * @return false
+ * @deprecated in classes which support actions, use
+ * <code>processActionEvent(ActionEvent)</code> instead
+ */
+ public boolean action(Event evt, Object what)
+ {
+ return false;
+ }
+
+ /**
+ * Called when the parent of this Component is made visible or when
+ * the Component is added to an already visible Container and needs
+ * to be shown. A native peer - if any - is created at this
+ * time. This method is called automatically by the AWT system and
+ * should not be called by user level code.
+ *
+ * @see #isDisplayable()
+ * @see #removeNotify()
+ */
+ public void addNotify()
+ {
+ // We need to lock the tree here to avoid races and inconsistencies.
+ synchronized (getTreeLock())
+ {
+ if (peer == null)
+ peer = getToolkit().createComponent(this);
+ else if (parent != null && parent.isLightweight())
+ new HeavyweightInLightweightListener(parent);
+ /* Now that all the children has gotten their peers, we should
+ have the event mask needed for this component and its
+ lightweight subcomponents. */
+ peer.setEventMask(eventMask);
+ /* We do not invalidate here, but rather leave that job up to
+ the peer. For efficiency, the peer can choose not to
+ invalidate if it is happy with the current dimensions,
+ etc. */
+ if (dropTarget != null)
+ dropTarget.addNotify(peer);
+ }
+ }
+
+ /**
+ * Called to inform this component is has been removed from its
+ * container. Its native peer - if any - is destroyed at this time.
+ * This method is called automatically by the AWT system and should
+ * not be called by user level code.
+ *
+ * @see #isDisplayable()
+ * @see #addNotify()
+ */
+ public void removeNotify()
+ {
+ // We need to lock the tree here to avoid races and inconsistencies.
+ synchronized (getTreeLock())
+ {
+ // We null our peer field before disposing of it, such that if we're
+ // not the event dispatch thread and the dispatch thread is awoken by
+ // the dispose call, there will be no race checking the peer's null
+ // status.
+
+ ComponentPeer tmp = peer;
+ peer = null;
+ if (tmp != null)
+ {
+ tmp.hide();
+ tmp.dispose();
+ }
+ }
+ }
+
+ /**
+ * AWT 1.0 GOT_FOCUS event handler. This method is meant to be
+ * overridden by components providing their own GOT_FOCUS handler.
+ * The default implementation simply returns false.
+ *
+ * @param evt the event to handle
+ * @param what the Object focused, ignored
+ * @return false
+ * @deprecated use {@link #processFocusEvent(FocusEvent)} instead
+ */
+ public boolean gotFocus(Event evt, Object what)
+ {
+ return false;
+ }
+
+ /**
+ * AWT 1.0 LOST_FOCUS event handler. This method is meant to be
+ * overridden by components providing their own LOST_FOCUS handler.
+ * The default implementation simply returns false.
+ *
+ * @param evt the event to handle
+ * @param what the Object focused, ignored
+ * @return false
+ * @deprecated use {@link #processFocusEvent(FocusEvent)} instead
+ */
+ public boolean lostFocus(Event evt, Object what)
+ {
+ return false;
+ }
+
+ /**
+ * Tests whether or not this component is in the group that can be
+ * traversed using the keyboard traversal mechanism (such as the TAB key).
+ *
+ * @return true if the component is traversed via the TAB key
+ * @see #setFocusable(boolean)
+ * @since 1.1
+ * @deprecated use {@link #isFocusable()} instead
+ */
+ public boolean isFocusTraversable()
+ {
+ return enabled && visible && (peer == null || isLightweight() || peer.isFocusTraversable());
+ }
+
+ /**
+ * Tests if this component can receive focus.
+ *
+ * @return true if this component can receive focus
+ * @since 1.4
+ */
+ public boolean isFocusable()
+ {
+ return focusable;
+ }
+
+ /**
+ * Specify whether this component can receive focus. This method also
+ * sets the {@link #isFocusTraversableOverridden} field to 1, which
+ * appears to be the undocumented way {@link
+ * DefaultFocusTraversalPolicy#accept(Component)} determines whether to
+ * respect the {@link #isFocusable()} method of the component.
+ *
+ * @param focusable the new focusable status
+ * @since 1.4
+ */
+ public void setFocusable(boolean focusable)
+ {
+ firePropertyChange("focusable", this.focusable, focusable);
+ this.focusable = focusable;
+ this.isFocusTraversableOverridden = 1;
+ }
+
+ /**
+ * Sets the focus traversal keys for one of the three focus
+ * traversal directions supported by Components:
+ * {@link KeyboardFocusManager#FORWARD_TRAVERSAL_KEYS},
+ * {@link KeyboardFocusManager#BACKWARD_TRAVERSAL_KEYS}, or
+ * {@link KeyboardFocusManager#UP_CYCLE_TRAVERSAL_KEYS}. Normally, the
+ * default values should match the operating system's native
+ * choices. To disable a given traversal, use
+ * <code>Collections.EMPTY_SET</code>. The event dispatcher will
+ * consume PRESSED, RELEASED, and TYPED events for the specified
+ * key, although focus can only transfer on PRESSED or RELEASED.
+ *
+ * <p>The defaults are:
+ * <table>
+ * <th><td>Identifier</td><td>Meaning</td><td>Default</td></th>
+ * <tr><td>KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS</td>
+ * <td>Normal forward traversal</td>
+ * <td>TAB on KEY_PRESSED, Ctrl-TAB on KEY_PRESSED</td></tr>
+ * <tr><td>KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS</td>
+ * <td>Normal backward traversal</td>
+ * <td>Shift-TAB on KEY_PRESSED, Ctrl-Shift-TAB on KEY_PRESSED</td></tr>
+ * <tr><td>KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS</td>
+ * <td>Go up a traversal cycle</td><td>None</td></tr>
+ * </table>
+ *
+ * If keystrokes is null, this component's focus traversal key set
+ * is inherited from one of its ancestors. If none of its ancestors
+ * has its own set of focus traversal keys, the focus traversal keys
+ * are set to the defaults retrieved from the current
+ * KeyboardFocusManager. If not null, the set must contain only
+ * AWTKeyStrokes that are not already focus keys and are not
+ * KEY_TYPED events.
+ *
+ * @param id one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS, or
+ * UP_CYCLE_TRAVERSAL_KEYS
+ * @param keystrokes a set of keys, or null
+ * @throws IllegalArgumentException if id or keystrokes is invalid
+ * @see #getFocusTraversalKeys(int)
+ * @see KeyboardFocusManager#FORWARD_TRAVERSAL_KEYS
+ * @see KeyboardFocusManager#BACKWARD_TRAVERSAL_KEYS
+ * @see KeyboardFocusManager#UP_CYCLE_TRAVERSAL_KEYS
+ * @since 1.4
+ */
+ public void setFocusTraversalKeys(int id, Set keystrokes)
+ {
+ if (keystrokes == null)
+ {
+ Container parent = getParent ();
+
+ while (parent != null)
+ {
+ if (parent.areFocusTraversalKeysSet (id))
+ {
+ keystrokes = parent.getFocusTraversalKeys (id);
+ break;
+ }
+ parent = parent.getParent ();
+ }
+
+ if (keystrokes == null)
+ keystrokes = KeyboardFocusManager.getCurrentKeyboardFocusManager ().
+ getDefaultFocusTraversalKeys (id);
+ }
+
+ Set sa;
+ Set sb;
+ String name;
+ switch (id)
+ {
+ case KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS:
+ sa = getFocusTraversalKeys
+ (KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
+ sb = getFocusTraversalKeys
+ (KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS);
+ name = "forwardFocusTraversalKeys";
+ break;
+ case KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS:
+ sa = getFocusTraversalKeys
+ (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
+ sb = getFocusTraversalKeys
+ (KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS);
+ name = "backwardFocusTraversalKeys";
+ break;
+ case KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS:
+ sa = getFocusTraversalKeys
+ (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
+ sb = getFocusTraversalKeys
+ (KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
+ name = "upCycleFocusTraversalKeys";
+ break;
+ default:
+ throw new IllegalArgumentException ();
+ }
+
+ int i = keystrokes.size ();
+ Iterator iter = keystrokes.iterator ();
+
+ while (--i >= 0)
+ {
+ Object o = iter.next ();
+ if (!(o instanceof AWTKeyStroke)
+ || sa.contains (o) || sb.contains (o)
+ || ((AWTKeyStroke) o).keyCode == KeyEvent.VK_UNDEFINED)
+ throw new IllegalArgumentException ();
+ }
+
+ if (focusTraversalKeys == null)
+ focusTraversalKeys = new Set[3];
+
+ keystrokes = Collections.unmodifiableSet (new HashSet (keystrokes));
+ firePropertyChange (name, focusTraversalKeys[id], keystrokes);
+
+ focusTraversalKeys[id] = keystrokes;
+ }
+
+ /**
+ * Returns the set of keys for a given focus traversal action, as
+ * defined in <code>setFocusTraversalKeys</code>. If not set, this
+ * is inherited from the parent component, which may have gotten it
+ * from the KeyboardFocusManager.
+ *
+ * @param id one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS,
+ * or UP_CYCLE_TRAVERSAL_KEYS
+ *
+ * @return set of traversal keys
+ *
+ * @throws IllegalArgumentException if id is invalid
+ *
+ * @see #setFocusTraversalKeys (int, Set)
+ * @see KeyboardFocusManager#FORWARD_TRAVERSAL_KEYS
+ * @see KeyboardFocusManager#BACKWARD_TRAVERSAL_KEYS
+ * @see KeyboardFocusManager#UP_CYCLE_TRAVERSAL_KEYS
+ *
+ * @since 1.4
+ */
+ public Set getFocusTraversalKeys (int id)
+ {
+ if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&
+ id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&
+ id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS)
+ throw new IllegalArgumentException();
+
+ Set s = null;
+
+ if (focusTraversalKeys != null)
+ s = focusTraversalKeys[id];
+
+ if (s == null && parent != null)
+ s = parent.getFocusTraversalKeys (id);
+
+ return s == null ? (KeyboardFocusManager.getCurrentKeyboardFocusManager()
+ .getDefaultFocusTraversalKeys(id)) : s;
+ }
+
+ /**
+ * Tests whether the focus traversal keys for a given action are explicitly
+ * set or inherited.
+ *
+ * @param id one of FORWARD_TRAVERSAL_KEYS, BACKWARD_TRAVERSAL_KEYS,
+ * or UP_CYCLE_TRAVERSAL_KEYS
+ * @return true if that set is explicitly specified
+ * @throws IllegalArgumentException if id is invalid
+ * @see #getFocusTraversalKeys (int)
+ * @see KeyboardFocusManager#FORWARD_TRAVERSAL_KEYS
+ * @see KeyboardFocusManager#BACKWARD_TRAVERSAL_KEYS
+ * @see KeyboardFocusManager#UP_CYCLE_TRAVERSAL_KEYS
+ * @since 1.4
+ */
+ public boolean areFocusTraversalKeysSet (int id)
+ {
+ if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&
+ id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&
+ id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS)
+ throw new IllegalArgumentException ();
+
+ return focusTraversalKeys != null && focusTraversalKeys[id] != null;
+ }
+
+ /**
+ * Enable or disable focus traversal keys on this Component. If
+ * they are, then the keyboard focus manager consumes and acts on
+ * key press and release events that trigger focus traversal, and
+ * discards the corresponding key typed events. If focus traversal
+ * keys are disabled, then all key events that would otherwise
+ * trigger focus traversal are sent to this Component.
+ *
+ * @param focusTraversalKeysEnabled the new value of the flag
+ * @see #getFocusTraversalKeysEnabled ()
+ * @see #setFocusTraversalKeys (int, Set)
+ * @see #getFocusTraversalKeys (int)
+ * @since 1.4
+ */
+ public void setFocusTraversalKeysEnabled (boolean focusTraversalKeysEnabled)
+ {
+ firePropertyChange ("focusTraversalKeysEnabled",
+ this.focusTraversalKeysEnabled,
+ focusTraversalKeysEnabled);
+ this.focusTraversalKeysEnabled = focusTraversalKeysEnabled;
+ }
+
+ /**
+ * Check whether or not focus traversal keys are enabled on this
+ * Component. If they are, then the keyboard focus manager consumes
+ * and acts on key press and release events that trigger focus
+ * traversal, and discards the corresponding key typed events. If
+ * focus traversal keys are disabled, then all key events that would
+ * otherwise trigger focus traversal are sent to this Component.
+ *
+ * @return true if focus traversal keys are enabled
+ * @see #setFocusTraversalKeysEnabled (boolean)
+ * @see #setFocusTraversalKeys (int, Set)
+ * @see #getFocusTraversalKeys (int)
+ * @since 1.4
+ */
+ public boolean getFocusTraversalKeysEnabled ()
+ {
+ return focusTraversalKeysEnabled;
+ }
+
+ /**
+ * Request that this Component be given the keyboard input focus and
+ * that its top-level ancestor become the focused Window.
+ *
+ * For the request to be granted, the Component must be focusable,
+ * displayable and showing and the top-level Window to which it
+ * belongs must be focusable. If the request is initially denied on
+ * the basis that the top-level Window is not focusable, the request
+ * will be remembered and granted when the Window does become
+ * focused.
+ *
+ * Never assume that this Component is the focus owner until it
+ * receives a FOCUS_GAINED event.
+ *
+ * The behaviour of this method is platform-dependent.
+ * {@link #requestFocusInWindow()} should be used instead.
+ *
+ * @see #requestFocusInWindow ()
+ * @see FocusEvent
+ * @see #addFocusListener (FocusListener)
+ * @see #isFocusable ()
+ * @see #isDisplayable ()
+ * @see KeyboardFocusManager#clearGlobalFocusOwner ()
+ */
+ public void requestFocus ()
+ {
+ requestFocusImpl(false, true);
+ }
+
+ /**
+ * Request that this Component be given the keyboard input focus and
+ * that its top-level ancestor become the focused Window.
+ *
+ * For the request to be granted, the Component must be focusable,
+ * displayable and showing and the top-level Window to which it
+ * belongs must be focusable. If the request is initially denied on
+ * the basis that the top-level Window is not focusable, the request
+ * will be remembered and granted when the Window does become
+ * focused.
+ *
+ * Never assume that this Component is the focus owner until it
+ * receives a FOCUS_GAINED event.
+ *
+ * The behaviour of this method is platform-dependent.
+ * {@link #requestFocusInWindow()} should be used instead.
+ *
+ * If the return value is false, the request is guaranteed to fail.
+ * If the return value is true, the request will succeed unless it
+ * is vetoed or something in the native windowing system intervenes,
+ * preventing this Component's top-level ancestor from becoming
+ * focused. This method is meant to be called by derived
+ * lightweight Components that want to avoid unnecessary repainting
+ * when they know a given focus transfer need only be temporary.
+ *
+ * @param temporary true if the focus request is temporary
+ * @return true if the request has a chance of success
+ * @see #requestFocusInWindow ()
+ * @see FocusEvent
+ * @see #addFocusListener (FocusListener)
+ * @see #isFocusable ()
+ * @see #isDisplayable ()
+ * @see KeyboardFocusManager#clearGlobalFocusOwner ()
+ * @since 1.4
+ */
+ protected boolean requestFocus (boolean temporary)
+ {
+ return requestFocusImpl(temporary, true);
+ }
+
+ /**
+ * Request that this component be given the keyboard input focus, if
+ * its top-level ancestor is the currently focused Window. A
+ * <code>FOCUS_GAINED</code> event will be fired if and only if this
+ * request is successful. To be successful, the component must be
+ * displayable, showing, and focusable, and its ancestor top-level
+ * Window must be focused.
+ *
+ * If the return value is false, the request is guaranteed to fail.
+ * If the return value is true, the request will succeed unless it
+ * is vetoed or something in the native windowing system intervenes,
+ * preventing this Component's top-level ancestor from becoming
+ * focused.
+ *
+ * @return true if the request has a chance of success
+ * @see #requestFocus ()
+ * @see FocusEvent
+ * @see #addFocusListener (FocusListener)
+ * @see #isFocusable ()
+ * @see #isDisplayable ()
+ * @see KeyboardFocusManager#clearGlobalFocusOwner ()
+ * @since 1.4
+ */
+ public boolean requestFocusInWindow ()
+ {
+ return requestFocusImpl(false, false);
+ }
+
+ /**
+ * Request that this component be given the keyboard input focus, if
+ * its top-level ancestor is the currently focused Window. A
+ * <code>FOCUS_GAINED</code> event will be fired if and only if this
+ * request is successful. To be successful, the component must be
+ * displayable, showing, and focusable, and its ancestor top-level
+ * Window must be focused.
+ *
+ * If the return value is false, the request is guaranteed to fail.
+ * If the return value is true, the request will succeed unless it
+ * is vetoed or something in the native windowing system intervenes,
+ * preventing this Component's top-level ancestor from becoming
+ * focused. This method is meant to be called by derived
+ * lightweight Components that want to avoid unnecessary repainting
+ * when they know a given focus transfer need only be temporary.
+ *
+ * @param temporary true if the focus request is temporary
+ * @return true if the request has a chance of success
+ * @see #requestFocus ()
+ * @see FocusEvent
+ * @see #addFocusListener (FocusListener)
+ * @see #isFocusable ()
+ * @see #isDisplayable ()
+ * @see KeyboardFocusManager#clearGlobalFocusOwner ()
+ * @since 1.4
+ */
+ protected boolean requestFocusInWindow (boolean temporary)
+ {
+ return requestFocusImpl(temporary, false);
+ }
+
+ /**
+ * Helper method for all 4 requestFocus variants.
+ *
+ * @param temporary indicates if the focus change is temporary
+ * @param focusWindow indicates if the window focus may be changed
+ *
+ * @return <code>false</code> if the request has been definitely denied,
+ * <code>true</code> otherwise
+ */
+ private boolean requestFocusImpl(boolean temporary, boolean focusWindow)
+ {
+ boolean retval = false;
+
+ // Don't try to focus non-focusable and non-visible components.
+ if (isFocusable() && isVisible())
+ {
+ ComponentPeer myPeer = peer;
+ if (peer != null)
+ {
+ // Find Window ancestor and find out if we're showing while
+ // doing this.
+ boolean showing = true;
+ Component window = this;
+ while (! (window instanceof Window))
+ {
+ if (! window.isVisible())
+ showing = false;
+ window = window.parent;
+ }
+ // Don't allow focus when there is no window or the window
+ // is not focusable.
+ if (window != null && ((Window) window).isFocusableWindow()
+ && showing)
+ {
+ // Search for nearest heavy ancestor (including this
+ // component).
+ Component heavyweightParent = this;
+ while (heavyweightParent.peer instanceof LightweightPeer)
+ heavyweightParent = heavyweightParent.parent;
+
+ // Don't allow focus on lightweight components without
+ // visible heavyweight ancestor
+ if (heavyweightParent != null && heavyweightParent.isVisible())
+ {
+ // Don't allow focus when heavyweightParent has no peer.
+ myPeer = heavyweightParent.peer;
+ if (myPeer != null)
+ {
+ // Register lightweight focus request.
+ if (heavyweightParent != this)
+ {
+ KeyboardFocusManager
+ .addLightweightFocusRequest(heavyweightParent,
+ this);
+ }
+
+ // Try to focus the component.
+ long time = EventQueue.getMostRecentEventTime();
+ boolean success = myPeer.requestFocus(this, temporary,
+ focusWindow,
+ time);
+ if (! success)
+ {
+ // Dequeue key events if focus request failed.
+ KeyboardFocusManager kfm =
+ KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ kfm.dequeueKeyEvents(time, this);
+ }
+ retval = success;
+ }
+ }
+ }
+ }
+ }
+ return retval;
+ }
+
+ /**
+ * Transfers focus to the next component in the focus traversal
+ * order, as though this were the current focus owner.
+ *
+ * @see #requestFocus()
+ * @since 1.1
+ */
+ public void transferFocus ()
+ {
+ nextFocus ();
+ }
+
+ /**
+ * Returns the root container that owns the focus cycle where this
+ * component resides. A focus cycle root is in two cycles, one as
+ * the ancestor, and one as the focusable element; this call always
+ * returns the ancestor.
+ *
+ * @return the ancestor container that owns the focus cycle
+ * @since 1.4
+ */
+ public Container getFocusCycleRootAncestor ()
+ {
+ Container parent = getParent ();
+
+ while (parent != null && !parent.isFocusCycleRoot())
+ parent = parent.getParent ();
+
+ return parent;
+ }
+
+ /**
+ * Tests if the container is the ancestor of the focus cycle that
+ * this component belongs to.
+ *
+ * @param c the container to test
+ * @return true if c is the focus cycle root
+ * @since 1.4
+ */
+ public boolean isFocusCycleRoot (Container c)
+ {
+ return c == getFocusCycleRootAncestor ();
+ }
+
+ /**
+ * AWT 1.0 focus event processor. Transfers focus to the next
+ * component in the focus traversal order, as though this were the
+ * current focus owner.
+ *
+ * @deprecated use {@link #transferFocus ()} instead
+ */
+ public void nextFocus ()
+ {
+ // Find the nearest valid (== showing && focusable && enabled) focus
+ // cycle root ancestor and the focused component in it.
+ Container focusRoot = getFocusCycleRootAncestor();
+ Component focusComp = this;
+ while (focusRoot != null
+ && ! (focusRoot.isShowing() && focusRoot.isFocusable()
+ && focusRoot.isEnabled()))
+ {
+ focusComp = focusRoot;
+ focusRoot = focusComp.getFocusCycleRootAncestor();
+ }
+
+ if (focusRoot != null)
+ {
+ // First try to get the componentBefore from the policy.
+ FocusTraversalPolicy policy = focusRoot.getFocusTraversalPolicy();
+ Component nextFocus = policy.getComponentAfter(focusRoot, focusComp);
+
+ // If this fails, then ask for the defaultComponent.
+ if (nextFocus == null)
+ nextFocus = policy.getDefaultComponent(focusRoot);
+
+ // Request focus on this component, if not null.
+ if (nextFocus != null)
+ nextFocus.requestFocus();
+ }
+ }
+
+ /**
+ * Transfers focus to the previous component in the focus traversal
+ * order, as though this were the current focus owner.
+ *
+ * @see #requestFocus ()
+ * @since 1.4
+ */
+ public void transferFocusBackward ()
+ {
+ // Find the nearest valid (== showing && focusable && enabled) focus
+ // cycle root ancestor and the focused component in it.
+ Container focusRoot = getFocusCycleRootAncestor();
+ Component focusComp = this;
+ while (focusRoot != null
+ && ! (focusRoot.isShowing() && focusRoot.isFocusable()
+ && focusRoot.isEnabled()))
+ {
+ focusComp = focusRoot;
+ focusRoot = focusComp.getFocusCycleRootAncestor();
+ }
+
+ if (focusRoot != null)
+ {
+ // First try to get the componentBefore from the policy.
+ FocusTraversalPolicy policy = focusRoot.getFocusTraversalPolicy();
+ Component nextFocus = policy.getComponentBefore(focusRoot, focusComp);
+
+ // If this fails, then ask for the defaultComponent.
+ if (nextFocus == null)
+ nextFocus = policy.getDefaultComponent(focusRoot);
+
+ // Request focus on this component, if not null.
+ if (nextFocus != null)
+ nextFocus.requestFocus();
+ }
+ }
+
+ /**
+ * Transfers focus to the focus cycle root of this component.
+ * However, if this is a Window, the default focus owner in the
+ * window in the current focus cycle is focused instead.
+ *
+ * @see #requestFocus()
+ * @see #isFocusCycleRoot(Container)
+ * @since 1.4
+ */
+ public void transferFocusUpCycle ()
+ {
+ // Find the nearest focus cycle root ancestor that is itself
+ // focusable, showing and enabled.
+ Container focusCycleRoot = getFocusCycleRootAncestor();
+ while (focusCycleRoot != null &&
+ ! (focusCycleRoot.isShowing() && focusCycleRoot.isFocusable()
+ && focusCycleRoot.isEnabled()))
+ {
+ focusCycleRoot = focusCycleRoot.getFocusCycleRootAncestor();
+ }
+
+ KeyboardFocusManager fm =
+ KeyboardFocusManager.getCurrentKeyboardFocusManager();
+
+ if (focusCycleRoot != null)
+ {
+ // If we found a focus cycle root, then we make this the new
+ // focused component, and make it's focus cycle root the new
+ // global focus cycle root. If the found root has no focus cycle
+ // root ancestor itself, then the component will be both the focused
+ // component and the new global focus cycle root.
+ Container focusCycleAncestor =
+ focusCycleRoot.getFocusCycleRootAncestor();
+ Container globalFocusCycleRoot;
+ if (focusCycleAncestor == null)
+ globalFocusCycleRoot = focusCycleRoot;
+ else
+ globalFocusCycleRoot = focusCycleAncestor;
+
+ fm.setGlobalCurrentFocusCycleRoot(globalFocusCycleRoot);
+ focusCycleRoot.requestFocus();
+ }
+ else
+ {
+ // If this component has no applicable focus cycle root, we try
+ // find the nearest window and set this as the new global focus cycle
+ // root and the default focus component of this window the new focused
+ // component.
+ Container cont;
+ if (this instanceof Container)
+ cont = (Container) this;
+ else
+ cont = getParent();
+
+ while (cont != null && !(cont instanceof Window))
+ cont = cont.getParent();
+
+ if (cont != null)
+ {
+ FocusTraversalPolicy policy = cont.getFocusTraversalPolicy();
+ Component focusComp = policy.getDefaultComponent(cont);
+ if (focusComp != null)
+ {
+ fm.setGlobalCurrentFocusCycleRoot(cont);
+ focusComp.requestFocus();
+ }
+ }
+ }
+ }
+
+ /**
+ * Tests if this component is the focus owner. Use {@link
+ * #isFocusOwner ()} instead.
+ *
+ * @return true if this component owns focus
+ * @since 1.2
+ */
+ public boolean hasFocus ()
+ {
+ KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
+
+ Component focusOwner = manager.getFocusOwner ();
+
+ return this == focusOwner;
+ }
+
+ /**
+ * Tests if this component is the focus owner.
+ *
+ * @return true if this component owns focus
+ * @since 1.4
+ */
+ public boolean isFocusOwner()
+ {
+ return hasFocus ();
+ }
+
+ /**
+ * Adds the specified popup menu to this component.
+ *
+ * @param popup the popup menu to be added
+ *
+ * @see #remove(MenuComponent)
+ *
+ * @since 1.1
+ */
+ public synchronized void add(PopupMenu popup)
+ {
+ if (popups == null)
+ popups = new Vector();
+ popups.add(popup);
+
+ if (popup.parent != null)
+ popup.parent.remove(popup);
+ popup.parent = this;
+ if (peer != null)
+ popup.addNotify();
+ }
+
+ /**
+ * Removes the specified popup menu from this component.
+ *
+ * @param popup the popup menu to remove
+ * @see #add(PopupMenu)
+ * @since 1.1
+ */
+ public synchronized void remove(MenuComponent popup)
+ {
+ if (popups != null)
+ popups.remove(popup);
+ }
+
+ /**
+ * Returns a debugging string representing this component. The string may
+ * be empty but not null.
+ *
+ * @return a string representing this component
+ */
+ protected String paramString()
+ {
+ StringBuffer param = new StringBuffer();
+ String name = getName();
+ if (name != null)
+ param.append(name).append(",");
+ param.append(x).append(",").append(y).append(",").append(width)
+ .append("x").append(height);
+ if (! isValid())
+ param.append(",invalid");
+ if (! isVisible())
+ param.append(",invisible");
+ if (! isEnabled())
+ param.append(",disabled");
+ if (! isOpaque())
+ param.append(",translucent");
+ if (isDoubleBuffered())
+ param.append(",doublebuffered");
+ if (parent == null)
+ param.append(",parent=null");
+ else
+ param.append(",parent=").append(parent.getName());
+ return param.toString();
+ }
+
+ /**
+ * Returns a string representation of this component. This is implemented
+ * as <code>getClass().getName() + '[' + paramString() + ']'</code>.
+ *
+ * @return a string representation of this component
+ */
+ public String toString()
+ {
+ return getClass().getName() + '[' + paramString() + ']';
+ }
+
+ /**
+ * Prints a listing of this component to <code>System.out</code>.
+ *
+ * @see #list(PrintStream)
+ */
+ public void list()
+ {
+ list(System.out, 0);
+ }
+
+ /**
+ * Prints a listing of this component to the specified print stream.
+ *
+ * @param out the <code>PrintStream</code> to print to
+ */
+ public void list(PrintStream out)
+ {
+ list(out, 0);
+ }
+
+ /**
+ * Prints a listing of this component to the specified print stream,
+ * starting at the specified indentation point.
+ *
+ * @param out the <code>PrintStream</code> to print to
+ * @param indent the indentation point
+ */
+ public void list(PrintStream out, int indent)
+ {
+ for (int i = 0; i < indent; ++i)
+ out.print(' ');
+ out.println(toString());
+ }
+
+ /**
+ * Prints a listing of this component to the specified print writer.
+ *
+ * @param out the <code>PrintWrinter</code> to print to
+ * @since 1.1
+ */
+ public void list(PrintWriter out)
+ {
+ list(out, 0);
+ }
+
+ /**
+ * Prints a listing of this component to the specified print writer,
+ * starting at the specified indentation point.
+ *
+ * @param out the <code>PrintWriter</code> to print to
+ * @param indent the indentation point
+ * @since 1.1
+ */
+ public void list(PrintWriter out, int indent)
+ {
+ for (int i = 0; i < indent; ++i)
+ out.print(' ');
+ out.println(toString());
+ }
+
+ /**
+ * Adds the specified property listener to this component. This is harmless
+ * if the listener is null, but if the listener has already been registered,
+ * it will now be registered twice. The property listener ignores inherited
+ * properties. Recognized properties include:<br>
+ * <ul>
+ * <li>the font (<code>"font"</code>)</li>
+ * <li>the background color (<code>"background"</code>)</li>
+ * <li>the foreground color (<code>"foreground"</code>)</li>
+ * <li>the focusability (<code>"focusable"</code>)</li>
+ * <li>the focus key traversal enabled state
+ * (<code>"focusTraversalKeysEnabled"</code>)</li>
+ * <li>the set of forward traversal keys
+ * (<code>"forwardFocusTraversalKeys"</code>)</li>
+ * <li>the set of backward traversal keys
+ * (<code>"backwardFocusTraversalKeys"</code>)</li>
+ * <li>the set of up-cycle traversal keys
+ * (<code>"upCycleFocusTraversalKeys"</code>)</li>
+ * </ul>
+ *
+ * @param listener the new listener to add
+ * @see #removePropertyChangeListener(PropertyChangeListener)
+ * @see #getPropertyChangeListeners()
+ * @see #addPropertyChangeListener(String, PropertyChangeListener)
+ * @since 1.1
+ */
+ public void addPropertyChangeListener(PropertyChangeListener listener)
+ {
+ if (changeSupport == null)
+ changeSupport = new PropertyChangeSupport(this);
+ changeSupport.addPropertyChangeListener(listener);
+ }
+
+ /**
+ * Removes the specified property listener from the component. This is
+ * harmless if the listener was not previously registered.
+ *
+ * @param listener the listener to remove
+ * @see #addPropertyChangeListener(PropertyChangeListener)
+ * @see #getPropertyChangeListeners()
+ * @see #removePropertyChangeListener(String, PropertyChangeListener)
+ * @since 1.1
+ */
+ public void removePropertyChangeListener(PropertyChangeListener listener)
+ {
+ if (changeSupport != null)
+ changeSupport.removePropertyChangeListener(listener);
+ }
+
+ /**
+ * Returns an array of all specified listeners registered on this component.
+ *
+ * @return an array of listeners
+ * @see #addPropertyChangeListener(PropertyChangeListener)
+ * @see #removePropertyChangeListener(PropertyChangeListener)
+ * @see #getPropertyChangeListeners(String)
+ * @since 1.4
+ */
+ public PropertyChangeListener[] getPropertyChangeListeners()
+ {
+ return changeSupport == null ? new PropertyChangeListener[0]
+ : changeSupport.getPropertyChangeListeners();
+ }
+
+ /**
+ * Adds the specified property listener to this component. This is harmless
+ * if the listener is null, but if the listener has already been registered,
+ * it will now be registered twice. The property listener ignores inherited
+ * properties. The listener is keyed to a single property. Recognized
+ * properties include:<br>
+ * <ul>
+ * <li>the font (<code>"font"</code>)</li>
+ * <li>the background color (<code>"background"</code>)</li>
+ * <li>the foreground color (<code>"foreground"</code>)</li>
+ * <li>the focusability (<code>"focusable"</code>)</li>
+ * <li>the focus key traversal enabled state
+ * (<code>"focusTraversalKeysEnabled"</code>)</li>
+ * <li>the set of forward traversal keys
+ * (<code>"forwardFocusTraversalKeys"</code>)</li>
+p * <li>the set of backward traversal keys
+ * (<code>"backwardFocusTraversalKeys"</code>)</li>
+ * <li>the set of up-cycle traversal keys
+ * (<code>"upCycleFocusTraversalKeys"</code>)</li>
+ * </ul>
+ *
+ * @param propertyName the property name to filter on
+ * @param listener the new listener to add
+ * @see #removePropertyChangeListener(String, PropertyChangeListener)
+ * @see #getPropertyChangeListeners(String)
+ * @see #addPropertyChangeListener(PropertyChangeListener)
+ * @since 1.1
+ */
+ public void addPropertyChangeListener(String propertyName,
+ PropertyChangeListener listener)
+ {
+ if (changeSupport == null)
+ changeSupport = new PropertyChangeSupport(this);
+ changeSupport.addPropertyChangeListener(propertyName, listener);
+ }
+
+ /**
+ * Removes the specified property listener on a particular property from
+ * the component. This is harmless if the listener was not previously
+ * registered.
+ *
+ * @param propertyName the property name to filter on
+ * @param listener the listener to remove
+ * @see #addPropertyChangeListener(String, PropertyChangeListener)
+ * @see #getPropertyChangeListeners(String)
+ * @see #removePropertyChangeListener(PropertyChangeListener)
+ * @since 1.1
+ */
+ public void removePropertyChangeListener(String propertyName,
+ PropertyChangeListener listener)
+ {
+ if (changeSupport != null)
+ changeSupport.removePropertyChangeListener(propertyName, listener);
+ }
+
+ /**
+ * Returns an array of all specified listeners on the named property that
+ * are registered on this component.
+ *
+ * @return an array of listeners
+ * @see #addPropertyChangeListener(String, PropertyChangeListener)
+ * @see #removePropertyChangeListener(String, PropertyChangeListener)
+ * @see #getPropertyChangeListeners()
+ * @since 1.4
+ */
+ public PropertyChangeListener[] getPropertyChangeListeners(String property)
+ {
+ return changeSupport == null ? new PropertyChangeListener[0]
+ : changeSupport.getPropertyChangeListeners(property);
+ }
+
+ /**
+ * Report a change in a bound property to any registered property listeners.
+ *
+ * @param propertyName the property that changed
+ * @param oldValue the old property value
+ * @param newValue the new property value
+ */
+ protected void firePropertyChange(String propertyName, Object oldValue,
+ Object newValue)
+ {
+ if (changeSupport != null)
+ changeSupport.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ /**
+ * Report a change in a bound property to any registered property listeners.
+ *
+ * @param propertyName the property that changed
+ * @param oldValue the old property value
+ * @param newValue the new property value
+ */
+ protected void firePropertyChange(String propertyName, boolean oldValue,
+ boolean newValue)
+ {
+ if (changeSupport != null)
+ changeSupport.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ /**
+ * Report a change in a bound property to any registered property listeners.
+ *
+ * @param propertyName the property that changed
+ * @param oldValue the old property value
+ * @param newValue the new property value
+ */
+ protected void firePropertyChange(String propertyName, int oldValue,
+ int newValue)
+ {
+ if (changeSupport != null)
+ changeSupport.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ /**
+ * Report a change in a bound property to any registered property listeners.
+ *
+ * @param propertyName the property that changed
+ * @param oldValue the old property value
+ * @param newValue the new property value
+ *
+ * @since 1.5
+ */
+ public void firePropertyChange(String propertyName, byte oldValue,
+ byte newValue)
+ {
+ if (changeSupport != null)
+ changeSupport.firePropertyChange(propertyName, new Byte(oldValue),
+ new Byte(newValue));
+ }
+
+ /**
+ * Report a change in a bound property to any registered property listeners.
+ *
+ * @param propertyName the property that changed
+ * @param oldValue the old property value
+ * @param newValue the new property value
+ *
+ * @since 1.5
+ */
+ public void firePropertyChange(String propertyName, char oldValue,
+ char newValue)
+ {
+ if (changeSupport != null)
+ changeSupport.firePropertyChange(propertyName, new Character(oldValue),
+ new Character(newValue));
+ }
+
+ /**
+ * Report a change in a bound property to any registered property listeners.
+ *
+ * @param propertyName the property that changed
+ * @param oldValue the old property value
+ * @param newValue the new property value
+ *
+ * @since 1.5
+ */
+ public void firePropertyChange(String propertyName, short oldValue,
+ short newValue)
+ {
+ if (changeSupport != null)
+ changeSupport.firePropertyChange(propertyName, new Short(oldValue),
+ new Short(newValue));
+ }
+
+ /**
+ * Report a change in a bound property to any registered property listeners.
+ *
+ * @param propertyName the property that changed
+ * @param oldValue the old property value
+ * @param newValue the new property value
+ *
+ * @since 1.5
+ */
+ public void firePropertyChange(String propertyName, long oldValue,
+ long newValue)
+ {
+ if (changeSupport != null)
+ changeSupport.firePropertyChange(propertyName, new Long(oldValue),
+ new Long(newValue));
+ }
+
+ /**
+ * Report a change in a bound property to any registered property listeners.
+ *
+ * @param propertyName the property that changed
+ * @param oldValue the old property value
+ * @param newValue the new property value
+ *
+ * @since 1.5
+ */
+ public void firePropertyChange(String propertyName, float oldValue,
+ float newValue)
+ {
+ if (changeSupport != null)
+ changeSupport.firePropertyChange(propertyName, new Float(oldValue),
+ new Float(newValue));
+ }
+
+
+ /**
+ * Report a change in a bound property to any registered property listeners.
+ *
+ * @param propertyName the property that changed
+ * @param oldValue the old property value
+ * @param newValue the new property value
+ *
+ * @since 1.5
+ */
+ public void firePropertyChange(String propertyName, double oldValue,
+ double newValue)
+ {
+ if (changeSupport != null)
+ changeSupport.firePropertyChange(propertyName, new Double(oldValue),
+ new Double(newValue));
+ }
+
+ /**
+ * Sets the text layout orientation of this component. New components default
+ * to UNKNOWN (which behaves like LEFT_TO_RIGHT). This method affects only
+ * the current component, while
+ * {@link #applyComponentOrientation(ComponentOrientation)} affects the
+ * entire hierarchy.
+ *
+ * @param o the new orientation (<code>null</code> is accepted)
+ * @see #getComponentOrientation()
+ */
+ public void setComponentOrientation(ComponentOrientation o)
+ {
+
+ ComponentOrientation oldOrientation = orientation;
+ orientation = o;
+ firePropertyChange("componentOrientation", oldOrientation, o);
+ }
+
+ /**
+ * Determines the text layout orientation used by this component.
+ *
+ * @return the component orientation (this can be <code>null</code>)
+ * @see #setComponentOrientation(ComponentOrientation)
+ */
+ public ComponentOrientation getComponentOrientation()
+ {
+ return orientation;
+ }
+
+ /**
+ * Sets the text layout orientation of this component. New components default
+ * to UNKNOWN (which behaves like LEFT_TO_RIGHT). This method affects the
+ * entire hierarchy, while
+ * {@link #setComponentOrientation(ComponentOrientation)} affects only the
+ * current component.
+ *
+ * @param o the new orientation
+ * @throws NullPointerException if o is null
+ * @see #getComponentOrientation()
+ * @since 1.4
+ */
+ public void applyComponentOrientation(ComponentOrientation o)
+ {
+ setComponentOrientation(o);
+ }
+
+ /**
+ * Returns the accessibility framework context of this class. Component is
+ * not accessible, so the default implementation returns null. Subclasses
+ * must override this behavior, and return an appropriate subclass of
+ * {@link AccessibleAWTComponent}.
+ *
+ * @return the accessibility context
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ return null;
+ }
+
+
+ // Helper methods; some are package visible for use by subclasses.
+
+ /**
+ * Subclasses should override this to return unique component names like
+ * "menuitem0".
+ *
+ * @return the generated name for this component
+ */
+ String generateName()
+ {
+ // Component is abstract.
+ return null;
+ }
+
+ /**
+ * Sets the peer for this component.
+ *
+ * @param peer the new peer
+ */
+ final void setPeer(ComponentPeer peer)
+ {
+ this.peer = peer;
+ }
+
+ /**
+ * Implementation method that allows classes such as Canvas and Window to
+ * override the graphics configuration without violating the published API.
+ *
+ * @return the graphics configuration
+ */
+ GraphicsConfiguration getGraphicsConfigurationImpl()
+ {
+ if (peer != null)
+ {
+ GraphicsConfiguration config = peer.getGraphicsConfiguration();
+ if (config != null)
+ return config;
+ }
+
+ if (parent != null)
+ return parent.getGraphicsConfiguration();
+
+ return null;
+ }
+
+ /**
+ * Translate an AWT 1.1 event ({@link AWTEvent}) into an AWT 1.0
+ * event ({@link Event}).
+ *
+ * @param e an AWT 1.1 event to translate
+ *
+ * @return an AWT 1.0 event representing e
+ */
+ static Event translateEvent (AWTEvent e)
+ {
+ Object target = e.getSource ();
+ Event translated = null;
+
+ if (e instanceof WindowEvent)
+ {
+ WindowEvent we = (WindowEvent) e;
+ int id = we.id;
+ int newId = 0;
+
+ switch (id)
+ {
+ case WindowEvent.WINDOW_DEICONIFIED:
+ newId = Event.WINDOW_DEICONIFY;
+ break;
+ case WindowEvent.WINDOW_CLOSED:
+ case WindowEvent.WINDOW_CLOSING:
+ newId = Event.WINDOW_DESTROY;
+ break;
+ case WindowEvent.WINDOW_ICONIFIED:
+ newId = Event.WINDOW_ICONIFY;
+ break;
+ case WindowEvent.WINDOW_GAINED_FOCUS:
+ newId = Event.GOT_FOCUS;
+ break;
+ case WindowEvent.WINDOW_LOST_FOCUS:
+ newId = Event.LOST_FOCUS;
+ break;
+ default:
+ return null;
+ }
+
+ translated = new Event(target, 0, newId, 0, 0, 0, 0);
+ }
+ else if (e instanceof InputEvent)
+ {
+ InputEvent ie = (InputEvent) e;
+ long when = ie.getWhen ();
+
+ int oldID = 0;
+ int id = e.getID ();
+
+ int oldMods = 0;
+ int mods = ie.getModifiersEx ();
+
+ if ((mods & InputEvent.BUTTON2_DOWN_MASK) != 0)
+ oldMods |= Event.META_MASK;
+ else if ((mods & InputEvent.BUTTON3_DOWN_MASK) != 0)
+ oldMods |= Event.ALT_MASK;
+
+ if ((mods & InputEvent.SHIFT_DOWN_MASK) != 0)
+ oldMods |= Event.SHIFT_MASK;
+
+ if ((mods & InputEvent.CTRL_DOWN_MASK) != 0)
+ oldMods |= Event.CTRL_MASK;
+
+ if ((mods & InputEvent.META_DOWN_MASK) != 0)
+ oldMods |= Event.META_MASK;
+
+ if ((mods & InputEvent.ALT_DOWN_MASK) != 0)
+ oldMods |= Event.ALT_MASK;
+
+ if (e instanceof MouseEvent && !ignoreOldMouseEvents())
+ {
+ if (id == MouseEvent.MOUSE_PRESSED)
+ oldID = Event.MOUSE_DOWN;
+ else if (id == MouseEvent.MOUSE_RELEASED)
+ oldID = Event.MOUSE_UP;
+ else if (id == MouseEvent.MOUSE_MOVED)
+ oldID = Event.MOUSE_MOVE;
+ else if (id == MouseEvent.MOUSE_DRAGGED)
+ oldID = Event.MOUSE_DRAG;
+ else if (id == MouseEvent.MOUSE_ENTERED)
+ oldID = Event.MOUSE_ENTER;
+ else if (id == MouseEvent.MOUSE_EXITED)
+ oldID = Event.MOUSE_EXIT;
+ else
+ // No analogous AWT 1.0 mouse event.
+ return null;
+
+ MouseEvent me = (MouseEvent) e;
+
+ translated = new Event (target, when, oldID,
+ me.getX (), me.getY (), 0, oldMods);
+ }
+ else if (e instanceof KeyEvent)
+ {
+ if (id == KeyEvent.KEY_PRESSED)
+ oldID = Event.KEY_PRESS;
+ else if (e.getID () == KeyEvent.KEY_RELEASED)
+ oldID = Event.KEY_RELEASE;
+ else
+ // No analogous AWT 1.0 key event.
+ return null;
+
+ int oldKey = 0;
+ int newKey = ((KeyEvent) e).getKeyCode ();
+ switch (newKey)
+ {
+ case KeyEvent.VK_BACK_SPACE:
+ oldKey = Event.BACK_SPACE;
+ break;
+ case KeyEvent.VK_CAPS_LOCK:
+ oldKey = Event.CAPS_LOCK;
+ break;
+ case KeyEvent.VK_DELETE:
+ oldKey = Event.DELETE;
+ break;
+ case KeyEvent.VK_DOWN:
+ case KeyEvent.VK_KP_DOWN:
+ oldKey = Event.DOWN;
+ break;
+ case KeyEvent.VK_END:
+ oldKey = Event.END;
+ break;
+ case KeyEvent.VK_ENTER:
+ oldKey = Event.ENTER;
+ break;
+ case KeyEvent.VK_ESCAPE:
+ oldKey = Event.ESCAPE;
+ break;
+ case KeyEvent.VK_F1:
+ oldKey = Event.F1;
+ break;
+ case KeyEvent.VK_F10:
+ oldKey = Event.F10;
+ break;
+ case KeyEvent.VK_F11:
+ oldKey = Event.F11;
+ break;
+ case KeyEvent.VK_F12:
+ oldKey = Event.F12;
+ break;
+ case KeyEvent.VK_F2:
+ oldKey = Event.F2;
+ break;
+ case KeyEvent.VK_F3:
+ oldKey = Event.F3;
+ break;
+ case KeyEvent.VK_F4:
+ oldKey = Event.F4;
+ break;
+ case KeyEvent.VK_F5:
+ oldKey = Event.F5;
+ break;
+ case KeyEvent.VK_F6:
+ oldKey = Event.F6;
+ break;
+ case KeyEvent.VK_F7:
+ oldKey = Event.F7;
+ break;
+ case KeyEvent.VK_F8:
+ oldKey = Event.F8;
+ break;
+ case KeyEvent.VK_F9:
+ oldKey = Event.F9;
+ break;
+ case KeyEvent.VK_HOME:
+ oldKey = Event.HOME;
+ break;
+ case KeyEvent.VK_INSERT:
+ oldKey = Event.INSERT;
+ break;
+ case KeyEvent.VK_LEFT:
+ case KeyEvent.VK_KP_LEFT:
+ oldKey = Event.LEFT;
+ break;
+ case KeyEvent.VK_NUM_LOCK:
+ oldKey = Event.NUM_LOCK;
+ break;
+ case KeyEvent.VK_PAUSE:
+ oldKey = Event.PAUSE;
+ break;
+ case KeyEvent.VK_PAGE_DOWN:
+ oldKey = Event.PGDN;
+ break;
+ case KeyEvent.VK_PAGE_UP:
+ oldKey = Event.PGUP;
+ break;
+ case KeyEvent.VK_PRINTSCREEN:
+ oldKey = Event.PRINT_SCREEN;
+ break;
+ case KeyEvent.VK_RIGHT:
+ case KeyEvent.VK_KP_RIGHT:
+ oldKey = Event.RIGHT;
+ break;
+ case KeyEvent.VK_SCROLL_LOCK:
+ oldKey = Event.SCROLL_LOCK;
+ break;
+ case KeyEvent.VK_TAB:
+ oldKey = Event.TAB;
+ break;
+ case KeyEvent.VK_UP:
+ case KeyEvent.VK_KP_UP:
+ oldKey = Event.UP;
+ break;
+ default:
+ oldKey = (int) ((KeyEvent) e).getKeyChar();
+ }
+
+ translated = new Event (target, when, oldID,
+ 0, 0, oldKey, oldMods);
+ }
+ }
+ else if (e instanceof AdjustmentEvent)
+ {
+ AdjustmentEvent ae = (AdjustmentEvent) e;
+ int type = ae.getAdjustmentType();
+ int oldType;
+ if (type == AdjustmentEvent.BLOCK_DECREMENT)
+ oldType = Event.SCROLL_PAGE_UP;
+ else if (type == AdjustmentEvent.BLOCK_INCREMENT)
+ oldType = Event.SCROLL_PAGE_DOWN;
+ else if (type == AdjustmentEvent.TRACK)
+ oldType = Event.SCROLL_ABSOLUTE;
+ else if (type == AdjustmentEvent.UNIT_DECREMENT)
+ oldType = Event.SCROLL_LINE_UP;
+ else if (type == AdjustmentEvent.UNIT_INCREMENT)
+ oldType = Event.SCROLL_LINE_DOWN;
+ else
+ oldType = type;
+ translated = new Event(target, oldType, new Integer(ae.getValue()));
+ }
+ else if (e instanceof ActionEvent)
+ translated = new Event (target, Event.ACTION_EVENT,
+ ((ActionEvent) e).getActionCommand ());
+
+ return translated;
+ }
+
+ /**
+ * Implementation of dispatchEvent. Allows trusted package classes
+ * to dispatch additional events first. This implementation first
+ * translates <code>e</code> to an AWT 1.0 event and sends the
+ * result to {@link #postEvent}. If the AWT 1.0 event is not
+ * handled, and events of type <code>e</code> are enabled for this
+ * component, e is passed on to {@link #processEvent}.
+ *
+ * @param e the event to dispatch
+ */
+
+ void dispatchEventImpl(AWTEvent e)
+ {
+ // Retarget focus events before dispatching it to the KeyboardFocusManager
+ // in order to handle lightweight components properly.
+ boolean dispatched = false;
+ if (! e.isFocusManagerEvent)
+ {
+ e = KeyboardFocusManager.retargetFocusEvent(e);
+ dispatched = KeyboardFocusManager.getCurrentKeyboardFocusManager()
+ .dispatchEvent(e);
+ }
+
+ if (! dispatched)
+ {
+ if (eventTypeEnabled (e.id))
+ {
+ if (e.id != PaintEvent.PAINT && e.id != PaintEvent.UPDATE)
+ processEvent(e);
+ }
+ if (peer != null)
+ peer.handleEvent(e);
+ }
+ }
+
+ /**
+ * Tells whether or not an event type is enabled.
+ */
+ boolean eventTypeEnabled (int type)
+ {
+ if (type > AWTEvent.RESERVED_ID_MAX)
+ return true;
+
+ switch (type)
+ {
+ case HierarchyEvent.HIERARCHY_CHANGED:
+ return (hierarchyListener != null
+ || (eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0);
+
+ case HierarchyEvent.ANCESTOR_MOVED:
+ case HierarchyEvent.ANCESTOR_RESIZED:
+ return (hierarchyBoundsListener != null
+ || (eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0);
+
+ case ComponentEvent.COMPONENT_HIDDEN:
+ case ComponentEvent.COMPONENT_MOVED:
+ case ComponentEvent.COMPONENT_RESIZED:
+ case ComponentEvent.COMPONENT_SHOWN:
+ return (componentListener != null
+ || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0);
+
+ case KeyEvent.KEY_PRESSED:
+ case KeyEvent.KEY_RELEASED:
+ case KeyEvent.KEY_TYPED:
+ return (keyListener != null
+ || (eventMask & AWTEvent.KEY_EVENT_MASK) != 0);
+
+ case MouseEvent.MOUSE_CLICKED:
+ case MouseEvent.MOUSE_ENTERED:
+ case MouseEvent.MOUSE_EXITED:
+ case MouseEvent.MOUSE_PRESSED:
+ case MouseEvent.MOUSE_RELEASED:
+ return (mouseListener != null
+ || (eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0);
+ case MouseEvent.MOUSE_MOVED:
+ case MouseEvent.MOUSE_DRAGGED:
+ return (mouseMotionListener != null
+ || (eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0);
+ case MouseEvent.MOUSE_WHEEL:
+ return (mouseWheelListener != null
+ || (eventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0);
+
+ case FocusEvent.FOCUS_GAINED:
+ case FocusEvent.FOCUS_LOST:
+ return (focusListener != null
+ || (eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0);
+
+ case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
+ case InputMethodEvent.CARET_POSITION_CHANGED:
+ return (inputMethodListener != null
+ || (eventMask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0);
+
+ case PaintEvent.PAINT:
+ case PaintEvent.UPDATE:
+ return (eventMask & AWTEvent.PAINT_EVENT_MASK) != 0;
+
+ default:
+ return false;
+ }
+ }
+
+ /**
+ * Coalesce paint events. Current heuristic is: Merge if the union of
+ * areas is less than twice that of the sum of the areas. The X server
+ * tend to create a lot of paint events that are adjacent but not
+ * overlapping.
+ *
+ * <pre>
+ * +------+
+ * | +-----+ ...will be merged
+ * | | |
+ * | | |
+ * +------+ |
+ * +-----+
+ *
+ * +---------------+--+
+ * | | | ...will not be merged
+ * +---------------+ |
+ * | |
+ * | |
+ * | |
+ * | |
+ * | |
+ * +--+
+ * </pre>
+ *
+ * @param queuedEvent the first paint event
+ * @param newEvent the second paint event
+ * @return the combined paint event, or null
+ */
+ private PaintEvent coalescePaintEvents(PaintEvent queuedEvent,
+ PaintEvent newEvent)
+ {
+ Rectangle r1 = queuedEvent.getUpdateRect();
+ Rectangle r2 = newEvent.getUpdateRect();
+ Rectangle union = r1.union(r2);
+ newEvent.setUpdateRect(union);
+ return newEvent;
+ }
+
+ /**
+ * This method is used to implement transferFocus(). CHILD is the child
+ * making the request. This is overridden by Container; when called for an
+ * ordinary component there is no child and so we always return null.
+ *
+ * FIXME: is this still needed, in light of focus traversal policies?
+ *
+ * @param child the component making the request
+ * @return the next component to focus on
+ */
+ Component findNextFocusComponent(Component child)
+ {
+ return null;
+ }
+
+ /**
+ * Deserializes this component. This regenerates all serializable listeners
+ * which were registered originally.
+ *
+ * @param s the stream to read from
+ * @throws ClassNotFoundException if deserialization fails
+ * @throws IOException if the stream fails
+ */
+ private void readObject(ObjectInputStream s)
+ throws ClassNotFoundException, IOException
+ {
+ s.defaultReadObject();
+ String key = (String) s.readObject();
+ while (key != null)
+ {
+ Object listener = s.readObject();
+ if ("componentL".equals(key))
+ addComponentListener((ComponentListener) listener);
+ else if ("focusL".equals(key))
+ addFocusListener((FocusListener) listener);
+ else if ("keyL".equals(key))
+ addKeyListener((KeyListener) listener);
+ else if ("mouseL".equals(key))
+ addMouseListener((MouseListener) listener);
+ else if ("mouseMotionL".equals(key))
+ addMouseMotionListener((MouseMotionListener) listener);
+ else if ("inputMethodL".equals(key))
+ addInputMethodListener((InputMethodListener) listener);
+ else if ("hierarchyL".equals(key))
+ addHierarchyListener((HierarchyListener) listener);
+ else if ("hierarchyBoundsL".equals(key))
+ addHierarchyBoundsListener((HierarchyBoundsListener) listener);
+ else if ("mouseWheelL".equals(key))
+ addMouseWheelListener((MouseWheelListener) listener);
+ key = (String) s.readObject();
+ }
+ }
+
+ /**
+ * Serializes this component. This ignores all listeners which do not
+ * implement Serializable, but includes those that do.
+ *
+ * @param s the stream to write to
+ * @throws IOException if the stream fails
+ */
+ private void writeObject(ObjectOutputStream s) throws IOException
+ {
+ s.defaultWriteObject();
+ AWTEventMulticaster.save(s, "componentL", componentListener);
+ AWTEventMulticaster.save(s, "focusL", focusListener);
+ AWTEventMulticaster.save(s, "keyL", keyListener);
+ AWTEventMulticaster.save(s, "mouseL", mouseListener);
+ AWTEventMulticaster.save(s, "mouseMotionL", mouseMotionListener);
+ AWTEventMulticaster.save(s, "inputMethodL", inputMethodListener);
+ AWTEventMulticaster.save(s, "hierarchyL", hierarchyListener);
+ AWTEventMulticaster.save(s, "hierarchyBoundsL", hierarchyBoundsListener);
+ AWTEventMulticaster.save(s, "mouseWheelL", mouseWheelListener);
+ s.writeObject(null);
+ }
+
+
+ // Nested classes.
+
+ /**
+ * This class fixes the bounds for a Heavyweight component that
+ * is placed inside a Lightweight container. When the lightweight is
+ * moved or resized, setBounds for the lightweight peer does nothing.
+ * Therefore, it was never moved on the screen. This class is
+ * attached to the lightweight, and it adjusts the position and size
+ * of the peer when notified.
+ * This is the same for show and hide.
+ */
+ class HeavyweightInLightweightListener
+ implements ComponentListener
+ {
+
+ /**
+ * Constructor. Adds component listener to lightweight parent.
+ *
+ * @param parent - the lightweight container.
+ */
+ public HeavyweightInLightweightListener(Container parent)
+ {
+ parent.addComponentListener(this);
+ }
+
+ /**
+ * This method is called when the component is resized.
+ *
+ * @param event the <code>ComponentEvent</code> indicating the resize
+ */
+ public void componentResized(ComponentEvent event)
+ {
+ // Nothing to do here, componentMoved will be called.
+ }
+
+ /**
+ * This method is called when the component is moved.
+ *
+ * @param event the <code>ComponentEvent</code> indicating the move
+ */
+ public void componentMoved(ComponentEvent event)
+ {
+ if (peer != null)
+ peer.setBounds(x, y, width, height);
+ }
+
+ /**
+ * This method is called when the component is made visible.
+ *
+ * @param event the <code>ComponentEvent</code> indicating the visibility
+ */
+ public void componentShown(ComponentEvent event)
+ {
+ if (isShowing())
+ peer.show();
+ }
+
+ /**
+ * This method is called when the component is hidden.
+ *
+ * @param event the <code>ComponentEvent</code> indicating the visibility
+ */
+ public void componentHidden(ComponentEvent event)
+ {
+ if (!isShowing())
+ peer.hide();
+ }
+ }
+
+ /**
+ * This class provides accessibility support for subclasses of container.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.3
+ * @status updated to 1.4
+ */
+ protected abstract class AccessibleAWTComponent extends AccessibleContext
+ implements Serializable, AccessibleComponent
+ {
+ /**
+ * Compatible with JDK 1.3+.
+ */
+ private static final long serialVersionUID = 642321655757800191L;
+
+ /**
+ * Converts show/hide events to PropertyChange events, and is registered
+ * as a component listener on this component.
+ *
+ * @serial the component handler
+ */
+ protected ComponentListener accessibleAWTComponentHandler
+ = new AccessibleAWTComponentHandler();
+
+ /**
+ * Converts focus events to PropertyChange events, and is registered
+ * as a focus listener on this component.
+ *
+ * @serial the focus handler
+ */
+ protected FocusListener accessibleAWTFocusHandler
+ = new AccessibleAWTFocusHandler();
+
+ /**
+ * The default constructor.
+ */
+ protected AccessibleAWTComponent()
+ {
+ Component.this.addComponentListener(accessibleAWTComponentHandler);
+ Component.this.addFocusListener(accessibleAWTFocusHandler);
+ }
+
+ /**
+ * Adds a global property change listener to the accessible component.
+ *
+ * @param l the listener to add
+ * @see #ACCESSIBLE_NAME_PROPERTY
+ * @see #ACCESSIBLE_DESCRIPTION_PROPERTY
+ * @see #ACCESSIBLE_STATE_PROPERTY
+ * @see #ACCESSIBLE_VALUE_PROPERTY
+ * @see #ACCESSIBLE_SELECTION_PROPERTY
+ * @see #ACCESSIBLE_TEXT_PROPERTY
+ * @see #ACCESSIBLE_VISIBLE_DATA_PROPERTY
+ */
+ public void addPropertyChangeListener(PropertyChangeListener l)
+ {
+ Component.this.addPropertyChangeListener(l);
+ super.addPropertyChangeListener(l);
+ }
+
+ /**
+ * Removes a global property change listener from this accessible
+ * component.
+ *
+ * @param l the listener to remove
+ */
+ public void removePropertyChangeListener(PropertyChangeListener l)
+ {
+ Component.this.removePropertyChangeListener(l);
+ super.removePropertyChangeListener(l);
+ }
+
+ /**
+ * Returns the accessible name of this component. It is almost always
+ * wrong to return getName(), since it is not localized. In fact, for
+ * things like buttons, this should be the text of the button, not the
+ * name of the object. The tooltip text might also be appropriate.
+ *
+ * @return the name
+ * @see #setAccessibleName(String)
+ */
+ public String getAccessibleName()
+ {
+ return accessibleName;
+ }
+
+ /**
+ * Returns a brief description of this accessible context. This should
+ * be localized.
+ *
+ * @return a description of this component
+ * @see #setAccessibleDescription(String)
+ */
+ public String getAccessibleDescription()
+ {
+ return accessibleDescription;
+ }
+
+ /**
+ * Returns the role of this component.
+ *
+ * @return the accessible role
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.AWT_COMPONENT;
+ }
+
+ /**
+ * Returns a state set describing this component's state.
+ *
+ * @return a new state set
+ * @see AccessibleState
+ */
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ AccessibleStateSet s = new AccessibleStateSet();
+ if (Component.this.isEnabled())
+ s.add(AccessibleState.ENABLED);
+ if (isFocusable())
+ s.add(AccessibleState.FOCUSABLE);
+ if (isFocusOwner())
+ s.add(AccessibleState.FOCUSED);
+ // Note: While the java.awt.Component has an 'opaque' property, it
+ // seems that it is not added to the accessible state set here, even
+ // if this property is true. However, it is handled for
+ // javax.swing.JComponent, so we add it there.
+ if (Component.this.isShowing())
+ s.add(AccessibleState.SHOWING);
+ if (Component.this.isVisible())
+ s.add(AccessibleState.VISIBLE);
+ return s;
+ }
+
+ /**
+ * Returns the parent of this component, if it is accessible.
+ *
+ * @return the accessible parent
+ */
+ public Accessible getAccessibleParent()
+ {
+ if (accessibleParent == null)
+ {
+ Container parent = getParent();
+ accessibleParent = parent instanceof Accessible
+ ? (Accessible) parent : null;
+ }
+ return accessibleParent;
+ }
+
+ /**
+ * Returns the index of this component in its accessible parent.
+ *
+ * @return the index, or -1 if the parent is not accessible
+ * @see #getAccessibleParent()
+ */
+ public int getAccessibleIndexInParent()
+ {
+ if (getAccessibleParent() == null)
+ return -1;
+ AccessibleContext context
+ = ((Component) accessibleParent).getAccessibleContext();
+ if (context == null)
+ return -1;
+ for (int i = context.getAccessibleChildrenCount(); --i >= 0; )
+ if (context.getAccessibleChild(i) == Component.this)
+ return i;
+ return -1;
+ }
+
+ /**
+ * Returns the number of children of this component which implement
+ * Accessible. Subclasses must override this if they can have children.
+ *
+ * @return the number of accessible children, default 0
+ */
+ public int getAccessibleChildrenCount()
+ {
+ return 0;
+ }
+
+ /**
+ * Returns the ith accessible child. Subclasses must override this if
+ * they can have children.
+ *
+ * @return the ith accessible child, or null
+ * @see #getAccessibleChildrenCount()
+ */
+ public Accessible getAccessibleChild(int i)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the locale of this component.
+ *
+ * @return the locale
+ * @throws IllegalComponentStateException if the locale is unknown
+ */
+ public Locale getLocale()
+ {
+ return Component.this.getLocale();
+ }
+
+ /**
+ * Returns this, since it is an accessible component.
+ *
+ * @return the accessible component
+ */
+ public AccessibleComponent getAccessibleComponent()
+ {
+ return this;
+ }
+
+ /**
+ * Gets the background color.
+ *
+ * @return the background color
+ * @see #setBackground(Color)
+ */
+ public Color getBackground()
+ {
+ return Component.this.getBackground();
+ }
+
+ /**
+ * Sets the background color.
+ *
+ * @param c the background color
+ * @see #getBackground()
+ * @see #isOpaque()
+ */
+ public void setBackground(Color c)
+ {
+ Component.this.setBackground(c);
+ }
+
+ /**
+ * Gets the foreground color.
+ *
+ * @return the foreground color
+ * @see #setForeground(Color)
+ */
+ public Color getForeground()
+ {
+ return Component.this.getForeground();
+ }
+
+ /**
+ * Sets the foreground color.
+ *
+ * @param c the foreground color
+ * @see #getForeground()
+ */
+ public void setForeground(Color c)
+ {
+ Component.this.setForeground(c);
+ }
+
+ /**
+ * Gets the cursor.
+ *
+ * @return the cursor
+ * @see #setCursor(Cursor)
+ */
+ public Cursor getCursor()
+ {
+ return Component.this.getCursor();
+ }
+
+ /**
+ * Sets the cursor.
+ *
+ * @param cursor the cursor
+ * @see #getCursor()
+ */
+ public void setCursor(Cursor cursor)
+ {
+ Component.this.setCursor(cursor);
+ }
+
+ /**
+ * Gets the font.
+ *
+ * @return the font
+ * @see #setFont(Font)
+ */
+ public Font getFont()
+ {
+ return Component.this.getFont();
+ }
+
+ /**
+ * Sets the font.
+ *
+ * @param f the font
+ * @see #getFont()
+ */
+ public void setFont(Font f)
+ {
+ Component.this.setFont(f);
+ }
+
+ /**
+ * Gets the font metrics for a font.
+ *
+ * @param f the font to look up
+ * @return its metrics
+ * @throws NullPointerException if f is null
+ * @see #getFont()
+ */
+ public FontMetrics getFontMetrics(Font f)
+ {
+ return Component.this.getFontMetrics(f);
+ }
+
+ /**
+ * Tests if the component is enabled.
+ *
+ * @return true if the component is enabled
+ * @see #setEnabled(boolean)
+ * @see #getAccessibleStateSet()
+ * @see AccessibleState#ENABLED
+ */
+ public boolean isEnabled()
+ {
+ return Component.this.isEnabled();
+ }
+
+ /**
+ * Set whether the component is enabled.
+ *
+ * @param b the new enabled status
+ * @see #isEnabled()
+ */
+ public void setEnabled(boolean b)
+ {
+ Component.this.setEnabled(b);
+ }
+
+ /**
+ * Test whether the component is visible (not necesarily showing).
+ *
+ * @return true if it is visible
+ * @see #setVisible(boolean)
+ * @see #getAccessibleStateSet()
+ * @see AccessibleState#VISIBLE
+ */
+ public boolean isVisible()
+ {
+ return Component.this.isVisible();
+ }
+
+ /**
+ * Sets the visibility of this component.
+ *
+ * @param b the desired visibility
+ * @see #isVisible()
+ */
+ public void setVisible(boolean b)
+ {
+ Component.this.setVisible(b);
+ }
+
+ /**
+ * Tests if the component is showing.
+ *
+ * @return true if this is showing
+ */
+ public boolean isShowing()
+ {
+ return Component.this.isShowing();
+ }
+
+ /**
+ * Tests if the point is contained in this component.
+ *
+ * @param p the point to check
+ * @return true if it is contained
+ * @throws NullPointerException if p is null
+ */
+ public boolean contains(Point p)
+ {
+ return Component.this.contains(p.x, p.y);
+ }
+
+ /**
+ * Returns the location of this object on the screen, or null if it is
+ * not showing.
+ *
+ * @return the location relative to screen coordinates, if showing
+ * @see #getBounds()
+ * @see #getLocation()
+ */
+ public Point getLocationOnScreen()
+ {
+ return Component.this.isShowing() ? Component.this.getLocationOnScreen()
+ : null;
+ }
+
+ /**
+ * Returns the location of this object relative to its parent's coordinate
+ * system, or null if it is not showing.
+ *
+ * @return the location
+ * @see #getBounds()
+ * @see #getLocationOnScreen()
+ */
+ public Point getLocation()
+ {
+ return Component.this.getLocation();
+ }
+
+ /**
+ * Sets the location of this relative to its parent's coordinate system.
+ *
+ * @param p the location
+ * @throws NullPointerException if p is null
+ * @see #getLocation()
+ */
+ public void setLocation(Point p)
+ {
+ Component.this.setLocation(p.x, p.y);
+ }
+
+ /**
+ * Gets the bounds of this component, or null if it is not on screen.
+ *
+ * @return the bounds
+ * @see #contains(Point)
+ * @see #setBounds(Rectangle)
+ */
+ public Rectangle getBounds()
+ {
+ return Component.this.getBounds();
+ }
+
+ /**
+ * Sets the bounds of this component.
+ *
+ * @param r the bounds
+ * @throws NullPointerException if r is null
+ * @see #getBounds()
+ */
+ public void setBounds(Rectangle r)
+ {
+ Component.this.setBounds(r.x, r.y, r.width, r.height);
+ }
+
+ /**
+ * Gets the size of this component, or null if it is not showing.
+ *
+ * @return the size
+ * @see #setSize(Dimension)
+ */
+ public Dimension getSize()
+ {
+ return Component.this.getSize();
+ }
+
+ /**
+ * Sets the size of this component.
+ *
+ * @param d the size
+ * @throws NullPointerException if d is null
+ * @see #getSize()
+ */
+ public void setSize(Dimension d)
+ {
+ Component.this.setSize(d.width, d.height);
+ }
+
+ /**
+ * Returns the Accessible child at a point relative to the coordinate
+ * system of this component, if one exists, or null. Since components
+ * have no children, subclasses must override this to get anything besides
+ * null.
+ *
+ * @param p the point to check
+ * @return the accessible child at that point
+ * @throws NullPointerException if p is null
+ */
+ public Accessible getAccessibleAt(Point p)
+ {
+ return null;
+ }
+
+ /**
+ * Tests whether this component can accept focus.
+ *
+ * @return true if this is focus traversable
+ * @see #getAccessibleStateSet ()
+ * @see AccessibleState#FOCUSABLE
+ * @see AccessibleState#FOCUSED
+ */
+ public boolean isFocusTraversable ()
+ {
+ return Component.this.isFocusTraversable ();
+ }
+
+ /**
+ * Requests focus for this component.
+ *
+ * @see #isFocusTraversable ()
+ */
+ public void requestFocus ()
+ {
+ Component.this.requestFocus ();
+ }
+
+ /**
+ * Adds a focus listener.
+ *
+ * @param l the listener to add
+ */
+ public void addFocusListener(FocusListener l)
+ {
+ Component.this.addFocusListener(l);
+ }
+
+ /**
+ * Removes a focus listener.
+ *
+ * @param l the listener to remove
+ */
+ public void removeFocusListener(FocusListener l)
+ {
+ Component.this.removeFocusListener(l);
+ }
+
+ /**
+ * Converts component changes into property changes.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.3
+ * @status updated to 1.4
+ */
+ protected class AccessibleAWTComponentHandler implements ComponentListener
+ {
+ /**
+ * Default constructor.
+ */
+ protected AccessibleAWTComponentHandler()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Convert a component hidden to a property change.
+ *
+ * @param e the event to convert
+ */
+ public void componentHidden(ComponentEvent e)
+ {
+ AccessibleAWTComponent.this.firePropertyChange
+ (ACCESSIBLE_STATE_PROPERTY, AccessibleState.VISIBLE, null);
+ }
+
+ /**
+ * Convert a component shown to a property change.
+ *
+ * @param e the event to convert
+ */
+ public void componentShown(ComponentEvent e)
+ {
+ AccessibleAWTComponent.this.firePropertyChange
+ (ACCESSIBLE_STATE_PROPERTY, null, AccessibleState.VISIBLE);
+ }
+
+ /**
+ * Moving a component does not affect properties.
+ *
+ * @param e ignored
+ */
+ public void componentMoved(ComponentEvent e)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Resizing a component does not affect properties.
+ *
+ * @param e ignored
+ */
+ public void componentResized(ComponentEvent e)
+ {
+ // Nothing to do here.
+ }
+ } // class AccessibleAWTComponentHandler
+
+ /**
+ * Converts focus changes into property changes.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.3
+ * @status updated to 1.4
+ */
+ protected class AccessibleAWTFocusHandler implements FocusListener
+ {
+ /**
+ * Default constructor.
+ */
+ protected AccessibleAWTFocusHandler()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Convert a focus gained to a property change.
+ *
+ * @param e the event to convert
+ */
+ public void focusGained(FocusEvent e)
+ {
+ AccessibleAWTComponent.this.firePropertyChange
+ (ACCESSIBLE_STATE_PROPERTY, null, AccessibleState.FOCUSED);
+ }
+
+ /**
+ * Convert a focus lost to a property change.
+ *
+ * @param e the event to convert
+ */
+ public void focusLost(FocusEvent e)
+ {
+ AccessibleAWTComponent.this.firePropertyChange
+ (ACCESSIBLE_STATE_PROPERTY, AccessibleState.FOCUSED, null);
+ }
+ } // class AccessibleAWTComponentHandler
+ } // class AccessibleAWTComponent
+
+ /**
+ * This class provides support for blitting offscreen surfaces to a
+ * component.
+ *
+ * @see BufferStrategy
+ *
+ * @since 1.4
+ */
+ protected class BltBufferStrategy extends BufferStrategy
+ {
+ /**
+ * The capabilities of the image buffer.
+ */
+ protected BufferCapabilities caps;
+
+ /**
+ * The back buffers used in this strategy.
+ */
+ protected VolatileImage[] backBuffers;
+
+ /**
+ * Whether or not the image buffer resources are allocated and
+ * ready to be drawn into.
+ */
+ protected boolean validatedContents;
+
+ /**
+ * The width of the back buffers.
+ */
+ protected int width;
+
+ /**
+ * The height of the back buffers.
+ */
+ protected int height;
+
+ /**
+ * The front buffer.
+ */
+ private VolatileImage frontBuffer;
+
+ /**
+ * Creates a blitting buffer strategy.
+ *
+ * @param numBuffers the number of buffers, including the front
+ * buffer
+ * @param caps the capabilities of this strategy
+ */
+ protected BltBufferStrategy(int numBuffers, BufferCapabilities caps)
+ {
+ this.caps = caps;
+ createBackBuffers(numBuffers - 1);
+ width = getWidth();
+ height = getHeight();
+ }
+
+ /**
+ * Initializes the backBuffers field with an array of numBuffers
+ * VolatileImages.
+ *
+ * @param numBuffers the number of backbuffers to create
+ */
+ protected void createBackBuffers(int numBuffers)
+ {
+ GraphicsConfiguration c =
+ GraphicsEnvironment.getLocalGraphicsEnvironment()
+ .getDefaultScreenDevice().getDefaultConfiguration();
+
+ backBuffers = new VolatileImage[numBuffers];
+
+ for (int i = 0; i < numBuffers; i++)
+ backBuffers[i] = c.createCompatibleVolatileImage(width, height);
+ }
+
+ /**
+ * Retrieves the capabilities of this buffer strategy.
+ *
+ * @return the capabilities of this buffer strategy
+ */
+ public BufferCapabilities getCapabilities()
+ {
+ return caps;
+ }
+
+ /**
+ * Retrieves a graphics object that can be used to draw into this
+ * strategy's image buffer.
+ *
+ * @return a graphics object
+ */
+ public Graphics getDrawGraphics()
+ {
+ // Return the backmost buffer's graphics.
+ return backBuffers[0].getGraphics();
+ }
+
+ /**
+ * Bring the contents of the back buffer to the front buffer.
+ */
+ public void show()
+ {
+ GraphicsConfiguration c =
+ GraphicsEnvironment.getLocalGraphicsEnvironment()
+ .getDefaultScreenDevice().getDefaultConfiguration();
+
+ // draw the front buffer.
+ getGraphics().drawImage(backBuffers[backBuffers.length - 1],
+ width, height, null);
+
+ BufferCapabilities.FlipContents f = getCapabilities().getFlipContents();
+
+ // blit the back buffers.
+ for (int i = backBuffers.length - 1; i > 0 ; i--)
+ backBuffers[i] = backBuffers[i - 1];
+
+ // create new backmost buffer.
+ if (f == BufferCapabilities.FlipContents.UNDEFINED)
+ backBuffers[0] = c.createCompatibleVolatileImage(width, height);
+
+ // create new backmost buffer and clear it to the background
+ // color.
+ if (f == BufferCapabilities.FlipContents.BACKGROUND)
+ {
+ backBuffers[0] = c.createCompatibleVolatileImage(width, height);
+ backBuffers[0].getGraphics().clearRect(0, 0, width, height);
+ }
+
+ // FIXME: set the backmost buffer to the prior contents of the
+ // front buffer. How do we retrieve the contents of the front
+ // buffer?
+ //
+ // if (f == BufferCapabilities.FlipContents.PRIOR)
+
+ // set the backmost buffer to a copy of the new front buffer.
+ if (f == BufferCapabilities.FlipContents.COPIED)
+ backBuffers[0] = backBuffers[backBuffers.length - 1];
+ }
+
+ /**
+ * Re-create the image buffer resources if they've been lost.
+ */
+ protected void revalidate()
+ {
+ GraphicsConfiguration c =
+ GraphicsEnvironment.getLocalGraphicsEnvironment()
+ .getDefaultScreenDevice().getDefaultConfiguration();
+
+ for (int i = 0; i < backBuffers.length; i++)
+ {
+ int result = backBuffers[i].validate(c);
+ if (result == VolatileImage.IMAGE_INCOMPATIBLE)
+ backBuffers[i] = c.createCompatibleVolatileImage(width, height);
+ }
+ validatedContents = true;
+ }
+
+ /**
+ * Returns whether or not the image buffer resources have been
+ * lost.
+ *
+ * @return true if the resources have been lost, false otherwise
+ */
+ public boolean contentsLost()
+ {
+ for (int i = 0; i < backBuffers.length; i++)
+ {
+ if (backBuffers[i].contentsLost())
+ {
+ validatedContents = false;
+ return true;
+ }
+ }
+ // we know that the buffer resources are valid now because we
+ // just checked them
+ validatedContents = true;
+ return false;
+ }
+
+ /**
+ * Returns whether or not the image buffer resources have been
+ * restored.
+ *
+ * @return true if the resources have been restored, false
+ * otherwise
+ */
+ public boolean contentsRestored()
+ {
+ GraphicsConfiguration c =
+ GraphicsEnvironment.getLocalGraphicsEnvironment()
+ .getDefaultScreenDevice().getDefaultConfiguration();
+
+ boolean imageRestored = false;
+
+ for (int i = 0; i < backBuffers.length; i++)
+ {
+ int result = backBuffers[i].validate(c);
+ if (result == VolatileImage.IMAGE_RESTORED)
+ imageRestored = true;
+ else if (result == VolatileImage.IMAGE_INCOMPATIBLE)
+ return false;
+ }
+ // we know that the buffer resources are valid now because we
+ // just checked them
+ validatedContents = true;
+ return imageRestored;
+ }
+ }
+
+ /**
+ * This class provides support for flipping component buffers. It
+ * can only be used on Canvases and Windows.
+ *
+ * @since 1.4
+ */
+ protected class FlipBufferStrategy extends BufferStrategy
+ {
+ /**
+ * The number of buffers.
+ */
+ protected int numBuffers;
+
+ /**
+ * The capabilities of this buffering strategy.
+ */
+ protected BufferCapabilities caps;
+
+ /**
+ * An Image reference to the drawing buffer.
+ */
+ protected Image drawBuffer;
+
+ /**
+ * A VolatileImage reference to the drawing buffer.
+ */
+ protected VolatileImage drawVBuffer;
+
+ /**
+ * Whether or not the image buffer resources are allocated and
+ * ready to be drawn into.
+ */
+ protected boolean validatedContents;
+
+ /**
+ * The width of the back buffer.
+ */
+ private int width;
+
+ /**
+ * The height of the back buffer.
+ */
+ private int height;
+
+ /**
+ * Creates a flipping buffer strategy. The only supported
+ * strategy for FlipBufferStrategy itself is a double-buffer page
+ * flipping strategy. It forms the basis for more complex derived
+ * strategies.
+ *
+ * @param numBuffers the number of buffers
+ * @param caps the capabilities of this buffering strategy
+ *
+ * @throws AWTException if the requested
+ * number-of-buffers/capabilities combination is not supported
+ */
+ protected FlipBufferStrategy(int numBuffers, BufferCapabilities caps)
+ throws AWTException
+ {
+ this.caps = caps;
+ width = getWidth();
+ height = getHeight();
+
+ if (numBuffers > 1)
+ createBuffers(numBuffers, caps);
+ else
+ {
+ drawVBuffer = peer.createVolatileImage(width, height);
+ drawBuffer = drawVBuffer;
+ }
+ }
+
+ /**
+ * Creates a multi-buffer flipping strategy. The number of
+ * buffers must be greater than one and the buffer capabilities
+ * must specify page flipping.
+ *
+ * @param numBuffers the number of flipping buffers; must be
+ * greater than one
+ * @param caps the buffering capabilities; caps.isPageFlipping()
+ * must return true
+ *
+ * @throws IllegalArgumentException if numBuffers is not greater
+ * than one or if the page flipping capability is not requested
+ *
+ * @throws AWTException if the requested flipping strategy is not
+ * supported
+ */
+ protected void createBuffers(int numBuffers, BufferCapabilities caps)
+ throws AWTException
+ {
+ if (numBuffers <= 1)
+ throw new IllegalArgumentException("FlipBufferStrategy.createBuffers:"
+ + " numBuffers must be greater than"
+ + " one.");
+
+ if (!caps.isPageFlipping())
+ throw new IllegalArgumentException("FlipBufferStrategy.createBuffers:"
+ + " flipping must be a specified"
+ + " capability.");
+
+ peer.createBuffers(numBuffers, caps);
+ }
+
+ /**
+ * Return a direct reference to the back buffer image.
+ *
+ * @return a direct reference to the back buffer image.
+ */
+ protected Image getBackBuffer()
+ {
+ return peer.getBackBuffer();
+ }
+
+ /**
+ * Perform a flip operation to transfer the contents of the back
+ * buffer to the front buffer.
+ */
+ protected void flip(BufferCapabilities.FlipContents flipAction)
+ {
+ peer.flip(flipAction);
+ }
+
+ /**
+ * Release the back buffer's resources.
+ */
+ protected void destroyBuffers()
+ {
+ peer.destroyBuffers();
+ }
+
+ /**
+ * Retrieves the capabilities of this buffer strategy.
+ *
+ * @return the capabilities of this buffer strategy
+ */
+ public BufferCapabilities getCapabilities()
+ {
+ return caps;
+ }
+
+ /**
+ * Retrieves a graphics object that can be used to draw into this
+ * strategy's image buffer.
+ *
+ * @return a graphics object
+ */
+ public Graphics getDrawGraphics()
+ {
+ return drawVBuffer.getGraphics();
+ }
+
+ /**
+ * Re-create the image buffer resources if they've been lost.
+ */
+ protected void revalidate()
+ {
+ GraphicsConfiguration c =
+ GraphicsEnvironment.getLocalGraphicsEnvironment()
+ .getDefaultScreenDevice().getDefaultConfiguration();
+
+ if (drawVBuffer.validate(c) == VolatileImage.IMAGE_INCOMPATIBLE)
+ drawVBuffer = peer.createVolatileImage(width, height);
+ validatedContents = true;
+ }
+
+ /**
+ * Returns whether or not the image buffer resources have been
+ * lost.
+ *
+ * @return true if the resources have been lost, false otherwise
+ */
+ public boolean contentsLost()
+ {
+ if (drawVBuffer.contentsLost())
+ {
+ validatedContents = false;
+ return true;
+ }
+ // we know that the buffer resources are valid now because we
+ // just checked them
+ validatedContents = true;
+ return false;
+ }
+
+ /**
+ * Returns whether or not the image buffer resources have been
+ * restored.
+ *
+ * @return true if the resources have been restored, false
+ * otherwise
+ */
+ public boolean contentsRestored()
+ {
+ GraphicsConfiguration c =
+ GraphicsEnvironment.getLocalGraphicsEnvironment()
+ .getDefaultScreenDevice().getDefaultConfiguration();
+
+ int result = drawVBuffer.validate(c);
+
+ boolean imageRestored = false;
+
+ if (result == VolatileImage.IMAGE_RESTORED)
+ imageRestored = true;
+ else if (result == VolatileImage.IMAGE_INCOMPATIBLE)
+ return false;
+
+ // we know that the buffer resources are valid now because we
+ // just checked them
+ validatedContents = true;
+ return imageRestored;
+ }
+
+ /**
+ * Bring the contents of the back buffer to the front buffer.
+ */
+ public void show()
+ {
+ flip(caps.getFlipContents());
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ComponentOrientation.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ComponentOrientation.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ComponentOrientation.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ComponentOrientation.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,215 @@
+/* ComponentOrientation.java -- describes a component's orientation
+ Copyright (C) 2000, 2001, 2002 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.io.Serializable;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * This class is used to differentiate different orientations for text layout.
+ * It controls whether text flows left-to-right or right-to-left, and whether
+ * lines are horizontal or vertical, as in this table:<br>
+ * <pre>
+ * LT RT TL TR
+ * A B C C B A A D G G D A
+ * D E F F E D B E H H E B
+ * G H I I H G C F I I F C
+ * </pre>
+ * <b>LT</b> languages are most common (left-to-right lines, top-to-bottom).
+ * This includes Western European languages, and optionally includes Japanese,
+ * Chinese, and Korean. <b>RT</b> languages (right-to-left lines,
+ * top-to-bottom) are mainly middle eastern, such as Hebrew and Arabic.
+ * <b>TR</b> languages flow top-to-bottom in a line, right-to-left, and are
+ * the basis of Japanese, Chinese, and Korean. Finally, <b>TL</b> languages
+ * flow top-to-bottom in a line, left-to-right, as in Mongolian.
+ *
+ * <p>This is a pretty poor excuse for a type-safe enum, since it is not
+ * guaranteed that orientation objects are unique (thanks to serialization),
+ * yet there is no equals() method. You would be wise to compare the output
+ * of isHorizontal() and isLeftToRight() rather than comparing objects with
+ * ==, especially since more constants may be added in the future.
+ *
+ * @author Bryce McKinlay (bryce at albatross.co.nz)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public final class ComponentOrientation implements Serializable
+{
+ /**
+ * Compatible with JDK 1.0+.
+ */
+ private static final long serialVersionUID = -4113291392143563828L;
+
+ /** Constant for unknown orientation. */
+ private static final int UNKNOWN_ID = 1;
+
+ /** Constant for horizontal line orientation. */
+ private static final int HORIZONTAL_ID = 2;
+
+ /** Constant for left-to-right orientation. */
+ private static final int LEFT_TO_RIGHT_ID = 4;
+
+ /**
+ * Items run left to right, and lines flow top to bottom. Examples: English,
+ * French.
+ */
+ public static final ComponentOrientation LEFT_TO_RIGHT
+ = new ComponentOrientation(HORIZONTAL_ID | LEFT_TO_RIGHT_ID);
+
+ /**
+ * Items run right to left, and lines flow top to bottom. Examples: Arabic,
+ * Hebrew.
+ */
+ public static final ComponentOrientation RIGHT_TO_LEFT
+ = new ComponentOrientation(HORIZONTAL_ID);
+
+ /**
+ * The orientation is unknown for the locale. For backwards compatibility,
+ * this behaves like LEFT_TO_RIGHT in the instance methods.
+ */
+ public static final ComponentOrientation UNKNOWN
+ = new ComponentOrientation(UNKNOWN_ID | HORIZONTAL_ID | LEFT_TO_RIGHT_ID);
+
+ /**
+ * The orientation of this object; bitwise-or of unknown (1), horizontal (2),
+ * and left-to-right (4).
+ *
+ * @serial the orientation
+ */
+ private final int orientation;
+
+ /**
+ * Construct a given orientation.
+ *
+ * @param orientation the orientation
+ */
+ private ComponentOrientation(int orientation)
+ {
+ this.orientation = orientation;
+ }
+
+ /**
+ * Returns true if the lines are horizontal, in which case lines flow
+ * top-to-bottom. For example, English, Hebrew. Counterexamples: Japanese,
+ * Chinese, Korean, Mongolian.
+ *
+ * @return true if this orientation has horizontal lines
+ */
+ public boolean isHorizontal()
+ {
+ return (orientation & HORIZONTAL_ID) != 0;
+ }
+
+ /**
+ * If isHorizontal() returns true, then this determines whether items in
+ * the line flow left-to-right. If isHorizontal() returns false, items in
+ * a line flow top-to-bottom, and this determines if lines flow
+ * left-to-right.
+ *
+ * @return true if this orientation flows left-to-right
+ */
+ public boolean isLeftToRight()
+ {
+ return (orientation & LEFT_TO_RIGHT_ID) != 0;
+ }
+
+ /**
+ * Gets an orientation appropriate for the locale.
+ *
+ * @param locale the locale
+ * @return the orientation for that locale
+ * @throws NullPointerException if locale is null
+ */
+ public static ComponentOrientation getOrientation(Locale locale)
+ {
+ // Based on iterating over all languages defined in JDK 1.4, this behavior
+ // matches Sun's. However, it makes me wonder if any non-horizontal
+ // orientations even exist, as it sure contradicts their documentation.
+ String language = locale.getLanguage();
+ if ("ar".equals(language) || "fa".equals(language) || "iw".equals(language)
+ || "ur".equals(language))
+ return RIGHT_TO_LEFT;
+ return LEFT_TO_RIGHT;
+ }
+
+ /**
+ * Gets an orientation from a resource bundle. This tries the following:
+ *
+ * <ul>
+ * <li>Use the key "Orientation" to find an instance of ComponentOrientation
+ * in the bundle.</li>
+ * <li>Get the locale of the resource bundle, and get the orientation of
+ * that locale.</li>
+ * <li>Give up and get the orientation of the default locale.</li>
+ * </ul>
+ *
+ * @param bdl the bundle to use
+ * @return the orientation
+ * @throws NullPointerException if bdl is null
+ * @deprecated use {@link #getOrientation(Locale)} instead
+ */
+ public static ComponentOrientation getOrientation(ResourceBundle bdl)
+ {
+ ComponentOrientation r;
+ try
+ {
+ r = (ComponentOrientation) bdl.getObject("Orientation");
+ if (r != null)
+ return r;
+ }
+ catch (MissingResourceException ignored)
+ {
+ }
+ catch (ClassCastException ignored)
+ {
+ }
+ try
+ {
+ r = getOrientation(bdl.getLocale());
+ if (r != null)
+ return r;
+ }
+ catch (Exception ignored)
+ {
+ }
+ return getOrientation(Locale.getDefault());
+ }
+} // class ComponentOrientation
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Composite.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Composite.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Composite.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Composite.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,73 @@
+/* Composite.java -- graphics formed from composite layers
+ Copyright (C) 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.image.ColorModel;
+
+/**
+ * This interface is for graphics which are formed as composites of others.
+ * It combines {@link Graphics2D} shapes according to defined rules to form
+ * the new image. Implementations of this interface must be immutable, because
+ * they are not cloned when a Graphics2D container is cloned.
+ *
+ * <p>Since this can expose pixels to untrusted code, there is a security
+ * check on custom objects, <code>readDisplayPixels</code>, to prevent leaking
+ * restricted information graphically.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see AlphaComposite
+ * @see CompositeContext
+ * @see Graphics2D#setComposite(Composite)
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface Composite
+{
+ /**
+ * Create a context state for performing the compositing operation. Several
+ * contexts may exist for this object, in a multi-threaded environment.
+ *
+ * @param srcColorModel the color model of the source
+ * @param dstColorModel the color model of the destination
+ * @param hints hints for choosing between rendering alternatives
+ */
+ CompositeContext createContext(ColorModel srcColorModel,
+ ColorModel dstColorModel,
+ RenderingHints hints);
+} // interface Composite
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/CompositeContext.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/CompositeContext.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/CompositeContext.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/CompositeContext.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,71 @@
+/* Composite.java -- the context for compositing graphics layers
+ Copyright (C) 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+/**
+ * This interface provides an optimized environment for compositing graphics.
+ * Several such contexts may exist for a given <code>Composite</code> object.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Composite
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface CompositeContext
+{
+ /**
+ * Release resources allocated for the compositing.
+ */
+ void dispose();
+
+ /**
+ * Compose the two source images into the composite image. The destination
+ * can be the same as one of the two inputs, and the destination must be
+ * compatible with the ColorModel chosen in {@link Composite#createContext}.
+ *
+ * @param src the lower image source in compositing
+ * @param dstIn the upper image source in compositing
+ * @param dstOut the destination for the composite
+ * @see Composite
+ */
+ void compose(Raster src, Raster dstIn, WritableRaster dstOut);
+} // interface CompositeContext
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Container.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Container.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Container.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Container.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,2261 @@
+/* Container.java -- parent container class in AWT
+ Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.event.ComponentListener;
+import java.awt.event.ContainerEvent;
+import java.awt.event.ContainerListener;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.KeyEvent;
+import java.awt.peer.ComponentPeer;
+import java.awt.peer.ContainerPeer;
+import java.awt.peer.LightweightPeer;
+import java.beans.PropertyChangeListener;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.EventListener;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.accessibility.Accessible;
+
+/**
+ * A generic window toolkit object that acts as a container for other objects.
+ * Components are tracked in a list, and new elements are at the end of the
+ * list or bottom of the stacking order.
+ *
+ * @author original author unknown
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ *
+ * @since 1.0
+ *
+ * @status still missing 1.4 support
+ */
+public class Container extends Component
+{
+ /**
+ * Compatible with JDK 1.0+.
+ */
+ private static final long serialVersionUID = 4613797578919906343L;
+
+ /* Serialized fields from the serialization spec. */
+ int ncomponents;
+ Component[] component;
+ LayoutManager layoutMgr;
+
+ Dimension maxSize;
+
+ /**
+ * @since 1.4
+ */
+ boolean focusCycleRoot;
+
+ /**
+ * Indicates if this container provides a focus traversal policy.
+ *
+ * @since 1.5
+ */
+ private boolean focusTraversalPolicyProvider;
+
+ int containerSerializedDataVersion;
+
+ /* Anything else is non-serializable, and should be declared "transient". */
+ transient ContainerListener containerListener;
+
+ /** The focus traversal policy that determines how focus is
+ transferred between this Container and its children. */
+ private FocusTraversalPolicy focusTraversalPolicy;
+
+ /**
+ * The focus traversal keys, if not inherited from the parent or default
+ * keyboard manager. These sets will contain only AWTKeyStrokes that
+ * represent press and release events to use as focus control.
+ *
+ * @see #getFocusTraversalKeys(int)
+ * @see #setFocusTraversalKeys(int, Set)
+ * @since 1.4
+ */
+ transient Set[] focusTraversalKeys;
+
+ /**
+ * Default constructor for subclasses.
+ */
+ public Container()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the number of components in this container.
+ *
+ * @return The number of components in this container.
+ */
+ public int getComponentCount()
+ {
+ return countComponents ();
+ }
+
+ /**
+ * Returns the number of components in this container.
+ *
+ * @return The number of components in this container.
+ *
+ * @deprecated use {@link #getComponentCount()} instead
+ */
+ public int countComponents()
+ {
+ return ncomponents;
+ }
+
+ /**
+ * Returns the component at the specified index.
+ *
+ * @param n The index of the component to retrieve.
+ *
+ * @return The requested component.
+ *
+ * @throws ArrayIndexOutOfBoundsException If the specified index is invalid
+ */
+ public Component getComponent(int n)
+ {
+ synchronized (getTreeLock ())
+ {
+ if (n < 0 || n >= ncomponents)
+ throw new ArrayIndexOutOfBoundsException("no such component");
+
+ return component[n];
+ }
+ }
+
+ /**
+ * Returns an array of the components in this container.
+ *
+ * @return The components in this container.
+ */
+ public Component[] getComponents()
+ {
+ synchronized (getTreeLock ())
+ {
+ Component[] result = new Component[ncomponents];
+
+ if (ncomponents > 0)
+ System.arraycopy(component, 0, result, 0, ncomponents);
+
+ return result;
+ }
+ }
+
+ /**
+ * Returns the insets for this container, which is the space used for
+ * borders, the margin, etc.
+ *
+ * @return The insets for this container.
+ */
+ public Insets getInsets()
+ {
+ return insets ();
+ }
+
+ /**
+ * Returns the insets for this container, which is the space used for
+ * borders, the margin, etc.
+ *
+ * @return The insets for this container.
+ * @deprecated use {@link #getInsets()} instead
+ */
+ public Insets insets()
+ {
+ if (peer == null)
+ return new Insets (0, 0, 0, 0);
+
+ return ((ContainerPeer) peer).getInsets ();
+ }
+
+ /**
+ * Adds the specified component to this container at the end of the
+ * component list.
+ *
+ * @param comp The component to add to the container.
+ *
+ * @return The same component that was added.
+ */
+ public Component add(Component comp)
+ {
+ addImpl(comp, null, -1);
+ return comp;
+ }
+
+ /**
+ * Adds the specified component to the container at the end of the
+ * component list. This method should not be used. Instead, use
+ * <code>add(Component, Object)</code>.
+ *
+ * @param name The name of the component to be added.
+ * @param comp The component to be added.
+ *
+ * @return The same component that was added.
+ *
+ * @see #add(Component,Object)
+ */
+ public Component add(String name, Component comp)
+ {
+ addImpl(comp, name, -1);
+ return comp;
+ }
+
+ /**
+ * Adds the specified component to this container at the specified index
+ * in the component list.
+ *
+ * @param comp The component to be added.
+ * @param index The index in the component list to insert this child
+ * at, or -1 to add at the end of the list.
+ *
+ * @return The same component that was added.
+ *
+ * @throws ArrayIndexOutOfBoundsException If the specified index is invalid.
+ */
+ public Component add(Component comp, int index)
+ {
+ addImpl(comp, null, index);
+ return comp;
+ }
+
+ /**
+ * Adds the specified component to this container at the end of the
+ * component list. The layout manager will use the specified constraints
+ * when laying out this component.
+ *
+ * @param comp The component to be added to this container.
+ * @param constraints The layout constraints for this component.
+ */
+ public void add(Component comp, Object constraints)
+ {
+ addImpl(comp, constraints, -1);
+ }
+
+ /**
+ * Adds the specified component to this container at the specified index
+ * in the component list. The layout manager will use the specified
+ * constraints when layout out this component.
+ *
+ * @param comp The component to be added.
+ * @param constraints The layout constraints for this component.
+ * @param index The index in the component list to insert this child
+ * at, or -1 to add at the end of the list.
+ *
+ * @throws ArrayIndexOutOfBoundsException If the specified index is invalid.
+ */
+ public void add(Component comp, Object constraints, int index)
+ {
+ addImpl(comp, constraints, index);
+ }
+
+ /**
+ * This method is called by all the <code>add()</code> methods to perform
+ * the actual adding of the component. Subclasses who wish to perform
+ * their own processing when a component is added should override this
+ * method. Any subclass doing this must call the superclass version of
+ * this method in order to ensure proper functioning of the container.
+ *
+ * @param comp The component to be added.
+ * @param constraints The layout constraints for this component, or
+ * <code>null</code> if there are no constraints.
+ * @param index The index in the component list to insert this child
+ * at, or -1 to add at the end of the list.
+ *
+ * @throws ArrayIndexOutOfBoundsException If the specified index is invalid.
+ */
+ protected void addImpl(Component comp, Object constraints, int index)
+ {
+ synchronized (getTreeLock ())
+ {
+ if (index > ncomponents
+ || (index < 0 && index != -1)
+ || comp instanceof Window
+ || (comp instanceof Container
+ && ((Container) comp).isAncestorOf(this)))
+ throw new IllegalArgumentException();
+
+ // Reparent component, and make sure component is instantiated if
+ // we are.
+ if (comp.parent != null)
+ comp.parent.remove(comp);
+ comp.parent = this;
+
+ if (peer != null)
+ {
+ // Notify the component that it has a new parent.
+ comp.addNotify();
+
+ if (comp.isLightweight ())
+ {
+ enableEvents (comp.eventMask);
+ if (!isLightweight ())
+ enableEvents (AWTEvent.PAINT_EVENT_MASK);
+ }
+ }
+
+ // Invalidate the layout of the added component and its ancestors.
+ comp.invalidate();
+
+ if (component == null)
+ component = new Component[4]; // FIXME, better initial size?
+
+ // This isn't the most efficient implementation. We could do less
+ // copying when growing the array. It probably doesn't matter.
+ if (ncomponents >= component.length)
+ {
+ int nl = component.length * 2;
+ Component[] c = new Component[nl];
+ System.arraycopy(component, 0, c, 0, ncomponents);
+ component = c;
+ }
+
+ if (index == -1)
+ component[ncomponents++] = comp;
+ else
+ {
+ System.arraycopy(component, index, component, index + 1,
+ ncomponents - index);
+ component[index] = comp;
+ ++ncomponents;
+ }
+
+ // Update the counter for Hierarchy(Bounds)Listeners.
+ int childHierarchyListeners = comp.numHierarchyListeners;
+ if (childHierarchyListeners > 0)
+ updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
+ childHierarchyListeners);
+ int childHierarchyBoundsListeners = comp.numHierarchyBoundsListeners;
+ if (childHierarchyBoundsListeners > 0)
+ updateHierarchyListenerCount(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
+ childHierarchyListeners);
+
+ // Notify the layout manager.
+ if (layoutMgr != null)
+ {
+ // If we have a LayoutManager2 the constraints are "real",
+ // otherwise they are the "name" of the Component to add.
+ if (layoutMgr instanceof LayoutManager2)
+ {
+ LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
+ lm2.addLayoutComponent(comp, constraints);
+ }
+ else if (constraints instanceof String)
+ layoutMgr.addLayoutComponent((String) constraints, comp);
+ else
+ layoutMgr.addLayoutComponent("", comp);
+ }
+
+ // We previously only sent an event when this container is showing.
+ // Also, the event was posted to the event queue. A Mauve test shows
+ // that this event is not delivered using the event queue and it is
+ // also sent when the container is not showing.
+ ContainerEvent ce = new ContainerEvent(this,
+ ContainerEvent.COMPONENT_ADDED,
+ comp);
+ ContainerListener[] listeners = getContainerListeners();
+ for (int i = 0; i < listeners.length; i++)
+ listeners[i].componentAdded(ce);
+
+ // Notify hierarchy listeners.
+ comp.fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED, comp,
+ this, HierarchyEvent.PARENT_CHANGED);
+ }
+ }
+
+ /**
+ * Removes the component at the specified index from this container.
+ *
+ * @param index The index of the component to remove.
+ */
+ public void remove(int index)
+ {
+ synchronized (getTreeLock ())
+ {
+ Component r = component[index];
+
+ ComponentListener[] list = r.getComponentListeners();
+ for (int j = 0; j < list.length; j++)
+ r.removeComponentListener(list[j]);
+
+ r.removeNotify();
+
+ System.arraycopy(component, index + 1, component, index,
+ ncomponents - index - 1);
+ component[--ncomponents] = null;
+
+ // Update the counter for Hierarchy(Bounds)Listeners.
+ int childHierarchyListeners = r.numHierarchyListeners;
+ if (childHierarchyListeners > 0)
+ updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
+ -childHierarchyListeners);
+ int childHierarchyBoundsListeners = r.numHierarchyBoundsListeners;
+ if (childHierarchyBoundsListeners > 0)
+ updateHierarchyListenerCount(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
+ -childHierarchyListeners);
+
+ invalidate();
+
+ if (layoutMgr != null)
+ layoutMgr.removeLayoutComponent(r);
+
+ r.parent = null;
+
+ if (isShowing ())
+ {
+ // Post event to notify of removing the component.
+ ContainerEvent ce = new ContainerEvent(this,
+ ContainerEvent.COMPONENT_REMOVED,
+ r);
+ getToolkit().getSystemEventQueue().postEvent(ce);
+ }
+
+ // Notify hierarchy listeners.
+ r.fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED, r,
+ this, HierarchyEvent.PARENT_CHANGED);
+ }
+ }
+
+ /**
+ * Removes the specified component from this container.
+ *
+ * @param comp The component to remove from this container.
+ */
+ public void remove(Component comp)
+ {
+ synchronized (getTreeLock ())
+ {
+ for (int i = 0; i < ncomponents; ++i)
+ {
+ if (component[i] == comp)
+ {
+ remove(i);
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Removes all components from this container.
+ */
+ public void removeAll()
+ {
+ synchronized (getTreeLock ())
+ {
+ // In order to allow the same bad tricks to be used as in RI
+ // this code has to stay exactly that way: In a real-life app
+ // a Container subclass implemented its own vector for
+ // subcomponents, supplied additional addXYZ() methods
+ // and overrode remove(int) and removeAll (the latter calling
+ // super.removeAll() ).
+ // By doing it this way, user code cannot prevent the correct
+ // removal of components.
+ for ( int index = 0; index < ncomponents; index++)
+ {
+ Component r = component[index];
+
+ ComponentListener[] list = r.getComponentListeners();
+ for (int j = 0; j < list.length; j++)
+ r.removeComponentListener(list[j]);
+
+ r.removeNotify();
+
+ if (layoutMgr != null)
+ layoutMgr.removeLayoutComponent(r);
+
+ r.parent = null;
+
+ if (isShowing ())
+ {
+ // Post event to notify of removing the component.
+ ContainerEvent ce
+ = new ContainerEvent(this,
+ ContainerEvent.COMPONENT_REMOVED,
+ r);
+
+ getToolkit().getSystemEventQueue().postEvent(ce);
+ }
+ }
+
+ invalidate();
+
+ ncomponents = 0;
+ }
+ }
+
+ /**
+ * Returns the current layout manager for this container.
+ *
+ * @return The layout manager for this container.
+ */
+ public LayoutManager getLayout()
+ {
+ return layoutMgr;
+ }
+
+ /**
+ * Sets the layout manager for this container to the specified layout
+ * manager.
+ *
+ * @param mgr The new layout manager for this container.
+ */
+ public void setLayout(LayoutManager mgr)
+ {
+ layoutMgr = mgr;
+ if (valid)
+ invalidate();
+ }
+
+ /**
+ * Layout the components in this container.
+ */
+ public void doLayout()
+ {
+ layout ();
+ }
+
+ /**
+ * Layout the components in this container.
+ *
+ * @deprecated use {@link #doLayout()} instead
+ */
+ public void layout()
+ {
+ if (layoutMgr != null)
+ layoutMgr.layoutContainer (this);
+ }
+
+ /**
+ * Invalidates this container to indicate that it (and all parent
+ * containers) need to be laid out.
+ */
+ public void invalidate()
+ {
+ super.invalidate();
+ if (layoutMgr != null && layoutMgr instanceof LayoutManager2)
+ {
+ LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
+ lm2.invalidateLayout(this);
+ }
+ }
+
+ /**
+ * Re-lays out the components in this container.
+ */
+ public void validate()
+ {
+ synchronized (getTreeLock ())
+ {
+ if (! isValid() && peer != null)
+ {
+ validateTree();
+ }
+ }
+ }
+
+ /**
+ * Recursively invalidates the container tree.
+ */
+ void invalidateTree()
+ {
+ synchronized (getTreeLock())
+ {
+ super.invalidate(); // Clean cached layout state.
+ for (int i = 0; i < ncomponents; i++)
+ {
+ Component comp = component[i];
+ comp.invalidate();
+ if (comp instanceof Container)
+ ((Container) comp).invalidateTree();
+ }
+
+ if (layoutMgr != null && layoutMgr instanceof LayoutManager2)
+ {
+ LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
+ lm2.invalidateLayout(this);
+ }
+ }
+ }
+
+ /**
+ * Recursively validates the container tree, recomputing any invalid
+ * layouts.
+ */
+ protected void validateTree()
+ {
+ if (valid)
+ return;
+
+ ContainerPeer cPeer = null;
+ if (peer != null && ! (peer instanceof LightweightPeer))
+ {
+ cPeer = (ContainerPeer) peer;
+ cPeer.beginValidate();
+ }
+
+ for (int i = 0; i < ncomponents; ++i)
+ {
+ Component comp = component[i];
+
+ if (comp.getPeer () == null)
+ comp.addNotify();
+ }
+
+ doLayout ();
+ for (int i = 0; i < ncomponents; ++i)
+ {
+ Component comp = component[i];
+
+ if (! comp.isValid())
+ {
+ if (comp instanceof Container)
+ {
+ ((Container) comp).validateTree();
+ }
+ else
+ {
+ component[i].validate();
+ }
+ }
+ }
+
+ /* children will call invalidate() when they are layed out. It
+ is therefore important that valid is not set to true
+ until after the children have been layed out. */
+ valid = true;
+
+ if (cPeer != null)
+ cPeer.endValidate();
+ }
+
+ public void setFont(Font f)
+ {
+ if( (f != null && (font == null || !font.equals(f)))
+ || f == null)
+ {
+ super.setFont(f);
+ // FIXME: Although it might make more sense to invalidate only
+ // those children whose font == null, Sun invalidates all children.
+ // So we'll do the same.
+ invalidateTree();
+ }
+ }
+
+ /**
+ * Returns the preferred size of this container.
+ *
+ * @return The preferred size of this container.
+ */
+ public Dimension getPreferredSize()
+ {
+ return preferredSize ();
+ }
+
+ /**
+ * Returns the preferred size of this container.
+ *
+ * @return The preferred size of this container.
+ *
+ * @deprecated use {@link #getPreferredSize()} instead
+ */
+ public Dimension preferredSize()
+ {
+ Dimension size = prefSize;
+ // Try to return cached value if possible.
+ if (size == null || !(prefSizeSet || valid))
+ {
+ // Need to lock here.
+ synchronized (getTreeLock())
+ {
+ LayoutManager l = layoutMgr;
+ if (l != null)
+ prefSize = l.preferredLayoutSize(this);
+ else
+ prefSize = super.preferredSizeImpl();
+ size = prefSize;
+ }
+ }
+ if (size != null)
+ return new Dimension(size);
+ else
+ return size;
+ }
+
+ /**
+ * Returns the minimum size of this container.
+ *
+ * @return The minimum size of this container.
+ */
+ public Dimension getMinimumSize()
+ {
+ return minimumSize ();
+ }
+
+ /**
+ * Returns the minimum size of this container.
+ *
+ * @return The minimum size of this container.
+ *
+ * @deprecated use {@link #getMinimumSize()} instead
+ */
+ public Dimension minimumSize()
+ {
+ Dimension size = minSize;
+ // Try to return cached value if possible.
+ if (size == null || !(minSizeSet || valid))
+ {
+ // Need to lock here.
+ synchronized (getTreeLock())
+ {
+ LayoutManager l = layoutMgr;
+ if (l != null)
+ minSize = l.minimumLayoutSize(this);
+ else
+ minSize = super.minimumSizeImpl();
+ size = minSize;
+ }
+ }
+ if (size != null)
+ return new Dimension(size);
+ else
+ return size;
+ }
+
+ /**
+ * Returns the maximum size of this container.
+ *
+ * @return The maximum size of this container.
+ */
+ public Dimension getMaximumSize()
+ {
+ Dimension size = maxSize;
+ // Try to return cached value if possible.
+ if (size == null || !(maxSizeSet || valid))
+ {
+ // Need to lock here.
+ synchronized (getTreeLock())
+ {
+ LayoutManager l = layoutMgr;
+ if (l instanceof LayoutManager2)
+ maxSize = ((LayoutManager2) l).maximumLayoutSize(this);
+ else
+ maxSize = super.maximumSizeImpl();
+ size = maxSize;
+ }
+ }
+ if (size != null)
+ return new Dimension(size);
+ else
+ return size;
+ }
+
+ /**
+ * Returns the preferred alignment along the X axis. This is a value
+ * between 0 and 1 where 0 represents alignment flush left and
+ * 1 means alignment flush right, and 0.5 means centered.
+ *
+ * @return The preferred alignment along the X axis.
+ */
+ public float getAlignmentX()
+ {
+ LayoutManager layout = getLayout();
+ float alignmentX = 0.0F;
+ if (layout != null && layout instanceof LayoutManager2)
+ {
+ synchronized (getTreeLock())
+ {
+ LayoutManager2 lm2 = (LayoutManager2) layout;
+ alignmentX = lm2.getLayoutAlignmentX(this);
+ }
+ }
+ else
+ alignmentX = super.getAlignmentX();
+ return alignmentX;
+ }
+
+ /**
+ * Returns the preferred alignment along the Y axis. This is a value
+ * between 0 and 1 where 0 represents alignment flush top and
+ * 1 means alignment flush bottom, and 0.5 means centered.
+ *
+ * @return The preferred alignment along the Y axis.
+ */
+ public float getAlignmentY()
+ {
+ LayoutManager layout = getLayout();
+ float alignmentY = 0.0F;
+ if (layout != null && layout instanceof LayoutManager2)
+ {
+ synchronized (getTreeLock())
+ {
+ LayoutManager2 lm2 = (LayoutManager2) layout;
+ alignmentY = lm2.getLayoutAlignmentY(this);
+ }
+ }
+ else
+ alignmentY = super.getAlignmentY();
+ return alignmentY;
+ }
+
+ /**
+ * Paints this container. The implementation of this method in this
+ * class forwards to any lightweight components in this container. If
+ * this method is subclassed, this method should still be invoked as
+ * a superclass method so that lightweight components are properly
+ * drawn.
+ *
+ * @param g - The graphics context for this paint job.
+ */
+ public void paint(Graphics g)
+ {
+ if (isShowing())
+ {
+ visitChildren(g, GfxPaintVisitor.INSTANCE, true);
+ }
+ }
+
+ /**
+ * Updates this container. The implementation of this method in this
+ * class forwards to any lightweight components in this container. If
+ * this method is subclassed, this method should still be invoked as
+ * a superclass method so that lightweight components are properly
+ * drawn.
+ *
+ * @param g The graphics context for this update.
+ *
+ * @specnote The specification suggests that this method forwards the
+ * update() call to all its lightweight children. Tests show
+ * that this is not done either in the JDK. The exact behaviour
+ * seems to be that the background is cleared in heavyweight
+ * Containers, and all other containers
+ * directly call paint(), causing the (lightweight) children to
+ * be painted.
+ */
+ public void update(Graphics g)
+ {
+ // It seems that the JDK clears the background of containers like Panel
+ // and Window (within this method) but not of 'plain' Containers or
+ // JComponents. This could
+ // lead to the assumption that it only clears heavyweight containers.
+ // However that is not quite true. In a test with a custom Container
+ // that overrides isLightweight() to return false, the background is
+ // also not cleared. So we do a check on !(peer instanceof LightweightPeer)
+ // instead.
+ if (isShowing())
+ {
+ ComponentPeer p = peer;
+ if (! (p instanceof LightweightPeer))
+ {
+ g.clearRect(0, 0, getWidth(), getHeight());
+ }
+ paint(g);
+ }
+ }
+
+ /**
+ * Prints this container. The implementation of this method in this
+ * class forwards to any lightweight components in this container. If
+ * this method is subclassed, this method should still be invoked as
+ * a superclass method so that lightweight components are properly
+ * drawn.
+ *
+ * @param g The graphics context for this print job.
+ */
+ public void print(Graphics g)
+ {
+ super.print(g);
+ visitChildren(g, GfxPrintVisitor.INSTANCE, true);
+ }
+
+ /**
+ * Paints all of the components in this container.
+ *
+ * @param g The graphics context for this paint job.
+ */
+ public void paintComponents(Graphics g)
+ {
+ paint(g);
+ visitChildren(g, GfxPaintAllVisitor.INSTANCE, true);
+ }
+
+ /**
+ * Prints all of the components in this container.
+ *
+ * @param g The graphics context for this print job.
+ */
+ public void printComponents(Graphics g)
+ {
+ super.paint(g);
+ visitChildren(g, GfxPrintAllVisitor.INSTANCE, true);
+ }
+
+ /**
+ * Adds the specified container listener to this object's list of
+ * container listeners.
+ *
+ * @param listener The listener to add.
+ */
+ public synchronized void addContainerListener(ContainerListener listener)
+ {
+ containerListener = AWTEventMulticaster.add(containerListener, listener);
+ }
+
+ /**
+ * Removes the specified container listener from this object's list of
+ * container listeners.
+ *
+ * @param listener The listener to remove.
+ */
+ public synchronized void removeContainerListener(ContainerListener listener)
+ {
+ containerListener = AWTEventMulticaster.remove(containerListener, listener);
+ }
+
+ /**
+ * @since 1.4
+ */
+ public synchronized ContainerListener[] getContainerListeners()
+ {
+ return (ContainerListener[])
+ AWTEventMulticaster.getListeners(containerListener,
+ ContainerListener.class);
+ }
+
+ /**
+ * Returns all registered {@link EventListener}s of the given
+ * <code>listenerType</code>.
+ *
+ * @param listenerType the class of listeners to filter (<code>null</code>
+ * not permitted).
+ *
+ * @return An array of registered listeners.
+ *
+ * @throws ClassCastException if <code>listenerType</code> does not implement
+ * the {@link EventListener} interface.
+ * @throws NullPointerException if <code>listenerType</code> is
+ * <code>null</code>.
+ *
+ * @see #getContainerListeners()
+ *
+ * @since 1.3
+ */
+ public EventListener[] getListeners(Class listenerType)
+ {
+ if (listenerType == ContainerListener.class)
+ return getContainerListeners();
+ return super.getListeners(listenerType);
+ }
+
+ /**
+ * Processes the specified event. This method calls
+ * <code>processContainerEvent()</code> if this method is a
+ * <code>ContainerEvent</code>, otherwise it calls the superclass
+ * method.
+ *
+ * @param e The event to be processed.
+ */
+ protected void processEvent(AWTEvent e)
+ {
+ if (e instanceof ContainerEvent)
+ processContainerEvent((ContainerEvent) e);
+ else
+ super.processEvent(e);
+ }
+
+ /**
+ * Called when a container event occurs if container events are enabled.
+ * This method calls any registered listeners.
+ *
+ * @param e The event that occurred.
+ */
+ protected void processContainerEvent(ContainerEvent e)
+ {
+ if (containerListener == null)
+ return;
+ switch (e.id)
+ {
+ case ContainerEvent.COMPONENT_ADDED:
+ containerListener.componentAdded(e);
+ break;
+
+ case ContainerEvent.COMPONENT_REMOVED:
+ containerListener.componentRemoved(e);
+ break;
+ }
+ }
+
+ /**
+ * AWT 1.0 event processor.
+ *
+ * @param e The event that occurred.
+ *
+ * @deprecated use {@link #dispatchEvent(AWTEvent)} instead
+ */
+ public void deliverEvent(Event e)
+ {
+ if (!handleEvent (e))
+ {
+ synchronized (getTreeLock ())
+ {
+ Component parent = getParent ();
+
+ if (parent != null)
+ parent.deliverEvent (e);
+ }
+ }
+ }
+
+ /**
+ * Returns the component located at the specified point. This is done
+ * by checking whether or not a child component claims to contain this
+ * point. The first child component that does is returned. If no
+ * child component claims the point, the container itself is returned,
+ * unless the point does not exist within this container, in which
+ * case <code>null</code> is returned.
+ *
+ * When components overlap, the first component is returned. The component
+ * that is closest to (x, y), containing that location, is returned.
+ * Heavyweight components take precedence of lightweight components.
+ *
+ * This function does not ignore invisible components. If there is an invisible
+ * component at (x,y), it will be returned.
+ *
+ * @param x The X coordinate of the point.
+ * @param y The Y coordinate of the point.
+ *
+ * @return The component containing the specified point, or
+ * <code>null</code> if there is no such point.
+ */
+ public Component getComponentAt(int x, int y)
+ {
+ return locate (x, y);
+ }
+
+ /**
+ * Returns the component located at the specified point. This is done
+ * by checking whether or not a child component claims to contain this
+ * point. The first child component that does is returned. If no
+ * child component claims the point, the container itself is returned,
+ * unless the point does not exist within this container, in which
+ * case <code>null</code> is returned.
+ *
+ * When components overlap, the first component is returned. The component
+ * that is closest to (x, y), containing that location, is returned.
+ * Heavyweight components take precedence of lightweight components.
+ *
+ * This function does not ignore invisible components. If there is an invisible
+ * component at (x,y), it will be returned.
+ *
+ * @param x The x position of the point to return the component at.
+ * @param y The y position of the point to return the component at.
+ *
+ * @return The component containing the specified point, or <code>null</code>
+ * if there is no such point.
+ *
+ * @deprecated use {@link #getComponentAt(int, int)} instead
+ */
+ public Component locate(int x, int y)
+ {
+ synchronized (getTreeLock ())
+ {
+ if (!contains (x, y))
+ return null;
+
+ // First find the component closest to (x,y) that is a heavyweight.
+ for (int i = 0; i < ncomponents; ++i)
+ {
+ Component comp = component[i];
+ int x2 = x - comp.x;
+ int y2 = y - comp.y;
+ if (comp.contains (x2, y2) && !comp.isLightweight())
+ return comp;
+ }
+
+ // if a heavyweight component is not found, look for a lightweight
+ // closest to (x,y).
+ for (int i = 0; i < ncomponents; ++i)
+ {
+ Component comp = component[i];
+ int x2 = x - comp.x;
+ int y2 = y - comp.y;
+ if (comp.contains (x2, y2) && comp.isLightweight())
+ return comp;
+ }
+
+ return this;
+ }
+ }
+
+ /**
+ * Returns the component located at the specified point. This is done
+ * by checking whether or not a child component claims to contain this
+ * point. The first child component that does is returned. If no
+ * child component claims the point, the container itself is returned,
+ * unless the point does not exist within this container, in which
+ * case <code>null</code> is returned.
+ *
+ * The top-most child component is returned in the case where components overlap.
+ * This is determined by finding the component closest to (x,y) and contains
+ * that location. Heavyweight components take precedence of lightweight components.
+ *
+ * This function does not ignore invisible components. If there is an invisible
+ * component at (x,y), it will be returned.
+ *
+ * @param p The point to return the component at.
+ * @return The component containing the specified point, or <code>null</code>
+ * if there is no such point.
+ */
+ public Component getComponentAt(Point p)
+ {
+ return getComponentAt (p.x, p.y);
+ }
+
+ /**
+ * Locates the visible child component that contains the specified position.
+ * The top-most child component is returned in the case where there is overlap
+ * in the components. If the containing child component is a Container,
+ * this method will continue searching for the deepest nested child
+ * component. Components which are not visible are ignored during the search.
+ *
+ * findComponentAt differs from getComponentAt, because it recursively
+ * searches a Container's children.
+ *
+ * @param x - x coordinate
+ * @param y - y coordinate
+ * @return null if the component does not contain the position.
+ * If there is no child component at the requested point and the point is
+ * within the bounds of the container the container itself is returned.
+ */
+ public Component findComponentAt(int x, int y)
+ {
+ synchronized (getTreeLock ())
+ {
+ if (! contains(x, y))
+ return null;
+
+ for (int i = 0; i < ncomponents; ++i)
+ {
+ // Ignore invisible children...
+ if (!component[i].isVisible())
+ continue;
+
+ int x2 = x - component[i].x;
+ int y2 = y - component[i].y;
+ // We don't do the contains() check right away because
+ // findComponentAt would redundantly do it first thing.
+ if (component[i] instanceof Container)
+ {
+ Container k = (Container) component[i];
+ Component r = k.findComponentAt(x2, y2);
+ if (r != null)
+ return r;
+ }
+ else if (component[i].contains(x2, y2))
+ return component[i];
+ }
+
+ return this;
+ }
+ }
+
+ /**
+ * Locates the visible child component that contains the specified position.
+ * The top-most child component is returned in the case where there is overlap
+ * in the components. If the containing child component is a Container,
+ * this method will continue searching for the deepest nested child
+ * component. Components which are not visible are ignored during the search.
+ *
+ * findComponentAt differs from getComponentAt, because it recursively
+ * searches a Container's children.
+ *
+ * @param p - the component's location
+ * @return null if the component does not contain the position.
+ * If there is no child component at the requested point and the point is
+ * within the bounds of the container the container itself is returned.
+ */
+ public Component findComponentAt(Point p)
+ {
+ return findComponentAt(p.x, p.y);
+ }
+
+ /**
+ * Called when this container is added to another container to inform it
+ * to create its peer. Peers for any child components will also be
+ * created.
+ */
+ public void addNotify()
+ {
+ synchronized (getTreeLock())
+ {
+ super.addNotify();
+ addNotifyContainerChildren();
+ }
+ }
+
+ /**
+ * Called when this container is removed from its parent container to
+ * inform it to destroy its peer. This causes the peers of all child
+ * component to be destroyed as well.
+ */
+ public void removeNotify()
+ {
+ synchronized (getTreeLock ())
+ {
+ for (int i = 0; i < ncomponents; ++i)
+ component[i].removeNotify();
+ super.removeNotify();
+ }
+ }
+
+ /**
+ * Tests whether or not the specified component is contained within
+ * this components subtree.
+ *
+ * @param comp The component to test.
+ *
+ * @return <code>true</code> if this container is an ancestor of the
+ * specified component, <code>false</code> otherwise.
+ */
+ public boolean isAncestorOf(Component comp)
+ {
+ synchronized (getTreeLock ())
+ {
+ while (true)
+ {
+ if (comp == null)
+ return false;
+ if (comp == this)
+ return true;
+ comp = comp.getParent();
+ }
+ }
+ }
+
+ /**
+ * Returns a string representing the state of this container for
+ * debugging purposes.
+ *
+ * @return A string representing the state of this container.
+ */
+ protected String paramString()
+ {
+ if (layoutMgr == null)
+ return super.paramString();
+
+ StringBuffer sb = new StringBuffer();
+ sb.append(super.paramString());
+ sb.append(",layout=");
+ sb.append(layoutMgr.getClass().getName());
+ return sb.toString();
+ }
+
+ /**
+ * Writes a listing of this container to the specified stream starting
+ * at the specified indentation point.
+ *
+ * @param out The <code>PrintStream</code> to write to.
+ * @param indent The indentation point.
+ */
+ public void list(PrintStream out, int indent)
+ {
+ synchronized (getTreeLock ())
+ {
+ super.list(out, indent);
+ for (int i = 0; i < ncomponents; ++i)
+ component[i].list(out, indent + 2);
+ }
+ }
+
+ /**
+ * Writes a listing of this container to the specified stream starting
+ * at the specified indentation point.
+ *
+ * @param out The <code>PrintWriter</code> to write to.
+ * @param indent The indentation point.
+ */
+ public void list(PrintWriter out, int indent)
+ {
+ synchronized (getTreeLock ())
+ {
+ super.list(out, indent);
+ for (int i = 0; i < ncomponents; ++i)
+ component[i].list(out, indent + 2);
+ }
+ }
+
+ /**
+ * Sets the focus traversal keys for a given traversal operation for this
+ * Container.
+ *
+ * @exception IllegalArgumentException If id is not one of
+ * KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
+ * KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
+ * KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS,
+ * or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS,
+ * or if keystrokes contains null, or if any Object in keystrokes is not an
+ * AWTKeyStroke, or if any keystroke represents a KEY_TYPED event, or if any
+ * keystroke already maps to another focus traversal operation for this
+ * Container.
+ *
+ * @since 1.4
+ */
+ public void setFocusTraversalKeys(int id, Set keystrokes)
+ {
+ if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&
+ id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&
+ id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS &&
+ id != KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS)
+ throw new IllegalArgumentException ();
+
+ if (keystrokes == null)
+ {
+ Container parent = getParent ();
+
+ while (parent != null)
+ {
+ if (parent.areFocusTraversalKeysSet (id))
+ {
+ keystrokes = parent.getFocusTraversalKeys (id);
+ break;
+ }
+ parent = parent.getParent ();
+ }
+
+ if (keystrokes == null)
+ keystrokes = KeyboardFocusManager.getCurrentKeyboardFocusManager ().
+ getDefaultFocusTraversalKeys (id);
+ }
+
+ Set sa;
+ Set sb;
+ Set sc;
+ String name;
+ switch (id)
+ {
+ case KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS:
+ sa = getFocusTraversalKeys
+ (KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
+ sb = getFocusTraversalKeys
+ (KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS);
+ sc = getFocusTraversalKeys
+ (KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS);
+ name = "forwardFocusTraversalKeys";
+ break;
+ case KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS:
+ sa = getFocusTraversalKeys
+ (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
+ sb = getFocusTraversalKeys
+ (KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS);
+ sc = getFocusTraversalKeys
+ (KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS);
+ name = "backwardFocusTraversalKeys";
+ break;
+ case KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS:
+ sa = getFocusTraversalKeys
+ (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
+ sb = getFocusTraversalKeys
+ (KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
+ sc = getFocusTraversalKeys
+ (KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS);
+ name = "upCycleFocusTraversalKeys";
+ break;
+ case KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS:
+ sa = getFocusTraversalKeys
+ (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
+ sb = getFocusTraversalKeys
+ (KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
+ sc = getFocusTraversalKeys
+ (KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS);
+ name = "downCycleFocusTraversalKeys";
+ break;
+ default:
+ throw new IllegalArgumentException ();
+ }
+
+ int i = keystrokes.size ();
+ Iterator iter = keystrokes.iterator ();
+
+ while (--i >= 0)
+ {
+ Object o = iter.next ();
+ if (!(o instanceof AWTKeyStroke)
+ || sa.contains (o) || sb.contains (o) || sc.contains (o)
+ || ((AWTKeyStroke) o).keyCode == KeyEvent.VK_UNDEFINED)
+ throw new IllegalArgumentException ();
+ }
+
+ if (focusTraversalKeys == null)
+ focusTraversalKeys = new Set[4];
+
+ keystrokes = Collections.unmodifiableSet (new HashSet (keystrokes));
+ firePropertyChange (name, focusTraversalKeys[id], keystrokes);
+
+ focusTraversalKeys[id] = keystrokes;
+ }
+
+ /**
+ * Returns the Set of focus traversal keys for a given traversal operation for
+ * this Container.
+ *
+ * @exception IllegalArgumentException If id is not one of
+ * KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
+ * KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
+ * KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS,
+ * or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS.
+ *
+ * @since 1.4
+ */
+ public Set getFocusTraversalKeys (int id)
+ {
+ if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&
+ id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&
+ id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS &&
+ id != KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS)
+ throw new IllegalArgumentException ();
+
+ Set s = null;
+
+ if (focusTraversalKeys != null)
+ s = focusTraversalKeys[id];
+
+ if (s == null && parent != null)
+ s = parent.getFocusTraversalKeys (id);
+
+ return s == null ? (KeyboardFocusManager.getCurrentKeyboardFocusManager()
+ .getDefaultFocusTraversalKeys(id)) : s;
+ }
+
+ /**
+ * Returns whether the Set of focus traversal keys for the given focus
+ * traversal operation has been explicitly defined for this Container.
+ * If this method returns false, this Container is inheriting the Set from
+ * an ancestor, or from the current KeyboardFocusManager.
+ *
+ * @exception IllegalArgumentException If id is not one of
+ * KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
+ * KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
+ * KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS,
+ * or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS.
+ *
+ * @since 1.4
+ */
+ public boolean areFocusTraversalKeysSet (int id)
+ {
+ if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&
+ id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&
+ id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS &&
+ id != KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS)
+ throw new IllegalArgumentException ();
+
+ return focusTraversalKeys != null && focusTraversalKeys[id] != null;
+ }
+
+ /**
+ * Check whether the given Container is the focus cycle root of this
+ * Container's focus traversal cycle. If this Container is a focus
+ * cycle root itself, then it will be in two different focus cycles
+ * -- it's own, and that of its ancestor focus cycle root's. In
+ * that case, if <code>c</code> is either of those containers, this
+ * method will return true.
+ *
+ * @param c the candidate Container
+ *
+ * @return true if c is the focus cycle root of the focus traversal
+ * cycle to which this Container belongs, false otherwise
+ *
+ * @since 1.4
+ */
+ public boolean isFocusCycleRoot (Container c)
+ {
+ if (this == c
+ && isFocusCycleRoot ())
+ return true;
+
+ Container ancestor = getFocusCycleRootAncestor ();
+
+ if (c == ancestor)
+ return true;
+
+ return false;
+ }
+
+ /**
+ * If this Container is a focus cycle root, set the focus traversal
+ * policy that determines the focus traversal order for its
+ * children. If non-null, this policy will be inherited by all
+ * inferior focus cycle roots. If <code>policy</code> is null, this
+ * Container will inherit its policy from the closest ancestor focus
+ * cycle root that's had its policy set.
+ *
+ * @param policy the new focus traversal policy for this Container or null
+ *
+ * @since 1.4
+ */
+ public void setFocusTraversalPolicy (FocusTraversalPolicy policy)
+ {
+ focusTraversalPolicy = policy;
+ }
+
+ /**
+ * Return the focus traversal policy that determines the focus
+ * traversal order for this Container's children. This method
+ * returns null if this Container is not a focus cycle root. If the
+ * focus traversal policy has not been set explicitly, then this
+ * method will return an ancestor focus cycle root's policy instead.
+ *
+ * @return this Container's focus traversal policy or null
+ *
+ * @since 1.4
+ */
+ public FocusTraversalPolicy getFocusTraversalPolicy ()
+ {
+ if (!isFocusCycleRoot ())
+ return null;
+
+ if (focusTraversalPolicy == null)
+ {
+ Container ancestor = getFocusCycleRootAncestor ();
+
+ if (ancestor != this && ancestor != null)
+ return ancestor.getFocusTraversalPolicy ();
+ else
+ {
+ KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
+
+ return manager.getDefaultFocusTraversalPolicy ();
+ }
+ }
+ else
+ return focusTraversalPolicy;
+ }
+
+ /**
+ * Check whether this Container's focus traversal policy has been
+ * explicitly set. If it has not, then this Container will inherit
+ * its focus traversal policy from one of its ancestor focus cycle
+ * roots.
+ *
+ * @return true if focus traversal policy is set, false otherwise
+ */
+ public boolean isFocusTraversalPolicySet ()
+ {
+ return focusTraversalPolicy == null;
+ }
+
+ /**
+ * Set whether or not this Container is the root of a focus
+ * traversal cycle. This Container's focus traversal policy
+ * determines the order of focus traversal. Some policies prevent
+ * the focus from being transferred between two traversal cycles
+ * until an up or down traversal operation is performed. In that
+ * case, normal traversal (not up or down) is limited to this
+ * Container and all of this Container's descendents that are not
+ * descendents of inferior focus cycle roots. In the default case
+ * however, ContainerOrderFocusTraversalPolicy is in effect, and it
+ * supports implicit down-cycle traversal operations.
+ *
+ * @param focusCycleRoot true if this is a focus cycle root, false otherwise
+ *
+ * @since 1.4
+ */
+ public void setFocusCycleRoot (boolean focusCycleRoot)
+ {
+ this.focusCycleRoot = focusCycleRoot;
+ }
+
+ /**
+ * Set to <code>true</code> if this container provides a focus traversal
+ * policy, <code>false</code> when the root container's focus
+ * traversal policy should be used.
+ *
+ * @return <code>true</code> if this container provides a focus traversal
+ * policy, <code>false</code> when the root container's focus
+ * traversal policy should be used
+ *
+ * @see #setFocusTraversalPolicyProvider(boolean)
+ *
+ * @since 1.5
+ */
+ public final boolean isFocusTraversalPolicyProvider()
+ {
+ return focusTraversalPolicyProvider;
+ }
+
+ /**
+ * Set to <code>true</code> if this container provides a focus traversal
+ * policy, <code>false</code> when the root container's focus
+ * traversal policy should be used.
+ *
+ * @param b <code>true</code> if this container provides a focus traversal
+ * policy, <code>false</code> when the root container's focus
+ * traversal policy should be used
+ *
+ * @see #isFocusTraversalPolicyProvider()
+ *
+ * @since 1.5
+ */
+ public final void setFocusTraversalPolicyProvider(boolean b)
+ {
+ focusTraversalPolicyProvider = b;
+ }
+
+ /**
+ * Check whether this Container is a focus cycle root.
+ *
+ * @return true if this is a focus cycle root, false otherwise
+ *
+ * @since 1.4
+ */
+ public boolean isFocusCycleRoot ()
+ {
+ return focusCycleRoot;
+ }
+
+ /**
+ * Transfer focus down one focus traversal cycle. If this Container
+ * is a focus cycle root, then its default component becomes the
+ * focus owner, and this Container becomes the current focus cycle
+ * root. No traversal will occur if this Container is not a focus
+ * cycle root.
+ *
+ * @since 1.4
+ */
+ public void transferFocusDownCycle ()
+ {
+ if (isFocusCycleRoot())
+ {
+ KeyboardFocusManager fm =
+ KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ fm.setGlobalCurrentFocusCycleRoot(this);
+ FocusTraversalPolicy policy = getFocusTraversalPolicy();
+ Component defaultComponent = policy.getDefaultComponent(this);
+ if (defaultComponent != null)
+ defaultComponent.requestFocus();
+ }
+ }
+
+ /**
+ * Sets the ComponentOrientation property of this container and all components
+ * contained within it.
+ *
+ * @exception NullPointerException If orientation is null
+ *
+ * @since 1.4
+ */
+ public void applyComponentOrientation (ComponentOrientation orientation)
+ {
+ if (orientation == null)
+ throw new NullPointerException();
+
+ setComponentOrientation(orientation);
+ for (int i = 0; i < ncomponents; i++)
+ {
+ if (component[i] instanceof Container)
+ ((Container) component[i]).applyComponentOrientation(orientation);
+ else
+ component[i].setComponentOrientation(orientation);
+ }
+ }
+
+ public void addPropertyChangeListener (PropertyChangeListener listener)
+ {
+ // TODO: Why is this overridden?
+ super.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener (String propertyName,
+ PropertyChangeListener listener)
+ {
+ // TODO: Why is this overridden?
+ super.addPropertyChangeListener(propertyName, listener);
+ }
+
+
+ /**
+ * Sets the Z ordering for the component <code>comp</code> to
+ * <code>index</code>. Components with lower Z order paint above components
+ * with higher Z order.
+ *
+ * @param comp the component for which to change the Z ordering
+ * @param index the index to set
+ *
+ * @throws NullPointerException if <code>comp == null</code>
+ * @throws IllegalArgumentException if comp is an ancestor of this container
+ * @throws IllegalArgumentException if <code>index</code> is not in
+ * <code>[0, getComponentCount()]</code> for moving between
+ * containers or <code>[0, getComponentCount() - 1]</code> for moving
+ * inside this container
+ * @throws IllegalArgumentException if <code>comp == this</code>
+ * @throws IllegalArgumentException if <code>comp</code> is a
+ * <code>Window</code>
+ *
+ * @see #getComponentZOrder(Component)
+ *
+ * @since 1.5
+ */
+ public final void setComponentZOrder(Component comp, int index)
+ {
+ if (comp == null)
+ throw new NullPointerException("comp must not be null");
+ if (comp instanceof Container && ((Container) comp).isAncestorOf(this))
+ throw new IllegalArgumentException("comp must not be an ancestor of "
+ + "this");
+ if (comp instanceof Window)
+ throw new IllegalArgumentException("comp must not be a Window");
+
+ if (comp == this)
+ throw new IllegalArgumentException("cannot add component to itself");
+
+ synchronized (getTreeLock())
+ {
+ // FIXME: Implement reparenting.
+ if ( comp.getParent() != this)
+ throw new AssertionError("Reparenting is not implemented yet");
+ else
+ {
+ // Find current component index.
+ int currentIndex = getComponentZOrder(comp);
+ if (currentIndex < index)
+ {
+ System.arraycopy(component, currentIndex + 1, component,
+ currentIndex, index - currentIndex);
+ }
+ else
+ {
+ System.arraycopy(component, index, component, index + 1,
+ currentIndex - index);
+ }
+ component[index] = comp;
+ }
+ }
+ }
+
+ /**
+ * Returns the Z ordering index of <code>comp</code>. If <code>comp</code>
+ * is not a child component of this Container, this returns <code>-1</code>.
+ *
+ * @param comp the component for which to query the Z ordering
+ *
+ * @return the Z ordering index of <code>comp</code> or <code>-1</code> if
+ * <code>comp</code> is not a child of this Container
+ *
+ * @see #setComponentZOrder(Component, int)
+ *
+ * @since 1.5
+ */
+ public final int getComponentZOrder(Component comp)
+ {
+ synchronized (getTreeLock())
+ {
+ int index = -1;
+ if (component != null)
+ {
+ for (int i = 0; i < ncomponents; i++)
+ {
+ if (component[i] == comp)
+ {
+ index = i;
+ break;
+ }
+ }
+ }
+ return index;
+ }
+ }
+
+ // Hidden helper methods.
+
+ /**
+ * Perform a graphics operation on the children of this container.
+ * For each applicable child, the visitChild() method will be called
+ * to perform the graphics operation.
+ *
+ * @param gfx The graphics object that will be used to derive new
+ * graphics objects for the children.
+ *
+ * @param visitor Object encapsulating the graphics operation that
+ * should be performed.
+ *
+ * @param lightweightOnly If true, only lightweight components will
+ * be visited.
+ */
+ private void visitChildren(Graphics gfx, GfxVisitor visitor,
+ boolean lightweightOnly)
+ {
+ synchronized (getTreeLock())
+ {
+ for (int i = ncomponents - 1; i >= 0; --i)
+ {
+ Component comp = component[i];
+ boolean applicable = comp.isVisible()
+ && (comp.isLightweight() || ! lightweightOnly);
+
+ if (applicable)
+ visitChild(gfx, visitor, comp);
+ }
+ }
+ }
+
+ /**
+ * Perform a graphics operation on a child. A translated and clipped
+ * graphics object will be created, and the visit() method of the
+ * visitor will be called to perform the operation.
+ *
+ * @param gfx The graphics object that will be used to derive new
+ * graphics objects for the child.
+ *
+ * @param visitor Object encapsulating the graphics operation that
+ * should be performed.
+ *
+ * @param comp The child component that should be visited.
+ */
+ private void visitChild(Graphics gfx, GfxVisitor visitor,
+ Component comp)
+ {
+ Rectangle bounds = comp.getBounds();
+
+ if(!gfx.hitClip(bounds.x,bounds.y, bounds.width, bounds.height))
+ return;
+ Graphics g2 = gfx.create(bounds.x, bounds.y, bounds.width,
+ bounds.height);
+ try
+ {
+ visitor.visit(comp, g2);
+ }
+ finally
+ {
+ g2.dispose();
+ }
+ }
+
+ void dispatchEventImpl(AWTEvent e)
+ {
+ boolean dispatched =
+ LightweightDispatcher.getInstance().dispatchEvent(e);
+ if (! dispatched)
+ {
+ if ((e.id <= ContainerEvent.CONTAINER_LAST
+ && e.id >= ContainerEvent.CONTAINER_FIRST)
+ && (containerListener != null
+ || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0))
+ processEvent(e);
+ else
+ super.dispatchEventImpl(e);
+ }
+ }
+
+ /**
+ * Tests if this container has an interest in the given event id.
+ *
+ * @param eventId The event id to check.
+ *
+ * @return <code>true</code> if a listener for the event id exists or
+ * if the eventMask is set for the event id.
+ *
+ * @see java.awt.Component#eventTypeEnabled(int)
+ */
+ boolean eventTypeEnabled(int eventId)
+ {
+ if(eventId <= ContainerEvent.CONTAINER_LAST
+ && eventId >= ContainerEvent.CONTAINER_FIRST)
+ return containerListener != null
+ || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0;
+ else
+ return super.eventTypeEnabled(eventId);
+ }
+
+ // This is used to implement Component.transferFocus.
+ Component findNextFocusComponent(Component child)
+ {
+ synchronized (getTreeLock ())
+ {
+ int start, end;
+ if (child != null)
+ {
+ for (start = 0; start < ncomponents; ++start)
+ {
+ if (component[start] == child)
+ break;
+ }
+ end = start;
+ // This special case lets us be sure to terminate.
+ if (end == 0)
+ end = ncomponents;
+ ++start;
+ }
+ else
+ {
+ start = 0;
+ end = ncomponents;
+ }
+
+ for (int j = start; j != end; ++j)
+ {
+ if (j >= ncomponents)
+ {
+ // The JCL says that we should wrap here. However, that
+ // seems wrong. To me it seems that focus order should be
+ // global within in given window. So instead if we reach
+ // the end we try to look in our parent, if we have one.
+ if (parent != null)
+ return parent.findNextFocusComponent(this);
+ j -= ncomponents;
+ }
+ if (component[j] instanceof Container)
+ {
+ Component c = component[j];
+ c = c.findNextFocusComponent(null);
+ if (c != null)
+ return c;
+ }
+ else if (component[j].isFocusTraversable())
+ return component[j];
+ }
+
+ return null;
+ }
+ }
+
+ /**
+ * Fires hierarchy events to the children of this container and this
+ * container itself. This overrides {@link Component#fireHierarchyEvent}
+ * in order to forward this event to all children.
+ */
+ void fireHierarchyEvent(int id, Component changed, Container parent,
+ long flags)
+ {
+ // Only propagate event if there is actually a listener waiting for it.
+ if ((id == HierarchyEvent.HIERARCHY_CHANGED && numHierarchyListeners > 0)
+ || ((id == HierarchyEvent.ANCESTOR_MOVED
+ || id == HierarchyEvent.ANCESTOR_RESIZED)
+ && numHierarchyBoundsListeners > 0))
+ {
+ for (int i = 0; i < ncomponents; i++)
+ component[i].fireHierarchyEvent(id, changed, parent, flags);
+ super.fireHierarchyEvent(id, changed, parent, flags);
+ }
+ }
+
+ /**
+ * Adjusts the number of hierarchy listeners of this container and all of
+ * its parents. This is called by the add/remove listener methods and
+ * structure changing methods in Container.
+ *
+ * @param type the type, either {@link AWTEvent#HIERARCHY_BOUNDS_EVENT_MASK}
+ * or {@link AWTEvent#HIERARCHY_EVENT_MASK}
+ * @param delta the number of listeners added or removed
+ */
+ void updateHierarchyListenerCount(long type, int delta)
+ {
+ if (type == AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK)
+ numHierarchyBoundsListeners += delta;
+ else if (type == AWTEvent.HIERARCHY_EVENT_MASK)
+ numHierarchyListeners += delta;
+ else
+ assert false : "Should not reach here";
+
+ if (parent != null)
+ parent.updateHierarchyListenerCount(type, delta);
+ }
+
+ private void addNotifyContainerChildren()
+ {
+ synchronized (getTreeLock ())
+ {
+ for (int i = ncomponents; --i >= 0; )
+ {
+ component[i].addNotify();
+ if (component[i].isLightweight ())
+ {
+ enableEvents(component[i].eventMask);
+ if (peer != null && !isLightweight ())
+ enableEvents (AWTEvent.PAINT_EVENT_MASK);
+ }
+ }
+ }
+ }
+
+ /**
+ * Deserialize this Container:
+ * <ol>
+ * <li>Read from the stream the default serializable fields.</li>
+ * <li>Read a list of serializable ContainerListeners as optional
+ * data. If the list is null, no listeners will be registered.</li>
+ * <li>Read this Container's FocusTraversalPolicy as optional data.
+ * If this is null, then this Container will use a
+ * DefaultFocusTraversalPolicy.</li>
+ * </ol>
+ *
+ * @param s the stream to read from
+ * @throws ClassNotFoundException if deserialization fails
+ * @throws IOException if the stream fails
+ */
+ private void readObject (ObjectInputStream s)
+ throws ClassNotFoundException, IOException
+ {
+ s.defaultReadObject ();
+ String key = (String) s.readObject ();
+ while (key != null)
+ {
+ Object object = s.readObject ();
+ if ("containerL".equals (key))
+ addContainerListener((ContainerListener) object);
+ // FIXME: under what key is the focus traversal policy stored?
+ else if ("focusTraversalPolicy".equals (key))
+ setFocusTraversalPolicy ((FocusTraversalPolicy) object);
+
+ key = (String) s.readObject();
+ }
+ }
+
+ /**
+ * Serialize this Container:
+ * <ol>
+ * <li>Write to the stream the default serializable fields.</li>
+ * <li>Write the list of serializable ContainerListeners as optional
+ * data.</li>
+ * <li>Write this Container's FocusTraversalPolicy as optional data.</li>
+ * </ol>
+ *
+ * @param s the stream to write to
+ * @throws IOException if the stream fails
+ */
+ private void writeObject (ObjectOutputStream s) throws IOException
+ {
+ s.defaultWriteObject ();
+ AWTEventMulticaster.save (s, "containerL", containerListener);
+ if (focusTraversalPolicy instanceof Serializable)
+ s.writeObject (focusTraversalPolicy);
+ else
+ s.writeObject (null);
+ }
+
+ // Nested classes.
+
+ /* The following classes are used in concert with the
+ visitChildren() method to implement all the graphics operations
+ that requires traversal of the containment hierarchy. */
+
+ abstract static class GfxVisitor
+ {
+ public abstract void visit(Component c, Graphics gfx);
+ }
+
+ static class GfxPaintVisitor extends GfxVisitor
+ {
+ public static final GfxVisitor INSTANCE = new GfxPaintVisitor();
+
+ public void visit(Component c, Graphics gfx)
+ {
+ c.paint(gfx);
+ }
+ }
+
+ static class GfxPrintVisitor extends GfxVisitor
+ {
+ public static final GfxVisitor INSTANCE = new GfxPrintVisitor();
+
+ public void visit(Component c, Graphics gfx)
+ {
+ c.print(gfx);
+ }
+ }
+
+ static class GfxPaintAllVisitor extends GfxVisitor
+ {
+ public static final GfxVisitor INSTANCE = new GfxPaintAllVisitor();
+
+ public void visit(Component c, Graphics gfx)
+ {
+ c.paintAll(gfx);
+ }
+ }
+
+ static class GfxPrintAllVisitor extends GfxVisitor
+ {
+ public static final GfxVisitor INSTANCE = new GfxPrintAllVisitor();
+
+ public void visit(Component c, Graphics gfx)
+ {
+ c.printAll(gfx);
+ }
+ }
+
+ /**
+ * This class provides accessibility support for subclasses of container.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ *
+ * @since 1.3
+ */
+ protected class AccessibleAWTContainer extends AccessibleAWTComponent
+ {
+ /**
+ * Compatible with JDK 1.4+.
+ */
+ private static final long serialVersionUID = 5081320404842566097L;
+
+ /**
+ * The handler to fire PropertyChange when children are added or removed.
+ *
+ * @serial the handler for property changes
+ */
+ protected ContainerListener accessibleContainerHandler
+ = new AccessibleContainerHandler();
+
+ /**
+ * The default constructor.
+ */
+ protected AccessibleAWTContainer()
+ {
+ Container.this.addContainerListener(accessibleContainerHandler);
+ }
+
+ /**
+ * Return the number of accessible children of the containing accessible
+ * object (at most the total number of its children).
+ *
+ * @return the number of accessible children
+ */
+ public int getAccessibleChildrenCount()
+ {
+ synchronized (getTreeLock ())
+ {
+ int count = 0;
+ int i = component == null ? 0 : component.length;
+ while (--i >= 0)
+ if (component[i] instanceof Accessible)
+ count++;
+ return count;
+ }
+ }
+
+ /**
+ * Return the nth accessible child of the containing accessible object.
+ *
+ * @param i the child to grab, zero-based
+ * @return the accessible child, or null
+ */
+ public Accessible getAccessibleChild(int i)
+ {
+ synchronized (getTreeLock ())
+ {
+ if (component == null)
+ return null;
+ int index = -1;
+ while (i >= 0 && ++index < component.length)
+ if (component[index] instanceof Accessible)
+ i--;
+ if (i < 0)
+ return (Accessible) component[index];
+ return null;
+ }
+ }
+
+ /**
+ * Return the accessible child located at point (in the parent's
+ * coordinates), if one exists.
+ *
+ * @param p the point to look at
+ *
+ * @return an accessible object at that point, or null
+ *
+ * @throws NullPointerException if p is null
+ */
+ public Accessible getAccessibleAt(Point p)
+ {
+ Component c = getComponentAt(p.x, p.y);
+ return c != Container.this && c instanceof Accessible ? (Accessible) c
+ : null;
+ }
+
+ /**
+ * This class fires a <code>PropertyChange</code> listener, if registered,
+ * when children are added or removed from the enclosing accessible object.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ *
+ * @since 1.3
+ */
+ protected class AccessibleContainerHandler implements ContainerListener
+ {
+ /**
+ * Default constructor.
+ */
+ protected AccessibleContainerHandler()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Fired when a component is added; forwards to the PropertyChange
+ * listener.
+ *
+ * @param e the container event for adding
+ */
+ public void componentAdded(ContainerEvent e)
+ {
+ AccessibleAWTContainer.this.firePropertyChange
+ (ACCESSIBLE_CHILD_PROPERTY, null, e.getChild());
+ }
+
+ /**
+ * Fired when a component is removed; forwards to the PropertyChange
+ * listener.
+ *
+ * @param e the container event for removing
+ */
+ public void componentRemoved(ContainerEvent e)
+ {
+ AccessibleAWTContainer.this.firePropertyChange
+ (ACCESSIBLE_CHILD_PROPERTY, e.getChild(), null);
+ }
+ } // class AccessibleContainerHandler
+ } // class AccessibleAWTContainer
+} // class Container
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ContainerOrderFocusTraversalPolicy.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ContainerOrderFocusTraversalPolicy.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ContainerOrderFocusTraversalPolicy.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ContainerOrderFocusTraversalPolicy.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,482 @@
+/* ContainerOrderFocusTraversalPolicy.java --
+ Copyright (C) 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.io.Serializable;
+
+/**
+ * ContainerOrderFocusTraversalPolicy defines a focus traversal order
+ * based on the order in which Components were packed in a Container.
+ * This policy performs a pre-order traversal of the Component
+ * hierarchy starting from a given focus cycle root. Portions of the
+ * hierarchy that are not visible and displayable are skipped.
+ *
+ * By default, this policy transfers focus down-cycle implicitly.
+ * That is, if a forward traversal is requested on a focus cycle root
+ * and the focus cycle root has focusable children, the focus will
+ * automatically be transfered down to the lower focus cycle.
+ *
+ * The default implementation of accept accepts only Components that
+ * are visible, displayable, enabled and focusable. Derived classes
+ * can override these acceptance criteria by overriding accept.
+ *
+ * @author Michael Koch
+ * @author Thomas Fitzsimmons (fitzsim at redhat.com)
+ * @since 1.4
+ */
+public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
+ implements Serializable
+{
+ /**
+ * Compatible to JDK 1.4+
+ */
+ static final long serialVersionUID = 486933713763926351L;
+
+ /**
+ * True if implicit down cycling is enabled.
+ */
+ private boolean implicitDownCycleTraversal = true;
+
+ /**
+ * Creates the <code>ContainerOrderFocusTraversalPolicy</code> object.
+ */
+ public ContainerOrderFocusTraversalPolicy ()
+ {
+ // Nothing to do here
+ }
+
+ /**
+ * Returns the Component that should receive the focus after current.
+ * root must be a focus cycle root of current.
+ *
+ * @param root a focus cycle root of current
+ * @param current a (possibly indirect) child of root, or root itself
+ *
+ * @return the next Component in the focus traversal order for root,
+ * or null if no acceptable Component exists.
+ *
+ * @exception IllegalArgumentException If root is not a focus cycle
+ * root of current, or if either root or current is null.
+ */
+ public Component getComponentAfter (Container root, Component current)
+ {
+ if (root == null)
+ throw new IllegalArgumentException ("focus cycle root is null");
+ if (current == null)
+ throw new IllegalArgumentException ("current component is null");
+
+ if (!root.isFocusCycleRoot ())
+ throw new IllegalArgumentException ("root is not a focus cycle root");
+
+ Container ancestor = current.getFocusCycleRootAncestor ();
+ Container prevAncestor = ancestor;
+ while (ancestor != root)
+ {
+ ancestor = current.getFocusCycleRootAncestor ();
+ if (ancestor == prevAncestor)
+ {
+ // We've reached the top focus cycle root ancestor. Check
+ // if it is root.
+ if (ancestor == null)
+ ancestor = root;
+ else if (ancestor != root)
+ throw new IllegalArgumentException ("the given container is not"
+ + " a focus cycle root of the"
+ + " current component");
+ else
+ break;
+ }
+ prevAncestor = ancestor;
+ }
+
+ // FIXME: is this the right thing to do here? It moves the context
+ // for traversal up one focus traversal cycle. We'll need a test
+ // for this.
+ if ((Component) root == current)
+ root = current.getFocusCycleRootAncestor ();
+
+ // Check if we've reached the top of the component hierarchy. If
+ // so then we want to loop around to the first component in the
+ // focus traversal cycle.
+ if (current instanceof Window)
+ return getFirstComponent ((Container) current);
+
+ Container parent = current.getParent ();
+ synchronized (parent.getTreeLock ())
+ {
+ Component[] components = parent.getComponents ();
+ int componentIndex = 0;
+ int numComponents = parent.getComponentCount ();
+
+ // Find component's index.
+ for (int i = 0; i < numComponents; i++)
+ {
+ if (components[i].equals(current))
+ componentIndex = i;
+ }
+
+ // Search forward for the next acceptable component.
+ // Search through all components at least one time
+ // i.e. start at componentIndex + 1 --> nComponents -1 --> 0 ---> componentIndex
+ int i = componentIndex + 1;
+ int end = numComponents - 1;
+ Component next = getNextAvailableComponent(components, i, end);
+ if (next != null)
+ return next;
+
+ // Now check remainder of components from 0 to componentIndex
+ i = 0;
+ end = componentIndex;
+ next = getNextAvailableComponent(components, i, end);
+ if (next != null)
+ return next;
+
+ // No focusable components after current in its Container. So go
+ // to the next Component after current's Container (parent).
+ Component result = getComponentAfter (root, parent);
+ return result;
+ }
+ }
+
+ /**
+ * Gets the next available component in the array between the given range.
+ *
+ * @param components - the array of components.
+ * @param start - where to start
+ * @param end - where to end
+ * @return next component if found
+ */
+ private Component getNextAvailableComponent(Component[] components, int start, int end)
+ {
+ while (start <= end)
+ {
+ Component c = components[start];
+
+ if (c.visible && c.isDisplayable() && c.enabled && c.focusable)
+ return c;
+
+ if (c instanceof Container)
+ {
+ Component result = getFirstComponent((Container) c);
+
+ if (result != null && implicitDownCycleTraversal && result.visible
+ && result.isDisplayable() && result.enabled && result.focusable)
+ return result;
+ }
+ start++;
+ }
+
+ return null;
+ }
+
+ /**
+ * Gets the previous available component in the array between the given range.
+ *
+ * @param components - the array of components.
+ * @param start - where to start
+ * @param end - where to end
+ * @return previous component if found
+ */
+ Component getPrevAvailableComponent(Component[] components, int start, int end)
+ {
+ while (start >= end)
+ {
+ Component c = components[start];
+ if (c.visible && c.isDisplayable() && c.enabled && c.focusable)
+ return c;
+
+ if (c instanceof Container)
+ {
+ Component result = getLastComponent((Container) c);
+
+ if (result != null
+ && (result.visible && result.isDisplayable() && result.enabled && result.focusable))
+ return result;
+ }
+ start--;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the Component that should receive the focus before
+ * <code>current</code>. <code>root</code> must be a focus cycle root of
+ * current.
+ *
+ * @param root a focus cycle root of current
+ * @param current a (possibly indirect) child of root, or root itself
+ * @return the previous Component in the focus traversal order for root, or
+ * null if no acceptable Component exists.
+ * @exception IllegalArgumentException If root is not a focus cycle root of
+ * current, or if either root or current is null.
+ */
+ public Component getComponentBefore (Container root, Component current)
+ {
+ if (root == null)
+ throw new IllegalArgumentException ("focus cycle root is null");
+ if (current == null)
+ throw new IllegalArgumentException ("current component is null");
+
+ if (!root.isFocusCycleRoot ())
+ throw new IllegalArgumentException ("root is not a focus cycle root");
+
+ Container ancestor = current.getFocusCycleRootAncestor ();
+ Container prevAncestor = ancestor;
+ while (ancestor != root)
+ {
+ ancestor = current.getFocusCycleRootAncestor ();
+ if (ancestor == prevAncestor)
+ {
+ // We've reached the top focus cycle root ancestor. Check
+ // if it is root.
+ if (ancestor == null)
+ ancestor = root;
+ else if (ancestor != root)
+ throw new IllegalArgumentException ("the given container is not"
+ + " a focus cycle root of the"
+ + " current component");
+ else
+ break;
+ }
+ prevAncestor = ancestor;
+ }
+
+ // FIXME: is this the right thing to do here? It moves the context
+ // for traversal up one focus traversal cycle. We'll need a test
+ // for this.
+ if ((Component) root == current)
+ root = current.getFocusCycleRootAncestor ();
+
+ // Check if we've reached the top of the component hierarchy. If
+ // so then we want to loop around to the last component in the
+ // focus traversal cycle.
+ if (current instanceof Window)
+ return getLastComponent ((Container) current);
+
+ Container parent = current.getParent ();
+
+ synchronized (parent.getTreeLock ())
+ {
+ Component[] components = parent.getComponents ();
+ int componentIndex = 0;
+ int numComponents = parent.getComponentCount ();
+
+ // Find component's index.
+ for (int i = 0; i < numComponents; i++)
+ {
+ if (components[i] == current)
+ componentIndex = i;
+ }
+
+ // Search through all components at least one time
+ // i.e. start at componentIndex - 1 --> 0 --> numComponents -1 ---> componentIndex
+ int i = componentIndex - 1;
+ int end = 0;
+ Component prev = getPrevAvailableComponent(components, i, end);
+ if (prev != null)
+ return prev;
+
+ // Now check remainder of components
+ i = numComponents -1;
+ end = componentIndex;
+ prev = getPrevAvailableComponent(components, i, end);
+ if (prev != null)
+ return prev;
+
+ // No focusable components before current in its Container. So go
+ // to the previous Component before current's Container (parent).
+ Component result = getComponentBefore (root, parent);
+
+ return result;
+ }
+ }
+
+ /**
+ * Returns the first Component of root that should receive the focus.
+ *
+ * @param root a focus cycle root
+ *
+ * @return the first Component in the focus traversal order for
+ * root, or null if no acceptable Component exists.
+ *
+ * @exception IllegalArgumentException If root is null.
+ */
+ public Component getFirstComponent(Container root)
+ {
+ if (root == null)
+ throw new IllegalArgumentException ();
+
+ if (!root.isVisible ()
+ || !root.isDisplayable ())
+ return null;
+
+ if (accept(root))
+ return root;
+
+ int ncomponents = root.getComponentCount();
+ for (int i = 0; i < ncomponents; i++)
+ {
+ Component component = root.getComponent(i);
+ if (component instanceof Container
+ && !((Container) component).isFocusCycleRoot())
+ {
+ Component first = null;
+ Container cont = (Container) component;
+ if (cont.isFocusTraversalPolicyProvider())
+ {
+ FocusTraversalPolicy childPol = cont.getFocusTraversalPolicy();
+ first = childPol.getFirstComponent(cont);
+ }
+ else
+ first = getFirstComponent(cont);
+ if (first != null)
+ return first;
+ }
+ else if (accept(component))
+ return component;
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the last Component of root that should receive the focus.
+ *
+ * @param root a focus cycle root
+ *
+ * @return the last Component in the focus traversal order for
+ * root, or null if no acceptable Component exists.
+ *
+ * @exception IllegalArgumentException If root is null.
+ */
+ public Component getLastComponent (Container root)
+ {
+ if (root == null)
+ throw new IllegalArgumentException ();
+
+ if (!root.isVisible ()
+ || !root.isDisplayable ())
+ return null;
+
+ if (root.visible && root.isDisplayable() && root.enabled
+ && root.focusable)
+ return root;
+
+ Component[] componentArray = root.getComponents ();
+
+ for (int i = componentArray.length - 1; i >= 0; i--)
+ {
+ Component component = componentArray [i];
+
+ if (component.visible && component.isDisplayable() && component.enabled
+ && component.focusable)
+ return component;
+
+ if (component instanceof Container)
+ {
+ Component result = getLastComponent ((Container) component);
+
+ if (result != null &&
+ result.visible && result.isDisplayable() && result.enabled
+ && result.focusable)
+ return result;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the default Component of root that should receive the focus.
+ *
+ * @param root a focus cycle root
+ *
+ * @return the default Component in the focus traversal order for
+ * root, or null if no acceptable Component exists.
+ *
+ * @exception IllegalArgumentException If root is null.
+ */
+ public Component getDefaultComponent (Container root)
+ {
+ return getFirstComponent (root);
+ }
+
+ /**
+ * Set whether or not implicit down cycling is enabled. If it is,
+ * then initiating a forward focus traversal operation onto a focus
+ * cycle root, the focus will be implicitly transferred into the
+ * root container's focus cycle.
+ *
+ * @param value the setting for implicit down cycling
+ */
+ public void setImplicitDownCycleTraversal (boolean value)
+ {
+ implicitDownCycleTraversal = value;
+ }
+
+ /**
+ * Check whether or not implicit down cycling is enabled. If it is,
+ * then initiating a forward focus traversal operation onto a focus
+ * cycle root, the focus will be implicitly transferred into the
+ * root container's focus cycle.
+ *
+ * @return true if the focus will be transferred down-cycle
+ * implicitly
+ */
+ public boolean getImplicitDownCycleTraversal ()
+ {
+ return implicitDownCycleTraversal;
+ }
+
+ /**
+ * Check whether the given Component is an acceptable target for the
+ * keyboard input focus.
+ *
+ * @param current the Component to check
+ *
+ * @return true if current is acceptable, false otherwise
+ */
+ protected boolean accept (Component current)
+ {
+ return (current.visible
+ && current.isDisplayable ()
+ && current.enabled
+ && current.focusable);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Cursor.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Cursor.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Cursor.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Cursor.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,239 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * This class represents various predefined cursor types.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class Cursor implements java.io.Serializable
+{
+ static final long serialVersionUID = 8028237497568985504L;
+
+ /**
+ * Constant for the system default cursor type
+ */
+ public static final int DEFAULT_CURSOR = 0;
+
+ /**
+ * Constant for a cross-hair cursor.
+ */
+ public static final int CROSSHAIR_CURSOR = 1;
+
+ /**
+ * Constant for a cursor over a text field.
+ */
+ public static final int TEXT_CURSOR = 2;
+
+ /**
+ * Constant for a cursor to display while waiting for an action to complete.
+ */
+ public static final int WAIT_CURSOR = 3;
+
+ /**
+ * Cursor used over SW corner of window decorations.
+ */
+ public static final int SW_RESIZE_CURSOR = 4;
+
+ /**
+ * Cursor used over SE corner of window decorations.
+ */
+ public static final int SE_RESIZE_CURSOR = 5;
+
+ /**
+ * Cursor used over NW corner of window decorations.
+ */
+ public static final int NW_RESIZE_CURSOR = 6;
+
+ /**
+ * Cursor used over NE corner of window decorations.
+ */
+ public static final int NE_RESIZE_CURSOR = 7;
+
+ /**
+ * Cursor used over N edge of window decorations.
+ */
+ public static final int N_RESIZE_CURSOR = 8;
+
+ /**
+ * Cursor used over S edge of window decorations.
+ */
+ public static final int S_RESIZE_CURSOR = 9;
+
+ /**
+ * Cursor used over W edge of window decorations.
+ */
+ public static final int W_RESIZE_CURSOR = 10;
+
+ /**
+ * Cursor used over E edge of window decorations.
+ */
+ public static final int E_RESIZE_CURSOR = 11;
+
+ /**
+ * Constant for a hand cursor.
+ */
+ public static final int HAND_CURSOR = 12;
+
+ /**
+ * Constant for a cursor used during window move operations.
+ */
+ public static final int MOVE_CURSOR = 13;
+
+ private static String[] NAMES = { "Default Cursor", "Crosshair Cursor",
+ "Text Cursor", "Wait Cursor",
+ "Southwest Resize Cursor",
+ "Southeast Resize Cursor",
+ "Northwest Resize Cursor",
+ "Northeast Resize Cursor",
+ "North Resize Cursor", "South Resize Cursor",
+ "West Resize Cursor", "East Resize Cursor",
+ "Hand Cursor", "Move Cursor" };
+
+ public static final int CUSTOM_CURSOR = 0xFFFFFFFF;
+
+ private static final int PREDEFINED_COUNT = 14;
+
+ protected static Cursor[] predefined = new Cursor[PREDEFINED_COUNT];
+ protected String name;
+
+ /**
+ * @serial The numeric id of this cursor.
+ */
+ int type;
+
+ /**
+ * Initializes a new instance of <code>Cursor</code> with the specified
+ * type.
+ *
+ * @param type The cursor type.
+ *
+ * @exception IllegalArgumentException If the specified cursor type is invalid
+ */
+ public Cursor(int type)
+ {
+ if (type < 0 || type >= PREDEFINED_COUNT)
+ throw new IllegalArgumentException ("invalid cursor " + type);
+
+ this.type = type;
+
+ name = NAMES[type];
+
+ // FIXME: lookup?
+ }
+
+ /** This constructor is used internally only.
+ * Application code should call Toolkit.createCustomCursor().
+ */
+ protected Cursor(String name)
+ {
+ this.name = name;
+ this.type = CUSTOM_CURSOR;
+ }
+
+ /**
+ * Returns an instance of <code>Cursor</code> for one of the specified
+ * predetermined types.
+ *
+ * @param type The type contant from this class.
+ *
+ * @return The requested predefined cursor.
+ *
+ * @exception IllegalArgumentException If the constant is not one of the
+ * predefined cursor type constants from this class.
+ */
+ public static Cursor getPredefinedCursor(int type)
+ {
+ if (type < 0 || type >= PREDEFINED_COUNT)
+ throw new IllegalArgumentException ("invalid cursor " + type);
+ if (predefined[type] == null)
+ predefined[type] = new Cursor(type);
+ return predefined[type];
+ }
+
+ /**
+ * Retrieves the system specific custom Cursor named Cursor names are,
+ * for example: "Invalid.16x16".
+ *
+ * @exception AWTException
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true.
+ */
+ public static Cursor getSystemCustomCursor(String name)
+ throws AWTException
+ {
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException ();
+
+ // FIXME
+ return null;
+ }
+
+ /**
+ * Returns an instance of the system default cursor type.
+ *
+ * @return The system default cursor.
+ */
+ public static Cursor getDefaultCursor()
+ {
+ return getPredefinedCursor(DEFAULT_CURSOR);
+ }
+
+ /**
+ * Returns the numeric type identifier for this cursor.
+ *
+ * @return The cursor id.
+ */
+ public int getType()
+ {
+ return type;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String toString()
+ {
+ return (this.getClass()
+ + "[type=" + getType()
+ + ",name=" + getName() + "]");
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/DefaultFocusTraversalPolicy.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/DefaultFocusTraversalPolicy.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/DefaultFocusTraversalPolicy.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/DefaultFocusTraversalPolicy.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,111 @@
+/* DefaultFocusTraversalPolicy.java --
+ Copyright (C) 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * DefaultFocusTraversalPolicy is the default focus traversal policy
+ * used by Containers.
+ *
+ * This policy sharpens ContainerOrderFocusTraversalPolicy's
+ * acceptance criteria, to reject those Components that have
+ * unfocusable peers. Despite this extra strictness, this policy will
+ * always accept a Component that has explicitly been set focusable by
+ * any means.
+ *
+ * This AWT implementation assumes that the peers of the following
+ * Components are not focusable: Canvas, Panel, Label, ScrollPane,
+ * Scrollbar, Window, and any lightweight Component.
+ *
+ * A Component's focusability is independent of the focusability of
+ * its peer.
+ *
+ * @author Thomas Fitzsimmons (fitzsim at redhat.com)
+ * @since 1.4
+ */
+public class DefaultFocusTraversalPolicy
+ extends ContainerOrderFocusTraversalPolicy
+{
+ private static final long serialVersionUID = 8876966522510157497L;
+
+ /**
+ * Construct a default focus traversal policy.
+ */
+ public DefaultFocusTraversalPolicy ()
+ {
+ }
+
+ /**
+ * Check whether a given Component would be acceptable as a focus
+ * owner. The Component must be displayable, visible and enabled to
+ * be acceptable. If the Component's focus traversability has been
+ * overridden, by overriding Component.isFocusTraversable or
+ * Component.isFocusable, or by calling Component.setFocusable, then
+ * the Component will be accepted if it is focusable. If the
+ * Component uses the default focus traversable behaviour, then
+ * <code>comp</code> will always be rejected if it is a Canvas,
+ * Panel, Label, ScrollPane, Scrollbar, Window or lightweight
+ * Component.
+ *
+ * @param comp the Component to check
+ *
+ * @return true if the Component is an acceptable target for
+ * keyboard input focus, false otherwise
+ */
+ protected boolean accept (Component comp)
+ {
+ if (comp.visible
+ && comp.isDisplayable ()
+ && comp.enabled)
+ {
+ if (comp.isFocusTraversableOverridden != 0
+ && (comp.isFocusTraversable () || comp.isFocusable()))
+ return true;
+
+ if (!(comp instanceof Canvas
+ || comp instanceof Panel
+ || comp instanceof Label
+ || comp instanceof ScrollPane
+ || comp instanceof Scrollbar
+ || comp instanceof Window
+ || comp.isLightweight ()))
+ return true;
+ }
+ return false;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,566 @@
+/* DefaultKeyboardFocusManager.java --
+ Copyright (C) 2002, 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.FocusEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.WindowEvent;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+// FIXME: finish documentation
+public class DefaultKeyboardFocusManager extends KeyboardFocusManager
+{
+ /**
+ * This class models a request to delay the dispatch of events that
+ * arrive after a certain time, until a certain component becomes
+ * the focus owner.
+ */
+ private class EventDelayRequest implements Comparable
+ {
+ /** A {@link java.util.List} of {@link java.awt.event.KeyEvent}s
+ that are being delayed, pending this request's {@link
+ Component} receiving the keyboard focus. */
+ private LinkedList enqueuedKeyEvents = new LinkedList ();
+
+ /** An event timestamp. All events that arrive after this time
+ should be queued in the {@link #enqueuedKeyEvents} {@link
+ java.util.List}. */
+ public long timestamp;
+ /** When this {@link Component} becomes focused, all events
+ between this EventDelayRequest and the next one in will be
+ dispatched from {@link #enqueuedKeyEvents}. */
+ public Component focusedComp;
+
+ /**
+ * Construct a new EventDelayRequest.
+ *
+ * @param timestamp events that arrive after this time will be
+ * delayed
+ * @param focusedComp the Component that needs to receive focus
+ * before events are dispatched
+ */
+ public EventDelayRequest (long timestamp, Component focusedComp)
+ {
+ this.timestamp = timestamp;
+ this.focusedComp = focusedComp;
+ }
+
+ public int compareTo (Object o)
+ {
+ if (!(o instanceof EventDelayRequest))
+ throw new ClassCastException ();
+
+ EventDelayRequest request = (EventDelayRequest) o;
+
+ if (request.timestamp < timestamp)
+ return -1;
+ else if (request.timestamp == timestamp)
+ return 0;
+ else
+ return 1;
+ }
+
+ public boolean equals (Object o)
+ {
+ if (!(o instanceof EventDelayRequest) || o == null)
+ return false;
+
+ EventDelayRequest request = (EventDelayRequest) o;
+
+ return (request.timestamp == timestamp
+ && request.focusedComp == focusedComp);
+ }
+
+ public void enqueueEvent (KeyEvent e)
+ {
+ KeyEvent last = (KeyEvent) enqueuedKeyEvents.getLast ();
+ if (last != null && e.getWhen () < last.getWhen ())
+ throw new RuntimeException ("KeyEvents enqueued out-of-order");
+
+ if (e.getWhen () <= timestamp)
+ throw new RuntimeException ("KeyEvents enqueued before starting timestamp");
+
+ enqueuedKeyEvents.add (e);
+ }
+
+ public void dispatchEvents ()
+ {
+ int size = enqueuedKeyEvents.size ();
+ for (int i = 0; i < size; i++)
+ {
+ KeyEvent e = (KeyEvent) enqueuedKeyEvents.remove (0);
+ dispatchKeyEvent (e);
+ }
+ }
+
+ public void discardEvents ()
+ {
+ enqueuedKeyEvents.clear ();
+ }
+ }
+
+ /**
+ * This flag indicates for which focus traversal key release event we
+ * possibly wait, before letting any more KEY_TYPED events through.
+ */
+ private AWTKeyStroke waitForKeyStroke = null;
+
+ /** The {@link java.util.SortedSet} of current
+ * {@link EventDelayRequest}s. */
+ private SortedSet delayRequests = new TreeSet ();
+
+ public DefaultKeyboardFocusManager ()
+ {
+ }
+
+ public boolean dispatchEvent (AWTEvent e)
+ {
+ if (e instanceof WindowEvent)
+ {
+ Window target = (Window) e.getSource ();
+
+ if (e.id == WindowEvent.WINDOW_ACTIVATED)
+ setGlobalActiveWindow (target);
+ else if (e.id == WindowEvent.WINDOW_GAINED_FOCUS)
+ {
+ setGlobalFocusedWindow (target);
+ FocusTraversalPolicy p = target.getFocusTraversalPolicy();
+ Component toFocus = p.getInitialComponent(target);
+ if (toFocus != null)
+ toFocus.requestFocusInWindow();
+ }
+ else if (e.id != WindowEvent.WINDOW_LOST_FOCUS
+ && e.id != WindowEvent.WINDOW_DEACTIVATED)
+ return false;
+
+ redispatchEvent(target, e);
+ return true;
+ }
+ else if (e instanceof FocusEvent)
+ {
+ FocusEvent fe = (FocusEvent) e;
+ Component target = fe.getComponent ();
+
+ boolean retval = false;
+ if (e.id == FocusEvent.FOCUS_GAINED)
+ {
+ retval = handleFocusGained(fe);
+ }
+ else if (e.id == FocusEvent.FOCUS_LOST)
+ {
+ retval = handleFocusLost(fe);
+ }
+ return true;
+ }
+ else if (e instanceof KeyEvent)
+ {
+ // Loop through all registered KeyEventDispatchers, giving
+ // each a chance to handle this event.
+ Iterator i = getKeyEventDispatchers().iterator();
+
+ while (i.hasNext ())
+ {
+ KeyEventDispatcher dispatcher = (KeyEventDispatcher) i.next ();
+ if (dispatcher.dispatchKeyEvent ((KeyEvent) e))
+ return true;
+ }
+
+ // processKeyEvent checks if this event represents a focus
+ // traversal key stroke.
+ Component focusOwner = getGlobalPermanentFocusOwner ();
+
+ if (focusOwner != null)
+ processKeyEvent (focusOwner, (KeyEvent) e);
+
+ if (e.isConsumed ())
+ return true;
+
+ if (enqueueKeyEvent ((KeyEvent) e))
+ // This event was enqueued for dispatch at a later time.
+ return true;
+ else
+ // This event wasn't handled by any of the registered
+ // KeyEventDispatchers, and wasn't enqueued for dispatch
+ // later, so send it to the default dispatcher.
+ return dispatchKeyEvent ((KeyEvent) e);
+ }
+
+ return false;
+ }
+
+ /**
+ * Handles FOCUS_GAINED events in {@link #dispatchEvent(AWTEvent)}.
+ *
+ * @param fe the focus event
+ */
+ private boolean handleFocusGained(FocusEvent fe)
+ {
+ Component target = fe.getComponent ();
+
+ // If old focus owner != new focus owner, notify old focus
+ // owner that it has lost focus.
+ Component oldFocusOwner = getGlobalFocusOwner();
+ if (oldFocusOwner != null && oldFocusOwner != target)
+ {
+ FocusEvent lost = new FocusEvent(oldFocusOwner,
+ FocusEvent.FOCUS_LOST,
+ fe.isTemporary(), target);
+ oldFocusOwner.dispatchEvent(lost);
+ }
+
+ setGlobalFocusOwner (target);
+ if (target != getGlobalFocusOwner())
+ {
+ // Focus transfer was rejected, like when the target is not
+ // focusable.
+ dequeueKeyEvents(-1, target);
+ // FIXME: Restore focus somehow.
+ }
+ else
+ {
+ if (! fe.isTemporary())
+ {
+ setGlobalPermanentFocusOwner (target);
+ if (target != getGlobalPermanentFocusOwner())
+ {
+ // Focus transfer was rejected, like when the target is not
+ // focusable.
+ dequeueKeyEvents(-1, target);
+ // FIXME: Restore focus somehow.
+ }
+ else
+ {
+ redispatchEvent(target, fe);
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Handles FOCUS_LOST events for {@link #dispatchEvent(AWTEvent)}.
+ *
+ * @param fe the focus event
+ *
+ * @return if the event has been handled
+ */
+ private boolean handleFocusLost(FocusEvent fe)
+ {
+ Component currentFocus = getGlobalFocusOwner();
+ if (currentFocus != fe.getOppositeComponent())
+ {
+ setGlobalFocusOwner(null);
+ if (getGlobalFocusOwner() != null)
+ {
+ // TODO: Is this possible? If so, then we should try to restore
+ // the focus.
+ }
+ else
+ {
+ if (! fe.isTemporary())
+ {
+ setGlobalPermanentFocusOwner(null);
+ if (getGlobalPermanentFocusOwner() != null)
+ {
+ // TODO: Is this possible? If so, then we should try to
+ // restore the focus.
+ }
+ else
+ {
+ fe.setSource(currentFocus);
+ redispatchEvent(currentFocus, fe);
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ private boolean enqueueKeyEvent (KeyEvent e)
+ {
+ Iterator i = delayRequests.iterator ();
+ boolean oneEnqueued = false;
+ while (i.hasNext ())
+ {
+ EventDelayRequest request = (EventDelayRequest) i.next ();
+ if (e.getWhen () > request.timestamp)
+ {
+ request.enqueueEvent (e);
+ oneEnqueued = true;
+ }
+ }
+ return oneEnqueued;
+ }
+
+ public boolean dispatchKeyEvent (KeyEvent e)
+ {
+ Component focusOwner = getFocusOwner();
+ if (focusOwner == null)
+ focusOwner = getFocusedWindow();
+
+ if (focusOwner != null)
+ redispatchEvent(focusOwner, e);
+
+ // Loop through all registered KeyEventPostProcessors, giving
+ // each a chance to process this event.
+ Iterator i = getKeyEventPostProcessors().iterator();
+
+ while (i.hasNext ())
+ {
+ KeyEventPostProcessor processor = (KeyEventPostProcessor) i.next ();
+ if (processor.postProcessKeyEvent ((KeyEvent) e))
+ return true;
+ }
+
+ // The event hasn't been consumed yet. Check if it is an
+ // MenuShortcut.
+ if (postProcessKeyEvent (e))
+ return true;
+
+ // Always return true.
+ return true;
+ }
+
+ public boolean postProcessKeyEvent (KeyEvent e)
+ {
+ // Check if this event represents a menu shortcut.
+
+ // MenuShortcuts are activated by Ctrl- KeyEvents, only on KEY_PRESSED.
+ int modifiers = e.getModifiersEx ();
+ if (e.getID() == KeyEvent.KEY_PRESSED
+ && (modifiers & KeyEvent.CTRL_DOWN_MASK) != 0)
+ {
+ Window focusedWindow = getGlobalFocusedWindow ();
+ if (focusedWindow instanceof Frame)
+ {
+ MenuBar menubar = ((Frame) focusedWindow).getMenuBar ();
+
+ if (menubar != null)
+ {
+ // If there's a menubar, loop through all menu items,
+ // checking whether each one has a shortcut, and if
+ // so, whether this key event should activate it.
+ int numMenus = menubar.getMenuCount ();
+
+ for (int i = 0; i < numMenus; i++)
+ {
+ Menu menu = menubar.getMenu (i);
+ int numItems = menu.getItemCount ();
+
+ for (int j = 0; j < numItems; j++)
+ {
+ MenuItem item = menu.getItem (j);
+ MenuShortcut shortcut = item.getShortcut ();
+
+ if (item.isEnabled() && shortcut != null)
+ {
+ // Dispatch a new ActionEvent if:
+ //
+ // a) this is a Shift- KeyEvent, and the
+ // shortcut requires the Shift modifier
+ //
+ // or, b) this is not a Shift- KeyEvent, and the
+ // shortcut does not require the Shift
+ // modifier.
+ if (shortcut.getKey () == e.getKeyCode ()
+ && ((shortcut.usesShiftModifier ()
+ && (modifiers & KeyEvent.SHIFT_DOWN_MASK) != 0)
+ || (! shortcut.usesShiftModifier ()
+ && (modifiers & KeyEvent.SHIFT_DOWN_MASK) == 0)))
+ {
+ item.dispatchEvent (new ActionEvent (item,
+ ActionEvent.ACTION_PERFORMED,
+ item.getActionCommand (),
+ modifiers));
+ // The event was dispatched.
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public void processKeyEvent (Component comp, KeyEvent e)
+ {
+ AWTKeyStroke eventKeystroke = AWTKeyStroke.getAWTKeyStrokeForEvent (e);
+ // For every focus traversal keystroke, we need to also consume
+ // the other two key event types for the same key (e.g. if
+ // KEY_PRESSED TAB is a focus traversal keystroke, we also need to
+ // consume KEY_RELEASED and KEY_TYPED TAB key events).
+ // consuming KEY_RELEASED is easy, because their keyCodes matches
+ // the KEY_PRESSED event. Consuming the intermediate KEY_TYPED is
+ // very difficult because their is no clean way that we can know
+ // which KEY_TYPED belongs to a focusTraversalKey and which not.
+ // To address this problem we swallow every KEY_TYPE between the
+ // KEY_PRESSED event that matches a focusTraversalKey and the
+ // corresponding KEY_RELEASED.
+ AWTKeyStroke oppositeKeystroke = AWTKeyStroke.getAWTKeyStroke (e.getKeyCode (),
+ e.getModifiersEx (),
+ !(e.id == KeyEvent.KEY_RELEASED));
+
+ // Here we check if we are currently waiting for a KEY_RELEASED and
+ // swallow all KeyEvents that are to be delivered in between. This
+ // should only be the KEY_TYPED events that correspond to the
+ // focusTraversalKey's KEY_PRESSED event
+ if (waitForKeyStroke != null)
+ {
+ if (eventKeystroke.equals(waitForKeyStroke))
+ // release this lock
+ waitForKeyStroke = null;
+
+ // as long as we are waiting for the KEY_RELEASED, we swallow every
+ // KeyEvent, including the KEY_RELEASED
+ e.consume();
+ return;
+ }
+
+ Set forwardKeystrokes = comp.getFocusTraversalKeys (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
+ Set backwardKeystrokes = comp.getFocusTraversalKeys (KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
+ Set upKeystrokes = comp.getFocusTraversalKeys (KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS);
+ Set downKeystrokes = null;
+ if (comp instanceof Container)
+ downKeystrokes = comp.getFocusTraversalKeys (KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS);
+
+ if (forwardKeystrokes.contains (eventKeystroke))
+ {
+ waitForKeyStroke = oppositeKeystroke;
+ focusNextComponent (comp);
+ e.consume ();
+ }
+ else if (backwardKeystrokes.contains (eventKeystroke))
+ {
+ waitForKeyStroke = oppositeKeystroke;
+ focusPreviousComponent (comp);
+ e.consume ();
+ }
+ else if (upKeystrokes.contains (eventKeystroke))
+ {
+ waitForKeyStroke = oppositeKeystroke;
+ upFocusCycle (comp);
+ e.consume ();
+ }
+ else if (comp instanceof Container
+ && downKeystrokes.contains (eventKeystroke))
+ {
+ waitForKeyStroke = oppositeKeystroke;
+ downFocusCycle ((Container) comp);
+ e.consume ();
+ }
+ }
+
+ protected void enqueueKeyEvents (long after, Component untilFocused)
+ {
+ delayRequests.add (new EventDelayRequest (after, untilFocused));
+ }
+
+ protected void dequeueKeyEvents (long after, Component untilFocused)
+ {
+ // FIXME: need synchronization on delayRequests and enqueuedKeyEvents.
+
+ // Remove the KeyEvent with the oldest timestamp, which should be
+ // the first element in the SortedSet.
+ if (after < 0)
+ {
+ int size = delayRequests.size ();
+ if (size > 0)
+ delayRequests.remove (delayRequests.first ());
+ }
+ else
+ {
+ EventDelayRequest template = new EventDelayRequest (after, untilFocused);
+ if (delayRequests.contains (template))
+ {
+ EventDelayRequest actual = (EventDelayRequest) delayRequests.tailSet (template).first ();
+ delayRequests.remove (actual);
+ actual.dispatchEvents ();
+ }
+ }
+ }
+
+ protected void discardKeyEvents (Component comp)
+ {
+ // FIXME: need synchronization on delayRequests and enqueuedKeyEvents.
+
+ Iterator i = delayRequests.iterator ();
+
+ while (i.hasNext ())
+ {
+ EventDelayRequest request = (EventDelayRequest) i.next ();
+
+ if (request.focusedComp == comp
+ || (comp instanceof Container
+ && ((Container) comp).isAncestorOf (request.focusedComp)))
+ request.discardEvents ();
+ }
+ }
+
+ public void focusPreviousComponent (Component comp)
+ {
+ if (comp != null)
+ comp.transferFocusBackward();
+ }
+
+ public void focusNextComponent (Component comp)
+ {
+ if (comp != null)
+ comp.transferFocus();
+ }
+
+ public void upFocusCycle (Component comp)
+ {
+ if (comp != null)
+ comp.transferFocusUpCycle();
+ }
+
+ public void downFocusCycle (Container cont)
+ {
+ if (cont != null)
+ cont.transferFocusDownCycle();
+ }
+} // class DefaultKeyboardFocusManager
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Dialog.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Dialog.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Dialog.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Dialog.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,534 @@
+/* Dialog.java -- An AWT dialog box
+ Copyright (C) 1999, 2000, 2001, 2002, 2005, 2006
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 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;
+
+import java.awt.peer.DialogPeer;
+
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
+
+/**
+ * <code>Dialog</code> provides a top-level window normally used to receive
+ * user input in applications.
+ * <p>
+ * A dialog always has another top-level window as owner and is only visible
+ * if this owner is visible to the user. The default layout of dialogs is the
+ * <code>BorderLayout</code>. Dialogs can be modal (blocks user input to other
+ * components) or non-modal (user input in other components are allowed).
+ * </p>
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Tom Tromey (tromey at redhat.com)
+ */
+public class Dialog extends Window
+{
+ // Serialization constant
+ private static final long serialVersionUID = 5920926903803293709L;
+
+ /**
+ * @serial Indicates whether or not this dialog box is modal.
+ */
+ private boolean modal;
+
+ /**
+ * @serial Indicates whether or not this dialog box is resizable.
+ */
+ private boolean resizable = true;
+
+ /**
+ * @serial The title string for this dialog box, which can be
+ * <code>null</code>.
+ */
+ private String title;
+
+ /**
+ * This field indicates whether the dialog is undecorated or not.
+ */
+ private boolean undecorated = false;
+
+ /**
+ * Indicates that we are blocked for modality in show
+ */
+ private boolean blocked = false;
+
+ /**
+ * Secondary EventQueue to handle AWT events while we are blocked for
+ * modality in show.
+ */
+ private EventQueue eq2 = null;
+
+ /**
+ * Initializes a new instance of <code>Dialog</code> with the specified
+ * parent, that is resizable and not modal, and which has no title.
+ *
+ * @param parent The parent frame of this dialog box.
+ * @exception IllegalArgumentException If the owner's GraphicsConfiguration
+ * is not from a screen device, or if owner is null. This exception is
+ * always thrown when GraphicsEnvironment.isHeadless() returns true.
+ */
+ public Dialog(Frame parent)
+ {
+ this(parent, "", false);
+ }
+
+ /**
+ * Initializes a new instance of <code>Dialog</code> with the specified
+ * parent and modality, that is resizable and which has no title.
+ *
+ * @param parent The parent frame of this dialog box.
+ * @param modal <code>true</code> if this dialog box is modal,
+ * <code>false</code> otherwise.
+ *
+ * @exception IllegalArgumentException If the owner's GraphicsConfiguration
+ * is not from a screen device, or if owner is null. This exception is
+ * always thrown when GraphicsEnvironment.isHeadless() returns true.
+ */
+ public Dialog(Frame parent, boolean modal)
+ {
+ this(parent, "", modal);
+ }
+
+ /**
+ * Initializes a new instance of <code>Dialog</code> with the specified
+ * parent, that is resizable and not modal, and which has the specified
+ * title.
+ *
+ * @param parent The parent frame of this dialog box.
+ * @param title The title string for this dialog box.
+ *
+ * @exception IllegalArgumentException If the owner's GraphicsConfiguration
+ * is not from a screen device, or if owner is null. This exceptionnis
+ * always thrown when GraphicsEnvironment.isHeadless() returns true.
+ */
+ public Dialog(Frame parent, String title)
+ {
+ this(parent, title, false);
+ }
+
+ /**
+ * Initializes a new instance of <code>Dialog</code> with the specified,
+ * parent, title, and modality, that is resizable.
+ *
+ * @param parent The parent frame of this dialog box.
+ * @param title The title string for this dialog box.
+ * @param modal <code>true</code> if this dialog box is modal,
+ * <code>false</code> otherwise.
+ *
+ * @exception IllegalArgumentException If owner is null or
+ * GraphicsEnvironment.isHeadless() returns true.
+ */
+ public Dialog(Frame parent, String title, boolean modal)
+ {
+ this(parent, title, modal, parent.getGraphicsConfiguration());
+ }
+
+ /**
+ * Initializes a new instance of <code>Dialog</code> with the specified,
+ * parent, title, modality and <code>GraphicsConfiguration</code>, that is
+ * resizable.
+ *
+ * @param parent The parent frame of this dialog box.
+ * @param title The title string for this dialog box.
+ * @param modal <code>true</code> if this dialog box is modal,
+ * <code>false</code> otherwise.
+ * @param gc The <code>GraphicsConfiguration</code> object to use. If
+ * <code>null</code> the <code>GraphicsConfiguration</code> of the target
+ * frame is used.
+ *
+ * @exception IllegalArgumentException If owner is null, the
+ * GraphicsConfiguration is not a screen device or
+ * GraphicsEnvironment.isHeadless() returns true.
+ * @since 1.4
+ */
+ public Dialog(Frame parent, String title, boolean modal,
+ GraphicsConfiguration gc)
+ {
+ super(parent, (gc == null) ? parent.getGraphicsConfiguration() : gc);
+
+ // A null title is equivalent to an empty title
+ this.title = (title != null) ? title : "";
+ this.modal = modal;
+ visible = false;
+
+ setLayout(new BorderLayout());
+ }
+
+ /**
+ * Initializes a new instance of <code>Dialog</code> with the specified,
+ * parent, that is resizable.
+ *
+ * @param owner The parent frame of this dialog box.
+ *
+ * @exception IllegalArgumentException If parent is null. This exception is
+ * always thrown when GraphicsEnvironment.isHeadless() returns true.
+ *
+ * @since 1.2
+ */
+ public Dialog(Dialog owner)
+ {
+ this(owner, "", false, owner.getGraphicsConfiguration());
+ }
+
+ /**
+ * Initializes a new instance of <code>Dialog</code> with the specified,
+ * parent and title, that is resizable.
+ *
+ * @param owner The parent frame of this dialog box.
+ * @param title The title string for this dialog box.
+ *
+ * @exception IllegalArgumentException If parent is null. This exception is
+ * always thrown when GraphicsEnvironment.isHeadless() returns
+ * true.
+ * @since 1.2
+ */
+ public Dialog(Dialog owner, String title)
+ {
+ this(owner, title, false, owner.getGraphicsConfiguration());
+ }
+
+ /**
+ * Initializes a new instance of <code>Dialog</code> with the specified,
+ * parent, title and modality, that is resizable.
+ *
+ * @param owner The parent frame of this dialog box.
+ * @param title The title string for this dialog box.
+ * @param modal <code>true</code> if this dialog box is modal,
+ * <code>false</code> otherwise.
+ *
+ * @exception IllegalArgumentException If parent is null. This exception is
+ * always thrown when GraphicsEnvironment.isHeadless() returns true.
+ * @since 1.2
+ */
+ public Dialog(Dialog owner, String title, boolean modal)
+ {
+ this(owner, title, modal, owner.getGraphicsConfiguration());
+ }
+
+ /**
+ * Initializes a new instance of <code>Dialog</code> with the specified,
+ * parent, title, modality and <code>GraphicsConfiguration</code>, that is
+ * resizable.
+ *
+ * @param parent The parent frame of this dialog box.
+ * @param title The title string for this dialog box.
+ * @param modal <code>true</code> if this dialog box is modal,
+ * <code>false</code> otherwise.
+ * @param gc The <code>GraphicsConfiguration</code> object to use. If
+ * <code>null</code> the <code>GraphicsConfiguration</code> of the target
+ * frame is used.
+ *
+ * @exception IllegalArgumentException If parent is null, the
+ * GraphicsConfiguration is not a screen device or
+ * GraphicsEnvironment.isHeadless() returns true.
+ *
+ * @since 1.4
+ */
+ public Dialog(Dialog parent, String title, boolean modal,
+ GraphicsConfiguration gc)
+ {
+ super(parent, (gc == null) ? parent.getGraphicsConfiguration() : gc);
+
+ // A null title is equivalent to an empty title
+ this.title = (title != null) ? title : "";
+ this.modal = modal;
+ visible = false;
+
+ setLayout(new BorderLayout());
+ }
+
+ /**
+ * Returns the title of this dialog box.
+ *
+ * @return The title of this dialog box.
+ */
+ public String getTitle()
+ {
+ return title;
+ }
+
+ /**
+ * Sets the title of this dialog box to the specified string.
+ *
+ * @param title the new title. If <code>null</code> an empty
+ * title will be set.
+ */
+ public synchronized void setTitle(String title)
+ {
+ // A null title is equivalent to an empty title
+ this.title = (title != null) ? title : "";
+
+ if (peer != null)
+ {
+ DialogPeer d = (DialogPeer) peer;
+ d.setTitle(title);
+ }
+ }
+
+ /**
+ * Tests whether or not this dialog box is modal.
+ *
+ * @return <code>true</code> if this dialog box is modal, <code>false</code>
+ * otherwise.
+ */
+ public boolean isModal()
+ {
+ return modal;
+ }
+
+ /**
+ * Changes the modality of this dialog box. This can only be done before the
+ * peer is created.
+ *
+ * @param modal <code>true</code> to make this dialog box modal,
+ * <code>false</code> to make it non-modal.
+ */
+ public void setModal(boolean modal)
+ {
+ this.modal = modal;
+ }
+
+ /**
+ * Tests whether or not this dialog box is resizable.
+ *
+ * @return <code>true</code> if this dialog is resizable,
+ * <code>false</code> otherwise.
+ */
+ public boolean isResizable()
+ {
+ return resizable;
+ }
+
+ /**
+ * Changes the resizability of this dialog box.
+ *
+ * @param resizable <code>true</code> to make this dialog resizable,
+ * <code>false</code> to make it non-resizable.
+ */
+ public synchronized void setResizable(boolean resizable)
+ {
+ this.resizable = resizable;
+ if (peer != null)
+ {
+ DialogPeer d = (DialogPeer) peer;
+ d.setResizable(resizable);
+ }
+ }
+
+ /**
+ * Creates this object's native peer.
+ */
+ public synchronized void addNotify()
+ {
+ if (peer == null)
+ peer = getToolkit().createDialog(this);
+ super.addNotify();
+ }
+
+ /**
+ * Makes this dialog visible and brings it to the front. If the dialog is
+ * modal and is not already visible, this call will not return until the
+ * dialog is hidden by someone calling hide or dispose. If this is the event
+ * dispatching thread we must ensure that another event thread runs while the
+ * one which invoked this method is blocked.
+ *
+ * @deprecated Use {@link Component#setVisible(boolean)} instead.
+ */
+ public synchronized void show()
+ {
+ super.show();
+
+ if (isModal())
+ {
+ // If already shown (and blocked) just return
+ if (blocked)
+ return;
+
+ /*
+ * If show is called in the dispatch thread for a modal dialog it will
+ * block so we must run another thread so the events keep being
+ * dispatched.
+ */
+ if (EventQueue.isDispatchThread())
+ {
+ EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
+ eq2 = new EventQueue();
+ eq.push(eq2);
+ }
+
+ try
+ {
+ blocked = true;
+ wait();
+ blocked = false;
+ }
+ catch (InterruptedException e)
+ {
+ blocked = false;
+ }
+
+ if (eq2 != null)
+ {
+ eq2.pop();
+ eq2 = null;
+ }
+ }
+ }
+
+ /**
+ * Hides the Dialog and then causes show() to return if it is currently
+ * blocked.
+ *
+ * @deprecated Use {@link Component#setVisible(boolean)} instead.
+ */
+ public synchronized void hide()
+ {
+ if (blocked)
+ {
+ notifyAll();
+ }
+
+ super.hide();
+ }
+
+ /**
+ * Disposes the Dialog and then causes show() to return if it is currently
+ * blocked.
+ */
+ public synchronized void dispose()
+ {
+ if (blocked)
+ {
+ notifyAll();
+ }
+
+ super.dispose();
+ }
+
+ /**
+ * Returns a debugging string for this component.
+ *
+ * @return A debugging string for this component.
+ */
+ protected String paramString()
+ {
+ return "title+" + title + ",modal=" + modal + ",resizable=" + resizable
+ + "," + super.paramString();
+ }
+
+ /**
+ * Returns whether this frame is undecorated or not.
+ *
+ * @return <code>true</code> if this dialog is undecorated,
+ * <code>false</code> otherwise.
+ *
+ * @since 1.4
+ */
+ public boolean isUndecorated()
+ {
+ return undecorated;
+ }
+
+ /**
+ * Disables or enables decorations for this frame. This method can only be
+ * called while the frame is not displayable.
+ *
+ * @param undecorated <code>true</code> to disable dialog decorations,
+ * <code>false</code> otherwise.
+ *
+ * @exception IllegalComponentStateException If this frame is displayable.
+ * @since 1.4
+ */
+ public void setUndecorated(boolean undecorated)
+ {
+ if (isDisplayable())
+ throw new IllegalComponentStateException();
+
+ this.undecorated = undecorated;
+ }
+
+ /**
+ * Accessibility support for <code>Dialog</code>.
+ */
+ protected class AccessibleAWTDialog
+ extends AccessibleAWTWindow
+ {
+ private static final long serialVersionUID = 4837230331833941201L;
+
+ /**
+ * Gets the role of this object.
+ * @return AccessibleRole.DIALOG
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.DIALOG;
+ }
+
+ /**
+ * Gets the state set of this object.
+ * @return The current state of this dialog.
+ */
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ AccessibleStateSet states = super.getAccessibleStateSet();
+ if (isResizable())
+ states.add(AccessibleState.RESIZABLE);
+ if (isModal())
+ states.add(AccessibleState.MODAL);
+ return states;
+ }
+ }
+
+ /**
+ * Gets the AccessibleContext associated with this <code>Dialog</code>. The
+ * context is created, if necessary.
+ *
+ * @return the associated context
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ /* Create the context if this is the first request */
+ if (accessibleContext == null)
+ accessibleContext = new AccessibleAWTDialog();
+ return accessibleContext;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Dimension.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Dimension.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Dimension.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Dimension.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,234 @@
+/* Dimension.java -- represents a 2-dimensional span
+ Copyright (C) 1999, 2000, 2002 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.geom.Dimension2D;
+import java.io.Serializable;
+
+/**
+ * This class holds a width and height value pair. This is used in plenty
+ * of windowing classes, but also has geometric meaning.
+ *
+ * <p>It is valid for a dimension to have negative width or height; but it
+ * is considered to have no area. Therefore, the behavior in various methods
+ * is undefined in such a case.
+ *
+ * <p>There are some public fields; if you mess with them in an inconsistent
+ * manner, it is your own fault when you get invalid results. Also, this
+ * class is not threadsafe.
+ *
+ * @author Per Bothner (bothner at cygnus.com)
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Component
+ * @see LayoutManager
+ * @since 1.0
+ * @status updated to 1.14
+ */
+public class Dimension extends Dimension2D implements Serializable
+{
+ /**
+ * Compatible with JDK 1.0+.
+ */
+ private static final long serialVersionUID = 4723952579491349524L;
+
+ /**
+ * The width of this object.
+ *
+ * @see #getSize()
+ * @see #setSize(double, double)
+ * @serial the width
+ */
+ public int width;
+
+ /**
+ * The height of this object.
+ *
+ * @see #getSize()
+ * @see #setSize(double, double)
+ * @serial the height
+ */
+ public int height;
+
+ /**
+ * Create a new Dimension with a width and height of zero.
+ */
+ public Dimension()
+ {
+ }
+
+ /**
+ * Create a new Dimension with width and height identical to that of the
+ * specified dimension.
+ *
+ * @param d the Dimension to copy
+ * @throws NullPointerException if d is null
+ */
+ public Dimension(Dimension d)
+ {
+ width = d.width;
+ height = d.height;
+ }
+
+ /**
+ * Create a new Dimension with the specified width and height.
+ *
+ * @param w the width of this object
+ * @param h the height of this object
+ */
+ public Dimension(int w, int h)
+ {
+ width = w;
+ height = h;
+ }
+
+ /**
+ * Gets the width of this dimension.
+ *
+ * @return the width, as a double
+ */
+ public double getWidth()
+ {
+ return width;
+ }
+
+ /**
+ * Gets the height of this dimension.
+ *
+ * @return the height, as a double
+ */
+ public double getHeight()
+ {
+ return height;
+ }
+
+ /**
+ * Sets the size of this dimension. The values are rounded to int.
+ *
+ * @param w the new width
+ * @param h the new height
+ * @since 1.2
+ */
+ public void setSize(double w, double h)
+ {
+ width = (int) w;
+ height = (int) h;
+ }
+
+ /**
+ * Returns the size of this dimension. A pretty useless method, as this is
+ * already a dimension.
+ *
+ * @return a copy of this dimension
+ * @see #setSize(Dimension)
+ * @since 1.1
+ */
+ public Dimension getSize()
+ {
+ return new Dimension(width, height);
+ }
+
+ /**
+ * Sets the width and height of this object to match that of the
+ * specified object.
+ *
+ * @param d the Dimension to get the new width and height from
+ * @throws NullPointerException if d is null
+ * @see #getSize()
+ * @since 1.1
+ */
+ public void setSize(Dimension d)
+ {
+ width = d.width;
+ height = d.height;
+ }
+
+ /**
+ * Sets the width and height of this object to the specified values.
+ *
+ * @param w the new width value
+ * @param h the new height value
+ */
+ public void setSize(int w, int h)
+ {
+ width = w;
+ height = h;
+ }
+
+ /**
+ * Tests this object for equality against the specified object. This will
+ * be true if and only if the specified object is an instance of
+ * Dimension2D, and has the same width and height.
+ *
+ * @param obj the object to test against
+ * @return true if the object is equal to this
+ */
+ public boolean equals(Object obj)
+ {
+ if (! (obj instanceof Dimension))
+ return false;
+ Dimension dim = (Dimension) obj;
+ return height == dim.height && width == dim.width;
+ }
+
+ /**
+ * Return the hashcode for this object. It is not documented, but appears
+ * to be <code>((width + height) * (width + height + 1) / 2) + width</code>.
+ *
+ * @return the hashcode
+ */
+ public int hashCode()
+ {
+ // Reverse engineering this was fun!
+ return (width + height) * (width + height + 1) / 2 + width;
+ }
+
+ /**
+ * Returns a string representation of this object. The format is:
+ * <code>getClass().getName() + "[width=" + width + ",height=" + height
+ * + ']'</code>.
+ *
+ * @return a string representation of this object
+ */
+ public String toString()
+ {
+ return getClass().getName()
+ + "[width=" + width + ",height=" + height + ']';
+ }
+} // class Dimension
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/DisplayMode.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/DisplayMode.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/DisplayMode.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/DisplayMode.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,164 @@
+/* DisplayMode.java -- a description of display mode configurations
+ Copyright (C) 2002, 2003, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * This encapsulates information about the display mode for a graphics
+ * device configuration. They are device dependent, and may not always be
+ * available.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see GraphicsDevice
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public final class DisplayMode
+{
+ /**
+ * Value of the bit depth if multiple depths are supported.
+ *
+ * @see #getBitDepth()
+ */
+ public static final int BIT_DEPTH_MULTI = -1;
+
+ /**
+ * Value of an unknown refresh rate.
+ *
+ * @see #getRefreshRate()
+ */
+ public static final int REFRESH_RATE_UNKNOWN = 0;
+
+ /** The width. */
+ private final int width;
+
+ /** The height. */
+ private final int height;
+
+ /** The bit depth. */
+ private final int bitDepth;
+
+ /** The refresh rate. */
+ private final int refreshRate;
+
+ /**
+ * Create a mode with the given parameters.
+ *
+ * @param width the width
+ * @param height the height
+ * @param bitDepth the bitDepth
+ * @param refreshRate the refreshRate
+ * @see #BIT_DEPTH_MULTI
+ * @see #REFRESH_RATE_UNKNOWN
+ */
+ public DisplayMode(int width, int height, int bitDepth, int refreshRate)
+ {
+ this.width = width;
+ this.height = height;
+ this.bitDepth = bitDepth;
+ this.refreshRate = refreshRate;
+ }
+
+ /**
+ * Returns the height, in pixels.
+ *
+ * @return the height
+ */
+ public int getHeight()
+ {
+ return height;
+ }
+
+ /**
+ * Returns the width, in pixels.
+ *
+ * @return the width
+ */
+ public int getWidth()
+ {
+ return width;
+ }
+
+ /**
+ * Returns the bit depth, in bits per pixel. This may be BIT_DEPTH_MULTI.
+ *
+ * @return the bit depth
+ * @see #BIT_DEPTH_MULTI
+ */
+ public int getBitDepth()
+ {
+ return bitDepth;
+ }
+
+ /**
+ * Returns the refresh rate, in hertz. This may be REFRESH_RATE_UNKNOWN.
+ *
+ * @return the refresh rate
+ * @see #REFRESH_RATE_UNKNOWN
+ */
+ public int getRefreshRate()
+ {
+ return refreshRate;
+ }
+
+ /**
+ * Test for equality. This returns true for two modes with identical
+ * parameters.
+ *
+ * @param dm The display mode to compare to
+ *
+ * @return true if it is equal
+ */
+ public boolean equals (DisplayMode dm)
+ {
+ return (width == dm.width
+ && height == dm.height
+ && bitDepth == dm.bitDepth
+ && refreshRate == dm.refreshRate);
+ }
+
+ /**
+ * Returns a hash code for the display mode.
+ *
+ * @return the hash code
+ */
+ public int hashCode()
+ {
+ return width + height + bitDepth + refreshRate;
+ }
+} // class DisplayMode
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Event.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Event.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Event.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Event.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,185 @@
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification, as well
+ * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
+ * Status: Believed complete and correct.
+ */
+
+public class Event implements java.io.Serializable
+{
+ static final long serialVersionUID = 5488922509400504703L;
+
+ public static final int SHIFT_MASK = 1;
+ public static final int CTRL_MASK = 2;
+ public static final int META_MASK = 4;
+ public static final int ALT_MASK = 8;
+
+ public static final int ACTION_EVENT = 1001;
+ public static final int BACK_SPACE = 8;
+ public static final int CAPS_LOCK = 1022;
+ public static final int DELETE = 127;
+ public static final int DOWN = 1005;
+ public static final int END = 1001;
+ public static final int ENTER = 10;
+ public static final int ESCAPE = 27;
+ public static final int F1 = 1008;
+ public static final int F10 = 1017;
+ public static final int F11 = 1018;
+ public static final int F12 = 1019;
+ public static final int F2 = 1009;
+ public static final int F3 = 1010;
+ public static final int F4 = 1011;
+ public static final int F5 = 1012;
+ public static final int F6 = 1013;
+ public static final int F7 = 1014;
+ public static final int F8 = 1015;
+ public static final int F9 = 1016;
+ public static final int GOT_FOCUS = 1004;
+ public static final int HOME = 1000;
+ public static final int INSERT = 1025;
+ public static final int KEY_ACTION = 403;
+ public static final int KEY_ACTION_RELEASE = 404;
+ public static final int KEY_PRESS = 401;
+ public static final int KEY_RELEASE = 402;
+ public static final int LEFT = 1006;
+ public static final int LIST_DESELECT = 702;
+ public static final int LIST_SELECT = 701;
+ public static final int LOAD_FILE = 1002;
+ public static final int LOST_FOCUS = 1005;
+ public static final int MOUSE_DOWN = 501;
+ public static final int MOUSE_DRAG = 506;
+ public static final int MOUSE_ENTER = 504;
+ public static final int MOUSE_EXIT = 505;
+ public static final int MOUSE_MOVE = 503;
+ public static final int MOUSE_UP = 502;
+ public static final int NUM_LOCK = 1023;
+ public static final int PAUSE = 1024;
+ public static final int PGDN = 1003;
+ public static final int PGUP = 1002;
+ public static final int PRINT_SCREEN = 1020;
+ public static final int RIGHT = 1007;
+ public static final int SAVE_FILE = 1003;
+ public static final int SCROLL_ABSOLUTE = 605;
+ public static final int SCROLL_BEGIN = 606;
+ public static final int SCROLL_END = 607;
+ public static final int SCROLL_LINE_DOWN = 602;
+ public static final int SCROLL_LINE_UP = 601;
+ public static final int SCROLL_LOCK = 1021;
+ public static final int SCROLL_PAGE_DOWN = 604;
+ public static final int SCROLL_PAGE_UP = 603;
+ public static final int TAB = 9;
+ public static final int UP = 1004;
+ public static final int WINDOW_DEICONIFY = 204;
+ public static final int WINDOW_DESTROY = 201;
+ public static final int WINDOW_EXPOSE = 202;
+ public static final int WINDOW_ICONIFY = 203;
+ public static final int WINDOW_MOVED = 205;
+
+ public Object arg;
+ public int clickCount;
+ boolean consumed; // Required by serialization spec.
+ public Event evt;
+ public int id;
+ public int key;
+ public int modifiers;
+ public Object target;
+ public long when;
+ public int x;
+ public int y;
+
+ public Event (Object target, int id, Object arg)
+ {
+ this.id = id;
+ this.target = target;
+ this.arg = arg;
+ }
+
+ public Event (Object target, long when, int id, int x, int y, int key,
+ int modifiers)
+ {
+ this.target = target;
+ this.when = when;
+ this.id = id;
+ this.x = x;
+ this.y = y;
+ this.key = key;
+ this.modifiers = modifiers;
+ }
+
+ public Event (Object target, long when, int id, int x, int y, int key,
+ int modifiers, Object arg)
+ {
+ this (target, when, id, x, y, key, modifiers);
+ this.arg = arg;
+ }
+
+ public boolean controlDown ()
+ {
+ return ((modifiers & CTRL_MASK) == 0 ? false : true);
+ }
+
+ public boolean metaDown ()
+ {
+ return ((modifiers & META_MASK) == 0 ? false : true);
+ }
+
+ protected String paramString ()
+ {
+ return "id=" + id + ",x=" + x + ",y=" + y
+ + ",target=" + target + ",arg=" + arg;
+ }
+
+ public boolean shiftDown()
+ {
+ return ((modifiers & SHIFT_MASK) == 0 ? false : true);
+ }
+
+ public String toString()
+ {
+ return getClass().getName() + "[" + paramString() + "]";
+ }
+
+ public void translate (int x, int y)
+ {
+ this.x += x;
+ this.y += y;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/EventDispatchThread.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/EventDispatchThread.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/EventDispatchThread.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/EventDispatchThread.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,104 @@
+/* EventDispatchThread.java -
+ Copyright (C) 2000, 2002, 2004 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * @author Bryce McKinlay
+ * @status believed complete, but untested.
+ */
+class EventDispatchThread extends Thread
+{
+ /**
+ * The default priority when no property has been set.
+ */
+ private static final int DEFAULT_PRIORITY = NORM_PRIORITY + 1;
+
+ private static int dispatchThreadNum;
+
+ private EventQueue queue;
+
+ EventDispatchThread(EventQueue queue)
+ {
+ super();
+ setName("AWT-EventQueue-" + ++dispatchThreadNum);
+ this.queue = queue;
+
+ int priority = DEFAULT_PRIORITY;
+ try
+ {
+ String priorityString =
+ System.getProperty("gnu.awt.dispatchthread.priority");
+ if (priorityString != null)
+ {
+ priority = Integer.parseInt(priorityString);
+ }
+ }
+ catch (NumberFormatException ex)
+ {
+ // Ignore and use default.
+ }
+ setPriority(priority);
+ }
+
+ public void run()
+ {
+ while (true)
+ {
+ try
+ {
+ AWTEvent evt = queue.getNextEvent();
+ queue.dispatchEvent(evt);
+ }
+ catch (ThreadDeath death)
+ {
+ // If someone wants to kill us, let them.
+ return;
+ }
+ catch (InterruptedException ie)
+ {
+ // We are interrupted when we should finish executing
+ return;
+ }
+ catch (Throwable x)
+ {
+ System.err.println("Exception during event dispatch:");
+ x.printStackTrace(System.err);
+ }
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/EventQueue.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/EventQueue.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/EventQueue.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/EventQueue.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,508 @@
+/* EventQueue.java --
+ Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.InputEvent;
+import java.awt.event.InputMethodEvent;
+import java.awt.event.InvocationEvent;
+import java.lang.reflect.InvocationTargetException;
+import java.util.EmptyStackException;
+
+/* Written using on-line Java 2 Platform Standard Edition v1.3 API
+ * Specification, as well as "The Java Class Libraries", 2nd edition
+ * (Addison-Wesley, 1998).
+ * Status: Believed complete, but untested.
+ */
+
+/**
+ * This class manages a queue of <code>AWTEvent</code> objects that
+ * are posted to it. The AWT system uses only one event queue for all
+ * events.
+ *
+ * @author Bryce McKinlay
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class EventQueue
+{
+ private static final int INITIAL_QUEUE_DEPTH = 8;
+ private AWTEvent[] queue = new AWTEvent[INITIAL_QUEUE_DEPTH];
+
+ private int next_in = 0; // Index where next event will be added to queue
+ private int next_out = 0; // Index of next event to be removed from queue
+
+ private EventQueue next;
+ private EventQueue prev;
+ private AWTEvent currentEvent;
+ private long lastWhen = System.currentTimeMillis();
+
+ private EventDispatchThread dispatchThread = new EventDispatchThread(this);
+ private boolean shutdown = false;
+
+ synchronized private void setShutdown (boolean b)
+ {
+ shutdown = b;
+ }
+
+ synchronized boolean isShutdown ()
+ {
+ if (shutdown)
+ return true;
+
+ // This is the exact self-shutdown condition specified in J2SE:
+ // http://java.sun.com/j2se/1.4.2/docs/api/java/awt/doc-files/AWTThreadIssues.html
+
+ // FIXME: check somewhere that the native queue is empty
+ if (peekEvent() == null)
+ {
+ Frame[] frames = Frame.getFrames();
+ for (int i = 0; i < frames.length; ++i)
+ if (frames[i].isDisplayable())
+ return false;
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Initializes a new instance of <code>EventQueue</code>.
+ */
+ public EventQueue()
+ {
+ }
+
+ /**
+ * Returns the next event in the queue. This method will block until
+ * an event is available or until the thread is interrupted.
+ *
+ * @return The next event in the queue.
+ *
+ * @exception InterruptedException If this thread is interrupted while
+ * waiting for an event to be posted to the queue.
+ */
+ public synchronized AWTEvent getNextEvent()
+ throws InterruptedException
+ {
+ if (next != null)
+ return next.getNextEvent();
+
+ while (next_in == next_out)
+ {
+ // We are not allowed to return null from this method, yet it
+ // is possible that we actually have run out of native events
+ // in the enclosing while() loop, and none of the native events
+ // happened to cause AWT events. We therefore ought to check
+ // the isShutdown() condition here, before risking a "native
+ // wait". If we check it before entering this function we may
+ // wait forever for events after the shutdown condition has
+ // arisen.
+
+ if (isShutdown())
+ throw new InterruptedException();
+
+ wait();
+ }
+
+ AWTEvent res = queue[next_out];
+
+ if (++next_out == queue.length)
+ next_out = 0;
+ return res;
+ }
+
+ /**
+ * Returns the next event in the queue without removing it from the queue.
+ * This method will block until an event is available or until the thread
+ * is interrupted.
+ *
+ * @return The next event in the queue.
+ * @specnote Does not block. Returns null if there are no events on the
+ * queue.
+ */
+ public synchronized AWTEvent peekEvent()
+ {
+ if (next != null)
+ return next.peekEvent();
+
+ if (next_in != next_out)
+ return queue[next_out];
+ else
+ return null;
+ }
+
+ /**
+ * Returns the next event in the queue that has the specified id
+ * without removing it from the queue.
+ * This method will block until an event is available or until the thread
+ * is interrupted.
+ *
+ * @param id The event id to return.
+ *
+ * @return The next event in the queue.
+ *
+ * @specnote Does not block. Returns null if there are no matching events
+ * on the queue.
+ */
+ public synchronized AWTEvent peekEvent(int id)
+ {
+ if (next != null)
+ return next.peekEvent(id);
+
+ int i = next_out;
+ while (i != next_in)
+ {
+ AWTEvent qevt = queue[i];
+ if (qevt.id == id)
+ return qevt;
+ }
+ return null;
+ }
+
+ /**
+ * Posts a new event to the queue.
+ *
+ * @param evt The event to post to the queue.
+ *
+ * @exception NullPointerException If event is null.
+ */
+ public synchronized void postEvent(AWTEvent evt)
+ {
+ if (evt == null)
+ throw new NullPointerException();
+
+ if (next != null)
+ {
+ next.postEvent(evt);
+ return;
+ }
+
+ /* Check for any events already on the queue with the same source
+ and ID. */
+ int i = next_out;
+ while (i != next_in)
+ {
+ AWTEvent qevt = queue[i];
+ Object src;
+ if (qevt.id == evt.id
+ && (src = qevt.getSource()) == evt.getSource()
+ && src instanceof Component)
+ {
+ /* If there are, call coalesceEvents on the source component
+ to see if they can be combined. */
+ Component srccmp = (Component) src;
+ AWTEvent coalesced_evt = srccmp.coalesceEvents(qevt, evt);
+ if (coalesced_evt != null)
+ {
+ /* Yes. Replace the existing event with the combined event. */
+ queue[i] = coalesced_evt;
+ return;
+ }
+ break;
+ }
+ if (++i == queue.length)
+ i = 0;
+ }
+
+ queue[next_in] = evt;
+ if (++next_in == queue.length)
+ next_in = 0;
+
+ if (next_in == next_out)
+ {
+ /* Queue is full. Extend it. */
+ AWTEvent[] oldQueue = queue;
+ queue = new AWTEvent[queue.length * 2];
+
+ int len = oldQueue.length - next_out;
+ System.arraycopy(oldQueue, next_out, queue, 0, len);
+ if (next_out != 0)
+ System.arraycopy(oldQueue, 0, queue, len, next_out);
+
+ next_out = 0;
+ next_in = oldQueue.length;
+ }
+
+ if (dispatchThread == null || !dispatchThread.isAlive())
+ {
+ dispatchThread = new EventDispatchThread(this);
+ dispatchThread.start();
+ }
+
+ notify();
+ }
+
+ /**
+ * Causes runnable to have its run method called in the dispatch thread of the
+ * EventQueue. This will happen after all pending events are processed. The
+ * call blocks until this has happened. This method will throw an Error if
+ * called from the event dispatcher thread.
+ *
+ * @exception InterruptedException If another thread has interrupted
+ * this thread.
+ * @exception InvocationTargetException If an exception is thrown when running
+ * runnable.
+ *
+ * @since 1.2
+ */
+ public static void invokeAndWait(Runnable runnable)
+ throws InterruptedException, InvocationTargetException
+ {
+ if (isDispatchThread ())
+ throw new Error("Can't call invokeAndWait from event dispatch thread");
+
+ EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
+ Thread current = Thread.currentThread();
+
+ InvocationEvent ie =
+ new InvocationEvent(eq, runnable, current, true);
+
+ synchronized (current)
+ {
+ eq.postEvent(ie);
+ current.wait();
+ }
+
+ Exception exception;
+
+ if ((exception = ie.getException()) != null)
+ throw new InvocationTargetException(exception);
+ }
+
+ /**
+ * This arranges for runnable to have its run method called in the
+ * dispatch thread of the EventQueue. This will happen after all
+ * pending events are processed.
+ *
+ * @since 1.2
+ */
+ public static void invokeLater(Runnable runnable)
+ {
+ EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
+
+ InvocationEvent ie =
+ new InvocationEvent(eq, runnable, null, false);
+
+ eq.postEvent(ie);
+ }
+
+ /**
+ * Return true if the current thread is the current AWT event dispatch
+ * thread.
+ */
+ public static boolean isDispatchThread()
+ {
+ EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
+
+ /* Find last EventQueue in chain */
+ while (eq.next != null)
+ eq = eq.next;
+
+ return (Thread.currentThread() == eq.dispatchThread);
+ }
+
+ /**
+ * Return the event currently being dispatched by the event
+ * dispatch thread. If the current thread is not the event
+ * dispatch thread, this method returns null.
+ *
+ * @since 1.4
+ */
+ public static AWTEvent getCurrentEvent()
+ {
+ EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
+ Thread ct = Thread.currentThread();
+
+ /* Find out if this thread is the dispatch thread for any of the
+ EventQueues in the chain */
+ while (ct != eq.dispatchThread)
+ {
+ // Try next EventQueue, if any
+ if (eq.next == null)
+ return null; // Not an event dispatch thread
+ eq = eq.next;
+ }
+
+ return eq.currentEvent;
+ }
+
+ /**
+ * Allows a custom EventQueue implementation to replace this one.
+ * All pending events are transferred to the new queue. Calls to postEvent,
+ * getNextEvent, and peekEvent and others are forwarded to the pushed queue
+ * until it is removed with a pop().
+ *
+ * @exception NullPointerException if newEventQueue is null.
+ */
+ public synchronized void push(EventQueue newEventQueue)
+ {
+ if (newEventQueue == null)
+ throw new NullPointerException ();
+
+ /* Make sure we are at the top of the stack because callers can
+ only get a reference to the one at the bottom using
+ Toolkit.getDefaultToolkit().getSystemEventQueue() */
+ if (next != null)
+ {
+ next.push (newEventQueue);
+ return;
+ }
+
+ /* Make sure we have a live dispatch thread to drive the queue */
+ if (dispatchThread == null)
+ dispatchThread = new EventDispatchThread(this);
+
+ int i = next_out;
+ while (i != next_in)
+ {
+ newEventQueue.postEvent(queue[i]);
+ next_out = i;
+ if (++i == queue.length)
+ i = 0;
+ }
+
+ next = newEventQueue;
+ newEventQueue.prev = this;
+ }
+
+ /** Transfer any pending events from this queue back to the parent queue that
+ * was previously push()ed. Event dispatch from this queue is suspended.
+ *
+ * @exception EmptyStackException If no previous push was made on this
+ * EventQueue.
+ */
+ protected void pop() throws EmptyStackException
+ {
+ if (prev == null)
+ throw new EmptyStackException();
+
+ /* The order is important here, we must get the prev lock first,
+ or deadlock could occur as callers usually get here following
+ prev's next pointer, and thus obtain prev's lock before trying
+ to get this lock. */
+ synchronized (prev)
+ {
+ prev.next = next;
+ if (next != null)
+ next.prev = prev;
+
+ synchronized (this)
+ {
+ int i = next_out;
+ while (i != next_in)
+ {
+ prev.postEvent(queue[i]);
+ next_out = i;
+ if (++i == queue.length)
+ i = 0;
+ }
+ // Empty the queue so it can be reused
+ next_in = 0;
+ next_out = 0;
+
+ setShutdown(true);
+ dispatchThread = null;
+ this.notifyAll();
+ }
+ }
+ }
+
+ /**
+ * Dispatches an event. The manner in which the event is dispatched depends
+ * upon the type of the event and the type of the event's source object.
+ *
+ * @exception NullPointerException If event is null.
+ */
+ protected void dispatchEvent(AWTEvent evt)
+ {
+ currentEvent = evt;
+
+ if (evt instanceof InputEvent)
+ lastWhen = ((InputEvent) evt).getWhen();
+ else if (evt instanceof ActionEvent)
+ lastWhen = ((ActionEvent) evt).getWhen();
+ else if (evt instanceof InvocationEvent)
+ lastWhen = ((InvocationEvent) evt).getWhen();
+
+ if (evt instanceof ActiveEvent)
+ {
+ ActiveEvent active_evt = (ActiveEvent) evt;
+ active_evt.dispatch();
+ }
+ else
+ {
+ Object source = evt.getSource();
+
+ if (source instanceof Component)
+ {
+ Component srccmp = (Component) source;
+ srccmp.dispatchEvent(evt);
+ }
+ else if (source instanceof MenuComponent)
+ {
+ MenuComponent srccmp = (MenuComponent) source;
+ srccmp.dispatchEvent(evt);
+ }
+ }
+ }
+
+ /**
+ * Returns the timestamp of the most recent event that had a timestamp, or
+ * the initialization time of the event queue if no events have been fired.
+ * At present, only <code>InputEvent</code>s, <code>ActionEvent</code>s,
+ * <code>InputMethodEvent</code>s, and <code>InvocationEvent</code>s have
+ * timestamps, but this may be added to other events in future versions.
+ * If this is called by the event dispatching thread, it can be any
+ * (sequential) value, but to other threads, the safest bet is to return
+ * System.currentTimeMillis().
+ *
+ * @return the most recent timestamp
+ * @see InputEvent#getWhen()
+ * @see ActionEvent#getWhen()
+ * @see InvocationEvent#getWhen()
+ * @see InputMethodEvent#getWhen()
+ * @since 1.4
+ */
+ public static long getMostRecentEventTime()
+ {
+ EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
+ if (Thread.currentThread() != eq.dispatchThread)
+ return System.currentTimeMillis();
+ return eq.lastWhen;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FileDialog.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FileDialog.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FileDialog.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FileDialog.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,370 @@
+/* FileDialog.java -- A filename selection dialog box
+ Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.peer.FileDialogPeer;
+import java.io.FilenameFilter;
+import java.io.Serializable;
+
+/**
+ * This class implements a file selection dialog box widget.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Tom Tromey (tromey at redhat.com)
+ */
+public class FileDialog extends Dialog implements Serializable
+{
+
+/*
+ * Static Variables
+ */
+
+/**
+ * Indicates that the purpose of the dialog is for opening a file.
+ */
+public static final int LOAD = 0;
+
+/**
+ * Indicates that the purpose of the dialog is for saving a file.
+ */
+public static final int SAVE = 1;
+
+// Serialization constant
+private static final long serialVersionUID = 5035145889651310422L;
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+/**
+ * @serial The directory for this file dialog.
+ */
+private String dir;
+
+/**
+ * @serial The filename for this file dialog
+ */
+private String file;
+
+/**
+ * @serial The filter for selecting filenames to display
+ */
+private FilenameFilter filter;
+
+/**
+ * @serial The mode of this dialog, either <code>LOAD</code> or
+ * <code>SAVE</code>.
+ */
+private int mode;
+
+/*************************************************************************/
+
+/*
+ * Constructors
+ */
+
+ /**
+ * Initializes a new instance of <code>FileDialog</code> with the specified
+ * parent. This dialog will have no title and will be for loading a file.
+ *
+ * @param parent The parent dialog for this.
+ *
+ * @since 1.5
+ */
+ public FileDialog(Dialog parent)
+ {
+ this(parent, "", LOAD);
+ }
+
+ /**
+ * Initialized a new instance of <code>FileDialog</code> with the
+ * specified parent and title. This dialog will be for opening a file.
+ *
+ * @param parent The parent dialog for this.
+ * @param title The title for this dialog.
+ *
+ * @since 1.5
+ */
+ public FileDialog(Dialog parent, String title)
+ {
+ this(parent, title, LOAD);
+ }
+
+ /**
+ * Initialized a new instance of <code>FileDialog</code> with the specified
+ * parent, title, and mode.
+ *
+ * @param parent The parent dialog for this.
+ * @param title The title for this dialog.
+ * @param mode The mode of the dialog, either <code>LOAD</code> or
+ * <code>SAVE</code>.
+ * @throws IllegalArgumentException - if illegal mode, if
+ * GraphicsEnvironment.isHeadless or if parent is null.
+ *
+ * @since 1.5
+ */
+ public FileDialog(Dialog parent, String title, int mode)
+ {
+ super(parent, title, true);
+
+ // Other IllegalArgumentException cases are taken care of in Window.java
+ if (mode != LOAD && mode != SAVE)
+ throw new IllegalArgumentException (
+ "Mode argument must be either LOAD or SAVE");
+
+ setMode(mode);
+ }
+
+/**
+ * Initializes a new instance of <code>FileDialog</code> with the
+ * specified parent. This dialog will have no title and will be for
+ * loading a file.
+ *
+ * @param parent The parent frame for this dialog.
+ */
+public
+FileDialog(Frame parent)
+{
+ this(parent, "", LOAD);
+}
+
+/*************************************************************************/
+
+/**
+ * Initialized a new instance of <code>FileDialog</code> with the
+ * specified parent and title. This dialog will be for opening a file.
+ *
+ * @param parent The parent frame for this dialog.
+ * @param title The title for this dialog.
+ */
+public
+FileDialog(Frame parent, String title)
+{
+ this(parent, title, LOAD);
+}
+
+/*************************************************************************/
+
+/**
+ * Initialized a new instance of <code>FileDialog</code> with the
+ * specified parent, title, and mode.
+ *
+ * @param parent The parent frame for this dialog.
+ * @param title The title for this dialog.
+ * @param mode The mode of the dialog, either <code>LOAD</code> or
+ * <code>SAVE</code>.
+ *
+ * @exception IllegalArgumentException If an illegal file dialog mode
+ * is supplied.
+ */
+public
+FileDialog(Frame parent, String title, int mode)
+{
+ super(parent, title, true);
+
+ if ((mode != LOAD) && (mode != SAVE))
+ throw new IllegalArgumentException (
+ "Mode argument must be either LOAD or SAVE");
+
+ setMode (mode);
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Methods
+ */
+
+/**
+ * Returns the mode of this dialog, either <code>LOAD</code> or
+ * <code>SAVE</code>.
+ *
+ * @return The mode of this dialog.
+ */
+public int
+getMode()
+{
+ return(mode);
+}
+
+/*************************************************************************/
+
+/**
+ * Sets the mode of this dialog to either <code>LOAD</code> or
+ * <code>SAVE</code>. This method is only effective before the native
+ * peer is created.
+ *
+ * @param mode The new mode of this file dialog.
+ *
+ * @exception IllegalArgumentException If an illegal file dialog mode
+ * is supplied.
+ */
+public void
+setMode(int mode)
+{
+ if ((mode != LOAD) && (mode != SAVE))
+ throw new IllegalArgumentException("Bad mode: " + mode);
+
+ this.mode = mode;
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the directory for this file dialog.
+ *
+ * @return The directory for this file dialog.
+ */
+public String
+getDirectory()
+{
+ return(dir);
+}
+
+/*************************************************************************/
+
+/**
+ * Sets the directory for this file dialog.
+ *
+ * @param dir The new directory for this file dialog.
+ */
+public synchronized void
+setDirectory(String dir)
+{
+ this.dir = dir;
+ if (peer != null)
+ {
+ FileDialogPeer f = (FileDialogPeer) peer;
+ f.setDirectory (dir);
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the file that is selected in this dialog.
+ *
+ * @return The file that is selected in this dialog.
+ */
+public String
+getFile()
+{
+ return(file);
+}
+
+/*************************************************************************/
+
+/**
+ * Sets the selected file for this dialog.
+ *
+ * @param file The selected file for this dialog.
+ */
+public synchronized void
+setFile(String file)
+{
+ this.file = file;
+ if (peer != null)
+ {
+ FileDialogPeer f = (FileDialogPeer) peer;
+ f.setFile (file);
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the filename filter being used by this dialog.
+ *
+ * @return The filename filter being used by this dialog.
+ */
+public FilenameFilter
+getFilenameFilter()
+{
+ return(filter);
+}
+
+/*************************************************************************/
+
+/**
+ * Sets the filename filter used by this dialog.
+ *
+ * @param filter The new filename filter for this file dialog box.
+ */
+public synchronized void
+setFilenameFilter(FilenameFilter filter)
+{
+ this.filter = filter;
+ if (peer != null)
+ {
+ FileDialogPeer f = (FileDialogPeer) peer;
+ f.setFilenameFilter (filter);
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * Creates the native peer for this file dialog box.
+ */
+public void
+addNotify()
+{
+ if (peer == null)
+ peer = getToolkit ().createFileDialog (this);
+ super.addNotify ();
+}
+
+/*************************************************************************/
+
+/**
+ * Returns a debugging string for this object.
+ *
+ * @return A debugging string for this object.
+ */
+protected String
+paramString()
+{
+ return ("dir=" + dir + ",file=" + file +
+ ",mode=" + mode + "," + super.paramString());
+}
+
+} // class FileDialog
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FlowLayout.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FlowLayout.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FlowLayout.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FlowLayout.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,362 @@
+/* FlowLayout.java -- Grid-based layout engine
+ Copyright (C) 1999, 2000, 2001, 2002, 2004 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.io.Serializable;
+
+/** This class implements a flow-based layout. Components are laid
+ * out in order from left to right. When a component cannot be placed
+ * without horizontal clipping, a new row is started. This class
+ * supports horizontal and vertical gaps. These are used for spacing
+ * between components.
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class FlowLayout implements LayoutManager, Serializable
+{
+ /** Constant that specifies left alignment. */
+ public static final int LEFT = 0;
+ /** Constant that specifies center alignment. */
+ public static final int CENTER = 1;
+ /** Constant that specifies right alignment. */
+ public static final int RIGHT = 2;
+
+ /** Constant that specifies alignment to leading edge of container's
+ * orientation. */
+ public static final int LEADING = 3;
+ /** Constant that specifies alignment to trailing edge of container's
+ * orientation. */
+ public static final int TRAILING = 4;
+
+ // Serialization constant
+ private static final long serialVersionUID = -7262534875583282631L;
+
+ /**
+ * Add a new component to the layout. This particular implementation
+ * does nothing.
+ *
+ * @param name the name
+ * @param comp the component
+ */
+ public void addLayoutComponent (String name, Component comp)
+ {
+ // Nothing.
+ }
+
+ /**
+ * Returns the current justification value for this object.
+ *
+ * @return The current justification value for this object.
+ */
+ public int getAlignment ()
+ {
+ return align;
+ }
+
+ /**
+ * Returns the horizontal gap between components.
+ *
+ * @return The horizontal gap between components.
+ */
+ public int getHgap ()
+ {
+ return hgap;
+ }
+
+ /**
+ * Returns the vertical gap between lines of components.
+ *
+ * @return The vertical gap between lines of components.
+ */
+ public int getVgap ()
+ {
+ return vgap;
+ }
+
+ /**
+ * Initializes a new instance of <code>FlowLayout</code> with a center
+ * justification and a default horizontal and vertical gap of 5.
+ */
+ public FlowLayout ()
+ {
+ this (CENTER, 5, 5);
+ }
+
+ /**
+ * Initializes a new instance of <code>FlowLayout</code> with the specified
+ * justification and a default horizontal and vertical gap of 5.
+ *
+ * @param align The justification setting, which should be one of the
+ * contants in this class.
+ */
+ public FlowLayout (int align)
+ {
+ this (align, 5, 5);
+ }
+
+ /**
+ * Initializes a new instance of <code>FlowLayout</code> with the specified
+ * justification and gap values
+ * @param align Alignment
+ * @param hgap The horizontal gap
+ * @param vgap The vertical gap
+ * @exception IllegalArgumentException If either gap is negative
+ */
+ public FlowLayout (int align, int hgap, int vgap)
+ {
+ // Use methods to set fields so that we can have all the checking
+ // in one place.
+ setVgap (vgap);
+ setHgap (hgap);
+ setAlignment (align);
+ }
+
+ /** Lay out the container's components based on current settings.
+ * @param parent The parent container
+ */
+ public void layoutContainer (Container parent)
+ {
+ synchronized (parent.getTreeLock ())
+ {
+ int num = parent.getComponentCount ();
+ // This is more efficient than calling getComponents().
+ Component[] comps = parent.component;
+
+ Dimension d = parent.getSize ();
+ Insets ins = parent.getInsets ();
+
+ ComponentOrientation orient = parent.getComponentOrientation ();
+ boolean left_to_right = orient.isLeftToRight ();
+
+ int y = ins.top + vgap;
+ int i = 0;
+ while (i < num)
+ {
+ // Find the components which go in the current row.
+ int new_w = ins.left + hgap + ins.right;
+ int new_h = 0;
+ int j;
+ boolean found_one = false;
+ for (j = i; j < num; ++j)
+ {
+ // Skip invisible items.
+ if (! comps[j].visible)
+ continue;
+
+ Dimension c = comps[j].getPreferredSize ();
+
+ int next_w = new_w + hgap + c.width;
+ if (next_w <= d.width || ! found_one)
+ {
+ new_w = next_w;
+ new_h = Math.max (new_h, c.height);
+ found_one = true;
+ }
+ else
+ {
+ // Must start a new row, and we already found an item
+ break;
+ }
+ }
+
+ // Set the location of each component for this row.
+ int x;
+
+ int myalign = align;
+ if (align == LEADING)
+ myalign = left_to_right ? LEFT : RIGHT;
+ else if (align == TRAILING)
+ myalign = left_to_right ? RIGHT : LEFT;
+
+ if (myalign == RIGHT)
+ x = ins.left + (d.width - new_w) + hgap;
+ else if (myalign == CENTER)
+ x = ins.left + (d.width - new_w) / 2 + hgap;
+ else // LEFT and all other values of align.
+ x = ins.left + hgap;
+
+ for (int k = i; k < j; ++k)
+ {
+ if (comps[k].visible)
+ {
+ Dimension c = comps[k].getPreferredSize ();
+ comps[k].setBounds (x, y + (new_h - c.height) / 2,
+ c.width, c.height);
+ x += c.width + hgap;
+ }
+ }
+
+ // Advance to next row.
+ i = j;
+ y += new_h + vgap;
+ }
+ }
+ }
+
+ /**
+ * Returns the minimum layout size for the specified container using
+ * this layout.
+ * @param cont The parent container
+ * @return The minimum layout size.
+ */
+ public Dimension minimumLayoutSize (Container cont)
+ {
+ return getSize (cont, true);
+ }
+
+ /**
+ * Returns the preferred layout size for the specified container using
+ * this layout.
+ * @param cont The parent container
+ * @return The preferred layout size.
+ */
+ public Dimension preferredLayoutSize (Container cont)
+ {
+ return getSize (cont, false);
+ }
+
+ /** Remove the indicated component from this layout manager.
+ * This particular implementation does nothing.
+ * @param comp The component to remove
+ */
+ public void removeLayoutComponent (Component comp)
+ {
+ // Nothing.
+ }
+
+ /**
+ * Sets the justification value for this object to the specified value.
+ *
+ * @param align The new justification value for this object, which must
+ * be one of the constants in this class.
+ */
+ public void setAlignment (int align)
+ {
+ // The JDK accepts invalid values and treats them as
+ // LEFT during layout, so do we. The invalid value is even stored,
+ // getAlignment() returns the same invalid value.
+ this.align = align;
+ }
+
+ /**
+ * Sets the horizontal gap between lines of components to the specified value.
+ * No Exception is thrown if hgap < 0.
+ *
+ * @param hgap The new horizontal gap between components.
+ */
+ public void setHgap (int hgap)
+ {
+ this.hgap = hgap;
+ }
+
+ /**
+ * Sets the vertical gap between lines of components to the specified value.
+ * No Exception is thrown if vgap < 0.
+ *
+ * @param vgap The new vertical gap.
+ */
+ public void setVgap (int vgap)
+ {
+ this.vgap = vgap;
+ }
+
+ /** Return String description of this object.
+ * @return A string representation of this object.
+ */
+ public String toString ()
+ {
+ return ("[" + getClass ().getName () + ",hgap=" + hgap + ",vgap=" + vgap
+ + ",align=" + align + "]");
+ }
+
+ // This method is used to compute the various sizes.
+ private Dimension getSize (Container parent, boolean is_min)
+ {
+ synchronized (parent.getTreeLock ())
+ {
+ int w, h, num = parent.getComponentCount ();
+ // This is more efficient than calling getComponents().
+ Component[] comps = parent.component;
+
+ w = 0;
+ h = 0;
+ for (int i = 0; i < num; ++i)
+ {
+ if (! comps[i].visible)
+ continue;
+
+ // FIXME: can we just directly read the fields in Component?
+ // Or will that not work with subclassing?
+ Dimension d;
+
+ if (is_min)
+ d = comps[i].getMinimumSize ();
+ else
+ d = comps[i].getPreferredSize ();
+
+ w += d.width;
+ h = Math.max (d.height, h);
+ }
+
+ Insets ins = parent.getInsets ();
+
+ w += (num + 1) * hgap + ins.left + ins.right;
+ h += 2 * vgap + ins.top + ins.bottom;
+
+ return new Dimension (w, h);
+ }
+ }
+
+ /**
+ * @serial The justification alignment of the lines of components, which
+ * will be one of the constants defined in this class.
+ */
+ private int align;
+
+ /**
+ * @serial The horizontal gap between components.
+ */
+ private int hgap;
+
+ /**
+ * @serial The vertical gap between lines of components.
+ */
+ private int vgap;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FocusTraversalPolicy.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FocusTraversalPolicy.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FocusTraversalPolicy.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FocusTraversalPolicy.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,103 @@
+/* FocusTraversalPolicy.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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * @since 1.4
+ */
+public abstract class FocusTraversalPolicy
+{
+ /**
+ * Creates a <code>FocusTraversalPolicy</code> object.
+ */
+ public FocusTraversalPolicy()
+ {
+ // Do nothing in here.
+ }
+
+ /**
+ * Returns the Component that should receive the focus after a Component.
+ *
+ * @exception IllegalArgumentException If root or current is null,
+ * or if root is not a focus cycle root of current.
+ */
+ public abstract Component getComponentAfter(Container root,
+ Component current);
+
+ /**
+ * Returns the Component that should receive the focus before a Component.
+ *
+ * @exception IllegalArgumentException If root or current is null,
+ * or if root is not a focus cycle root of current.
+ */
+ public abstract Component getComponentBefore(Container root,
+ Component current);
+
+ /**
+ * Returns the first Component in the traversal cycle.
+ *
+ * @exception IllegalArgumentException If root is null.
+ */
+ public abstract Component getFirstComponent(Container root);
+
+ /**
+ * Returns the last Component in the traversal cycle.
+ *
+ * @exception IllegalArgumentException If root is null.
+ */
+ public abstract Component getLastComponent(Container root);
+
+ /**
+ * Returns the default Component to focus.
+ *
+ * @exception IllegalArgumentException If root is null.
+ */
+ public abstract Component getDefaultComponent(Container root);
+
+ /**
+ * Returns the Component that should receive the focus when a Window is made
+ * visible for the first time.
+ *
+ * @exception IllegalArgumentException If window is null.
+ */
+ public Component getInitialComponent(Window window)
+ {
+ return getDefaultComponent(window);
+ }
+} // class FocusTraversalPolicy
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Font.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Font.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Font.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Font.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1379 @@
+/* Font.java -- Font object
+ Copyright (C) 1999, 2002, 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import gnu.java.awt.ClasspathToolkit;
+import gnu.java.awt.peer.ClasspathFontPeer;
+
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.font.LineMetrics;
+import java.awt.font.TextLayout;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.peer.FontPeer;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+import java.text.AttributedCharacterIterator;
+import java.text.CharacterIterator;
+import java.text.StringCharacterIterator;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+/**
+ * This class represents a windowing system font.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @author Graydon Hoare (graydon at redhat.com)
+ */
+public class Font implements Serializable
+{
+
+ /**
+ * Constant indicating a "plain" font.
+ */
+ public static final int PLAIN = 0;
+
+ /**
+ * Constant indicating a "bold" font.
+ */
+ public static final int BOLD = 1;
+
+ /**
+ * Constant indicating an "italic" font.
+ */
+ public static final int ITALIC = 2;
+
+ /**
+ * Constant indicating the baseline mode characteristic of Roman.
+ */
+ public static final int ROMAN_BASELINE = 0;
+
+ /**
+ * Constant indicating the baseline mode characteristic of Chinese.
+ */
+ public static final int CENTER_BASELINE = 1;
+
+ /**
+ * Constant indicating the baseline mode characteristic of Devanigri.
+ */
+ public static final int HANGING_BASELINE = 2;
+
+
+ /**
+ * Indicates to <code>createFont</code> that the supplied font data
+ * is in TrueType format.
+ *
+ * <p><em>Specification Note:</em> The Sun JavaDoc for J2SE 1.4 does
+ * not indicate whether this value also subsumes OpenType. OpenType
+ * is essentially the same format as TrueType, but allows to define
+ * glyph shapes in the same way as PostScript, using cubic bezier
+ * curves.
+ *
+ * @since 1.3
+ */
+ public static final int TRUETYPE_FONT = 0;
+
+ /**
+ * Indicates to <code>createFont</code> that the supplied font data
+ * is in Type1 format.
+ *
+ * @since 1.5
+ */
+ public static final int TYPE1_FONT = 1;
+
+ /**
+ * A flag for <code>layoutGlyphVector</code>, indicating that the
+ * orientation of a text run is from left to right.
+ *
+ * @since 1.4
+ */
+ public static final int LAYOUT_LEFT_TO_RIGHT = 0;
+
+
+ /**
+ * A flag for <code>layoutGlyphVector</code>, indicating that the
+ * orientation of a text run is from right to left.
+ *
+ * @since 1.4
+ */
+ public static final int LAYOUT_RIGHT_TO_LEFT = 1;
+
+
+ /**
+ * A flag for <code>layoutGlyphVector</code>, indicating that the
+ * text does not contain valid characters before the
+ * <code>start</code> position. If this flag is set,
+ * <code>layoutGlyphVector</code> does not examine the text before
+ * <code>start</code>, even if this would be necessary to select the
+ * correct glyphs (e.g., for Arabic text).
+ *
+ * @since 1.4
+ */
+ public static final int LAYOUT_NO_START_CONTEXT = 2;
+
+
+ /**
+ * A flag for <code>layoutGlyphVector</code>, indicating that the
+ * text does not contain valid characters after the
+ * <code>limit</code> position. If this flag is set,
+ * <code>layoutGlyphVector</code> does not examine the text after
+ * <code>limit</code>, even if this would be necessary to select the
+ * correct glyphs (e.g., for Arabic text).
+ *
+ * @since 1.4
+ */
+ public static final int LAYOUT_NO_LIMIT_CONTEXT = 4;
+
+ /**
+ * The logical name of this font.
+ *
+ * @since 1.0
+ */
+ protected String name;
+
+ /**
+ * The size of this font in points, rounded.
+ *
+ * @since 1.0
+ */
+ protected int size;
+
+ /**
+ * The size of this font in points.
+ *
+ * @since 1.0
+ */
+ protected float pointSize;
+
+ /**
+ * The style of this font -- PLAIN, BOLD, ITALIC or BOLD+ITALIC.
+ *
+ * @since 1.0
+ */
+ protected int style;
+
+//Serialization constant
+ private static final long serialVersionUID = -4206021311591459213L;
+
+
+ // The ClasspathToolkit-provided peer which implements this font
+ private transient ClasspathFontPeer peer;
+
+
+ /**
+ * Creates a <code>Font</code> object from the specified string, which
+ * is in one of the following formats:
+ * <p>
+ * <ul>
+ * <li>fontname-style-pointsize
+ * <li>fontname-style
+ * <li>fontname-pointsize
+ * <li>fontname
+ * </ul>
+ * <p>
+ * The style should be one of BOLD, ITALIC, or BOLDITALIC. The default
+ * style if none is specified is PLAIN. The default size if none
+ * is specified is 12.
+ *
+ * @param fontspec a string specifying the required font (<code>null</code>
+ * permitted, interpreted as 'Dialog-PLAIN-12').
+ *
+ * @return A font.
+ */
+ public static Font decode(String fontspec)
+ {
+ if (fontspec == null)
+ fontspec = "Dialog-PLAIN-12";
+ String name = null;
+ int style = PLAIN;
+ int size = 12;
+
+ StringTokenizer st = new StringTokenizer(fontspec, "- ");
+ while (st.hasMoreTokens())
+ {
+ String token = st.nextToken();
+ if (name == null)
+ {
+ name = token;
+ continue;
+ }
+
+ if (token.toUpperCase().equals("BOLD"))
+ {
+ style = BOLD;
+ continue;
+ }
+ if (token.toUpperCase().equals("ITALIC"))
+ {
+ style = ITALIC;
+ continue;
+ }
+ if (token.toUpperCase().equals("BOLDITALIC"))
+ {
+ style = BOLD | ITALIC;
+ continue;
+ }
+
+ int tokenval = 0;
+ try
+ {
+ tokenval = Integer.parseInt(token);
+ }
+ catch (NumberFormatException e)
+ {
+ // Ignored.
+ }
+
+ if (tokenval != 0)
+ size = tokenval;
+ }
+
+ HashMap attrs = new HashMap();
+ ClasspathFontPeer.copyStyleToAttrs(style, attrs);
+ ClasspathFontPeer.copySizeToAttrs(size, attrs);
+
+ return getFontFromToolkit(name, attrs);
+ }
+
+ /* These methods delegate to the toolkit. */
+
+ static ClasspathToolkit tk()
+ {
+ return (ClasspathToolkit) Toolkit.getDefaultToolkit();
+ }
+
+ /* Every factory method in Font should eventually call this. */
+ static Font getFontFromToolkit(String name, Map attribs)
+ {
+ return tk().getFont(name, attribs);
+ }
+
+ /* Every Font constructor should eventually call this. */
+ static ClasspathFontPeer getPeerFromToolkit(String name, Map attrs)
+ {
+ return tk().getClasspathFontPeer(name, attrs);
+ }
+
+
+ /**
+ * Returns a <code>Font</code> object from the passed property name.
+ *
+ * @param propname The name of the system property.
+ * @param defval Value to use if the property is not found.
+ *
+ * @return The requested font, or <code>default</code> if the property
+ * not exist or is malformed.
+ */
+ public static Font getFont(String propname, Font defval)
+ {
+ String propval = System.getProperty(propname);
+ if (propval != null)
+ return decode(propval);
+ return defval;
+ }
+
+ /**
+ * Returns a <code>Font</code> object from the passed property name.
+ *
+ * @param propname The name of the system property.
+ *
+ * @return The requested font, or <code>null</code> if the property
+ * not exist or is malformed.
+ */
+ public static Font getFont(String propname)
+ {
+ return getFont(propname, (Font) null);
+ }
+
+ /**
+ * Initializes a new instance of <code>Font</code> with the specified
+ * attributes.
+ *
+ * @param name The name of the font.
+ * @param style The font style.
+ * @param size The font point size.
+ */
+ public Font(String name, int style, int size)
+ {
+ HashMap attrs = new HashMap();
+ ClasspathFontPeer.copyStyleToAttrs(style, attrs);
+ ClasspathFontPeer.copySizeToAttrs(size, attrs);
+ this.peer = getPeerFromToolkit(name, attrs);
+ this.size = size;
+ this.pointSize = (float) size;
+ if (name != null)
+ this.name = name;
+ else
+ this.name = peer.getName(this);
+ }
+
+ public Font(Map attrs)
+ {
+ this(null, attrs);
+ }
+
+ /* This extra constructor is here to permit ClasspathToolkit and to
+ build a font with a "logical name" as well as attrs.
+ ClasspathToolkit.getFont(String,Map) uses reflection to call this
+ package-private constructor. */
+ Font(String name, Map attrs)
+ {
+ // If attrs is null, setting it to an empty HashMap will give this
+ // Font default attributes.
+ if (attrs == null)
+ attrs = new HashMap();
+ peer = getPeerFromToolkit(name, attrs);
+ size = (int) peer.getSize(this);
+ pointSize = peer.getSize(this);
+ if (name != null)
+ this.name = name;
+ else
+ this.name = peer.getName(this);
+ }
+
+ /**
+ * Returns the logical name of the font. A logical name is the name the
+ * font was constructed with. It may be the name of a logical font (one
+ * of 6 required names in all java environments) or it may be a face
+ * name.
+ *
+ * @return The logical name of the font.
+ *
+ * @see #getFamily()
+ * @see #getFontName()
+ */
+ public String getName ()
+ {
+ return peer.getName(this);
+ }
+
+ /**
+ * Returns the size of the font, in typographics points (1/72 of an inch),
+ * rounded to an integer.
+ *
+ * @return The font size
+ */
+ public int getSize()
+ {
+ return size;
+ }
+
+ /**
+ * Returns the size of the font, in typographics points (1/72 of an inch).
+ *
+ * @return The font size
+ */
+ public float getSize2D()
+ {
+ return pointSize;
+ }
+
+ /**
+ * Tests whether or not this is a plain font. This will be true if
+ * and only if neither the bold nor the italics style is set.
+ *
+ * @return <code>true</code> if this is a plain font, <code>false</code>
+ * otherwise.
+ */
+ public boolean isPlain()
+ {
+ return peer.isPlain(this);
+ }
+
+ /**
+ * Tests whether or not this font is bold.
+ *
+ * @return <code>true</code> if this font is bold, <code>false</code>
+ * otherwise.
+ */
+ public boolean isBold()
+ {
+ return peer.isBold(this);
+ }
+
+ /**
+ * Tests whether or not this font is italic.
+ *
+ * @return <code>true</code> if this font is italic, <code>false</code>
+ * otherwise.
+ */
+ public boolean isItalic()
+ {
+ return peer.isItalic(this);
+ }
+
+ /**
+ * Returns the family name of this font. A family name describes a design
+ * or "brand name" (such as Helvetica or Palatino). It is less specific
+ * than a font face name (such as Helvetica Bold).
+ *
+ * @return A string containing the font family name.
+ *
+ * @since 1.2
+ *
+ * @see #getName()
+ * @see #getFontName()
+ * @see GraphicsEnvironment#getAvailableFontFamilyNames()
+ */
+ public String getFamily()
+ {
+ return peer.getFamily(this);
+ }
+
+ /**
+ * Returns integer code representing the sum of style flags of this font, a
+ * combination of either {@link #PLAIN}, {@link #BOLD}, or {@link #ITALIC}.
+ *
+ * @return code representing the style of this font.
+ *
+ * @see #isPlain()
+ * @see #isBold()
+ * @see #isItalic()
+ */
+ public int getStyle()
+ {
+ return peer.getStyle(this);
+ }
+
+ /**
+ * Checks if specified character maps to a glyph in this font.
+ *
+ * @param c The character to check.
+ *
+ * @return Whether the character has a corresponding glyph in this font.
+ *
+ * @since 1.2
+ */
+ public boolean canDisplay(char c)
+ {
+ return peer.canDisplay(this, c);
+ }
+
+ /**
+ * Checks how much of a given string can be mapped to glyphs in
+ * this font.
+ *
+ * @param s The string to check.
+ *
+ * @return The index of the first character in <code>s</code> which cannot
+ * be converted to a glyph by this font, or <code>-1</code> if all
+ * characters can be mapped to glyphs.
+ *
+ * @since 1.2
+ */
+ public int canDisplayUpTo(String s)
+ {
+ return peer.canDisplayUpTo(this, new StringCharacterIterator(s),
+ 0, s.length() - 1);
+ }
+
+ /**
+ * Checks how much of a given sequence of text can be mapped to glyphs in
+ * this font.
+ *
+ * @param text Array containing the text to check.
+ * @param start Position of first character to check in <code>text</code>.
+ * @param limit Position of last character to check in <code>text</code>.
+ *
+ * @return The index of the first character in the indicated range which
+ * cannot be converted to a glyph by this font, or <code>-1</code> if all
+ * characters can be mapped to glyphs.
+ *
+ * @since 1.2
+ *
+ * @throws IndexOutOfBoundsException if the range [start, limit] is
+ * invalid in <code>text</code>.
+ */
+ public int canDisplayUpTo (char[] text, int start, int limit)
+ {
+ return peer.canDisplayUpTo(this,
+ new StringCharacterIterator(new String (text)),
+ start, limit);
+ }
+
+ /**
+ * Checks how much of a given sequence of text can be mapped to glyphs in
+ * this font.
+ *
+ * @param i Iterator over the text to check.
+ * @param start Position of first character to check in <code>i</code>.
+ * @param limit Position of last character to check in <code>i</code>.
+ *
+ * @return The index of the first character in the indicated range which
+ * cannot be converted to a glyph by this font, or <code>-1</code> if all
+ * characters can be mapped to glyphs.
+ *
+ * @since 1.2
+ *
+ * @throws IndexOutOfBoundsException if the range [start, limit] is
+ * invalid in <code>i</code>.
+ */
+ public int canDisplayUpTo(CharacterIterator i, int start, int limit)
+ {
+ return peer.canDisplayUpTo(this, i, start, limit);
+ }
+
+ /**
+ * Creates a new font with point size 1 and {@link #PLAIN} style,
+ * reading font data from the provided input stream. The resulting font
+ * can have further fonts derived from it using its
+ * <code>deriveFont</code> method.
+ *
+ * @param fontFormat Integer code indicating the format the font data is
+ * in.Currently this can only be {@link #TRUETYPE_FONT}.
+ * @param is {@link InputStream} from which font data will be read. This
+ * stream is not closed after font data is extracted.
+ *
+ * @return A new {@link Font} of the format indicated.
+ *
+ * @throws IllegalArgumentException if <code>fontType</code> is not
+ * recognized.
+ * @throws FontFormatException if data in InputStream is not of format
+ * indicated.
+ * @throws IOException if insufficient data is present on InputStream.
+ *
+ * @since 1.3
+ */
+ public static Font createFont (int fontFormat, InputStream is)
+ throws FontFormatException, IOException
+ {
+ return tk().createFont(fontFormat, is);
+ }
+
+ /**
+ * Creates a new font from a File object.
+ *
+ * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
+ *
+ * @param fontFormat - Integer code indicating the format the font data is
+ * in.Currently this can only be {@link #TRUETYPE_FONT}.
+ * @param file - a {@link File} from which font data will be read.
+ *
+ * @return A new {@link Font} of the format indicated.
+ *
+ * @throws IllegalArgumentException if <code>fontType</code> is not
+ * recognized.
+ * @throws NullPointerException if <code>file</code> is <code>null</code>.
+ * @throws FontFormatException if data in the file is invalid or cannot be read..
+ * @throws SecurityException if the caller has no read permission for the file.
+ * @throws IOException if the file cannot be read
+ *
+ * @since 1.5
+ */
+ public static Font createFont (int fontFormat, File file)
+ throws FontFormatException, IOException
+ {
+ if( file == null )
+ throw new NullPointerException("Null file argument");
+ return tk().createFont(fontFormat, new FileInputStream( file ));
+ }
+
+ /**
+ * Maps characters to glyphs in a one-to-one relationship, returning a new
+ * {@link GlyphVector} with a mapped glyph for each input character. This
+ * sort of mapping is often sufficient for some scripts such as Roman, but
+ * is inappropriate for scripts with special shaping or contextual layout
+ * requirements such as Arabic, Indic, Hebrew or Thai.
+ *
+ * @param ctx The rendering context used for precise glyph placement.
+ * @param str The string to convert to Glyphs.
+ *
+ * @return A new {@link GlyphVector} containing glyphs mapped from str,
+ * through the font's cmap table.
+ *
+ * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
+ */
+ public GlyphVector createGlyphVector(FontRenderContext ctx, String str)
+ {
+ return peer.createGlyphVector(this, ctx, new StringCharacterIterator(str));
+ }
+
+ /**
+ * Maps characters to glyphs in a one-to-one relationship, returning a new
+ * {@link GlyphVector} with a mapped glyph for each input character. This
+ * sort of mapping is often sufficient for some scripts such as Roman, but
+ * is inappropriate for scripts with special shaping or contextual layout
+ * requirements such as Arabic, Indic, Hebrew or Thai.
+ *
+ * @param ctx The rendering context used for precise glyph placement.
+ * @param i Iterator over the text to convert to glyphs.
+ *
+ * @return A new {@link GlyphVector} containing glyphs mapped from str,
+ * through the font's cmap table.
+ *
+ * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
+ */
+ public GlyphVector createGlyphVector(FontRenderContext ctx,
+ CharacterIterator i)
+ {
+ return peer.createGlyphVector(this, ctx, i);
+ }
+
+ /**
+ * Maps characters to glyphs in a one-to-one relationship, returning a new
+ * {@link GlyphVector} with a mapped glyph for each input character. This
+ * sort of mapping is often sufficient for some scripts such as Roman, but
+ * is inappropriate for scripts with special shaping or contextual layout
+ * requirements such as Arabic, Indic, Hebrew or Thai.
+ *
+ * @param ctx The rendering context used for precise glyph placement.
+ * @param chars Array of characters to convert to glyphs.
+ *
+ * @return A new {@link GlyphVector} containing glyphs mapped from str,
+ * through the font's cmap table.
+ *
+ * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
+ */
+ public GlyphVector createGlyphVector(FontRenderContext ctx, char[] chars)
+ {
+ return peer.createGlyphVector(this, ctx,
+ new StringCharacterIterator(new String(chars)));
+ }
+
+ /**
+ * Extracts a sequence of glyphs from a font, returning a new {@link
+ * GlyphVector} with a mapped glyph for each input glyph code.
+ *
+ * @param ctx The rendering context used for precise glyph placement.
+ * @param glyphCodes Array of characters to convert to glyphs.
+ *
+ * @return A new {@link GlyphVector} containing glyphs mapped from str,
+ * through the font's cmap table.
+ *
+ * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
+ *
+ * @specnote This method is documented to perform character-to-glyph
+ * conversions, in the Sun documentation, but its second parameter name is
+ * "glyphCodes" and it is not clear to me why it would exist if its
+ * purpose was to transport character codes inside integers. I assume it
+ * is mis-documented in the Sun documentation.
+ */
+ public GlyphVector createGlyphVector(FontRenderContext ctx, int[] glyphCodes)
+ {
+ return peer.createGlyphVector(this, ctx, glyphCodes);
+ }
+
+ /**
+ * Produces a new {@link Font} based on the current font, adjusted to a
+ * new size and style.
+ *
+ * @param style The style of the newly created font.
+ * @param size The size of the newly created font.
+ *
+ * @return A clone of the current font, with the specified size and style.
+ *
+ * @since 1.2
+ */
+ public Font deriveFont(int style, float size)
+ {
+ return peer.deriveFont(this, style, size);
+ }
+
+ /**
+ * Produces a new {@link Font} based on the current font, adjusted to a
+ * new size.
+ *
+ * @param size The size of the newly created font.
+ *
+ * @return A clone of the current font, with the specified size.
+ *
+ * @since 1.2
+ */
+ public Font deriveFont(float size)
+ {
+ return peer.deriveFont(this, size);
+ }
+
+ /**
+ * Produces a new {@link Font} based on the current font, adjusted to a
+ * new style.
+ *
+ * @param style The style of the newly created font.
+ *
+ * @return A clone of the current font, with the specified style.
+ *
+ * @since 1.2
+ */
+ public Font deriveFont(int style)
+ {
+ return peer.deriveFont(this, style);
+ }
+
+ /**
+ * Produces a new {@link Font} based on the current font, adjusted to a
+ * new style and subjected to a new affine transformation.
+ *
+ * @param style The style of the newly created font.
+ * @param a The transformation to apply.
+ *
+ * @return A clone of the current font, with the specified style and
+ * transform.
+ *
+ * @throws IllegalArgumentException If transformation is
+ * <code>null</code>.
+ *
+ * @since 1.2
+ */
+ public Font deriveFont(int style, AffineTransform a)
+ {
+ if (a == null)
+ throw new IllegalArgumentException("Affine transformation is null");
+
+ return peer.deriveFont(this, style, a);
+ }
+
+ /**
+ * Produces a new {@link Font} based on the current font, subjected
+ * to a new affine transformation.
+ *
+ * @param a The transformation to apply.
+ *
+ * @return A clone of the current font, with the specified transform.
+ *
+ * @throws IllegalArgumentException If transformation is
+ * <code>null</code>.
+ *
+ * @since 1.2
+ */
+ public Font deriveFont(AffineTransform a)
+ {
+ if (a == null)
+ throw new IllegalArgumentException("Affine transformation is null");
+
+ return peer.deriveFont(this, a);
+ }
+
+ /**
+ * Produces a new {@link Font} based on the current font, adjusted to a
+ * new set of attributes.
+ *
+ * @param attributes Attributes of the newly created font.
+ *
+ * @return A clone of the current font, with the specified attributes.
+ *
+ * @since 1.2
+ */
+ public Font deriveFont(Map attributes)
+ {
+ return peer.deriveFont(this, attributes);
+ }
+
+ /**
+ * Returns a map of chracter attributes which this font currently has set.
+ *
+ * @return A map of chracter attributes which this font currently has set.
+ *
+ * @see #getAvailableAttributes()
+ * @see java.text.AttributedCharacterIterator.Attribute
+ * @see java.awt.font.TextAttribute
+ */
+ public Map getAttributes()
+ {
+ return peer.getAttributes(this);
+ }
+
+ /**
+ * Returns an array of chracter attribute keys which this font understands.
+ *
+ * @return An array of chracter attribute keys which this font understands.
+ *
+ * @see #getAttributes()
+ * @see java.text.AttributedCharacterIterator.Attribute
+ * @see java.awt.font.TextAttribute
+ */
+ public AttributedCharacterIterator.Attribute[] getAvailableAttributes()
+ {
+ return peer.getAvailableAttributes(this);
+ }
+
+ /**
+ * Returns a baseline code (one of {@link #ROMAN_BASELINE}, {@link
+ * #CENTER_BASELINE} or {@link #HANGING_BASELINE}) indicating which baseline
+ * this font will measure baseline offsets for, when presenting glyph
+ * metrics for a given character.
+ *
+ * Baseline offsets describe the position of a glyph relative to an
+ * invisible line drawn under, through the center of, or over a line of
+ * rendered text, respectively. Different scripts use different baseline
+ * modes, so clients should not assume all baseline offsets in a glyph
+ * vector are from a common baseline.
+ *
+ * @param c The character code to select a baseline mode for.
+ *
+ * @return The baseline mode which would be used in a glyph associated
+ * with the provided character.
+ *
+ * @since 1.2
+ *
+ * @see LineMetrics#getBaselineOffsets()
+ */
+ public byte getBaselineFor(char c)
+ {
+ return peer.getBaselineFor(this, c);
+ }
+
+ /**
+ * Returns the family name of this font. A family name describes a
+ * typographic style (such as Helvetica or Palatino). It is more specific
+ * than a logical font name (such as Sans Serif) but less specific than a
+ * font face name (such as Helvetica Bold).
+ *
+ * @param lc The locale in which to describe the name of the font family.
+ *
+ * @return A string containing the font family name, localized for the
+ * provided locale.
+ *
+ * @since 1.2
+ *
+ * @see #getName()
+ * @see #getFontName()
+ * @see GraphicsEnvironment#getAvailableFontFamilyNames()
+ * @see Locale
+ */
+ public String getFamily(Locale lc)
+ {
+ return peer.getFamily(this, lc);
+ }
+
+ /**
+ * Returns a font appropriate for the given attribute set.
+ *
+ * @param attributes The attributes required for the new font.
+ *
+ * @return A new Font with the given attributes.
+ *
+ * @since 1.2
+ *
+ * @see java.awt.font.TextAttribute
+ */
+ public static Font getFont(Map attributes)
+ {
+ return getFontFromToolkit(null, attributes);
+ }
+
+ /**
+ * Returns the font face name of the font. A font face name describes a
+ * specific variant of a font family (such as Helvetica Bold). It is more
+ * specific than both a font family name (such as Helvetica) and a logical
+ * font name (such as Sans Serif).
+ *
+ * @return The font face name of the font.
+ *
+ * @since 1.2
+ *
+ * @see #getName()
+ * @see #getFamily()
+ */
+ public String getFontName()
+ {
+ return peer.getFontName(this);
+ }
+
+ /**
+ * Returns the font face name of the font. A font face name describes a
+ * specific variant of a font family (such as Helvetica Bold). It is more
+ * specific than both a font family name (such as Helvetica).
+ *
+ * @param lc The locale in which to describe the name of the font face.
+ *
+ * @return A string containing the font face name, localized for the
+ * provided locale.
+ *
+ * @since 1.2
+ *
+ * @see #getName()
+ * @see #getFamily()
+ */
+ public String getFontName(Locale lc)
+ {
+ return peer.getFontName(this, lc);
+ }
+
+ /**
+ * Returns the italic angle of this font, a measurement of its slant when
+ * style is {@link #ITALIC}. The precise meaning is the inverse slope of a
+ * caret line which "best measures" the font's italic posture.
+ *
+ * @return The italic angle.
+ *
+ * @see java.awt.font.TextAttribute#POSTURE
+ */
+ public float getItalicAngle()
+ {
+ return peer.getItalicAngle(this);
+ }
+
+ /**
+ * Returns a {@link LineMetrics} object constructed with the specified
+ * text and {@link FontRenderContext}.
+ *
+ * @param text The string to calculate metrics from.
+ * @param begin Index of first character in <code>text</code> to measure.
+ * @param limit Index of last character in <code>text</code> to measure.
+ * @param rc Context for calculating precise glyph placement and hints.
+ *
+ * @return A new {@link LineMetrics} object.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>text</code>.
+ */
+ public LineMetrics getLineMetrics(String text, int begin,
+ int limit, FontRenderContext rc)
+ {
+ return peer.getLineMetrics(this, new StringCharacterIterator(text),
+ begin, limit, rc);
+ }
+
+ /**
+ * Returns a {@link LineMetrics} object constructed with the specified
+ * text and {@link FontRenderContext}.
+ *
+ * @param chars The string to calculate metrics from.
+ * @param begin Index of first character in <code>text</code> to measure.
+ * @param limit Index of last character in <code>text</code> to measure.
+ * @param rc Context for calculating precise glyph placement and hints.
+ *
+ * @return A new {@link LineMetrics} object.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>chars</code>.
+ */
+ public LineMetrics getLineMetrics(char[] chars, int begin,
+ int limit, FontRenderContext rc)
+ {
+ return peer.getLineMetrics(this,
+ new StringCharacterIterator(new String(chars)),
+ begin, limit, rc);
+ }
+
+ /**
+ * Returns a {@link LineMetrics} object constructed with the specified
+ * text and {@link FontRenderContext}.
+ *
+ * @param ci The string to calculate metrics from.
+ * @param begin Index of first character in <code>text</code> to measure.
+ * @param limit Index of last character in <code>text</code> to measure.
+ * @param rc Context for calculating precise glyph placement and hints.
+ *
+ * @return A new {@link LineMetrics} object.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>ci</code>.
+ */
+ public LineMetrics getLineMetrics(CharacterIterator ci, int begin,
+ int limit, FontRenderContext rc)
+ {
+ return peer.getLineMetrics(this, ci, begin, limit, rc);
+ }
+
+ /**
+ * Returns the maximal bounding box of all the bounding boxes in this
+ * font, when the font's bounding boxes are evaluated in a given {@link
+ * FontRenderContext}
+ *
+ * @param rc Context in which to evaluate bounding boxes.
+ *
+ * @return The maximal bounding box.
+ */
+ public Rectangle2D getMaxCharBounds(FontRenderContext rc)
+ {
+ return peer.getMaxCharBounds(this, rc);
+ }
+
+ /**
+ * Returns the glyph code this font uses to represent missing glyphs. This
+ * code will be present in glyph vectors when the font was unable to
+ * locate a glyph to represent a particular character code.
+ *
+ * @return The missing glyph code.
+ *
+ * @since 1.2
+ */
+ public int getMissingGlyphCode()
+ {
+ return peer.getMissingGlyphCode(this);
+ }
+
+ /**
+ * Returns the overall number of glyphs in this font. This number is one
+ * more than the greatest glyph code used in any glyph vectors this font
+ * produces. In other words, glyph codes are taken from the range
+ * <code>[ 0, getNumGlyphs() - 1 ]</code>.
+ *
+ * @return The number of glyphs in this font.
+ *
+ * @since 1.2
+ */
+ public int getNumGlyphs()
+ {
+ return peer.getNumGlyphs(this);
+ }
+
+ /**
+ * Returns the PostScript Name of this font.
+ *
+ * @return The PostScript Name of this font.
+ *
+ * @since 1.2
+ *
+ * @see #getName()
+ * @see #getFamily()
+ * @see #getFontName()
+ */
+ public String getPSName()
+ {
+ return peer.getPostScriptName(this);
+ }
+
+ /**
+ * Returns the logical bounds of the specified string when rendered with this
+ * font in the specified {@link FontRenderContext}. This box will include the
+ * glyph origin, ascent, advance, height, and leading, but may not include all
+ * diacritics or accents. To get the complete visual bounding box of all the
+ * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
+ * {@link TextLayout}.
+ *
+ * @param str The string to measure.
+ * @param frc The context in which to make the precise glyph measurements.
+ *
+ * @return A bounding box covering the logical bounds of the specified text.
+ *
+ * @see #createGlyphVector(FontRenderContext, String)
+ */
+ public Rectangle2D getStringBounds(String str, FontRenderContext frc)
+ {
+ return getStringBounds(str, 0, str.length() - 1, frc);
+ }
+
+ /**
+ * Returns the logical bounds of the specified string when rendered with this
+ * font in the specified {@link FontRenderContext}. This box will include the
+ * glyph origin, ascent, advance, height, and leading, but may not include all
+ * diacritics or accents. To get the complete visual bounding box of all the
+ * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
+ * {@link TextLayout}.
+ *
+ * @param str The string to measure.
+ * @param begin Index of the first character in <code>str</code> to measure.
+ * @param limit Index of the last character in <code>str</code> to measure.
+ * @param frc The context in which to make the precise glyph measurements.
+ *
+ * @return A bounding box covering the logical bounds of the specified text.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>str</code>.
+ *
+ * @since 1.2
+ *
+ * @see #createGlyphVector(FontRenderContext, String)
+ */
+ public Rectangle2D getStringBounds(String str, int begin,
+ int limit, FontRenderContext frc)
+ {
+ return peer.getStringBounds(this, new StringCharacterIterator(str), begin,
+ limit, frc);
+ }
+
+ /**
+ * Returns the logical bounds of the specified string when rendered with this
+ * font in the specified {@link FontRenderContext}. This box will include the
+ * glyph origin, ascent, advance, height, and leading, but may not include all
+ * diacritics or accents. To get the complete visual bounding box of all the
+ * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
+ * {@link TextLayout}.
+ *
+ * @param ci The text to measure.
+ * @param begin Index of the first character in <code>ci</code> to measure.
+ * @param limit Index of the last character in <code>ci</code> to measure.
+ * @param frc The context in which to make the precise glyph measurements.
+ *
+ * @return A bounding box covering the logical bounds of the specified text.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>ci</code>.
+ *
+ * @since 1.2
+ *
+ * @see #createGlyphVector(FontRenderContext, CharacterIterator)
+ */
+ public Rectangle2D getStringBounds(CharacterIterator ci, int begin,
+ int limit, FontRenderContext frc)
+ {
+ return peer.getStringBounds(this, ci, begin, limit, frc);
+ }
+
+ /**
+ * Returns the logical bounds of the specified string when rendered with this
+ * font in the specified {@link FontRenderContext}. This box will include the
+ * glyph origin, ascent, advance, height, and leading, but may not include all
+ * diacritics or accents. To get the complete visual bounding box of all the
+ * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
+ * {@link TextLayout}.
+ *
+ * @param chars The text to measure.
+ * @param begin Index of the first character in <code>ci</code> to measure.
+ * @param limit Index of the last character in <code>ci</code> to measure.
+ * @param frc The context in which to make the precise glyph measurements.
+ *
+ * @return A bounding box covering the logical bounds of the specified text.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>chars</code>.
+ *
+ * @since 1.2
+ *
+ * @see #createGlyphVector(FontRenderContext, char[])
+ */
+ public Rectangle2D getStringBounds(char[] chars, int begin,
+ int limit, FontRenderContext frc)
+ {
+ return peer.getStringBounds(this,
+ new StringCharacterIterator(new String(chars)),
+ begin, limit, frc);
+ }
+
+ /**
+ * Returns a copy of the affine transformation this font is currently
+ * subject to, if any.
+ *
+ * @return The current transformation.
+ */
+ public AffineTransform getTransform()
+ {
+ return peer.getTransform(this);
+ }
+
+ /**
+ * Indicates whether this font's line metrics are uniform. A font may be
+ * composed of several "subfonts", each covering a different code range,
+ * and each with their own line metrics. A font with no subfonts, or
+ * subfonts with identical line metrics, is said to have "uniform" line
+ * metrics.
+ *
+ * @return Whether this font has uniform line metrics.
+ *
+ * @see LineMetrics
+ * @see #getLineMetrics(String, FontRenderContext)
+ */
+ public boolean hasUniformLineMetrics()
+ {
+ return peer.hasUniformLineMetrics(this);
+ }
+
+ /**
+ * Indicates whether this font is subject to a non-identity affine
+ * transformation.
+ *
+ * @return <code>true</code> iff the font has a non-identity affine
+ * transformation applied to it.
+ */
+ public boolean isTransformed()
+ {
+ return peer.isTransformed(this);
+ }
+
+ /**
+ * Produces a glyph vector representing a full layout fo the specified
+ * text in this font. Full layouts may include complex shaping and
+ * reordering operations, for scripts such as Arabic or Hindi.
+ *
+ * Bidirectional (bidi) layout is not performed in this method; text
+ * should have its bidi direction specified with one of the flags {@link
+ * #LAYOUT_LEFT_TO_RIGHT} or {@link #LAYOUT_RIGHT_TO_LEFT}.
+ *
+ * Some types of layout (notably Arabic glyph shaping) may examine context
+ * characters beyond the bounds of the indicated range, in order to select
+ * an appropriate shape. The flags {@link #LAYOUT_NO_START_CONTEXT} and
+ * {@link #LAYOUT_NO_LIMIT_CONTEXT} can be provided to prevent these extra
+ * context areas from being examined, for instance if they contain invalid
+ * characters.
+ *
+ * @param frc Context in which to perform the layout.
+ * @param chars Text to perform layout on.
+ * @param start Index of first character to perform layout on.
+ * @param limit Index of last character to perform layout on.
+ * @param flags Combination of flags controlling layout.
+ *
+ * @return A new {@link GlyphVector} representing the specified text.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>chars</code>.
+ */
+ public GlyphVector layoutGlyphVector(FontRenderContext frc,
+ char[] chars, int start,
+ int limit, int flags)
+ {
+ return peer.layoutGlyphVector(this, frc, chars, start, limit, flags);
+ }
+
+
+ /**
+ * Returns a native peer object for this font.
+ *
+ * @return A native peer object for this font.
+ *
+ * @deprecated
+ */
+ public FontPeer getPeer()
+ {
+ return peer;
+ }
+
+
+ /**
+ * Returns a hash value for this font.
+ *
+ * @return A hash for this font.
+ */
+ public int hashCode()
+ {
+ return this.toString().hashCode();
+ }
+
+
+ /**
+ * Tests whether or not the specified object is equal to this font. This
+ * will be true if and only if:
+ * <P>
+ * <ul>
+ * <li>The object is not <code>null</code>.
+ * <li>The object is an instance of <code>Font</code>.
+ * <li>The object has the same names, style, size, and transform as this object.
+ * </ul>
+ *
+ * @return <code>true</code> if the specified object is equal to this
+ * object, <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj == null)
+ return false;
+
+ if (! (obj instanceof Font))
+ return false;
+
+ Font f = (Font) obj;
+
+ return (f.getName().equals(this.getName())
+ && f.getFamily().equals(this.getFamily())
+ && f.getFontName().equals(this.getFontName())
+ && f.getTransform().equals(this.getTransform ())
+ && f.getSize() == this.getSize()
+ && f.getStyle() == this.getStyle());
+ }
+
+ /**
+ * Returns a string representation of this font.
+ *
+ * @return A string representation of this font.
+ */
+ public String toString()
+ {
+ String styleString = "";
+
+ switch (getStyle())
+ {
+ case 0:
+ styleString = "plain";
+ break;
+ case 1:
+ styleString = "bold";
+ break;
+ case 2:
+ styleString = "italic";
+ break;
+ default:
+ styleString = "unknown";
+ }
+
+ return getClass().getName()
+ + "[family=" + getFamily ()
+ + ",name=" + getFontName ()
+ + ",style=" + styleString
+ + ",size=" + getSize () + "]";
+ }
+
+
+ /**
+ * Determines the line metrics for a run of text.
+ *
+ * @param str the text run to be measured.
+ *
+ * @param frc the font rendering parameters that are used for the
+ * measurement. The exact placement and size of text slightly
+ * depends on device-specific characteristics, for instance
+ * the device resolution or anti-aliasing. For this reason,
+ * the returned measurement will only be accurate if the
+ * passed <code>FontRenderContext</code> correctly reflects
+ * the relevant parameters. Hence, <code>frc</code> should be
+ * obtained from the same <code>Graphics2D</code> that will
+ * be used for drawing, and any rendering hints should be set
+ * to the desired values before obtaining <code>frc</code>.
+ *
+ * @see java.awt.Graphics2D#getFontRenderContext()
+ */
+ public LineMetrics getLineMetrics(String str, FontRenderContext frc)
+ {
+ return getLineMetrics(str, 0, str.length() - 1, frc);
+ }
+
+ /**
+ * Reads the normal fields from the stream and then constructs the
+ * peer from the style and size through getPeerFromToolkit().
+ */
+ private void readObject(ObjectInputStream ois)
+ throws IOException, ClassNotFoundException
+ {
+ ois.defaultReadObject();
+
+ HashMap attrs = new HashMap();
+ ClasspathFontPeer.copyStyleToAttrs(style, attrs);
+ ClasspathFontPeer.copySizeToAttrs(size, attrs);
+ peer = getPeerFromToolkit(name, attrs);
+
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FontFormatException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FontFormatException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FontFormatException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FontFormatException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,65 @@
+/* FontFormatException.java -- the specified font is bad
+ Copyright (C) 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+/**
+ * Thrown when a specified font is bad.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Font
+ * @since 1.3
+ * @status updated to 1.4
+ */
+public class FontFormatException extends Exception
+{
+ /**
+ * Compatible with JDK 1.4+.
+ */
+ private static final long serialVersionUID = -4481290147811361272L;
+
+ /**
+ * Create a new instance with the specified detailed error message.
+ *
+ * @param message the detailed error message
+ */
+ public FontFormatException(String message)
+ {
+ super(message);
+ }
+} // class FontFormatException
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FontMetrics.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FontMetrics.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FontMetrics.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/FontMetrics.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,448 @@
+/* FontMetrics.java -- Information about about a fonts display characteristics
+ Copyright (C) 1999, 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.font.FontRenderContext;
+import java.awt.font.LineMetrics;
+import java.awt.geom.Rectangle2D;
+import java.text.CharacterIterator;
+
+// FIXME: I leave many methods basically unimplemented. This
+// should be reviewed.
+
+/**
+ * This class returns information about the display characteristics of
+ * a font. It is abstract, and concrete subclasses should implement at
+ * least the following methods:
+ *
+ * <ul>
+ * <li>getAscent()</li>
+ * <li>getDescent()</li>
+ * <li>getLeading()</li>
+ * <li>getMaxAdvance()</li>
+ * <li>charWidth(char)</li>
+ * <li>charsWidth(char[], int, int)</li>
+ * </ul>
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public abstract class FontMetrics implements java.io.Serializable
+{
+ // Serialization constant.
+ private static final long serialVersionUID = 1681126225205050147L;
+
+ /**
+ * This is the font for which metrics will be returned.
+ */
+ protected Font font;
+
+ /**
+ * Initializes a new instance of <code>FontMetrics</code> for the
+ * specified font.
+ *
+ * @param font The font to return metric information for.
+ */
+ protected FontMetrics(Font font)
+ {
+ this.font = font;
+ }
+
+ /**
+ * Returns the font that this object is creating metric information fo.
+ *
+ * @return The font for this object.
+ */
+ public Font getFont()
+ {
+ return font;
+ }
+
+ /**
+ * Returns the leading, or spacing between lines, for this font.
+ *
+ * @return The font leading.
+ */
+ public int getLeading()
+ {
+ return 0;
+ }
+
+ /**
+ * Returns the ascent of the font, which is the distance from the base
+ * to the top of the majority of characters in the set. Some characters
+ * can exceed this value however.
+ *
+ * @return The font ascent.
+ */
+ public int getAscent()
+ {
+ return 1;
+ }
+
+ /**
+ * Returns the descent of the font, which is the distance from the base
+ * to the bottom of the majority of characters in the set. Some characters
+ * can exceed this value however.
+ *
+ * @return The font descent.
+ */
+ public int getDescent()
+ {
+ return 1;
+ }
+
+ /**
+ * Returns the height of a line in this font. This will be the sum
+ * of the leading, the ascent, and the descent.
+ *
+ * @return The height of the font.
+ */
+ public int getHeight()
+ {
+ return getAscent() + getDescent() + getLeading();
+ }
+
+ /**
+ * Returns the maximum ascent value. This is the maximum distance any
+ * character in the font rised above the baseline.
+ *
+ * @return The maximum ascent for this font.
+ */
+ public int getMaxAscent()
+ {
+ return getAscent();
+ }
+
+ /**
+ * Returns the maximum descent value. This is the maximum distance any
+ * character in the font extends below the baseline.
+ *
+ * @return The maximum descent for this font.
+ */
+ public int getMaxDescent()
+ {
+ return getMaxDecent();
+ }
+
+ /**
+ * Returns the maximum descent value. This is the maximum distance any
+ * character in the font extends below the baseline.
+ *
+ * @return The maximum descent for this font.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getMaxDescent()</code>.
+ */
+ public int getMaxDecent()
+ {
+ return getDescent();
+ }
+
+ /**
+ * Returns the width of the widest character in the font.
+ *
+ * @return The width of the widest character in the font.
+ */
+ public int getMaxAdvance()
+ {
+ return -1;
+ }
+
+ /**
+ * Returns the width of the specified character.
+ *
+ * @param ch The character to return the width of.
+ *
+ * @return The width of the specified character.
+ */
+ public int charWidth(int ch)
+ {
+ char[] chars = Character.toChars(ch);
+ return charsWidth(chars, 0, chars.length);
+ }
+
+ /**
+ * Returns the width of the specified character.
+ *
+ * @param ch The character to return the width of.
+ *
+ * @return The width of the specified character.
+ */
+ public int charWidth(char ch)
+ {
+ return 1;
+ }
+
+ /**
+ * Returns the total width of the specified string
+ *
+ * @param str The string to return the width of.
+ *
+ * @return The width of the string.
+ */
+ public int stringWidth(String str)
+ {
+ char[] buf = new char[str.length()];
+ str.getChars(0, str.length(), buf, 0);
+
+ return charsWidth(buf, 0, buf.length);
+ }
+
+ /**
+ * Returns the total width of the specified character array.
+ *
+ * @param buf The character array containing the data.
+ * @param offset The offset into the array to start calculating from.
+ * @param len The total number of bytes to process.
+ *
+ * @return The width of the requested characters.
+ */
+ public int charsWidth(char[] buf, int offset, int len)
+ {
+ int total_width = 0;
+ int endOffset = offset + len;
+ for (int i = offset; i < endOffset; i++)
+ total_width += charWidth(buf[i]);
+ return total_width;
+ }
+
+ /**
+ * Returns the total width of the specified byte array.
+ *
+ * @param buf The byte array containing the data.
+ * @param offset The offset into the array to start calculating from.
+ * @param len The total number of bytes to process.
+ *
+ * @return The width of the requested characters.
+ */
+ public int bytesWidth(byte[] buf, int offset, int len)
+ {
+ int total_width = 0;
+ for (int i = offset; i < len; i++)
+ total_width = charWidth((char) buf[i]);
+
+ return total_width;
+ }
+
+ /**
+ * Returns the widths of the first 256 characters in the font.
+ *
+ * @return The widths of the first 256 characters in the font.
+ */
+ public int[] getWidths()
+ {
+ int[] result = new int[256];
+ for (char i = 0; i < 256; i++)
+ result[i] = charWidth(i);
+ return result;
+ }
+
+ /**
+ * Returns a string representation of this object.
+ *
+ * @return A string representation of this object.
+ */
+ public String toString()
+ {
+ return (this.getClass() + "[font=" + font + ",ascent=" + getAscent()
+ + ",descent=" + getDescent() + ",height=" + getHeight() + "]");
+ }
+
+ // Generic FontRenderContext used when getLineMetrics is called with a
+ // plain Graphics object.
+ private static final FontRenderContext gRC = new FontRenderContext(null,
+ false,
+ false);
+
+ /**
+ * Returns a {@link LineMetrics} object constructed with the
+ * specified text and the {@link FontRenderContext} of the Graphics
+ * object when it is an instance of Graphics2D or a generic
+ * FontRenderContext with a null transform, not anti-aliased and not
+ * using fractional metrics.
+ *
+ * @param text The string to calculate metrics from.
+ * @param g The Graphics object that will be used.
+ *
+ * @return A new {@link LineMetrics} object.
+ */
+ public LineMetrics getLineMetrics(String text, Graphics g)
+ {
+ return getLineMetrics(text, 0, text.length(), g);
+ }
+
+ /**
+ * Returns a {@link LineMetrics} object constructed with the
+ * specified text and the {@link FontRenderContext} of the Graphics
+ * object when it is an instance of Graphics2D or a generic
+ * FontRenderContext with a null transform, not anti-aliased and not
+ * using fractional metrics.
+ *
+ * @param text The string to calculate metrics from.
+ * @param begin Index of first character in <code>text</code> to measure.
+ * @param limit Index of last character in <code>text</code> to measure.
+ * @param g The Graphics object that will be used.
+ *
+ * @return A new {@link LineMetrics} object.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>text</code>.
+ */
+ public LineMetrics getLineMetrics(String text, int begin, int limit,
+ Graphics g)
+ {
+ FontRenderContext rc;
+ if (g instanceof Graphics2D)
+ rc = ((Graphics2D) g).getFontRenderContext();
+ else
+ rc = gRC;
+ return font.getLineMetrics(text, begin, limit, rc);
+ }
+
+ /**
+ * Returns a {@link LineMetrics} object constructed with the
+ * specified text and the {@link FontRenderContext} of the Graphics
+ * object when it is an instance of Graphics2D or a generic
+ * FontRenderContext with a null transform, not anti-aliased and not
+ * using fractional metrics.
+ *
+ * @param chars The string to calculate metrics from.
+ * @param begin Index of first character in <code>text</code> to measure.
+ * @param limit Index of last character in <code>text</code> to measure.
+ * @param g The Graphics object that will be used.
+ *
+ * @return A new {@link LineMetrics} object.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>text</code>.
+ */
+ public LineMetrics getLineMetrics(char[] chars, int begin, int limit,
+ Graphics g)
+ {
+ FontRenderContext rc;
+ if (g instanceof Graphics2D)
+ rc = ((Graphics2D) g).getFontRenderContext();
+ else
+ rc = gRC;
+ return font.getLineMetrics(chars, begin, limit, rc);
+ }
+
+ /**
+ * Returns the bounds of the largest character in a Graphics context.
+ * @param context the Graphics context object.
+ * @return a <code>Rectangle2D</code> representing the bounds
+ */
+ public Rectangle2D getMaxCharBounds(Graphics context)
+ {
+ if( context instanceof Graphics2D )
+ return font.getMaxCharBounds(((Graphics2D)context).getFontRenderContext());
+ return font.getMaxCharBounds( gRC );
+ }
+
+ /**
+ * Returns a {@link LineMetrics} object constructed with the
+ * specified text and the {@link FontRenderContext} of the Graphics
+ * object when it is an instance of Graphics2D or a generic
+ * FontRenderContext with a null transform, not anti-aliased and not
+ * using fractional metrics.
+ *
+ * @param ci An iterator over the string to calculate metrics from.
+ * @param begin Index of first character in <code>text</code> to measure.
+ * @param limit Index of last character in <code>text</code> to measure.
+ * @param g The Graphics object that will be used.
+ *
+ * @return A new {@link LineMetrics} object.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>text</code>.
+ */
+ public LineMetrics getLineMetrics(CharacterIterator ci, int begin,
+ int limit, Graphics g)
+ {
+ FontRenderContext rc;
+ if (g instanceof Graphics2D)
+ rc = ((Graphics2D) g).getFontRenderContext();
+ else
+ rc = gRC;
+ return font.getLineMetrics(ci, begin, limit, rc);
+ }
+
+ public Rectangle2D getStringBounds(String str, Graphics context)
+ {
+ return font.getStringBounds(str, getFontRenderContext(context));
+ }
+
+ public Rectangle2D getStringBounds(String str, int beginIndex, int limit,
+ Graphics context)
+ {
+ return font.getStringBounds(str, beginIndex, limit,
+ getFontRenderContext(context));
+ }
+
+ public Rectangle2D getStringBounds(char[] chars, int beginIndex, int limit,
+ Graphics context)
+ {
+ return font.getStringBounds(chars, beginIndex, limit,
+ getFontRenderContext(context));
+ }
+
+ public Rectangle2D getStringBounds(CharacterIterator ci, int beginIndex,
+ int limit, Graphics context)
+ {
+ return font.getStringBounds(ci, beginIndex, limit,
+ getFontRenderContext(context));
+ }
+
+ private FontRenderContext getFontRenderContext(Graphics context)
+ {
+ if (context instanceof Graphics2D)
+ return ((Graphics2D) context).getFontRenderContext();
+
+ return gRC;
+ }
+
+ /**
+ * Returns if the font has uniform line metrics.
+ * @see Font#hasUniformLineMetrics()
+ */
+ public boolean hasUniformLineMetrics()
+ {
+ return font.hasUniformLineMetrics();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Frame.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Frame.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Frame.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Frame.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,661 @@
+/* Frame.java -- AWT toplevel window
+ Copyright (C) 1999, 2000, 2002, 2004, 2005, 2006
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.peer.FramePeer;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
+
+/**
+ * This class is a top-level window with a title bar and window
+ * decorations.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class Frame extends Window implements MenuContainer
+{
+
+ /**
+ * Constant for the default cursor.
+ *
+ * @deprecated Replaced by <code>Cursor.DEFAULT_CURSOR</code> instead.
+ */
+ public static final int DEFAULT_CURSOR = Cursor.DEFAULT_CURSOR;
+
+ /**
+ * Constant for a cross-hair cursor.
+ *
+ * @deprecated Use <code>Cursor.CROSSHAIR_CURSOR</code> instead.
+ */
+ public static final int CROSSHAIR_CURSOR = Cursor.CROSSHAIR_CURSOR;
+
+ /**
+ * Constant for a cursor over a text field.
+ *
+ * @deprecated Use <code>Cursor.TEXT_CURSOR</code> instead.
+ */
+ public static final int TEXT_CURSOR = Cursor.TEXT_CURSOR;
+
+ /**
+ * Constant for a cursor to display while waiting for an action to complete.
+ *
+ * @deprecated Use <code>Cursor.WAIT_CURSOR</code>.
+ */
+ public static final int WAIT_CURSOR = Cursor.WAIT_CURSOR;
+
+ /**
+ * Cursor used over SW corner of window decorations.
+ *
+ * @deprecated Use <code>Cursor.SW_RESIZE_CURSOR</code> instead.
+ */
+ public static final int SW_RESIZE_CURSOR = Cursor.SW_RESIZE_CURSOR;
+
+ /**
+ * Cursor used over SE corner of window decorations.
+ * @deprecated Use <code>Cursor.SE_RESIZE_CURSOR</code> instead.
+ */
+ public static final int SE_RESIZE_CURSOR = Cursor.SE_RESIZE_CURSOR;
+
+ /**
+ * Cursor used over NW corner of window decorations.
+ *
+ * @deprecated Use <code>Cursor.NW_RESIZE_CURSOR</code> instead.
+ */
+ public static final int NW_RESIZE_CURSOR = Cursor.NW_RESIZE_CURSOR;
+
+ /**
+ * Cursor used over NE corner of window decorations.
+ *
+ * @deprecated Use <code>Cursor.NE_RESIZE_CURSOR</code> instead.
+ */
+ public static final int NE_RESIZE_CURSOR = Cursor.NE_RESIZE_CURSOR;
+
+ /**
+ * Cursor used over N edge of window decorations.
+ *
+ * @deprecated Use <code>Cursor.N_RESIZE_CURSOR</code> instead.
+ */
+ public static final int N_RESIZE_CURSOR = Cursor.N_RESIZE_CURSOR;
+
+ /**
+ * Cursor used over S edge of window decorations.
+ *
+ * @deprecated Use <code>Cursor.S_RESIZE_CURSOR</code> instead.
+ */
+ public static final int S_RESIZE_CURSOR = Cursor.S_RESIZE_CURSOR;
+
+ /**
+ * Cursor used over E edge of window decorations.
+ *
+ * @deprecated Use <code>Cursor.E_RESIZE_CURSOR</code> instead.
+ */
+ public static final int E_RESIZE_CURSOR = Cursor.E_RESIZE_CURSOR;
+
+ /**
+ * Cursor used over W edge of window decorations.
+ *
+ * @deprecated Use <code>Cursor.W_RESIZE_CURSOR</code> instead.
+ */
+ public static final int W_RESIZE_CURSOR = Cursor.W_RESIZE_CURSOR;
+
+ /**
+ * Constant for a hand cursor.
+ *
+ * @deprecated Use <code>Cursor.HAND_CURSOR</code> instead.
+ */
+ public static final int HAND_CURSOR = Cursor.HAND_CURSOR;
+
+ /**
+ * Constant for a cursor used during window move operations.
+ *
+ * @deprecated Use <code>Cursor.MOVE_CURSOR</code> instead.
+ */
+ public static final int MOVE_CURSOR = Cursor.MOVE_CURSOR;
+
+ public static final int ICONIFIED = 1;
+ public static final int MAXIMIZED_BOTH = 6;
+ public static final int MAXIMIZED_HORIZ = 2;
+ public static final int MAXIMIZED_VERT = 4;
+ public static final int NORMAL = 0;
+
+//Serialization version constant
+ private static final long serialVersionUID = 2673458971256075116L;
+
+ /**
+ * @serial The version of the class data being serialized
+ * FIXME: what is this value?
+ */
+ private int frameSerializedDataVersion;
+
+ /**
+ * @serial Image used as the icon when this frame is minimized.
+ */
+ private Image icon;
+
+ /**
+ * @serial Constant used by the JDK Motif peer set. Not used in
+ * this implementation.
+ */
+ private boolean mbManagement;
+
+ /**
+ * @serial The menu bar for this frame.
+ */
+ private MenuBar menuBar;
+
+ /**
+ * @serial A list of other top-level windows owned by this window.
+ */
+ Vector ownedWindows = new Vector();
+
+ /**
+ * @serial Indicates whether or not this frame is resizable.
+ */
+ private boolean resizable = true;
+
+ /**
+ * @serial The state of this frame.
+ * // FIXME: What are the values here?
+ * This is package-private to avoid an accessor method.
+ */
+ int state;
+
+ /**
+ * @serial The title of the frame.
+ */
+ private String title = "";
+
+ /**
+ * Maximized bounds for this frame.
+ */
+ private Rectangle maximizedBounds;
+
+ /**
+ * This field indicates whether the frame is undecorated or not.
+ */
+ private boolean undecorated = false;
+
+ /*
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_frame_number;
+
+ /**
+ * Initializes a new instance of <code>Frame</code> that is not visible
+ * and has no title.
+ */
+ public Frame()
+ {
+ this("");
+ noteFrame(this);
+ }
+
+ /**
+ * Initializes a new instance of <code>Frame</code> that is not visible
+ * and has the specified title.
+ *
+ * @param title the title of this frame
+ */
+ public Frame(String title)
+ {
+ super();
+ this.title = title;
+ // Top-level frames are initially invisible.
+ visible = false;
+ noteFrame(this);
+ }
+
+ public Frame(GraphicsConfiguration gc)
+ {
+ super(gc);
+ visible = false;
+ noteFrame(this);
+ }
+
+ public Frame(String title, GraphicsConfiguration gc)
+ {
+ super(gc);
+ setTitle(title);
+ visible = false;
+ noteFrame(this);
+ }
+
+ /**
+ * Returns this frame's title string.
+ *
+ * @return this frame's title string
+ */
+ public String getTitle()
+ {
+ return title;
+ }
+
+ /**
+ * Sets this frame's title to the specified value.
+ *
+ * @param title the new frame title
+ */
+ public synchronized void setTitle(String title)
+ {
+ this.title = title;
+ if (peer != null)
+ ((FramePeer) peer).setTitle(title);
+ }
+
+ /**
+ * Returns this frame's icon.
+ *
+ * @return this frame's icon, or <code>null</code> if this frame does not
+ * have an icon
+ */
+ public Image getIconImage()
+ {
+ return icon;
+ }
+
+ /**
+ * Sets this frame's icon to the specified value.
+ *
+ * @icon the new icon for this frame
+ */
+ public synchronized void setIconImage(Image icon)
+ {
+ this.icon = icon;
+ if (peer != null)
+ ((FramePeer) peer).setIconImage(icon);
+ }
+
+ /**
+ * Returns this frame's menu bar.
+ *
+ * @return this frame's menu bar, or <code>null</code> if this frame
+ * does not have a menu bar
+ */
+ public MenuBar getMenuBar()
+ {
+ return menuBar;
+ }
+
+ /**
+ * Sets this frame's menu bar. Removes any existing menu bar. If the
+ * given menu bar is part of another frame it will be removed from
+ * that frame.
+ *
+ * @param menuBar the new menu bar for this frame
+ */
+ public synchronized void setMenuBar(MenuBar menuBar)
+ {
+ if (this.menuBar != null)
+ remove(this.menuBar);
+
+ this.menuBar = menuBar;
+ if (menuBar != null)
+ {
+ MenuContainer parent = menuBar.getParent();
+ if (parent != null)
+ parent.remove(menuBar);
+ menuBar.setParent(this);
+
+ if (peer != null)
+ {
+ if (menuBar != null)
+ menuBar.addNotify();
+ invalidateTree();
+ ((FramePeer) peer).setMenuBar(menuBar);
+ }
+ }
+ }
+
+ /**
+ * Tests whether or not this frame is resizable. This will be
+ * <code>true</code> by default.
+ *
+ * @return <code>true</code> if this frame is resizable, <code>false</code>
+ * otherwise
+ */
+ public boolean isResizable()
+ {
+ return resizable;
+ }
+
+ /**
+ * Sets the resizability of this frame to the specified value.
+ *
+ * @param resizable <code>true</code> to make the frame resizable,
+ * <code>false</code> to make it non-resizable
+ */
+ public synchronized void setResizable(boolean resizable)
+ {
+ this.resizable = resizable;
+ if (peer != null)
+ ((FramePeer) peer).setResizable(resizable);
+ }
+
+ /**
+ * Returns the cursor type of the cursor for this window. This will
+ * be one of the constants in this class.
+ *
+ * @return the cursor type for this frame
+ *
+ * @deprecated Use <code>Component.getCursor()</code> instead.
+ */
+ public int getCursorType()
+ {
+ return getCursor().getType();
+ }
+
+ /**
+ * Sets the cursor for this window to the specified type. The specified
+ * type should be one of the constants in this class.
+ *
+ * @param type the cursor type
+ *
+ * @deprecated Use <code>Component.setCursor(Cursor)</code> instead.
+ */
+ public void setCursor(int type)
+ {
+ setCursor(new Cursor(type));
+ }
+
+ /**
+ * Removes the specified menu component from this frame. If it is
+ * the current MenuBar it is removed from the frame. If it is a
+ * Popup it is removed from this component. If it is any other menu
+ * component it is ignored.
+ *
+ * @param menu the menu component to remove
+ */
+ public void remove(MenuComponent menu)
+ {
+ if (menu == menuBar)
+ {
+ if (menuBar != null)
+ {
+ if (peer != null)
+ {
+ ((FramePeer) peer).setMenuBar(null);
+ menuBar.removeNotify();
+ }
+ menuBar.setParent(null);
+ }
+ menuBar = null;
+ }
+ else
+ super.remove(menu);
+ }
+
+ public void addNotify()
+ {
+ if (menuBar != null)
+ menuBar.addNotify();
+ if (peer == null)
+ peer = getToolkit ().createFrame (this);
+
+ super.addNotify();
+ }
+
+ public void removeNotify()
+ {
+ if (menuBar != null)
+ menuBar.removeNotify();
+ super.removeNotify();
+ }
+
+ /**
+ * Returns a debugging string describing this window.
+ *
+ * @return a debugging string describing this window
+ */
+ protected String paramString()
+ {
+ String title = getTitle();
+
+ String resizable = "";
+ if (isResizable ())
+ resizable = ",resizable";
+
+ String state = "";
+ switch (getState ())
+ {
+ case NORMAL:
+ state = ",normal";
+ break;
+ case ICONIFIED:
+ state = ",iconified";
+ break;
+ case MAXIMIZED_BOTH:
+ state = ",maximized-both";
+ break;
+ case MAXIMIZED_HORIZ:
+ state = ",maximized-horiz";
+ break;
+ case MAXIMIZED_VERT:
+ state = ",maximized-vert";
+ break;
+ }
+
+ return super.paramString () + ",title=" + title + resizable + state;
+ }
+
+ private static ArrayList weakFrames = new ArrayList();
+
+ private static void noteFrame(Frame f)
+ {
+ weakFrames.add(new WeakReference(f));
+ }
+
+ public static Frame[] getFrames()
+ {
+ int n = 0;
+ synchronized (weakFrames)
+ {
+ Iterator i = weakFrames.iterator();
+ while (i.hasNext())
+ {
+ WeakReference wr = (WeakReference) i.next();
+ if (wr.get() != null)
+ ++n;
+ }
+ if (n == 0)
+ return new Frame[0];
+ else
+ {
+ Frame[] frames = new Frame[n];
+ n = 0;
+ i = weakFrames.iterator();
+ while (i.hasNext())
+ {
+ WeakReference wr = (WeakReference) i.next();
+ if (wr.get() != null)
+ frames[n++] = (Frame) wr.get();
+ }
+ return frames;
+ }
+ }
+ }
+
+ public void setState(int state)
+ {
+ int current_state = getExtendedState ();
+
+ if (state == NORMAL
+ && (current_state & ICONIFIED) != 0)
+ setExtendedState(current_state | ICONIFIED);
+
+ if (state == ICONIFIED
+ && (current_state & ~ICONIFIED) == 0)
+ setExtendedState(current_state & ~ICONIFIED);
+ }
+
+ public int getState()
+ {
+ // FIXME: State might have changed in the peer... Must check.
+ return (state & ICONIFIED) != 0 ? ICONIFIED : NORMAL;
+ }
+
+ /**
+ * @since 1.4
+ */
+ public void setExtendedState(int state)
+ {
+ this.state = state;
+ }
+
+ /**
+ * @since 1.4
+ */
+ public int getExtendedState()
+ {
+ return state;
+ }
+
+ /**
+ * @since 1.4
+ */
+ public void setMaximizedBounds(Rectangle maximizedBounds)
+ {
+ this.maximizedBounds = maximizedBounds;
+ }
+
+ /**
+ * Returns the maximized bounds of this frame.
+ *
+ * @return the maximized rectangle, may be null
+ *
+ * @since 1.4
+ */
+ public Rectangle getMaximizedBounds()
+ {
+ return maximizedBounds;
+ }
+
+ /**
+ * Returns whether this frame is undecorated or not.
+ *
+ * @since 1.4
+ */
+ public boolean isUndecorated()
+ {
+ return undecorated;
+ }
+
+ /**
+ * Disables or enables decorations for this frame. This method can only be
+ * called while the frame is not displayable.
+ *
+ * @throws IllegalComponentStateException if this frame is displayable
+ *
+ * @since 1.4
+ */
+ public void setUndecorated(boolean undecorated)
+ {
+ if (isDisplayable())
+ throw new IllegalComponentStateException();
+
+ this.undecorated = undecorated;
+ }
+
+ /**
+ * Generate a unique name for this frame.
+ *
+ * @return a unique name for this frame
+ */
+ String generateName()
+ {
+ return "frame" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_frame_number++;
+ }
+
+ /**
+ * Accessibility support for <code>Frame</code>.
+ */
+ protected class AccessibleAWTFrame extends AccessibleAWTWindow
+ {
+ private static final long serialVersionUID = -6172960752956030250L;
+
+ /**
+ * Gets the role of this object.
+ * @return AccessibleRole.FRAME
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.FRAME;
+ }
+
+ /**
+ * Gets the state set of this object.
+ * @return The current state of this frame.
+ */
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ AccessibleStateSet states = super.getAccessibleStateSet();
+ if (isResizable())
+ states.add(AccessibleState.RESIZABLE);
+ if ((state & ICONIFIED) != 0)
+ states.add(AccessibleState.ICONIFIED);
+ return states;
+ }
+ }
+
+ /**
+ * Gets the AccessibleContext associated with this <code>Frame</code>.
+ * The context is created, if necessary.
+ *
+ * @return the associated context
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ // Create the context if this is the first request.
+ if (accessibleContext == null)
+ accessibleContext = new AccessibleAWTFrame();
+ return accessibleContext;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GradientPaint.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GradientPaint.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GradientPaint.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GradientPaint.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,229 @@
+/* GradientPaint.java --
+ Copyright (C) 2002, 2005, 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.ColorModel;
+import gnu.java.awt.GradientPaintContext;
+
+/**
+ * A paint object that can be used to color a region by blending two colors.
+ * Instances of this class are immutable.
+ */
+public class GradientPaint implements Paint
+{
+ private final float x1;
+ private final float y1;
+ private final Color c1;
+ private final float x2;
+ private final float y2;
+ private final Color c2;
+ private final boolean cyclic;
+
+ /**
+ * Creates a new acyclic <code>GradientPaint</code>.
+ *
+ * @param x1 the x-coordinate of the anchor point for color 1.
+ * @param y1 the y-coordinate of the anchor point for color 1.
+ * @param c1 color 1 (<code>null</code> not permitted).
+ * @param x2 the x-coordinate of the anchor point for color 2.
+ * @param y2 the y-coordinate of the anchor point for color 2.
+ * @param c2 the second color (<code>null</code> not permitted).
+ */
+ public GradientPaint(float x1, float y1, Color c1,
+ float x2, float y2, Color c2)
+ {
+ this(x1, y1, c1, x2, y2, c2, false);
+ }
+
+ /**
+ * Creates a new acyclic <code>GradientPaint</code>.
+ *
+ * @param p1 anchor point 1 (<code>null</code> not permitted).
+ * @param c1 color 1 (<code>null</code> not permitted).
+ * @param p2 anchor point 2 (<code>null</code> not permitted).
+ * @param c2 color 2 (<code>null</code> not permitted).
+ */
+ public GradientPaint(Point2D p1, Color c1, Point2D p2, Color c2)
+ {
+ this((float) p1.getX(), (float) p1.getY(), c1,
+ (float) p2.getX(), (float) p2.getY(), c2, false);
+ }
+
+ /**
+ * Creates a new cyclic or acyclic <code>GradientPaint</code>.
+ *
+ * @param x1 the x-coordinate of the anchor point for color 1.
+ * @param y1 the y-coordinate of the anchor point for color 1.
+ * @param c1 color 1 (<code>null</code> not permitted).
+ * @param x2 the x-coordinate of the anchor point for color 2.
+ * @param y2 the y-coordinate of the anchor point for color 2.
+ * @param c2 the second color (<code>null</code> not permitted).
+ * @param cyclic a flag that controls whether the gradient is cyclic or
+ * acyclic.
+ */
+ public GradientPaint(float x1, float y1, Color c1,
+ float x2, float y2, Color c2, boolean cyclic)
+ {
+ if (c1 == null || c2 == null)
+ throw new NullPointerException();
+ this.x1 = x1;
+ this.y1 = y1;
+ this.c1 = c1;
+ this.x2 = x2;
+ this.y2 = y2;
+ this.c2 = c2;
+ this.cyclic = cyclic;
+ }
+
+ /**
+ * Creates a new cyclic or acyclic <code>GradientPaint</code>.
+ *
+ * @param p1 anchor point 1 (<code>null</code> not permitted).
+ * @param c1 color 1 (<code>null</code> not permitted).
+ * @param p2 anchor point 2 (<code>null</code> not permitted).
+ * @param c2 color 2 (<code>null</code> not permitted).
+ * @param cyclic a flag that controls whether the gradient is cyclic or
+ * acyclic.
+ */
+ public GradientPaint(Point2D p1, Color c1, Point2D p2, Color c2,
+ boolean cyclic)
+ {
+ this((float) p1.getX(), (float) p1.getY(), c1,
+ (float) p2.getX(), (float) p2.getY(), c2, cyclic);
+ }
+
+ /**
+ * Returns a point with the same coordinates as the anchor point for color 1.
+ * Note that if you modify this point, the <code>GradientPaint</code> remains
+ * unchanged.
+ *
+ * @return A point with the same coordinates as the anchor point for color 1.
+ */
+ public Point2D getPoint1()
+ {
+ return new Point2D.Float(x1, y1);
+ }
+
+ /**
+ * Returns the first color.
+ *
+ * @return The color (never <code>null</code>).
+ */
+ public Color getColor1()
+ {
+ return c1;
+ }
+
+ /**
+ * Returns a point with the same coordinates as the anchor point for color 2.
+ * Note that if you modify this point, the <code>GradientPaint</code> remains
+ * unchanged.
+ *
+ * @return A point with the same coordinates as the anchor point for color 2.
+ */
+ public Point2D getPoint2()
+ {
+ return new Point2D.Float(x2, y2);
+ }
+
+ /**
+ * Returns the second color.
+ *
+ * @return The color (never <code>null</code>).
+ */
+ public Color getColor2()
+ {
+ return c2;
+ }
+
+ /**
+ * Returns <code>true</code> if this <code>GradientPaint</code> instance is
+ * cyclic, and <code>false</code> otherwise.
+ *
+ * @return A boolean.
+ */
+ public boolean isCyclic()
+ {
+ return cyclic;
+ }
+
+ /**
+ * Returns the {@link PaintContext} used to generate the color pattern.
+ *
+ * @param cm the color model, used as a hint (ignored in this
+ * implementation).
+ * @param deviceBounds the device space bounding box of the painted area.
+ * @param userBounds the user space bounding box of the painted area.
+ * @param xform the transformation from user space to device space.
+ * @param hints any hints for choosing between rendering alternatives.
+ *
+ * @return The context for performing the paint
+ */
+ public PaintContext createContext(ColorModel cm, Rectangle deviceBounds,
+ Rectangle2D userBounds,
+ AffineTransform xform,
+ RenderingHints hints)
+ {
+ Point2D xp1 = xform.transform(getPoint1(), null);
+ Point2D xp2 = xform.transform(getPoint2(), null);
+ return new GradientPaintContext((float) xp1.getX(), (float) xp1.getY(), c1,
+ (float) xp2.getX(), (float) xp2.getY(), c2, cyclic);
+ }
+
+ /**
+ * Returns the transparency code for this <code>GradientPaint</code> instance.
+ * This is derived from the two {@link Color} objects used in creating this
+ * object: if both colors are opaque, this method returns
+ * {@link Transparency#OPAQUE}, otherwise it returns
+ * {@link Transparency#TRANSLUCENT}.
+ *
+ * @return {@link Transparency#OPAQUE} or {@link Transparency#TRANSLUCENT}.
+ */
+ public int getTransparency()
+ {
+ if (c1.getAlpha() == 255 && c2.getAlpha() == 255)
+ return Transparency.OPAQUE;
+ else
+ return Transparency.TRANSLUCENT;
+ }
+
+} // class GradientPaint
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Graphics.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Graphics.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Graphics.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Graphics.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,639 @@
+/* Graphics.java -- Abstract Java drawing class
+ Copyright (C) 1999, 2000, 2002, 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.image.ImageObserver;
+import java.text.AttributedCharacterIterator;
+
+/**
+ * This is the abstract superclass of classes for drawing to graphics
+ * devices such as the screen or printers.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Warren Levy (warrenl at cygnus.com)
+ */
+public abstract class Graphics
+{
+
+ /**
+ * Default constructor for subclasses.
+ */
+ protected
+ Graphics()
+ {
+ }
+
+ /**
+ * Returns a copy of this <code>Graphics</code> object.
+ *
+ * @return A copy of this object.
+ */
+ public abstract Graphics create();
+
+ /**
+ * Returns a copy of this <code>Graphics</code> object. The origin point
+ * will be translated to the point (x, y) and the cliping rectangle set
+ * to the intersection of the clipping rectangle in this object and the
+ * rectangle specified by the parameters to this method.
+ *
+ * @param x The new X coordinate of the clipping region rect.
+ * @param y The new Y coordinate of the clipping region rect.
+ * @param width The width of the clipping region intersect rectangle.
+ * @param height The height of the clipping region intersect rectangle.
+ *
+ * @return A copy of this object, modified as specified.
+ */
+ public Graphics create(int x, int y, int width, int height)
+ {
+ Graphics g = create();
+
+ g.translate(x, y);
+ // FIXME: I'm not sure if this will work. Are the old clip rect bounds
+ // translated above?
+ g.clipRect(0, 0, width, height);
+
+ return(g);
+ }
+
+ /**
+ * Translates this context so that its new origin point is the point
+ * (x, y).
+ *
+ * @param x The new X coordinate of the origin.
+ * @param y The new Y coordinate of the origin.
+ */
+ public abstract void translate(int x, int y);
+
+ /**
+ * Returns the current color for this object.
+ *
+ * @return The color for this object.
+ */
+ public abstract Color getColor();
+
+ /**
+ * Sets the current color for this object.
+ *
+ * @param color The new color.
+ */
+ public abstract void setColor(Color color);
+
+ /**
+ * Sets this context into "paint" mode, where the target pixels are
+ * completely overwritten when drawn on.
+ */
+ public abstract void setPaintMode();
+
+ /**
+ * Sets this context info "XOR" mode, where the targe pixles are
+ * XOR-ed when drawn on.
+ *
+ * @param color The color to XOR against.
+ */
+ public abstract void setXORMode(Color color);
+
+ /**
+ * Returns the current font for this graphics context.
+ *
+ * @return The current font.
+ */
+ public abstract Font getFont();
+
+ /**
+ * Sets the font for this graphics context to the specified value.
+ *
+ * @param font The new font.
+ */
+ public abstract void setFont(Font font);
+
+ /**
+ * Returns the font metrics for the current font.
+ *
+ * @return The font metrics for the current font.
+ */
+ public FontMetrics getFontMetrics()
+ {
+ return getFontMetrics(getFont());
+ }
+
+ /**
+ * Returns the font metrics for the specified font.
+ *
+ * @param font The font to return metrics for.
+ *
+ * @return The requested font metrics.
+ */
+ public abstract FontMetrics getFontMetrics(Font font);
+
+ /**
+ * Returns the bounding rectangle of the clipping region for this
+ * graphics context.
+ *
+ * @return The bounding rectangle for the clipping region.
+ */
+ public abstract Rectangle getClipBounds();
+
+ /**
+ * Returns the bounding rectangle of the clipping region for this
+ * graphics context.
+ *
+ * @return The bounding rectangle for the clipping region.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getClipBounds()</code>.
+ */
+ public Rectangle getClipRect()
+ {
+ return getClipBounds();
+ }
+
+ /**
+ * Sets the clipping region to the intersection of the current clipping
+ * region and the rectangle determined by the specified parameters.
+ *
+ * @param x The X coordinate of the upper left corner of the intersect rect.
+ * @param y The Y coordinate of the upper left corner of the intersect rect.
+ * @param width The width of the intersect rect.
+ * @param height The height of the intersect rect.
+ */
+ public abstract void clipRect(int x, int y, int width, int height);
+
+ /**
+ * Sets the clipping region to the rectangle determined by the specified
+ * parameters.
+ *
+ * @param x The X coordinate of the upper left corner of the rect.
+ * @param y The Y coordinate of the upper left corner of the rect.
+ * @param width The width of the rect.
+ * @param height The height of the rect.
+ */
+ public abstract void setClip(int x, int y, int width, int height);
+
+ /**
+ * Returns the current clipping region as a <code>Shape</code> object.
+ *
+ * @return The clipping region as a <code>Shape</code>.
+ */
+ public abstract Shape getClip();
+
+ /**
+ * Sets the clipping region to the specified <code>Shape</code>.
+ *
+ * @param clip The new clipping region.
+ */
+ public abstract void setClip(Shape clip);
+
+ /**
+ * Copies the specified rectangle to the specified offset location.
+ *
+ * @param x The X coordinate of the upper left corner of the copy rect.
+ * @param y The Y coordinate of the upper left corner of the copy rect.
+ * @param width The width of the copy rect.
+ * @param height The height of the copy rect.
+ * @param dx The offset from the X value to start drawing.
+ * @param dy The offset from the Y value to start drawing.
+ */
+ public abstract void copyArea(int x, int y, int width, int height, int dx,
+ int dy);
+
+ /**
+ * Draws a line between the two specified points.
+ *
+ * @param x1 The X coordinate of the first point.
+ * @param y1 The Y coordinate of the first point.
+ * @param x2 The X coordinate of the second point.
+ * @param y2 The Y coordinate of the second point.
+ */
+ public abstract void drawLine(int x1, int y1, int x2, int y2);
+
+ /**
+ * Fills the area bounded by the specified rectangle.
+ *
+ * @param x The X coordinate of the upper left corner of the fill rect.
+ * @param y The Y coordinate of the upper left corner of the fill rect.
+ * @param width The width of the fill rect.
+ * @param height The height of the fill rect.
+ */
+ public abstract void fillRect(int x, int y, int width, int height);
+
+ /**
+ * Draws the outline of the specified rectangle.
+ *
+ * @param x The X coordinate of the upper left corner of the draw rect.
+ * @param y The Y coordinate of the upper left corner of the draw rect.
+ * @param width The width of the draw rect.
+ * @param height The height of the draw rect.
+ */
+ public void drawRect(int x, int y, int width, int height)
+ {
+ int x1 = x;
+ int y1 = y;
+ int x2 = x + width;
+ int y2 = y + height;
+ drawLine(x1, y1, x2, y1);
+ drawLine(x2, y1, x2, y2);
+ drawLine(x2, y2, x1, y2);
+ drawLine(x1, y2, x1, y1);
+ }
+
+ /**
+ * Clears the specified rectangle.
+ *
+ * @param x The X coordinate of the upper left corner of the clear rect.
+ * @param y The Y coordinate of the upper left corner of the clear rect.
+ * @param width The width of the clear rect.
+ * @param height The height of the clear rect.
+ */
+ public abstract void clearRect(int x, int y, int width, int height);
+
+ /**
+ * Draws the outline of the specified rectangle with rounded cornders.
+ *
+ * @param x The X coordinate of the upper left corner of the draw rect.
+ * @param y The Y coordinate of the upper left corner of the draw rect.
+ * @param width The width of the draw rect.
+ * @param height The height of the draw rect.
+ * @param arcWidth The width of the corner arcs.
+ * @param arcHeight The height of the corner arcs.
+ */
+ public abstract void drawRoundRect(int x, int y, int width, int height,
+ int arcWidth, int arcHeight);
+
+ /**
+ * Fills the specified rectangle with rounded cornders.
+ *
+ * @param x The X coordinate of the upper left corner of the fill rect.
+ * @param y The Y coordinate of the upper left corner of the fill rect.
+ * @param width The width of the fill rect.
+ * @param height The height of the fill rect.
+ * @param arcWidth The width of the corner arcs.
+ * @param arcHeight The height of the corner arcs.
+ */
+ public abstract void fillRoundRect(int x, int y, int width, int height,
+ int arcWidth, int arcHeight);
+
+ public void draw3DRect(int x, int y, int width, int height, boolean raised)
+ {
+ Color color = getColor();
+ Color tl = color.brighter();
+ Color br = color.darker();
+
+ if (!raised)
+ {
+ Color tmp = tl;
+ tl = br;
+ br = tmp;
+ }
+
+ int x1 = x;
+ int y1 = y;
+ int x2 = x + width;
+ int y2 = y + height;
+
+ setColor(tl);
+ drawLine(x1, y1, x2, y1);
+ drawLine(x1, y2, x1, y1);
+ setColor(br);
+ drawLine(x2, y1, x2, y2);
+ drawLine(x2, y2, x1, y2);
+ setColor(color);
+ }
+
+ /**
+ * Fills the specified rectangle with a 3D effect
+ *
+ * @param x The X coordinate of the upper left corner of the fill rect.
+ * @param y The Y coordinate of the upper left corner of the fill rect.
+ * @param width The width of the fill rect.
+ * @param height The height of the fill rect.
+ * @param raised <code>true</code> if the rectangle appears raised,
+ * <code>false</code> if it should appear etched.
+ */
+ public void fill3DRect(int x, int y, int width, int height, boolean raised)
+ {
+ fillRect(x, y, width, height);
+ draw3DRect(x, y, width-1, height-1, raised);
+ }
+
+ /**
+ * Draws an oval that just fits within the specified rectangle.
+ *
+ * @param x The X coordinate of the upper left corner of the rect.
+ * @param y The Y coordinate of the upper left corner of the rect.
+ * @param width The width of the rect.
+ * @param height The height of the rect.
+ */
+ public abstract void drawOval(int x, int y, int width, int height);
+
+ /**
+ * Fills an oval that just fits within the specified rectangle.
+ *
+ * @param x The X coordinate of the upper left corner of the rect.
+ * @param y The Y coordinate of the upper left corner of the rect.
+ * @param width The width of the rect.
+ * @param height The height of the rect.
+ */
+ public abstract void fillOval(int x, int y, int width, int height);
+
+ /**
+ * Draws an arc using the specified bounding rectangle and the specified
+ * angle parameter. The arc is centered at the center of the rectangle.
+ * The arc starts at the arcAngle position and extend for arcAngle
+ * degrees. The degree origin is at the 3 o'clock position.
+ *
+ * @param x The X coordinate of the upper left corner of the rect.
+ * @param y The Y coordinate of the upper left corner of the rect.
+ * @param width The width of the rect.
+ * @param height The height of the rect.
+ * @param arcStart The beginning angle of the arc.
+ * @param arcAngle The extent of the arc.
+ */
+ public abstract void drawArc(int x, int y, int width, int height,
+ int arcStart, int arcAngle);
+
+ /**
+ * Fills the arc define by the specified bounding rectangle and the specified
+ * angle parameter. The arc is centered at the center of the rectangle.
+ * The arc starts at the arcAngle position and extend for arcAngle
+ * degrees. The degree origin is at the 3 o'clock position.
+ *
+ * @param x The X coordinate of the upper left corner of the rect.
+ * @param y The Y coordinate of the upper left corner of the rect.
+ * @param width The width of the rect.
+ * @param height The height of the rect.
+ * @param arcStart The beginning angle of the arc.
+ * @param arcAngle The extent of the arc.
+ */
+ public abstract void fillArc(int x, int y, int width, int height,
+ int arcStart, int arcAngle);
+
+ /**
+ * Draws a series of interconnected lines determined by the arrays
+ * of corresponding x and y coordinates.
+ *
+ * @param xPoints The X coordinate array.
+ * @param yPoints The Y coordinate array.
+ * @param npoints The number of points to draw.
+ */
+ public abstract void drawPolyline(int xPoints[], int yPoints[], int npoints);
+
+ /**
+ * Draws a series of interconnected lines determined by the arrays
+ * of corresponding x and y coordinates. The figure is closed if necessary
+ * by connecting the first and last points.
+ *
+ * @param xPoints The X coordinate array.
+ * @param yPoints The Y coordinate array.
+ * @param npoints The number of points to draw.
+ */
+ public abstract void drawPolygon(int xPoints[], int yPoints[], int npoints);
+
+ /**
+ * Draws the specified polygon.
+ *
+ * @param polygon The polygon to draw.
+ */
+ public void drawPolygon(Polygon polygon)
+ {
+ drawPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints);
+ }
+
+ /**
+ * Fills the polygon determined by the arrays
+ * of corresponding x and y coordinates.
+ *
+ * @param xPoints The X coordinate array.
+ * @param yPoints The Y coordinate array.
+ * @param npoints The number of points to draw.
+ */
+ public abstract void fillPolygon(int xPoints[], int yPoints[], int npoints);
+
+ /**
+ * Fills the specified polygon
+ *
+ * @param polygon The polygon to fill.
+ */
+ public void fillPolygon(Polygon polygon)
+ {
+ fillPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints);
+ }
+
+ /**
+ * Draws the specified string starting at the specified point.
+ *
+ * @param string The string to draw.
+ * @param x The X coordinate of the point to draw at.
+ * @param y The Y coordinate of the point to draw at.
+ */
+ public abstract void drawString(String string, int x, int y);
+
+ public abstract void drawString (AttributedCharacterIterator ci, int x,
+ int y);
+
+ /**
+ * Draws the specified characters starting at the specified point.
+ *
+ * @param data The array of characters to draw.
+ * @param offset The offset into the array to start drawing characters from.
+ * @param length The number of characters to draw.
+ * @param x The X coordinate of the point to draw at.
+ * @param y The Y coordinate of the point to draw at.
+ */
+ public void drawChars(char data[], int offset, int length, int x, int y)
+ {
+ drawString(new String(data, offset, length), x, y);
+ }
+
+ public void drawBytes(byte[] data, int offset, int length, int x, int y)
+ {
+ String str = new String(data, offset, length);
+ drawString(str, x, y);
+ }
+
+ /**
+ * Draws all of the image that is available and returns. If the image
+ * is not completely loaded, <code>false</code> is returned and
+ * the specified iamge observer is notified as more data becomes
+ * available.
+ *
+ * @param image The image to draw.
+ * @param x The X coordinate of the point to draw at.
+ * @param y The Y coordinate of the point to draw at.
+ * @param observer The image observer to notify as data becomes available.
+ *
+ * @return <code>true</code> if all the image data is available,
+ * <code>false</code> otherwise.
+ */
+ public abstract boolean drawImage(Image image, int x, int y,
+ ImageObserver observer);
+
+ /**
+ * Draws all of the image that is available and returns. The image
+ * is scaled to fit in the specified rectangle. If the image
+ * is not completely loaded, <code>false</code> is returned and
+ * the specified iamge observer is notified as more data becomes
+ * available.
+ *
+ * @param image The image to draw.
+ * @param x The X coordinate of the point to draw at.
+ * @param y The Y coordinate of the point to draw at.
+ * @param width The width of the rectangle to draw in.
+ * @param height The height of the rectangle to draw in.
+ * @param observer The image observer to notify as data becomes available.
+ *
+ * @return <code>true</code> if all the image data is available,
+ * <code>false</code> otherwise.
+ */
+ public abstract boolean drawImage(Image image, int x, int y, int width,
+ int height, ImageObserver observer);
+
+ /**
+ * Draws all of the image that is available and returns. If the image
+ * is not completely loaded, <code>false</code> is returned and
+ * the specified iamge observer is notified as more data becomes
+ * available.
+ *
+ * @param image The image to draw.
+ * @param x The X coordinate of the point to draw at.
+ * @param y The Y coordinate of the point to draw at.
+ * @param bgcolor The background color to use for the image.
+ * @param observer The image observer to notify as data becomes available.
+ *
+ * @return <code>true</code> if all the image data is available,
+ * <code>false</code> otherwise.
+ */
+ public abstract boolean drawImage(Image image, int x, int y, Color bgcolor,
+ ImageObserver observer);
+
+ /**
+ * Draws all of the image that is available and returns. The image
+ * is scaled to fit in the specified rectangle. If the image
+ * is not completely loaded, <code>false</code> is returned and
+ * the specified iamge observer is notified as more data becomes
+ * available.
+ *
+ * @param image The image to draw.
+ * @param x The X coordinate of the point to draw at.
+ * @param y The Y coordinate of the point to draw at.
+ * @param width The width of the rectangle to draw in.
+ * @param height The height of the rectangle to draw in.
+ * @param bgcolor The background color to use for the image.
+ * @param observer The image observer to notify as data becomes available.
+ *
+ * @return <code>true</code> if all the image data is available,
+ * <code>false</code> otherwise.
+ */
+ public abstract boolean drawImage(Image image, int x, int y, int width,
+ int height, Color bgcolor,
+ ImageObserver observer);
+
+ /**
+ * FIXME: Write Javadocs for this when you understand it.
+ */
+ public abstract boolean drawImage(Image image, int dx1, int dy1, int dx2,
+ int dy2, int sx1, int sy1, int sx2,
+ int sy2, ImageObserver observer);
+
+ /**
+ * FIXME: Write Javadocs for this when you understand it.
+ */
+ public abstract boolean drawImage(Image image, int dx1, int dy1, int dx2,
+ int dy2, int sx1, int sy1, int sx2,
+ int sy2, Color bgcolor,
+ ImageObserver observer);
+
+ /**
+ * Free any resources held by this graphics context immediately instead
+ * of waiting for the object to be garbage collected and finalized.
+ */
+ public abstract void dispose();
+
+ /**
+ * Frees the resources held by this graphics context when it is
+ * garbage collected.
+ */
+ public void finalize()
+ {
+ dispose();
+ }
+
+ /**
+ * Returns a string representation of this object.
+ *
+ * @return A string representation of this object.
+ */
+ public String toString()
+ {
+ return getClass ().getName () + "[font=" + getFont () + ",color="
+ + getColor () + "]";
+ }
+
+ /**
+ * Returns <code>true</code> if the specified rectangle intersects with the
+ * current clip, <code>false</code> otherwise.
+ *
+ * @param x the X coordinate of the upper left corner of the test rectangle
+ * @param y the Y coordinate of the upper left corner of the test rectangle
+ * @param width the width of the upper left corner of the test rectangle
+ * @param height the height of the upper left corner of the test rectangle
+ * @return <code>true</code> if the specified rectangle intersects with the
+ * current clip, <code>false</code> otherwise
+ */
+ public boolean hitClip(int x, int y, int width, int height)
+ {
+ Shape clip = getClip();
+ if (clip == null)
+ return true;
+ return getClip().intersects(x, y, width, height);
+ }
+
+ public Rectangle getClipBounds(Rectangle r)
+ {
+ Rectangle clipBounds = getClipBounds();
+
+ if (r == null)
+ return clipBounds;
+
+ r.x = clipBounds.x;
+ r.y = clipBounds.y;
+ r.width = clipBounds.width;
+ r.height = clipBounds.height;
+ return r;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Graphics2D.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Graphics2D.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Graphics2D.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Graphics2D.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,358 @@
+/* Copyright (C) 2000, 2002, 2004, 2006, Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.geom.AffineTransform;
+import java.awt.image.BufferedImage;
+import java.awt.image.BufferedImageOp;
+import java.awt.image.ImageObserver;
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderableImage;
+import java.awt.print.PageFormat;
+import java.awt.print.Printable;
+import java.text.AttributedCharacterIterator;
+import java.util.Map;
+
+/**
+ * An abstract class defining a device independent two-dimensional vector
+ * graphics API. Concrete subclasses implement this API for output of
+ * vector graphics to:
+ * <p>
+ * <ul>
+ * <li>a {@link javax.swing.JComponent} - in the
+ * {@link javax.swing.JComponent#paint(Graphics)} method, the incoming
+ * {@link Graphics} should always be an instance of
+ * <code>Graphics2D</code>;</li>
+ * <li>a {@link BufferedImage} - see
+ * {@link BufferedImage#createGraphics()};</li>
+ * <li>a {@link java.awt.print.PrinterJob} - in the
+ * {@link Printable#print(Graphics, PageFormat, int)} method, the incoming
+ * {@link Graphics} should always be an instance of
+ * <code>Graphics2D</code>.</li>
+ * </ul>
+ * <p>
+ * Third party libraries provide support for output to other formats via this
+ * API, including encapsulated postscript (EPS), portable document format (PDF),
+ * and scalable vector graphics (SVG).
+ *
+ * @author Rolf W. Rasmussen (rolfwr at ii.uib.no)
+ */
+public abstract class Graphics2D extends Graphics
+{
+
+ protected Graphics2D()
+ {
+ }
+
+ public void draw3DRect(int x, int y, int width, int height,
+ boolean raised)
+ {
+ super.draw3DRect(x, y, width, height, raised);
+ }
+
+ public void fill3DRect(int x, int y, int width, int height,
+ boolean raised)
+ {
+ super.fill3DRect(x, y, width, height, raised);
+ }
+
+ /**
+ * Draws an outline around a shape using the current stroke and paint.
+ *
+ * @param shape the shape (<code>null</code> not permitted).
+ *
+ * @see #getStroke()
+ * @see #getPaint()
+ */
+ public abstract void draw(Shape shape);
+
+ public abstract boolean drawImage(Image image, AffineTransform xform,
+ ImageObserver obs);
+
+ public abstract void drawImage(BufferedImage image,
+ BufferedImageOp op,
+ int x,
+ int y);
+
+ public abstract void drawRenderedImage(RenderedImage image,
+ AffineTransform xform);
+
+ public abstract void drawRenderableImage(RenderableImage image,
+ AffineTransform xform);
+
+ /**
+ * Draws a string at the specified location, using the current font.
+ *
+ * @param text the string to draw.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @see Graphics#setFont(Font)
+ */
+ public abstract void drawString(String text, int x, int y);
+
+ /**
+ * Draws a string at the specified location, using the current font.
+ *
+ * @param text the string to draw.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @see Graphics#setFont(Font)
+ */
+ public abstract void drawString(String text, float x, float y);
+
+ /**
+ * Draws an attributed string at the specified location.
+ *
+ * @param iterator the source of the attributed text.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ */
+ public abstract void drawString(AttributedCharacterIterator iterator,
+ int x, int y);
+
+ /**
+ * Draws an attributed string at the specified location.
+ *
+ * @param iterator the source of the attributed text.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ */
+ public abstract void drawString(AttributedCharacterIterator iterator,
+ float x, float y);
+
+ /**
+ * Fills the interior of the specified <code>shape</code> using the current
+ * paint.
+ *
+ * @param shape the shape to fill (<code>null</code> not permitted).
+ *
+ * @see #draw(Shape)
+ * @see #getPaint()
+ */
+ public abstract void fill(Shape shape);
+
+ public abstract boolean hit(Rectangle rect, Shape text,
+ boolean onStroke);
+
+ public abstract GraphicsConfiguration getDeviceConfiguration();
+
+ /**
+ * Sets the current compositing rule.
+ *
+ * @param comp the composite.
+ *
+ * @see #getComposite()
+ */
+ public abstract void setComposite(Composite comp);
+
+ /**
+ * Sets the paint to be used for subsequent drawing operations.
+ *
+ * @param paint the paint (<code>null</code> not permitted).
+ *
+ * @see #getPaint()
+ */
+ public abstract void setPaint(Paint paint);
+
+ /**
+ * Sets the stroke to be used for subsequent drawing operations.
+ *
+ * @param stroke the stroke (<code>null</code> not permitted).
+ *
+ * @see #getStroke()
+ */
+ public abstract void setStroke(Stroke stroke);
+
+ /**
+ * Adds or updates a hint in the current rendering hints table.
+ *
+ * @param hintKey the hint key.
+ * @param hintValue the hint value.
+ */
+ public abstract void setRenderingHint(RenderingHints.Key hintKey,
+ Object hintValue);
+
+ /**
+ * Returns the current value of a rendering hint.
+ *
+ * @param hintKey the key for the hint.
+ *
+ * @return The value for the specified hint.
+ */
+ public abstract Object getRenderingHint(RenderingHints.Key hintKey);
+
+ /**
+ * Replaces the current rendering hints with the supplied hints.
+ *
+ * @param hints the hints.
+ *
+ * @see #addRenderingHints(Map)
+ */
+ public abstract void setRenderingHints(Map hints);
+
+ /**
+ * Adds/updates the rendering hint.
+ *
+ * @param hints the hints to add or update.
+ */
+ public abstract void addRenderingHints(Map hints);
+
+ /**
+ * Returns the current rendering hints.
+ *
+ * @return The current rendering hints.
+ */
+ public abstract RenderingHints getRenderingHints();
+
+ public abstract void translate(int x, int y);
+
+ public abstract void translate(double tx, double ty);
+
+ public abstract void rotate(double theta);
+
+ public abstract void rotate(double theta, double x, double y);
+
+ public abstract void scale(double scaleX, double scaleY);
+
+ public abstract void shear(double shearX, double shearY);
+
+ /**
+ * Sets the current transform to a concatenation of <code>transform</code>
+ * and the existing transform.
+ *
+ * @param transform the transform.
+ */
+ public abstract void transform(AffineTransform transform);
+
+ /**
+ * Sets the current transform. If the caller specifies a <code>null</code>
+ * transform, this method should set the current transform to the
+ * identity transform.
+ *
+ * @param transform the transform (<code>null</code> permitted).
+ *
+ * @see #getTransform()
+ */
+ public abstract void setTransform(AffineTransform transform);
+
+ /**
+ * Returns the current transform.
+ *
+ * @return The current transform.
+ *
+ * @see #setTransform(AffineTransform)
+ */
+ public abstract AffineTransform getTransform();
+
+ /**
+ * Returns the current paint.
+ *
+ * @return The current paint.
+ *
+ * @see #setPaint(Paint)
+ */
+ public abstract Paint getPaint();
+
+ /**
+ * Returns the current compositing rule.
+ *
+ * @return The current compositing rule.
+ *
+ * @see #setComposite(Composite)
+ */
+ public abstract Composite getComposite();
+
+ /**
+ * Sets the background color (used by the
+ * {@link Graphics#clearRect(int, int, int, int)} method).
+ *
+ * @param color the color.
+ *
+ * @see #getBackground()
+ */
+ public abstract void setBackground(Color color);
+
+ /**
+ * Returns the color used by the
+ * {@link Graphics#clearRect(int, int, int, int)} method.
+ *
+ * @return The background color.
+ *
+ * @see #setBackground(Color)
+ */
+ public abstract Color getBackground();
+
+ /**
+ * Returns the current stroke.
+ *
+ * @return The current stroke.
+ *
+ * @see #setStroke(Stroke)
+ */
+ public abstract Stroke getStroke();
+
+ /**
+ * Sets the clip region to the intersection of the current clipping region
+ * and <code>s</code>.
+ *
+ * @param s the shape to intersect with the current clipping region.
+ *
+ * @see Graphics#setClip(Shape)
+ */
+ public abstract void clip(Shape s);
+
+ /**
+ * Returns the font render context.
+ *
+ * @return The font render context.
+ */
+ public abstract FontRenderContext getFontRenderContext();
+
+ /**
+ * Draws a glyph vector at the specified location.
+ *
+ * @param g the glyph vector.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ */
+ public abstract void drawGlyphVector(GlyphVector g, float x, float y);
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GraphicsConfigTemplate.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GraphicsConfigTemplate.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GraphicsConfigTemplate.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GraphicsConfigTemplate.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,106 @@
+/* GraphicsConfigTemplate.java -- a template for selecting configurations
+ Copyright (C) 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.io.Serializable;
+
+/**
+ * This allows filtering an array of GraphicsConfigurations for the best
+ * one based on various requirements. The resulting configuration has had
+ * all non-default attributes set as required to meet or exceed the request.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see GraphicsConfiguration
+ * @see GraphicsDevice
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public abstract class GraphicsConfigTemplate implements Serializable
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = -8061369279557787079L;
+
+ /** States that a feature is required to select a configuration. */
+ public static final int REQUIRED = 1;
+
+ /**
+ * States that a feature is preferred, but not required, to select a
+ * configuration. In the case of multiple valid configurations, the tie
+ * breaks in favor of the one with the feature.
+ */
+ public static final int PREFERRED = 2;
+
+ /**
+ * States that a feature is not necessary in the configuration. In the case
+ * of multiple valid configurations, the tie breaks in favor of the one
+ * without the feature, to reduce overhead.
+ */
+ public static final int UNNECESSARY = 3;
+
+ /**
+ * The default constructor.
+ */
+ public GraphicsConfigTemplate()
+ {
+ }
+
+ /**
+ * Returns the "best" match among the array of possible configurations, given
+ * the criteria of this template.
+ *
+ * @param array the array to choose from
+ * @return the best match
+ * @throws NullPointerException if array is null
+ */
+ public abstract GraphicsConfiguration getBestConfiguration
+ (GraphicsConfiguration[] array);
+
+ /**
+ * Returns true if the given configuration supports all the features required
+ * by this template.
+ *
+ * @param config the configuration to test
+ * @return true if it is a match
+ * @throws NullPointerException if config is null
+ */
+ public abstract boolean isGraphicsConfigSupported
+ (GraphicsConfiguration config);
+} // class GraphicsConfigTemplate
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GraphicsConfiguration.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GraphicsConfiguration.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GraphicsConfiguration.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GraphicsConfiguration.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,250 @@
+/* GraphicsConfiguration.java -- describes characteristics of graphics
+ Copyright (C) 2000, 2001, 2002 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import gnu.classpath.NotImplementedException;
+
+import java.awt.geom.AffineTransform;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.VolatileImage;
+
+/**
+ * This class describes the configuration of various graphics devices, such
+ * as a monitor or printer. Different configurations may exist for the same
+ * device, according to the different native modes supported.
+ *
+ * <p>Virtual devices are supported (for example, in a multiple screen
+ * environment, a virtual device covers all screens simultaneously); the
+ * configuration will have a non-zero relative coordinate system in such
+ * a case.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see Window
+ * @see Frame
+ * @see GraphicsEnvironment
+ * @see GraphicsDevice
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public abstract class GraphicsConfiguration
+{
+
+ /** The cached image capabilities. */
+ private ImageCapabilities imageCapabilities;
+
+ /** The cached buffer capabilities. */
+ private BufferCapabilities bufferCapabilities;
+
+ /**
+ * The default constructor.
+ *
+ * @see GraphicsDevice#getConfigurations()
+ * @see GraphicsDevice#getDefaultConfiguration()
+ * @see GraphicsDevice#getBestConfiguration(GraphicsConfigTemplate)
+ * @see Graphics2D#getDeviceConfiguration()
+ */
+ protected GraphicsConfiguration ()
+ {
+ }
+
+ /**
+ * Gets the associated device that this configuration describes.
+ *
+ * @return the device
+ */
+ public abstract GraphicsDevice getDevice();
+
+ /**
+ * Returns a buffered image optimized to this device, so that blitting can
+ * be supported in the buffered image.
+ *
+ * @param w the width of the buffer
+ * @param h the height of the buffer
+ * @return the buffered image, or null if none is supported
+ */
+ public abstract BufferedImage createCompatibleImage(int w, int h);
+
+ /**
+ * Returns a buffered volatile image optimized to this device, so that
+ * blitting can be supported in the buffered image. Because the buffer is
+ * volatile, it can be optimized by native graphics accelerators.
+ *
+ * @param w the width of the buffer
+ * @param h the height of the buffer
+ * @return the buffered image, or null if none is supported
+ * @see Component#createVolatileImage(int, int)
+ * @since 1.4
+ */
+ public abstract VolatileImage createCompatibleVolatileImage(int w, int h);
+
+ /**
+ * Returns a buffered volatile image optimized to this device, and with the
+ * given capabilities, so that blitting can be supported in the buffered
+ * image. Because the buffer is volatile, it can be optimized by native
+ * graphics accelerators.
+ *
+ * @param w the width of the buffer
+ * @param h the height of the buffer
+ * @param caps the desired capabilities of the image buffer
+ * @return the buffered image, or null if none is supported
+ * @throws AWTException if the capabilities cannot be met
+ * @since 1.4
+ */
+ public VolatileImage createCompatibleVolatileImage(int w, int h,
+ ImageCapabilities caps)
+ throws AWTException
+ {
+ throw new AWTException("not implemented");
+ }
+
+ /**
+ * Returns a buffered volatile image optimized to this device, and
+ * with the given transparency. Because the buffer is volatile, it
+ * can be optimized by native graphics accelerators.
+ *
+ * @param width the width of the buffer
+ * @param height the height of the buffer
+ * @param transparency the transparency value for the buffer
+ * @return the buffered image, or null if none is supported
+ * @since 1.5
+ */
+ public abstract VolatileImage createCompatibleVolatileImage(int width,
+ int height,
+ int transparency);
+
+ /**
+ * Returns a buffered image optimized to this device, and with the specified
+ * transparency, so that blitting can be supported in the buffered image.
+ *
+ * @param w the width of the buffer
+ * @param h the height of the buffer
+ * @param transparency the transparency of the buffer
+ * @return the buffered image, or null if none is supported
+ * @see Transparency#OPAQUE
+ * @see Transparency#BITMASK
+ * @see Transparency#TRANSLUCENT
+ */
+ public abstract BufferedImage createCompatibleImage(int w, int h,
+ int transparency);
+
+ /**
+ * Gets the color model of the corresponding device.
+ *
+ * @return the color model
+ */
+ public abstract ColorModel getColorModel();
+
+ /**
+ * Gets a color model for the corresponding device which supports the desired
+ * transparency level.
+ *
+ * @param transparency the transparency of the model
+ * @return the color model, with transparency
+ * @see Transparency#OPAQUE
+ * @see Transparency#BITMASK
+ * @see Transparency#TRANSLUCENT
+ */
+ public abstract ColorModel getColorModel(int transparency);
+
+ /**
+ * Returns a transform that maps user coordinates to device coordinates. The
+ * preferred mapping is about 72 user units to 1 inch (2.54 cm) of physical
+ * space. This is often the identity transform. The device coordinates have
+ * the origin at the upper left, with increasing x to the right, and
+ * increasing y to the bottom.
+ *
+ * @return the transformation from user space to device space
+ * @see #getNormalizingTransform()
+ */
+ public abstract AffineTransform getDefaultTransform();
+
+ /**
+ * Returns a transform that maps user coordinates to device coordinates. The
+ * exact mapping is 72 user units to 1 inch (2.54 cm) of physical space.
+ * This is often the identity transform. The device coordinates have the
+ * origin at the upper left, with increasing x to the right, and increasing
+ * y to the bottom. Note that this is more accurate (and thus, sometimes more
+ * costly) than the default transform.
+ *
+ * @return the normalized transformation from user space to device space
+ * @see #getDefaultTransform()
+ */
+ public abstract AffineTransform getNormalizingTransform();
+
+ /**
+ * Returns the bounds of the configuration, in device coordinates. If this
+ * is a virtual device (for example, encompassing several screens), the
+ * bounds may have a non-zero origin.
+ *
+ * @return the device bounds
+ * @since 1.3
+ */
+ public abstract Rectangle getBounds();
+
+ /**
+ * Returns the buffering capabilities of this configuration.
+ *
+ * @return the buffer capabilities
+ * @since 1.4
+ */
+ public BufferCapabilities getBufferCapabilities()
+ {
+ if (imageCapabilities == null)
+ getImageCapabilities();
+
+ if (bufferCapabilities == null)
+ bufferCapabilities = new BufferCapabilities(imageCapabilities,
+ imageCapabilities, null);
+ return bufferCapabilities;
+ }
+
+ /**
+ * Returns the imaging capabilities of this configuration.
+ *
+ * @return the image capabilities
+ * @since 1.4
+ */
+ public ImageCapabilities getImageCapabilities()
+ {
+ if (imageCapabilities == null)
+ imageCapabilities = new ImageCapabilities(false);
+ return imageCapabilities;
+ }
+} // class GraphicsConfiguration
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GraphicsDevice.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GraphicsDevice.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GraphicsDevice.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GraphicsDevice.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,292 @@
+/* GraphicsDevice.java -- information about a graphics device
+ Copyright (C) 2002, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.awt.image.VolatileImage;
+
+/**
+ * This describes a graphics device available to the given environment. This
+ * includes screen and printer devices, and the different configurations for
+ * each device. Also, this allows you to create virtual devices which operate
+ * over a multi-screen environment.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see GraphicsEnvironment
+ * @see GraphicsConfiguration
+ * @since 1.3
+ * @status updated to 1.4
+ */
+public abstract class GraphicsDevice
+{
+ /** Device is a raster screen. */
+ public static final int TYPE_RASTER_SCREEN = 0;
+
+ /** Device is a printer. */
+ public static final int TYPE_PRINTER = 1;
+
+ /** Device is an image buffer not visible to the user. */
+ public static final int TYPE_IMAGE_BUFFER = 2;
+
+ /** The current full-screen window, or null if there is none. */
+ private Window full_screen;
+
+ /**
+ * The bounds of the fullscreen window before it has been switched to full
+ * screen.
+ */
+ private Rectangle fullScreenOldBounds;
+
+ /** The current display mode, or null if unknown. */
+ private DisplayMode mode;
+
+ /**
+ * The default constructor.
+ *
+ * @see GraphicsEnvironment#getScreenDevices()
+ * @see GraphicsEnvironment#getDefaultScreenDevice()
+ * @see GraphicsConfiguration#getDevice()
+ */
+ protected GraphicsDevice()
+ {
+ }
+
+ /**
+ * Returns the type of the device.
+ *
+ * @return the device type
+ * @see #TYPE_RASTER_SCREEN
+ * @see #TYPE_PRINTER
+ * @see #TYPE_IMAGE_BUFFER
+ */
+ public abstract int getType();
+
+ /**
+ * Returns an identification string for the device. This can be
+ * vendor-specific, and may be useful for debugging.
+ *
+ * @return the identification
+ */
+ public abstract String getIDstring();
+
+ /**
+ * Return all configurations valid for this device.
+ *
+ * @return an array of configurations
+ */
+ public abstract GraphicsConfiguration[] getConfigurations();
+
+ /**
+ * Return the default configuration for this device.
+ *
+ * @return the default configuration
+ */
+ public abstract GraphicsConfiguration getDefaultConfiguration();
+
+ /**
+ * Return the best configuration, according to the criteria in the given
+ * template.
+ *
+ * @param template the template to adjust by
+ * @return the best configuration
+ * @throws NullPointerException if template is null
+ */
+ public GraphicsConfiguration getBestConfiguration
+ (GraphicsConfigTemplate template)
+ {
+ return template.getBestConfiguration(getConfigurations());
+ }
+
+ /**
+ * Returns true if the device supports full-screen exclusive mode. The
+ * default implementation returns true; subclass it if this is not the case.
+ *
+ * @return true if full screen support is available
+ * @since 1.4
+ */
+ public boolean isFullScreenSupported()
+ {
+ return true;
+ }
+
+ /**
+ * Toggle the given window between full screen and normal mode. The previous
+ * full-screen window, if different, is restored; if the given window is
+ * null, no window will be full screen. If
+ * <code>isFullScreenSupported()</code> returns true, full screen mode is
+ * considered to be exclusive, which implies:<ul>
+ * <li>Windows cannot overlap the full-screen window. All other application
+ * windows will always appear beneath the full-screen window in the
+ * Z-order.</li>
+ * <li>Input method windows are disabled. It is advisable to call
+ * <code>Component.enableInputMethods(false)</code> to make a component
+ * a non-client of the input method framework.</li>
+ * </ul><br>
+ * If <code>isFullScreenSupported()</code> returns false, full-screen
+ * exclusive mode is simulated by resizing the window to the size of the
+ * screen and positioning it at (0,0). This is also what this method does.
+ * If a device supports real fullscreen mode then it should override this
+ * method as well as #isFullScreenSupported and #getFullScreenWindow.
+ *
+ * @param w the window to toggle
+ * @see #isFullScreenSupported()
+ * @see #getFullScreenWindow()
+ * @see #setDisplayMode(DisplayMode)
+ * @see Component#enableInputMethods(boolean)
+ * @since 1.4
+ */
+ public synchronized void setFullScreenWindow(Window w)
+ {
+ // Restore the previous window to normal mode and release the reference.
+ if (full_screen != null)
+ {
+ full_screen.setBounds(fullScreenOldBounds);
+ }
+
+ full_screen = null;
+
+ // If w != null, make it full-screen.
+ if (w != null)
+ {
+ fullScreenOldBounds = w.getBounds();
+ full_screen = w;
+ DisplayMode dMode = getDisplayMode();
+ full_screen.setBounds(0, 0, dMode.getWidth(), dMode.getHeight());
+ full_screen.requestFocus();
+ full_screen.setLocationRelativeTo(null);
+ }
+ }
+
+ /**
+ * Returns the current full-screen window of the device, or null if no
+ * window is full-screen.
+ *
+ * @return the full-screen window
+ * @see #setFullScreenWindow(Window)
+ * @since 1.4
+ */
+ public Window getFullScreenWindow()
+ {
+ return full_screen;
+ }
+
+ /**
+ * Returns whether this device supports low-level display changes. This may
+ * depend on whether full-screen exclusive mode is available.
+ *
+ * XXX The default implementation returns false for now.
+ *
+ * @return true if display changes are supported
+ * @see #setDisplayMode(DisplayMode)
+ * @since 1.4
+ */
+ public boolean isDisplayChangeSupported()
+ {
+ return false;
+ }
+
+ /**
+ * Sets the display mode. This may be dependent on the availability of
+ * full-screen exclusive mode.
+ *
+ * @param mode the new mode
+ * @throws IllegalArgumentException if the new mode is not in getDisplayModes
+ * @throws UnsupportedOperationException if ! isDisplayChangeSupported()
+ * @see #getDisplayMode()
+ * @see #getDisplayModes()
+ * @see #isDisplayChangeSupported()
+ * @since 1.4
+ */
+ public void setDisplayMode(DisplayMode mode)
+ {
+ DisplayMode[] array = getDisplayModes();
+ if (! isDisplayChangeSupported())
+ throw new UnsupportedOperationException();
+ int i = array == null ? 0 : array.length;
+ while (--i >= 0)
+ if (array[i].equals(mode))
+ break;
+ if (i < 0)
+ throw new IllegalArgumentException();
+ this.mode = mode;
+ }
+
+ /**
+ * Returns the current display mode of this device, or null if unknown.
+ *
+ * @return the current display mode
+ * @see #setDisplayMode(DisplayMode)
+ * @see #getDisplayModes()
+ * @since 1.4
+ */
+ public DisplayMode getDisplayMode()
+ {
+ return mode;
+ }
+
+ /**
+ * Return an array of all available display modes. This implementation
+ * returns a 0-length array, so subclasses must override this.
+ *
+ * @return the array of available modes
+ * @since 1.4
+ */
+ public DisplayMode[] getDisplayModes()
+ {
+ return new DisplayMode[0];
+ }
+
+ /**
+ * Return the number of bytes available in accelerated memory on this
+ * device. The device may support creation or caching on a first-come,
+ * first-served basis, depending on the operating system and driver.
+ * Memory may be a finite resource, and because of multi-threading, you
+ * are not guaranteed that the result of this method ensures your image
+ * will successfully be put in accelerated memory. A negative result means
+ * the memory is unlimited. The default implementation assumes no special
+ * memory is available, and returns 0.
+ *
+ * @return the size of accelerated memory available
+ * @see VolatileImage#flush()
+ * @see ImageCapabilities#isAccelerated()
+ */
+ public int getAvailableAcceleratedMemory()
+ {
+ return 0;
+ }
+} // class GraphicsDevice
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GraphicsEnvironment.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GraphicsEnvironment.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GraphicsEnvironment.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GraphicsEnvironment.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,244 @@
+/* GraphicsEnvironment.java -- information about the graphics environment
+ Copyright (C) 2002, 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import gnu.java.awt.ClasspathToolkit;
+import gnu.classpath.SystemProperties;
+import java.awt.image.BufferedImage;
+import java.util.Locale;
+
+/**
+ * This descibes the collection of GraphicsDevice and Font objects available
+ * on a given platform. The resources might be local or remote, and specify
+ * the valid configurations for displaying graphics.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see GraphicsDevice
+ * @see GraphicsConfiguration
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public abstract class GraphicsEnvironment
+{
+ private static GraphicsEnvironment localGraphicsEnvironment;
+
+ /**
+ * The environment must be obtained from a factory or query method, hence
+ * this constructor is protected.
+ */
+ protected GraphicsEnvironment()
+ {
+ }
+
+ /**
+ * Returns the local graphics environment. If the java.awt.graphicsenv
+ * system property is set, it instantiates the specified class,
+ * otherwise it assume that the awt toolkit is a ClasspathToolkit
+ * and delegates to it to create the instance.
+ *
+ * @return the local environment
+ */
+ public static GraphicsEnvironment getLocalGraphicsEnvironment()
+ {
+ if (localGraphicsEnvironment != null)
+ return localGraphicsEnvironment;
+
+ String graphicsenv = SystemProperties.getProperty("java.awt.graphicsenv",
+ null);
+ if (graphicsenv != null)
+ {
+ try
+ {
+ // We intentionally use the bootstrap class loader.
+ localGraphicsEnvironment = (GraphicsEnvironment)
+ Class.forName(graphicsenv).newInstance();
+ return localGraphicsEnvironment;
+ }
+ catch (Exception x)
+ {
+ throw (InternalError)
+ new InternalError("Unable to instantiate java.awt.graphicsenv")
+ .initCause(x);
+ }
+ }
+ else
+ {
+ ClasspathToolkit tk;
+ tk = ((ClasspathToolkit) Toolkit.getDefaultToolkit());
+ localGraphicsEnvironment = tk.getLocalGraphicsEnvironment();
+ return localGraphicsEnvironment;
+ }
+ }
+
+ /**
+ * Check if the local environment is headless, meaning that it does not
+ * support a display, keyboard, or mouse. Many methods in the Abstract
+ * Windows Toolkit (java.awt) throw a {@link HeadlessException} if this
+ * returns true.
+ *
+ * This method returns true if the java.awt.headless property is set
+ * to "true".
+ *
+ * @return true if the environment is headless, meaning that graphics are
+ * unsupported
+ * @since 1.4
+ */
+ public static boolean isHeadless()
+ {
+ String headless = SystemProperties.getProperty("java.awt.headless", null);
+ return "true".equalsIgnoreCase(headless);
+ }
+
+ /**
+ * Check if the given environment is headless, meaning that it does not
+ * support a display, keyboard, or mouse. Many methods in the Abstract
+ * Windows Toolkit (java.awt) throw a {@link HeadlessException} if this
+ * returns true. This default implementation returns isHeadless(), so
+ * subclasses need only override it if they differ.
+ *
+ * @return true if the environment is headless, meaning that graphics are
+ * unsupported
+ * @since 1.4
+ */
+ public boolean isHeadlessInstance()
+ {
+ return isHeadless();
+ }
+
+ /**
+ * Get an array of all the GraphicsDevice objects.
+ *
+ * @return the available graphics devices, may be 0 length
+ * @throws HeadlessException if the environment is headless
+ */
+ public abstract GraphicsDevice[] getScreenDevices();
+
+ /**
+ * Get the default screen GraphicsDevice object.
+ *
+ * @return the default screen device
+ * @throws HeadlessException if the environment is headless
+ */
+ public abstract GraphicsDevice getDefaultScreenDevice();
+
+ /**
+ * Return a Graphics2D object which will render into the specified image.
+ *
+ * @param image the image to render into
+ * @return the object that renders into the image
+ */
+ public abstract Graphics2D createGraphics(BufferedImage image);
+
+ /**
+ * Returns an array of the one-point size fonts available in this
+ * environment. From there, the user can select the font and derive the
+ * correct one of proper size and attributes, using <code>deriveFont</code>.
+ * Only one master version of each font appears in this array; if a font
+ * can be derived from another, it must be created in that way.
+ *
+ * @return the array of available fonts
+ * @see #getAvailableFontFamilyNames()
+ * @see Font#deriveFont(int, float)
+ * @since 1.2
+ */
+ public abstract Font[] getAllFonts();
+
+ /**
+ * Returns an array of the font family names available in this environment.
+ * This allows flexibility in choosing the style of font, while still letting
+ * the Font class decide its best match.
+ *
+ * @return the array of available font families
+ * @see #getAllFonts()
+ * @see Font#getFamily()
+ * @since 1.2
+ */
+ public abstract String[] getAvailableFontFamilyNames();
+
+ /**
+ * Returns an array of the font family names available in this environment,
+ * localized to the current Locale if l is non-null. This allows
+ * flexibility in choosing the style of font, while still letting the Font
+ * class decide its best match.
+ *
+ * @param l the locale to use
+ * @return the array of available font families, localized
+ * @see #getAllFonts()
+ * @see Font#getFamily()
+ * @since 1.2
+ */
+ public abstract String[] getAvailableFontFamilyNames(Locale l);
+
+ /**
+ * Returns the point where a window should be centered. You should probably
+ * also check that the window fits within the screen bounds. The default
+ * simply returns the center of the maximum window bounds; subclasses should
+ * override this if native objects (like scrollbars) make that off-centered.
+ *
+ * @return the centering point
+ * @throws HeadlessException if the environment is headless
+ * @see #getMaximumWindowBounds()
+ * @since 1.4
+ */
+ public Point getCenterPoint()
+ {
+ Rectangle r = getMaximumWindowBounds();
+ return new Point(r.x + r.width / 2, r.y + r.height / 2);
+ }
+
+ /**
+ * Returns the maximum bounds for a centered window object. The default
+ * implementation simply returns the bounds of the default configuration
+ * of the default screen; subclasses should override this to if native
+ * objects (like scrollbars) reduce what is truly available. Also,
+ * subclasses should override this if the window should be centered across
+ * a multi-screen display.
+ *
+ * @return the maximum window bounds
+ * @throws HeadlessException if the environment is headless
+ * @see #getCenterPoint()
+ * @see GraphicsConfiguration#getBounds()
+ * @see Toolkit#getScreenInsets(GraphicsConfiguration)
+ * @since 1.4
+ */
+ public Rectangle getMaximumWindowBounds()
+ {
+ return getDefaultScreenDevice().getDefaultConfiguration().getBounds();
+ }
+} // class GraphicsEnvironment
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GridBagConstraints.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GridBagConstraints.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GridBagConstraints.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GridBagConstraints.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,246 @@
+/* GridBagConstraints.java -- Constraints for GridBag layout manager
+ Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation
+
+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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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;
+
+import java.io.Serializable;
+
+/**
+ * This specifies the constraints for a component managed by the
+ * GridBagLayout layout manager.
+ */
+public class GridBagConstraints implements Cloneable, Serializable
+{
+ static final long serialVersionUID = -1000070633030801713L;
+
+ // Fill values.
+ /**
+ * Don't fill.
+ */
+ public static final int NONE = 0;
+
+ /**
+ * Fill in both directions.
+ */
+ public static final int BOTH = 1;
+
+ /**
+ * Fill horizontally.
+ */
+ public static final int HORIZONTAL = 2;
+
+ /**
+ * Fill vertically.
+ */
+ public static final int VERTICAL = 3;
+
+ // Anchor values.
+ /**
+ * Position in the center.
+ */
+ public static final int CENTER = 10;
+
+ /**
+ * Position to the north.
+ */
+ public static final int NORTH = 11;
+
+ /**
+ * Position to the northeast.
+ */
+ public static final int NORTHEAST = 12;
+
+ /**
+ * Position to the east.
+ */
+ public static final int EAST = 13;
+
+ /**
+ * Position to the southeast.
+ */
+ public static final int SOUTHEAST = 14;
+
+ /**
+ * Position to the south.
+ */
+ public static final int SOUTH = 15;
+
+ /**
+ * Position to the southwest.
+ */
+ public static final int SOUTHWEST = 16;
+
+ /**
+ * Position to the west.
+ */
+ public static final int WEST = 17;
+
+ /**
+ * Position to the northwest.
+ */
+ public static final int NORTHWEST = 18;
+
+ // gridx and gridy values.
+ /**
+ * Occupy all remaining cells except last cell.
+ */
+ public static final int RELATIVE = -1;
+
+ /**
+ * Occupy all remaining cells.
+ */
+ public static final int REMAINDER = 0;
+
+ /**
+ * Position to where a page starts. Equals NORTH for horizontal orientations.
+ */
+ public static final int PAGE_START = 19;
+
+ /**
+ * Position to where a page ends. Equals SOUTH for horizontal orientations.
+ */
+ public static final int PAGE_END = 20;
+
+ /**
+ * Position to where a text line would start. Equals to WEST for
+ * left-to-right orientations.
+ */
+ public static final int LINE_START = 21;
+
+ /**
+ * Position to where a text line would end. Equals to EAST for
+ * left-to-right orientations.
+ */
+ public static final int LINE_END = 22;
+
+ /**
+ * Position to where the first text line would start. Equals to NORTHWEST for
+ * horizontal left-to-right orientations.
+ */
+ public static final int FIRST_LINE_START = 23;
+
+ /**
+ * Position to where the first text line would end. Equals to NORTHEAST for
+ * horizontal left-to-right orientations.
+ */
+ public static final int FIRST_LINE_END = 24;
+
+ /**
+ * Position to where the last text line would start. Equals to SOUTHWEST for
+ * horizontal left-to-right orientations.
+ */
+ public static final int LAST_LINE_START = 25;
+
+ /**
+ * Position to where the last text line would end. Equals to SOUTHEAST for
+ * horizontal left-to-right orientations.
+ */
+ public static final int LAST_LINE_END = 26;
+
+ public int anchor;
+ public int fill;
+ public int gridheight;
+ public int gridwidth;
+ public int gridx;
+ public int gridy;
+ public Insets insets;
+ public int ipadx;
+ public int ipady;
+ public double weightx;
+ public double weighty;
+
+ /**
+ * Create a copy of this object.
+ */
+ public Object clone ()
+ {
+ try
+ {
+ GridBagConstraints g = (GridBagConstraints) super.clone ();
+ g.insets = (Insets) insets.clone ();
+ return g;
+ }
+ catch (CloneNotSupportedException _)
+ {
+ // Can't happen.
+ return null;
+ }
+ }
+
+ /**
+ * Create a new GridBagConstraints object with the default
+ * parameters.
+ */
+ public GridBagConstraints ()
+ {
+ this.anchor = CENTER;
+ this.fill = NONE;
+ this.gridx = RELATIVE;
+ this.gridy = RELATIVE;
+ this.gridwidth = 1;
+ this.gridheight = 1;
+ this.ipadx = 0;
+ this.ipady = 0;
+ this.insets = new Insets (0, 0, 0, 0);
+ this.weightx = 0;
+ this.weighty = 0;
+ }
+
+ /**
+ * Create a new GridBagConstraints object with the indicated
+ * parameters.
+ */
+ public GridBagConstraints (int gridx, int gridy,
+ int gridwidth, int gridheight,
+ double weightx, double weighty,
+ int anchor, int fill,
+ Insets insets, int ipadx, int ipady)
+ {
+ this.anchor = anchor;
+ this.fill = fill;
+ this.gridx = gridx;
+ this.gridy = gridy;
+ this.gridwidth = gridwidth;
+ this.gridheight = gridheight;
+ this.ipadx = ipadx;
+ this.ipady = ipady;
+ this.insets = insets;
+ this.weightx = weightx;
+ this.weighty = weighty;
+ }
+}
More information about the llvm-commits
mailing list