Is the set of style string texts (and accepted values) documented somewhere? I see examples in the manual but not a definitive list.



asked 09 Apr '12, 06:50

dazed's gravatar image

accept rate: 0% has the list of Style properties that are definitely recognized by jgraphx and the doc for that (in com.mxgraph.util) has the details well laid out. Look for the ones starting with STYLE_ to see what you can set and the other constants (ALIGN_TOP, FONT_BOLD, etc.) for possible values. Then put that in your stylesheet with a name so you can set your cell style to it like setting a css class:

\nmxStylesheet stylesheet = graph.getStylesheet();\nHashMap<string, object=""> nodeStyle = new HashMap<string, object="">();\nnodeStyle.put(mxConstants.STYLE_FONTCOLOR, "#000000");\nnodeStyle.put(mxConstants.STYLE_FONTFAMILY, "tahoma");\nnodeStyle.put(mxConstants.STYLE_SPACING_LEFT, 3);\nnodeStyle.put(mxConstants.STYLE_SPACING_RIGHT, 3);\nnodeStyle.put(mxConstants.STYLE_SPACING_TOP, 3);\nnodeStyle.put(mxConstants.STYLE_SPACING_BOTTOM, 0);\nstylesheet.putCellStyle("NODE",nodeStyle);\n\nHashMap<string, object=""> groupStyle = new HashMap<string, object="">();\ngroupStyle.put(mxConstants.STYLE_VERTICAL_ALIGN, mxConstants.ALIGN_TOP);\ngroupStyle.put(mxConstants.STYLE_ALIGN, mxConstants.ALIGN_RIGHT);\ngroupStyle.put(mxConstants.STYLE_FONTSTYLE, mxConstants.FONT_BOLD);\nstylesheet.putCellStyle("GROUP",groupStyle);\n\nmxCell cell myCell;\nmyCell.setStyle("NODE;GROUP");\n

see also:


answered 09 Apr '12, 08:20

Kurt's gravatar image

accept rate: 100%

Thanks - that's a better way of controlling the styles (Having looked back at the manual following your response, I see this referenced under "New Global Style").


I was expanding on one of the examples - and using "graph.insertEdge()" and "graph.insertVertex()", but these focus in on the string approach.


Just as thoughts (for library authors), I might reflect that: \na) the string approach and the mxStylesheet approach don't feel fully joined - getting a usable style string out of the stylesheet or being able to insertVertex with an mxStyleSheet might be a little better.\nb) while I can go to the source for the allowable values for an style item, it might be good to get these shown in the javadoc for msStyleSheet and/or mxConstant.


Anyway you've put me on the right track now - thanks again

(09 Apr '12, 11:23) dazed
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]( "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: 09 Apr '12, 06:50

Seen: 3,185 times

Last updated: 09 Apr '12, 11:23