Java Code Examples for org.netbeans.api.visual.widget.Widget#isVisible()

The following examples show how to use org.netbeans.api.visual.widget.Widget#isVisible() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbsoluteLayout.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void layout (Widget widget) {
    Collection<Widget> children = widget.getChildren ();
    for (Widget child : children) {
        if (child.isVisible ())
            child.resolveBounds (child.getPreferredLocation (), null);
        else
            child.resolveBounds (null, new Rectangle ());
    }
}
 
Example 2
Source File: OverlayLayout.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void justify (Widget widget) {
    Rectangle clientArea = widget.getClientArea ();
    for (Widget child : widget.getChildren ()) {
        if (child.isVisible ()) {
            Point location = child.getPreferredBounds ().getLocation ();
            child.resolveBounds (new Point (clientArea.x - location.x, clientArea.y - location.y), new Rectangle (location, clientArea.getSize ()));
        } else {
            child.resolveBounds (clientArea.getLocation (), new Rectangle ());
        }
    }
}
 
Example 3
Source File: DesignerWidgetIdentityCode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the index of visible widget represented by given object using depth first search.
 * Integer.MAX_VALUE if none found.
 */ 
private static int getIdentityCode(ObjectScene scene, Object object) {
    List<Widget> widgets = scene.findWidgets(object);
    Widget w = null;
    ArrayList<Widget> pathToRoot = new ArrayList<Widget>();
    if(widgets!=null) {
        for(Widget w1:widgets) {
            pathToRoot = new ArrayList<Widget>();
            if(!w1.isVisible()) continue;
            Widget parent = w1.getParentWidget();
            while(parent!=null && parent.isVisible()) {
                pathToRoot.add(0,parent);
                parent = parent.getParentWidget();
            }
            if(!pathToRoot.isEmpty()&&pathToRoot.get(0)==scene) {
                w = w1;
                pathToRoot.add(w);
                break;
            }
        }
    }
    if(w==null) 
        return Integer.MAX_VALUE;
    int code = 0;
    for(int i=0;i<pathToRoot.size();) {
        Widget widgetOnPath=pathToRoot.get(i++);
        code++;
        if(i == pathToRoot.size()) break;
        int nextWidgetOnPathIndex = widgetOnPath.getChildren().indexOf(pathToRoot.get(i));
        for(int j=0;j<nextWidgetOnPathIndex;j++) {
            code+=getTreeSize(widgetOnPath.getChildren().get(j));
        }
    }
    return code;
}
 
Example 4
Source File: DesignerWidgetIdentityCode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static int getTreeSize(Widget w) {
    if(!w.isVisible()) return 0;
    int size = 1;
    for(Widget ch:w.getChildren()) {
        size+= getTreeSize(ch);
    }
    return size;
}
 
Example 5
Source File: WsitWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void determineVisibility() {
    for(Widget button:configButtons.getChildren()) {
        if(button.isVisible()) {
            setVisible(true);
            return;
        }
    }
    setVisible(false);
}
 
Example 6
Source File: ConnectionWidgetLayout.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void layout (Widget widget) {
    ConnectionWidget connectionWidget = (ConnectionWidget) widget;

    connectionWidget.calculateRouting ();
    java.util.List<Point> controlPoints = connectionWidget.getControlPoints ();
    boolean empty = controlPoints == null  ||  controlPoints.size () <= 0;

    double totalDistance = 0.0;
    double[] distances = new double[empty ? 0 : controlPoints.size () - 1];
    for (int i = 0; i < distances.length; i ++)
        distances[i] = totalDistance += GeomUtil.distanceSq (controlPoints.get (i), controlPoints.get (i + 1));

    ArrayList<Widget> childrenToResolve = new ArrayList<Widget> (widget.getChildren());
    for (Map.Entry<Placement,ArrayList<Widget>> entry : reverse.entrySet()) {
        Placement placement = entry.getKey ();
        ArrayList<Widget> currentlyResolving = null;
        for (Widget childWidget : entry.getValue()) {
            if (childWidget.getParentWidget() == widget  &&  childWidget.isVisible()) {
                if (currentlyResolving == null)
                    currentlyResolving = new ArrayList<Widget>();
                currentlyResolving.add(childWidget);
            }
        }
        if (currentlyResolving == null)
            continue;
        Point point;
        if (empty) {
            point = new Point();
        } else if (placement.isPercentage) {
            float percentage = placement.placementInPercentage;
            if (percentage <= 0.0)
                point = connectionWidget.getFirstControlPoint ();
            else if (percentage >= 1.0)
                point = connectionWidget.getLastControlPoint ();
            else
                point = getLinePointAtPercentage (distances, (int) (percentage * totalDistance), controlPoints);
        } else {
            int distance = placement.placementAtDistance;
            if (distance < 0)
                point = getLinePointAtPercentage (distances, distance + (int) totalDistance, controlPoints);
            else
                point = getLinePointAtPercentage (distances, distance, controlPoints);
        }
        layoutChildrenAt (point, placement.alignment, connectionWidget, currentlyResolving);
        childrenToResolve.removeAll (currentlyResolving);
    }
    if (! childrenToResolve.isEmpty())
        layoutChildrenAt (new Point (), null, connectionWidget, childrenToResolve);
}