From 569d9bd9d6a270e8ede5867ff0b1f13475047e8b Mon Sep 17 00:00:00 2001 From: Antti Villberg Date: Mon, 15 Jun 2020 08:36:01 +0300 Subject: [PATCH] TextGrid changes for Solvo Change-Id: Ibccd48e98a68ce15cb2d9735ae9198f08388112d --- .../diagram/elements/TextGridNode.java | 49 ++++++++++++++----- .../simantics/diagram/elements/TextNode.java | 2 +- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextGridNode.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextGridNode.java index 3b8de9092..afd9772db 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextGridNode.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextGridNode.java @@ -11,15 +11,8 @@ *******************************************************************************/ package org.simantics.diagram.elements; -import gnu.trove.map.TIntObjectMap; -import gnu.trove.map.TMap; -import gnu.trove.map.hash.THashMap; -import gnu.trove.map.hash.TIntObjectHashMap; -import gnu.trove.procedure.TObjectProcedure; - import java.awt.Color; import java.awt.Font; -import java.awt.Graphics2D; import java.awt.geom.AffineTransform; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; @@ -42,6 +35,12 @@ import org.simantics.scenegraph.g2d.nodes.Decoration; import org.simantics.scenegraph.utils.NodeUtil; import org.simantics.scl.runtime.function.Function1; +import gnu.trove.map.TIntObjectMap; +import gnu.trove.map.TMap; +import gnu.trove.map.hash.THashMap; +import gnu.trove.map.hash.TIntObjectHashMap; +import gnu.trove.procedure.TObjectProcedure; + /** * TODO: does not work remotely, e.g. rowIds */ @@ -264,13 +263,41 @@ public class TextGridNode extends G2DParentNode implements Decoration { return rowIds.get(y); } + class FontSizeSum implements TObjectProcedure { + + final double[] hs; + + FontSizeSum(int maxY) { + hs = new double[maxY+1]; + } + + @Override + public boolean execute(Cell key) { + A a = nodes.get(key); + int h = a.getFont().getSize(); + if(h > hs[key.y]) + hs[key.y] = h; + return true; + } + + public double getH() { + double result = 0; + for(int i=0;i