2
1

I don't want to keep track of all vertices in order to delete them. Is there a suitable method for deleting all vertices?

Found "mxGraphModel.clear()" but am not sure after reading the javadoc about what it does:

/**
 * Sets a new root using createRoot.
 */
public void clear()
{
    setRoot(createRoot());
}

E g, will it clear other things but the vertices (and edges)?

Another approach perhaps then is "mxGraph.removeCells(mxGraphModel.getCells().values().toArray(new Object[]))", that I understand better but is a bit long...

asked 02 Mar '11, 03:27

markuswahl's gravatar image

markuswahl
1851513
accept rate: 28%

edited 06 May '13, 17:23

David's gravatar image

David
4.9k21831


Try graph.removeCells(graph.getChildVertices(graph.getDefaultParent()))

link

answered 02 Mar '11, 20:39

Gaudenz's gravatar image

Gaudenz
80.1k1310
accept rate: 39%

edited 02 Mar '11, 20:41

Try graph.removeCells(graph.getChildVertices(graph.getDefaultParent()))

This works great for cells and I assume that if I remove all cells from a graph that also all edges are gone associated with a cell. If the graph is referenced by a graphComponent then it will also remove alle cells from the swing component. But if there are single edges left, which weren't linked to a cell, than they will stay. How can I get rid of these?

So, is there a function to clean the graph component?

link

answered 21 Jul '11, 09:16

thatstraight's gravatar image

thatstraight
156
accept rate: 0%

edited 06 May '13, 17:23

David's gravatar image

David
4.9k21831

1

Try graph.removeCells(graph.getChildCells(graph.getDefaultParent(), true, true))

(22 Jul '11, 02:46) Gaudenz
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×194
×6
×3

Asked: 02 Mar '11, 03:27

Seen: 14,077 times

Last updated: 06 May '13, 17:23