Hi friends,

I'm working with elliptic vertex and, by default, I have: (1) dashed green border on move selection; (2) green border on selection to create a new edge or establishing a target for a edge; (3) and blue squares in the start and end of an edge, when selected.

I just don't want these bounding boxes. Instead off, I want to change the cell styles on these events.

Then, I've found how to implement a mouse tracker that marks cells under the mouse, in the begining of mxCellMarker Class documentation. But I still can't treat the moving selection.

Any help, please?

Thank you!

Here, I put the text and code I've found in mxCellMarker Class documentation.

Implements a mouse tracker that marks cells under the mouse. This class fires the following event: mxEvent.MARK fires in mark and unmark to notify the listener of a new cell under the mouse. The state property contains the mxCellState of the respective cell or null if no cell is under the mouse. To create a cell marker which highlights cells "in-place", the following code can be used:

mxCellMarker highlighter = new mxCellMarker(graphComponent) { protected Map lastStyle; public mxCellState process(MouseEvent e) { mxCellState state = null; if (isEnabled()) { state = getState(e); boolean isValid = (state != null) ? isValidState(state) : false; if (!isValid) { state = null; } highlight(state); } return state; } public void highlight(mxCellState state) { if (validState != state) { Rectangle dirty = null; if (validState != null) { validState.setStyle(lastStyle); dirty = validState.getBoundingBox().getRectangle(); dirty.grow(4, 4); } if (state != null) { lastStyle = state.getStyle(); state.setStyle(new Hashtable(state.getStyle())); state.getStyle().put("strokeColor", "#00ff00"); state.getStyle().put("fontColor", "#00ff00"); state.getStyle().put("strokeWidth", "3"); Rectangle tmp = state.getBoundingBox().getRectangle(); if (dirty != null) { dirty.add(tmp); } else { dirty = tmp; } dirty.grow(4, 4); } validState = state; graphComponent.repaint(dirty); } } public void reset() { highlight(null); } public void paint(Graphics g) { // do nothing } }; graphComponent.getConnectionHandler().setMarker(highlighter);

asked 30 Jun '12, 11:59

emaschio's gravatar image

accept rate: 20%

In the next version we will add mxCellHandler.destroy, so eg. a fill color change for selected vertices can be implemented as follows:

new mxVertexHandler(this, state)
  private Map<String, Object> originalStyle;

   * Refreshes the cell handler.
  public void refresh(mxCellState state)
    if (this.state == null)
      this.state = state;

      originalStyle = new HashMap<String, Object>(
      // Clone before changing in-place
      state.setStyle(new HashMap<String, Object>(
      state.getStyle().put("fillColor", "green");

    bounds = state.getRectangle();

  public void destroy()


answered 01 Jul '12, 08:22

Gaudenz's gravatar image

accept rate: 39%

Thanks, you've really helped me!

And, please, how can I do the same for the edges? But I need that edges allow reconection.


answered 01 Jul '12, 11:12

emaschio's gravatar image

accept rate: 20%

Your answer
toggle preview

Follow this question

By Email:

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



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



Asked: 30 Jun '12, 11:59

Seen: 3,518 times

Last updated: 01 Jul '12, 11:12