https://github.com/fuhrmanator/PlantUMLPharoGizmo
Pharo support for PlantUML
https://github.com/fuhrmanator/PlantUMLPharoGizmo
pharo plantuml plantuml-generator
Last synced: 6 months ago
JSON representation
Pharo support for PlantUML
- Host: GitHub
- URL: https://github.com/fuhrmanator/PlantUMLPharoGizmo
- Owner: fuhrmanator
- License: mit
- Created: 2019-05-24T15:16:50.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-01-23T21:47:03.000Z (over 3 years ago)
- Last Synced: 2024-05-21T04:31:52.143Z (12 months ago)
- Topics: pharo, plantuml, plantuml-generator
- Language: Smalltalk
- Homepage:
- Size: 295 KB
- Stars: 17
- Watchers: 4
- Forks: 3
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-pharo - PlantUMLPharoGizmo - Pharo support for PlantUML. (Graphics)
README
# PlantUMLPharoGizmo
Pharo support for PlantUML.> Note: The GUI part of this project was initially done in Spec 2, which works best in Pharo 8. However, the baseline will load a GUI that works with Pharo 7.
> Note 2: Many people have requested support for PlantUML **without Moose**, so I made a fork. I only tested it in Pharo 9 (PRs are welcome to make it work in Pharo 8):
> Note 3: Have a look at https://github.com/kasperosterbye/PlantUMLBridge for a simpler version of the support in this tool.
[](https://www.youtube.com/watch?v=fHCcYSa6VhU "Demo of PlantUML Gizmo prototype in Pharo with Spec GUI")
## Loading (requires Moose)
```Smalltalk
Metacello new
repository: 'github://fuhrmanator/PlantUMLPharoGizmo/src';
baseline: 'PUGizmo';
load.
```## Loading (without Moose, requires Pharo 9)
```Smalltalk
Metacello new
repository: 'github://fuhrmanator/PlantUMLPharoGizmo:pharo9/src';
baseline: 'PUGizmo';
load.
```## Example
### Class diagrams using a Moose Java model
One reason to get PlantUML working in Pharo was to use it with Moose, and there is now a Moose browser. **Prerequisite:** A generated MSE file for the sample project [FactoryVariants](https://github.com/fuhrmanator/FactoryVariants) was already loaded in Moose.

Here's the SVG of the diagram shown in the screenshot above, rendered from the PlantUML source that you can copy from the browser and render at PlantUML.com:

#### Programmatic usage
There's a utility method to generate PlantUML source for a Java model (see [this example](https://fuhrmanator.github.io/2019/07/29/AnalyzingJavaWithMoose.html)) in Moose.
```Smalltalk
| classes pUMLSource key serverUrl imageMorph w |
classes := (MooseModel root first allClasses reject:#isStub)
select: [:c | c mooseName beginsWith: 'headfirst::designpatterns::factory::pizzaaf'].
pUMLSource := PUGizmo plantUMLSourceForMooseClasses: classes.key := pUMLSource plantDeflateAndEncode.
serverUrl := 'http://www.plantuml.com/plantuml/png/', key .
imageMorph := (ZnEasy getPng: serverUrl asUrl) asAlphaImageMorph .
imageMorph layout: #scaledAspect.
w := imageMorph openInWindow.
w center; fitInWorld.
```
### Simple class diagram
```smalltalk
plantUMLSource := '@startuml
skinparam style strictuml
skinparam backgroundcolor transparent
skinparam classbackgroundcolor Yellow/LightYellow
class Banana
note right #red: Ceci n''est pas\nune banane.
@enduml'.codePart := plantUMLSource plantDeflateAndEncode.
serverUrl := 'https://www.plantuml.com/plantuml/img/', codePart.
(ZnEasy getPng: serverUrl) asMorph openInWindow."Get the Source back from a URL"
recoveredSource := serverUrl plantUrlStringToPlantSourceString.self assert: recoveredSource equals: plantUMLSource.
```
### Mind map
```smalltalk
plantUMLSource := '@startmindmap
* Debian
** Ubuntu
*** Linux Mint
*** Kubuntu
*** Lubuntu
*** KDE Neon
** LMDE
** SolydXK
** SteamOS
** Raspbian with a very long name
*** Raspmbc => OSMC
*** Raspyfi => Volumio
@endmindmap'.codePart := plantUMLSource plantDeflateAndEncode.
serverUrl := 'https://www.plantuml.com/plantuml/img/', codePart.
(ZnEasy getPng: serverUrl) asMorph openInWindow.
```