/** * @see TimingTarget#timingEvent(Animator, double) */ @Override public void timingEvent(Animator animator, double v) { currentAlpha = (float) (v * (MAX_ALPHA - MIN_ALPHA)) + MIN_ALPHA; if (WindowUtils.isWindowAlphaSupported()) { WindowUtils.setWindowAlpha(TransparentToolTipDialog.this, currentAlpha); } } }
/** * Create an overlay. * <p> * An "alpha-compatible" graphics configuration will be used when creating the window so as to enable a transparent * overlay. * * @param owner owning window, must not be <code>null</code> * @throws IllegalArgumentException if the <code>owner</code> parameter is <code>null</code> */ public AbstractJWindowOverlayComponent(Window owner) { this(owner, WindowUtils.getAlphaCompatibleGraphicsConfiguration()); }
/** * Applies the given mask to the given window. Does nothing if the * operation is not supported. The mask is treated as a bitmap and * ignores transparency. */ public static void setWindowMask(Window w, Shape mask) { getInstance().setWindowMask(w, mask); }
WindowUtils.setWindowMask(dragImage, dragIcon); WindowUtils.setWindowAlpha(dragImage, DEFAULT_ALPHA); move(initialScreenLoc); dragImage.setVisible(true);
/** Set the transparency of the ghosted image. * @param alpha transparency level */ public void setAlpha(float alpha) { WindowUtils.setWindowAlpha(dragImage, alpha); }
private static String getGamePath() { return WindowUtils.getAllWindows(false).stream().filter(window -> { char[] className = new char[512]; User32.INSTANCE.GetClassName(window.getHWND(), className, 512); return Native.toString(className).equals("POEWindowClass"); }).map(it -> { String filePath = it.getFilePath(); return StringUtils.substringBeforeLast(filePath, "\\"); }).findAny().orElse(null); } }
WindowUtils.setWindowMask(dragImage, dragIcon); WindowUtils.setWindowAlpha(dragImage, DEFAULT_ALPHA); move(initialScreenLoc); dragImage.setVisible(true);
/** Set the transparency of the ghosted image. */ public void setAlpha(float alpha) { WindowUtils.setWindowAlpha(dragImage, alpha); }
/** * Returns a {@link GraphicsConfiguration} comptible with alpha * compositing. */ public static GraphicsConfiguration getAlphaCompatibleGraphicsConfiguration() { return getInstance().getAlphaCompatibleGraphicsConfiguration(); }
/** * @see java.awt.event.MouseListener#mouseExited(MouseEvent) */ @Override public void mouseExited(MouseEvent e) { if (rolloverAnimated) { if ((transparencyAnimator != null) && (transparencyAnimator.isRunning())) { transparencyAnimator.stop(); } long duration = (long) ((MAX_ALPHA - currentAlpha) * FADE_IN_MAX_DURATION / (MAX_ALPHA - MIN_ALPHA)); if (duration <= 0) { timingEvent(null, 1.0); } else { transparencyAnimator = new Animator.Builder().setDuration(duration, TimeUnit.MILLISECONDS) .setInterpolator(new SplineInterpolator(0.8, 0.2, 0.2, 0.8)).addTarget(this).build(); transparencyAnimator.start(); } } else if (WindowUtils.isWindowAlphaSupported()) { WindowUtils.setWindowAlpha(TransparentToolTipDialog.this, MAX_ALPHA); } }
public Overlay(Window owner) { super(owner, WindowUtils.getAlphaCompatibleGraphicsConfiguration()); setBackground(new Color(0, 0, 0, 0)); // This is what you do in JDK7 setLayout(null); JButton b = new JButton("JButton"); b.setBounds(150, 150, 100, 24); add(b); TranslucentComponent c = new TranslucentComponent(); c.setBounds(150, 200, 300, 40); add(c); }
/** * Detects the size of an icon. * * @param hIcon * The icon handle type. * @return Either the requested icon's dimension or an {@link Dimension} * instance of {@code (0, 0)}. */ public static Dimension getIconSize(final HICON hIcon) { return getInstance().getIconSize(hIcon); }
/** * @see java.awt.event.MouseListener#mouseEntered(MouseEvent) */ @Override public void mouseEntered(MouseEvent e) { if (rolloverAnimated) { if ((transparencyAnimator != null) && (transparencyAnimator.isRunning())) { transparencyAnimator.stop(); } long duration = (long) ((currentAlpha - MIN_ALPHA) * FADE_OUT_MAX_DURATION / (MAX_ALPHA - MIN_ALPHA)); if (duration <= 0) { timingEvent(null, 0.0); } else { transparencyAnimator = new Animator.Builder().setDuration(duration, TimeUnit.MILLISECONDS) .setInterpolator(new SplineInterpolator(0.8, 0.2, 0.2, 0.8)).addTarget(this).build(); transparencyAnimator.startReverse(); } } else if (WindowUtils.isWindowAlphaSupported()) { WindowUtils.setWindowAlpha(TransparentToolTipDialog.this, MIN_ALPHA); } }
/** * Applies the given mask to the given heavyweight component. Does nothing * if the operation is not supported. The mask is treated as a bitmap and * ignores transparency. */ public static void setComponentMask(Component c, Shape mask) { getInstance().setWindowMask(c, mask); }
/** * Obtains the set icon for the window associated with the specified * window handle. * * @param hwnd * The concerning window handle. * @return Either the window's icon or {@code null} if an error * occurred. */ public static BufferedImage getWindowIcon(final HWND hwnd) { return getInstance().getWindowIcon(hwnd); }
/** * Tries to obtain the Window's title which belongs to the specified window * handle. * * @param hwnd * The concerning window handle. * @return Either the title or an empty string of no title was found or an * error occurred. */ public static String getWindowTitle(final HWND hwnd) { return getInstance().getWindowTitle(hwnd); }
/** * Returns a {@link GraphicsConfiguration} comptible with alpha * compositing. */ public static GraphicsConfiguration getAlphaCompatibleGraphicsConfiguration() { return getInstance().getAlphaCompatibleGraphicsConfiguration(); }
/** * Applies the given mask to the given heavyweight component. Does nothing * if the operation is not supported. The mask is treated as a bitmap and * ignores transparency. */ public static void setComponentMask(Component c, Shape mask) { getInstance().setWindowMask(c, mask); }
/** * Applies the given mask to the given window. Does nothing if the * operation is not supported. The mask is treated as a bitmap and * ignores transparency. */ public static void setWindowMask(Window w, Icon mask) { getInstance().setWindowMask(w, mask); }
/** * Requests the location and size of the window associated with the * specified window handle. * * @param hwnd * The concerning window handle. * @return The location and size of the window. */ public static Rectangle getWindowLocationAndSize(final HWND hwnd) { return getInstance().getWindowLocationAndSize(hwnd); } }