Hi,

I was wondering if it was possible to change some drag gesture in jgraph. I work in java, in a project like the GraphEditor example.

I'd like to :

  • disable the automatic creation of a vertex when you drag the mouse from a connectable vertex to a empty spot of the graph (it clones the vertex and the end of the connection)

  • enable drop a vertex inside an other vertex, like the grouping method, but with mouse. Currently, it is not possible to add a child vertex to a parent vertex, if this vertex has no children.

I'm going into the source code maybe mxGraphHandler and mxGraphTransferHandler are the solution. But if you have some clues, I thank you.

/Q

asked 24 Apr '12, 08:29

qiou's gravatar image

qiou
12
accept rate: 0%


Auto answer for the drop inside a vertex with no children :

override mxGraph.isValidDropTarget like :

public boolean isValidDropTarget(Object cell, Object[] cells) {
    if(((mxCell)cell).getValue() instanceof YOURDROPPABLEVERTEX){
        return true;
    }
    else { 
        return super.isValidDropTarget(cell, cells);
    }
}

that let's the first question

link

answered 24 Apr '12, 08:32

qiou's gravatar image

qiou
12
accept rate: 0%

graphComponent.getConnectionHandler().setCreateTarget(false) - should be default.

(25 Apr '12, 03:02) Gaudenz

Thx a lot, problem solved.

(25 Apr '12, 03:33) qiou
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
×45
×37

Asked: 24 Apr '12, 08:29

Seen: 1,816 times

Last updated: 25 Apr '12, 03:33