Use TikZ styles

+1 vote
asked Oct 10, 2017 in Closed feature request by Dresaan (400 points)
I would like to propose to use style definitions instead of styling attributes on every object in TikZ.

This would make the exported LaTex files a lot more clean and readable.

To do so, you need to define a style in the params of the tikzpicture like this:

\begin{tikzpicture}[yscale=-1,

plantClass/.style={This is where the style attributes come to },

plantPackage/.style={ This is where the style attributes come to },

plantLabel/.style={ This is where the style attributes come to}]

 

The style attributes are the same as the now at the objects directly used.

The object just get the style name as attribute like the following:

\draw[plantPackage] (30pt,32pt) rectangle (481pt,341pt);

1 Answer

0 votes
answered Oct 10, 2017 by plantuml (294,960 points)
selected Oct 12, 2017 by Dresaan
 
Best answer

This sounds like a good idea but this is difficult to implement right now.
'Drawing' in PNG/SVG/EPS/TikZ is done by a low-level generic layer that has no idea about style/class/package/label

However, it would be possible to detect duplicated commands like \draw[color=plantucolor0002,line width=1.5pt] and to generated dedicated style for them (but that would have generated names like aid23sdh) and then have:

\begin{tikzpicture}[yscale=-1,
aid23sdh/.style={color=plantucolor0002,line width=1.5pt}
]
\draw[aid23sdh] (30pt,32pt) rectangle (481pt,341pt);


would this fits your needs ?

Note that this needs some work...
 

commented Oct 11, 2017 by Dresaan (400 points)
In my opinion, if you change a generated (and propably regenerated) part of code by hand you should not complain about names.
It would be nice if the names do not became something strong similar names like aid23sdh, aid23sdi, aid23sdj ... but even that would be no problem and a lot more readable than the current version.
commented Oct 11, 2017 by plantuml (294,960 points)
You can try last beta, we use some style feature of LaTeX now :
https://www.dropbox.com/s/koo42q3d9gxw288/plantuml.jar?dl=0

Few tests done, so feedback welcome!

We do not use (yet?) style for \shade command. Should we use them also here ?
commented Oct 11, 2017 by Dresaan (400 points)
I would recomend to use it everywhere.
The parts where you use the styles look good. :-)
commented Oct 11, 2017 by plantuml (294,960 points)
Ok, thanks.
We've made the modification in last beta (beta4)
https://www.dropbox.com/s/koo42q3d9gxw288/plantuml.jar?dl=0
commented Oct 12, 2017 by Dresaan (400 points)
Looks good. Thank you :-)
...