Example usage for java.awt Component isVisible

List of usage examples for java.awt Component isVisible

Introduction

In this page you can find the example usage for java.awt Component isVisible.

Prototype

@Transient
public boolean isVisible() 

Source Link

Document

Determines whether this component should be visible when its parent is visible.

Usage

From source file:self.philbrown.javaQuery.$.java

/**
 * Select all {@link View#INVISIBLE invisible}, {@link View#GONE gone}, and 0-alpha views within the 
 * view hierarchy rooted at the given view
 * @param v the view hierarchy in which to search
 * @return a list the found views/* w w  w  . jav  a2s .c om*/
 */
private List<Component> recursivelySelectHidden(Component v) {
    List<Component> list = new ArrayList<Component>();
    if (v instanceof Container) {
        for (int i = 0; i < ((Container) v).getComponentCount(); i++) {
            list.addAll(recursivelySelectHidden(((Container) v).getComponent(i)));
        }
    }
    if (!v.isVisible() || v.isOpaque())
        list.add(v);
    return list;
}

From source file:self.philbrown.javaQuery.$.java

/**
 * Select all {@link View#VISIBLE visible} and 1-alpha views within the given view hierarchy
 * @param v the view to search in//from ww  w . ja va2s . c o  m
 * @return a list the found views
 */
private List<Component> recursivelySelectVisible(Component v) {
    List<Component> list = new ArrayList<Component>();
    if (v instanceof Container) {
        for (int i = 0; i < ((Container) v).getComponentCount(); i++) {
            list.addAll(recursivelySelectVisible(((Container) v).getComponent(i)));
        }
    }
    if (v.isVisible() || !v.isOpaque())
        list.add(v);
    return list;
}

From source file:com.mirth.connect.client.ui.Frame.java

private Component getVisibleComponent(Component component) {
    if (component != null && component.isVisible()) {
        return component;
    } else if (this.isVisible()) {
        return this;
    } else {//from  w ww  . j ava  2 s. c  om
        return null;
    }
}

From source file:fxts.stations.ui.SideLayout.java

/**
 * Lays out the grid.//from   www  .  java 2  s  . c  om
 *
 * @param aParent the layout container
 */
