Package com.alee.managers.glasspane

Examples of com.alee.managers.glasspane.WebGlassPane


    public static void setHiglightedComponent ( final Component highlight, final Component highlightBase )
    {
        if ( highlight != null )
        {
            final WebGlassPane wgp = GlassPaneManager.getGlassPane ( SwingUtils.getWindowAncestor ( highlight ) );
            if ( wgp != null )
            {
                wgp.clearHighlights ();
                wgp.setHighlightBase ( highlightBase != null ? highlightBase : wgp );
                wgp.addHighlightedComponents ( highlight );
            }
        }
    }
View Full Code Here


        if ( highlights != null && highlights.size () > 0 )
        {
            final List<String> clearedIds = new ArrayList<String> ();
            for ( final Component component : highlights )
            {
                final WebGlassPane wgp = GlassPaneManager.getGlassPane ( SwingUtils.getWindowAncestor ( component ) );
                if ( wgp != null )
                {
                    if ( !clearedIds.contains ( wgp.getId () ) )
                    {
                        wgp.setHighlightBase ( highlightBase != null ? highlightBase : wgp );
                        wgp.clearHighlights ();
                        clearedIds.add ( wgp.getId () );
                    }
                    wgp.addHighlightedComponents ( component );
                }
            }
        }
    }
View Full Code Here

    public static void removeHigligtedComponent ( final Component highlight )
    {
        if ( highlight != null )
        {
            final WebGlassPane wgp = GlassPaneManager.getGlassPane ( SwingUtils.getWindowAncestor ( highlight ) );
            if ( wgp != null )
            {
                wgp.removeHighlightedComponents ( highlight );
            }
        }
    }
View Full Code Here

    {
        if ( highlights != null && highlights.size () > 0 )
        {
            for ( final Component component : highlights )
            {
                final WebGlassPane wgp = GlassPaneManager.getGlassPane ( SwingUtils.getWindowAncestor ( component ) );
                if ( wgp != null )
                {
                    wgp.removeHighlightedComponents ( component );
                }
            }
        }
    }
View Full Code Here

     * Removes all highlights from window
     */

    public static void clearHighlightedComponents ( final Window window )
    {
        final WebGlassPane wgp = GlassPaneManager.getGlassPane ( window );
        if ( wgp != null )
        {
            wgp.clearHighlights ();
        }
    }
View Full Code Here

     * Sets highlight base for window
     */

    public static void setHighlightBase ( final Window window, final Component highlightBase )
    {
        final WebGlassPane wgp = GlassPaneManager.getGlassPane ( window );
        if ( wgp != null )
        {
            wgp.setHighlightBase ( highlightBase );
        }
    }
View Full Code Here

    public static void fadeOut ( final JComponent component )
    {
        final BufferedImage bi = SwingUtils.createComponentSnapshot ( component );
        final Rectangle b = SwingUtils.getBoundsInWindow ( component );
        final WebGlassPane wgp = GlassPaneManager.getGlassPane ( component );

        // Initial image palcement
        wgp.setPaintedImage ( bi, b.getLocation (), 100 );

        // Hiding component
        component.setVisible ( false );

        // Animating fade
        WebTimer.repeat ( "EffectsManager.fadeOut", StyleConstants.avgAnimationDelay, new ActionListener ()
        {
            private int opacity = 100;

            @Override
            public void actionPerformed ( final ActionEvent e )
            {
                if ( opacity > 0 )
                {
                    opacity -= 5;
                    final Point l = b.getLocation ();
                    l.y += ( 100 - opacity ) / 2;
                    wgp.setPaintedImage ( bi, l, opacity );
                }
                else
                {
                    wgp.clearPaintedImage ();
                    ( ( WebTimer ) e.getSource () ).stop ();
                }
            }
        } );
    }
View Full Code Here

            {
                timers.get ( component ).restart ();
            }
            else
            {
                final WebGlassPane webGlassPane = GlassPaneManager.getGlassPane ( component );
                if ( webGlassPane != null )
                {
                    final List<WebCustomTooltip> tooltips = new ArrayList<WebCustomTooltip> ();
                    tooltips.addAll ( webTooltips.get ( component ) );
                    for ( final WebCustomTooltip tooltip : tooltips )
                    {
                        webGlassPane.showComponent ( tooltip );
                    }
                }
            }
            return true;
        }
