org.netbeans.api.visual.vmd.VMDNodeWidget Java Examples

The following examples show how to use org.netbeans.api.visual.vmd.VMDNodeWidget. 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: PageFlowView.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a PageFlowScene node from a pageNode.  The PageNode will generally be some type of DataObject unless
 * there is no true file to represent it.  In that case a abstractNode should be passed
 * @param pageNode the node that represents a dataobject or empty object
 * @param type
 * @param glyphs
 * @return
 */
protected VMDNodeWidget createNode(final Page pageNode, String type, List<Image> glyphs) {
    String pageName = pageNode.getDisplayName();


    final VMDNodeWidget widget = (VMDNodeWidget) getScene().addNode(pageNode);
    //        widget.setNodeProperties(null /*IMAGE_LIST*/, pageName, type, glyphs);
    widget.setNodeProperties(pageNode.getIcon(java.beans.BeanInfo.ICON_COLOR_16x16), pageName, type, glyphs);
    PageFlowSceneData.PageData data = sceneData.getPageData(pageName);
    if (data != null) {
        widget.setPreferredLocation(data.getPoint());
        widget.setMinimized(data.isMinimized());
    }
    getScene().addPin(pageNode, new Pin(pageNode));

    /* Now we want to runPinSetup on demand */
    //runPinSetup(pageNode, widget);
    selectPageFlowSceneElement(pageNode);
    return widget;
}
 
Example #2
Source File: TgdVisitor.java    From Llunatic with GNU General Public License v3.0 6 votes vote down vote up
private void addComparisonAtom(ComparisonAtom atom) {
    logger.debug("COMPARISON ATOM: " + atom.toString());
    String atomId = atom.toString();
    GraphNode graphNode = new GraphNode(atomId);
    graphNode.setValue(TgdDepSceneGenerator.ATOM, atom);
    VMDNodeWidget nodeWidget = scene.createNode(graphNode, false);
    comparisonAtomsNodes.add(graphNode);
    result.add(graphNode);
    setNodeBorder(nodeWidget);
    for (int i = 0; i < atom.getVariables().size(); i++) {
        FormulaVariable var = atom.getVariables().get(i);
        logger.debug("FORMULA VAR PIN: " + var.toString());
        PinNode pinNode = new PinNode(graphNode, var.getId());
        pinNode.setValue(TgdDepSceneGenerator.VARIABLE_VALUE, var.getId());
        scene.createHiddenPin(pinNode);
    }
}
 
Example #3
Source File: TgdVisitor.java    From Llunatic with GNU General Public License v3.0 6 votes vote down vote up
private void addRelationalAtom(RelationalAtom atom) {
    logger.debug("RELATIONAL ATOM: " + atom.toString());
    String atomId = atom.getTableNameWithAlias();
    GraphNode graphNode = new GraphNode(atomId, atom.getTableNameWithAlias());
    graphNode.setValue(TgdDepSceneGenerator.ATOM, atom);
    VMDNodeWidget nodeWidget = scene.createNode(graphNode, false);
    relationalAtomsNodes.add(graphNode);
    result.add(graphNode);
    configureNodeView(graphNode);
    setNodeBorder(nodeWidget);
    for (FormulaAttribute formulaAttribute : atom.getAttributes()) {
        logger.debug("FORMULA ATTRIBUTE PIN: " + formulaAttribute.toString());
        PinNode pinNode = new PinNode(graphNode, formulaAttribute.getAttributeName(), formulaAttribute.toString());
        pinNode.setValue(TgdDepSceneGenerator.VARIABLE_VALUE, formulaAttribute.getValue().toString());
        scene.createPin(pinNode);
    }
}
 
Example #4
Source File: TgdVisitor.java    From Llunatic with GNU General Public License v3.0 6 votes vote down vote up
private void addBuiltinAtom(BuiltInAtom atom) {
    logger.debug("BUILTIN ATOM: " + atom.toString());
    String atomId = atom.toString();
    GraphNode graphNode = new GraphNode(atomId);
    graphNode.setValue(TgdDepSceneGenerator.ATOM, atom);
    VMDNodeWidget nodeWidget = scene.createNode(graphNode, false);
    builtinAtomsNodes.add(graphNode);
    result.add(graphNode);
    setNodeBorder(nodeWidget);
    for (int i = 0; i < atom.getVariables().size(); i++) {
        FormulaVariable var = atom.getVariables().get(i);
        logger.debug("FORMULA VAR PIN: " + var.toString());
        PinNode pinNode = new PinNode(graphNode, var.getId());
        pinNode.setValue(TgdDepSceneGenerator.VARIABLE_VALUE, var.getId());
        scene.createHiddenPin(pinNode);
    }
}
 
