Merge
This commit is contained in:
commit
c627fa5807
@ -60,16 +60,28 @@ ifneq ($(findstring $(OPENJDK_TARGET_OS), windows aix),)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copy msvcrXX.dll on windows
|
# Copy the microsoft runtime libraries on windows
|
||||||
|
|
||||||
ifeq ($(OPENJDK_TARGET_OS), windows)
|
ifeq ($(OPENJDK_TARGET_OS), windows)
|
||||||
MSVCR_TARGET := $(LIB_DST_DIR)/$(notdir $(MSVCR_DLL))
|
|
||||||
# Chmod to avoid permission issues if bundles are unpacked on unix platforms.
|
|
||||||
$(MSVCR_TARGET): $(MSVCR_DLL)
|
|
||||||
$(call install-file)
|
|
||||||
$(CHMOD) a+rx $@
|
|
||||||
|
|
||||||
TARGETS += $(MSVCR_TARGET)
|
# Chmod to avoid permission issues if bundles are unpacked on unix platforms.
|
||||||
|
define copy-and-chmod
|
||||||
|
$(install-file)
|
||||||
|
$(CHMOD) a+rx $@
|
||||||
|
endef
|
||||||
|
|
||||||
|
# Use separate macro calls in case the source files are not in the same
|
||||||
|
# directory.
|
||||||
|
$(eval $(call SetupCopyFiles,COPY_MSVCR, \
|
||||||
|
DEST := $(LIB_DST_DIR), \
|
||||||
|
FILES := $(MSVCR_DLL), \
|
||||||
|
MACRO := copy-and-chmod))
|
||||||
|
|
||||||
|
$(eval $(call SetupCopyFiles,COPY_MSVCP, \
|
||||||
|
DEST := $(LIB_DST_DIR), \
|
||||||
|
FILES := $(MSVCP_DLL), \
|
||||||
|
MACRO := copy-and-chmod))
|
||||||
|
|
||||||
|
TARGETS += $(COPY_MSVCR) $(COPY_MSVCP)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -515,6 +515,77 @@ TARGETS += $(BUILD_LIBJAVAJPEG)
|
|||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
ifeq ($(BUILD_HEADLESS), true)
|
||||||
|
# Mac and Windows only use the native AWT lib, do not build libawt_headless
|
||||||
|
ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx),)
|
||||||
|
|
||||||
|
LIBAWT_HEADLESS_DIRS := $(JDK_TOPDIR)/src/java.desktop/unix/native/libawt_headless/awt \
|
||||||
|
$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \
|
||||||
|
$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/java2d/opengl \
|
||||||
|
$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/java2d/x11 \
|
||||||
|
$(JDK_TOPDIR)/src/java.desktop/share/native/common/java2d/opengl \
|
||||||
|
$(JDK_TOPDIR)/src/java.desktop/share/native/common/font \
|
||||||
|
#
|
||||||
|
|
||||||
|
LIBAWT_HEADLESS_EXCLUDES := medialib
|
||||||
|
LIBAWT_HEADLESS_CFLAGS := -I$(SUPPORT_OUTPUTDIR)/headers/java.desktop \
|
||||||
|
$(addprefix -I, $(LIBAWT_HEADLESS_DIRS)) \
|
||||||
|
-I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d \
|
||||||
|
-I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d/loops \
|
||||||
|
-I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/awt/image/cvutils \
|
||||||
|
-I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d/pipe \
|
||||||
|
-I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/awt/image \
|
||||||
|
-I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libawt/java2d \
|
||||||
|
-I$(JDK_TOPDIR)/src/java.desktop/share/native/common/font \
|
||||||
|
-I$(JDK_TOPDIR)/src/java.desktop/share/native/common/awt/debug \
|
||||||
|
-I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/font \
|
||||||
|
-I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libsunwjdga/ \
|
||||||
|
$(LIBJAVA_HEADER_FLAGS) \
|
||||||
|
#
|
||||||
|
|
||||||
|
LIBAWT_HEADLESS_REORDER :=
|
||||||
|
ifeq ($(OPENJDK_TARGET_OS), solaris)
|
||||||
|
ifneq ($(OPENJDK_TARGET_CPU), x86_64)
|
||||||
|
LIBAWT_HEADLESS_REORDER := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/reorder-$(OPENJDK_TARGET_CPU)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(eval $(call SetupNativeCompilation,BUILD_LIBAWT_HEADLESS, \
|
||||||
|
LIBRARY := awt_headless, \
|
||||||
|
OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
|
||||||
|
SRC := $(LIBAWT_HEADLESS_DIRS), \
|
||||||
|
EXCLUDES := $(LIBAWT_HEADLESS_EXCLUDES), \
|
||||||
|
LANG := C, \
|
||||||
|
OPTIMIZATION := LOW, \
|
||||||
|
CFLAGS := $(CFLAGS_JDKLIB) \
|
||||||
|
-DHEADLESS=true \
|
||||||
|
-DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \
|
||||||
|
$(CUPS_CFLAGS) \
|
||||||
|
$(X_CFLAGS) \
|
||||||
|
$(LIBAWT_HEADLESS_CFLAGS), \
|
||||||
|
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/mapfile-vers, \
|
||||||
|
LDFLAGS := $(LDFLAGS_JDKLIB) \
|
||||||
|
$(call SET_SHARED_LIBRARY_ORIGIN), \
|
||||||
|
LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \
|
||||||
|
LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
|
||||||
|
LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
|
||||||
|
LDFLAGS_macosx := $(call SET_SHARED_LIBRARY_ORIGIN)., \
|
||||||
|
REORDER := $(LIBAWT_HEADLESS_REORDER), \
|
||||||
|
LDFLAGS_SUFFIX_linux := -ljvm -lawt -lm $(LIBDL) -ljava, \
|
||||||
|
LDFLAGS_SUFFIX_aix := -ljvm -lawt -ljava,\
|
||||||
|
LDFLAGS_SUFFIX_solaris := $(LIBDL) -ljvm -lawt -lm -ljava $(LIBCXX) -lc, \
|
||||||
|
OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libawt_headless, \
|
||||||
|
DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
|
||||||
|
|
||||||
|
$(BUILD_LIBAWT_HEADLESS): $(BUILD_LIBAWT)
|
||||||
|
|
||||||
|
TARGETS += $(BUILD_LIBAWT_HEADLESS)
|
||||||
|
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
LIBFONTMANAGER_SRC := $(JDK_TOPDIR)/src/java.desktop/share/native/libfontmanager \
|
LIBFONTMANAGER_SRC := $(JDK_TOPDIR)/src/java.desktop/share/native/libfontmanager \
|
||||||
$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libfontmanager
|
$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libfontmanager
|
||||||
LIBFONTMANAGER_CFLAGS := \
|
LIBFONTMANAGER_CFLAGS := \
|
||||||
@ -562,10 +633,6 @@ ifeq ($(OPENJDK_TARGET_OS), linux)
|
|||||||
BUILD_LIBFONTMANAGER_ExtensionSubtables.cpp_CXXFLAGS := -fno-strict-aliasing
|
BUILD_LIBFONTMANAGER_ExtensionSubtables.cpp_CXXFLAGS := -fno-strict-aliasing
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Libfontmanager doesn't actually need X_LIBS to link, but if building
|
|
||||||
# on a Solaris machine without X installed, using a devkit, linking
|
|
||||||
# to libawt_xawt will fail without the -L parameters from X_LIBS. Filter
|
|
||||||
# out the -R parameters since they aren't needed.
|
|
||||||
$(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER, \
|
$(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER, \
|
||||||
LIBRARY := fontmanager, \
|
LIBRARY := fontmanager, \
|
||||||
OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
|
OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
|
||||||
@ -583,9 +650,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER, \
|
|||||||
LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \
|
LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \
|
||||||
LDFLAGS_SUFFIX := $(BUILD_LIBFONTMANAGER_FONTLIB), \
|
LDFLAGS_SUFFIX := $(BUILD_LIBFONTMANAGER_FONTLIB), \
|
||||||
LDFLAGS_SUFFIX_linux := -lawt $(LIBM) $(LIBCXX) -ljava -ljvm -lc, \
|
LDFLAGS_SUFFIX_linux := -lawt $(LIBM) $(LIBCXX) -ljava -ljvm -lc, \
|
||||||
LDFLAGS_SUFFIX_solaris := $(filter-out -R%, $(X_LIBS)) \
|
LDFLAGS_SUFFIX_solaris := -lawt -lawt_headless -lc $(LIBM) $(LIBCXX) -ljava -ljvm, \
|
||||||
-lawt -lawt_xawt -lc $(LIBM) $(LIBCXX) -ljava -ljvm, \
|
LDFLAGS_SUFFIX_aix := -lawt -lawt_headless $(LIBM) $(LIBCXX) -ljava -ljvm,\
|
||||||
LDFLAGS_SUFFIX_aix := -lawt -lawt_xawt $(LIBM) $(LIBCXX) -ljava -ljvm,\
|
|
||||||
LDFLAGS_SUFFIX_macosx := -lawt $(LIBM) $(LIBCXX) -undefined dynamic_lookup \
|
LDFLAGS_SUFFIX_macosx := -lawt $(LIBM) $(LIBCXX) -undefined dynamic_lookup \
|
||||||
-ljava -ljvm, \
|
-ljava -ljvm, \
|
||||||
LDFLAGS_SUFFIX_windows := $(WIN_JAVA_LIB) advapi32.lib user32.lib gdi32.lib \
|
LDFLAGS_SUFFIX_windows := $(WIN_JAVA_LIB) advapi32.lib user32.lib gdi32.lib \
|
||||||
@ -601,7 +667,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER, \
|
|||||||
$(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT)
|
$(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT)
|
||||||
|
|
||||||
ifneq (, $(findstring $(OPENJDK_TARGET_OS), solaris aix))
|
ifneq (, $(findstring $(OPENJDK_TARGET_OS), solaris aix))
|
||||||
$(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT_XAWT)
|
$(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT_HEADLESS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
TARGETS += $(BUILD_LIBFONTMANAGER)
|
TARGETS += $(BUILD_LIBFONTMANAGER)
|
||||||
@ -723,77 +789,6 @@ TARGETS += $(BUILD_LIBJAWT)
|
|||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ifeq ($(BUILD_HEADLESS), true)
|
|
||||||
# Mac and Windows only use the native AWT lib, do not build libawt_headless
|
|
||||||
ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx),)
|
|
||||||
|
|
||||||
LIBAWT_HEADLESS_DIRS := $(JDK_TOPDIR)/src/java.desktop/unix/native/libawt_headless/awt \
|
|
||||||
$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \
|
|
||||||
$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/java2d/opengl \
|
|
||||||
$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/java2d/x11 \
|
|
||||||
$(JDK_TOPDIR)/src/java.desktop/share/native/common/java2d/opengl \
|
|
||||||
$(JDK_TOPDIR)/src/java.desktop/share/native/common/font \
|
|
||||||
#
|
|
||||||
|
|
||||||
LIBAWT_HEADLESS_EXCLUDES := medialib
|
|
||||||
LIBAWT_HEADLESS_CFLAGS := -I$(SUPPORT_OUTPUTDIR)/headers/java.desktop \
|
|
||||||
$(addprefix -I, $(LIBAWT_HEADLESS_DIRS)) \
|
|
||||||
-I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d \
|
|
||||||
-I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d/loops \
|
|
||||||
-I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/awt/image/cvutils \
|
|
||||||
-I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d/pipe \
|
|
||||||
-I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/awt/image \
|
|
||||||
-I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libawt/java2d \
|
|
||||||
-I$(JDK_TOPDIR)/src/java.desktop/share/native/common/font \
|
|
||||||
-I$(JDK_TOPDIR)/src/java.desktop/share/native/common/awt/debug \
|
|
||||||
-I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/font \
|
|
||||||
-I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libsunwjdga/ \
|
|
||||||
$(LIBJAVA_HEADER_FLAGS) \
|
|
||||||
#
|
|
||||||
|
|
||||||
LIBAWT_HEADLESS_REORDER :=
|
|
||||||
ifeq ($(OPENJDK_TARGET_OS), solaris)
|
|
||||||
ifneq ($(OPENJDK_TARGET_CPU), x86_64)
|
|
||||||
LIBAWT_HEADLESS_REORDER := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/reorder-$(OPENJDK_TARGET_CPU)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(eval $(call SetupNativeCompilation,BUILD_LIBAWT_HEADLESS, \
|
|
||||||
LIBRARY := awt_headless, \
|
|
||||||
OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
|
|
||||||
SRC := $(LIBAWT_HEADLESS_DIRS), \
|
|
||||||
EXCLUDES := $(LIBAWT_HEADLESS_EXCLUDES), \
|
|
||||||
LANG := C, \
|
|
||||||
OPTIMIZATION := LOW, \
|
|
||||||
CFLAGS := $(CFLAGS_JDKLIB) \
|
|
||||||
-DHEADLESS=true \
|
|
||||||
-DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \
|
|
||||||
$(CUPS_CFLAGS) \
|
|
||||||
$(X_CFLAGS) \
|
|
||||||
$(LIBAWT_HEADLESS_CFLAGS), \
|
|
||||||
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/mapfile-vers, \
|
|
||||||
LDFLAGS := $(LDFLAGS_JDKLIB) \
|
|
||||||
$(call SET_SHARED_LIBRARY_ORIGIN), \
|
|
||||||
LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \
|
|
||||||
LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
|
|
||||||
LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
|
|
||||||
LDFLAGS_macosx := $(call SET_SHARED_LIBRARY_ORIGIN)., \
|
|
||||||
REORDER := $(LIBAWT_HEADLESS_REORDER), \
|
|
||||||
LDFLAGS_SUFFIX_linux := -ljvm -lawt -lm $(LIBDL) -ljava, \
|
|
||||||
LDFLAGS_SUFFIX_aix := -ljvm -lawt -ljava,\
|
|
||||||
LDFLAGS_SUFFIX_solaris := $(LIBDL) -ljvm -lawt -lm -ljava $(LIBCXX) -lc, \
|
|
||||||
OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libawt_headless, \
|
|
||||||
DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
|
|
||||||
|
|
||||||
$(BUILD_LIBAWT_HEADLESS): $(BUILD_LIBAWT)
|
|
||||||
|
|
||||||
TARGETS += $(BUILD_LIBAWT_HEADLESS)
|
|
||||||
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
ifndef BUILD_HEADLESS_ONLY
|
ifndef BUILD_HEADLESS_ONLY
|
||||||
|
|
||||||
LIBSPLASHSCREEN_DIRS := \
|
LIBSPLASHSCREEN_DIRS := \
|
||||||
|
@ -271,6 +271,11 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
|
|||||||
# Staticically link with c runtime on windows.
|
# Staticically link with c runtime on windows.
|
||||||
LIBJLI_CFLAGS := $(filter-out -MD, $(LIBJLI_CFLAGS))
|
LIBJLI_CFLAGS := $(filter-out -MD, $(LIBJLI_CFLAGS))
|
||||||
LIBJLI_OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE)
|
LIBJLI_OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE)
|
||||||
|
# Supply the name of the C runtime lib.
|
||||||
|
LIBJLI_CFLAGS += -DMSVCR_DLL_NAME='"$(notdir $(MSVCR_DLL))"'
|
||||||
|
ifneq ($(MSVCP_DLL), )
|
||||||
|
LIBJLI_CFLAGS += -DMSVCP_DLL_NAME='"$(notdir $(MSVCP_DLL))"'
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
LIBJLI_OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE)/jli
|
LIBJLI_OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE)/jli
|
||||||
endif
|
endif
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
java.base
|
java.base
|
||||||
java.compiler
|
java.compiler
|
||||||
|
java.datatransfer
|
||||||
java.desktop
|
java.desktop
|
||||||
java.instrument
|
java.instrument
|
||||||
java.logging
|
java.logging
|
||||||
|
@ -265,26 +265,17 @@ LoadMSVCRT()
|
|||||||
* assumed to be present in the "JRE path" directory. If it is not found
|
* assumed to be present in the "JRE path" directory. If it is not found
|
||||||
* there (or "JRE path" fails to resolve), skip the explicit load and let
|
* there (or "JRE path" fails to resolve), skip the explicit load and let
|
||||||
* nature take its course, which is likely to be a failure to execute.
|
* nature take its course, which is likely to be a failure to execute.
|
||||||
* This is clearly completely specific to the exact compiler version
|
* The makefiles will provide the correct lib contained in quotes in the
|
||||||
* which isn't very nice, but its hardly the only place.
|
* macro MSVCR_DLL_NAME.
|
||||||
* No attempt to look for compiler versions in between 2003 and 2010
|
|
||||||
* as we aren't supporting building with those.
|
|
||||||
*/
|
*/
|
||||||
#ifdef _MSC_VER
|
#ifdef MSVCR_DLL_NAME
|
||||||
#if _MSC_VER < 1400
|
|
||||||
#define CRT_DLL "msvcr71.dll"
|
|
||||||
#endif
|
|
||||||
#if _MSC_VER >= 1600
|
|
||||||
#define CRT_DLL "msvcr100.dll"
|
|
||||||
#endif
|
|
||||||
#ifdef CRT_DLL
|
|
||||||
if (GetJREPath(crtpath, MAXPATHLEN)) {
|
if (GetJREPath(crtpath, MAXPATHLEN)) {
|
||||||
if (JLI_StrLen(crtpath) + JLI_StrLen("\\bin\\") +
|
if (JLI_StrLen(crtpath) + JLI_StrLen("\\bin\\") +
|
||||||
JLI_StrLen(CRT_DLL) >= MAXPATHLEN) {
|
JLI_StrLen(MSVCR_DLL_NAME) >= MAXPATHLEN) {
|
||||||
JLI_ReportErrorMessage(JRE_ERROR11);
|
JLI_ReportErrorMessage(JRE_ERROR11);
|
||||||
return JNI_FALSE;
|
return JNI_FALSE;
|
||||||
}
|
}
|
||||||
(void)JLI_StrCat(crtpath, "\\bin\\" CRT_DLL); /* Add crt dll */
|
(void)JLI_StrCat(crtpath, "\\bin\\" MSVCR_DLL_NAME); /* Add crt dll */
|
||||||
JLI_TraceLauncher("CRT path is %s\n", crtpath);
|
JLI_TraceLauncher("CRT path is %s\n", crtpath);
|
||||||
if (_access(crtpath, 0) == 0) {
|
if (_access(crtpath, 0) == 0) {
|
||||||
if (LoadLibrary(crtpath) == 0) {
|
if (LoadLibrary(crtpath) == 0) {
|
||||||
@ -293,8 +284,24 @@ LoadMSVCRT()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* CRT_DLL */
|
#endif /* MSVCR_DLL_NAME */
|
||||||
#endif /* _MSC_VER */
|
#ifdef MSVCP_DLL_NAME
|
||||||
|
if (GetJREPath(crtpath, MAXPATHLEN)) {
|
||||||
|
if (JLI_StrLen(crtpath) + JLI_StrLen("\\bin\\") +
|
||||||
|
JLI_StrLen(MSVCP_DLL_NAME) >= MAXPATHLEN) {
|
||||||
|
JLI_ReportErrorMessage(JRE_ERROR11);
|
||||||
|
return JNI_FALSE;
|
||||||
|
}
|
||||||
|
(void)JLI_StrCat(crtpath, "\\bin\\" MSVCP_DLL_NAME); /* Add prt dll */
|
||||||
|
JLI_TraceLauncher("PRT path is %s\n", crtpath);
|
||||||
|
if (_access(crtpath, 0) == 0) {
|
||||||
|
if (LoadLibrary(crtpath) == 0) {
|
||||||
|
JLI_ReportErrorMessage(DLL_ERROR4, crtpath);
|
||||||
|
return JNI_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* MSVCP_DLL_NAME */
|
||||||
loaded = 1;
|
loaded = 1;
|
||||||
}
|
}
|
||||||
return JNI_TRUE;
|
return JNI_TRUE;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -46,8 +46,6 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@code DataFlavor} provides meta information about data. {@code DataFlavor}
|
* A {@code DataFlavor} provides meta information about data. {@code DataFlavor}
|
||||||
* is typically used to access data on the clipboard, or during
|
* is typically used to access data on the clipboard, or during
|
||||||
@ -137,7 +135,7 @@ public class DataFlavor implements Externalizable, Cloneable {
|
|||||||
try {
|
try {
|
||||||
SecurityManager sm = System.getSecurityManager();
|
SecurityManager sm = System.getSecurityManager();
|
||||||
if (sm != null) {
|
if (sm != null) {
|
||||||
sm.checkPermission(GET_CLASSLOADER_PERMISSION);
|
sm.checkPermission(new RuntimePermission("getClassLoader"));
|
||||||
}
|
}
|
||||||
ClassLoader loader = ClassLoader.getSystemClassLoader();
|
ClassLoader loader = ClassLoader.getSystemClassLoader();
|
||||||
try {
|
try {
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -215,7 +215,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
|
|||||||
line = line.substring(0, line.length() - 1) + reader.readLine().trim();
|
line = line.substring(0, line.length() - 1) + reader.readLine().trim();
|
||||||
}
|
}
|
||||||
int delimiterPosition = line.indexOf('=');
|
int delimiterPosition = line.indexOf('=');
|
||||||
String key = line.substring(0, delimiterPosition).replaceAll("\\ ", " ");
|
String key = line.substring(0, delimiterPosition).replace("\\ ", " ");
|
||||||
String[] values = line.substring(delimiterPosition + 1, line.length()).split(",");
|
String[] values = line.substring(delimiterPosition + 1, line.length()).split(",");
|
||||||
for (String value : values) {
|
for (String value : values) {
|
||||||
try {
|
try {
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -68,8 +68,9 @@ public abstract class AquaBorder implements Border, UIResource {
|
|||||||
painter.state.set(size);
|
painter.state.set(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Insets getBorderInsets(final Component c) {
|
public Insets getBorderInsets(final Component c) {
|
||||||
return sizeVariant.margins;
|
return (Insets) sizeVariant.margins.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AquaBorder deriveBorderForSize(final Size size) {
|
protected AquaBorder deriveBorderForSize(final Size size) {
|
||||||
@ -130,8 +131,10 @@ public abstract class AquaBorder implements Border, UIResource {
|
|||||||
return (focusable != null && focusable instanceof JComponent && ((JComponent)focusable).hasFocus());
|
return (focusable != null && focusable instanceof JComponent && ((JComponent)focusable).hasFocus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isBorderOpaque() { return false; }
|
public boolean isBorderOpaque() { return false; }
|
||||||
|
|
||||||
|
@Override
|
||||||
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int w, final int h) {
|
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int w, final int h) {
|
||||||
painter.paint(g, c, x, y, w, h);
|
painter.paint(g, c, x, y, w, h);
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ public class AquaComboBoxUI extends BasicComboBoxUI implements Sizeable {
|
|||||||
|
|
||||||
actionMap.put("aquaSelectNext", highlightNextAction);
|
actionMap.put("aquaSelectNext", highlightNextAction);
|
||||||
actionMap.put("aquaSelectPrevious", highlightPreviousAction);
|
actionMap.put("aquaSelectPrevious", highlightPreviousAction);
|
||||||
actionMap.put("aquaEnterPressed", triggerSelectionAction);
|
actionMap.put("enterPressed", triggerSelectionAction);
|
||||||
actionMap.put("aquaSpacePressed", toggleSelectionAction);
|
actionMap.put("aquaSpacePressed", toggleSelectionAction);
|
||||||
|
|
||||||
actionMap.put("aquaSelectHome", highlightFirstAction);
|
actionMap.put("aquaSelectHome", highlightFirstAction);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -1098,8 +1098,15 @@ public class AquaFileChooserUI extends FileChooserUI {
|
|||||||
super(f);
|
super(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component getTableCellRendererComponent(final JTable list, final Object value, final boolean isSelected, final boolean cellHasFocus, final int index, final int col) {
|
public Component getTableCellRendererComponent(final JTable list,
|
||||||
super.getTableCellRendererComponent(list, value, isSelected, false, index, col); // No focus border, thanks
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final boolean cellHasFocus,
|
||||||
|
final int index,
|
||||||
|
final int col) {
|
||||||
|
super.getTableCellRendererComponent(list, value, isSelected, false,
|
||||||
|
index,
|
||||||
|
col); // No focus border, thanks
|
||||||
final File file = (File)value;
|
final File file = (File)value;
|
||||||
final JFileChooser fc = getFileChooser();
|
final JFileChooser fc = getFileChooser();
|
||||||
setText(fc.getName(file));
|
setText(fc.getName(file));
|
||||||
@ -1115,8 +1122,14 @@ public class AquaFileChooserUI extends FileChooserUI {
|
|||||||
super(f);
|
super(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component getTableCellRendererComponent(final JTable list, final Object value, final boolean isSelected, final boolean cellHasFocus, final int index, final int col) {
|
public Component getTableCellRendererComponent(final JTable list,
|
||||||
super.getTableCellRendererComponent(list, value, isSelected, false, index, col);
|
final Object value,
|
||||||
|
final boolean isSelected,
|
||||||
|
final boolean cellHasFocus,
|
||||||
|
final int index,
|
||||||
|
final int col) {
|
||||||
|
super.getTableCellRendererComponent(list, value, isSelected, false,
|
||||||
|
index, col);
|
||||||
final File file = (File)fFileList.getValueAt(index, 0);
|
final File file = (File)fFileList.getValueAt(index, 0);
|
||||||
setEnabled(isSelectableInList(file));
|
setEnabled(isSelectableInList(file));
|
||||||
final DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.SHORT);
|
final DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.SHORT);
|
||||||
@ -1132,14 +1145,17 @@ public class AquaFileChooserUI extends FileChooserUI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Dimension getPreferredSize(final JComponent c) {
|
public Dimension getPreferredSize(final JComponent c) {
|
||||||
return PREF_SIZE;
|
return new Dimension(PREF_WIDTH, PREF_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Dimension getMinimumSize(final JComponent c) {
|
public Dimension getMinimumSize(final JComponent c) {
|
||||||
return MIN_SIZE;
|
return new Dimension(MIN_WIDTH, MIN_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Dimension getMaximumSize(final JComponent c) {
|
public Dimension getMaximumSize(final JComponent c) {
|
||||||
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
@ -1819,12 +1835,8 @@ public class AquaFileChooserUI extends FileChooserUI {
|
|||||||
|
|
||||||
private static final int PREF_WIDTH = 550;
|
private static final int PREF_WIDTH = 550;
|
||||||
private static final int PREF_HEIGHT = 400;
|
private static final int PREF_HEIGHT = 400;
|
||||||
private static final Dimension PREF_SIZE = new Dimension(PREF_WIDTH, PREF_HEIGHT);
|
|
||||||
|
|
||||||
private static final int MIN_WIDTH = 400;
|
private static final int MIN_WIDTH = 400;
|
||||||
private static final int MIN_HEIGHT = 250;
|
private static final int MIN_HEIGHT = 250;
|
||||||
private static final Dimension MIN_SIZE = new Dimension(MIN_WIDTH, MIN_HEIGHT);
|
|
||||||
|
|
||||||
private static final int LIST_MIN_WIDTH = 400;
|
private static final int LIST_MIN_WIDTH = 400;
|
||||||
private static final int LIST_MIN_HEIGHT = 100;
|
private static final int LIST_MIN_HEIGHT = 100;
|
||||||
private static final Dimension LIST_MIN_SIZE = new Dimension(LIST_MIN_WIDTH, LIST_MIN_HEIGHT);
|
private static final Dimension LIST_MIN_SIZE = new Dimension(LIST_MIN_WIDTH, LIST_MIN_HEIGHT);
|
||||||
|
@ -214,7 +214,7 @@ public class AquaKeyBindings {
|
|||||||
"PAGE_DOWN", "aquaSelectPageDown",
|
"PAGE_DOWN", "aquaSelectPageDown",
|
||||||
"HOME", "aquaSelectHome",
|
"HOME", "aquaSelectHome",
|
||||||
"END", "aquaSelectEnd",
|
"END", "aquaSelectEnd",
|
||||||
"ENTER", "aquaEnterPressed",
|
"ENTER", "enterPressed",
|
||||||
"UP", "aquaSelectPrevious",
|
"UP", "aquaSelectPrevious",
|
||||||
"KP_UP", "aquaSelectPrevious",
|
"KP_UP", "aquaSelectPrevious",
|
||||||
"DOWN", "aquaSelectNext",
|
"DOWN", "aquaSelectNext",
|
||||||
|
@ -77,14 +77,72 @@ public final class CFont extends PhysicalFont {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static native long createNativeFont(final String nativeFontName,
|
private static native long createNativeFont(final String nativeFontName,
|
||||||
final int style,
|
final int style);
|
||||||
final boolean isFakeItalic);
|
|
||||||
private static native void disposeNativeFont(final long nativeFontPtr);
|
private static native void disposeNativeFont(final long nativeFontPtr);
|
||||||
|
|
||||||
private boolean isFakeItalic;
|
private boolean isFakeItalic;
|
||||||
private String nativeFontName;
|
private String nativeFontName;
|
||||||
private long nativeFontPtr;
|
private long nativeFontPtr;
|
||||||
|
|
||||||
|
private native float getWidthNative(final long nativeFontPtr);
|
||||||
|
private native float getWeightNative(final long nativeFontPtr);
|
||||||
|
|
||||||
|
private int fontWidth = -1;
|
||||||
|
private int fontWeight = -1;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getWidth() {
|
||||||
|
if (fontWidth == -1) {
|
||||||
|
// Apple use a range of -1 -> +1, where 0.0 is normal
|
||||||
|
// OpenType uses a % range from 50% -> 200% where 100% is normal
|
||||||
|
// and maps these onto the integer values 1->9.
|
||||||
|
// Since that is what Font2D.getWidth() expects, remap to that.
|
||||||
|
float fw = getWidthNative(getNativeFontPtr());
|
||||||
|
if (fw == 0.0) { // short cut the common case
|
||||||
|
fontWidth = Font2D.FWIDTH_NORMAL;
|
||||||
|
return fontWidth;
|
||||||
|
}
|
||||||
|
fw += 1.0; fw *= 100.0;
|
||||||
|
if (fw <= 50.0) {
|
||||||
|
fontWidth = 1;
|
||||||
|
} else if (fw <= 62.5) {
|
||||||
|
fontWidth = 2;
|
||||||
|
} else if (fw <= 75.0) {
|
||||||
|
fontWidth = 3;
|
||||||
|
} else if (fw <= 87.5) {
|
||||||
|
fontWidth = 4;
|
||||||
|
} else if (fw <= 100.0) {
|
||||||
|
fontWidth = 5;
|
||||||
|
} else if (fw <= 112.5) {
|
||||||
|
fontWidth = 6;
|
||||||
|
} else if (fw <= 125.0) {
|
||||||
|
fontWidth = 7;
|
||||||
|
} else if (fw <= 150.0) {
|
||||||
|
fontWidth = 8;
|
||||||
|
} else {
|
||||||
|
fontWidth = 9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fontWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getWeight() {
|
||||||
|
if (fontWeight == -1) {
|
||||||
|
// Apple use a range of -1 -> +1, where 0 is medium/regular
|
||||||
|
// Map this on to the OpenType range of 100->900 where
|
||||||
|
// 500 is medium/regular.
|
||||||
|
// We'll actually map to 0->1000 but that's close enough.
|
||||||
|
float fw = getWeightNative(getNativeFontPtr());
|
||||||
|
if (fw == 0) {
|
||||||
|
return Font2D.FWEIGHT_NORMAL;
|
||||||
|
}
|
||||||
|
fw += 1.0; fw *= 500;
|
||||||
|
fontWeight = (int)fw;
|
||||||
|
}
|
||||||
|
return fontWeight;
|
||||||
|
}
|
||||||
|
|
||||||
// this constructor is called from CFontWrapper.m
|
// this constructor is called from CFontWrapper.m
|
||||||
public CFont(String name) {
|
public CFont(String name) {
|
||||||
this(name, name);
|
this(name, name);
|
||||||
@ -94,10 +152,11 @@ public final class CFont extends PhysicalFont {
|
|||||||
handle = new Font2DHandle(this);
|
handle = new Font2DHandle(this);
|
||||||
fullName = name;
|
fullName = name;
|
||||||
familyName = inFamilyName;
|
familyName = inFamilyName;
|
||||||
nativeFontName = inFamilyName;
|
nativeFontName = fullName;
|
||||||
setStyle();
|
setStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called from CFontManager too */
|
||||||
public CFont(CFont other, String logicalFamilyName) {
|
public CFont(CFont other, String logicalFamilyName) {
|
||||||
handle = new Font2DHandle(this);
|
handle = new Font2DHandle(this);
|
||||||
fullName = logicalFamilyName;
|
fullName = logicalFamilyName;
|
||||||
@ -109,6 +168,7 @@ public final class CFont extends PhysicalFont {
|
|||||||
|
|
||||||
public CFont createItalicVariant() {
|
public CFont createItalicVariant() {
|
||||||
CFont font = new CFont(this, familyName);
|
CFont font = new CFont(this, familyName);
|
||||||
|
font.nativeFontName = fullName;
|
||||||
font.fullName =
|
font.fullName =
|
||||||
fullName + (style == Font.BOLD ? "" : "-") + "Italic-Derived";
|
fullName + (style == Font.BOLD ? "" : "-") + "Italic-Derived";
|
||||||
font.style |= Font.ITALIC;
|
font.style |= Font.ITALIC;
|
||||||
@ -118,7 +178,7 @@ public final class CFont extends PhysicalFont {
|
|||||||
|
|
||||||
protected synchronized long getNativeFontPtr() {
|
protected synchronized long getNativeFontPtr() {
|
||||||
if (nativeFontPtr == 0L) {
|
if (nativeFontPtr == 0L) {
|
||||||
nativeFontPtr = createNativeFont(nativeFontName, style, isFakeItalic);
|
nativeFontPtr = createNativeFont(nativeFontName, style);
|
||||||
}
|
}
|
||||||
return nativeFontPtr;
|
return nativeFontPtr;
|
||||||
}
|
}
|
||||||
|
@ -252,13 +252,42 @@ public final class CFontManager extends SunFontManager {
|
|||||||
final CFont font = new CFont(fontName, fontFamilyName);
|
final CFont font = new CFont(fontName, fontFamilyName);
|
||||||
|
|
||||||
registerGenericFont(font);
|
registerGenericFont(font);
|
||||||
|
}
|
||||||
|
|
||||||
if ((font.getStyle() & Font.ITALIC) == 0) {
|
void registerItalicDerived() {
|
||||||
registerGenericFont(font.createItalicVariant(), true);
|
FontFamily[] famArr = FontFamily.getAllFontFamilies();
|
||||||
|
for (int i=0; i<famArr.length; i++) {
|
||||||
|
FontFamily family = famArr[i];
|
||||||
|
|
||||||
|
Font2D f2dPlain = family.getFont(Font.PLAIN);
|
||||||
|
if (f2dPlain != null && !(f2dPlain instanceof CFont)) continue;
|
||||||
|
Font2D f2dBold = family.getFont(Font.BOLD);
|
||||||
|
if (f2dBold != null && !(f2dBold instanceof CFont)) continue;
|
||||||
|
Font2D f2dItalic = family.getFont(Font.ITALIC);
|
||||||
|
if (f2dItalic != null && !(f2dItalic instanceof CFont)) continue;
|
||||||
|
Font2D f2dBoldItalic = family.getFont(Font.BOLD|Font.ITALIC);
|
||||||
|
if (f2dBoldItalic != null && !(f2dBoldItalic instanceof CFont)) continue;
|
||||||
|
|
||||||
|
CFont plain = (CFont)f2dPlain;
|
||||||
|
CFont bold = (CFont)f2dBold;
|
||||||
|
CFont italic = (CFont)f2dItalic;
|
||||||
|
CFont boldItalic = (CFont)f2dBoldItalic;
|
||||||
|
|
||||||
|
if (bold == null) bold = plain;
|
||||||
|
if (plain == null && bold == null) continue;
|
||||||
|
if (italic != null && boldItalic != null) continue;
|
||||||
|
if (plain != null && italic == null) {
|
||||||
|
registerGenericFont(plain.createItalicVariant(), true);
|
||||||
|
}
|
||||||
|
if (bold != null && boldItalic == null) {
|
||||||
|
registerGenericFont(bold.createItalicVariant(), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Object waitForFontsToBeLoaded = new Object();
|
Object waitForFontsToBeLoaded = new Object();
|
||||||
|
private boolean loadedAllFonts = false;
|
||||||
|
|
||||||
public void loadFonts()
|
public void loadFonts()
|
||||||
{
|
{
|
||||||
synchronized(waitForFontsToBeLoaded)
|
synchronized(waitForFontsToBeLoaded)
|
||||||
@ -267,7 +296,11 @@ public final class CFontManager extends SunFontManager {
|
|||||||
java.security.AccessController.doPrivileged(
|
java.security.AccessController.doPrivileged(
|
||||||
new java.security.PrivilegedAction<Object>() {
|
new java.security.PrivilegedAction<Object>() {
|
||||||
public Object run() {
|
public Object run() {
|
||||||
loadNativeFonts();
|
if (!loadedAllFonts) {
|
||||||
|
loadNativeFonts();
|
||||||
|
registerItalicDerived();
|
||||||
|
loadedAllFonts = true;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -890,9 +890,9 @@ JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
|
|||||||
// text, or 'text in progress'. We also need to send the event if we get an insert text out of the blue!
|
// text, or 'text in progress'. We also need to send the event if we get an insert text out of the blue!
|
||||||
// (i.e., when the user uses the Character palette or Inkwell), or when the string to insert is a complex
|
// (i.e., when the user uses the Character palette or Inkwell), or when the string to insert is a complex
|
||||||
// Unicode value.
|
// Unicode value.
|
||||||
NSUInteger utf8Length = [aString lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
|
NSUInteger utf16Length = [aString lengthOfBytesUsingEncoding:NSUTF16StringEncoding];
|
||||||
|
|
||||||
if ([self hasMarkedText] || !fProcessingKeystroke || (utf8Length > 1)) {
|
if ([self hasMarkedText] || !fProcessingKeystroke || (utf16Length > 2)) {
|
||||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||||
|
|
||||||
static JNF_MEMBER_CACHE(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V");
|
static JNF_MEMBER_CACHE(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V");
|
||||||
|
@ -35,15 +35,11 @@
|
|||||||
#import "AWTStrike.h"
|
#import "AWTStrike.h"
|
||||||
#import "CoreTextSupport.h"
|
#import "CoreTextSupport.h"
|
||||||
|
|
||||||
|
|
||||||
#define DEBUG
|
|
||||||
|
|
||||||
@implementation AWTFont
|
@implementation AWTFont
|
||||||
|
|
||||||
- (id) initWithFont:(NSFont *)font isFakeItalic:(BOOL)isFakeItalic {
|
- (id) initWithFont:(NSFont *)font {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
fIsFakeItalic = isFakeItalic;
|
|
||||||
fFont = [font retain];
|
fFont = [font retain];
|
||||||
fNativeCGFont = CTFontCopyGraphicsFont((CTFontRef)font, NULL);
|
fNativeCGFont = CTFontCopyGraphicsFont((CTFontRef)font, NULL);
|
||||||
}
|
}
|
||||||
@ -72,7 +68,6 @@
|
|||||||
|
|
||||||
+ (AWTFont *) awtFontForName:(NSString *)name
|
+ (AWTFont *) awtFontForName:(NSString *)name
|
||||||
style:(int)style
|
style:(int)style
|
||||||
isFakeItalic:(BOOL)isFakeItalic
|
|
||||||
{
|
{
|
||||||
// create font with family & size
|
// create font with family & size
|
||||||
NSFont *nsFont = [NSFont fontWithName:name size:1.0];
|
NSFont *nsFont = [NSFont fontWithName:name size:1.0];
|
||||||
@ -95,7 +90,7 @@
|
|||||||
nsFont = [[NSFontManager sharedFontManager] convertFont:nsFont toHaveTrait:NSBoldFontMask];
|
nsFont = [[NSFontManager sharedFontManager] convertFont:nsFont toHaveTrait:NSBoldFontMask];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [[[AWTFont alloc] initWithFont:nsFont isFakeItalic:isFakeItalic] autorelease];
|
return [[[AWTFont alloc] initWithFont:nsFont] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSFont *) nsFontForJavaFont:(jobject)javaFont env:(JNIEnv *)env {
|
+ (NSFont *) nsFontForJavaFont:(jobject)javaFont env:(JNIEnv *)env {
|
||||||
@ -354,7 +349,7 @@ JNF_COCOA_EXIT(env);
|
|||||||
JNIEXPORT jlong JNICALL
|
JNIEXPORT jlong JNICALL
|
||||||
Java_sun_font_CFont_createNativeFont
|
Java_sun_font_CFont_createNativeFont
|
||||||
(JNIEnv *env, jclass clazz,
|
(JNIEnv *env, jclass clazz,
|
||||||
jstring nativeFontName, jint style, jboolean isFakeItalic)
|
jstring nativeFontName, jint style)
|
||||||
{
|
{
|
||||||
AWTFont *awtFont = nil;
|
AWTFont *awtFont = nil;
|
||||||
|
|
||||||
@ -362,8 +357,7 @@ JNF_COCOA_ENTER(env);
|
|||||||
|
|
||||||
awtFont =
|
awtFont =
|
||||||
[AWTFont awtFontForName:JNFJavaToNSString(env, nativeFontName)
|
[AWTFont awtFontForName:JNFJavaToNSString(env, nativeFontName)
|
||||||
style:style
|
style:style]; // autoreleased
|
||||||
isFakeItalic:isFakeItalic]; // autoreleased
|
|
||||||
|
|
||||||
if (awtFont) {
|
if (awtFont) {
|
||||||
CFRetain(awtFont); // GC
|
CFRetain(awtFont); // GC
|
||||||
@ -374,6 +368,52 @@ JNF_COCOA_EXIT(env);
|
|||||||
return ptr_to_jlong(awtFont);
|
return ptr_to_jlong(awtFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: sun_font_CFont
|
||||||
|
* Method: getWidthNative
|
||||||
|
* Signature: (J)F
|
||||||
|
*/
|
||||||
|
JNIEXPORT jfloat JNICALL
|
||||||
|
Java_sun_font_CFont_getWidthNative
|
||||||
|
(JNIEnv *env, jobject cfont, jlong awtFontPtr)
|
||||||
|
{
|
||||||
|
float widthVal;
|
||||||
|
JNF_COCOA_ENTER(env);
|
||||||
|
|
||||||
|
AWTFont *awtFont = (AWTFont *)jlong_to_ptr(awtFontPtr);
|
||||||
|
NSFont* nsFont = awtFont->fFont;
|
||||||
|
NSFontDescriptor *fontDescriptor = nsFont.fontDescriptor;
|
||||||
|
NSDictionary *fontTraits = [fontDescriptor objectForKey : NSFontTraitsAttribute];
|
||||||
|
NSNumber *width = [fontTraits objectForKey : NSFontWidthTrait];
|
||||||
|
widthVal = (float)[width floatValue];
|
||||||
|
|
||||||
|
JNF_COCOA_EXIT(env);
|
||||||
|
return (jfloat)widthVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: sun_font_CFont
|
||||||
|
* Method: getWeightNative
|
||||||
|
* Signature: (J)F
|
||||||
|
*/
|
||||||
|
JNIEXPORT jfloat JNICALL
|
||||||
|
Java_sun_font_CFont_getWeightNative
|
||||||
|
(JNIEnv *env, jobject cfont, jlong awtFontPtr)
|
||||||
|
{
|
||||||
|
float weightVal;
|
||||||
|
JNF_COCOA_ENTER(env);
|
||||||
|
|
||||||
|
AWTFont *awtFont = (AWTFont *)jlong_to_ptr(awtFontPtr);
|
||||||
|
NSFont* nsFont = awtFont->fFont;
|
||||||
|
NSFontDescriptor *fontDescriptor = nsFont.fontDescriptor;
|
||||||
|
NSDictionary *fontTraits = [fontDescriptor objectForKey : NSFontTraitsAttribute];
|
||||||
|
NSNumber *weight = [fontTraits objectForKey : NSFontWeightTrait];
|
||||||
|
weightVal = (float)[weight floatValue];
|
||||||
|
|
||||||
|
JNF_COCOA_EXIT(env);
|
||||||
|
return (jfloat)weightVal;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: sun_font_CFont
|
* Class: sun_font_CFont
|
||||||
* Method: disposeNativeFont
|
* Method: disposeNativeFont
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -43,8 +43,6 @@ import org.w3c.dom.Node;
|
|||||||
|
|
||||||
import java.awt.image.Raster;
|
import java.awt.image.Raster;
|
||||||
import java.awt.image.WritableRaster;
|
import java.awt.image.WritableRaster;
|
||||||
import java.awt.image.SampleModel;
|
|
||||||
import java.awt.image.DataBuffer;
|
|
||||||
import java.awt.image.DataBufferByte;
|
import java.awt.image.DataBufferByte;
|
||||||
import java.awt.image.ColorModel;
|
import java.awt.image.ColorModel;
|
||||||
import java.awt.image.IndexColorModel;
|
import java.awt.image.IndexColorModel;
|
||||||
@ -1048,7 +1046,13 @@ public class JPEGImageWriter extends ImageWriter {
|
|||||||
|
|
||||||
// Call the writer, who will call back for every scanline
|
// Call the writer, who will call back for every scanline
|
||||||
|
|
||||||
processImageStarted(currentImage);
|
clearAbortRequest();
|
||||||
|
cbLock.lock();
|
||||||
|
try {
|
||||||
|
processImageStarted(currentImage);
|
||||||
|
} finally {
|
||||||
|
cbLock.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
boolean aborted = false;
|
boolean aborted = false;
|
||||||
|
|
||||||
@ -1225,6 +1229,23 @@ public class JPEGImageWriter extends ImageWriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected synchronized void clearAbortRequest() {
|
||||||
|
setThreadLock();
|
||||||
|
try {
|
||||||
|
cbLock.check();
|
||||||
|
if (abortRequested()) {
|
||||||
|
super.clearAbortRequest();
|
||||||
|
// reset C structures
|
||||||
|
resetWriter(structPointer);
|
||||||
|
// reset the native destination
|
||||||
|
setDest(structPointer);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
clearThreadLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void resetInternalState() {
|
private void resetInternalState() {
|
||||||
// reset C structures
|
// reset C structures
|
||||||
resetWriter(structPointer);
|
resetWriter(structPointer);
|
||||||
@ -1652,7 +1673,7 @@ public class JPEGImageWriter extends ImageWriter {
|
|||||||
int vsamp0 = specs[0].VsamplingFactor;
|
int vsamp0 = specs[0].VsamplingFactor;
|
||||||
for (int i = 1; i < specs.length; i++) {
|
for (int i = 1; i < specs.length; i++) {
|
||||||
if ((specs[i].HsamplingFactor != hsamp0) ||
|
if ((specs[i].HsamplingFactor != hsamp0) ||
|
||||||
(specs[i].HsamplingFactor != hsamp0))
|
(specs[i].VsamplingFactor != vsamp0))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -100,7 +100,8 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
|||||||
private static Dimension prefListSize = new Dimension(75, 150);
|
private static Dimension prefListSize = new Dimension(75, 150);
|
||||||
|
|
||||||
private static Dimension PREF_SIZE = new Dimension(435, 360);
|
private static Dimension PREF_SIZE = new Dimension(435, 360);
|
||||||
private static Dimension MIN_SIZE = new Dimension(200, 300);
|
private static final int MIN_WIDTH = 200;
|
||||||
|
private static final int MIN_HEIGHT = 300;
|
||||||
|
|
||||||
private static Dimension ZERO_ACC_SIZE = new Dimension(1, 1);
|
private static Dimension ZERO_ACC_SIZE = new Dimension(1, 1);
|
||||||
|
|
||||||
@ -1052,6 +1053,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Dimension getPreferredSize(JComponent c) {
|
public Dimension getPreferredSize(JComponent c) {
|
||||||
Dimension prefSize = new Dimension(PREF_SIZE);
|
Dimension prefSize = new Dimension(PREF_SIZE);
|
||||||
JComponent accessory = getFileChooser().getAccessory();
|
JComponent accessory = getFileChooser().getAccessory();
|
||||||
@ -1067,10 +1069,12 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dimension getMinimumSize(JComponent x) {
|
@Override
|
||||||
return new Dimension(MIN_SIZE);
|
public Dimension getMinimumSize(JComponent x) {
|
||||||
|
return new Dimension(MIN_WIDTH, MIN_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Dimension getMaximumSize(JComponent x) {
|
public Dimension getMaximumSize(JComponent x) {
|
||||||
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -65,8 +65,8 @@ public class MotifFileChooserUI extends BasicFileChooserUI {
|
|||||||
|
|
||||||
private static Dimension WITH_ACCELERATOR_PREF_SIZE = new Dimension(650, 450);
|
private static Dimension WITH_ACCELERATOR_PREF_SIZE = new Dimension(650, 450);
|
||||||
private static Dimension PREF_SIZE = new Dimension(350, 450);
|
private static Dimension PREF_SIZE = new Dimension(350, 450);
|
||||||
private static Dimension MIN_SIZE = new Dimension(200, 300);
|
private static final int MIN_WIDTH = 200;
|
||||||
|
private static final int MIN_HEIGHT = 300;
|
||||||
private static Dimension PREF_ACC_SIZE = new Dimension(10, 10);
|
private static Dimension PREF_ACC_SIZE = new Dimension(10, 10);
|
||||||
private static Dimension ZERO_ACC_SIZE = new Dimension(1, 1);
|
private static Dimension ZERO_ACC_SIZE = new Dimension(1, 1);
|
||||||
|
|
||||||
@ -628,6 +628,7 @@ public class MotifFileChooserUI extends BasicFileChooserUI {
|
|||||||
return scrollpane;
|
return scrollpane;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Dimension getPreferredSize(JComponent c) {
|
public Dimension getPreferredSize(JComponent c) {
|
||||||
Dimension prefSize =
|
Dimension prefSize =
|
||||||
(getFileChooser().getAccessory() != null) ? WITH_ACCELERATOR_PREF_SIZE : PREF_SIZE;
|
(getFileChooser().getAccessory() != null) ? WITH_ACCELERATOR_PREF_SIZE : PREF_SIZE;
|
||||||
@ -640,10 +641,12 @@ public class MotifFileChooserUI extends BasicFileChooserUI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dimension getMinimumSize(JComponent x) {
|
@Override
|
||||||
return MIN_SIZE;
|
public Dimension getMinimumSize(JComponent x) {
|
||||||
|
return new Dimension(MIN_WIDTH, MIN_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Dimension getMaximumSize(JComponent x) {
|
public Dimension getMaximumSize(JComponent x) {
|
||||||
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,6 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
|
|||||||
|
|
||||||
private static int MIN_WIDTH = 425;
|
private static int MIN_WIDTH = 425;
|
||||||
private static int MIN_HEIGHT = 245;
|
private static int MIN_HEIGHT = 245;
|
||||||
private static Dimension MIN_SIZE = new Dimension(MIN_WIDTH, MIN_HEIGHT);
|
|
||||||
|
|
||||||
private static int LIST_PREF_WIDTH = 444;
|
private static int LIST_PREF_WIDTH = 444;
|
||||||
private static int LIST_PREF_HEIGHT = 138;
|
private static int LIST_PREF_HEIGHT = 138;
|
||||||
@ -642,6 +641,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
|
|||||||
* @return a <code>Dimension</code> specifying the preferred
|
* @return a <code>Dimension</code> specifying the preferred
|
||||||
* width and height of the file chooser
|
* width and height of the file chooser
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Dimension getPreferredSize(JComponent c) {
|
public Dimension getPreferredSize(JComponent c) {
|
||||||
int prefWidth = PREF_SIZE.width;
|
int prefWidth = PREF_SIZE.width;
|
||||||
Dimension d = c.getLayout().preferredLayoutSize(c);
|
Dimension d = c.getLayout().preferredLayoutSize(c);
|
||||||
@ -660,8 +660,9 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
|
|||||||
* @return a <code>Dimension</code> specifying the minimum
|
* @return a <code>Dimension</code> specifying the minimum
|
||||||
* width and height of the file chooser
|
* width and height of the file chooser
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Dimension getMinimumSize(JComponent c) {
|
public Dimension getMinimumSize(JComponent c) {
|
||||||
return MIN_SIZE;
|
return new Dimension(MIN_WIDTH, MIN_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -671,6 +672,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
|
|||||||
* @return a <code>Dimension</code> specifying the maximum
|
* @return a <code>Dimension</code> specifying the maximum
|
||||||
* width and height of the file chooser
|
* width and height of the file chooser
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Dimension getMaximumSize(JComponent c) {
|
public Dimension getMaximumSize(JComponent c) {
|
||||||
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -1690,15 +1690,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
|||||||
/* do nothing */
|
/* do nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Delete references from LightweightDispatcher of a heavyweight parent
|
|
||||||
*/
|
|
||||||
void clearLightweightDispatcherOnRemove(Component removedComponent) {
|
|
||||||
if (parent != null) {
|
|
||||||
parent.clearLightweightDispatcherOnRemove(removedComponent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated As of JDK version 1.1,
|
* @deprecated As of JDK version 1.1,
|
||||||
* replaced by <code>setVisible(boolean)</code>.
|
* replaced by <code>setVisible(boolean)</code>.
|
||||||
@ -6242,7 +6233,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
|||||||
/**
|
/**
|
||||||
* Indicates whether a class or its superclasses override coalesceEvents.
|
* Indicates whether a class or its superclasses override coalesceEvents.
|
||||||
* Must be called with lock on coalesceMap and privileged.
|
* Must be called with lock on coalesceMap and privileged.
|
||||||
* @see checkCoalsecing
|
* @see checkCoalescing
|
||||||
*/
|
*/
|
||||||
private static boolean isCoalesceEventsOverriden(Class<?> clazz) {
|
private static boolean isCoalesceEventsOverriden(Class<?> clazz) {
|
||||||
assert Thread.holdsLock(coalesceMap);
|
assert Thread.holdsLock(coalesceMap);
|
||||||
@ -7083,8 +7074,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
synchronized (getTreeLock()) {
|
synchronized (getTreeLock()) {
|
||||||
clearLightweightDispatcherOnRemove(this);
|
|
||||||
|
|
||||||
if (isFocusOwner() && KeyboardFocusManager.isAutoFocusTransferEnabledFor(this)) {
|
if (isFocusOwner() && KeyboardFocusManager.isAutoFocusTransferEnabledFor(this)) {
|
||||||
transferFocus(true);
|
transferFocus(true);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -41,6 +41,7 @@ import java.io.ObjectStreamField;
|
|||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
|
|
||||||
import java.util.EventListener;
|
import java.util.EventListener;
|
||||||
@ -3321,16 +3322,6 @@ public class Container extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
void clearLightweightDispatcherOnRemove(Component removedComponent) {
|
|
||||||
if (dispatcher != null) {
|
|
||||||
dispatcher.removeReferences(removedComponent);
|
|
||||||
} else {
|
|
||||||
//It is a Lightweight Container, should clear parent`s Dispatcher
|
|
||||||
super.clearLightweightDispatcherOnRemove(removedComponent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final Container getTraversalRoot() {
|
final Container getTraversalRoot() {
|
||||||
if (isFocusCycleRoot()) {
|
if (isFocusCycleRoot()) {
|
||||||
return findTraversalRoot();
|
return findTraversalRoot();
|
||||||
@ -4431,7 +4422,9 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener {
|
|||||||
|
|
||||||
LightweightDispatcher(Container nativeContainer) {
|
LightweightDispatcher(Container nativeContainer) {
|
||||||
this.nativeContainer = nativeContainer;
|
this.nativeContainer = nativeContainer;
|
||||||
mouseEventTarget = null;
|
mouseEventTarget = new WeakReference<>(null);
|
||||||
|
targetLastEntered = new WeakReference<>(null);
|
||||||
|
targetLastEnteredDT = new WeakReference<>(null);
|
||||||
eventMask = 0;
|
eventMask = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4442,9 +4435,9 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener {
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
//System.out.println("Disposing lw dispatcher");
|
//System.out.println("Disposing lw dispatcher");
|
||||||
stopListeningForOtherDrags();
|
stopListeningForOtherDrags();
|
||||||
mouseEventTarget = null;
|
mouseEventTarget.clear();
|
||||||
targetLastEntered = null;
|
targetLastEntered.clear();
|
||||||
targetLastEnteredDT = null;
|
targetLastEnteredDT.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -4531,65 +4524,62 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener {
|
|||||||
|
|
||||||
trackMouseEnterExit(mouseOver, e);
|
trackMouseEnterExit(mouseOver, e);
|
||||||
|
|
||||||
// 4508327 : MOUSE_CLICKED should only go to the recipient of
|
Component met = mouseEventTarget.get();
|
||||||
// the accompanying MOUSE_PRESSED, so don't reset mouseEventTarget on a
|
// 4508327 : MOUSE_CLICKED should only go to the recipient of
|
||||||
// MOUSE_CLICKED.
|
// the accompanying MOUSE_PRESSED, so don't reset mouseEventTarget on a
|
||||||
if (!isMouseGrab(e) && id != MouseEvent.MOUSE_CLICKED) {
|
// MOUSE_CLICKED.
|
||||||
mouseEventTarget = (mouseOver != nativeContainer) ? mouseOver: null;
|
if (!isMouseGrab(e) && id != MouseEvent.MOUSE_CLICKED) {
|
||||||
isCleaned = false;
|
met = (mouseOver != nativeContainer) ? mouseOver : null;
|
||||||
|
mouseEventTarget = new WeakReference<>(met);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mouseEventTarget != null) {
|
if (met != null) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case MouseEvent.MOUSE_ENTERED:
|
case MouseEvent.MOUSE_ENTERED:
|
||||||
case MouseEvent.MOUSE_EXITED:
|
case MouseEvent.MOUSE_EXITED:
|
||||||
break;
|
break;
|
||||||
case MouseEvent.MOUSE_PRESSED:
|
case MouseEvent.MOUSE_PRESSED:
|
||||||
retargetMouseEvent(mouseEventTarget, id, e);
|
retargetMouseEvent(met, id, e);
|
||||||
break;
|
break;
|
||||||
case MouseEvent.MOUSE_RELEASED:
|
case MouseEvent.MOUSE_RELEASED:
|
||||||
retargetMouseEvent(mouseEventTarget, id, e);
|
retargetMouseEvent(met, id, e);
|
||||||
break;
|
break;
|
||||||
case MouseEvent.MOUSE_CLICKED:
|
case MouseEvent.MOUSE_CLICKED:
|
||||||
// 4508327: MOUSE_CLICKED should never be dispatched to a Component
|
// 4508327: MOUSE_CLICKED should never be dispatched to a Component
|
||||||
// other than that which received the MOUSE_PRESSED event. If the
|
// other than that which received the MOUSE_PRESSED event. If the
|
||||||
// mouse is now over a different Component, don't dispatch the event.
|
// mouse is now over a different Component, don't dispatch the event.
|
||||||
// The previous fix for a similar problem was associated with bug
|
// The previous fix for a similar problem was associated with bug
|
||||||
// 4155217.
|
// 4155217.
|
||||||
if (mouseOver == mouseEventTarget) {
|
if (mouseOver == met) {
|
||||||
retargetMouseEvent(mouseOver, id, e);
|
retargetMouseEvent(mouseOver, id, e);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MouseEvent.MOUSE_MOVED:
|
case MouseEvent.MOUSE_MOVED:
|
||||||
retargetMouseEvent(mouseEventTarget, id, e);
|
retargetMouseEvent(met, id, e);
|
||||||
break;
|
break;
|
||||||
case MouseEvent.MOUSE_DRAGGED:
|
case MouseEvent.MOUSE_DRAGGED:
|
||||||
if (isMouseGrab(e)) {
|
if (isMouseGrab(e)) {
|
||||||
retargetMouseEvent(mouseEventTarget, id, e);
|
retargetMouseEvent(met, id, e);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MouseEvent.MOUSE_WHEEL:
|
case MouseEvent.MOUSE_WHEEL:
|
||||||
// This may send it somewhere that doesn't have MouseWheelEvents
|
// This may send it somewhere that doesn't have MouseWheelEvents
|
||||||
// enabled. In this case, Component.dispatchEventImpl() will
|
// enabled. In this case, Component.dispatchEventImpl() will
|
||||||
// retarget the event to a parent that DOES have the events enabled.
|
// retarget the event to a parent that DOES have the events enabled.
|
||||||
if (eventLog.isLoggable(PlatformLogger.Level.FINEST) && (mouseOver != null)) {
|
if (eventLog.isLoggable(PlatformLogger.Level.FINEST) && (mouseOver != null)) {
|
||||||
eventLog.finest("retargeting mouse wheel to " +
|
eventLog.finest("retargeting mouse wheel to " +
|
||||||
mouseOver.getName() + ", " +
|
mouseOver.getName() + ", " +
|
||||||
mouseOver.getClass());
|
mouseOver.getClass());
|
||||||
|
}
|
||||||
|
retargetMouseEvent(mouseOver, id, e);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
retargetMouseEvent(mouseOver, id, e);
|
//Consuming of wheel events is implemented in "retargetMouseEvent".
|
||||||
break;
|
if (id != MouseEvent.MOUSE_WHEEL) {
|
||||||
|
e.consume();
|
||||||
}
|
}
|
||||||
//Consuming of wheel events is implemented in "retargetMouseEvent".
|
|
||||||
if (id != MouseEvent.MOUSE_WHEEL) {
|
|
||||||
e.consume();
|
|
||||||
}
|
}
|
||||||
} else if (isCleaned && id != MouseEvent.MOUSE_WHEEL) {
|
return e.isConsumed();
|
||||||
//After mouseEventTarget was removed and cleaned should consume all events
|
|
||||||
//until new mouseEventTarget is found
|
|
||||||
e.consume();
|
|
||||||
}
|
|
||||||
return e.isConsumed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean processDropTargetEvent(SunDropTargetEvent e) {
|
private boolean processDropTargetEvent(SunDropTargetEvent e) {
|
||||||
@ -4646,15 +4636,16 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener {
|
|||||||
// drag has an associated drop target. MOUSE_ENTERED comes when the
|
// drag has an associated drop target. MOUSE_ENTERED comes when the
|
||||||
// mouse is in the native container already. To propagate this event
|
// mouse is in the native container already. To propagate this event
|
||||||
// properly we should null out targetLastEntered.
|
// properly we should null out targetLastEntered.
|
||||||
targetLastEnteredDT = null;
|
targetLastEnteredDT.clear();
|
||||||
} else if (id == MouseEvent.MOUSE_ENTERED) {
|
} else if (id == MouseEvent.MOUSE_ENTERED) {
|
||||||
isMouseDTInNativeContainer = true;
|
isMouseDTInNativeContainer = true;
|
||||||
} else if (id == MouseEvent.MOUSE_EXITED) {
|
} else if (id == MouseEvent.MOUSE_EXITED) {
|
||||||
isMouseDTInNativeContainer = false;
|
isMouseDTInNativeContainer = false;
|
||||||
}
|
}
|
||||||
targetLastEnteredDT = retargetMouseEnterExit(targetOver, e,
|
Component tle = retargetMouseEnterExit(targetOver, e,
|
||||||
targetLastEnteredDT,
|
targetLastEnteredDT.get(),
|
||||||
isMouseDTInNativeContainer);
|
isMouseDTInNativeContainer);
|
||||||
|
targetLastEnteredDT = new WeakReference<>(tle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -4680,9 +4671,10 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener {
|
|||||||
isMouseInNativeContainer = false;
|
isMouseInNativeContainer = false;
|
||||||
stopListeningForOtherDrags();
|
stopListeningForOtherDrags();
|
||||||
}
|
}
|
||||||
targetLastEntered = retargetMouseEnterExit(targetOver, e,
|
Component tle = retargetMouseEnterExit(targetOver, e,
|
||||||
targetLastEntered,
|
targetLastEntered.get(),
|
||||||
isMouseInNativeContainer);
|
isMouseInNativeContainer);
|
||||||
|
targetLastEntered = new WeakReference<>(tle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component retargetMouseEnterExit(Component targetOver, MouseEvent e,
|
private Component retargetMouseEnterExit(Component targetOver, MouseEvent e,
|
||||||
@ -4944,22 +4936,17 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener {
|
|||||||
* is null, there are currently no events being forwarded to
|
* is null, there are currently no events being forwarded to
|
||||||
* a subcomponent.
|
* a subcomponent.
|
||||||
*/
|
*/
|
||||||
private transient Component mouseEventTarget;
|
private transient WeakReference<Component> mouseEventTarget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The last component entered by the {@code MouseEvent}.
|
* The last component entered by the {@code MouseEvent}.
|
||||||
*/
|
*/
|
||||||
private transient Component targetLastEntered;
|
private transient WeakReference<Component> targetLastEntered;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The last component entered by the {@code SunDropTargetEvent}.
|
* The last component entered by the {@code SunDropTargetEvent}.
|
||||||
*/
|
*/
|
||||||
private transient Component targetLastEnteredDT;
|
private transient WeakReference<Component> targetLastEnteredDT;
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates whether {@code mouseEventTarget} was removed and nulled
|
|
||||||
*/
|
|
||||||
private transient boolean isCleaned;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the mouse over the native container.
|
* Is the mouse over the native container.
|
||||||
@ -5000,17 +4987,4 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener {
|
|||||||
AWTEvent.MOUSE_EVENT_MASK |
|
AWTEvent.MOUSE_EVENT_MASK |
|
||||||
AWTEvent.MOUSE_MOTION_EVENT_MASK |
|
AWTEvent.MOUSE_MOTION_EVENT_MASK |
|
||||||
AWTEvent.MOUSE_WHEEL_EVENT_MASK;
|
AWTEvent.MOUSE_WHEEL_EVENT_MASK;
|
||||||
|
|
||||||
void removeReferences(Component removedComponent) {
|
|
||||||
if (mouseEventTarget == removedComponent) {
|
|
||||||
isCleaned = true;
|
|
||||||
mouseEventTarget = null;
|
|
||||||
}
|
|
||||||
if (targetLastEntered == removedComponent) {
|
|
||||||
targetLastEntered = null;
|
|
||||||
}
|
|
||||||
if (targetLastEnteredDT == removedComponent) {
|
|
||||||
targetLastEnteredDT = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,14 @@ public class EventQueue {
|
|||||||
|
|
||||||
private FwDispatcher fwDispatcher;
|
private FwDispatcher fwDispatcher;
|
||||||
|
|
||||||
private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.EventQueue");
|
private static volatile PlatformLogger eventLog;
|
||||||
|
|
||||||
|
private static final PlatformLogger getEventLog() {
|
||||||
|
if(eventLog == null) {
|
||||||
|
eventLog = PlatformLogger.getLogger("java.awt.event.EventQueue");
|
||||||
|
}
|
||||||
|
return eventLog;
|
||||||
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
AWTAccessor.setEventQueueAccessor(
|
AWTAccessor.setEventQueueAccessor(
|
||||||
@ -762,8 +769,8 @@ public class EventQueue {
|
|||||||
dispatchThread.stopDispatching();
|
dispatchThread.stopDispatching();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (eventLog.isLoggable(PlatformLogger.Level.FINE)) {
|
if (getEventLog().isLoggable(PlatformLogger.Level.FINE)) {
|
||||||
eventLog.fine("Unable to dispatch event: " + event);
|
getEventLog().fine("Unable to dispatch event: " + event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -860,8 +867,8 @@ public class EventQueue {
|
|||||||
* @since 1.2
|
* @since 1.2
|
||||||
*/
|
*/
|
||||||
public void push(EventQueue newEventQueue) {
|
public void push(EventQueue newEventQueue) {
|
||||||
if (eventLog.isLoggable(PlatformLogger.Level.FINE)) {
|
if (getEventLog().isLoggable(PlatformLogger.Level.FINE)) {
|
||||||
eventLog.fine("EventQueue.push(" + newEventQueue + ")");
|
getEventLog().fine("EventQueue.push(" + newEventQueue + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
pushPopLock.lock();
|
pushPopLock.lock();
|
||||||
@ -886,8 +893,8 @@ public class EventQueue {
|
|||||||
// Use getNextEventPrivate() as it doesn't call flushPendingEvents()
|
// Use getNextEventPrivate() as it doesn't call flushPendingEvents()
|
||||||
newEventQueue.postEventPrivate(topQueue.getNextEventPrivate());
|
newEventQueue.postEventPrivate(topQueue.getNextEventPrivate());
|
||||||
} catch (InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
if (eventLog.isLoggable(PlatformLogger.Level.FINE)) {
|
if (getEventLog().isLoggable(PlatformLogger.Level.FINE)) {
|
||||||
eventLog.fine("Interrupted push", ie);
|
getEventLog().fine("Interrupted push", ie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -925,8 +932,8 @@ public class EventQueue {
|
|||||||
* @since 1.2
|
* @since 1.2
|
||||||
*/
|
*/
|
||||||
protected void pop() throws EmptyStackException {
|
protected void pop() throws EmptyStackException {
|
||||||
if (eventLog.isLoggable(PlatformLogger.Level.FINE)) {
|
if (getEventLog().isLoggable(PlatformLogger.Level.FINE)) {
|
||||||
eventLog.fine("EventQueue.pop(" + this + ")");
|
getEventLog().fine("EventQueue.pop(" + this + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
pushPopLock.lock();
|
pushPopLock.lock();
|
||||||
@ -948,8 +955,8 @@ public class EventQueue {
|
|||||||
try {
|
try {
|
||||||
prevQueue.postEventPrivate(topQueue.getNextEventPrivate());
|
prevQueue.postEventPrivate(topQueue.getNextEventPrivate());
|
||||||
} catch (InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
if (eventLog.isLoggable(PlatformLogger.Level.FINE)) {
|
if (getEventLog().isLoggable(PlatformLogger.Level.FINE)) {
|
||||||
eventLog.fine("Interrupted pop", ie);
|
getEventLog().fine("Interrupted pop", ie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -181,7 +181,7 @@ public class MenuBar extends MenuComponent implements MenuContainer, Accessible
|
|||||||
* removed from the menu bar, and replaced with the specified menu.
|
* removed from the menu bar, and replaced with the specified menu.
|
||||||
* @param m the menu to be set as the help menu
|
* @param m the menu to be set as the help menu
|
||||||
*/
|
*/
|
||||||
public void setHelpMenu(Menu m) {
|
public void setHelpMenu(final Menu m) {
|
||||||
synchronized (getTreeLock()) {
|
synchronized (getTreeLock()) {
|
||||||
if (helpMenu == m) {
|
if (helpMenu == m) {
|
||||||
return;
|
return;
|
||||||
@ -189,11 +189,11 @@ public class MenuBar extends MenuComponent implements MenuContainer, Accessible
|
|||||||
if (helpMenu != null) {
|
if (helpMenu != null) {
|
||||||
remove(helpMenu);
|
remove(helpMenu);
|
||||||
}
|
}
|
||||||
if (m.parent != this) {
|
|
||||||
add(m);
|
|
||||||
}
|
|
||||||
helpMenu = m;
|
helpMenu = m;
|
||||||
if (m != null) {
|
if (m != null) {
|
||||||
|
if (m.parent != this) {
|
||||||
|
add(m);
|
||||||
|
}
|
||||||
m.isHelpMenu = true;
|
m.isHelpMenu = true;
|
||||||
m.parent = this;
|
m.parent = this;
|
||||||
MenuBarPeer peer = (MenuBarPeer)this.peer;
|
MenuBarPeer peer = (MenuBarPeer)this.peer;
|
||||||
@ -242,7 +242,7 @@ public class MenuBar extends MenuComponent implements MenuContainer, Accessible
|
|||||||
* @param index the position of the menu to be removed.
|
* @param index the position of the menu to be removed.
|
||||||
* @see java.awt.MenuBar#add(java.awt.Menu)
|
* @see java.awt.MenuBar#add(java.awt.Menu)
|
||||||
*/
|
*/
|
||||||
public void remove(int index) {
|
public void remove(final int index) {
|
||||||
synchronized (getTreeLock()) {
|
synchronized (getTreeLock()) {
|
||||||
Menu m = getMenu(index);
|
Menu m = getMenu(index);
|
||||||
menus.removeElementAt(index);
|
menus.removeElementAt(index);
|
||||||
@ -252,6 +252,10 @@ public class MenuBar extends MenuComponent implements MenuContainer, Accessible
|
|||||||
m.parent = null;
|
m.parent = null;
|
||||||
peer.delMenu(index);
|
peer.delMenu(index);
|
||||||
}
|
}
|
||||||
|
if (helpMenu == m) {
|
||||||
|
helpMenu = null;
|
||||||
|
m.isHelpMenu = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,26 +25,23 @@
|
|||||||
|
|
||||||
package java.awt.image;
|
package java.awt.image;
|
||||||
|
|
||||||
import java.awt.Transparency;
|
|
||||||
import java.awt.color.ColorSpace;
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.GraphicsConfiguration;
|
|
||||||
import java.awt.GraphicsEnvironment;
|
import java.awt.GraphicsEnvironment;
|
||||||
import java.awt.ImageCapabilities;
|
|
||||||
import java.awt.geom.Rectangle2D;
|
|
||||||
import java.awt.geom.Point2D;
|
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Transparency;
|
||||||
|
import java.awt.color.ColorSpace;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import sun.awt.image.BytePackedRaster;
|
|
||||||
import sun.awt.image.ShortComponentRaster;
|
|
||||||
import sun.awt.image.ByteComponentRaster;
|
import sun.awt.image.ByteComponentRaster;
|
||||||
|
import sun.awt.image.BytePackedRaster;
|
||||||
import sun.awt.image.IntegerComponentRaster;
|
import sun.awt.image.IntegerComponentRaster;
|
||||||
import sun.awt.image.OffScreenImageSource;
|
import sun.awt.image.OffScreenImageSource;
|
||||||
|
import sun.awt.image.ShortComponentRaster;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -68,18 +65,14 @@ import sun.awt.image.OffScreenImageSource;
|
|||||||
* @see Raster
|
* @see Raster
|
||||||
* @see WritableRaster
|
* @see WritableRaster
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class BufferedImage extends java.awt.Image
|
public class BufferedImage extends java.awt.Image
|
||||||
implements WritableRenderedImage, Transparency
|
implements WritableRenderedImage, Transparency
|
||||||
{
|
{
|
||||||
int imageType = TYPE_CUSTOM;
|
private int imageType = TYPE_CUSTOM;
|
||||||
ColorModel colorModel;
|
private ColorModel colorModel;
|
||||||
WritableRaster raster;
|
private final WritableRaster raster;
|
||||||
OffScreenImageSource osis;
|
private OffScreenImageSource osis;
|
||||||
Hashtable<?, ?> properties;
|
private Hashtable<String, Object> properties;
|
||||||
|
|
||||||
boolean isAlphaPremultiplied;// If true, alpha has been premultiplied in
|
|
||||||
// color channels
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Image Type Constants
|
* Image Type Constants
|
||||||
@ -328,8 +321,8 @@ public class BufferedImage extends java.awt.Image
|
|||||||
0x000000ff, // Blue
|
0x000000ff, // Blue
|
||||||
0x0 // Alpha
|
0x0 // Alpha
|
||||||
);
|
);
|
||||||
raster = colorModel.createCompatibleWritableRaster(width,
|
raster = colorModel.createCompatibleWritableRaster(width,
|
||||||
height);
|
height);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -355,9 +348,8 @@ public class BufferedImage extends java.awt.Image
|
|||||||
true, // Alpha Premultiplied
|
true, // Alpha Premultiplied
|
||||||
DataBuffer.TYPE_INT
|
DataBuffer.TYPE_INT
|
||||||
);
|
);
|
||||||
|
raster = colorModel.createCompatibleWritableRaster(width,
|
||||||
raster = colorModel.createCompatibleWritableRaster(width,
|
height);
|
||||||
height);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -368,8 +360,8 @@ public class BufferedImage extends java.awt.Image
|
|||||||
0x0000ff00, // Green
|
0x0000ff00, // Green
|
||||||
0x00ff0000 // Blue
|
0x00ff0000 // Blue
|
||||||
);
|
);
|
||||||
raster = colorModel.createCompatibleWritableRaster(width,
|
raster = colorModel.createCompatibleWritableRaster(width,
|
||||||
height);
|
height);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -642,7 +634,14 @@ public class BufferedImage extends java.awt.Image
|
|||||||
|
|
||||||
colorModel = cm;
|
colorModel = cm;
|
||||||
this.raster = raster;
|
this.raster = raster;
|
||||||
this.properties = properties;
|
if (properties != null && !properties.isEmpty()) {
|
||||||
|
this.properties = new Hashtable<>();
|
||||||
|
for (final Object key : properties.keySet()) {
|
||||||
|
if (key instanceof String) {
|
||||||
|
this.properties.put((String) key, properties.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
int numBands = raster.getNumBands();
|
int numBands = raster.getNumBands();
|
||||||
boolean isAlphaPre = cm.isAlphaPremultiplied();
|
boolean isAlphaPre = cm.isAlphaPremultiplied();
|
||||||
final boolean isStandard = isStandard(cm, raster);
|
final boolean isStandard = isStandard(cm, raster);
|
||||||
@ -1272,7 +1271,11 @@ public class BufferedImage extends java.awt.Image
|
|||||||
* or <code>null</code> if no property names are recognized.
|
* or <code>null</code> if no property names are recognized.
|
||||||
*/
|
*/
|
||||||
public String[] getPropertyNames() {
|
public String[] getPropertyNames() {
|
||||||
return null;
|
if (properties == null || properties.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final Set<String> keys = properties.keySet();
|
||||||
|
return keys.toArray(new String[keys.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -2215,10 +2215,7 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl
|
|||||||
*/
|
*/
|
||||||
public boolean imageUpdate(Image img, int infoflags,
|
public boolean imageUpdate(Image img, int infoflags,
|
||||||
int x, int y, int w, int h) {
|
int x, int y, int w, int h) {
|
||||||
Icon iconDisplayed = getIcon();
|
Icon iconDisplayed = null;
|
||||||
if (iconDisplayed == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!model.isEnabled()) {
|
if (!model.isEnabled()) {
|
||||||
if (model.isSelected()) {
|
if (model.isSelected()) {
|
||||||
@ -2238,7 +2235,12 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl
|
|||||||
iconDisplayed = getSelectedIcon();
|
iconDisplayed = getSelectedIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SwingUtilities.doesIconReferenceImage(iconDisplayed, img)) {
|
if (iconDisplayed == null) {
|
||||||
|
iconDisplayed = getIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iconDisplayed == null
|
||||||
|
|| !SwingUtilities.doesIconReferenceImage(iconDisplayed, img)) {
|
||||||
// We don't know about this image, disable the notification so
|
// We don't know about this image, disable the notification so
|
||||||
// we don't keep repainting.
|
// we don't keep repainting.
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -27,22 +27,15 @@ package javax.swing;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Dictionary;
|
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.EventListener;
|
import java.util.EventListener;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.awt.image.VolatileImage;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.peer.LightweightPeer;
|
import java.awt.peer.LightweightPeer;
|
||||||
import java.awt.dnd.DropTarget;
|
|
||||||
import java.awt.font.FontRenderContext;
|
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.beans.VetoableChangeListener;
|
import java.beans.VetoableChangeListener;
|
||||||
import java.beans.VetoableChangeSupport;
|
import java.beans.VetoableChangeSupport;
|
||||||
@ -1868,7 +1861,7 @@ public abstract class JComponent extends Container implements Serializable,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides <code>Container.getAlignmentY</code> to return
|
* Overrides <code>Container.getAlignmentY</code> to return
|
||||||
* the horizontal alignment.
|
* the vertical alignment.
|
||||||
*
|
*
|
||||||
* @return the value of the <code>alignmentY</code> property
|
* @return the value of the <code>alignmentY</code> property
|
||||||
* @see #setAlignmentY
|
* @see #setAlignmentY
|
||||||
@ -1882,9 +1875,9 @@ public abstract class JComponent extends Container implements Serializable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the horizontal alignment.
|
* Sets the vertical alignment.
|
||||||
*
|
*
|
||||||
* @param alignmentY the new horizontal alignment
|
* @param alignmentY the new vertical alignment
|
||||||
* @see #getAlignmentY
|
* @see #getAlignmentY
|
||||||
* @beaninfo
|
* @beaninfo
|
||||||
* description: The preferred vertical alignment of the component.
|
* description: The preferred vertical alignment of the component.
|
||||||
@ -1897,7 +1890,7 @@ public abstract class JComponent extends Container implements Serializable,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides <code>Container.getAlignmentX</code> to return
|
* Overrides <code>Container.getAlignmentX</code> to return
|
||||||
* the vertical alignment.
|
* the horizontal alignment.
|
||||||
*
|
*
|
||||||
* @return the value of the <code>alignmentX</code> property
|
* @return the value of the <code>alignmentX</code> property
|
||||||
* @see #setAlignmentX
|
* @see #setAlignmentX
|
||||||
@ -1911,9 +1904,9 @@ public abstract class JComponent extends Container implements Serializable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the vertical alignment.
|
* Sets the horizontal alignment.
|
||||||
*
|
*
|
||||||
* @param alignmentX the new vertical alignment
|
* @param alignmentX the new horizontal alignment
|
||||||
* @see #getAlignmentX
|
* @see #getAlignmentX
|
||||||
* @beaninfo
|
* @beaninfo
|
||||||
* description: The preferred horizontal alignment of the component.
|
* description: The preferred horizontal alignment of the component.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -30,7 +30,6 @@ import java.awt.im.InputContext;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.text.*;
|
import java.text.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import javax.swing.UIManager;
|
|
||||||
import javax.swing.event.*;
|
import javax.swing.event.*;
|
||||||
import javax.swing.plaf.UIResource;
|
import javax.swing.plaf.UIResource;
|
||||||
import javax.swing.text.*;
|
import javax.swing.text.*;
|
||||||
@ -151,7 +150,7 @@ import javax.swing.text.*;
|
|||||||
* will be created to handle formatting of numbers:
|
* will be created to handle formatting of numbers:
|
||||||
* <pre>
|
* <pre>
|
||||||
* JFormattedTextField tf = new JFormattedTextField();
|
* JFormattedTextField tf = new JFormattedTextField();
|
||||||
* tf.setValue(new Number(100));
|
* tf.setValue(100);
|
||||||
* </pre>
|
* </pre>
|
||||||
* <p>
|
* <p>
|
||||||
* <strong>Warning:</strong> As the <code>AbstractFormatter</code> will
|
* <strong>Warning:</strong> As the <code>AbstractFormatter</code> will
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -1287,10 +1287,10 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
|
|||||||
return paintTrack;
|
return paintTrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether the track is painted on the slider.
|
* Determines whether the track is painted on the slider. By default, this
|
||||||
* By default, this property is {@code true}.
|
* property is {@code true}. It is up to the look and feel to honor this
|
||||||
|
* property, some may choose to ignore it.
|
||||||
*
|
*
|
||||||
* @param b whether or not to paint the slider track
|
* @param b whether or not to paint the slider track
|
||||||
* @see #getPaintTrack
|
* @see #getPaintTrack
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -493,7 +493,6 @@ public class JTextArea extends JTextComponent {
|
|||||||
* @exception IllegalArgumentException if part of the range is an
|
* @exception IllegalArgumentException if part of the range is an
|
||||||
* invalid position in the model
|
* invalid position in the model
|
||||||
* @see #insert
|
* @see #insert
|
||||||
* @see #replaceRange
|
|
||||||
*/
|
*/
|
||||||
public void replaceRange(String str, int start, int end) {
|
public void replaceRange(String str, int start, int end) {
|
||||||
if (end < start) {
|
if (end < start) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -36,10 +36,9 @@ import java.awt.Insets;
|
|||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.KeyboardFocusManager;
|
import java.awt.KeyboardFocusManager;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.Vector;
|
|
||||||
import sun.swing.DefaultLookup;
|
import sun.swing.DefaultLookup;
|
||||||
import sun.swing.UIAction;
|
import sun.swing.UIAction;
|
||||||
import sun.awt.AppContext;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic L&F for a desktop.
|
* Basic L&F for a desktop.
|
||||||
@ -49,9 +48,6 @@ import sun.awt.AppContext;
|
|||||||
public class BasicDesktopPaneUI extends DesktopPaneUI {
|
public class BasicDesktopPaneUI extends DesktopPaneUI {
|
||||||
// Old actions forward to an instance of this.
|
// Old actions forward to an instance of this.
|
||||||
private static final Actions SHARED_ACTION = new Actions();
|
private static final Actions SHARED_ACTION = new Actions();
|
||||||
private static Dimension minSize = new Dimension(0,0);
|
|
||||||
private static Dimension maxSize = new Dimension(Integer.MAX_VALUE,
|
|
||||||
Integer.MAX_VALUE);
|
|
||||||
private Handler handler;
|
private Handler handler;
|
||||||
private PropertyChangeListener pcl;
|
private PropertyChangeListener pcl;
|
||||||
|
|
||||||
@ -304,13 +300,19 @@ public class BasicDesktopPaneUI extends DesktopPaneUI {
|
|||||||
|
|
||||||
public void paint(Graphics g, JComponent c) {}
|
public void paint(Graphics g, JComponent c) {}
|
||||||
|
|
||||||
public Dimension getPreferredSize(JComponent c) {return null;}
|
@Override
|
||||||
|
public Dimension getPreferredSize(JComponent c) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Dimension getMinimumSize(JComponent c) {
|
public Dimension getMinimumSize(JComponent c) {
|
||||||
return minSize;
|
return new Dimension(0, 0);
|
||||||
}
|
}
|
||||||
public Dimension getMaximumSize(JComponent c){
|
|
||||||
return maxSize;
|
@Override
|
||||||
|
public Dimension getMaximumSize(JComponent c) {
|
||||||
|
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -92,8 +92,6 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
|||||||
|
|
||||||
private static int MIN_WIDTH = 500;
|
private static int MIN_WIDTH = 500;
|
||||||
private static int MIN_HEIGHT = 326;
|
private static int MIN_HEIGHT = 326;
|
||||||
private static Dimension MIN_SIZE = new Dimension(MIN_WIDTH, MIN_HEIGHT);
|
|
||||||
|
|
||||||
private static int LIST_PREF_WIDTH = 405;
|
private static int LIST_PREF_WIDTH = 405;
|
||||||
private static int LIST_PREF_HEIGHT = 135;
|
private static int LIST_PREF_HEIGHT = 135;
|
||||||
private static Dimension LIST_PREF_SIZE = new Dimension(LIST_PREF_WIDTH, LIST_PREF_HEIGHT);
|
private static Dimension LIST_PREF_SIZE = new Dimension(LIST_PREF_WIDTH, LIST_PREF_HEIGHT);
|
||||||
@ -615,6 +613,7 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
|||||||
* @return a <code>Dimension</code> specifying the preferred
|
* @return a <code>Dimension</code> specifying the preferred
|
||||||
* width and height of the file chooser
|
* width and height of the file chooser
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Dimension getPreferredSize(JComponent c) {
|
public Dimension getPreferredSize(JComponent c) {
|
||||||
int prefWidth = PREF_SIZE.width;
|
int prefWidth = PREF_SIZE.width;
|
||||||
Dimension d = c.getLayout().preferredLayoutSize(c);
|
Dimension d = c.getLayout().preferredLayoutSize(c);
|
||||||
@ -633,8 +632,9 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
|||||||
* @return a <code>Dimension</code> specifying the minimum
|
* @return a <code>Dimension</code> specifying the minimum
|
||||||
* width and height of the file chooser
|
* width and height of the file chooser
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Dimension getMinimumSize(JComponent c) {
|
public Dimension getMinimumSize(JComponent c) {
|
||||||
return MIN_SIZE;
|
return new Dimension(MIN_WIDTH, MIN_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -644,6 +644,7 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
|||||||
* @return a <code>Dimension</code> specifying the maximum
|
* @return a <code>Dimension</code> specifying the maximum
|
||||||
* width and height of the file chooser
|
* width and height of the file chooser
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Dimension getMaximumSize(JComponent c) {
|
public Dimension getMaximumSize(JComponent c) {
|
||||||
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
@ -654,7 +655,8 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
|||||||
} else {
|
} else {
|
||||||
JFileChooser fc = getFileChooser();
|
JFileChooser fc = getFileChooser();
|
||||||
if ((fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) ||
|
if ((fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) ||
|
||||||
(fc.isDirectorySelectionEnabled() && fc.isFileSelectionEnabled() && fc.getFileSystemView().isFileSystemRoot(file))) {
|
(fc.isDirectorySelectionEnabled() && fc.isFileSelectionEnabled()
|
||||||
|
&& fc.getFileSystemView().isFileSystemRoot(file))) {
|
||||||
return file.getPath();
|
return file.getPath();
|
||||||
} else {
|
} else {
|
||||||
return file.getName();
|
return file.getName();
|
||||||
|
@ -710,8 +710,9 @@ public class GapContent extends GapVector implements AbstractDocument.Content, S
|
|||||||
* @param length the length >= 0
|
* @param length the length >= 0
|
||||||
* @return the set of instances
|
* @return the set of instances
|
||||||
*/
|
*/
|
||||||
protected Vector<UndoPosRef> getPositionsInRange(Vector<UndoPosRef> v,
|
@SuppressWarnings({"rawtypes", "unchecked"}) // UndoPosRef type cannot be exposed
|
||||||
int offset, int length) {
|
protected Vector getPositionsInRange(Vector v,
|
||||||
|
int offset, int length) {
|
||||||
int endOffset = offset + length;
|
int endOffset = offset + length;
|
||||||
int startIndex;
|
int startIndex;
|
||||||
int endIndex;
|
int endIndex;
|
||||||
@ -758,7 +759,8 @@ public class GapContent extends GapVector implements AbstractDocument.Content, S
|
|||||||
*
|
*
|
||||||
* @param positions the UndoPosRef instances to reset
|
* @param positions the UndoPosRef instances to reset
|
||||||
*/
|
*/
|
||||||
protected void updateUndoPositions(Vector<UndoPosRef> positions, int offset,
|
@SuppressWarnings("rawtypes") // UndoPosRef type cannot be exposed
|
||||||
|
protected void updateUndoPositions(Vector positions, int offset,
|
||||||
int length) {
|
int length) {
|
||||||
// Find the indexs of the end points.
|
// Find the indexs of the end points.
|
||||||
int endOffset = offset + length;
|
int endOffset = offset + length;
|
||||||
@ -775,7 +777,7 @@ public class GapContent extends GapVector implements AbstractDocument.Content, S
|
|||||||
|
|
||||||
// Reset the location of the refenences.
|
// Reset the location of the refenences.
|
||||||
for(int counter = positions.size() - 1; counter >= 0; counter--) {
|
for(int counter = positions.size() - 1; counter >= 0; counter--) {
|
||||||
UndoPosRef ref = positions.elementAt(counter);
|
UndoPosRef ref = (UndoPosRef) positions.elementAt(counter);
|
||||||
ref.resetLocation(endOffset, g1);
|
ref.resetLocation(endOffset, g1);
|
||||||
}
|
}
|
||||||
// We have to resort the marks in the range startIndex to endIndex.
|
// We have to resort the marks in the range startIndex to endIndex.
|
||||||
@ -902,7 +904,8 @@ public class GapContent extends GapVector implements AbstractDocument.Content, S
|
|||||||
protected String string;
|
protected String string;
|
||||||
/** An array of instances of UndoPosRef for the Positions in the
|
/** An array of instances of UndoPosRef for the Positions in the
|
||||||
* range that was removed, valid after undo. */
|
* range that was removed, valid after undo. */
|
||||||
protected Vector<UndoPosRef> posRefs;
|
@SuppressWarnings("rawtypes") // UndoPosRef type cannot be exposed
|
||||||
|
protected Vector posRefs;
|
||||||
} // GapContent.InsertUndo
|
} // GapContent.InsertUndo
|
||||||
|
|
||||||
|
|
||||||
@ -911,6 +914,7 @@ public class GapContent extends GapVector implements AbstractDocument.Content, S
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial") // JDK-implementation class
|
@SuppressWarnings("serial") // JDK-implementation class
|
||||||
class RemoveUndo extends AbstractUndoableEdit {
|
class RemoveUndo extends AbstractUndoableEdit {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
protected RemoveUndo(int offset, String string) {
|
protected RemoveUndo(int offset, String string) {
|
||||||
super();
|
super();
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
@ -934,6 +938,7 @@ public class GapContent extends GapVector implements AbstractDocument.Content, S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void redo() throws CannotRedoException {
|
public void redo() throws CannotRedoException {
|
||||||
super.redo();
|
super.redo();
|
||||||
try {
|
try {
|
||||||
|
@ -271,11 +271,12 @@ public final class StringContent implements AbstractDocument.Content, Serializab
|
|||||||
* @param length the length >= 0
|
* @param length the length >= 0
|
||||||
* @return the set of instances
|
* @return the set of instances
|
||||||
*/
|
*/
|
||||||
protected Vector<UndoPosRef> getPositionsInRange(Vector<UndoPosRef> v, int offset,
|
@SuppressWarnings({"rawtypes", "unchecked"}) // UndoPosRef type cannot be exposed
|
||||||
int length) {
|
protected Vector getPositionsInRange(Vector v, int offset,
|
||||||
|
int length) {
|
||||||
int n = marks.size();
|
int n = marks.size();
|
||||||
int end = offset + length;
|
int end = offset + length;
|
||||||
Vector<UndoPosRef> placeIn = (v == null) ? new Vector<>() : v;
|
Vector placeIn = (v == null) ? new Vector() : v;
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
PosRec mark = marks.elementAt(i);
|
PosRec mark = marks.elementAt(i);
|
||||||
if (mark.unused) {
|
if (mark.unused) {
|
||||||
@ -298,9 +299,10 @@ public final class StringContent implements AbstractDocument.Content, Serializab
|
|||||||
*
|
*
|
||||||
* @param positions the positions of the instances
|
* @param positions the positions of the instances
|
||||||
*/
|
*/
|
||||||
protected void updateUndoPositions(Vector<UndoPosRef> positions) {
|
@SuppressWarnings("rawtypes") // UndoPosRef type cannot be exposed
|
||||||
|
protected void updateUndoPositions(Vector positions) {
|
||||||
for(int counter = positions.size() - 1; counter >= 0; counter--) {
|
for(int counter = positions.size() - 1; counter >= 0; counter--) {
|
||||||
UndoPosRef ref = positions.elementAt(counter);
|
UndoPosRef ref = (UndoPosRef) positions.elementAt(counter);
|
||||||
// Check if the Position is still valid.
|
// Check if the Position is still valid.
|
||||||
if(ref.rec.unused) {
|
if(ref.rec.unused) {
|
||||||
positions.removeElementAt(counter);
|
positions.removeElementAt(counter);
|
||||||
@ -437,7 +439,8 @@ public final class StringContent implements AbstractDocument.Content, Serializab
|
|||||||
protected String string;
|
protected String string;
|
||||||
// An array of instances of UndoPosRef for the Positions in the
|
// An array of instances of UndoPosRef for the Positions in the
|
||||||
// range that was removed, valid after undo.
|
// range that was removed, valid after undo.
|
||||||
protected Vector<UndoPosRef> posRefs;
|
@SuppressWarnings("rawtypes") // UndoPosRef type cannot be exposed
|
||||||
|
protected Vector posRefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -445,6 +448,7 @@ public final class StringContent implements AbstractDocument.Content, Serializab
|
|||||||
* UndoableEdit created for removes.
|
* UndoableEdit created for removes.
|
||||||
*/
|
*/
|
||||||
class RemoveUndo extends AbstractUndoableEdit {
|
class RemoveUndo extends AbstractUndoableEdit {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
protected RemoveUndo(int offset, String string) {
|
protected RemoveUndo(int offset, String string) {
|
||||||
super();
|
super();
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
@ -471,6 +475,7 @@ public final class StringContent implements AbstractDocument.Content, Serializab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void redo() throws CannotRedoException {
|
public void redo() throws CannotRedoException {
|
||||||
super.redo();
|
super.redo();
|
||||||
try {
|
try {
|
||||||
|
@ -157,6 +157,21 @@ public abstract class Font2D {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final int FWIDTH_NORMAL = 5; // OS/2 usWidthClass
|
||||||
|
public static final int FWEIGHT_NORMAL = 400; // OS/2 usWeightClass
|
||||||
|
public static final int FWEIGHT_BOLD = 700; // OS/2 usWeightClass
|
||||||
|
|
||||||
|
public int getWidth() {
|
||||||
|
return FWIDTH_NORMAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWeight() {
|
||||||
|
if ((style & Font.BOLD) !=0) {
|
||||||
|
return FWEIGHT_BOLD;
|
||||||
|
} else {
|
||||||
|
return FWEIGHT_NORMAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int getRank() {
|
int getRank() {
|
||||||
return fontRank;
|
return fontRank;
|
||||||
|
@ -27,6 +27,7 @@ package sun.font;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -77,7 +78,7 @@ public class FontFamily {
|
|||||||
family.bolditalic = null;
|
family.bolditalic = null;
|
||||||
}
|
}
|
||||||
if (family.plain == null && family.bold == null &&
|
if (family.plain == null && family.bold == null &&
|
||||||
family.plain == null && family.bold == null) {
|
family.italic == null && family.bolditalic == null) {
|
||||||
familyNameMap.remove(name);
|
familyNameMap.remove(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,7 +135,98 @@ public class FontFamily {
|
|||||||
return java.util.Objects.equals(newDir, existDir);
|
return java.util.Objects.equals(newDir, existDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We want a family to be of the same width and prefer medium/normal width.
|
||||||
|
* Once we find a particular width we accept more of the same width
|
||||||
|
* until we find one closer to normal when we 'evict' all existing fonts.
|
||||||
|
* So once we see a 'normal' width font we evict all members that are not
|
||||||
|
* normal width and then accept only new ones that are normal width.
|
||||||
|
*
|
||||||
|
* Once a font passes the width test we subject it to the weight test.
|
||||||
|
* For Plain we target the weight the closest that is <= NORMAL (400)
|
||||||
|
* For Bold we target the weight that is closest to BOLD (700).
|
||||||
|
*
|
||||||
|
* In the future, rather than discarding these fonts, we should
|
||||||
|
* extend the family to include these so lookups on these properties
|
||||||
|
* can locate them, as presently they will only be located by full name
|
||||||
|
* based lookup.
|
||||||
|
*/
|
||||||
|
|
||||||
|
private int familyWidth = 0;
|
||||||
|
private boolean preferredWidth(Font2D font) {
|
||||||
|
|
||||||
|
int newWidth = font.getWidth();
|
||||||
|
|
||||||
|
if (familyWidth == 0) {
|
||||||
|
familyWidth = newWidth;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newWidth == familyWidth) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Math.abs(Font2D.FWIDTH_NORMAL - newWidth) <
|
||||||
|
Math.abs(Font2D.FWIDTH_NORMAL - familyWidth))
|
||||||
|
{
|
||||||
|
if (FontUtilities.debugFonts()) {
|
||||||
|
FontUtilities.getLogger().info(
|
||||||
|
"Found more preferred width. New width = " + newWidth +
|
||||||
|
" Old width = " + familyWidth + " in font " + font +
|
||||||
|
" nulling out fonts plain: " + plain + " bold: " + bold +
|
||||||
|
" italic: " + italic + " bolditalic: " + bolditalic);
|
||||||
|
}
|
||||||
|
familyWidth = newWidth;
|
||||||
|
plain = bold = italic = bolditalic = null;
|
||||||
|
return true;
|
||||||
|
} else if (FontUtilities.debugFonts()) {
|
||||||
|
FontUtilities.getLogger().info(
|
||||||
|
"Family rejecting font " + font +
|
||||||
|
" of less preferred width " + newWidth);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean closerWeight(Font2D currFont, Font2D font, int style) {
|
||||||
|
if (familyWidth != font.getWidth()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currFont == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FontUtilities.debugFonts()) {
|
||||||
|
FontUtilities.getLogger().info(
|
||||||
|
"New weight for style " + style + ". Curr.font=" + currFont +
|
||||||
|
" New font="+font+" Curr.weight="+ + currFont.getWeight()+
|
||||||
|
" New weight="+font.getWeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
int newWeight = font.getWeight();
|
||||||
|
switch (style) {
|
||||||
|
case Font.PLAIN:
|
||||||
|
case Font.ITALIC:
|
||||||
|
return (newWeight <= Font2D.FWEIGHT_NORMAL &&
|
||||||
|
newWeight > currFont.getWeight());
|
||||||
|
|
||||||
|
case Font.BOLD:
|
||||||
|
case Font.BOLD|Font.ITALIC:
|
||||||
|
return (Math.abs(newWeight - Font2D.FWEIGHT_BOLD) <
|
||||||
|
Math.abs(currFont.getWeight() - Font2D.FWEIGHT_BOLD));
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setFont(Font2D font, int style) {
|
public void setFont(Font2D font, int style) {
|
||||||
|
|
||||||
|
if (FontUtilities.isLogging()) {
|
||||||
|
FontUtilities.getLogger().info(
|
||||||
|
"Request to add " + font + " with style " + style +
|
||||||
|
" to family " + this);
|
||||||
|
}
|
||||||
/* Allow a lower-rank font only if its a file font
|
/* Allow a lower-rank font only if its a file font
|
||||||
* from the exact same source as any previous font.
|
* from the exact same source as any previous font.
|
||||||
*/
|
*/
|
||||||
@ -152,19 +244,27 @@ public class FontFamily {
|
|||||||
switch (style) {
|
switch (style) {
|
||||||
|
|
||||||
case Font.PLAIN:
|
case Font.PLAIN:
|
||||||
plain = font;
|
if (preferredWidth(font) && closerWeight(plain, font, style)) {
|
||||||
|
plain = font;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Font.BOLD:
|
case Font.BOLD:
|
||||||
bold = font;
|
if (preferredWidth(font) && closerWeight(bold, font, style)) {
|
||||||
|
bold = font;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Font.ITALIC:
|
case Font.ITALIC:
|
||||||
italic = font;
|
if (preferredWidth(font) && closerWeight(italic, font, style)) {
|
||||||
|
italic = font;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Font.BOLD|Font.ITALIC:
|
case Font.BOLD|Font.ITALIC:
|
||||||
bolditalic = font;
|
if (preferredWidth(font) && closerWeight(bolditalic, font, style)) {
|
||||||
|
bolditalic = font;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -316,6 +416,11 @@ public class FontFamily {
|
|||||||
return allLocaleNames.get(name.toLowerCase());
|
return allLocaleNames.get(name.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static FontFamily[] getAllFontFamilies() {
|
||||||
|
Collection<FontFamily> families = familyNameMap.values();
|
||||||
|
return families.toArray(new FontFamily[0]);
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return
|
return
|
||||||
"Font family: " + familyName +
|
"Font family: " + familyName +
|
||||||
|
@ -963,6 +963,18 @@ public class TrueTypeFont extends FileFont {
|
|||||||
setStyle(getTableBuffer(os_2Tag));
|
setStyle(getTableBuffer(os_2Tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int fontWidth = 0;
|
||||||
|
@Override
|
||||||
|
public int getWidth() {
|
||||||
|
return (fontWidth > 0) ? fontWidth : super.getWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int fontWeight = 0;
|
||||||
|
@Override
|
||||||
|
public int getWeight() {
|
||||||
|
return (fontWeight > 0) ? fontWeight : super.getWeight();
|
||||||
|
}
|
||||||
|
|
||||||
/* TrueTypeFont can use the fsSelection fields of OS/2 table
|
/* TrueTypeFont can use the fsSelection fields of OS/2 table
|
||||||
* to determine the style. In the unlikely case that doesn't exist,
|
* to determine the style. In the unlikely case that doesn't exist,
|
||||||
* can use macStyle in the 'head' table but simpler to
|
* can use macStyle in the 'head' table but simpler to
|
||||||
@ -978,8 +990,15 @@ public class TrueTypeFont extends FileFont {
|
|||||||
private static final int fsSelectionBoldBit = 0x00020;
|
private static final int fsSelectionBoldBit = 0x00020;
|
||||||
private static final int fsSelectionRegularBit = 0x00040;
|
private static final int fsSelectionRegularBit = 0x00040;
|
||||||
private void setStyle(ByteBuffer os_2Table) {
|
private void setStyle(ByteBuffer os_2Table) {
|
||||||
|
if (os_2Table == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (os_2Table.capacity() >= 8) {
|
||||||
|
fontWeight = os_2Table.getChar(4) & 0xffff;
|
||||||
|
fontWidth = os_2Table.getChar(6) & 0xffff;
|
||||||
|
}
|
||||||
/* fsSelection is unsigned short at buffer offset 62 */
|
/* fsSelection is unsigned short at buffer offset 62 */
|
||||||
if (os_2Table == null || os_2Table.capacity() < 64) {
|
if (os_2Table.capacity() < 64) {
|
||||||
super.setStyle();
|
super.setStyle();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1564,7 +1564,7 @@ public class ServiceDialog extends JDialog implements ActionListener {
|
|||||||
bmObj = bmTmpObj;
|
bmObj = bmTmpObj;
|
||||||
} else {
|
} else {
|
||||||
if (lmObj == null || rmObj == null ||
|
if (lmObj == null || rmObj == null ||
|
||||||
tmObj == null || rmObj == null) {
|
tmObj == null || bmObj == null) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
leftMargin.setValue(lmObj);
|
leftMargin.setValue(lmObj);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -31,6 +31,7 @@ import static java.awt.RenderingHints.*;
|
|||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.awt.font.*;
|
import java.awt.font.*;
|
||||||
import java.awt.print.PrinterGraphics;
|
import java.awt.print.PrinterGraphics;
|
||||||
|
import java.text.BreakIterator;
|
||||||
import java.text.CharacterIterator;
|
import java.text.CharacterIterator;
|
||||||
import java.text.AttributedCharacterIterator;
|
import java.text.AttributedCharacterIterator;
|
||||||
import java.text.AttributedString;
|
import java.text.AttributedString;
|
||||||
@ -461,16 +462,15 @@ public class SwingUtilities2 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (needsTextLayout) {
|
if (needsTextLayout) {
|
||||||
FontRenderContext frc = getFontRenderContext(c, fm);
|
|
||||||
AttributedString aString = new AttributedString(string);
|
AttributedString aString = new AttributedString(string);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
aString.addAttribute(TextAttribute.NUMERIC_SHAPING,
|
aString.addAttribute(TextAttribute.NUMERIC_SHAPING,
|
||||||
c.getClientProperty(TextAttribute.NUMERIC_SHAPING));
|
c.getClientProperty(TextAttribute.NUMERIC_SHAPING));
|
||||||
}
|
}
|
||||||
LineBreakMeasurer measurer =
|
LineBreakMeasurer measurer = new LineBreakMeasurer(
|
||||||
new LineBreakMeasurer(aString.getIterator(), frc);
|
aString.getIterator(), BreakIterator.getCharacterInstance(),
|
||||||
int nChars = measurer.nextOffset(availTextWidth);
|
getFontRenderContext(c, fm));
|
||||||
string = string.substring(0, nChars);
|
string = string.substring(0, measurer.nextOffset(availTextWidth));
|
||||||
|
|
||||||
}
|
}
|
||||||
return string + clipString;
|
return string + clipString;
|
||||||
|
@ -1,150 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
|
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
||||||
*
|
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle in the LICENSE file that accompanied this code.
|
|
||||||
*
|
|
||||||
* This code 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
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package sun.awt.X11;
|
|
||||||
|
|
||||||
import java.util.logging.*;
|
|
||||||
import java.text.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Formatter class providing ANSI output. Based on java.util.logging.SimpleFormatter sources.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class XAWTFormatter extends java.util.logging.Formatter {
|
|
||||||
Date dat = new Date();
|
|
||||||
private final static String format = "{0,date} {0,time}";
|
|
||||||
private MessageFormat formatter;
|
|
||||||
|
|
||||||
private Object args[] = new Object[1];
|
|
||||||
|
|
||||||
// Line separator string. This is the value of the line.separator
|
|
||||||
// property at the moment that the SimpleFormatter was created.
|
|
||||||
private String lineSeparator = System.lineSeparator();
|
|
||||||
|
|
||||||
boolean displayFullRecord = false;
|
|
||||||
boolean useANSI = false;
|
|
||||||
boolean showDate = true;
|
|
||||||
boolean showLevel = true;
|
|
||||||
boolean swapMethodClass = false;
|
|
||||||
public XAWTFormatter() {
|
|
||||||
displayFullRecord = "true".equals(LogManager.getLogManager().getProperty("XAWTFormatter.displayFullRecord"));
|
|
||||||
useANSI = "true".equals(LogManager.getLogManager().getProperty("XAWTFormatter.useANSI"));
|
|
||||||
showDate = !"false".equals(LogManager.getLogManager().getProperty("XAWTFormatter.showDate"));
|
|
||||||
showLevel = !"false".equals(LogManager.getLogManager().getProperty("XAWTFormatter.showLevel"));
|
|
||||||
swapMethodClass = "true".equals(LogManager.getLogManager().getProperty("XAWTFormatter.swapMethodClass"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Format the given LogRecord.
|
|
||||||
* @param record the log record to be formatted.
|
|
||||||
* @return a formatted log record
|
|
||||||
*/
|
|
||||||
public synchronized String format(LogRecord record) {
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
if (useANSI) {
|
|
||||||
Level lev = record.getLevel();
|
|
||||||
if (Level.FINEST.equals(lev)) {
|
|
||||||
sb.append("[36m");
|
|
||||||
} else if (Level.FINER.equals(lev)) {
|
|
||||||
sb.append("[32m");
|
|
||||||
} else if (Level.FINE.equals(lev)) {
|
|
||||||
sb.append("[34m");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (displayFullRecord) {
|
|
||||||
if (showDate) {
|
|
||||||
// Minimize memory allocations here.
|
|
||||||
dat.setTime(record.getMillis());
|
|
||||||
args[0] = dat;
|
|
||||||
StringBuffer text = new StringBuffer();
|
|
||||||
if (formatter == null) {
|
|
||||||
formatter = new MessageFormat(format);
|
|
||||||
}
|
|
||||||
formatter.format(args, text, null);
|
|
||||||
sb.append(text);
|
|
||||||
sb.append(" ");
|
|
||||||
} else {
|
|
||||||
sb.append(" ");
|
|
||||||
}
|
|
||||||
if (swapMethodClass) {
|
|
||||||
if (record.getSourceMethodName() != null) {
|
|
||||||
sb.append(" [35m");
|
|
||||||
sb.append(record.getSourceMethodName());
|
|
||||||
sb.append("[30m ");
|
|
||||||
}
|
|
||||||
if (record.getSourceClassName() != null) {
|
|
||||||
sb.append(record.getSourceClassName());
|
|
||||||
} else {
|
|
||||||
sb.append(record.getLoggerName());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (record.getSourceClassName() != null) {
|
|
||||||
sb.append(record.getSourceClassName());
|
|
||||||
} else {
|
|
||||||
sb.append(record.getLoggerName());
|
|
||||||
}
|
|
||||||
if (record.getSourceMethodName() != null) {
|
|
||||||
sb.append(" [35m");
|
|
||||||
sb.append(record.getSourceMethodName());
|
|
||||||
sb.append("[30m");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sb.append(lineSeparator);
|
|
||||||
}
|
|
||||||
if (useANSI) {
|
|
||||||
Level lev = record.getLevel();
|
|
||||||
if (Level.FINEST.equals(lev)) {
|
|
||||||
sb.append("[36m");
|
|
||||||
} else if (Level.FINER.equals(lev)) {
|
|
||||||
sb.append("[32m");
|
|
||||||
} else if (Level.FINE.equals(lev)) {
|
|
||||||
sb.append("[34m");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (showLevel) {
|
|
||||||
sb.append(record.getLevel().getLocalizedName());
|
|
||||||
sb.append(": ");
|
|
||||||
}
|
|
||||||
String message = formatMessage(record);
|
|
||||||
sb.append(message);
|
|
||||||
sb.append(lineSeparator);
|
|
||||||
if (record.getThrown() != null) {
|
|
||||||
try {
|
|
||||||
StringWriter sw = new StringWriter();
|
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
|
||||||
record.getThrown().printStackTrace(pw);
|
|
||||||
pw.close();
|
|
||||||
sb.append(sw.toString());
|
|
||||||
} catch (Exception ex) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (useANSI) {
|
|
||||||
sb.append("[30m");
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,15 +25,17 @@
|
|||||||
|
|
||||||
package sun.awt.X11;
|
package sun.awt.X11;
|
||||||
|
|
||||||
import sun.awt.EmbeddedFrame;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.AWTKeyStroke;
|
import java.awt.AWTKeyStroke;
|
||||||
import java.util.logging.Logger;
|
import java.awt.Toolkit;
|
||||||
|
|
||||||
|
import sun.awt.EmbeddedFrame;
|
||||||
|
import sun.util.logging.PlatformLogger;
|
||||||
|
|
||||||
@SuppressWarnings("serial") // JDK-implementation class
|
@SuppressWarnings("serial") // JDK-implementation class
|
||||||
public class XEmbeddedFrame extends EmbeddedFrame {
|
public class XEmbeddedFrame extends EmbeddedFrame {
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger(XEmbeddedFrame.class.getName());
|
private static final PlatformLogger log =
|
||||||
|
PlatformLogger.getLogger(XEmbeddedFrame.class.getName());
|
||||||
|
|
||||||
long handle;
|
long handle;
|
||||||
public XEmbeddedFrame() {
|
public XEmbeddedFrame() {
|
||||||
|
@ -180,7 +180,7 @@ public class FcFontConfiguration extends FontConfiguration {
|
|||||||
String[] componentFaceNames = cfi[idx].getComponentFaceNames();
|
String[] componentFaceNames = cfi[idx].getComponentFaceNames();
|
||||||
FontDescriptor[] ret = new FontDescriptor[componentFaceNames.length];
|
FontDescriptor[] ret = new FontDescriptor[componentFaceNames.length];
|
||||||
for (int i = 0; i < componentFaceNames.length; i++) {
|
for (int i = 0; i < componentFaceNames.length; i++) {
|
||||||
ret[i] = new FontDescriptor(componentFaceNames[i], StandardCharsets.UTF_8.newEncoder(), new int[0]);
|
ret[i] = new FontDescriptor(componentFaceNames[i], StandardCharsets.ISO_8859_1.newEncoder(), new int[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -52,6 +52,7 @@ JNIEXPORT jstring JNICALL Java_sun_awt_windows_WDesktopPeer_ShellExecute
|
|||||||
// 6457572: ShellExecute possibly changes FPU control word - saving it here
|
// 6457572: ShellExecute possibly changes FPU control word - saving it here
|
||||||
unsigned oldcontrol87 = _control87(0, 0);
|
unsigned oldcontrol87 = _control87(0, 0);
|
||||||
HINSTANCE retval = ::ShellExecute(NULL, verb_c, fileOrUri_c, NULL, NULL, SW_SHOWNORMAL);
|
HINSTANCE retval = ::ShellExecute(NULL, verb_c, fileOrUri_c, NULL, NULL, SW_SHOWNORMAL);
|
||||||
|
DWORD error = ::GetLastError();
|
||||||
_control87(oldcontrol87, 0xffffffff);
|
_control87(oldcontrol87, 0xffffffff);
|
||||||
|
|
||||||
JNU_ReleaseStringPlatformChars(env, fileOrUri_j, fileOrUri_c);
|
JNU_ReleaseStringPlatformChars(env, fileOrUri_j, fileOrUri_c);
|
||||||
@ -65,7 +66,7 @@ JNIEXPORT jstring JNICALL Java_sun_awt_windows_WDesktopPeer_ShellExecute
|
|||||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
NULL,
|
NULL,
|
||||||
(int)retval,
|
error,
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||||
(LPTSTR)&buffer,
|
(LPTSTR)&buffer,
|
||||||
0,
|
0,
|
||||||
|
@ -0,0 +1,215 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code 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
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.Button;
|
||||||
|
import java.awt.Canvas;
|
||||||
|
import java.awt.Checkbox;
|
||||||
|
import java.awt.Choice;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Dialog;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.FileDialog;
|
||||||
|
import java.awt.Frame;
|
||||||
|
import java.awt.Label;
|
||||||
|
import java.awt.List;
|
||||||
|
import java.awt.Panel;
|
||||||
|
import java.awt.ScrollPane;
|
||||||
|
import java.awt.Scrollbar;
|
||||||
|
import java.awt.TextArea;
|
||||||
|
import java.awt.TextField;
|
||||||
|
import java.awt.Window;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import javax.swing.Box;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JCheckBoxMenuItem;
|
||||||
|
import javax.swing.JColorChooser;
|
||||||
|
import javax.swing.JDesktopPane;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JEditorPane;
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
|
import javax.swing.JFormattedTextField;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JInternalFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JLayeredPane;
|
||||||
|
import javax.swing.JMenu;
|
||||||
|
import javax.swing.JMenuBar;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPasswordField;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
|
import javax.swing.JProgressBar;
|
||||||
|
import javax.swing.JRadioButton;
|
||||||
|
import javax.swing.JRadioButtonMenuItem;
|
||||||
|
import javax.swing.JRootPane;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JSeparator;
|
||||||
|
import javax.swing.JSlider;
|
||||||
|
import javax.swing.JSpinner;
|
||||||
|
import javax.swing.JSplitPane;
|
||||||
|
import javax.swing.JTabbedPane;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.JTextPane;
|
||||||
|
import javax.swing.JToggleButton;
|
||||||
|
import javax.swing.JToolBar;
|
||||||
|
import javax.swing.JTree;
|
||||||
|
import javax.swing.JViewport;
|
||||||
|
import javax.swing.JWindow;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.UIManager.LookAndFeelInfo;
|
||||||
|
import javax.swing.UnsupportedLookAndFeelException;
|
||||||
|
import javax.swing.table.JTableHeader;
|
||||||
|
|
||||||
|
import static javax.swing.UIManager.getInstalledLookAndFeels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @bug 6459798
|
||||||
|
* @author Sergey Bylokhov
|
||||||
|
*/
|
||||||
|
public final class DimensionEncapsulation implements Runnable {
|
||||||
|
|
||||||
|
java.util.List<Component> failures = new ArrayList<>();
|
||||||
|
|
||||||
|
public static void main(final String[] args) throws Exception {
|
||||||
|
for (final LookAndFeelInfo laf : getInstalledLookAndFeels()) {
|
||||||
|
SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf));
|
||||||
|
SwingUtilities.invokeAndWait(new DimensionEncapsulation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
runTest(new Panel());
|
||||||
|
runTest(new Button());
|
||||||
|
runTest(new Checkbox());
|
||||||
|
runTest(new Canvas());
|
||||||
|
runTest(new Choice());
|
||||||
|
runTest(new Label());
|
||||||
|
runTest(new Scrollbar());
|
||||||
|
runTest(new TextArea());
|
||||||
|
runTest(new TextField());
|
||||||
|
runTest(new Dialog(new JFrame()));
|
||||||
|
runTest(new Frame());
|
||||||
|
runTest(new Window(new JFrame()));
|
||||||
|
runTest(new FileDialog(new JFrame()));
|
||||||
|
runTest(new List());
|
||||||
|
runTest(new ScrollPane());
|
||||||
|
runTest(new JFrame());
|
||||||
|
runTest(new JDialog(new JFrame()));
|
||||||
|
runTest(new JWindow(new JFrame()));
|
||||||
|
runTest(new JLabel("hi"));
|
||||||
|
runTest(new JMenu());
|
||||||
|
runTest(new JTree());
|
||||||
|
runTest(new JTable());
|
||||||
|
runTest(new JMenuItem());
|
||||||
|
runTest(new JCheckBoxMenuItem());
|
||||||
|
runTest(new JToggleButton());
|
||||||
|
runTest(new JSpinner());
|
||||||
|
runTest(new JSlider());
|
||||||
|
runTest(Box.createVerticalBox());
|
||||||
|
runTest(Box.createHorizontalBox());
|
||||||
|
runTest(new JTextField());
|
||||||
|
runTest(new JTextArea());
|
||||||
|
runTest(new JTextPane());
|
||||||
|
runTest(new JPasswordField());
|
||||||
|
runTest(new JFormattedTextField());
|
||||||
|
runTest(new JEditorPane());
|
||||||
|
runTest(new JButton());
|
||||||
|
runTest(new JColorChooser());
|
||||||
|
runTest(new JFileChooser());
|
||||||
|
runTest(new JCheckBox());
|
||||||
|
runTest(new JInternalFrame());
|
||||||
|
runTest(new JDesktopPane());
|
||||||
|
runTest(new JTableHeader());
|
||||||
|
runTest(new JLayeredPane());
|
||||||
|
runTest(new JRootPane());
|
||||||
|
runTest(new JMenuBar());
|
||||||
|
runTest(new JOptionPane());
|
||||||
|
runTest(new JRadioButton());
|
||||||
|
runTest(new JRadioButtonMenuItem());
|
||||||
|
runTest(new JPopupMenu());
|
||||||
|
//runTest(new JScrollBar()); --> don't test defines max and min in
|
||||||
|
// terms of preferred
|
||||||
|
runTest(new JScrollPane());
|
||||||
|
runTest(new JViewport());
|
||||||
|
runTest(new JSplitPane());
|
||||||
|
runTest(new JTabbedPane());
|
||||||
|
runTest(new JToolBar());
|
||||||
|
runTest(new JSeparator());
|
||||||
|
runTest(new JProgressBar());
|
||||||
|
if (!failures.isEmpty()) {
|
||||||
|
System.out.println("These classes failed");
|
||||||
|
for (final Component failure : failures) {
|
||||||
|
System.out.println(failure.getClass());
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Test failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void runTest(final Component c) {
|
||||||
|
try {
|
||||||
|
test(c);
|
||||||
|
c.setMinimumSize(new Dimension(100, 10));
|
||||||
|
c.setMaximumSize(new Dimension(200, 20));
|
||||||
|
c.setPreferredSize(new Dimension(300, 30));
|
||||||
|
test(c);
|
||||||
|
} catch (final Throwable ignored) {
|
||||||
|
failures.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void test(final Component component) {
|
||||||
|
final Dimension psize = component.getPreferredSize();
|
||||||
|
psize.width += 200;
|
||||||
|
if (Objects.equals(psize, component.getPreferredSize())) {
|
||||||
|
throw new RuntimeException("PreferredSize is wrong");
|
||||||
|
}
|
||||||
|
final Dimension msize = component.getMaximumSize();
|
||||||
|
msize.width += 200;
|
||||||
|
if (Objects.equals(msize, component.getMaximumSize())) {
|
||||||
|
throw new RuntimeException("MaximumSize is wrong");
|
||||||
|
}
|
||||||
|
final Dimension misize = component.getMinimumSize();
|
||||||
|
misize.width += 200;
|
||||||
|
if (Objects.equals(misize, component.getMinimumSize())) {
|
||||||
|
throw new RuntimeException("MinimumSize is wrong");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setLookAndFeel(final LookAndFeelInfo laf) {
|
||||||
|
try {
|
||||||
|
UIManager.setLookAndFeel(laf.getClassName());
|
||||||
|
System.out.println("LookAndFeel: " + laf.getClassName());
|
||||||
|
} catch (ClassNotFoundException | InstantiationException |
|
||||||
|
UnsupportedLookAndFeelException | IllegalAccessException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,166 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code 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
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import javax.swing.Box;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JCheckBoxMenuItem;
|
||||||
|
import javax.swing.JColorChooser;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JDesktopPane;
|
||||||
|
import javax.swing.JEditorPane;
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
|
import javax.swing.JFormattedTextField;
|
||||||
|
import javax.swing.JInternalFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JLayeredPane;
|
||||||
|
import javax.swing.JMenu;
|
||||||
|
import javax.swing.JMenuBar;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPasswordField;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
|
import javax.swing.JProgressBar;
|
||||||
|
import javax.swing.JRadioButton;
|
||||||
|
import javax.swing.JRadioButtonMenuItem;
|
||||||
|
import javax.swing.JRootPane;
|
||||||
|
import javax.swing.JScrollBar;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JSeparator;
|
||||||
|
import javax.swing.JSlider;
|
||||||
|
import javax.swing.JSpinner;
|
||||||
|
import javax.swing.JSplitPane;
|
||||||
|
import javax.swing.JTabbedPane;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.JTextPane;
|
||||||
|
import javax.swing.JToggleButton;
|
||||||
|
import javax.swing.JToolBar;
|
||||||
|
import javax.swing.JTree;
|
||||||
|
import javax.swing.JViewport;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.UnsupportedLookAndFeelException;
|
||||||
|
import javax.swing.table.JTableHeader;
|
||||||
|
|
||||||
|
import static javax.swing.UIManager.LookAndFeelInfo;
|
||||||
|
import static javax.swing.UIManager.getInstalledLookAndFeels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @bug 6459800
|
||||||
|
* @author Sergey Bylokhov
|
||||||
|
*/
|
||||||
|
public final class InsetsEncapsulation implements Runnable {
|
||||||
|
|
||||||
|
private final Collection<Component> failures = new ArrayList<>();
|
||||||
|
|
||||||
|
public static void main(final String[] args) throws Exception {
|
||||||
|
for (final LookAndFeelInfo laf : getInstalledLookAndFeels()) {
|
||||||
|
SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf));
|
||||||
|
SwingUtilities.invokeAndWait(new InsetsEncapsulation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
runTest(new JLabel("hi"));
|
||||||
|
runTest(new JMenu());
|
||||||
|
runTest(new JTree());
|
||||||
|
runTest(new JTable());
|
||||||
|
runTest(new JMenuItem());
|
||||||
|
runTest(new JCheckBoxMenuItem());
|
||||||
|
runTest(new JToggleButton());
|
||||||
|
runTest(new JSpinner());
|
||||||
|
runTest(new JSlider());
|
||||||
|
runTest(Box.createVerticalBox());
|
||||||
|
runTest(Box.createHorizontalBox());
|
||||||
|
runTest(new JTextField());
|
||||||
|
runTest(new JTextArea());
|
||||||
|
runTest(new JTextPane());
|
||||||
|
runTest(new JPasswordField());
|
||||||
|
runTest(new JFormattedTextField());
|
||||||
|
runTest(new JEditorPane());
|
||||||
|
runTest(new JButton());
|
||||||
|
runTest(new JColorChooser());
|
||||||
|
runTest(new JFileChooser());
|
||||||
|
runTest(new JCheckBox());
|
||||||
|
runTest(new JInternalFrame());
|
||||||
|
runTest(new JDesktopPane());
|
||||||
|
runTest(new JTableHeader());
|
||||||
|
runTest(new JLayeredPane());
|
||||||
|
runTest(new JRootPane());
|
||||||
|
runTest(new JMenuBar());
|
||||||
|
runTest(new JOptionPane());
|
||||||
|
runTest(new JRadioButton());
|
||||||
|
runTest(new JRadioButtonMenuItem());
|
||||||
|
runTest(new JPopupMenu());
|
||||||
|
runTest(new JScrollBar());
|
||||||
|
runTest(new JScrollPane());
|
||||||
|
runTest(new JViewport());
|
||||||
|
runTest(new JSplitPane());
|
||||||
|
runTest(new JTabbedPane());
|
||||||
|
runTest(new JToolBar());
|
||||||
|
runTest(new JSeparator());
|
||||||
|
runTest(new JProgressBar());
|
||||||
|
if (!failures.isEmpty()) {
|
||||||
|
System.out.println("These classes failed");
|
||||||
|
for (final Component failure : failures) {
|
||||||
|
System.out.println(failure.getClass());
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Test failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void runTest(final JComponent component) {
|
||||||
|
try {
|
||||||
|
test(component);
|
||||||
|
} catch (final Throwable ignored) {
|
||||||
|
failures.add(component);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void test(final JComponent component) {
|
||||||
|
final Insets p = component.getInsets();
|
||||||
|
p.top += 3;
|
||||||
|
if (p.equals(component.getInsets())) {
|
||||||
|
throw new RuntimeException("Insets altered by altering Insets!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setLookAndFeel(final LookAndFeelInfo laf) {
|
||||||
|
try {
|
||||||
|
UIManager.setLookAndFeel(laf.getClassName());
|
||||||
|
System.out.println("LookAndFeel: " + laf.getClassName());
|
||||||
|
} catch (ClassNotFoundException | InstantiationException |
|
||||||
|
UnsupportedLookAndFeelException | IllegalAccessException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
83
jdk/test/java/awt/Desktop/8064934/bug8064934.java
Normal file
83
jdk/test/java/awt/Desktop/8064934/bug8064934.java
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code 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
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* @test
|
||||||
|
* @bug 8064934
|
||||||
|
* @summary Incorrect Exception message from java.awt.Desktop.open()
|
||||||
|
* @author Dmitry Markov
|
||||||
|
* @run main bug8064934
|
||||||
|
*/
|
||||||
|
import sun.awt.OSInfo;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.security.AccessController;
|
||||||
|
|
||||||
|
public class bug8064934 {
|
||||||
|
private static final String NO_ASSOCIATION_ERROR_MESSAGE = "Error message: No application is associated with" +
|
||||||
|
" the specified file for this operation.";
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// This test is intended only for Windows
|
||||||
|
if (AccessController.doPrivileged(OSInfo.getOSTypeAction()) != OSInfo.OSType.WINDOWS) {
|
||||||
|
System.out.println("The test is for Windows platform only");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test whether Desktop is supported of not
|
||||||
|
if (!Desktop.isDesktopSupported()) {
|
||||||
|
System.out.println("Desktop is not supported");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Desktop desktop = Desktop.getDesktop();
|
||||||
|
// Test whether open action is supported or not
|
||||||
|
if (!desktop.isSupported(Desktop.Action.OPEN)) {
|
||||||
|
System.out.println("Desktop.Action.OPEN is not supported");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = null;
|
||||||
|
try {
|
||||||
|
file = File.createTempFile("test", ".foo");
|
||||||
|
if (!file.exists()) {
|
||||||
|
throw new RuntimeException("Can not create temp file");
|
||||||
|
}
|
||||||
|
desktop.open(file);
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
String errorMessage = ioe.getMessage().trim();
|
||||||
|
if (errorMessage != null && !errorMessage.endsWith(NO_ASSOCIATION_ERROR_MESSAGE)) {
|
||||||
|
throw new RuntimeException("Test FAILED! Wrong Error message: \n" +
|
||||||
|
"Actual " + errorMessage.substring(errorMessage.indexOf("Error message:")) + "\n" +
|
||||||
|
"Expected " + NO_ASSOCIATION_ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (file != null) {
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Test PASSED!");
|
||||||
|
}
|
||||||
|
}
|
166
jdk/test/java/awt/FontClass/HelvLtOblTest.java
Normal file
166
jdk/test/java/awt/FontClass/HelvLtOblTest.java
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code 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
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 8064833
|
||||||
|
* @summary Test correct font is obtained via famil+style
|
||||||
|
* @run main HelvLtOblTest
|
||||||
|
*/
|
||||||
|
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
|
import java.awt.font.FontRenderContext;
|
||||||
|
import java.awt.font.GlyphVector;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
public class HelvLtOblTest extends JComponent {
|
||||||
|
|
||||||
|
static Font helvFont = null;
|
||||||
|
|
||||||
|
static int[] codes = { 0x23, 0x4a, 0x48, 0x3, 0x4a, 0x55, 0x42, 0x4d,
|
||||||
|
0x4a, 0x44, 0x3,
|
||||||
|
0x53, 0x46, 0x45, 0x3, 0x55, 0x46, 0x59, 0x55, };
|
||||||
|
|
||||||
|
static String str = "Big italic red text";
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
String os = System.getProperty("os.name");
|
||||||
|
if (!os.startsWith("Mac")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||||
|
Font[] fonts = ge.getAllFonts();
|
||||||
|
for (int i=0; i<fonts.length; i++) {
|
||||||
|
if (fonts[i].getPSName().equals("Helvetica-LightOblique")) {
|
||||||
|
helvFont = fonts[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (helvFont == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final HelvLtOblTest test = new HelvLtOblTest();
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
JFrame f = new JFrame();
|
||||||
|
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
f.add("Center", test);
|
||||||
|
f.pack();
|
||||||
|
f.setVisible(true);
|
||||||
|
});
|
||||||
|
test.compareImages();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dimension getPreferredSize() {
|
||||||
|
return new Dimension(400,400);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paintComponent(Graphics g) {
|
||||||
|
super.paintComponent(g);
|
||||||
|
Graphics2D g2 = (Graphics2D)g;
|
||||||
|
FontRenderContext frc = new FontRenderContext(null, true, true);
|
||||||
|
Font f = helvFont.deriveFont(Font.PLAIN, 40);
|
||||||
|
System.out.println("font = " +f.getFontName());
|
||||||
|
GlyphVector gv = f.createGlyphVector(frc, codes);
|
||||||
|
g.setFont(f);
|
||||||
|
g.setColor(Color.white);
|
||||||
|
g.fillRect(0,0,400,400);
|
||||||
|
g.setColor(Color.black);
|
||||||
|
g2.drawGlyphVector(gv, 5,200);
|
||||||
|
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
||||||
|
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||||
|
g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
|
||||||
|
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
|
||||||
|
g2.drawString(str, 5, 250);
|
||||||
|
}
|
||||||
|
|
||||||
|
void compareImages() {
|
||||||
|
BufferedImage bi0 = drawText(false);
|
||||||
|
BufferedImage bi1 = drawText(true);
|
||||||
|
compare(bi0, bi1);
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferedImage drawText(boolean doGV) {
|
||||||
|
int w = 400;
|
||||||
|
int h = 50;
|
||||||
|
BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
|
||||||
|
Graphics2D g = bi.createGraphics();
|
||||||
|
g.setColor(Color.white);
|
||||||
|
g.fillRect(0,0,w,h);
|
||||||
|
g.setColor(Color.black);
|
||||||
|
Font f = helvFont.deriveFont(Font.PLAIN, 40);
|
||||||
|
g.setFont(f);
|
||||||
|
int x = 5;
|
||||||
|
int y = h - 10;
|
||||||
|
if (doGV) {
|
||||||
|
FontRenderContext frc = new FontRenderContext(null, true, true);
|
||||||
|
GlyphVector gv = f.createGlyphVector(frc, codes);
|
||||||
|
g.drawGlyphVector(gv, 5, y);
|
||||||
|
} else {
|
||||||
|
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
||||||
|
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||||
|
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
|
||||||
|
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
|
||||||
|
g.drawString(str, x, y);
|
||||||
|
}
|
||||||
|
return bi;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Need to allow for minimal rounding error, so allow each component
|
||||||
|
// to differ by 1.
|
||||||
|
void compare(BufferedImage bi0, BufferedImage bi1) {
|
||||||
|
int wid = bi0.getWidth();
|
||||||
|
int hgt = bi0.getHeight();
|
||||||
|
for (int x=0; x<wid; x++) {
|
||||||
|
for (int y=0; y<hgt; y++) {
|
||||||
|
int rgb0 = bi0.getRGB(x, y);
|
||||||
|
int rgb1 = bi1.getRGB(x, y);
|
||||||
|
if (rgb0 == rgb1) continue;
|
||||||
|
int r0 = (rgb0 & 0xff0000) >> 16;
|
||||||
|
int r1 = (rgb1 & 0xff0000) >> 16;
|
||||||
|
int rdiff = r0-r1; if (rdiff<0) rdiff = -rdiff;
|
||||||
|
int g0 = (rgb0 & 0x00ff00) >> 8;
|
||||||
|
int g1 = (rgb1 & 0x00ff00) >> 8;
|
||||||
|
int gdiff = g0-g1; if (gdiff<0) gdiff = -gdiff;
|
||||||
|
int b0 = (rgb0 & 0x0000ff);
|
||||||
|
int b1 = (rgb1 & 0x0000ff);
|
||||||
|
int bdiff = b0-b1; if (bdiff<0) bdiff = -bdiff;
|
||||||
|
if (rdiff > 1 || gdiff > 1 || bdiff > 1) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"Images differ at x=" + x + " y="+ y + " " +
|
||||||
|
Integer.toHexString(rgb0) + " vs " +
|
||||||
|
Integer.toHexString(rgb1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,152 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code 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
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.DisplayMode;
|
||||||
|
import java.awt.Frame;
|
||||||
|
import java.awt.GraphicsDevice;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import static java.awt.DisplayMode.REFRESH_RATE_UNKNOWN;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @bug 6430607
|
||||||
|
* @summary Test that we throw an exception for incorrect display modes
|
||||||
|
* @author Dmitri.Trembovetski@Sun.COM area=FullScreen
|
||||||
|
* @run main/othervm NonExistentDisplayModeTest
|
||||||
|
* @run main/othervm -Dsun.java2d.noddraw=true NonExistentDisplayModeTest
|
||||||
|
* @run main/othervm -Dsun.java2d.opengl=true NonExistentDisplayModeTest
|
||||||
|
*/
|
||||||
|
public class NonExistentDisplayModeTest {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
new NonExistentDisplayModeTest().start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void start() {
|
||||||
|
Frame f = new Frame("Testing, please wait..");
|
||||||
|
f.pack();
|
||||||
|
GraphicsDevice gd = f.getGraphicsConfiguration().getDevice();
|
||||||
|
if (!gd.isFullScreenSupported()) {
|
||||||
|
System.out.println("Exclusive FS mode not supported, test passed.");
|
||||||
|
f.dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gd.setFullScreenWindow(f);
|
||||||
|
if (!gd.isDisplayChangeSupported()) {
|
||||||
|
System.out.println("DisplayMode change not supported, test passed.");
|
||||||
|
f.dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DisplayMode dms[] = gd.getDisplayModes();
|
||||||
|
ArrayList<DisplayMode> dmList = new ArrayList<DisplayMode>(dms.length);
|
||||||
|
for (DisplayMode dm : dms) {
|
||||||
|
dmList.add(dm);
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<DisplayMode> nonExistentDms = createNonExistentDMList(dmList);
|
||||||
|
|
||||||
|
for (DisplayMode dm : nonExistentDms) {
|
||||||
|
boolean exThrown = false;
|
||||||
|
try {
|
||||||
|
System.out.printf("Testing mode: (%4dx%4d) depth=%3d rate=%d\n",
|
||||||
|
dm.getWidth(), dm.getHeight(),
|
||||||
|
dm.getBitDepth(), dm.getRefreshRate());
|
||||||
|
gd.setDisplayMode(dm);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
exThrown = true;
|
||||||
|
}
|
||||||
|
if (!exThrown) {
|
||||||
|
gd.setFullScreenWindow(null);
|
||||||
|
f.dispose();
|
||||||
|
throw new
|
||||||
|
RuntimeException("Failed: No exception thrown for dm "+dm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gd.setFullScreenWindow(null);
|
||||||
|
f.dispose();
|
||||||
|
System.out.println("Test passed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Random rnd = new Random();
|
||||||
|
private ArrayList<DisplayMode>
|
||||||
|
createNonExistentDMList(ArrayList<DisplayMode> dmList)
|
||||||
|
{
|
||||||
|
ArrayList<DisplayMode> newList =
|
||||||
|
new ArrayList<DisplayMode>(dmList.size());
|
||||||
|
// vary one parameter at a time
|
||||||
|
int param = 0;
|
||||||
|
for (DisplayMode dm : dmList) {
|
||||||
|
param = ++param % 3;
|
||||||
|
switch (param) {
|
||||||
|
case 0: {
|
||||||
|
DisplayMode newDM = deriveSize(dm);
|
||||||
|
if (!dmList.contains(newDM)) {
|
||||||
|
newList.add(newDM);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
DisplayMode newDM = deriveDepth(dm);
|
||||||
|
if (!dmList.contains(newDM)) {
|
||||||
|
newList.add(newDM);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
if (dm.getRefreshRate() != REFRESH_RATE_UNKNOWN) {
|
||||||
|
DisplayMode newDM = deriveRR(dm);
|
||||||
|
if (!dmList.contains(newDM)) {
|
||||||
|
newList.add(newDM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DisplayMode deriveSize(DisplayMode dm) {
|
||||||
|
int w = dm.getWidth() / 7;
|
||||||
|
int h = dm.getHeight() / 3;
|
||||||
|
return new DisplayMode(w, h, dm.getBitDepth(), dm.getRefreshRate());
|
||||||
|
}
|
||||||
|
private static DisplayMode deriveRR(DisplayMode dm) {
|
||||||
|
return new DisplayMode(dm.getWidth(), dm.getHeight(),
|
||||||
|
dm.getBitDepth(), 777);
|
||||||
|
}
|
||||||
|
private static DisplayMode deriveDepth(DisplayMode dm) {
|
||||||
|
int depth;
|
||||||
|
if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI) {
|
||||||
|
depth = 77;
|
||||||
|
} else {
|
||||||
|
depth = DisplayMode.BIT_DEPTH_MULTI;
|
||||||
|
}
|
||||||
|
return new DisplayMode(dm.getWidth(), dm.getHeight(),
|
||||||
|
depth, dm.getRefreshRate());
|
||||||
|
}
|
||||||
|
}
|
132
jdk/test/java/awt/MenuBar/RemoveHelpMenu/RemoveHelpMenu.java
Normal file
132
jdk/test/java/awt/MenuBar/RemoveHelpMenu/RemoveHelpMenu.java
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code 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
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.Frame;
|
||||||
|
import java.awt.Menu;
|
||||||
|
import java.awt.MenuBar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @bug 6475361
|
||||||
|
* @author Sergey Bylokhov
|
||||||
|
*/
|
||||||
|
public final class RemoveHelpMenu {
|
||||||
|
|
||||||
|
public static void main(final String[] args) {
|
||||||
|
final Frame frame = new Frame("RemoveHelpMenu Test");
|
||||||
|
try {
|
||||||
|
frame.pack();
|
||||||
|
// peer exists
|
||||||
|
test1(getMenuBar(frame));
|
||||||
|
test2(getMenuBar(frame));
|
||||||
|
test3(getMenuBar(frame));
|
||||||
|
test4(getMenuBar(frame));
|
||||||
|
} finally {
|
||||||
|
frame.dispose();
|
||||||
|
}
|
||||||
|
// peer is null
|
||||||
|
test1(getMenuBar(frame));
|
||||||
|
test2(getMenuBar(frame));
|
||||||
|
test3(getMenuBar(frame));
|
||||||
|
test4(getMenuBar(frame));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static MenuBar getMenuBar(final Frame frame) {
|
||||||
|
final MenuBar menuBar = new MenuBar();
|
||||||
|
frame.setMenuBar(menuBar);
|
||||||
|
return menuBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void checkHelpMenu(final Menu menu, final boolean expected) {
|
||||||
|
final boolean actual = menu.toString().contains("isHelpMenu=true");
|
||||||
|
if (actual != expected) {
|
||||||
|
throw new RuntimeException("Incorrect menu type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void checkMenuCount(final MenuBar bar, final int expected) {
|
||||||
|
final int actual = bar.getMenuCount();
|
||||||
|
if (actual != expected) {
|
||||||
|
throw new RuntimeException("Incorrect menus count");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void checkCurrentMenu(final MenuBar bar, final Menu menu) {
|
||||||
|
if (bar.getHelpMenu() != menu) {
|
||||||
|
throw new RuntimeException("Wrong HelpMenu");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void test1(final MenuBar menuBar) {
|
||||||
|
checkCurrentMenu(menuBar, null);
|
||||||
|
checkMenuCount(menuBar, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void test2(final MenuBar menuBar) {
|
||||||
|
final Menu helpMenu = new Menu("Help Menu");
|
||||||
|
menuBar.setHelpMenu(helpMenu);
|
||||||
|
checkCurrentMenu(menuBar, helpMenu);
|
||||||
|
checkMenuCount(menuBar, 1);
|
||||||
|
checkHelpMenu(helpMenu, true);
|
||||||
|
|
||||||
|
menuBar.remove(helpMenu);
|
||||||
|
checkCurrentMenu(menuBar, null);
|
||||||
|
checkMenuCount(menuBar, 0);
|
||||||
|
checkHelpMenu(helpMenu, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void test3(final MenuBar menuBar) {
|
||||||
|
final Menu helpMenu1 = new Menu("Help Menu1");
|
||||||
|
final Menu helpMenu2 = new Menu("Help Menu2");
|
||||||
|
menuBar.setHelpMenu(helpMenu1);
|
||||||
|
checkCurrentMenu(menuBar, helpMenu1);
|
||||||
|
checkMenuCount(menuBar, 1);
|
||||||
|
checkHelpMenu(helpMenu1, true);
|
||||||
|
checkHelpMenu(helpMenu2, false);
|
||||||
|
|
||||||
|
menuBar.setHelpMenu(helpMenu2);
|
||||||
|
checkCurrentMenu(menuBar, helpMenu2);
|
||||||
|
checkMenuCount(menuBar, 1);
|
||||||
|
checkHelpMenu(helpMenu1, false);
|
||||||
|
checkHelpMenu(helpMenu2, true);
|
||||||
|
|
||||||
|
menuBar.remove(helpMenu2);
|
||||||
|
checkCurrentMenu(menuBar, null);
|
||||||
|
checkMenuCount(menuBar, 0);
|
||||||
|
checkHelpMenu(helpMenu1, false);
|
||||||
|
checkHelpMenu(helpMenu2, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void test4(final MenuBar menuBar) {
|
||||||
|
final Menu helpMenu = new Menu("Help Menu");
|
||||||
|
menuBar.setHelpMenu(helpMenu);
|
||||||
|
checkCurrentMenu(menuBar, helpMenu);
|
||||||
|
checkMenuCount(menuBar, 1);
|
||||||
|
checkHelpMenu(helpMenu, true);
|
||||||
|
|
||||||
|
menuBar.setHelpMenu(null);
|
||||||
|
checkCurrentMenu(menuBar, null);
|
||||||
|
checkMenuCount(menuBar, 0);
|
||||||
|
checkHelpMenu(helpMenu, false);
|
||||||
|
}
|
||||||
|
}
|
@ -40,6 +40,7 @@
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import javax.swing.plaf.metal.MetalLookAndFeel;
|
||||||
import test.java.awt.regtesthelpers.Util;
|
import test.java.awt.regtesthelpers.Util;
|
||||||
|
|
||||||
public class HWDisappear
|
public class HWDisappear
|
||||||
@ -109,7 +110,7 @@ public class HWDisappear
|
|||||||
|
|
||||||
// Click on the button.
|
// Click on the button.
|
||||||
Point bLoc = b.getLocationOnScreen();
|
Point bLoc = b.getLocationOnScreen();
|
||||||
robot.mouseMove(bLoc.x + b.getWidth() / 2, bLoc.y + 5);
|
robot.mouseMove(bLoc.x + b.getWidth() / 2, bLoc.y + b.getHeight() / 2);
|
||||||
|
|
||||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||||
@ -148,8 +149,9 @@ public class HWDisappear
|
|||||||
// instantiated in the same VM. Being static (and using
|
// instantiated in the same VM. Being static (and using
|
||||||
// static vars), it aint gonna work. Not worrying about
|
// static vars), it aint gonna work. Not worrying about
|
||||||
// it for now.
|
// it for now.
|
||||||
public static void main( String args[] ) throws InterruptedException
|
public static void main( String args[] ) throws Exception
|
||||||
{
|
{
|
||||||
|
UIManager.setLookAndFeel(new MetalLookAndFeel());
|
||||||
mainThread = Thread.currentThread();
|
mainThread = Thread.currentThread();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code 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
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 8061636
|
||||||
|
* @summary fix for 7079254 changes behavior of MouseListener, MouseMotionListener
|
||||||
|
* @library ../../regtesthelpers
|
||||||
|
* @build Util
|
||||||
|
* @author Alexander Zvegintsev
|
||||||
|
* @run main RemovedComponentMouseListener
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.Robot;
|
||||||
|
import java.awt.event.InputEvent;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import javax.swing.*;
|
||||||
|
import test.java.awt.regtesthelpers.Util;
|
||||||
|
|
||||||
|
public class RemovedComponentMouseListener extends JFrame {
|
||||||
|
|
||||||
|
static boolean mouseReleasedReceived;
|
||||||
|
static JButton button;
|
||||||
|
|
||||||
|
public RemovedComponentMouseListener() {
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
JPanel buttonPanel = new JPanel();
|
||||||
|
button = new JButton("Button");
|
||||||
|
|
||||||
|
setSize(300, 300);
|
||||||
|
|
||||||
|
buttonPanel.add(button);
|
||||||
|
panel.add(buttonPanel);
|
||||||
|
setContentPane(panel);
|
||||||
|
|
||||||
|
button.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
buttonPanel.remove(button);
|
||||||
|
panel.add(button);
|
||||||
|
button.revalidate();
|
||||||
|
button.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
mouseReleasedReceived = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
SwingUtilities.invokeAndWait(() -> {
|
||||||
|
new RemovedComponentMouseListener();
|
||||||
|
});
|
||||||
|
|
||||||
|
Robot r = Util.createRobot();
|
||||||
|
r.setAutoDelay(100);
|
||||||
|
r.waitForIdle();
|
||||||
|
Util.pointOnComp(button, r);
|
||||||
|
|
||||||
|
r.waitForIdle();
|
||||||
|
r.mousePress(InputEvent.BUTTON1_MASK);
|
||||||
|
r.waitForIdle();
|
||||||
|
r.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||||
|
r.waitForIdle();
|
||||||
|
if (!mouseReleasedReceived) {
|
||||||
|
throw new RuntimeException("mouseReleased event was not received");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,136 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code 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
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
@test
|
||||||
|
@bug 8068283
|
||||||
|
@summary Checks that <Alt>+Char accelerators work when pressed in a text component
|
||||||
|
@author Anton Nashatyrev
|
||||||
|
@run main AltCharAcceleratorTest
|
||||||
|
*/
|
||||||
|
|
||||||
|
import sun.awt.SunToolkit;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
public class AltCharAcceleratorTest {
|
||||||
|
|
||||||
|
boolean action1 = false;
|
||||||
|
boolean action2 = false;
|
||||||
|
|
||||||
|
CountDownLatch focusLatch = new CountDownLatch(1);
|
||||||
|
CountDownLatch actionLatch = new CountDownLatch(2);
|
||||||
|
|
||||||
|
public AltCharAcceleratorTest() throws Exception {
|
||||||
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
JFrame f = new JFrame("frame");
|
||||||
|
final JTextField t = new JTextField();
|
||||||
|
JMenuBar mb = new JMenuBar();
|
||||||
|
JMenu m1 = new JMenu("File");
|
||||||
|
JMenuItem i1 = new JMenuItem("Save");
|
||||||
|
JMenuItem i2 = new JMenuItem("Load");
|
||||||
|
|
||||||
|
i1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.ALT_MASK));
|
||||||
|
i2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, KeyEvent.ALT_MASK));
|
||||||
|
|
||||||
|
i1.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
System.out.println("Action1!");
|
||||||
|
action1 = true;
|
||||||
|
actionLatch.countDown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
i2.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
System.out.println("Action2!");
|
||||||
|
action2 = true;
|
||||||
|
actionLatch.countDown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
t.addFocusListener(new FocusAdapter() {
|
||||||
|
@Override
|
||||||
|
public void focusGained(FocusEvent e) {
|
||||||
|
System.out.println("Focused!");
|
||||||
|
focusLatch.countDown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
t.setColumns(10);
|
||||||
|
t.requestFocusInWindow();
|
||||||
|
|
||||||
|
f.setJMenuBar(mb);
|
||||||
|
mb.add(m1);
|
||||||
|
m1.add(i1);
|
||||||
|
m1.add(i2);
|
||||||
|
|
||||||
|
f.setLayout(new FlowLayout());
|
||||||
|
f.add(t);
|
||||||
|
f.setSize(200, 200);
|
||||||
|
|
||||||
|
f.setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void test() throws Exception {
|
||||||
|
((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
|
||||||
|
|
||||||
|
focusLatch.await(5, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
Robot robot = new Robot();
|
||||||
|
robot.setAutoDelay(100);
|
||||||
|
|
||||||
|
robot.keyPress(KeyEvent.VK_ALT);
|
||||||
|
robot.keyPress(KeyEvent.VK_T);
|
||||||
|
robot.keyRelease(KeyEvent.VK_T);
|
||||||
|
robot.keyRelease(KeyEvent.VK_ALT);
|
||||||
|
|
||||||
|
robot.keyPress(KeyEvent.VK_ALT);
|
||||||
|
robot.keyPress(KeyEvent.VK_F);
|
||||||
|
robot.keyRelease(KeyEvent.VK_F);
|
||||||
|
robot.keyRelease(KeyEvent.VK_ALT);
|
||||||
|
|
||||||
|
actionLatch.await(5, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
if (!action1 || !action2) {
|
||||||
|
throw new RuntimeException("Actions not performed");
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Passed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
AltCharAcceleratorTest t = new AltCharAcceleratorTest();
|
||||||
|
t.test();
|
||||||
|
}
|
||||||
|
}
|
103
jdk/test/java/awt/image/BufferedImage/GetPropertyNames.java
Normal file
103
jdk/test/java/awt/image/BufferedImage/GetPropertyNames.java
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code 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
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import static java.awt.image.BufferedImage.TYPE_INT_ARGB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @bug 8066132
|
||||||
|
* @author Sergey Bylokhov
|
||||||
|
*/
|
||||||
|
public final class GetPropertyNames {
|
||||||
|
|
||||||
|
static BufferedImage defaultProps = new BufferedImage(1, 1, TYPE_INT_ARGB);
|
||||||
|
|
||||||
|
public static void main(final String[] args) {
|
||||||
|
// default result is null
|
||||||
|
if (defaultProps.getPropertyNames() != null) {
|
||||||
|
throw new RuntimeException("PropertyNames should be null");
|
||||||
|
}
|
||||||
|
// for null properties result is null
|
||||||
|
final BufferedImage emptyProps = getBufferedImage(null);
|
||||||
|
if (emptyProps.getPropertyNames() != null) {
|
||||||
|
throw new RuntimeException("PropertyNames should be null");
|
||||||
|
}
|
||||||
|
// for empty properties result is null
|
||||||
|
final BufferedImage nullProps = getBufferedImage(new Properties());
|
||||||
|
if (nullProps.getPropertyNames() != null) {
|
||||||
|
throw new RuntimeException("PropertyNames should be null");
|
||||||
|
}
|
||||||
|
// for non-string keys result is null
|
||||||
|
final Properties properties = new Properties();
|
||||||
|
properties.put(1, 1);
|
||||||
|
properties.put(2, 2);
|
||||||
|
properties.put(3, 3);
|
||||||
|
final BufferedImage nonStringProps = getBufferedImage(properties);
|
||||||
|
if (nonStringProps.getPropertyNames() != null) {
|
||||||
|
throw new RuntimeException("PropertyNames should be null");
|
||||||
|
}
|
||||||
|
// for string keys result is not null
|
||||||
|
properties.clear();
|
||||||
|
properties.setProperty("1", "1");
|
||||||
|
properties.setProperty("2", "2");
|
||||||
|
validate(getBufferedImage(properties), 2);
|
||||||
|
// for the mix of strings and objects result is not null
|
||||||
|
properties.clear();
|
||||||
|
properties.put(1, 1);
|
||||||
|
properties.put(2, 2);
|
||||||
|
properties.put(3, 3);
|
||||||
|
properties.setProperty("key1", "value1");
|
||||||
|
properties.setProperty("key2", "value2");
|
||||||
|
final BufferedImage mixProps = getBufferedImage(properties);
|
||||||
|
validate(mixProps, 2);
|
||||||
|
if (!"value1".equals(mixProps.getProperty("key1"))
|
||||||
|
|| !"value2".equals(mixProps.getProperty("key2"))) {
|
||||||
|
throw new RuntimeException("Wrong key-value pair");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static BufferedImage getBufferedImage(final Properties properties) {
|
||||||
|
return new BufferedImage(defaultProps.getColorModel(),
|
||||||
|
defaultProps.getRaster(),
|
||||||
|
defaultProps.isAlphaPremultiplied(),
|
||||||
|
properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void validate(final BufferedImage bi, final int expected) {
|
||||||
|
final String[] names = bi.getPropertyNames();
|
||||||
|
if (names.length != expected) {
|
||||||
|
throw new RuntimeException("Wrong number of names");
|
||||||
|
}
|
||||||
|
for (final String name : names) {
|
||||||
|
final Object property = bi.getProperty(name);
|
||||||
|
if (property == Image.UndefinedProperty || property == null) {
|
||||||
|
throw new RuntimeException("Unexpected property");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
205
jdk/test/javax/imageio/plugins/jpeg/MagentaEXIFTest.java
Normal file
205
jdk/test/javax/imageio/plugins/jpeg/MagentaEXIFTest.java
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code 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
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @bug 8071707 6243376
|
||||||
|
* @summary Test verifies that EXIF images with differing sampling factors
|
||||||
|
* are written correctly
|
||||||
|
*
|
||||||
|
* @run main MagentaEXIFTest
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
|
||||||
|
import javax.imageio.IIOImage;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.imageio.ImageReader;
|
||||||
|
import javax.imageio.ImageTypeSpecifier;
|
||||||
|
import javax.imageio.ImageWriteParam;
|
||||||
|
import javax.imageio.ImageWriter;
|
||||||
|
import javax.imageio.metadata.IIOInvalidTreeException;
|
||||||
|
import javax.imageio.metadata.IIOMetadata;
|
||||||
|
import javax.imageio.metadata.IIOMetadataNode;
|
||||||
|
import javax.imageio.stream.ImageInputStream;
|
||||||
|
import javax.imageio.stream.ImageOutputStream;
|
||||||
|
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
|
import org.w3c.dom.NamedNodeMap;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
|
|
||||||
|
public class MagentaEXIFTest {
|
||||||
|
|
||||||
|
public static void main(final String[] argv) throws Exception {
|
||||||
|
|
||||||
|
IIOMetadata jpegmetadata = null;
|
||||||
|
ImageWriter jpgWriter = ImageIO.getImageWritersByFormatName("jpg").next();
|
||||||
|
try {
|
||||||
|
jpegmetadata = createJPEGMetadata(jpgWriter);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
ImageOutputStream output = ImageIO.createImageOutputStream(baos);
|
||||||
|
jpgWriter.setOutput(output);
|
||||||
|
int w=100, h=100;
|
||||||
|
BufferedImage bi = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
|
||||||
|
Graphics2D g2d = bi.createGraphics();
|
||||||
|
g2d.setColor(Color.white);
|
||||||
|
g2d.fillRect(0, 0, w, h);
|
||||||
|
IIOImage image = new IIOImage(bi, null, jpegmetadata);
|
||||||
|
jpgWriter.write(null, image, null);
|
||||||
|
jpgWriter.dispose();
|
||||||
|
|
||||||
|
baos.flush();
|
||||||
|
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||||
|
ImageInputStream iis = ImageIO.createImageInputStream(bais);
|
||||||
|
bi = ImageIO.read(iis);
|
||||||
|
for (int i=0; i<bi.getWidth(); i++) {
|
||||||
|
for(int j=0; j<bi.getHeight(); j++) {
|
||||||
|
if (bi.getRGB(i, j) != Color.white.getRGB()) {
|
||||||
|
throw new RuntimeException("Wrong color : " + Integer.toHexString(bi.getRGB(i, j)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void displayMetadata(Node node, int level) {
|
||||||
|
for (int i = 0; i < level; i++) System.out.print(" ");
|
||||||
|
System.out.print("<" + node.getNodeName());
|
||||||
|
NamedNodeMap map = node.getAttributes();
|
||||||
|
if (map != null) { // print attribute values
|
||||||
|
int length = map.getLength();
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
Node attr = map.item(i);
|
||||||
|
System.out.print(" " + attr.getNodeName() +
|
||||||
|
"=\"" + attr.getNodeValue() + "\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Node child = node.getFirstChild();
|
||||||
|
if (child != null) {
|
||||||
|
System.out.println(">"); // close current tag
|
||||||
|
while (child != null) { // emit child tags recursively
|
||||||
|
displayMetadata(child, level + 1);
|
||||||
|
child = child.getNextSibling();
|
||||||
|
}
|
||||||
|
for (int i = 0; i < level; i++) System.out.print(" ");
|
||||||
|
System.out.println("</" + node.getNodeName() + ">");
|
||||||
|
} else {
|
||||||
|
System.out.println("/>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Construct a JPEG IIOMetadata that has had the JFIF marker removed and
|
||||||
|
* an APP1 EXIF marker added, and further massaged so that we have differing
|
||||||
|
* horizontal and vertical sampling factors for one channel.
|
||||||
|
*/
|
||||||
|
static IIOMetadata createJPEGMetadata(ImageWriter iw) throws IIOInvalidTreeException {
|
||||||
|
String jpegMDName = "javax_imageio_jpeg_image_1.0";
|
||||||
|
ImageWriter imgWriter = ImageIO.getImageWritersByFormatName("jpg").next();
|
||||||
|
BufferedImage bi = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
|
||||||
|
ImageTypeSpecifier ist = new ImageTypeSpecifier(bi);
|
||||||
|
IIOMetadata metadata = imgWriter.getDefaultImageMetadata(ist, null);
|
||||||
|
|
||||||
|
IIOMetadataNode root = new IIOMetadataNode(jpegMDName);
|
||||||
|
IIOMetadataNode header = new IIOMetadataNode("JPEGvariety");
|
||||||
|
IIOMetadataNode sequence = new IIOMetadataNode("markerSequence");
|
||||||
|
|
||||||
|
root.appendChild(header);
|
||||||
|
root.appendChild(sequence);
|
||||||
|
|
||||||
|
IIOMetadataNode app1 = new IIOMetadataNode("unknown");
|
||||||
|
app1.setUserObject(new byte[255]);
|
||||||
|
app1.setAttribute("MarkerTag", "255");
|
||||||
|
sequence.appendChild(app1);
|
||||||
|
|
||||||
|
IIOMetadataNode sof = new IIOMetadataNode("sof");
|
||||||
|
sof.setAttribute("process", "0");
|
||||||
|
sof.setAttribute("samplePrecision", "8");
|
||||||
|
sof.setAttribute("numLines", "100");
|
||||||
|
sof.setAttribute("samplesPerLine", "100");
|
||||||
|
sof.setAttribute("numFrameComponents", "3");
|
||||||
|
IIOMetadataNode c1 = new IIOMetadataNode("componentSpec");
|
||||||
|
c1.setAttribute("componentId", "1");
|
||||||
|
c1.setAttribute("HsamplingFactor", "1");
|
||||||
|
c1.setAttribute("VsamplingFactor", "2");
|
||||||
|
c1.setAttribute("QtableSelector", "1");
|
||||||
|
sof.appendChild(c1);
|
||||||
|
IIOMetadataNode c2 = new IIOMetadataNode("componentSpec");
|
||||||
|
c2.setAttribute("componentId", "2");
|
||||||
|
c2.setAttribute("HsamplingFactor", "1");
|
||||||
|
c2.setAttribute("VsamplingFactor", "1");
|
||||||
|
c2.setAttribute("QtableSelector", "1");
|
||||||
|
sof.appendChild(c2);
|
||||||
|
IIOMetadataNode c3 = new IIOMetadataNode("componentSpec");
|
||||||
|
c3.setAttribute("componentId", "3");
|
||||||
|
c3.setAttribute("HsamplingFactor", "1");
|
||||||
|
c3.setAttribute("VsamplingFactor", "1");
|
||||||
|
c3.setAttribute("QtableSelector", "1");
|
||||||
|
sof.appendChild(c3);
|
||||||
|
sequence.appendChild(sof);
|
||||||
|
metadata.setFromTree(jpegMDName, root);
|
||||||
|
IIOMetadata def = imgWriter.getDefaultImageMetadata(ist, null);
|
||||||
|
metadata.mergeTree(jpegMDName, def.getAsTree(jpegMDName));
|
||||||
|
Node tree = metadata.getAsTree(jpegMDName);
|
||||||
|
Node variety = tree.getFirstChild();
|
||||||
|
Node jfif = variety.getFirstChild();
|
||||||
|
variety.removeChild(jfif);
|
||||||
|
sequence = (IIOMetadataNode)tree.getLastChild();
|
||||||
|
NodeList markers = sequence.getChildNodes();
|
||||||
|
IIOMetadataNode n, sofNode=null;
|
||||||
|
for (int i=0;i<markers.getLength();i++) {
|
||||||
|
n = (IIOMetadataNode)markers.item(i);
|
||||||
|
if (n.getNodeName().equals("sof")) {
|
||||||
|
sofNode = n;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IIOMetadataNode componentSpec = (IIOMetadataNode)sofNode.getFirstChild();
|
||||||
|
Attr attr = componentSpec.getAttributeNode("HsamplingFactor");
|
||||||
|
attr.setValue("1");
|
||||||
|
attr = componentSpec.getAttributeNode("VsamplingFactor");
|
||||||
|
attr.setValue("2");
|
||||||
|
metadata.setFromTree(jpegMDName, tree);
|
||||||
|
String[] names = metadata.getMetadataFormatNames();
|
||||||
|
int length = names.length;
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
System.out.println( "Format name: " + names[ i ] );
|
||||||
|
displayMetadata(metadata.getAsTree(names[i]), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return metadata;
|
||||||
|
}
|
||||||
|
}
|
212
jdk/test/javax/imageio/plugins/shared/WriteAfterAbort.java
Normal file
212
jdk/test/javax/imageio/plugins/shared/WriteAfterAbort.java
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code 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
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.imageio.ImageWriter;
|
||||||
|
import javax.imageio.event.IIOWriteProgressListener;
|
||||||
|
import javax.imageio.spi.IIORegistry;
|
||||||
|
import javax.imageio.spi.ImageWriterSpi;
|
||||||
|
import javax.imageio.stream.ImageOutputStream;
|
||||||
|
|
||||||
|
import static java.awt.image.BufferedImage.TYPE_BYTE_BINARY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @bug 4952954
|
||||||
|
* @summary abortFlag must be cleared for every ImageWriter.write operation
|
||||||
|
* @author Sergey Bylokhov
|
||||||
|
*/
|
||||||
|
public final class WriteAfterAbort implements IIOWriteProgressListener {
|
||||||
|
|
||||||
|
private volatile boolean abortFlag = true;
|
||||||
|
private volatile boolean isAbortCalled;
|
||||||
|
private volatile boolean isCompleteCalled;
|
||||||
|
private volatile boolean isProgressCalled;
|
||||||
|
private volatile boolean isStartedCalled;
|
||||||
|
private static final int WIDTH = 100;
|
||||||
|
private static final int HEIGHT = 100;
|
||||||
|
|
||||||
|
private void test(final ImageWriter writer) throws IOException {
|
||||||
|
// Image initialization
|
||||||
|
final BufferedImage imageWrite = new BufferedImage(WIDTH, HEIGHT,
|
||||||
|
TYPE_BYTE_BINARY);
|
||||||
|
final Graphics2D g = imageWrite.createGraphics();
|
||||||
|
g.setColor(Color.WHITE);
|
||||||
|
g.fillRect(0, 0, WIDTH, HEIGHT);
|
||||||
|
g.dispose();
|
||||||
|
|
||||||
|
// File initialization
|
||||||
|
final File file = File.createTempFile("temp", ".img");
|
||||||
|
file.deleteOnExit();
|
||||||
|
final FileOutputStream fos = new SkipWriteOnAbortOutputStream(file);
|
||||||
|
final ImageOutputStream ios = ImageIO.createImageOutputStream(fos);
|
||||||
|
writer.setOutput(ios);
|
||||||
|
writer.addIIOWriteProgressListener(this);
|
||||||
|
|
||||||
|
// This write will be aborted, and file will not be touched
|
||||||
|
writer.write(imageWrite);
|
||||||
|
if (!isStartedCalled) {
|
||||||
|
throw new RuntimeException("Started should be called");
|
||||||
|
}
|
||||||
|
if (!isProgressCalled) {
|
||||||
|
throw new RuntimeException("Progress should be called");
|
||||||
|
}
|
||||||
|
if (!isAbortCalled) {
|
||||||
|
throw new RuntimeException("Abort should be called");
|
||||||
|
}
|
||||||
|
if (isCompleteCalled) {
|
||||||
|
throw new RuntimeException("Complete should not be called");
|
||||||
|
}
|
||||||
|
// Flush aborted data
|
||||||
|
ios.flush();
|
||||||
|
|
||||||
|
// This write should be completed successfully and the file should
|
||||||
|
// contain correct image data.
|
||||||
|
abortFlag = false;
|
||||||
|
isAbortCalled = false;
|
||||||
|
isCompleteCalled = false;
|
||||||
|
isProgressCalled = false;
|
||||||
|
isStartedCalled = false;
|
||||||
|
writer.write(imageWrite);
|
||||||
|
|
||||||
|
if (!isStartedCalled) {
|
||||||
|
throw new RuntimeException("Started should be called");
|
||||||
|
}
|
||||||
|
if (!isProgressCalled) {
|
||||||
|
throw new RuntimeException("Progress should be called");
|
||||||
|
}
|
||||||
|
if (isAbortCalled) {
|
||||||
|
throw new RuntimeException("Abort should not be called");
|
||||||
|
}
|
||||||
|
if (!isCompleteCalled) {
|
||||||
|
throw new RuntimeException("Complete should be called");
|
||||||
|
}
|
||||||
|
writer.dispose();
|
||||||
|
ios.close();
|
||||||
|
|
||||||
|
// Validates content of the file.
|
||||||
|
final BufferedImage imageRead = ImageIO.read(file);
|
||||||
|
for (int x = 0; x < WIDTH; ++x) {
|
||||||
|
for (int y = 0; y < HEIGHT; ++y) {
|
||||||
|
if (imageRead.getRGB(x, y) != imageWrite.getRGB(x, y)) {
|
||||||
|
throw new RuntimeException("Test failed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(final String[] args) throws IOException {
|
||||||
|
final IIORegistry registry = IIORegistry.getDefaultInstance();
|
||||||
|
final Iterator<ImageWriterSpi> iter = registry.getServiceProviders(
|
||||||
|
ImageWriterSpi.class, provider -> true, true);
|
||||||
|
|
||||||
|
// Validates all supported ImageWriters
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
final WriteAfterAbort writeAfterAbort = new WriteAfterAbort();
|
||||||
|
final ImageWriter writer = iter.next().createWriterInstance();
|
||||||
|
System.out.println("ImageWriter = " + writer);
|
||||||
|
writeAfterAbort.test(writer);
|
||||||
|
}
|
||||||
|
System.out.println("Test passed");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Callbacks
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void imageComplete(ImageWriter source) {
|
||||||
|
isCompleteCalled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void imageProgress(ImageWriter source, float percentageDone) {
|
||||||
|
isProgressCalled = true;
|
||||||
|
if (percentageDone > 50 && abortFlag) {
|
||||||
|
source.abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void imageStarted(ImageWriter source, int imageIndex) {
|
||||||
|
isStartedCalled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeAborted(final ImageWriter source) {
|
||||||
|
isAbortCalled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void thumbnailComplete(ImageWriter source) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void thumbnailProgress(ImageWriter source, float percentageDone) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void thumbnailStarted(ImageWriter source, int imageIndex,
|
||||||
|
int thumbnailIndex) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We need to skip writes on abort, because content of the file after abort
|
||||||
|
* is undefined.
|
||||||
|
*/
|
||||||
|
private class SkipWriteOnAbortOutputStream extends FileOutputStream {
|
||||||
|
|
||||||
|
SkipWriteOnAbortOutputStream(File file) throws FileNotFoundException {
|
||||||
|
super(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(int b) throws IOException {
|
||||||
|
if (!abortFlag) {
|
||||||
|
super.write(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(byte[] b) throws IOException {
|
||||||
|
if (!abortFlag) {
|
||||||
|
super.write(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(byte[] b, int off, int len) throws IOException {
|
||||||
|
if (!abortFlag) {
|
||||||
|
super.write(b, off, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
120
jdk/test/javax/print/PrintSEUmlauts/PrintSEUmlauts.java
Normal file
120
jdk/test/javax/print/PrintSEUmlauts/PrintSEUmlauts.java
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Oracle designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Oracle in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code 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
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.awt.print.PageFormat;
|
||||||
|
import java.awt.print.Printable;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import javax.print.DocFlavor;
|
||||||
|
import javax.print.DocPrintJob;
|
||||||
|
import javax.print.SimpleDoc;
|
||||||
|
import javax.print.StreamPrintService;
|
||||||
|
import javax.print.StreamPrintServiceFactory;
|
||||||
|
import javax.print.attribute.HashDocAttributeSet;
|
||||||
|
import javax.print.attribute.HashPrintRequestAttributeSet;
|
||||||
|
import javax.print.event.PrintJobAdapter;
|
||||||
|
import javax.print.event.PrintJobEvent;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 8067364
|
||||||
|
* @summary Printing to Postscript doesn't support dieresis
|
||||||
|
* @build PrintSEUmlauts
|
||||||
|
* @run main/othervm PrintSEUmlauts
|
||||||
|
*/
|
||||||
|
public class PrintSEUmlauts implements Printable {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
|
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||||
|
|
||||||
|
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
|
||||||
|
String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();
|
||||||
|
|
||||||
|
StreamPrintServiceFactory[] factories =
|
||||||
|
StreamPrintServiceFactory.
|
||||||
|
lookupStreamPrintServiceFactories(flavor, mime);
|
||||||
|
if (factories.length == 0) {
|
||||||
|
System.out.println("No print service found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileOutputStream output = new FileOutputStream("out.ps");
|
||||||
|
StreamPrintService service = factories[0].getPrintService(output);
|
||||||
|
|
||||||
|
SimpleDoc doc =
|
||||||
|
new SimpleDoc(new PrintSEUmlauts(),
|
||||||
|
DocFlavor.SERVICE_FORMATTED.PRINTABLE,
|
||||||
|
new HashDocAttributeSet());
|
||||||
|
DocPrintJob job = service.createPrintJob();
|
||||||
|
job.addPrintJobListener(new PrintJobAdapter() {
|
||||||
|
@Override
|
||||||
|
public void printJobCompleted(PrintJobEvent pje) {
|
||||||
|
testPrintAndExit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
job.print(doc, new HashPrintRequestAttributeSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final boolean DEBUG = false;
|
||||||
|
private static void testPrintAndExit() {
|
||||||
|
String expected = "<e4> 7.44 100.0 100.0 S";
|
||||||
|
String content = "";
|
||||||
|
|
||||||
|
File file = new File("out.ps");
|
||||||
|
if (!DEBUG) {
|
||||||
|
file.deleteOnExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
try (FileInputStream stream = new FileInputStream(file)) {
|
||||||
|
byte[] data = new byte[(int) file.length()];
|
||||||
|
stream.read(data);
|
||||||
|
content = new String(data, StandardCharsets.ISO_8859_1);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!content.contains(expected)) {
|
||||||
|
System.err.println("FAIL");
|
||||||
|
if (DEBUG) {
|
||||||
|
System.err.println("printing content");
|
||||||
|
System.err.println(content);
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Expected <e4> to represent 'ä' but not found!");
|
||||||
|
}
|
||||||
|
System.err.println("SUCCESS");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int print(Graphics g, PageFormat pf, int pg) {
|
||||||
|
if (pg > 0) return NO_SUCH_PAGE;
|
||||||
|
g.drawString("ä", 100, 100);
|
||||||
|
return PAGE_EXISTS;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code 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
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.awt.image.ImageObserver;
|
||||||
|
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
|
import static java.awt.image.BufferedImage.TYPE_INT_RGB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @bug 6573305
|
||||||
|
* @summary Animated icon should animate when the JButton is pressed.
|
||||||
|
* @author Sergey Bylokhov
|
||||||
|
*/
|
||||||
|
public final class AnimatedIcon {
|
||||||
|
|
||||||
|
public static void main(final String[] args) throws Exception {
|
||||||
|
SwingUtilities.invokeAndWait(() -> {
|
||||||
|
final BufferedImage bi = new BufferedImage(1, 1, TYPE_INT_RGB);
|
||||||
|
final ImageIcon icon = new ImageIcon(bi);
|
||||||
|
final JButton button = new JButton(icon);
|
||||||
|
// Default icon is set => imageUpdate should return true for it
|
||||||
|
isAnimated(bi, button);
|
||||||
|
button.getModel().setPressed(true);
|
||||||
|
button.getModel().setArmed(true);
|
||||||
|
isAnimated(bi, button);
|
||||||
|
button.getModel().setPressed(false);
|
||||||
|
button.getModel().setArmed(false);
|
||||||
|
button.getModel().setSelected(true);
|
||||||
|
isAnimated(bi, button);
|
||||||
|
button.getModel().setSelected(false);
|
||||||
|
button.getModel().setRollover(true);
|
||||||
|
button.setRolloverEnabled(true);
|
||||||
|
isAnimated(bi, button);
|
||||||
|
button.getModel().setSelected(true);
|
||||||
|
isAnimated(bi, button);
|
||||||
|
// Default icon is not set => imageUpdate should return true for
|
||||||
|
// other icons if any
|
||||||
|
button.setIcon(null);
|
||||||
|
button.setPressedIcon(icon);
|
||||||
|
button.getModel().setPressed(true);
|
||||||
|
button.getModel().setArmed(true);
|
||||||
|
isAnimated(bi, button);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void isAnimated(BufferedImage bi, JButton button) {
|
||||||
|
if (!button.imageUpdate(bi, ImageObserver.SOMEBITS, 0, 0, 1, 1)) {
|
||||||
|
throw new RuntimeException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -38,9 +38,20 @@ public class Test4177735 implements Runnable {
|
|||||||
private static final long DELAY = 1000L;
|
private static final long DELAY = 1000L;
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
int hsvIndex = 0;
|
||||||
|
int panelsLength;
|
||||||
|
int finalIndex;
|
||||||
JColorChooser chooser = new JColorChooser();
|
JColorChooser chooser = new JColorChooser();
|
||||||
AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
|
AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
|
||||||
chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] });
|
panelsLength = panels.length;
|
||||||
|
|
||||||
|
for(int i = 0; i < panelsLength; i++) {
|
||||||
|
if(panels[i].getDisplayName().equals("HSV")) {
|
||||||
|
hsvIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finalIndex = Math.min(hsvIndex, panelsLength - 1);
|
||||||
|
chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[finalIndex] });
|
||||||
|
|
||||||
JDialog dialog = show(chooser);
|
JDialog dialog = show(chooser);
|
||||||
pause(DELAY);
|
pause(DELAY);
|
||||||
|
@ -59,7 +59,7 @@ public class bug6824395 {
|
|||||||
editorPaneLayer.setUI(layerUI);
|
editorPaneLayer.setUI(layerUI);
|
||||||
|
|
||||||
scrollPane = new JScrollPane(editorPaneLayer);
|
scrollPane = new JScrollPane(editorPaneLayer);
|
||||||
|
scrollPane.setViewportBorder(null);
|
||||||
scrollPane.setPreferredSize(new Dimension(200, 250));
|
scrollPane.setPreferredSize(new Dimension(200, 250));
|
||||||
frame.add(scrollPane);
|
frame.add(scrollPane);
|
||||||
|
|
||||||
|
35
jdk/test/javax/swing/JTabbedPane/4209065/bug4209065.html
Normal file
35
jdk/test/javax/swing/JTabbedPane/4209065/bug4209065.html
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
|
||||||
|
This code is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License version 2 only, as
|
||||||
|
published by the Free Software Foundation.
|
||||||
|
|
||||||
|
This code 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
|
||||||
|
version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
accompanied this code).
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License version
|
||||||
|
2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
or visit www.oracle.com if you need additional information or have any
|
||||||
|
questions.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<Html>
|
||||||
|
<Body>
|
||||||
|
<!--
|
||||||
|
<H1>Test</H1>
|
||||||
|
<Center>
|
||||||
|
<APPLET code="bug4209065.class" WIDTH = 600 HEIGHT = 400>
|
||||||
|
</APPLET>
|
||||||
|
</Center>
|
||||||
|
-->
|
||||||
|
|
||||||
|
</Body>
|
||||||
|
</Html>
|
57
jdk/test/javax/swing/JTabbedPane/4209065/bug4209065.java
Normal file
57
jdk/test/javax/swing/JTabbedPane/4209065/bug4209065.java
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code 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
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
|
import javax.swing.JApplet;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JTabbedPane;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @bug 4209065
|
||||||
|
* @author Georges Saab
|
||||||
|
* @run applet/manual=yesno bug4209065.html
|
||||||
|
*/
|
||||||
|
public final class bug4209065 extends JApplet {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
try {
|
||||||
|
EventQueue.invokeAndWait(this::createTabbedPane);
|
||||||
|
} catch (InterruptedException | InvocationTargetException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createTabbedPane() {
|
||||||
|
JTabbedPane tp = new JTabbedPane();
|
||||||
|
getContentPane().add(tp);
|
||||||
|
String text = "<html><center>If the style of the text on the tabs matches"
|
||||||
|
+ "<br>the descriptions, press <em><b>PASS</b></em></center></html>";
|
||||||
|
tp.addTab("<html><center><font size=+3>big</font></center></html>", new JLabel(text));
|
||||||
|
tp.addTab("<html><center><font color=red>red</font></center></html>", new JLabel(text));
|
||||||
|
tp.addTab("<html><center><em><b>Bold Italic!</b></em></center></html>", new JLabel(text));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code 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
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Robot;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
|
import static java.awt.image.BufferedImage.TYPE_INT_ARGB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @bug 8015085
|
||||||
|
* @summary Shortening via " ... " is broken for Strings containing a combining
|
||||||
|
* diaeresis.
|
||||||
|
* @author Sergey Bylokhov
|
||||||
|
*/
|
||||||
|
public class TestBadBreak {
|
||||||
|
|
||||||
|
static JFrame frame;
|
||||||
|
static Robot robot;
|
||||||
|
static final String withCombiningDiaeresis = "123p://.aaaaaaaaaaaaaaaaaaaaaa.123/a\u0308" ;
|
||||||
|
static final String withoutCombiningDiaeresis = "123p://.aaaaaaaaaaaaaaaaaaaaaa.123/\u00E4" ;
|
||||||
|
|
||||||
|
public static void main(final String[] args) throws Exception {
|
||||||
|
robot = new Robot();
|
||||||
|
final BufferedImage bi1 = new BufferedImage(200, 90, TYPE_INT_ARGB);
|
||||||
|
final BufferedImage bi2 = new BufferedImage(200, 90, TYPE_INT_ARGB);
|
||||||
|
test(withCombiningDiaeresis, bi1);
|
||||||
|
test(withoutCombiningDiaeresis, bi2);
|
||||||
|
for (int x = 0; x < bi1.getWidth(); ++x) {
|
||||||
|
for (int y = 0; y < bi1.getHeight(); ++y) {
|
||||||
|
if (bi1.getRGB(x, y) != bi2.getRGB(x, y)) {
|
||||||
|
ImageIO.write(bi1, "png", new File("image1.png"));
|
||||||
|
ImageIO.write(bi2, "png", new File("image2.png"));
|
||||||
|
throw new RuntimeException("Wrong color");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void test(final String text, final BufferedImage i1)
|
||||||
|
throws Exception {
|
||||||
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
frame = new JFrame();
|
||||||
|
final JLabel label = new JLabel(text) {
|
||||||
|
@Override
|
||||||
|
protected void paintComponent(Graphics g) {
|
||||||
|
Graphics2D g2d = i1.createGraphics();
|
||||||
|
super.paintComponent(g2d);
|
||||||
|
g2d.dispose();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
frame.getContentPane().add(label);
|
||||||
|
frame.setBounds(200, 200, 200, 90);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
robot.waitForIdle();
|
||||||
|
SwingUtilities.invokeAndWait(() -> frame.setVisible(true));
|
||||||
|
robot.waitForIdle();
|
||||||
|
SwingUtilities.invokeAndWait(frame::dispose);
|
||||||
|
robot.waitForIdle();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user