Package com.alee.laf.tree

Examples of com.alee.laf.tree.WebTree


     */
    @Override
    public Component getPreview ( final WebLookAndFeelDemo owner )
    {
        // Editable tree
        final WebTree tree1 = new WebTree ();
        tree1.setEditable ( true );
        tree1.setSelectionMode ( WebTree.DISCONTIGUOUS_TREE_SELECTION );
        final WebScrollPane treeScroll1 = new WebScrollPane ( tree1 );
        treeScroll1.setPreferredSize ( new Dimension ( 200, 150 ) );

        // Tree with a custom selection style
        final WebTree tree2 = new WebTree ();
        tree2.setEditable ( true );
        tree2.setSelectionMode ( WebTree.DISCONTIGUOUS_TREE_SELECTION );
        tree2.setSelectionStyle ( TreeSelectionStyle.group );
        final WebScrollPane treeScroll2 = new WebScrollPane ( tree2 );
        treeScroll2.setPreferredSize ( new Dimension ( 200, 150 ) );

        return new GroupPanel ( treeScroll1, treeScroll2 );
    }
View Full Code Here


        if ( dragSourceDragEvent.getSource () instanceof DragSourceContext )
        {
            final DragSourceContext dsc = ( DragSourceContext ) dragSourceDragEvent.getSource ();
            if ( dsc.getComponent () instanceof WebTree )
            {
                final WebTree tree = ( WebTree ) dsc.getComponent ();
                final List<E> realNodes;
                if ( nodes.get ( 0 ) instanceof UniqueNode )
                {
                    final List<UniqueNode> uniqueNodes = ( List<UniqueNode> ) nodes;
                    if ( tree instanceof WebExTree )
                    {
                        final WebExTree exTree = ( WebExTree ) tree;
                        realNodes = new ArrayList<E> ();
                        for ( final UniqueNode node : uniqueNodes )
                        {
                            realNodes.add ( ( E ) exTree.findNode ( node.getId () ) );
                        }
                    }
                    else if ( tree instanceof WebExTree )
                    {
                        final WebAsyncTree exTree = ( WebAsyncTree ) tree;
                        realNodes = new ArrayList<E> ();
                        for ( final UniqueNode node : uniqueNodes )
                        {
                            realNodes.add ( ( E ) exTree.findNode ( node.getId () ) );
                        }
                    }
                    else
                    {
                        realNodes = nodes;
                    }
                }
                else
                {
                    realNodes = nodes;
                }

                final FontMetrics fm = tree.getFontMetrics ( tree.getFont () );
                final int fmh = fm.getHeight ();

                final int limit = getNodesViewLimit ();
                final int amount = realNodes.size () - limit;
                final String text = amount > 1 ? "And %s more elements" : "And one more element";
                final String moreText = limit > 0 ? String.format ( text, amount ) : null;
                final Insets moreTextOffset = getMoreTextMargin ();

                int width = 0;
                int height = 0;
                int count = 0;
                for ( final DefaultMutableTreeNode node : realNodes )
                {
                    if ( limit <= 0 || limit > count )
                    {
                        final Rectangle bounds = tree.getNodeBounds ( node );
                        width = Math.max ( bounds.width, width );
                        height += bounds.height;
                        count++;
                    }
                    else
                    {
                        width = Math.max ( moreTextOffset.left + fm.stringWidth ( moreText ) + moreTextOffset.right, width );
                        height += moreTextOffset.top + fmh + moreTextOffset.bottom;
                        break;
                    }
                }

                final BufferedImage image = ImageUtils.createCompatibleImage ( width, height, BufferedImage.TRANSLUCENT );
                final Graphics2D g2d = image.createGraphics ();
                int y = 0;
                count = 0;
                for ( final E node : realNodes )
                {
                    if ( limit <= 0 || limit > count )
                    {
                        final int row = tree.getRowForNode ( node );
                        final boolean exp = tree.isExpanded ( node );
                        final boolean leaf = tree.getModel ().isLeaf ( node );
                        final Component r =
                                tree.getCellRenderer ().getTreeCellRendererComponent ( tree, node, false, exp, leaf, row, false );
                        final Dimension ps = r.getPreferredSize ();
                        tree.getCellRendererPane ().paintComponent ( g2d, r, null, 0, y, ps.width, ps.height );
                        y += ps.height;
                        count++;
                    }
                    else
                    {
View Full Code Here

TOP

Related Classes of com.alee.laf.tree.WebTree

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.