ebpa
ebpa

Reputation: 1259

Scaling part of a PlantUML diagram

Scaling is controlled by the scale keyword. I'm curious if it's possible to scale part of a PlantUML diagram somehow or at the very least: scale the font size for part of a diagram.

It doesn't seem like scale may be scoped to part of a diagram (and I have not found any examples that suggest that is possible). Conceivably it might be used in the following manner, but this example scales the entire image:

@startuml

package "Some Group" {
  scale 0.5
  HTTP - [First Component]
  [Another Component]
}

node "Other Groups" {
  FTP - [Second Component]
  [First Component] --> FTP
} 

@enduml

Upvotes: 3

Views: 5818

Answers (1)

aristotll
aristotll

Reputation: 9175

I do not think currently there is a way to achieve it. From the source code of the PlantUML scale command:

protected CommandExecutionResult executeArg(AbstractPSystem diagram, LineLocation location, RegexResult arg) {
    double scale = Double.parseDouble(arg.get("SCALE", 0));
    if (scale == 0) {
        return CommandExecutionResult.error("Scale cannot be zero");
    }
    if (arg.get("DIV", 0) != null) {
        final double div = Double.parseDouble(arg.get("DIV", 0));
        if (div == 0) {
            return CommandExecutionResult.error("Scale cannot be zero");
        }
        scale /= div;
    }
    diagram.setScale(new ScaleSimple(scale));
    return CommandExecutionResult.ok();
}

The location of scale is not used, and PlantUML just sets the scale of diagram by diagram.setScale(new ScaleSimple(scale)).

You can verify this kind of action by:

@startuml
    
package "Some Group" {
  scale 0.5
  HTTP - [First Component]
  [Another Component]
}

node "Other Groups" {
  scale 5
  FTP - [Second Component]
  [First Component] --> FTP
}

@enduml

The scale 0.5 is overridden by the scale 5 command.

Upvotes: 3

Related Questions