Example #5
Source File: VmdEgdSceneGenerator.java    From Llunatic with GNU General Public License v3.0 6 votes vote down vote up
private List<VMDNodeWidget> createPremiseNodes(VMDGraphScene scene) {
    List<VMDNodeWidget> result = new ArrayList<VMDNodeWidget>();
    for (String commonValue : commonValues.keySet()) {
        Collection<String> cells = commonValues.get(commonValue);
        if (cells.size() > 1) {
            VMDNodeWidget node = (VMDNodeWidget) scene.addNode(commonValue);
            node.setNodeName(commonValue);
            node.setBorder(premiseBorder);
            createNodePin(scene, node);
            result.add(node);
            for (String cell : cells) {
                VMDPinWidget pin = (VMDPinWidget) scene.addPin(commonValue, cell + ":" + commonValue);
                pin.setPinName(cell);
            }
        }
    }
    return result;
}
 
Example #6
Source File: VmdEgdSceneGenerator.java    From Llunatic with GNU General Public License v3.0 6 votes vote down vote up
@Override
    public void populateScene(VMDGraphScene scene) {
        premiseVisitor.visitDependency(dependency);
        conclusionVisitor.visitDependency(dependency);
        ComparisonAtom conclusion = (ComparisonAtom) conclusionVisitor.getResult();
        List<VMDNodeWidget> premiseNodes = createPremiseNodes(scene);
        VMDNodeWidget conclusionNode = createConclusionNode(scene, conclusion);
//        int i = 0;
//        for (VMDNodeWidget premiseNode : premiseNodes) {
//            String edge = "node"+i;
//            scene.addEdge(edge);
//            scene.setEdgeSource(edge, premiseNode.getNodeName() + VMDGraphScene.PIN_ID_DEFAULT_SUFFIX);
//            scene.setEdgeTarget(edge, conclusionNode.getNodeName() + VMDGraphScene.PIN_ID_DEFAULT_SUFFIX);
//            i++;
//        }
    }
 
Example #7
Source File: PageFlowScene.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void setText(Widget widget, String text) {

            Page pageNode = (Page) findObject(nodeWidget);
            if (pageNode.canRename() && !text.equals(pageNode.getName())) {

                //Explicitly declared oldName and newName for ease of reading.
                String oldName = pageNode.getDisplayName();
                String newName;

                pageNode.setName(text);
                newName = pageNode.getDisplayName();

                //                if( oldName != newName ) {
                //                    renamePin(pageNode, oldName + "pin", newName + "pin");
                //                }
                if (widget instanceof LabelWidget) {
                    ((LabelWidget) widget).setLabel(newName);
                } else if (widget instanceof VMDNodeWidget) {
                    ((VMDNodeWidget) widget).getNodeNameWidget().setLabel(newName);
                }
                validate();
            }
        }
 
Example #8
Source File: EgdSceneGenerator.java    From Llunatic with GNU General Public License v3.0 6 votes vote down vote up
private List<GraphNode> createPremiseNodes(IVmdScene scene) {
    List<GraphNode> result = new ArrayList<GraphNode>();
    for (String commonValue : commonValues.keySet()) {
        Collection<String> cells = commonValues.get(commonValue);
        if (cells.size() > 1) {
            GraphNode graphNode = new GraphNode(commonValue);
            VMDNodeWidget node = scene.createNode(graphNode, true);
            node.setBorder(premiseBorder);
            result.add(graphNode);
            for (String cell : cells) {
                scene.createPin(new PinNode(graphNode, cell + ":" + commonValue));
            }
        }
    }
    return result;
}
 