View Full Code Here

            return null;
        }

        // Checking if glass pane is available
        final Window window = SwingUtils.getWindowAncestor ( customTooltip.getComponent () );
        final WebGlassPane webGlassPane = GlassPaneManager.getGlassPane ( window );
        if ( webGlassPane == null )
        {
            return null;
        }

        // Adding relocate listener
        final ComponentAdapter componentAdapter = new ComponentAdapter ()
        {
            @Override
            public void componentResized ( final ComponentEvent e )
            {
                customTooltip.updateLocation ();
            }
        };
        webGlassPane.addComponentListener ( componentAdapter );

        // Global mouse listener
        final AWTEventListener closeListener = customTooltip.isDefaultCloseBehavior () ? new AWTEventListener ()
        {
            @Override
            public void eventDispatched ( final AWTEvent event )
            {
                if ( event instanceof MouseEvent && event.getID () == MouseEvent.MOUSE_PRESSED )
                {
                    customTooltip.closeTooltip ();
                }
            }
        } : null;

        // Adding destroy sequence
        customTooltip.addTooltipListener ( new TooltipAdapter ()
        {
            @Override
            public void tooltipShowing ()
            {
                if ( customTooltip.isDefaultCloseBehavior () )
                {
                    // Mouse press listener to close one-time tooltip
                    Toolkit.getDefaultToolkit ().addAWTEventListener ( closeListener, AWTEvent.MOUSE_EVENT_MASK );
                }
            }

            @Override
            public void tooltipHidden ()
            {
                // Removing tooltip listener
                customTooltip.removeTooltipListener ( this );

                if ( customTooltip.isDefaultCloseBehavior () )
                {
                    // Removing press listener
                    Toolkit.getDefaultToolkit ().removeAWTEventListener ( closeListener );
                }

                // Removing tooltip from list
                oneTimeTooltips.remove ( customTooltip );

                // Removing relocation listener
                webGlassPane.removeComponentListener ( componentAdapter );

                if ( destroyOnClose )
                {
                    // Destroying tooltip
                    customTooltip.destroyTooltip ();
                }
            }
        } );

        // Registering one-time tooltip
        oneTimeTooltips.add ( customTooltip );

        // Displaying one-time tooltip
        webGlassPane.showComponent ( customTooltip );

        return customTooltip;
    }
View Full Code Here

     *
     * @param button magnifier display button
     */
    private void initializeMagnifier ( final WebToggleButton button )
    {
        final WebGlassPane glassPane = GlassPaneManager.getGlassPane ( StyleEditor.this );
        final JComponent zoomProvider = SwingUtils.getRootPane ( StyleEditor.this ).getLayeredPane ();
        button.addActionListener ( new ActionListener ()
        {
            private boolean visible = false;
            private AWTEventListener listener;
            private WebTimer forceUpdater;

            @Override
            public void actionPerformed ( final ActionEvent e )
            {
                performAction ();
            }

            protected void performAction ()
            {
                if ( !visible )
                {
                    visible = true;

                    if ( forceUpdater == null || listener == null )
                    {
                        forceUpdater = new WebTimer ( 200, new ActionListener ()
                        {
                            @Override
                            public void actionPerformed ( final ActionEvent e )
                            {
                                updateMagnifier ();
                            }
                        } );
                        listener = new AWTEventListener ()
                        {
                            @Override
                            public void eventDispatched ( final AWTEvent event )
                            {
                                SwingUtilities.invokeLater ( new Runnable ()
                                {
                                    @Override
                                    public void run ()
                                    {
                                        if ( visible )
                                        {
                                            forceUpdater.restart ();
                                            updateMagnifier ();
                                        }
                                    }
                                } );
                            }
                        };
                    }
                    Toolkit.getDefaultToolkit ().addAWTEventListener ( listener, AWTEvent.MOUSE_MOTION_EVENT_MASK );
                    Toolkit.getDefaultToolkit ().addAWTEventListener ( listener, AWTEvent.MOUSE_WHEEL_EVENT_MASK );
                    Toolkit.getDefaultToolkit ().addAWTEventListener ( listener, AWTEvent.MOUSE_EVENT_MASK );
                    updateMagnifier ();

                    setCursor ( SystemUtils.getTransparentCursor () );
                }
                else
                {
                    visible = false;

                    Toolkit.getDefaultToolkit ().removeAWTEventListener ( listener );
                    forceUpdater.stop ();
                    hideMagnifier ();

                    setCursor ( Cursor.getDefaultCursor () );
                }
            }

            protected void updateMagnifier ()
            {
                final Point mp = MouseInfo.getPointerInfo ().getLocation ();
                final Rectangle gb = SwingUtils.getBoundsOnScreen ( glassPane );
                if ( gb.contains ( mp ) )
                {
                    final Point gp = gb.getLocation ();
                    final int mx = mp.x - gp.x - magnifier.getWidth () / 2;
                    final int my = mp.y - gp.y - magnifier.getHeight () / 2;

                    final int w = 162 / zoomFactor;
                    final BufferedImage image = ImageUtils.createCompatibleImage ( w, w, Transparency.TRANSLUCENT );
                    final Graphics2D g2d = image.createGraphics ();
                    g2d.translate ( -( mp.x - gp.x - w / 2 ), -( mp.y - gp.y - w / 2 ) );
                    zoomProvider.paintAll ( g2d );
                    g2d.dispose ();

                    final BufferedImage finalImage = ImageUtils.createCompatibleImage ( 220, 220, Transparency.TRANSLUCENT );
                    final Graphics2D g = finalImage.createGraphics ();
                    g.setClip ( new Ellipse2D.Double ( 29, 29, 162, 162 ) );
                    g.drawImage ( image, 29, 29, 162, 162, null );
                    g.setClip ( null );
                    g.drawImage ( magnifier, 0, 0, null );
                    g.dispose ();

                    glassPane.setPaintedImage ( finalImage, new Point ( mx, my ) );
                }
                else
                {
                    hideMagnifier ();
                }
            }

            protected void hideMagnifier ()
            {
                glassPane.setPaintedImage ( null, null );
            }
        } );
    }
View Full Code Here

TOP

Related Classes of com.alee.managers.glasspane.WebGlassPane

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.