protected void arrangeGrid(Container aParent) {
    /////////////////////////////////////////////////////////
    //It`s only for debugging
    JComponent jc = (JComponent) aParent;
    String sType = (String) jc.getClientProperty("TYPE");
    if (sType != null) {
        boolean bInternal = "internal".equals(sType);
        mLogger.debug("\n" + sType);
    }
    //////////////////////////////////////////////////////////
    Component comp;
    int compindex;
    SideConstraints constraints;
    Insets insets = aParent.getInsets();
    Component[] components = aParent.getComponents();
    Dimension d;
    Rectangle r = new Rectangle();
    int i, diffw, diffh;
    double weight;
    SideLayoutInfo info;
    mRightToLeft = !aParent.getComponentOrientation().isLeftToRight();

    /*
    * If the parent has no slaves anymore, then don't do anything
    * at all:  just leave the parent's size as-is.
    */
    if (components.length == 0 && (mColumnWidths == null || mColumnWidths.length == 0)
            && (mRowHeights == null || mRowHeights.length == 0)) {
        return;
    }

    /*
    * Pass #1: scan all the slaves to figure out the total amount
    * of space needed.
    */

    info = getLayoutInfo(aParent, PREFERREDSIZE);
    d = getMinSize(aParent, info);

    //
    //    System.out.println("parent=w:" + parent.getWidth() + ",h:" + parent.getHeight() +
    //                       "min=w:" + d.getWidth() + ",h:" + d.getHeight());
    if (aParent.getWidth() < d.width || aParent.getHeight() < d.height) {
        info = getLayoutInfo(aParent, MINSIZE);
        d = getMinSize(aParent, info);
        //
        //      System.out.println("MINSIZE");
    } else {
        //
        //      System.out.println("Non MINSIZE");
    }
    mLayoutInfo = info;
    r.width = d.width;
    r.height = d.height;

    /*
    * If the current dimensions of the window don't match the desired
    * dimensions, then adjust the minWidth and minHeight arrays
    * according to the weights.
    */

    diffw = aParent.getWidth() - r.width;
    //
    //    System.out.println("diffw=" + diffw);
    if (diffw != 0) {
        weight = 0.0;
        for (i = 0; i < info.width; i++) {
            weight += info.weightX[i];
        }
        if (weight > 0.0) {
            for (i = 0; i < info.width; i++) {
                int dx = (int) (((double) diffw * info.weightX[i]) / weight);
                info.minWidth[i] += dx;
                r.width += dx;
                if (info.minWidth[i] < 0) {
                    r.width -= info.minWidth[i];
                    info.minWidth[i] = 0;
                }
            }
        }
        diffw = aParent.getWidth() - r.width;
    } else {
        diffw = 0;
    }
    diffh = aParent.getHeight() - r.height;
    //
    //    System.out.println("diffh=" + diffh);
    if (diffh != 0) {
        weight = 0.0;
        for (i = 0; i < info.height; i++) {
            weight += info.weightY[i];
        }
        if (weight > 0.0) {
            for (i = 0; i < info.height; i++) {
                int dy = (int) (((double) diffh * info.weightY[i]) / weight);
                info.minHeight[i] += dy;
                r.height += dy;
                if (info.minHeight[i] < 0) {
                    r.height -= info.minHeight[i];
                    info.minHeight[i] = 0;
                }
            }
        }
        diffh = aParent.getHeight() - r.height;
    } else {
        diffh = 0;
    }

    /*
    * Now do the actual layout of the slaves using the layout information
    * that has been collected.
    */

    info.startx = /*diffw/2 +*/ insets.left;
    info.starty = /*diffh/2 +*/ insets.top;
    //
    //    System.out.println("info.startx = " + info.startx);
    //    System.out.println("info.starty = " + info.startx);
    for (compindex = 0; compindex < components.length; compindex++) {
        comp = components[compindex];
        if (!comp.isVisible()) {
            continue;
        }
        constraints = lookupConstraints(comp);
        if (!mRightToLeft) {
            r.x = info.startx;
            for (i = 0; i < constraints.tempX; i++) {
                r.x += info.minWidth[i];
            }
        } else {
            r.x = aParent.getWidth() - insets.right;
            for (i = 0; i < constraints.tempX; i++) {
                r.x -= info.minWidth[i];
            }
        }
        r.y = info.starty;
        for (i = 0; i < constraints.tempY; i++) {
            r.y += info.minHeight[i];
        }
        r.width = 0;
        for (i = constraints.tempX; i < constraints.tempX + constraints.tempWidth; i++) {
            r.width += info.minWidth[i];
        }
        r.height = 0;
        for (i = constraints.tempY; i < constraints.tempY + constraints.tempHeight; i++) {
            r.height += info.minHeight[i];
        }
        adjustForGravity(constraints, r);
        if (r.x < 0) {
            r.width -= r.x;
            r.x = 0;
        }
        if (r.y < 0) {
            r.height -= r.y;
            r.y = 0;
        }

        /*
        * If the window is too small to be interesting then
        * unmap it.  Otherwise configure it and then make sure
        * it's mapped.
        */

        if (r.width <= 0 || r.height <= 0) {
            comp.setBounds(0, 0, 0, 0);
        } else {
            if (comp.getX() != r.x || comp.getY() != r.y || comp.getWidth() != r.width
                    || comp.getHeight() != r.height) {
                comp.setBounds(r.x, r.y, r.width, r.height);
            }
        }

        //        System.out.println("Initial component size (x = " + (int)comp.getX() +
        //                           ", y = " + (int)(comp.getY()) +
        //                           ", widht = " + (int)(comp.getWidth()) +
        //                           ", height = " + (int)(comp.getHeight()));
        if (diffw > 0) {
            //            System.out.println("It`s increasing by x!");
            //if (comp instanceof IResizableComponent) {
            //                System.out.println("It`s resizable component: " + comp);

            //IResizableComponent resizeComp = (IResizableComponent)comp;
            ResizeParameter param = constraints.resize;

            //                System.out.println("Params: Left=" + param.getLeft() + ",top=" + param.getTop() +
            //                                   ",Right=" + param.getRight() + ",bottom=" + param.getBottom());
            comp.setBounds((int) (comp.getX() + diffw * param.getLeft()), comp.getY(),
                    (int) (comp.getWidth() + diffw * (param.getRight() - param.getLeft())), comp.getHeight());

            //                System.out.println("Set Bounds (x = " + (int)(comp.getX() + diffw * param.getLeft()) +
            //                    ", y = " + (int)(comp.getY()) +
            //                    ", widht = " + (int)(comp.getWidth() +
            ///                                     diffw * (param.getRight() - param.getLeft())) +
            //                    ", height = " + (int)(comp.getHeight()));
            //            }
        }
        if (diffh > 0) {
            //            System.out.println("It`s increasing by y!");
            //            if (comp instanceof IResizableComponent) {
            //                System.out.println("It`s resizable component: " + comp);

            //                IResizableComponent resizeComp = (IResizableComponent)comp;
            ResizeParameter param = constraints.resize;

            //                System.out.println("Params: Left=" + param.getLeft() + ",top=" + param.getTop() +
            //                                   ",Right=" + param.getRight() + ",bottom=" + param.getBottom());
            comp.setBounds(comp.getX(), (int) (comp.getY() + diffh * param.getTop()), comp.getWidth(),
                    (int) (comp.getHeight() + diffh * (param.getBottom() - param.getTop())));

            //                System.out.println("Set Bounds (x = " + (int)(comp.getX()) +
            //                    ", y = " + (int)(comp.getY() + diffh * param.getTop()) +
            //                    ", widht = " + (int)(comp.getWidth()) +
            //                    ", height = " + (int)(comp.getHeight() +
            //                                     diffh * (param.getBottom() - param.getTop())));
            //            }
        }
    }
}