Example #9
Source File: GraphColorScheme.java    From Llunatic with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void installUI(VMDNodeWidget widget) {
    widget.setBorder(VMDFactory.createVMDNodeBorder());
    widget.setOpaque(false);
    
    Widget header = widget.getHeader();
    header.setBorder(HEADER_BORDER_PIN);
    header.setBackground(COLOR_SELECTED);
    header.setOpaque(false);
    
    Widget minimize = widget.getMinimizeButton();
    minimize.setBorder(BORDER_MINIMIZE);
    
    Widget pinsSeparator = widget.getPinsSeparator();
    pinsSeparator.setForeground(BORDER_CATEGORY_BACKGROUND);
}
 
Example #10
Source File: PageFlowSceneData.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Map<String, PageData> createSceneInfo(PageFlowScene scene) {
    Map<String, PageData> sceneInfo = new HashMap<String, PageData>();
    Collection<Page> pages = scene.getNodes();
    for (Page page : pages) {
        VMDNodeWidget pageWidget = (VMDNodeWidget) scene.findWidget(page);
        Point p;
        if (scene.isValidated()) {
            p = pageWidget.getLocation();
        } else {
            p = pageWidget.getPreferredLocation();
        }
        if ( p != null ) {
            sceneInfo.put(page.getDisplayName(), createPageData(p, pageWidget.isMinimized()));
        }
    }
    return sceneInfo;
}
 
Example #11
Source File: GraphColorScheme.java    From Llunatic with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void updateUI(VMDNodeWidget widget, ObjectState previousState, ObjectState state) {
    if (!previousState.isSelected() && state.isSelected()) {
        widget.bringToFront();
    } else if (!previousState.isHovered() && state.isHovered()) {
        widget.bringToFront();
    }
    Widget header = widget.getHeader();
    header.setOpaque(state.isSelected());
    if (state.isFocused() || state.isHovered()) {
        header.setBorder(BORDER_PIN_HOVERED);
    } else {
        header.setBorder(HEADER_BORDER_PIN);
    }
    
}
 
Example #12
Source File: LunaticDepScene.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public VMDNodeWidget createNode(GraphNode graphNode, boolean createDefaultPin) {
    VMDNodeWidget widget = (VMDNodeWidget) addNode(graphNode);
    widget.setNodeName(graphNode.getDisplayName());
    if (createDefaultPin) {
        PinNode defaultPin = new PinNode(graphNode, PIN_ID_DEFAULT_SUFFIX);
        defaultPin.setHidden(true);
        graphNode.setDefautlPin(defaultPin);
        addPin(graphNode, graphNode.getDefaultPin());
    }
    return widget;
}
 
Example #13
Source File: LunaticDepScene.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
private Anchor getPinAnchor(PinNode pin) {
    if (pin == null) {
        return null;
    }
    VMDNodeWidget nodeWidget = (VMDNodeWidget) findWidget(super.getPinNode(pin));
    Widget pinMainWidget = findWidget(pin);
    Anchor anchor;
    if (pinMainWidget != null) {
        anchor = new BestPathAnchor(pinMainWidget);
        anchor = nodeWidget.createAnchorPin(anchor);
    } else {
        anchor = nodeWidget.getNodeAnchor();
    }
    return anchor;
}
 
Example #14
Source File: LunaticDepScene.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Implements attaching a widget to a pin. The widget is VMDPinWidget and
 * has object-hover and select action.
 *
 * @param node the node
 * @param pin the pin
 * @return the widget attached to the pin, null, if it is a default pin
 */
@Override
protected Widget attachPinWidget(GraphNode node, PinNode pin) {
    if (pin.isHidden()) {
        return null;
    }
    VMDPinWidget widget = new VMDPinWidget(this, scheme);
    ((VMDNodeWidget) findWidget(node)).attachPinWidget(widget);
    widget.getActions().addAction(createObjectHoverAction());
    widget.getActions().addAction(createSelectAction());
    return widget;
}
 
Example #15
Source File: LunaticDepScene.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Implements attaching a widget to a node. The widget is VMDNodeWidget and
 * has object-hover, select, popup-menu and move actions.
 *
 * @param node the node
 * @return the widget attached to the node
 */
@Override
protected Widget attachNodeWidget(GraphNode node) {
    VMDNodeWidget widget = new VMDNodeWidget(this, scheme);
    mainLayer.addChild(widget);
    widget.getHeader().getActions().addAction(createObjectHoverAction());
    widget.getActions().addAction(createSelectAction());
    widget.getActions().addAction(moveAction);
    return widget;
}
 
