mirror of
https://github.com/octoleo/plantuml.git
synced 2025-02-08 23:18:29 +00:00
Merge pull request #499 from matthew16550/smetana-margins
Fix top & left margin problems with CucaDiagrams
This commit is contained in:
commit
b2a4e20792
@ -102,6 +102,7 @@ import net.sourceforge.plantuml.svek.SvekNode;
|
|||||||
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
|
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
|
||||||
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
|
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
|
||||||
import net.sourceforge.plantuml.ugraphic.ImageParameter;
|
import net.sourceforge.plantuml.ugraphic.ImageParameter;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.MinMax;
|
||||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
@ -126,14 +127,18 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||||||
class Drawing extends AbstractTextBlock implements TextBlockBackcolored {
|
class Drawing extends AbstractTextBlock implements TextBlockBackcolored {
|
||||||
|
|
||||||
private final YMirror ymirror;
|
private final YMirror ymirror;
|
||||||
private final Dimension2D dim;
|
private final MinMax minMax;
|
||||||
|
|
||||||
public Drawing(YMirror ymirror, Dimension2D dim) {
|
public Drawing(YMirror ymirror, MinMax minMax) {
|
||||||
this.ymirror = ymirror;
|
this.ymirror = ymirror;
|
||||||
this.dim = dim;
|
this.minMax = minMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawU(UGraphic ug) {
|
public void drawU(UGraphic ug) {
|
||||||
|
if (minMax != null) {
|
||||||
|
// Matches the adjustment in SvekResult.calculateDimension()
|
||||||
|
ug = ug.apply(new UTranslate(6 - minMax.getMinX(), 6 - minMax.getMinY()));
|
||||||
|
}
|
||||||
|
|
||||||
for (Map.Entry<IGroup, ST_Agraph_s> ent : clusters.entrySet()) {
|
for (Map.Entry<IGroup, ST_Agraph_s> ent : clusters.entrySet()) {
|
||||||
drawGroup(ug, ymirror, ent.getKey(), ent.getValue());
|
drawGroup(ug, ymirror, ent.getKey(), ent.getValue());
|
||||||
@ -161,10 +166,10 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
||||||
if (dim == null) {
|
if (minMax == null) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
return dim;
|
return minMax.getDimension();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Point2D getCorner(ST_Agnode_s n) {
|
private Point2D getCorner(ST_Agnode_s n) {
|
||||||
@ -446,14 +451,13 @@ public class CucaDiagramFileMakerSmetana implements CucaDiagramFileMaker {
|
|||||||
|
|
||||||
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
|
final ImageBuilder imageBuilder = ImageBuilder.build(imageParameter);
|
||||||
|
|
||||||
imageBuilder.setUDrawable(new Drawing(null, null));
|
final MinMax minMax = TextBlockUtils.getMinMax(new Drawing(null, null), stringBounder, false);
|
||||||
final Dimension2D dim = imageBuilder.getFinalDimension(stringBounder);
|
|
||||||
|
|
||||||
final AnnotatedWorker annotatedWorker = new AnnotatedWorker(diagram, diagram.getSkinParam(),
|
final AnnotatedWorker annotatedWorker = new AnnotatedWorker(diagram, diagram.getSkinParam(),
|
||||||
fileFormatOption.getDefaultStringBounder(diagram.getSkinParam()));
|
fileFormatOption.getDefaultStringBounder(diagram.getSkinParam()));
|
||||||
|
|
||||||
// imageBuilder.setUDrawable(new Drawing(new YMirror(dim.getHeight())));
|
// imageBuilder.setUDrawable(new Drawing(new YMirror(dim.getHeight())));
|
||||||
imageBuilder.setUDrawable(annotatedWorker.addAdd(new Drawing(new YMirror(dim.getHeight()), dim)));
|
imageBuilder.setUDrawable(annotatedWorker.addAdd(new Drawing(new YMirror(minMax.getHeight()), minMax)));
|
||||||
|
|
||||||
return imageBuilder.writeImageTOBEMOVED(diagram.seed(), os);
|
return imageBuilder.writeImageTOBEMOVED(diagram.seed(), os);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user