From: Antti Villberg Date: Mon, 15 Jun 2020 05:36:01 +0000 (+0300) Subject: TextGrid changes for Solvo X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=25030a144d486f85ca62a287641fe222bacd0d42;p=simantics%2Fplatform.git TextGrid changes for Solvo Change-Id: Ibccd48e98a68ce15cb2d9735ae9198f08388112d --- 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