Example #16
Source File: TgdVisitor.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
private void setNodeBorder(VMDNodeWidget nodeWidget) {
    if (premise) {
        nodeWidget.setBorder(premiseBorder);
    } else {
        nodeWidget.setBorder(conclusionBorder);
    }
}
 
Example #17
Source File: GraphColorScheme.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
static Widget createPinCategoryWidgetCore(VMDNodeWidget widget, String categoryDisplayName, boolean changeFont) {
    Scene scene = widget.getScene();
    LabelWidget label = new LabelWidget(scene, categoryDisplayName);
    label.setOpaque(true);
    label.setBackground(BORDER_CATEGORY_BACKGROUND);
    label.setForeground(Color.GRAY);
    if (changeFont) {
        Font fontPinCategory = scene.getDefaultFont().deriveFont(10.0f);
        label.setFont(fontPinCategory);
    }
    label.setAlignment(LabelWidget.Alignment.CENTER);
    label.setCheckClipping(true);
    return label;
}
 
Example #18
Source File: VmdTgdDepSceneGenerator.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
private void addAtom(RelationalAtom atom) {
    logger.debug("FORMULA ATOM: " + atom.toString());
    String atomId = atom.getTableNameWithAlias();
    VMDNodeWidget n1 = (VMDNodeWidget) scene.addNode(atomId);
    n1.setNodeName(atom.getTableNameWithAlias());
    nodes.add(n1);
    for (FormulaAttribute formulaVariable : atom.getAttributes()) {
        logger.debug("FORMULA ATTRIBUTE PIN: " + formulaVariable.toString());
        VMDPinWidget pin = (VMDPinWidget) scene.addPin(atomId, formulaVariable.hashCode() + "");
        pin.setPinName(formulaVariable.toString());
    }
}
 
Example #19
Source File: DB_VMDGraph.java    From BART with MIT License 5 votes vote down vote up
private void createTable(ITable table)   {
    VMDNodeWidget tableWidget = (VMDNodeWidget)scene.addNode(table.getName());
    tableWidget.setNodeProperties(ImageUtilities.loadImage(R.IMAGE_NODE_DBMS), 
                                  table.getName(), 
                                  "TABLE", null);
    tableWidget.setToolTipText("Double click for View Table data");
    tableWidget.getActions().addAction(ActionFactory.createEditAction(
                                    new TableEditProvider(topCompName, table)));
    for(Attribute attribute : table.getAttributes())   {
        if(attribute.getName().equalsIgnoreCase("oid"))continue;
        createAttribute(table.getName(),attribute);
    }
}
 
Example #20
Source File: QBGraphScene.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected Widget attachNodeWidget(Object node) {
    
    VMDNodeWidget widget = new VMDNodeWidget(this);
    // Widget widget = new Widget(this);
    
    widget.setLayout(LayoutFactory.createVerticalFlowLayout());
    widget.setBorder(VMDFactory.createVMDNodeBorder());
    widget.getActions().addAction(moveAction);
    
    ComponentWidget componentWidget = null;
    // LabelWidget label = null;
    
    if (node instanceof QBNodeComponent) // we have a qbNodeComponent
    {
        // label = new LabelWidget(this, ((QBNodeComponent)node).getNodeName());
        widget.setNodeName(((QBNodeComponent)node).getNodeName());
        widget.setNodeType("Table");
        componentWidget = new ComponentWidget(this, (QBNodeComponent)node);
        componentWidget.setBorder(VMDFactory.createVMDNodeBorder());
    }
    
    // 	label.setOpaque(true);
    // 	label.setBackground(Color.LIGHT_GRAY);
    // 	widget.addChild(label);
    
    widget.addChild(componentWidget);
    
    mainLayer.addChild(widget);
    return widget;
}
 
