4

I want to rotate a cell in jgraphx. For this purpose, I used the style of cell as follows:

mxCell v2 =(mxCell) graph.insertVertex(parent, null, "World!", 240, 150, 80, 30,"rotation=90");

This causes the cell to rotate. However, the green box around this cell does not rotate along with the cell:

enter image description here

This causes problems when a port is added to the cell since the coordinates are related to this green box. How can I rotate this green box along with the cell? Here is the whole code, which is the Hello World example I got from jgraphx Github.

package com.mxgraph.examples.swing;

import javax.swing.JFrame;

import com.mxgraph.swing.mxGraphComponent;

import com.mxgraph.view.mxGraph;

public class HelloWorld extends JFrame
{

/**
 * 
 */
private static final long serialVersionUID = -2707712944901661771L;

public HelloWorld()
{
    super("Hello, World!");

    mxGraph graph = new mxGraph();
    Object parent = graph.getDefaultParent();

    graph.getModel().beginUpdate();
    try
    {
        mxCell v1 = (mxCell) graph.insertVertex(parent, null, "Hello", 20, 20, 80, 30);
        mxCell v2 =(mxCell) graph.insertVertex(parent, null, "World!", 240, 150, 80, 30,"rotation=90");
        graph.insertEdge(parent, null, "Edge", v1, v2);
    }
    finally
    {
        graph.getModel().endUpdate();
    }

    mxGraphComponent graphComponent = new mxGraphComponent(graph);
    getContentPane().add(graphComponent);
}

public static void main(String[] args)
{
    HelloWorld frame = new HelloWorld();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(400, 320);
    frame.setVisible(true);
}

}

0 Answers0