Rectangle package with title compartment

0 votes
asked Feb 24, 2014 in To be sorted by fred (540 points)
Hello,
 
Is it possible to draw a rectangle package with a separate compartment for the title?
The following code:
 
package foo2 <<Rect>> {
  class Class2
}
 
does not produce a separate compartment for the title.
 
I also tried:
 
package "<u>_____foo2_____</u>" <<Rect>> {
  class Class2
}
 
but the result is not completely satisfying, and the code not very elegant (notably too dependant on  the width of package contents).
 
Also, it does not seem possible to use Creole for this purpose:
 
package "foo2\n----" <<Rect>> {
  class Class2
}
 
 
Thanks,
 
Fred

 

1 Answer

0 votes
answered Feb 24, 2014 by plantuml (295,000 points)
selected Feb 25, 2014 by fred
 
Best answer

Good idea, thanks for the suggestion.

In the following beta :  https://dl.dropboxusercontent.com/u/13064071/ca/plantuml.jar

You can have:

@startuml
package foo1 <<Card>> {
  class Class1
 }
@enduml

If someone find a better syntax keyword than "Card", please post.

About Creole, we will on day publish a version that allows Creole everywhere. But we are doing regression test right now, because this new parser (the Creole one) could create unexpected changes.

Anyway, we will publish a beta version when this will be ready for users' testing.

Thanks,

commented Feb 25, 2014 by rmric (2,140 points)
If I'm not mistaken, it looks the image is not a "card", but a regular "package".

About the syntax keyword, what about the simpler syntax shown below, freeing up the stereotype specifier for user-defined usage (c.f. http://plantuml.sourceforge.net/qa/?qa=1600/stylesheets-in-plantuml-for-class-diagrams) ?

@startuml
card foo1 {
  class Class1
 }
@enduml

Another solution could be a (stereotypable) skinparam "rectangleSeparatedTitle true" activating the card style for the "rectangle" keyword.

Regards
commented Feb 25, 2014 by fred (540 points)
Hello,

The foo1 package also renders as a normal package in my browser. However, I am almost sure it rendered as a card yesterday.

Anyway, when using the appropriate beta version (see dropbox link), the card is properly rendered.

About the syntax: the stereotype-based syntax is aligned with existing syntax http://plantuml.sourceforge.net/classes.html#PStyle .
Moreover, UML allows multiple stereotypes per elements. Therefore, if PlantUML supported it as well, using <<card>> (or <<rect>>) would not prevent user-defined usage, such as:

@startuml
package foo1 <<card, userDefinedStereotype>> {
  class Class1
 }
@enduml

That being said, I agree that being able to specify shape independently of stereotype would also be useful.


Regards,

Fred
commented Sep 27, 2019 by valexiev (1,200 points)

The simpler syntax now works. The syntax with two stereotypes doesn't work for me; furthermore showing the stereotype names on the diagram is not always desired

...