Example #21
Source File: PageFlowScene.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Anchor getPinAnchor(Pin pin) {
    if (pin == null) {
        return null;
    }
    VMDNodeWidget nodeWidget = (VMDNodeWidget) findWidget(getPinNode(pin));
    Widget pinMainWidget = findWidget(pin);
    Anchor anchor;
    if (pinMainWidget != null) {
        anchor = AnchorFactory.createDirectionalAnchor(pinMainWidget, AnchorFactory.DirectionalAnchorKind.HORIZONTAL, 8);
        anchor = nodeWidget.createAnchorPin(anchor);
    } else {
        anchor = nodeWidget.getNodeAnchor();
    }
    return anchor;
}
 
Example #22
Source File: PageFlowSceneData.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void loadSceneData(PageFlowScene scene, Map<String, PageData> sceneInfo) {
    if (sceneInfo == null) {
        return;
    }
    Collection<Page> pages = scene.getNodes();
    for (Page page : pages) {
        PageData data = sceneInfo.get(page.getDisplayName());
        if (data != null) {
            VMDNodeWidget pageWidget = (VMDNodeWidget) scene.findWidget(page);
            pageWidget.setPreferredLocation(data.getPoint());
            pageWidget.setMinimized(data.isMinimized());
        }
    }
}
 
Example #23
Source File: PageFlowView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public synchronized void resetNodeWidget(Page pageNode, boolean contentItemsChanged) {

        if (pageNode == null) {
            throw new RuntimeException("PageFlowEditor: Cannot set node to null");
        }

        //Reset the Node Name
        VMDNodeWidget nodeWidget = (VMDNodeWidget) getScene().findWidget(pageNode);

        //Do this because sometimes the node display name is the object display name.
        pageNode.updateNode_HACK();
        //        nodeWidget.setNodeName(node.getDisplayName());
        if (nodeWidget != null) {
            nodeWidget.setNodeProperties(pageNode.getIcon(java.beans.BeanInfo.ICON_COLOR_16x16), pageNode.getDisplayName(), null, null);
            if (contentItemsChanged) {
                redrawPinsAndEdges(pageNode);
            }
        } else {
            validateGraph();
            System.err.println("PageFlowCreationStack: " + pfc.PageFlowCreationStack);
            System.err.println("PageFlowDestroyStack: " + pfc.PageFlowDestroyStack);
            pfc.PageFlowCreationStack.clear();
            pfc.PageFlowDestroyStack.clear();
            System.err.println("PageNode: " + pageNode);
            //            System.err.println("Node Widget is null in scene for: " + pageNode.getDisplayName());
            System.err.println("Here are the scene nodes: " + getScene().getNodes());
        //            Thread.dumpStack();
        }
    }
 
Example #24
Source File: VmdEgdSceneGenerator.java    From Llunatic with GNU General Public License v3.0 4 votes vote down vote up
private void createNodePin(VMDGraphScene scene, VMDNodeWidget node) {
//        scene.addPin(node.getNodeName(), node.getNodeName() + VMDGraphScene.PIN_ID_DEFAULT_SUFFIX);
    }
 
Example #25
Source File: VmdTgdDepSceneGenerator.java    From Llunatic with GNU General Public License v3.0 4 votes vote down vote up
@Override
public List<VMDNodeWidget> getResult() {
    return nodes;
}
 
Example #26
Source File: PageFlowScene.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public PageNodeTextFieldInplaceEditor(VMDNodeWidget nodeWidget) {
    this.nodeWidget = nodeWidget;
}
 
Example #27
Source File: GraphColorScheme.java    From Llunatic with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean isNodeMinimizeButtonOnRight(VMDNodeWidget widget) {
    return false;
}
 
Example #28
Source File: GraphColorScheme.java    From Llunatic with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Image getMinimizeWidgetImage(VMDNodeWidget widget) {
    return widget.isMinimized()
            ? ImageUtilities.loadImage("org/netbeans/modules/visual/resources/vmd-expand.png") // NOI18N
            : ImageUtilities.loadImage("org/netbeans/modules/visual/resources/vmd-collapse.png"); // NOI18N
}
 
Example #29
Source File: GraphColorScheme.java    From Llunatic with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Widget createPinCategoryWidget(VMDNodeWidget widget, String categoryDisplayName) {
    return createPinCategoryWidgetCore(widget, categoryDisplayName, true);
}
 
Example #30
Source File: IVmdScene.java    From Llunatic with GNU General Public License v3.0 votes vote down vote up
VMDNodeWidget createNode(GraphNode graphNode, boolean createDefaultPin);