FileDocCategorySizeDatePackage
ViewHierarchyScene.javaAPI DocAndroid 1.5 API10041Wed May 06 22:41:10 BST 2009com.android.hierarchyviewer.scene

ViewHierarchyScene

public class ViewHierarchyScene extends org.netbeans.api.visual.graph.GraphScene

Fields Summary
private ViewNode
root
private org.netbeans.api.visual.widget.LayerWidget
widgetLayer
private org.netbeans.api.visual.widget.LayerWidget
connectionLayer
private org.netbeans.api.visual.action.WidgetAction
moveAction
Constructors Summary
public ViewHierarchyScene()


      
        widgetLayer = new LayerWidget(this);
        connectionLayer = new LayerWidget(this);

        addChild(widgetLayer);
        addChild(connectionLayer);
    
Methods Summary
protected voidattachEdgeSourceAnchor(java.lang.String edge, ViewNode oldSourceNode, ViewNode sourceNode)

        final ConnectionWidget connection = (ConnectionWidget) findWidget(edge);
        final Widget source = findWidget(sourceNode);
        connection.bringToBack();
        source.bringToFront();
        connection.setSourceAnchor(AnchorFactory.createRectangularAnchor(source));
    
protected voidattachEdgeTargetAnchor(java.lang.String edge, ViewNode oldTargetNode, ViewNode targetNode)

        final ConnectionWidget connection = (ConnectionWidget) findWidget(edge);
        final Widget target = findWidget(targetNode);
        connection.bringToBack();
        target.bringToFront();
        connection.setTargetAnchor(AnchorFactory.createRectangularAnchor(target));
    
protected org.netbeans.api.visual.widget.WidgetattachEdgeWidget(java.lang.String edge)

        ConnectionWidget connectionWidget = new ConnectionWidget(this);
        connectionLayer.addChild(connectionWidget);
        return connectionWidget;
    
protected org.netbeans.api.visual.widget.WidgetattachNodeWidget(ViewNode node)

        Widget widget = createBox(node, node.name, node.id);
        widget.getActions().addAction(createSelectAction());
        widget.getActions().addAction(moveAction);
        widgetLayer.addChild(widget);
        return widget;
    
private org.netbeans.api.visual.widget.WidgetcreateBox(ViewNode node, java.lang.String nodeName, java.lang.String id)

        final String shortName = getShortName(nodeName);
        node.setShortName(shortName);

        GradientWidget box = new GradientWidget(this, node);
        box.setLayout(LayoutFactory.createVerticalFlowLayout());
        box.setBorder(BorderFactory.createLineBorder(2, Color.BLACK));
        box.setOpaque(true);

        LabelWidget label = new LabelWidget(this);
        label.setFont(getDefaultFont().deriveFont(Font.PLAIN, 12.0f));
        label.setLabel(shortName);
        label.setBorder(BorderFactory.createEmptyBorder(6, 6, 0, 6));
        label.setAlignment(LabelWidget.Alignment.CENTER);

        box.addChild(label);
        
        label = new LabelWidget(this);
        label.setFont(getDefaultFont().deriveFont(Font.PLAIN, 10.0f));
        label.setLabel(getAddress(nodeName));
        label.setBorder(BorderFactory.createEmptyBorder(3, 6, 0, 6));
        label.setAlignment(LabelWidget.Alignment.CENTER);

        box.addressWidget = label;
        
        box.addChild(label);
        
        label = new LabelWidget(this);
        label.setFont(getDefaultFont().deriveFont(Font.PLAIN, 10.0f));
        label.setLabel(id);
        label.setBorder(BorderFactory.createEmptyBorder(3, 6, 6, 6));
        label.setAlignment(LabelWidget.Alignment.CENTER);
        
        box.addChild(label);

        return box;
    
private static java.lang.StringgetAddress(java.lang.String name)

        String[] nameAndHashcode = name.split("@");
        return "@" + nameAndHashcode[1];
    
public ViewNodegetRoot()

        return root;
    
private static java.lang.StringgetShortName(java.lang.String name)

        String[] nameAndHashcode = name.split("@");
        String[] packages = nameAndHashcode[0].split("\\.");
        return packages[packages.length - 1];
    
voidsetRoot(ViewNode root)

        this.root = root;