private String getLabel(Node n, Column[] cols, GraphView view) { String str = ""; if (cols != null) { int i = 0; for (Column c : cols) { if (i++ > 0) { str += " - "; } Object val = n.getAttribute(c, view); str += val != null ? val : ""; } } if (str.isEmpty()) { str = n.getLabel(); } if (str == null) { str = ""; } return str; }
private void loadSelectedRow(JPanel settingsPanel) { JLabel selectedRowLabel = new JLabel(); selectedRowLabel.setText(getMessage("MergeNodesUI.selectedRowText")); settingsPanel.add(selectedRowLabel, "wrap"); nodesComboBox = new JComboBox(); //Prepare selected node combo box with nodes data: nodes = manipulator.getNodes(); Node selectedNode = manipulator.getSelectedNode(); for (int i = 0; i < nodes.length; i++) { nodesComboBox.addItem(nodes[i].getId() + " - " + nodes[i].getLabel()); if (nodes[i] == selectedNode) { nodesComboBox.setSelectedIndex(i); } } settingsPanel.add(nodesComboBox, "growx, wrap 25px"); }
@Override public void setup(Manipulator m, DialogControls dialogControls) { manipulator = (LinkNodes) m; nodes = manipulator.getNodes(); if(manipulator.isDirected()){ directedEdge.setSelected(true); }else{ undirectedEdge.setSelected(true); } Node sourceNode = manipulator.getSourceNode(); //Prepare combo box with nodes data: for (int i = 0; i < nodes.length; i++) { sourceNodeComboBox.addItem(nodes[i].getId() + " - " + nodes[i].getLabel()); if (nodes[i] == sourceNode) { sourceNodeComboBox.setSelectedIndex(i); } } }
@Override public void select() { //Get current visible graph GraphController graphController = Lookup.getDefault().lookup(GraphController.class); Graph graph = graphController.getGraphModel().getGraphVisible(); //Build the autocomplete data. A simple map from node's label graph.readLock(); data = new HashMap<String, Node>(); for (Node n : graph.getNodes()) { String label = n.getLabel(); String id = n.getId().toString(); if (label != null) { if (!label.isEmpty()) { data.put(label, n); } } else if (id != null && !id.isEmpty()) { data.put(id, n); } } graph.readUnlock(); }
@Override public void mouseClicked(PreviewMouseEvent event, PreviewProperties properties, Workspace workspace) { for (Node node : Lookup.getDefault().lookup(GraphController.class).getGraphModel(workspace).getGraph().getNodes()) { if (clickingInNode(node, event)) { properties.putValue("display-label.node.id", node.getId()); System.err.println("Node " + node.getLabel() + " clicked!");//System.out is ignored in Netbeans platform applications!! JOptionPane.showMessageDialog(null, "Node " + node.getLabel() + " clicked!"); event.setConsumed(true);//So the renderer is executed and the graph repainted return; } } properties.removeSimpleValue("display-label.node.id"); event.setConsumed(true);//So the renderer is executed and the graph repainted }
private void refreshRows() { rows = columnsAndRowChooser.getRows(); Object sourceRow = columnsAndRowChooser.getRow(); Node node; Edge edge; //Prepare combo box with nodes/edges data: for (int i = 0; i < rows.length; i++) { if (rows[i] instanceof Node) { node = (Node) rows[i]; rowComboBox.addItem(node.getId() + " - " + node.getLabel()); } else { edge = (Edge) rows[i]; rowComboBox.addItem(edge.getId() + " - " + edge.getLabel()); } if (rows[i] == sourceRow) { rowComboBox.setSelectedIndex(i); } } }
/** * Single node edition mode will always be enabled with this single node * constructor * * @param node */ public EditNodes(Node node) { super(Children.LEAF); this.nodes = new Node[]{node}; setName(node.getLabel()); multipleNodes = false; GraphController gc = Lookup.getDefault().lookup(GraphController.class); currentTimeFormat = gc.getGraphModel().getTimeFormat(); dateTimeZone = gc.getGraphModel().getTimeZone(); }
/** * If the nodes array has more than one element, multiple nodes edition mode * will be enabled. * * @param nodes */ public EditNodes(Node[] nodes) { super(Children.LEAF); this.nodes = nodes; multipleNodes = nodes.length > 1; if (multipleNodes) { setName(NbBundle.getMessage(EditNodes.class, "EditNodes.multiple.elements")); } else { setName(nodes[0].getLabel()); } GraphController gc = Lookup.getDefault().lookup(GraphController.class); currentTimeFormat = gc.getGraphModel().getTimeFormat(); dateTimeZone = gc.getGraphModel().getTimeZone(); }
@Override public void setup(Manipulator m, DialogControls dialogControls) { this.manipulator = (AddEdgeToGraph) m; if (manipulator.isDirected()) { directedRadioButton.setSelected(true); } else { undirectedRadioButton.setSelected(true); } graph = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getGraph(); nodes = graph.getNodes().toArray(); workspace = Lookup.getDefault().lookup(ProjectController.class).getCurrentWorkspace(); for (Node n : nodes) { sourceNodesComboBox.addItem(n.getId() + " - " + n.getLabel()); targetNodesComboBox.addItem(n.getId() + " - " + n.getLabel()); } SelectedOptions selectedOptions = workspace.getLookup().lookup(SelectedOptions.class); if (selectedOptions != null) { setNodeComboBoxSelection(sourceNodesComboBox, selectedOptions.source); setNodeComboBoxSelection(targetNodesComboBox, selectedOptions.target); edgeTypeComboBox.setSelectedItem(selectedOptions.edgeType); } else { workspace.add(new SelectedOptions()); } refreshAvailableEdgeTypes(); dialogControls.setOkButtonEnabled(nodes.length > 0); }
@Override public Object getValueFor(Edge edge) { if (showEdgesNodesLabels) { return edge.getSource().getId() + " - " + edge.getSource().getLabel(); } else { return edge.getSource().getId(); } } };
@Override public Object getValueFor(Edge edge) { if (showEdgesNodesLabels) { return edge.getTarget().getId() + " - " + edge.getTarget().getLabel(); } else { return edge.getTarget().getId(); } } };
String label = n.getLabel(); statement.executeUpdate("insert into nodes values('" + id + "', '" + label + "')"); if (cancel) {
for (Node n : graph.getNodes()) { TimestampIntegerMap value = (TimestampIntegerMap) n.getAttribute("price"); System.out.println("'" + n.getLabel() + "': " + value.toString()); System.out.println("With AVERAGE estimator: '" + n.getLabel() + "': " + priceFrom2007to2009Avg); System.out.println("With MAX estimator: '" + n.getLabel() + "': " + priceFrom2007to2009Max);
set.setDisplayName(NbBundle.getMessage(EditNodes.class, "EditNodes.attributes.text.multiple")); } else { set.setDisplayName(NbBundle.getMessage(EditNodes.class, "EditNodes.attributes.text", nodes[0].getLabel()));
private void copyNodeProperties(Node node, Node nodeCopy) { nodeCopy.setPosition(node.x(), node.y(), node.z()); nodeCopy.setColor(node.getColor()); nodeCopy.setFixed(node.isFixed()); nodeCopy.setLabel(node.getLabel()); nodeCopy.setSize(node.size()); }
private void copyNodeProperties(Node node, Node nodeCopy) { nodeCopy.setPosition(node.x(), node.y(), node.z()); nodeCopy.setColor(node.getColor()); nodeCopy.setFixed(node.isFixed()); nodeCopy.setLabel(node.getLabel()); nodeCopy.setSize(node.size()); }
System.out.println(n.getLabel() + " has " + neighbors.length + " neighbors");
Sheet.Set set = new Sheet.Set(); set.setName("properties"); set.setDisplayName(NbBundle.getMessage(EditNodes.class, "EditNodes.properties.text", node.getLabel()));
private Node copyNode(Node node, Graph graph) { Node copy = buildNode(graph, node.getLabel()); //Copy properties (position, size and color): copy.setX(node.x()); copy.setY(node.y()); copy.setZ(node.z()); copy.setSize(node.size()); copy.setR(node.r()); copy.setG(node.g()); copy.setB(node.b()); copy.setAlpha(node.alpha()); Table nodeTable = graph.getModel().getNodeTable(); //Copy attributes: for (Column column : nodeTable) { if (!column.isReadOnly()) { copy.setAttribute(column, node.getAttribute(column)); } } graph.addNode(copy); return copy; }