Merge
This commit is contained in:
commit
dfdd614819
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2017, 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
|
||||
@ -211,6 +211,10 @@ public final class CFont extends PhysicalFont implements FontSubstitution {
|
||||
ArrayList<String> listOfString = new ArrayList<String>();
|
||||
getCascadeList(nativeFontPtr, listOfString);
|
||||
|
||||
// add JRE "Lucida Sans Regular" to the cascade list to enable fallback
|
||||
// to happen to this JRE font in case the intended glyph is missing in
|
||||
// fonts provided in the CoreText provided cascaded list
|
||||
listOfString.add("Lucida Sans Regular");
|
||||
FontManager fm = FontManagerFactory.getInstance();
|
||||
int numFonts = 1 + listOfString.size();
|
||||
PhysicalFont[] fonts = new PhysicalFont[numFonts];
|
||||
|
@ -265,9 +265,8 @@ final class CPlatformResponder {
|
||||
|
||||
static class DeltaAccumulator {
|
||||
|
||||
static final double MIN_THRESHOLD = 0.1;
|
||||
static final double MAX_THRESHOLD = 0.5;
|
||||
double accumulatedDelta;
|
||||
boolean accumulate;
|
||||
|
||||
int getRoundedDelta(double delta, int scrollPhase) {
|
||||
|
||||
@ -278,25 +277,23 @@ final class CPlatformResponder {
|
||||
roundDelta = delta > 0 ? 1 : -1;
|
||||
}
|
||||
} else { // trackpad
|
||||
boolean begin = scrollPhase == NSEvent.SCROLL_PHASE_BEGAN;
|
||||
boolean end = scrollPhase == NSEvent.SCROLL_MASK_PHASE_ENDED
|
||||
|| scrollPhase == NSEvent.SCROLL_MASK_PHASE_CANCELLED;
|
||||
|
||||
if (begin) {
|
||||
if (scrollPhase == NSEvent.SCROLL_PHASE_BEGAN) {
|
||||
accumulatedDelta = 0;
|
||||
accumulate = true;
|
||||
}
|
||||
else if (scrollPhase == NSEvent.SCROLL_PHASE_MOMENTUM_BEGAN) {
|
||||
accumulate = true;
|
||||
}
|
||||
if (accumulate) {
|
||||
|
||||
accumulatedDelta += delta;
|
||||
accumulatedDelta += delta;
|
||||
|
||||
double absAccumulatedDelta = Math.abs(accumulatedDelta);
|
||||
if (absAccumulatedDelta > MAX_THRESHOLD) {
|
||||
roundDelta = (int) Math.round(accumulatedDelta);
|
||||
accumulatedDelta -= roundDelta;
|
||||
}
|
||||
|
||||
if (end) {
|
||||
if (roundDelta == 0 && absAccumulatedDelta > MIN_THRESHOLD) {
|
||||
roundDelta = accumulatedDelta > 0 ? 1 : -1;
|
||||
accumulatedDelta -= roundDelta;
|
||||
|
||||
if (scrollPhase == NSEvent.SCROLL_PHASE_ENDED) {
|
||||
accumulate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,8 +36,8 @@ final class NSEvent {
|
||||
static final int SCROLL_PHASE_UNSUPPORTED = 1;
|
||||
static final int SCROLL_PHASE_BEGAN = 2;
|
||||
static final int SCROLL_PHASE_CONTINUED = 3;
|
||||
static final int SCROLL_MASK_PHASE_CANCELLED = 4;
|
||||
static final int SCROLL_MASK_PHASE_ENDED = 5;
|
||||
static final int SCROLL_PHASE_MOMENTUM_BEGAN = 4;
|
||||
static final int SCROLL_PHASE_ENDED = 5;
|
||||
|
||||
private int type;
|
||||
private int modifierFlags;
|
||||
|
@ -381,6 +381,13 @@ static BOOL shouldUsePressAndHold() {
|
||||
} else {
|
||||
clickCount = [event clickCount];
|
||||
}
|
||||
|
||||
jdouble deltaX = [event deltaX];
|
||||
jdouble deltaY = [event deltaY];
|
||||
if ([AWTToolkit hasPreciseScrollingDeltas: event]) {
|
||||
deltaX = [event scrollingDeltaX] * 0.1;
|
||||
deltaY = [event scrollingDeltaY] * 0.1;
|
||||
}
|
||||
|
||||
static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
|
||||
static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDDI)V");
|
||||
@ -391,8 +398,8 @@ static BOOL shouldUsePressAndHold() {
|
||||
[event buttonNumber],
|
||||
(jint)localPoint.x, (jint)localPoint.y,
|
||||
(jint)absP.x, (jint)absP.y,
|
||||
[event deltaY],
|
||||
[event deltaX],
|
||||
deltaY,
|
||||
deltaX,
|
||||
[AWTToolkit scrollStateWithEvent: event]);
|
||||
CHECK_NULL(jEvent);
|
||||
|
||||
|
@ -139,7 +139,14 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize, BOOL autosize) {
|
||||
jint clickCount;
|
||||
|
||||
clickCount = [event clickCount];
|
||||
|
||||
|
||||
jdouble deltaX = [event deltaX];
|
||||
jdouble deltaY = [event deltaY];
|
||||
if ([AWTToolkit hasPreciseScrollingDeltas: event]) {
|
||||
deltaX = [event scrollingDeltaX] * 0.1;
|
||||
deltaY = [event scrollingDeltaY] * 0.1;
|
||||
}
|
||||
|
||||
static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
|
||||
static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDDI)V");
|
||||
jobject jEvent = JNFNewObject(env, jctor_NSEvent,
|
||||
@ -149,8 +156,8 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize, BOOL autosize) {
|
||||
[event buttonNumber],
|
||||
(jint)localPoint.x, (jint)localPoint.y,
|
||||
(jint)absP.x, (jint)absP.y,
|
||||
[event deltaY],
|
||||
[event deltaX],
|
||||
deltaY,
|
||||
deltaX,
|
||||
[AWTToolkit scrollStateWithEvent: event]);
|
||||
CHECK_NULL(jEvent);
|
||||
|
||||
|
@ -42,6 +42,7 @@ extern jint* gButtonDownMasks;
|
||||
+ (long) getEventCount;
|
||||
+ (void) eventCountPlusPlus;
|
||||
+ (jint) scrollStateWithEvent: (NSEvent*) event;
|
||||
+ (BOOL) hasPreciseScrollingDeltas: (NSEvent*) event;
|
||||
@end
|
||||
|
||||
/*
|
||||
|
@ -47,7 +47,7 @@
|
||||
#define SCROLL_PHASE_UNSUPPORTED 1
|
||||
#define SCROLL_PHASE_BEGAN 2
|
||||
#define SCROLL_PHASE_CONTINUED 3
|
||||
#define SCROLL_PHASE_CANCELLED 4
|
||||
#define SCROLL_PHASE_MOMENTUM_BEGAN 4
|
||||
#define SCROLL_PHASE_ENDED 5
|
||||
|
||||
int gNumberOfButtons;
|
||||
@ -85,16 +85,33 @@ static long eventCount;
|
||||
return 0;
|
||||
}
|
||||
|
||||
NSEventPhase phase = [event phase];
|
||||
NSEventPhase momentumPhase = [event momentumPhase];
|
||||
|
||||
if (!phase && !momentumPhase) return SCROLL_PHASE_UNSUPPORTED;
|
||||
switch (phase) {
|
||||
case NSEventPhaseBegan: return SCROLL_PHASE_BEGAN;
|
||||
case NSEventPhaseCancelled: return SCROLL_PHASE_CANCELLED;
|
||||
case NSEventPhaseEnded: return SCROLL_PHASE_ENDED;
|
||||
default: return SCROLL_PHASE_CONTINUED;
|
||||
if ([event phase]) {
|
||||
// process a phase of manual scrolling
|
||||
switch ([event phase]) {
|
||||
case NSEventPhaseBegan: return SCROLL_PHASE_BEGAN;
|
||||
case NSEventPhaseCancelled: return SCROLL_PHASE_ENDED;
|
||||
case NSEventPhaseEnded: return SCROLL_PHASE_ENDED;
|
||||
default: return SCROLL_PHASE_CONTINUED;
|
||||
}
|
||||
}
|
||||
|
||||
if ([event momentumPhase]) {
|
||||
// process a phase of automatic scrolling
|
||||
switch ([event momentumPhase]) {
|
||||
case NSEventPhaseBegan: return SCROLL_PHASE_MOMENTUM_BEGAN;
|
||||
case NSEventPhaseCancelled: return SCROLL_PHASE_ENDED;
|
||||
case NSEventPhaseEnded: return SCROLL_PHASE_ENDED;
|
||||
default: return SCROLL_PHASE_CONTINUED;
|
||||
}
|
||||
}
|
||||
// phase and momentum phase both are not set
|
||||
return SCROLL_PHASE_UNSUPPORTED;
|
||||
}
|
||||
|
||||
+ (BOOL) hasPreciseScrollingDeltas: (NSEvent*) event {
|
||||
return [event type] == NSScrollWheel
|
||||
&& [event respondsToSelector:@selector(hasPreciseScrollingDeltas)]
|
||||
&& [event hasPreciseScrollingDeltas];
|
||||
}
|
||||
@end
|
||||
|
||||
|
@ -1439,51 +1439,72 @@ public class BMPImageReader extends ImageReader implements BMPConstants {
|
||||
decodeRLE8(imSize, padding, values, bdata);
|
||||
}
|
||||
|
||||
private boolean copyRLE8ScanlineToDst(int lineNo,
|
||||
byte[] val,
|
||||
byte[] bdata) {
|
||||
// Return value
|
||||
boolean isSuccess = false;
|
||||
|
||||
// Reusing the code to copy 1 row of pixels or scanline to required
|
||||
// destination buffer.
|
||||
if (lineNo >= sourceRegion.y &&
|
||||
lineNo < sourceRegion.y + sourceRegion.height) {
|
||||
if (noTransform) {
|
||||
int pos = lineNo * width;
|
||||
for(int i = 0; i < width; i++)
|
||||
bdata[pos++] = val[i];
|
||||
processImageUpdate(bi, 0, lineNo,
|
||||
destinationRegion.width, 1, 1, 1,
|
||||
new int[]{0});
|
||||
isSuccess = true;
|
||||
} else if ((lineNo - sourceRegion.y) % scaleY == 0) {
|
||||
int lineStride =
|
||||
((ComponentSampleModel)sampleModel).getScanlineStride();
|
||||
int currentLine = (lineNo - sourceRegion.y) / scaleY +
|
||||
destinationRegion.y;
|
||||
int pos = currentLine * lineStride;
|
||||
pos += destinationRegion.x;
|
||||
for (int i = sourceRegion.x;
|
||||
i < sourceRegion.x + sourceRegion.width;
|
||||
i += scaleX)
|
||||
bdata[pos++] = val[i];
|
||||
processImageUpdate(bi, 0, currentLine,
|
||||
destinationRegion.width, 1, 1, 1,
|
||||
new int[]{0});
|
||||
isSuccess = true;
|
||||
}
|
||||
// Ensure to reset the scanline buffer once the copy is complete.
|
||||
for(int scIndex = 0; scIndex < width; scIndex++) {
|
||||
val[scIndex] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return isSuccess;
|
||||
}
|
||||
|
||||
private void decodeRLE8(int imSize,
|
||||
int padding,
|
||||
byte[] values,
|
||||
byte[] bdata) throws IOException {
|
||||
|
||||
byte val[] = new byte[width * height];
|
||||
byte val[] = new byte[width];
|
||||
int count = 0, l = 0;
|
||||
int value;
|
||||
boolean flag = false;
|
||||
int lineNo = isBottomUp ? height - 1 : 0;
|
||||
int lineStride =
|
||||
((ComponentSampleModel)sampleModel).getScanlineStride();
|
||||
int finished = 0;
|
||||
|
||||
while (count != imSize) {
|
||||
// Ensure image source has sufficient data to decode
|
||||
while ((count + 1) < imSize) {
|
||||
value = values[count++] & 0xff;
|
||||
if (value == 0) {
|
||||
switch(values[count++] & 0xff) {
|
||||
|
||||
case 0:
|
||||
// End-of-scanline marker
|
||||
if (lineNo >= sourceRegion.y &&
|
||||
lineNo < sourceRegion.y + sourceRegion.height) {
|
||||
if (noTransform) {
|
||||
int pos = lineNo * width;
|
||||
for(int i = 0; i < width; i++)
|
||||
bdata[pos++] = val[i];
|
||||
processImageUpdate(bi, 0, lineNo,
|
||||
destinationRegion.width, 1, 1, 1,
|
||||
new int[]{0});
|
||||
finished++;
|
||||
} else if ((lineNo - sourceRegion.y) % scaleY == 0) {
|
||||
int currentLine = (lineNo - sourceRegion.y) / scaleY +
|
||||
destinationRegion.y;
|
||||
int pos = currentLine * lineStride;
|
||||
pos += destinationRegion.x;
|
||||
for (int i = sourceRegion.x;
|
||||
i < sourceRegion.x + sourceRegion.width;
|
||||
i += scaleX)
|
||||
bdata[pos++] = val[i];
|
||||
processImageUpdate(bi, 0, currentLine,
|
||||
destinationRegion.width, 1, 1, 1,
|
||||
new int[]{0});
|
||||
finished++;
|
||||
}
|
||||
// Copy the decoded scanline to destination
|
||||
if (copyRLE8ScanlineToDst(lineNo, val, bdata)) {
|
||||
finished++;
|
||||
}
|
||||
processImageProgress(100.0F * finished / destinationRegion.height);
|
||||
lineNo += isBottomUp ? -1 : 1;
|
||||
@ -1492,26 +1513,62 @@ public class BMPImageReader extends ImageReader implements BMPConstants {
|
||||
if (abortRequested()) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// End-of-RLE marker
|
||||
flag = true;
|
||||
|
||||
// Check if the last decoded scanline was copied to
|
||||
// destination bitmap
|
||||
if (l != 0) {
|
||||
// Copy the decoded scanline to destination
|
||||
if (copyRLE8ScanlineToDst(lineNo, val, bdata)) {
|
||||
finished++;
|
||||
}
|
||||
processImageProgress(100.0F * finished / destinationRegion.height);
|
||||
lineNo += isBottomUp ? -1 : 1;
|
||||
l = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// delta or vector marker
|
||||
int xoff = values[count++] & 0xff;
|
||||
int yoff = values[count] & 0xff;
|
||||
// Move to the position xoff, yoff down
|
||||
l += xoff + yoff*width;
|
||||
if ((count+1) < imSize) {
|
||||
int xoff = values[count++] & 0xff;
|
||||
int yoff = values[count++] & 0xff;
|
||||
|
||||
// Check if the yOffset shifts the decoding to another
|
||||
// row. In such cases, the decoded pixels in scanline
|
||||
// buffer-val must be copied to the destination image.
|
||||
if (yoff != 0) {
|
||||
// Copy the decoded scanline to destination
|
||||
if (copyRLE8ScanlineToDst(lineNo, val, bdata)) {
|
||||
finished++;
|
||||
}
|
||||
processImageProgress(100.0F * finished
|
||||
/ destinationRegion.height);
|
||||
lineNo += isBottomUp ? -yoff : yoff;
|
||||
}
|
||||
|
||||
// Move to the position xoff, yoff down
|
||||
l += xoff + yoff*width;
|
||||
l %= width;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
int end = values[count-1] & 0xff;
|
||||
for (int i=0; i<end; i++) {
|
||||
val[l++] = (byte)(values[count++] & 0xff);
|
||||
byte readByte = 0;
|
||||
// Ensure to check if the source index-count, does not
|
||||
// exceed the source image size
|
||||
for (int i=0; (i < end) && (count < imSize); i++) {
|
||||
readByte = (byte)(values[count++] & 0xff);
|
||||
// Ensure to check if scanline index-l, does not
|
||||
// exceed the scanline buffer size (width of image)
|
||||
if (l < width) {
|
||||
val[l++] = readByte;
|
||||
}
|
||||
}
|
||||
|
||||
// Whenever end pixels can fit into odd number of bytes,
|
||||
@ -1519,10 +1576,16 @@ public class BMPImageReader extends ImageReader implements BMPConstants {
|
||||
if ((end & 1) == 1) {
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
for (int i=0; i<value; i++) {
|
||||
val[l++] = (byte)(values[count] & 0xff);
|
||||
// Encoded mode
|
||||
// Ensure to check if the source index-count, does not
|
||||
// exceed the source image size
|
||||
if (count < imSize) {
|
||||
for (int i=0; (i < value) && (l < width); i++) {
|
||||
val[l++] = (byte)(values[count] & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
count++;
|
||||
|
@ -335,7 +335,7 @@ public class Desktop {
|
||||
* most of the platforms support the {@link Desktop.Action#OPEN}
|
||||
* action. But for a specific file, there may not be an
|
||||
* application registered to open it. In this case, {@link
|
||||
* #isSupported} may return {@code true}, but the corresponding
|
||||
* #isSupported(Action)} may return {@code true}, but the corresponding
|
||||
* action method will throw an {@link IOException}.
|
||||
*
|
||||
* @param action the specified {@link Action}
|
||||
@ -720,7 +720,7 @@ public class Desktop {
|
||||
* default behavior.
|
||||
*
|
||||
* @param aboutHandler the handler to respond to the
|
||||
* {@link java.awt.desktop.AboutHandler#handleAbout} )} message
|
||||
* {@link java.awt.desktop.AboutHandler#handleAbout(AboutEvent)} message
|
||||
*
|
||||
* @throws SecurityException if a security manager exists and it
|
||||
* denies the
|
||||
@ -828,7 +828,7 @@ public class Desktop {
|
||||
* open a URL.
|
||||
*
|
||||
* Setting the handler to {@code null} causes all
|
||||
* {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} requests to be
|
||||
* {@link OpenURIHandler#openURI(OpenURIEvent)} requests to be
|
||||
* enqueued until another handler is set.
|
||||
*
|
||||
* @implNote Please note that for Mac OS, notifications
|
||||
|
@ -30,8 +30,8 @@ package java.awt.desktop;
|
||||
* Event sent when the application has become the foreground app, and when it is
|
||||
* no longer the foreground app.
|
||||
*
|
||||
* @see AppForegroundListener#appRaisedToForeground(AppEvent.AppForegroundEvent)
|
||||
* @see AppForegroundListener#appMovedToBackground(AppEvent.AppForegroundEvent)
|
||||
* @see AppForegroundListener#appRaisedToForeground(AppForegroundEvent)
|
||||
* @see AppForegroundListener#appMovedToBackground(AppForegroundEvent)
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
|
@ -29,8 +29,8 @@ package java.awt.desktop;
|
||||
/**
|
||||
* Event sent when the application has been hidden or shown.
|
||||
*
|
||||
* @see AppHiddenListener#appHidden(AppEvent.AppHiddenEvent)
|
||||
* @see AppHiddenListener#appUnhidden(AppEvent.AppHiddenEvent)
|
||||
* @see AppHiddenListener#appHidden(AppHiddenEvent)
|
||||
* @see AppHiddenListener#appUnhidden(AppHiddenEvent)
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
|
@ -29,7 +29,7 @@ package java.awt.desktop;
|
||||
/**
|
||||
* Event sent when the application is asked to re-open itself.
|
||||
*
|
||||
* @see AppReopenedListener#appReopened(AppEvent.AppReopenedEvent)
|
||||
* @see AppReopenedListener#appReopened(AppReopenedEvent)
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
|
@ -31,7 +31,7 @@ import java.net.URI;
|
||||
/**
|
||||
* Event sent when the app is asked to open a {@code URI}.
|
||||
*
|
||||
* @see OpenURIHandler#openURI(AppEvent.OpenURIEvent)
|
||||
* @see OpenURIHandler#openURI(OpenURIEvent)
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
|
@ -33,7 +33,7 @@ import java.util.List;
|
||||
/**
|
||||
* Event sent when the app is asked to print a list of files.
|
||||
*
|
||||
* @see PrintFilesHandler#printFiles(AppEvent.PrintFilesEvent)
|
||||
* @see PrintFilesHandler#printFiles(PrintFilesEvent)
|
||||
* @since 9
|
||||
*/
|
||||
public final class PrintFilesEvent extends FilesEvent {
|
||||
|
@ -28,7 +28,7 @@ package java.awt.desktop;
|
||||
/**
|
||||
* Event sent when the application is asked to quit.
|
||||
*
|
||||
* @see QuitHandler#handleQuitRequestWith(AppEvent.QuitEvent, QuitResponse)
|
||||
* @see QuitHandler#handleQuitRequestWith(QuitEvent, QuitResponse)
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
|
@ -28,8 +28,8 @@ package java.awt.desktop;
|
||||
* Event sent when the displays attached to the system enter and exit power save
|
||||
* sleep.
|
||||
*
|
||||
* @see ScreenSleepListener#screenAboutToSleep(AppEvent.ScreenSleepEvent)
|
||||
* @see ScreenSleepListener#screenAwoke(AppEvent.ScreenSleepEvent)
|
||||
* @see ScreenSleepListener#screenAboutToSleep(ScreenSleepEvent)
|
||||
* @see ScreenSleepListener#screenAwoke(ScreenSleepEvent)
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
|
@ -28,8 +28,8 @@ package java.awt.desktop;
|
||||
/**
|
||||
* Event sent when the system enters and exits power save sleep.
|
||||
*
|
||||
* @see SystemSleepListener#systemAboutToSleep(AppEvent.SystemSleepEvent)
|
||||
* @see SystemSleepListener#systemAwoke(AppEvent.SystemSleepEvent)
|
||||
* @see SystemSleepListener#systemAboutToSleep(SystemSleepEvent)
|
||||
* @see SystemSleepListener#systemAwoke(SystemSleepEvent)
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
|
@ -29,8 +29,8 @@ package java.awt.desktop;
|
||||
*
|
||||
* Some systems may provide a reason of a user session change.
|
||||
*
|
||||
* @see UserSessionListener#userSessionActivated(AppEvent.UserSessionEvent)
|
||||
* @see UserSessionListener#userSessionDeactivated(AppEvent.UserSessionEvent)
|
||||
* @see UserSessionListener#userSessionActivated(UserSessionEvent)
|
||||
* @see UserSessionListener#userSessionDeactivated(UserSessionEvent)
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2017, 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
|
||||
@ -31,10 +31,10 @@ import java.awt.color.ICC_ColorSpace;
|
||||
import sun.java2d.cmm.CMSManager;
|
||||
import sun.java2d.cmm.ColorTransform;
|
||||
import sun.java2d.cmm.PCMM;
|
||||
import java.awt.Toolkit;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* The {@code ColorModel} abstract class encapsulates the
|
||||
@ -362,7 +362,14 @@ public abstract class ColorModel implements Transparency{
|
||||
this.transparency = transparency;
|
||||
}
|
||||
|
||||
nBits = bits.clone();
|
||||
/*
|
||||
* We need significant bits value only for the length
|
||||
* of number of components, so we truncate remaining part.
|
||||
* It also helps in hashCode calculation since bits[] can contain
|
||||
* different values after the length of number of components between
|
||||
* two ColorModels.
|
||||
*/
|
||||
nBits = Arrays.copyOf(bits, numComponents);
|
||||
this.pixel_bits = pixel_bits;
|
||||
if (pixel_bits <= 0) {
|
||||
throw new IllegalArgumentException("Number of pixel bits must "+
|
||||
@ -1441,69 +1448,53 @@ public abstract class ColorModel implements Transparency{
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the specified {@code Object} is an instance of
|
||||
* {@code ColorModel} and if it equals this
|
||||
* {@code ColorModel}.
|
||||
* @param obj the {@code Object} to test for equality
|
||||
* @return {@code true} if the specified {@code Object}
|
||||
* is an instance of {@code ColorModel} and equals this
|
||||
* {@code ColorModel}; {@code false} otherwise.
|
||||
* This method simply delegates to the default implementation in {@code Object}
|
||||
* which is identical to an {@code ==} test since this class cannot enforce the
|
||||
* issues of a proper equality test among multiple independent subclass
|
||||
* branches.
|
||||
* Subclasses are encouraged to override this method and provide equality
|
||||
* testing for their own properties in addition to equality tests for the
|
||||
* following common base properties of {@code ColorModel}:
|
||||
* <ul>
|
||||
* <li>Support for alpha component.</li>
|
||||
* <li>Is alpha premultiplied.</li>
|
||||
* <li>Number of bits per pixel.</li>
|
||||
* <li>Type of transparency like Opaque, Bitmask or Translucent.</li>
|
||||
* <li>Number of components in a pixel.</li>
|
||||
* <li>{@code ColorSpace} type.</li>
|
||||
* <li>Type of the array used to represent pixel values.</li>
|
||||
* <li>Number of significant bits per color and alpha component.</li>
|
||||
* </ul>
|
||||
* @param obj the reference object with which to compare.
|
||||
* @return {@code true} if this object is the same as the obj
|
||||
* argument; {@code false} otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof ColorModel)) {
|
||||
return false;
|
||||
}
|
||||
ColorModel cm = (ColorModel) obj;
|
||||
|
||||
if (this == cm) {
|
||||
return true;
|
||||
}
|
||||
if (supportsAlpha != cm.hasAlpha() ||
|
||||
isAlphaPremultiplied != cm.isAlphaPremultiplied() ||
|
||||
pixel_bits != cm.getPixelSize() ||
|
||||
transparency != cm.getTransparency() ||
|
||||
numComponents != cm.getNumComponents())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int[] nb = cm.getComponentSize();
|
||||
|
||||
if ((nBits != null) && (nb != null)) {
|
||||
for (int i = 0; i < numComponents; i++) {
|
||||
if (nBits[i] != nb[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return ((nBits == null) && (nb == null));
|
||||
}
|
||||
|
||||
return true;
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code for this ColorModel.
|
||||
*
|
||||
* @return a hash code for this ColorModel.
|
||||
* This method simply delegates to the default implementation in {@code Object}
|
||||
* which returns the system ID for the class.
|
||||
* Subclasses are encouraged to override this method and provide a hash
|
||||
* for their own properties in addition to hashing the values of the
|
||||
* following common base properties of {@code ColorModel}:
|
||||
* <ul>
|
||||
* <li>Support for alpha component.</li>
|
||||
* <li>Is alpha premultiplied.</li>
|
||||
* <li>Number of bits per pixel.</li>
|
||||
* <li>Type of transparency like Opaque, Bitmask or Translucent.</li>
|
||||
* <li>Number of components in a pixel.</li>
|
||||
* <li>{@code ColorSpace} type.</li>
|
||||
* <li>Type of the array used to represent pixel values.</li>
|
||||
* <li>Number of significant bits per color and alpha component.</li>
|
||||
* </ul>
|
||||
* @return a hash code value for this object.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
int result = 0;
|
||||
|
||||
result = (supportsAlpha ? 2 : 3) +
|
||||
(isAlphaPremultiplied ? 4 : 5) +
|
||||
pixel_bits * 6 +
|
||||
transparency * 7 +
|
||||
numComponents * 8;
|
||||
|
||||
if (nBits != null) {
|
||||
for (int i = 0; i < numComponents; i++) {
|
||||
result = result + nBits[i] * (i + 9);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1961,4 +1952,4 @@ public abstract class ColorModel implements Transparency{
|
||||
return lg16Toog16LUT;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2017, 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
|
||||
@ -27,6 +27,7 @@ package java.awt.image;
|
||||
|
||||
import java.awt.color.ColorSpace;
|
||||
import java.awt.color.ICC_ColorSpace;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* A {@code ColorModel} class that works with pixel values that
|
||||
@ -200,6 +201,7 @@ public class ComponentColorModel extends ColorModel {
|
||||
private float[] diffMinMax;
|
||||
private float[] compOffset;
|
||||
private float[] compScale;
|
||||
private volatile int hashCode;
|
||||
|
||||
/**
|
||||
* Constructs a {@code ComponentColorModel} from the specified
|
||||
@ -2927,22 +2929,59 @@ public class ComponentColorModel extends ColorModel {
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares this color model with another for equality.
|
||||
*
|
||||
* @param obj The object to compare with this color model.
|
||||
* @return {@code true} if the color model objects are equal,
|
||||
* {@code false} if they are not.
|
||||
* Tests if the specified {@code Object} is an instance
|
||||
* of {@code ComponentColorModel} and equals this
|
||||
* {@code ComponentColorModel}.
|
||||
* @param obj the {@code Object} to test for equality
|
||||
* @return {@code true} if the specified {@code Object}
|
||||
* is an instance of {@code ComponentColorModel} and equals this
|
||||
* {@code ComponentColorModel}; {@code false} otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!super.equals(obj)) {
|
||||
if (!(obj instanceof ComponentColorModel)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (obj.getClass() != getClass()) {
|
||||
ComponentColorModel cm = (ComponentColorModel) obj;
|
||||
if (supportsAlpha != cm.hasAlpha() ||
|
||||
isAlphaPremultiplied != cm.isAlphaPremultiplied() ||
|
||||
pixel_bits != cm.getPixelSize() ||
|
||||
transparency != cm.getTransparency() ||
|
||||
numComponents != cm.getNumComponents() ||
|
||||
(!(colorSpace.equals(cm.colorSpace))) ||
|
||||
transferType != cm.transferType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(Arrays.equals(nBits, cm.getComponentSize()))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Returns the hash code for this ComponentColorModel.
|
||||
*
|
||||
* @return a hash code for this ComponentColorModel.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = hashCode;
|
||||
if (result == 0) {
|
||||
result = 7;
|
||||
result = 89 * result + this.pixel_bits;
|
||||
result = 89 * result + Arrays.hashCode(this.nBits);
|
||||
result = 89 * result + this.transparency;
|
||||
result = 89 * result + (this.supportsAlpha ? 1 : 0);
|
||||
result = 89 * result + (this.isAlphaPremultiplied ? 1 : 0);
|
||||
result = 89 * result + this.numComponents;
|
||||
result = 89 * result + this.colorSpace.hashCode();
|
||||
result = 89 * result + this.transferType;
|
||||
hashCode = result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2017, 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
|
||||
@ -28,6 +28,7 @@ package java.awt.image;
|
||||
import java.awt.Transparency;
|
||||
import java.awt.color.ColorSpace;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* The {@code IndexColorModel} class is a {@code ColorModel}
|
||||
@ -129,6 +130,7 @@ public class IndexColorModel extends ColorModel {
|
||||
private int transparent_index = -1;
|
||||
private boolean allgrayopaque;
|
||||
private BigInteger validBits;
|
||||
private volatile int hashCode;
|
||||
|
||||
private sun.awt.image.BufImgSurfaceData.ICMColorData colorData = null;
|
||||
|
||||
@ -1532,4 +1534,100 @@ public class IndexColorModel extends ColorModel {
|
||||
+ " isAlphaPre = "+isAlphaPremultiplied
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the specified {@code Object} is an
|
||||
* instance of {@code IndexColorModel}
|
||||
* and if it equals this {@code IndexColorModel}
|
||||
* @param obj the {@code Object} to test for equality
|
||||
* @return {@code true} if the specified {@code Object}
|
||||
* equals this {@code IndexColorModel}; {@code false} otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (!(obj instanceof IndexColorModel)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IndexColorModel cm = (IndexColorModel) obj;
|
||||
if (supportsAlpha != cm.hasAlpha() ||
|
||||
isAlphaPremultiplied != cm.isAlphaPremultiplied() ||
|
||||
pixel_bits != cm.getPixelSize() ||
|
||||
transparency != cm.getTransparency() ||
|
||||
numComponents != cm.getNumComponents() ||
|
||||
(!(colorSpace.equals(cm.colorSpace))) ||
|
||||
transferType != cm.transferType ||
|
||||
map_size != cm.map_size ||
|
||||
transparent_index != cm.transparent_index)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(Arrays.equals(nBits, cm.getComponentSize()))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// verify whether we have to check equality of all bits in validBits
|
||||
boolean testValidBits;
|
||||
if (validBits == cm.validBits) {
|
||||
testValidBits = false;
|
||||
} else if (validBits == null || cm.validBits == null) {
|
||||
return false;
|
||||
} else if (validBits.equals(cm.validBits)) {
|
||||
testValidBits = false;
|
||||
} else {
|
||||
testValidBits = true;
|
||||
}
|
||||
|
||||
if (testValidBits) {
|
||||
for (int i = 0; i < map_size; i++) {
|
||||
if (rgb[i] != cm.rgb[i] ||
|
||||
validBits.testBit(i) != cm.validBits.testBit(i))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < map_size; i++) {
|
||||
if (rgb[i] != cm.rgb[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code for IndexColorModel.
|
||||
*
|
||||
* @return a hash code for IndexColorModel
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = hashCode;
|
||||
if (result == 0) {
|
||||
/*
|
||||
* We are intentionally not calculating hashCode for validBits,
|
||||
* because it is only used for 8-bit indexed screens and they
|
||||
* are very rare. It is very unlikely for 2 IndexColorModels
|
||||
* to have different valiBits and have same value for all
|
||||
* other properties.
|
||||
*/
|
||||
result = 7;
|
||||
result = 89 * result + this.pixel_bits;
|
||||
result = 89 * result + Arrays.hashCode(this.nBits);
|
||||
result = 89 * result + this.transparency;
|
||||
result = 89 * result + (this.supportsAlpha ? 1 : 0);
|
||||
result = 89 * result + (this.isAlphaPremultiplied ? 1 : 0);
|
||||
result = 89 * result + this.numComponents;
|
||||
result = 89 * result + this.colorSpace.hashCode();
|
||||
result = 89 * result + this.transferType;
|
||||
result = 89 * result + Arrays.hashCode(this.rgb);
|
||||
result = 89 * result + this.map_size;
|
||||
result = 89 * result + this.transparent_index;
|
||||
hashCode = result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2017, 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
|
||||
@ -27,6 +27,7 @@ package java.awt.image;
|
||||
|
||||
import java.awt.Transparency;
|
||||
import java.awt.color.ColorSpace;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* The {@code PackedColorModel} class is an abstract
|
||||
@ -88,6 +89,7 @@ public abstract class PackedColorModel extends ColorModel {
|
||||
int[] maskArray;
|
||||
int[] maskOffsets;
|
||||
float[] scaleFactors;
|
||||
private volatile int hashCode;
|
||||
|
||||
/**
|
||||
* Constructs a {@code PackedColorModel} from a color mask array,
|
||||
@ -393,25 +395,63 @@ public abstract class PackedColorModel extends ColorModel {
|
||||
* is an instance of {@code PackedColorModel} and equals this
|
||||
* {@code PackedColorModel}; {@code false} otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof PackedColorModel)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!super.equals(obj)) {
|
||||
PackedColorModel cm = (PackedColorModel) obj;
|
||||
|
||||
if (supportsAlpha != cm.hasAlpha() ||
|
||||
isAlphaPremultiplied != cm.isAlphaPremultiplied() ||
|
||||
pixel_bits != cm.getPixelSize() ||
|
||||
transparency != cm.getTransparency() ||
|
||||
numComponents != cm.getNumComponents() ||
|
||||
(!(colorSpace.equals(cm.colorSpace))) ||
|
||||
transferType != cm.transferType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
PackedColorModel cm = (PackedColorModel) obj;
|
||||
int numC = cm.getNumComponents();
|
||||
for(int i=0; i < numC; i++) {
|
||||
if (maskArray[i] != cm.getMask(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(Arrays.equals(nBits, cm.getComponentSize()))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code for this PackedColorModel.
|
||||
*
|
||||
* @return a hash code for this PackedColorModel.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = hashCode;
|
||||
if (result == 0) {
|
||||
result = 7;
|
||||
result = 89 * result + this.pixel_bits;
|
||||
result = 89 * result + Arrays.hashCode(this.nBits);
|
||||
result = 89 * result + this.transparency;
|
||||
result = 89 * result + (this.supportsAlpha ? 1 : 0);
|
||||
result = 89 * result + (this.isAlphaPremultiplied ? 1 : 0);
|
||||
result = 89 * result + this.numComponents;
|
||||
result = 89 * result + this.colorSpace.hashCode();
|
||||
result = 89 * result + this.transferType;
|
||||
result = 89 * result + Arrays.hashCode(this.maskArray);
|
||||
hashCode = result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static final int[] createBitsArray(int[]colorMaskArray,
|
||||
int alphaMask) {
|
||||
int numColors = colorMaskArray.length;
|
||||
@ -480,4 +520,4 @@ public abstract class PackedColorModel extends ColorModel {
|
||||
return count;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -93,20 +93,25 @@ public final class CompositeFont extends Font2D {
|
||||
* better that it is handled internally to the CompositeFont class.
|
||||
*/
|
||||
if (fm.getEUDCFont() != null) {
|
||||
int msCnt = numMetricsSlots;
|
||||
int fbCnt = numSlots - msCnt;
|
||||
numSlots++;
|
||||
if (componentNames != null) {
|
||||
componentNames = new String[numSlots];
|
||||
System.arraycopy(compNames, 0, componentNames, 0, numSlots-1);
|
||||
componentNames[numSlots-1] =
|
||||
fm.getEUDCFont().getFontName(null);
|
||||
System.arraycopy(compNames, 0, componentNames, 0, msCnt);
|
||||
componentNames[msCnt] = fm.getEUDCFont().getFontName(null);
|
||||
System.arraycopy(compNames, msCnt,
|
||||
componentNames, msCnt+1, fbCnt);
|
||||
}
|
||||
if (componentFileNames != null) {
|
||||
componentFileNames = new String[numSlots];
|
||||
System.arraycopy(compFileNames, 0,
|
||||
componentFileNames, 0, numSlots-1);
|
||||
componentFileNames, 0, msCnt);
|
||||
System.arraycopy(compFileNames, msCnt,
|
||||
componentFileNames, msCnt+1, fbCnt);
|
||||
}
|
||||
components = new PhysicalFont[numSlots];
|
||||
components[numSlots-1] = fm.getEUDCFont();
|
||||
components[msCnt] = fm.getEUDCFont();
|
||||
deferredInitialisation = new boolean[numSlots];
|
||||
if (defer) {
|
||||
for (int i=0; i<numSlots-1; i++) {
|
||||
|
@ -71,7 +71,9 @@ public final class CompositeStrike extends FontStrike {
|
||||
}
|
||||
|
||||
PhysicalStrike getStrikeForSlot(int slot) {
|
||||
|
||||
if (slot >= strikes.length) {
|
||||
slot = 0;
|
||||
}
|
||||
PhysicalStrike strike = strikes[slot];
|
||||
if (strike == null) {
|
||||
strike =
|
||||
|
@ -626,7 +626,11 @@ class ExtendedTextSourceLabel extends ExtendedTextLabel implements Decoration.La
|
||||
glyphinfo = gv.getGlyphInfo();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println(source);
|
||||
if (DEBUG) {
|
||||
System.err.println(source);
|
||||
e.printStackTrace();
|
||||
}
|
||||
glyphinfo = new float[gv.getNumGlyphs() * numvals];
|
||||
}
|
||||
|
||||
int numGlyphs = gv.getNumGlyphs();
|
||||
@ -775,7 +779,7 @@ class ExtendedTextSourceLabel extends ExtendedTextLabel implements Decoration.La
|
||||
if (gx == gxlimit) {
|
||||
tgt = charInfo.length / numvals;
|
||||
} else {
|
||||
tgt = indices[gx]-1;
|
||||
tgt = indices[gx];
|
||||
}
|
||||
if (DEBUG) {
|
||||
System.err.println("gx=" + gx + " gxlimit=" + gxlimit +
|
||||
|
@ -27,6 +27,7 @@ package sun.font;
|
||||
|
||||
import java.io.File;
|
||||
import java.awt.Font;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -132,6 +133,16 @@ public class FontFamily {
|
||||
|
||||
FileFont newFont = (FileFont)font;
|
||||
File newDir = (new File(newFont.platName)).getParentFile();
|
||||
if (existDir != null) {
|
||||
try {
|
||||
existDir = existDir.getCanonicalFile();
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
if (newDir != null) {
|
||||
try {
|
||||
newDir = newDir.getCanonicalFile();
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
return java.util.Objects.equals(newDir, existDir);
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,9 @@ hb_jdk_get_glyph (hb_font_t *font HB_UNUSED,
|
||||
|
||||
*glyph = (hb_codepoint_t)
|
||||
env->CallIntMethod(font2D, sunFontIDs.f2dCharToGlyphMID, u);
|
||||
if ((int)*glyph < 0) {
|
||||
*glyph = 0;
|
||||
}
|
||||
return (*glyph != 0);
|
||||
}
|
||||
|
||||
|
@ -523,9 +523,9 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
dynamicColorModel = null;
|
||||
defaultConfig = null;
|
||||
configs = null;
|
||||
initScaleFactors();
|
||||
// pass on to all top-level windows on this display
|
||||
topLevels.notifyListeners();
|
||||
initScaleFactors();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,6 +80,8 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||
* WindowStateEvent is posted to the EventQueue.
|
||||
*/
|
||||
private WindowListener windowListener;
|
||||
private float scaleX;
|
||||
private float scaleY;
|
||||
|
||||
/**
|
||||
* Initialize JNI field IDs
|
||||
@ -190,7 +192,10 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||
|
||||
// Express our interest in display changes
|
||||
GraphicsConfiguration gc = getGraphicsConfiguration();
|
||||
((Win32GraphicsDevice)gc.getDevice()).addDisplayChangedListener(this);
|
||||
Win32GraphicsDevice gd = (Win32GraphicsDevice) gc.getDevice();
|
||||
gd.addDisplayChangedListener(this);
|
||||
scaleX = gd.getDefaultScaleX();
|
||||
scaleY = gd.getDefaultScaleY();
|
||||
|
||||
initActiveWindowsTracking((Window)target);
|
||||
|
||||
@ -539,6 +544,22 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||
|
||||
AWTAccessor.getComponentAccessor().
|
||||
setGraphicsConfiguration((Component)target, winGraphicsConfig);
|
||||
|
||||
checkDPIChange(oldDev, newDev);
|
||||
}
|
||||
|
||||
private void checkDPIChange(Win32GraphicsDevice oldDev,
|
||||
Win32GraphicsDevice newDev) {
|
||||
float newScaleX = newDev.getDefaultScaleX();
|
||||
float newScaleY = newDev.getDefaultScaleY();
|
||||
|
||||
if (scaleX != newScaleX || scaleY != newScaleY) {
|
||||
if (oldDev.getScreen() == newDev.getScreen()) {
|
||||
windowDPIChange(scaleX, scaleY, newScaleX, newScaleY);
|
||||
}
|
||||
scaleX = newScaleX;
|
||||
scaleY = newScaleY;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -781,6 +802,9 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||
}
|
||||
}
|
||||
|
||||
native void windowDPIChange(float prevScaleX, float prevScaleY,
|
||||
float newScaleX, float newScaleY);
|
||||
|
||||
/*
|
||||
* The method maps the list of the active windows to the window's AppContext,
|
||||
* then the method registers ActiveWindowListener, GuiDisposedListener listeners;
|
||||
|
@ -950,8 +950,11 @@ AwtComponent::SetWindowPos(HWND wnd, HWND after,
|
||||
return 1;
|
||||
}
|
||||
|
||||
void AwtComponent::Reshape(int x, int y, int w, int h) {
|
||||
ReshapeNoScale(ScaleUpX(x), ScaleUpY(y), ScaleUpX(w), ScaleUpY(h));
|
||||
}
|
||||
|
||||
void AwtComponent::Reshape(int x, int y, int w, int h)
|
||||
void AwtComponent::ReshapeNoScale(int x, int y, int w, int h)
|
||||
{
|
||||
#if defined(DEBUG)
|
||||
RECT rc;
|
||||
@ -960,11 +963,6 @@ void AwtComponent::Reshape(int x, int y, int w, int h)
|
||||
DTRACE_PRINTLN4("AwtComponent::Reshape from %d, %d, %d, %d", rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top);
|
||||
#endif
|
||||
|
||||
x = ScaleUpX(x);
|
||||
y = ScaleUpY(y);
|
||||
w = ScaleUpX(w);
|
||||
h = ScaleUpY(h);
|
||||
|
||||
AwtWindow* container = GetContainer();
|
||||
AwtComponent* parent = GetParent();
|
||||
if (container != NULL && container == parent) {
|
||||
|
@ -275,6 +275,7 @@ public:
|
||||
virtual void Show();
|
||||
virtual void Hide();
|
||||
virtual void Reshape(int x, int y, int w, int h);
|
||||
void ReshapeNoScale(int x, int y, int w, int h);
|
||||
|
||||
/*
|
||||
* Fix for 4046446.
|
||||
|
@ -153,6 +153,14 @@ struct SetFullScreenExclusiveModeStateStruct {
|
||||
jboolean isFSEMState;
|
||||
};
|
||||
|
||||
// struct for _WindowDPIChange() method
|
||||
struct ScaleStruct {
|
||||
jobject window;
|
||||
jfloat prevScaleX;
|
||||
jfloat prevScaleY;
|
||||
jfloat scaleX;
|
||||
jfloat scaleY;
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* AwtWindow fields
|
||||
@ -1753,6 +1761,9 @@ MsgRouting AwtWindow::WmMove(int x, int y)
|
||||
(env)->SetIntField(peer, AwtWindow::sysYID, ScaleDownY(rect.top));
|
||||
SendComponentEvent(java_awt_event_ComponentEvent_COMPONENT_MOVED);
|
||||
|
||||
prevX = rect.left;
|
||||
prevY = rect.top;
|
||||
|
||||
env->DeleteLocalRef(target);
|
||||
return AwtComponent::WmMove(x, y);
|
||||
}
|
||||
@ -2053,6 +2064,8 @@ void AwtWindow::CheckIfOnNewScreen() {
|
||||
int curScrn = GetScreenImOn();
|
||||
|
||||
if (curScrn != m_screenNum) { // we've been moved
|
||||
int prevScrn = m_screenNum;
|
||||
|
||||
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
|
||||
|
||||
jclass peerCls = env->GetObjectClass(m_peerObject);
|
||||
@ -2068,12 +2081,81 @@ void AwtWindow::CheckIfOnNewScreen() {
|
||||
}
|
||||
|
||||
env->CallVoidMethod(m_peerObject, draggedID);
|
||||
|
||||
m_screenNum = curScrn;
|
||||
WindowDPIChange(prevScrn, curScrn);
|
||||
|
||||
env->DeleteLocalRef(peerCls);
|
||||
}
|
||||
}
|
||||
|
||||
int Disposition(int x1, int x2, int x) {
|
||||
return x < x1 ? -1 : (x > x2 ? 1 : 0);
|
||||
}
|
||||
|
||||
void AwtWindow::WindowDPIChange(int prevScreen, int screen) {
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice* prevDevice = devices->GetDevice(prevScreen);
|
||||
AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
|
||||
|
||||
if (prevDevice && device) {
|
||||
RECT prevBounds;
|
||||
RECT bounds;
|
||||
|
||||
if (MonitorBounds(prevDevice->GetMonitor(), &prevBounds)
|
||||
&& MonitorBounds(device->GetMonitor(), &bounds)) {
|
||||
int x;
|
||||
int y;
|
||||
int dx;
|
||||
int dy;
|
||||
RECT rect;
|
||||
|
||||
::GetWindowRect(GetHWnd(), &rect);
|
||||
x = rect.left;
|
||||
y = rect.top;
|
||||
dx = x - prevX;
|
||||
dy = y - prevY;
|
||||
|
||||
if (dx != 0 || dy != 0) {
|
||||
int w = rect.right - rect.left;
|
||||
int h = rect.bottom - rect.top;
|
||||
int dispX = Disposition(prevBounds.left, prevBounds.right,
|
||||
(bounds.left + bounds.right) / 2);
|
||||
int dispY = Disposition(prevBounds.top, prevBounds.bottom,
|
||||
(bounds.top + bounds.bottom) / 2);
|
||||
|
||||
w = w * device->GetScaleX() / prevDevice->GetScaleX();
|
||||
h = h * device->GetScaleY() / prevDevice->GetScaleY();
|
||||
|
||||
prevX = x;
|
||||
prevY = y;
|
||||
|
||||
if (dx != 0 && dispX != 0) {
|
||||
x = dispX > 0 ? bounds.left : bounds.right - w;
|
||||
y = min(y, bounds.top);
|
||||
ReshapeNoScale(x, y, w, h);
|
||||
} else if (dy != 0 && dispY != 0) {
|
||||
x = max(x, bounds.left);
|
||||
y = dispY > 0 ? bounds.top : bounds.bottom - h;
|
||||
ReshapeNoScale(x, y, w, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AwtWindow::WindowDPIChange(float prevScaleX, float prevScaleY, float scaleX, float scaleY) {
|
||||
int w;
|
||||
int h;
|
||||
RECT rect;
|
||||
|
||||
::GetWindowRect(GetHWnd(), &rect);
|
||||
|
||||
w = (rect.right - rect.left) * scaleX / prevScaleX;
|
||||
h = (rect.bottom - rect.top) * scaleY / prevScaleY;
|
||||
ReshapeNoScale(rect.left, rect.top, w, h);
|
||||
}
|
||||
|
||||
BOOL AwtWindow::IsFocusableWindow() {
|
||||
/*
|
||||
* For Window/Frame/Dialog to accept focus it should:
|
||||
@ -3102,6 +3184,29 @@ void AwtWindow::_GetNativeWindowSize(void* param) {
|
||||
|
||||
env->DeleteGlobalRef(self);
|
||||
}
|
||||
|
||||
void AwtWindow::_WindowDPIChange(void* param)
|
||||
{
|
||||
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
|
||||
|
||||
ScaleStruct *ss = (ScaleStruct *)param;
|
||||
jobject self = ss->window;
|
||||
jfloat prevScaleX = ss->prevScaleX;
|
||||
jfloat prevScaleY = ss->prevScaleY;
|
||||
jfloat scaleX = ss->scaleX;
|
||||
jfloat scaleY = ss->scaleY;
|
||||
|
||||
PDATA pData;
|
||||
JNI_CHECK_PEER_GOTO(self, ret);
|
||||
AwtWindow *window = (AwtWindow *)pData;
|
||||
|
||||
window->WindowDPIChange(prevScaleX, prevScaleY, scaleX, scaleY);
|
||||
|
||||
ret:
|
||||
env->DeleteGlobalRef(self);
|
||||
delete ss;
|
||||
}
|
||||
|
||||
extern "C" int getSystemMetricValue(int msgType);
|
||||
extern "C" {
|
||||
|
||||
@ -3800,4 +3905,27 @@ Java_sun_awt_windows_WWindowPeer_repositionSecurityWarning(JNIEnv *env,
|
||||
CATCH_BAD_ALLOC;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_awt_windows_WWindowPeer
|
||||
* Method: windowDPIChange
|
||||
* Signature: (FFFF)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_awt_windows_WWindowPeer_windowDPIChange(JNIEnv *env, jobject self,
|
||||
jfloat prevScaleX, jfloat prevScaleY, jfloat scaleX, jfloat scaleY)
|
||||
{
|
||||
TRY;
|
||||
|
||||
ScaleStruct *ss = new ScaleStruct;
|
||||
ss->window = env->NewGlobalRef(self);
|
||||
ss->prevScaleX = prevScaleX;
|
||||
ss->prevScaleY = prevScaleY;
|
||||
ss->scaleX = scaleX;
|
||||
ss->scaleY = scaleY;
|
||||
|
||||
AwtToolkit::GetInstance().InvokeFunction(AwtWindow::_WindowDPIChange, ss);
|
||||
// global refs and ss are deleted in _WindowDPIChange
|
||||
|
||||
CATCH_BAD_ALLOC;
|
||||
}
|
||||
} /* extern "C" */
|
||||
|
@ -242,6 +242,7 @@ public:
|
||||
static void _RepositionSecurityWarning(void* param);
|
||||
static void _SetFullScreenExclusiveModeState(void* param);
|
||||
static void _GetNativeWindowSize(void* param);
|
||||
static void _WindowDPIChange(void* param);
|
||||
|
||||
inline static BOOL IsResizing() {
|
||||
return sm_resizing;
|
||||
@ -383,8 +384,12 @@ protected:
|
||||
|
||||
private:
|
||||
int m_screenNum;
|
||||
int prevX;
|
||||
int prevY;
|
||||
|
||||
void InitOwner(AwtWindow *owner);
|
||||
void WindowDPIChange(int prevScreen, int newScreen);
|
||||
void WindowDPIChange(float prevScaleX, float prevScaleY, float scaleX, float scaleY);
|
||||
|
||||
Type m_windowType;
|
||||
void InitType(JNIEnv *env, jobject peer);
|
||||
|
@ -26,9 +26,9 @@
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 7089914
|
||||
* @bug 7089914 8174720
|
||||
* @requires (os.family == "windows")
|
||||
* @modules java.desktop/com.sun.java.swing.plaf.windows
|
||||
* @modules java.desktop/com.sun.java.swing.plaf.windows:open
|
||||
* @summary Focus on image icons are not visible in javaws cache with high contrast mode
|
||||
* @author Sean Chou
|
||||
*/
|
||||
|
@ -0,0 +1,278 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.Image;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Panel;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.AbstractMultiResolutionImage;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/* @test
|
||||
* @bug 8147440 8147016
|
||||
* @summary HiDPI (Windows): Swing components have incorrect sizes after
|
||||
* changing display resolution
|
||||
* @run main/manual/othervm WindowResizingOnDPIChangingTest
|
||||
*/
|
||||
public class WindowResizingOnDPIChangingTest {
|
||||
|
||||
private static volatile boolean testResult = false;
|
||||
private static volatile CountDownLatch countDownLatch;
|
||||
private static TestFrame undecoratedFrame;
|
||||
private static TestFrame decoratedFrame;
|
||||
private static JFrame mainFrame;
|
||||
|
||||
private static final String INSTRUCTIONS = "INSTRUCTIONS:\n"
|
||||
+ "Verify that window is properly resized after the display DPI updating.\n"
|
||||
+ "\n"
|
||||
+ "The test is applicable for OSes that allows to change the display DPI\n"
|
||||
+ "without the system rebooting (like Windows 8.1 and higher). Press PASS for other\n"
|
||||
+ "systems. \n"
|
||||
+ "\n"
|
||||
+ "1. Set the display DPI size to 192 (DPI scale factor 200%)\n"
|
||||
+ "2. Press Show Frames button\n"
|
||||
+ "Two frames decorated and undecorated appear.\n"
|
||||
+ "3. Check that the string \"scale 2x\" is painted on the windows.\n"
|
||||
+ "4. Set the display DPI size to 96 (DPI scale factor 100%)\n"
|
||||
+ "5. Check that the string \"scale: 1x\" is painted on the windows.\n"
|
||||
+ "6. Check that the windows are properly resized in the same way as native applications\n"
|
||||
+ "7. Check that the windows are properly repainted and do not contain drawing artifacts\n"
|
||||
+ "If so, press PASS, else press FAIL.\n";
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
|
||||
countDownLatch = new CountDownLatch(1);
|
||||
SwingUtilities.invokeLater(WindowResizingOnDPIChangingTest::createUI);
|
||||
countDownLatch.await(15, TimeUnit.MINUTES);
|
||||
if (!testResult) {
|
||||
throw new RuntimeException("Test fails!");
|
||||
}
|
||||
}
|
||||
|
||||
private static void createUI() {
|
||||
|
||||
mainFrame = new JFrame("DPI change test");
|
||||
GridBagLayout layout = new GridBagLayout();
|
||||
JPanel mainControlPanel = new JPanel(layout);
|
||||
JPanel resultButtonPanel = new JPanel(layout);
|
||||
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
|
||||
JPanel testPanel = new JPanel(new FlowLayout());
|
||||
JButton frameButton = new JButton("Show Frames");
|
||||
frameButton.addActionListener((e) -> {
|
||||
int x = 20;
|
||||
int y = 10;
|
||||
int w = 400;
|
||||
int h = 300;
|
||||
|
||||
undecoratedFrame = new TestFrame(w, h, true);
|
||||
undecoratedFrame.setLocation(x, y);
|
||||
undecoratedFrame.setVisible(true);
|
||||
|
||||
decoratedFrame = new TestFrame(w, h, false);
|
||||
decoratedFrame.setLocation(x + w + 10, y);
|
||||
decoratedFrame.setVisible(true);
|
||||
|
||||
});
|
||||
testPanel.add(frameButton);
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
mainControlPanel.add(testPanel, gbc);
|
||||
|
||||
JTextArea instructionTextArea = new JTextArea();
|
||||
instructionTextArea.setText(INSTRUCTIONS);
|
||||
instructionTextArea.setEditable(false);
|
||||
instructionTextArea.setBackground(Color.white);
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 1;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
mainControlPanel.add(instructionTextArea, gbc);
|
||||
|
||||
JButton passButton = new JButton("Pass");
|
||||
passButton.setActionCommand("Pass");
|
||||
passButton.addActionListener((ActionEvent e) -> {
|
||||
testResult = true;
|
||||
disposeFrames();
|
||||
countDownLatch.countDown();
|
||||
|
||||
});
|
||||
|
||||
JButton failButton = new JButton("Fail");
|
||||
failButton.setActionCommand("Fail");
|
||||
failButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
disposeFrames();
|
||||
countDownLatch.countDown();
|
||||
}
|
||||
});
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
resultButtonPanel.add(passButton, gbc);
|
||||
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 0;
|
||||
resultButtonPanel.add(failButton, gbc);
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 2;
|
||||
mainControlPanel.add(resultButtonPanel, gbc);
|
||||
|
||||
mainFrame.add(mainControlPanel);
|
||||
mainFrame.pack();
|
||||
|
||||
mainFrame.addWindowListener(new WindowAdapter() {
|
||||
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
disposeFrames();
|
||||
countDownLatch.countDown();
|
||||
}
|
||||
});
|
||||
mainFrame.setVisible(true);
|
||||
}
|
||||
|
||||
private static void disposeFrames() {
|
||||
if (decoratedFrame != null && decoratedFrame.isVisible()) {
|
||||
decoratedFrame.dispose();
|
||||
}
|
||||
if (undecoratedFrame != null && undecoratedFrame.isVisible()) {
|
||||
undecoratedFrame.dispose();
|
||||
}
|
||||
if (mainFrame != null && mainFrame.isVisible()) {
|
||||
mainFrame.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
static class TestFrame extends Frame {
|
||||
|
||||
private final TestMultiResolutionImage mrImage;
|
||||
|
||||
public TestFrame(int width, int height, boolean undecorated) throws HeadlessException {
|
||||
super("Test Frame. Undecorated: " + undecorated);
|
||||
setSize(width, height);
|
||||
mrImage = new TestMultiResolutionImage(width, height);
|
||||
|
||||
setUndecorated(undecorated);
|
||||
Panel panel = new Panel(new FlowLayout()) {
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
AffineTransform tx = ((Graphics2D) g).getTransform();
|
||||
mrImage.scaleX = tx.getScaleX();
|
||||
mrImage.scaleY = tx.getScaleY();
|
||||
Insets insets = getInsets();
|
||||
g.drawImage(mrImage, insets.left, insets.bottom, null);
|
||||
}
|
||||
};
|
||||
add(panel);
|
||||
}
|
||||
}
|
||||
|
||||
static class TestMultiResolutionImage extends AbstractMultiResolutionImage {
|
||||
|
||||
final int width;
|
||||
final int height;
|
||||
double scaleX;
|
||||
double scaleY;
|
||||
|
||||
public TestMultiResolutionImage(int width, int height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth(ImageObserver observer) {
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight(ImageObserver observer) {
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Image getBaseImage() {
|
||||
return getResolutionVariant(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getResolutionVariant(double destImageWidth, double destImageHeight) {
|
||||
|
||||
int w = (int) destImageWidth;
|
||||
int h = (int) destImageHeight;
|
||||
|
||||
BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics2D g = img.createGraphics();
|
||||
g.scale(scaleX, scaleY);
|
||||
int red = (int) (255 / scaleX);
|
||||
int green = (int) (250 / scaleX);
|
||||
int blue = (int) (20 / scaleX);
|
||||
g.setColor(new Color(red, green, blue));
|
||||
g.fillRect(0, 0, width, height);
|
||||
|
||||
g.setColor(Color.decode("#87CEFA"));
|
||||
Font f = g.getFont();
|
||||
g.setFont(new Font(f.getName(), Font.BOLD, 24));
|
||||
g.drawString(String.format("scales: [%1.2fx, %1.2fx]", scaleX, scaleY),
|
||||
width / 6, height / 2);
|
||||
|
||||
g.dispose();
|
||||
return img;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Image> getResolutionVariants() {
|
||||
return Collections.unmodifiableList(Arrays.asList(getBaseImage()));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,274 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.Image;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Panel;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.AbstractMultiResolutionImage;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/* @test
|
||||
* @bug 8147440 8147016
|
||||
* @summary HiDPI (Windows): Swing components have incorrect sizes after
|
||||
* changing display resolution
|
||||
* @run main/manual/othervm WindowResizingOnMovingToAnotherDisplay
|
||||
*/
|
||||
public class WindowResizingOnMovingToAnotherDisplay {
|
||||
|
||||
private static volatile boolean testResult = false;
|
||||
private static volatile CountDownLatch countDownLatch;
|
||||
private static TestFrame frame;
|
||||
private static JFrame mainFrame;
|
||||
|
||||
private static final String INSTRUCTIONS = "INSTRUCTIONS:\n"
|
||||
+ "Verify that a window is properly resized after moving to a display"
|
||||
+ " with different DPI.\n"
|
||||
+ "\n"
|
||||
+ "The test is applicable for a multi-monitor system where displays"
|
||||
+ " are configured to have different DPI\n"
|
||||
+ "\n"
|
||||
+ "1. Press Show Frame button\n"
|
||||
+ "The frame appear.\n"
|
||||
+ "2. Check that the string \"scales [ScaleX, ScaleY]\" is painted on the window"
|
||||
+ " where ScaleX and ScaleY are the scales for current display.\n"
|
||||
+ "The scales are calculated as DPI / 96 and are 1 for the DPI value 96"
|
||||
+ " and 2 for the DPI value 192.\n"
|
||||
+ "3. Move the frame to the second display.\n"
|
||||
+ "4. Check that the string \"scales [ScaleX, ScaleY]\" is updated"
|
||||
+ " to show the right display scales.\n"
|
||||
+ "5. Check that the window is properly resized.\n"
|
||||
+ "6. Check that the window is properly repainted and does not contain drawing artifacts\n"
|
||||
+ "Try different display positions (left, right, top, bottom).\n"
|
||||
+ "If all tests are passed, press PASS, else press FAIL.\n";
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
|
||||
countDownLatch = new CountDownLatch(1);
|
||||
SwingUtilities.invokeLater(WindowResizingOnMovingToAnotherDisplay::createUI);
|
||||
countDownLatch.await(15, TimeUnit.MINUTES);
|
||||
if (!testResult) {
|
||||
throw new RuntimeException("Test fails!");
|
||||
}
|
||||
}
|
||||
|
||||
private static void createUI() {
|
||||
|
||||
mainFrame = new JFrame("DPI change test");
|
||||
GridBagLayout layout = new GridBagLayout();
|
||||
JPanel mainControlPanel = new JPanel(layout);
|
||||
JPanel resultButtonPanel = new JPanel(layout);
|
||||
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
|
||||
JPanel testPanel = new JPanel(new FlowLayout());
|
||||
JButton frameButton = new JButton("Show Frame");
|
||||
frameButton.addActionListener((e) -> {
|
||||
int x = 20;
|
||||
int y = 10;
|
||||
int w = 400;
|
||||
int h = 300;
|
||||
|
||||
frame = new TestFrame(w, h);
|
||||
frame.setLocation(x, y);
|
||||
frame.setVisible(true);
|
||||
|
||||
});
|
||||
testPanel.add(frameButton);
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
mainControlPanel.add(testPanel, gbc);
|
||||
|
||||
JTextArea instructionTextArea = new JTextArea();
|
||||
instructionTextArea.setText(INSTRUCTIONS);
|
||||
instructionTextArea.setEditable(false);
|
||||
instructionTextArea.setBackground(Color.white);
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 1;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
mainControlPanel.add(instructionTextArea, gbc);
|
||||
|
||||
JButton passButton = new JButton("Pass");
|
||||
passButton.setActionCommand("Pass");
|
||||
passButton.addActionListener((ActionEvent e) -> {
|
||||
testResult = true;
|
||||
disposeFrames();
|
||||
countDownLatch.countDown();
|
||||
|
||||
});
|
||||
|
||||
JButton failButton = new JButton("Fail");
|
||||
failButton.setActionCommand("Fail");
|
||||
failButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
disposeFrames();
|
||||
countDownLatch.countDown();
|
||||
}
|
||||
});
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
resultButtonPanel.add(passButton, gbc);
|
||||
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 0;
|
||||
resultButtonPanel.add(failButton, gbc);
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 2;
|
||||
mainControlPanel.add(resultButtonPanel, gbc);
|
||||
|
||||
mainFrame.add(mainControlPanel);
|
||||
mainFrame.pack();
|
||||
|
||||
mainFrame.addWindowListener(new WindowAdapter() {
|
||||
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
disposeFrames();
|
||||
countDownLatch.countDown();
|
||||
}
|
||||
});
|
||||
mainFrame.setVisible(true);
|
||||
}
|
||||
|
||||
private static void disposeFrames() {
|
||||
if (frame != null && frame.isVisible()) {
|
||||
frame.dispose();
|
||||
}
|
||||
|
||||
if (mainFrame != null && mainFrame.isVisible()) {
|
||||
mainFrame.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
static class TestFrame extends Frame {
|
||||
|
||||
private final TestMultiResolutionImage mrImage;
|
||||
|
||||
public TestFrame(int width, int height) throws HeadlessException {
|
||||
super("Test Frame");
|
||||
setSize(width, height);
|
||||
mrImage = new TestMultiResolutionImage(width, height);
|
||||
|
||||
Panel panel = new Panel(new FlowLayout()) {
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
AffineTransform tx = ((Graphics2D) g).getTransform();
|
||||
mrImage.scaleX = tx.getScaleX();
|
||||
mrImage.scaleY = tx.getScaleY();
|
||||
Insets insets = getInsets();
|
||||
g.drawImage(mrImage, insets.left, insets.bottom, null);
|
||||
}
|
||||
};
|
||||
add(panel);
|
||||
}
|
||||
}
|
||||
|
||||
static class TestMultiResolutionImage extends AbstractMultiResolutionImage {
|
||||
|
||||
final int width;
|
||||
final int height;
|
||||
double scaleX;
|
||||
double scaleY;
|
||||
|
||||
public TestMultiResolutionImage(int width, int height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth(ImageObserver observer) {
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight(ImageObserver observer) {
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Image getBaseImage() {
|
||||
return getResolutionVariant(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getResolutionVariant(double destImageWidth, double destImageHeight) {
|
||||
|
||||
int w = (int) destImageWidth;
|
||||
int h = (int) destImageHeight;
|
||||
|
||||
BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics2D g = img.createGraphics();
|
||||
g.scale(scaleX, scaleY);
|
||||
int red = (int) (255 / scaleX);
|
||||
int green = (int) (250 / scaleX);
|
||||
int blue = (int) (20 / scaleX);
|
||||
g.setColor(new Color(red, green, blue));
|
||||
g.fillRect(0, 0, width, height);
|
||||
|
||||
g.setColor(Color.decode("#87CEFA"));
|
||||
Font f = g.getFont();
|
||||
g.setFont(new Font(f.getName(), Font.BOLD, 24));
|
||||
g.drawString(String.format("scales: [%1.2fx, %1.2fx]", scaleX, scaleY),
|
||||
width / 6, height / 2);
|
||||
|
||||
g.dispose();
|
||||
return img;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Image> getResolutionVariants() {
|
||||
return Collections.unmodifiableList(Arrays.asList(getBaseImage()));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2008, 2017, 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
|
||||
@ -24,7 +24,7 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# @test IOExceptionIfEncodedURLTest.sh
|
||||
# @bug 6193279 6619458
|
||||
# @bug 6193279 6619458 8137087
|
||||
# @summary REGRESSION: AppletViewer throws IOException when path is encoded URL
|
||||
# @author Dmitry Cherepanov: area=appletviewer
|
||||
# @modules java.base/sun.net.www
|
||||
@ -56,7 +56,7 @@ pass()
|
||||
#Call this to run the test with a file name
|
||||
test()
|
||||
{
|
||||
${TESTJAVA}${FILESEP}bin${FILESEP}appletviewer -Xnosecurity ${URL} > err 2>&1 &
|
||||
"${TESTJAVA}"${FILESEP}bin${FILESEP}appletviewer -Xnosecurity ${URL} > err 2>&1 &
|
||||
APPLET_ID=$!
|
||||
sleep 15
|
||||
kill -9 $APPLET_ID
|
||||
@ -134,7 +134,9 @@ case "$OS" in
|
||||
DEFAULT_JDK="/cygdrive/c/Program\ Files/Java/jdk1.8.0"
|
||||
FILESEP="/"
|
||||
PATHSEP=";"
|
||||
TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
|
||||
TMP=`cd "${SYSTEMROOT}/Temp"; echo ${PWD}`
|
||||
x="cygpath -m $PWD"
|
||||
PWD=$(eval $x)
|
||||
;;
|
||||
|
||||
AIX )
|
||||
|
162
jdk/test/java/awt/font/Fallback/MissingGlyphTest.java
Normal file
162
jdk/test/java/awt/font/Fallback/MissingGlyphTest.java
Normal file
@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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 8147002
|
||||
* @summary Verifies if Arabic character alef is rendered in osx
|
||||
* @run main/manual MissingGlyphTest
|
||||
*/
|
||||
import java.awt.Font;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
public class MissingGlyphTest {
|
||||
private static Thread mainThread;
|
||||
private static boolean testPassed;
|
||||
private static boolean testGeneratedInterrupt;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (!System.getProperty("os.name").startsWith("Mac")) {
|
||||
return;
|
||||
}
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
doTest(MissingGlyphTest::glyphTest);
|
||||
});
|
||||
mainThread = Thread.currentThread();
|
||||
try {
|
||||
Thread.sleep(180000);
|
||||
} catch (InterruptedException e) {
|
||||
if (!testPassed && testGeneratedInterrupt) {
|
||||
throw new RuntimeException("Alef character is not rendered");
|
||||
}
|
||||
}
|
||||
if (!testGeneratedInterrupt) {
|
||||
throw new RuntimeException("user has not executed the test");
|
||||
}
|
||||
}
|
||||
|
||||
private static void glyphTest() {
|
||||
frame = new JFrame("Test");
|
||||
frame.add(new MyComponent());
|
||||
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
public static synchronized void pass() {
|
||||
testPassed = true;
|
||||
testGeneratedInterrupt = true;
|
||||
mainThread.interrupt();
|
||||
}
|
||||
|
||||
public static synchronized void fail() {
|
||||
testPassed = false;
|
||||
testGeneratedInterrupt = true;
|
||||
mainThread.interrupt();
|
||||
}
|
||||
|
||||
private static void doTest(Runnable action) {
|
||||
String description
|
||||
= " The test is supposed to display arabic alef character.\n"
|
||||
+ " If it resembles like the one shown in\n "
|
||||
+ " www.fileformat.info/info/unicode/char/0627/index.htm\n "
|
||||
+ " in Italic style ,press PASS.\n"
|
||||
+ " If the glyph is not shown or empty rectangle is shown, press FAIL";
|
||||
|
||||
final JDialog dialog = new JDialog();
|
||||
dialog.setTitle("printBannerTest");
|
||||
JTextArea textArea = new JTextArea(description);
|
||||
textArea.setEditable(false);
|
||||
final JButton testButton = new JButton("Start Test");
|
||||
final JButton passButton = new JButton("PASS");
|
||||
passButton.setEnabled(false);
|
||||
passButton.addActionListener((e) -> {
|
||||
dialog.dispose();
|
||||
frame.dispose();
|
||||
pass();
|
||||
});
|
||||
final JButton failButton = new JButton("FAIL");
|
||||
failButton.setEnabled(false);
|
||||
failButton.addActionListener((e) -> {
|
||||
dialog.dispose();
|
||||
frame.dispose();
|
||||
fail();
|
||||
});
|
||||
testButton.addActionListener((e) -> {
|
||||
testButton.setEnabled(false);
|
||||
action.run();
|
||||
passButton.setEnabled(true);
|
||||
failButton.setEnabled(true);
|
||||
});
|
||||
JPanel mainPanel = new JPanel(new BorderLayout());
|
||||
mainPanel.add(textArea, BorderLayout.CENTER);
|
||||
JPanel buttonPanel = new JPanel(new FlowLayout());
|
||||
buttonPanel.add(testButton);
|
||||
buttonPanel.add(passButton);
|
||||
buttonPanel.add(failButton);
|
||||
mainPanel.add(buttonPanel, BorderLayout.SOUTH);
|
||||
dialog.add(mainPanel);
|
||||
dialog.pack();
|
||||
dialog.setVisible(true);
|
||||
dialog.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
System.out.println("main dialog closing");
|
||||
testGeneratedInterrupt = false;
|
||||
mainThread.interrupt();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class MyComponent extends JComponent {
|
||||
private final Font font = new Font("Menlo", Font.ITALIC, 100);
|
||||
private final String text = "\u0627"; // Arabic letter alef
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
if (font.canDisplayUpTo(text) == -1) {
|
||||
g.setColor(Color.black);
|
||||
g.setFont(font);
|
||||
g.drawString(text, 70, 110);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
49
jdk/test/java/awt/font/TextLayout/HitTest.java
Normal file
49
jdk/test/java/awt/font/TextLayout/HitTest.java
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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
|
||||
* @summary verify Hit index with supplementary characters.
|
||||
* @bug 8173028
|
||||
*/
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.font.TextHitInfo;
|
||||
import java.awt.font.TextLayout;
|
||||
|
||||
public class HitTest {
|
||||
|
||||
public static void main(String args[]) {
|
||||
String s = new String(new int[]{0x1d400, 0x61}, 0, 2);
|
||||
Font font = new Font("Dialog", Font.PLAIN, 12);
|
||||
FontRenderContext frc = new FontRenderContext(null, false, false);
|
||||
TextLayout tl = new TextLayout(s, font, frc);
|
||||
TextHitInfo currHit = TextHitInfo.beforeOffset(3);
|
||||
TextHitInfo prevHit = tl.getNextLeftHit(currHit);
|
||||
System.out.println("index=" + prevHit.getCharIndex()+
|
||||
" leading edge=" + prevHit.isLeadingEdge());
|
||||
if (prevHit.getCharIndex() != 2) {
|
||||
throw new RuntimeException("Expected 2 for hit index");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @summary Verify no exception for unsupported code point.
|
||||
* @bug 8172967
|
||||
*/
|
||||
import java.awt.Font;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.font.TextLayout;
|
||||
|
||||
public class MissingCodePointLayoutTest {
|
||||
public static void main(String[] args) {
|
||||
Font font = new Font("Tahoma", Font.PLAIN, 12);
|
||||
String text = "\ude00";
|
||||
FontRenderContext frc = new FontRenderContext(null, false, false);
|
||||
TextLayout layout = new TextLayout(text, font, frc);
|
||||
layout.getCaretShapes(0);
|
||||
}
|
||||
}
|
||||
|
86
jdk/test/java/awt/image/ColorModel/EqualsTest.java
Normal file
86
jdk/test/java/awt/image/ColorModel/EqualsTest.java
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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 4524500 7107905
|
||||
* @run main EqualsTest
|
||||
* @summary Tests whether ColorModel.equals() succeeds using a
|
||||
* user-implemented subclass of ColorModel which calls the ColorModel(int bits)
|
||||
* constructor. The test fails if an exception is thrown when equals()
|
||||
* is called or if equals() returns an incorrect value.
|
||||
*/
|
||||
|
||||
import java.awt.image.ColorModel;
|
||||
|
||||
public class EqualsTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SimpleColorModel scm1 = new SimpleColorModel(3);
|
||||
SimpleColorModel scm2 = new SimpleColorModel(3);
|
||||
SimpleColorModel scm3 = new SimpleColorModel(8);
|
||||
ColorModel rgbcm = ColorModel.getRGBdefault();
|
||||
|
||||
try {
|
||||
if (scm1.equals(scm2)) {
|
||||
throw new RuntimeException("Test 1 failed: " +
|
||||
"scm1 should not equal scm2");
|
||||
}
|
||||
|
||||
if (scm1.equals(scm3)) {
|
||||
throw new RuntimeException("Test 2 failed: " +
|
||||
"scm1 should not equal scm3");
|
||||
}
|
||||
|
||||
if (scm1.equals(rgbcm) || rgbcm.equals(scm1)) {
|
||||
throw new RuntimeException("Test 3 failed: " +
|
||||
"scm1 should not equal rgbcm");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Test failed: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
private static class SimpleColorModel extends ColorModel {
|
||||
|
||||
public SimpleColorModel(int bits) {
|
||||
super(bits);
|
||||
}
|
||||
|
||||
public int getRed(int pixel) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getGreen(int pixel) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getBlue(int pixel) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getAlpha(int pixel) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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 7107905
|
||||
* @summary Test verifies whether equals() and hashCode() methods in
|
||||
* ComponentColorModel works properly.
|
||||
* @run main ComponentColorModelEqualsTest
|
||||
*/
|
||||
|
||||
import java.awt.Transparency;
|
||||
import java.awt.color.ColorSpace;
|
||||
import java.awt.image.ComponentColorModel;
|
||||
import java.awt.image.DataBuffer;
|
||||
|
||||
public class ComponentColorModelEqualsTest {
|
||||
|
||||
private static void verifyEquals(ComponentColorModel m1,
|
||||
ComponentColorModel m2) {
|
||||
if (m1.equals(null)) {
|
||||
throw new RuntimeException("equals(null) returns true");
|
||||
}
|
||||
if (!(m1.equals(m2))) {
|
||||
throw new RuntimeException("equals() method is not working"
|
||||
+ " properly");
|
||||
}
|
||||
if (!(m2.equals(m1))) {
|
||||
throw new RuntimeException("equals() method is not working"
|
||||
+ " properly");
|
||||
}
|
||||
if (m1.hashCode() != m2.hashCode()) {
|
||||
throw new RuntimeException("HashCode is not same for same"
|
||||
+ " ComponentColorModels");
|
||||
}
|
||||
}
|
||||
|
||||
private static void testConstructor1() {
|
||||
/*
|
||||
* verify equality with constructor
|
||||
* ComponentColorModel(ColorSpace colorSpace,
|
||||
* int[] bits,
|
||||
* boolean hasAlpha,
|
||||
* boolean isAlphaPremultiplied,
|
||||
* int transparency,
|
||||
* int transferType)
|
||||
*/
|
||||
ComponentColorModel model1 =
|
||||
new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
|
||||
new int[] {8, 8, 8},
|
||||
false,
|
||||
false,
|
||||
Transparency.OPAQUE,
|
||||
DataBuffer.TYPE_BYTE);
|
||||
ComponentColorModel model2 =
|
||||
new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
|
||||
new int[] {8, 8, 8},
|
||||
false,
|
||||
false,
|
||||
Transparency.OPAQUE,
|
||||
DataBuffer.TYPE_BYTE);
|
||||
verifyEquals(model1, model2);
|
||||
}
|
||||
|
||||
private static void testConstructor2() {
|
||||
/*
|
||||
* verify equality with constructor
|
||||
* ComponentColorModel(ColorSpace colorSpace,
|
||||
* boolean hasAlpha,
|
||||
* boolean isAlphaPremultiplied,
|
||||
* int transparency,
|
||||
* int transferType)
|
||||
*/
|
||||
ComponentColorModel model1 =
|
||||
new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
|
||||
false,
|
||||
false,
|
||||
Transparency.OPAQUE,
|
||||
DataBuffer.TYPE_BYTE);
|
||||
ComponentColorModel model2 =
|
||||
new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
|
||||
false,
|
||||
false,
|
||||
Transparency.OPAQUE,
|
||||
DataBuffer.TYPE_BYTE);
|
||||
verifyEquals(model1, model2);
|
||||
}
|
||||
|
||||
private static void testSameComponentColorModel() {
|
||||
testConstructor1();
|
||||
testConstructor2();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
// verify ComponentColorModel equality using different constructors.
|
||||
testSameComponentColorModel();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,250 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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 7107905
|
||||
* @summary Test verifies whether equals() and hashCode() methods in
|
||||
* IndexColorModel works properly for IndexColorModel unique
|
||||
* properties.
|
||||
* @run main IndexColorModelEqualsTest
|
||||
*/
|
||||
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.IndexColorModel;
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class IndexColorModelEqualsTest {
|
||||
|
||||
private static void verifyEquals(IndexColorModel m1,
|
||||
IndexColorModel m2) {
|
||||
if (m1.equals(null)) {
|
||||
throw new RuntimeException("equals(null) returns true");
|
||||
}
|
||||
if (!(m1.equals(m2))) {
|
||||
throw new RuntimeException("equals() method is not working"
|
||||
+ " properly");
|
||||
}
|
||||
if (!(m2.equals(m1))) {
|
||||
throw new RuntimeException("equals() method is not working"
|
||||
+ " properly");
|
||||
}
|
||||
if (m1.hashCode() != m2.hashCode()) {
|
||||
throw new RuntimeException("HashCode is not same for same"
|
||||
+ " IndexColorModels");
|
||||
}
|
||||
}
|
||||
|
||||
private static void testColorMapEquality() {
|
||||
// test with different cmap values.
|
||||
IndexColorModel model1 = new IndexColorModel(8, 3, new int[] {1, 2, 3},
|
||||
0, true, -1, DataBuffer.TYPE_BYTE);
|
||||
IndexColorModel model2 = new IndexColorModel(8, 3, new int[] {4, 5, 6},
|
||||
0, true, -1, DataBuffer.TYPE_BYTE);
|
||||
if (model1.equals(model2)) {
|
||||
throw new RuntimeException("equals() method is determining"
|
||||
+ " ColorMap equality improperly");
|
||||
}
|
||||
if (model2.equals(model1)) {
|
||||
throw new RuntimeException("equals() method is determining"
|
||||
+ " ColorMap equality improperly");
|
||||
}
|
||||
}
|
||||
|
||||
private static void testSizeEquality() {
|
||||
// test with different size for cmap.
|
||||
IndexColorModel model1 = new IndexColorModel(8, 4,
|
||||
new int[] {1, 2, 3, 4},
|
||||
0, true, -1, DataBuffer.TYPE_BYTE);
|
||||
IndexColorModel model2 = new IndexColorModel(8, 3,
|
||||
new int[] {1, 2, 3},
|
||||
0, true, -1, DataBuffer.TYPE_BYTE);
|
||||
if (model1.equals(model2)) {
|
||||
throw new RuntimeException("equals() method is determining"
|
||||
+ " Map size equality improperly");
|
||||
}
|
||||
if (model2.equals(model1)) {
|
||||
throw new RuntimeException("equals() method is determining"
|
||||
+ " Map size equality improperly");
|
||||
}
|
||||
}
|
||||
|
||||
private static void testTransparentIndexEquality() {
|
||||
// test with different values for transparent_index.
|
||||
IndexColorModel model1 = new IndexColorModel(8, 3, new int[] {1, 2, 3},
|
||||
0, true, 1, DataBuffer.TYPE_BYTE);
|
||||
IndexColorModel model2 = new IndexColorModel(8, 3, new int[] {1, 2, 3},
|
||||
0, true, 2, DataBuffer.TYPE_BYTE);
|
||||
if (model1.equals(model2)) {
|
||||
throw new RuntimeException("equals() method is determining"
|
||||
+ " TransparentIndex equality improperly");
|
||||
}
|
||||
if (model2.equals(model1)) {
|
||||
throw new RuntimeException("equals() method is determining"
|
||||
+ " TransparentIndex equality improperly");
|
||||
}
|
||||
}
|
||||
|
||||
private static void testValidPixelsEquality() {
|
||||
// test with different valid pixels.
|
||||
/*
|
||||
* In setRGBs() function of IndexColorModel we override
|
||||
* transparent_index value to map to pixel value if alpha is 0x00
|
||||
* so we should have atleast minimum alpha value to verify
|
||||
* equality of validBits thats why we have color value as
|
||||
* 16777216(2 ^ 24).
|
||||
*/
|
||||
int color = 16777216;
|
||||
IndexColorModel model1 = new IndexColorModel(8, 3, new int[] {color,
|
||||
color, color}, 0, DataBuffer.TYPE_BYTE, new BigInteger("1"));
|
||||
IndexColorModel model2 = new IndexColorModel(8, 3, new int[] {color,
|
||||
color, color}, 0, DataBuffer.TYPE_BYTE, new BigInteger("2"));
|
||||
if (model1.equals(model2)) {
|
||||
throw new RuntimeException("equals() method is determining"
|
||||
+ " Valid pixels equality improperly");
|
||||
}
|
||||
if (model2.equals(model1)) {
|
||||
throw new RuntimeException("equals() method is determining"
|
||||
+ " Valid pixels equality improperly");
|
||||
}
|
||||
}
|
||||
|
||||
private static void testConstructor1() {
|
||||
/*
|
||||
* verify equality with constructor
|
||||
* IndexColorModel(int bits, int size, byte[] r, byte[] g, byte[] b)
|
||||
*/
|
||||
IndexColorModel model1 = new IndexColorModel(8, 2,
|
||||
new byte[] {1, 2}, new byte[] {1, 2}, new byte[] {1, 2});
|
||||
IndexColorModel model2 = new IndexColorModel(8, 2,
|
||||
new byte[] {1, 2}, new byte[] {1, 2}, new byte[] {1, 2});
|
||||
verifyEquals(model1, model2);
|
||||
}
|
||||
|
||||
private static void testConstructor2() {
|
||||
/*
|
||||
* verify equality with constructor
|
||||
* IndexColorModel(int bits, int size, byte[] r, byte[] g, byte[] b,
|
||||
* byte[] a)
|
||||
*/
|
||||
IndexColorModel model1 = new IndexColorModel(8, 2, new byte[] {1, 2},
|
||||
new byte[] {1, 2}, new byte[] {1, 2}, new byte[] {1, 2});
|
||||
IndexColorModel model2 = new IndexColorModel(8, 2, new byte[] {1, 2},
|
||||
new byte[] {1, 2}, new byte[] {1, 2}, new byte[] {1, 2});
|
||||
verifyEquals(model1, model2);
|
||||
}
|
||||
|
||||
private static void testConstructor3() {
|
||||
/*
|
||||
* verify equality with constructor
|
||||
* IndexColorModel(int bits, int size, byte[] r, byte[] g, byte[] b,
|
||||
* int trans)
|
||||
*/
|
||||
IndexColorModel model1 = new IndexColorModel(8, 2, new byte[] {1, 2},
|
||||
new byte[] {1, 2}, new byte[] {1, 2}, 1);
|
||||
IndexColorModel model2 = new IndexColorModel(8, 2, new byte[] {1, 2},
|
||||
new byte[] {1, 2}, new byte[] {1, 2}, 1);
|
||||
verifyEquals(model1, model2);
|
||||
}
|
||||
|
||||
private static void testConstructor4() {
|
||||
/*
|
||||
* verify equality with constructor
|
||||
* IndexColorModel(int bits, int size, byte[] cmap, int start,
|
||||
* boolean hasalpha)
|
||||
*/
|
||||
IndexColorModel model1 = new IndexColorModel(8, 1,
|
||||
new byte[] {1, 2, 3, 4}, 0, true);
|
||||
IndexColorModel model2 = new IndexColorModel(8, 1,
|
||||
new byte[] {1, 2, 3, 4}, 0, true);
|
||||
verifyEquals(model1, model2);
|
||||
}
|
||||
|
||||
private static void testConstructor5() {
|
||||
/*
|
||||
* verify equality with constructor
|
||||
* IndexColorModel(int bits, int size, byte[] cmap, int start,
|
||||
* boolean hasalpha, int trans)
|
||||
*/
|
||||
IndexColorModel model1 = new IndexColorModel(8, 1,
|
||||
new byte[] {1, 2, 3, 4}, 0, true, 0);
|
||||
IndexColorModel model2 = new IndexColorModel(8, 1,
|
||||
new byte[] {1, 2, 3, 4}, 0, true, 0);
|
||||
verifyEquals(model1, model2);
|
||||
}
|
||||
|
||||
private static void testConstructor6() {
|
||||
/*
|
||||
* verify equality with constructor
|
||||
* IndexColorModel(int bits, int size, int[] cmap, int start,
|
||||
* boolean hasalpha, int trans, int transferType)
|
||||
*/
|
||||
IndexColorModel model1 = new IndexColorModel(8, 3, new int[] {1, 2, 3},
|
||||
0, true, -1, DataBuffer.TYPE_BYTE);
|
||||
IndexColorModel model2 = new IndexColorModel(8, 3, new int[] {1, 2, 3},
|
||||
0, true, -1, DataBuffer.TYPE_BYTE);
|
||||
verifyEquals(model1, model2);
|
||||
}
|
||||
|
||||
private static void testConstructor7() {
|
||||
/*
|
||||
* verify equality with constructor
|
||||
* IndexColorModel(int bits, int size, int[] cmap, int start,
|
||||
* int transferType, BigInteger validBits)
|
||||
*/
|
||||
/*
|
||||
* In setRGBs() function of IndexColorModel we override
|
||||
* transparent_index value to map to pixel value if alpha is 0x00
|
||||
* so we should have atleast minimum alpha value to keep
|
||||
* both model1 and model2 same.
|
||||
*/
|
||||
int color = 16777216;
|
||||
IndexColorModel model1 = new IndexColorModel(8, 3, new int[] {color,
|
||||
color, color}, 0, DataBuffer.TYPE_BYTE, new BigInteger("1"));
|
||||
IndexColorModel model2 = new IndexColorModel(8, 3, new int[] {color,
|
||||
color, color}, 0, DataBuffer.TYPE_BYTE, new BigInteger("1"));
|
||||
verifyEquals(model1, model2);
|
||||
}
|
||||
|
||||
private static void testSameIndexColorModel() {
|
||||
testConstructor1();
|
||||
testConstructor2();
|
||||
testConstructor3();
|
||||
testConstructor4();
|
||||
testConstructor5();
|
||||
testConstructor6();
|
||||
testConstructor7();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
/* test whether equals() method works properly for parameters
|
||||
* unique to IndexColorModel.
|
||||
*/
|
||||
testColorMapEquality();
|
||||
testSizeEquality();
|
||||
testTransparentIndexEquality();
|
||||
testValidPixelsEquality();
|
||||
// verify same IndexColorModel equality using different constructors.
|
||||
testSameIndexColorModel();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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 7107905
|
||||
* @summary Test verifies whether equals() and hashCode() methods in
|
||||
* PackedColorModel works properly.
|
||||
* @run main PackedColorModelEqualsTest
|
||||
*/
|
||||
|
||||
import java.awt.color.ColorSpace;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.DirectColorModel;
|
||||
|
||||
public class PackedColorModelEqualsTest {
|
||||
|
||||
private static void verifyEquals(DirectColorModel m1,
|
||||
DirectColorModel m2) {
|
||||
if (m1.equals(null)) {
|
||||
throw new RuntimeException("equals(null) returns true");
|
||||
}
|
||||
if (!(m1.equals(m2))) {
|
||||
throw new RuntimeException("equals() method is not working"
|
||||
+ " properly");
|
||||
}
|
||||
if (!(m2.equals(m1))) {
|
||||
throw new RuntimeException("equals() method is not working"
|
||||
+ " properly");
|
||||
}
|
||||
if (m1.hashCode() != m2.hashCode()) {
|
||||
throw new RuntimeException("HashCode is not same for same"
|
||||
+ " PackedColorModels");
|
||||
}
|
||||
}
|
||||
|
||||
private static void testMaskArrayEquality() {
|
||||
/*
|
||||
* Test with different maskArray values, since PackedColorModel
|
||||
* is abstract we use subclass DirectColorModel.
|
||||
*/
|
||||
DirectColorModel model1 =
|
||||
new DirectColorModel(24, 0x00FF0000, 0x0000FF00, 0x000000FF);
|
||||
DirectColorModel model2 =
|
||||
new DirectColorModel(24, 0x000000FF, 0x0000FF00, 0x00FF0000);
|
||||
if (model1.equals(model2)) {
|
||||
throw new RuntimeException("equals() method is determining"
|
||||
+ " ColorMap equality improperly");
|
||||
}
|
||||
if (model2.equals(model1)) {
|
||||
throw new RuntimeException("equals() method is determining"
|
||||
+ " ColorMap equality improperly");
|
||||
}
|
||||
}
|
||||
|
||||
private static void testConstructor1() {
|
||||
/*
|
||||
* verify equality with constructor
|
||||
* DirectColorModel(int bits, int rmask, int gmask, int bmask,
|
||||
* int amask)
|
||||
*/
|
||||
DirectColorModel model1 =
|
||||
new DirectColorModel(32, 0xFF000000, 0x00FF0000,
|
||||
0x0000FF00, 0x000000FF);
|
||||
DirectColorModel model2 =
|
||||
new DirectColorModel(32, 0xFF000000, 0x00FF0000,
|
||||
0x0000FF00, 0x000000FF);
|
||||
verifyEquals(model1, model2);
|
||||
}
|
||||
|
||||
private static void testConstructor2() {
|
||||
/*
|
||||
* verify equality with constructor
|
||||
* DirectColorModel(ColorSpace space, int bits, int rmask, int gmask,
|
||||
* int bmask, int amask, boolean isAlphaPremultiplied, int transferType)
|
||||
*/
|
||||
DirectColorModel model1 =
|
||||
new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
|
||||
32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF,
|
||||
false, DataBuffer.TYPE_BYTE);
|
||||
DirectColorModel model2 =
|
||||
new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
|
||||
32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF,
|
||||
false, DataBuffer.TYPE_BYTE);
|
||||
verifyEquals(model1, model2);
|
||||
}
|
||||
|
||||
private static void testSamePackedColorModel() {
|
||||
testConstructor1();
|
||||
testConstructor2();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
// test with different mask array.
|
||||
testMaskArrayEquality();
|
||||
// verify PackedColorModel equality using different constructors.
|
||||
testSamePackedColorModel();
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ import javax.swing.SwingUtilities;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8166591
|
||||
* @bug 8166591 8173876
|
||||
* @key headful
|
||||
* @summary [macos 10.12] Trackpad scrolling of text on OS X 10.12 Sierra
|
||||
* is very fast (Trackpad, Retina only)
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
/* @test
|
||||
@bug 4936917 7190578
|
||||
@bug 4936917 7190578 8174717
|
||||
@summary Tests if background is correctly painted when <BODY> has css margins
|
||||
@author Denis Sharypov
|
||||
@library ../../../regtesthelpers
|
||||
@ -72,6 +72,7 @@ public class bug4936917 {
|
||||
blockTillDisplayed(editorPane);
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
robot.delay(300);
|
||||
|
||||
int x0 = p.x + 15 ;
|
||||
int y = p.y + 15;
|
||||
|
Loading…
x
Reference in New Issue
Block a user