Hi all,

I'm trying to add just a circle in the center of each edges by using additional overlays (which essentially are JPanel). The problem is that I can't get the center of the edge, in fact every time I do

cell.getGeometry().getCenterX(); cell.getGeometry().getCenterY();

the returned point is always 0,0.

Does anyone have a suggestion?

Thank you in advance,

Giulio

asked 01 May '12, 11:34

giulo's gravatar image

giulo
112
accept rate: 0%


I solved this problem by giving the proper bounds to the overlay.

    @Override
public mxRectangle getBounds(mxCellState state) {
    this.scale = state.getView().getScale();

    x = (int) (state.getCenterX() - ((int) (radius/2)*scale));
    y = (int) (state.getCenterY() - ((int) (20/2)*scale));
    scaledRadius = radius*scale;

    //state is the size of the overlay
    return new mxRectangle(x, y, scaledRadius, scaledRadius);
}
link

answered 01 May '12, 20:07

giulo's gravatar image

giulo
112
accept rate: 0%

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:

×100
×10
×9

Asked: 01 May '12, 11:34

Seen: 1,376 times

Last updated: 01 May '12, 20:07