Hi Everyone, I have seen similar posts but I could not really fit the answers to my problem.

I want to make a vertex in Java.

I create a cell with this method : cells = createVertex("Hello" + "\n" + "mar ", 700, 20, 100, 75, Color.ORANGE, true );

The method is the following:

public static DefaultGraphCell createVertex(String name, double x,
        double y, double w, double h, Color bg, boolean raised) {

    // Create vertex with the given name
    DefaultGraphCell cell = new DefaultGraphCell(name);

    // Set bounds
    GraphConstants.setBounds(cell.getAttributes(),
            new Rectangle2D.Double(x, y, w, h));

    // Set fill color
    if (bg != null) {
        GraphConstants.setGradientColor(cell.getAttributes(), bg);
        GraphConstants.setOpaque(cell.getAttributes(), true);
    }

    // Set raised border
    if (raised) {
        GraphConstants.setBorder(cell.getAttributes(),
                BorderFactory.createRaisedBevelBorder());
    } else // Set black border
    {
        GraphConstants.setBorderColor(cell.getAttributes(),
                Color.black);
    }
    // Add a Floating Port
    cell.addPort();

    return cell;
}

The problem is that the break line does not happen. Could you please tell me what shall I include in the code so as to make it work?

Regards

asked 07 Aug '12, 08:49

Marios%20Michaelidis's gravatar image

Marios Michaelidis
11
accept rate: 0%

edited 14 Sep '12, 06:45

David's gravatar image

David
4.9k21831


link

answered 08 Aug '12, 00:08

Lofi's gravatar image

Lofi
1.0k1221
accept rate: 37%

Hi Lofi, this link is not for The standard Jgraph but for the mxgraph one.I actually use the following:

GraphModel model = new DefaultGraphModel(); JGraph graph = new JGraph(model);

Therefore, I cannot use : graph.setHtmlLabels( true);

and

graph.setAutoSizeCells( true); as these are for mxgraph.

Any other suggestion or , do you know how can I embed HTML to my current graph the way it is?

Regards

(08 Aug '12, 09:35) Marios Michaelidis

Lofi's answer is correct for both mxGraph (JavaScript) and the current JGraph version (JGraphX or JGraph 6). You are using a version of JGraph many years out of date, you're unlikely to find anyone with knowledge about it any longer.

(08 Aug '12, 16:26) David

Please convert this to a question or I will delete it.

(25 Sep '12, 15:05) David
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:

×79
×66
×5

Asked: 07 Aug '12, 08:49

Seen: 1,900 times

Last updated: 26 Sep '12, 03:17