import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
+import java.util.Comparator;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
import org.simantics.maps.MapScalingTransform;
g.setFont(FONT);
double rowHeight = g.getFontMetrics().getHeight() * 1.1;
+ // let's calculate the max width
+ Optional<Integer> max = labels.stream().map(t -> g.getFontMetrics().stringWidth((String) t.c2)).max(Comparator.naturalOrder());
+ int width = max.orElse(10);
+ g.setColor(Color.WHITE);
+ int totalHeight = (int)Math.round(rowHeight * labels.size());
+ g.fillRect(-(W1 + PAD + W2 + 5), -(totalHeight + (int)Math.round(rowHeight)), (W1 + PAD + W2 + width + 10), totalHeight + 5);
+
g.setColor(Color.BLACK);
for (Tuple3 t : labels) {
double scale = 1.5 / g.getTransform().getScaleX();
g.scale(scale, scale);
+ int width1 = g.getFontMetrics().stringWidth(info);
+ int height = g.getFontMetrics().getHeight();
+
+ g.setColor(Color.WHITE);
+ g.fillRect(-width1/2 - 5, -2, width1, height);
+
g.setFont(FONT);
g.setColor(Color.BLACK);
g.transform(AffineTransform.getRotateInstance(direction.getX(), direction.getY()));
g.translate(0, 10);
- int width1 = g.getFontMetrics().stringWidth(info);
g.drawString(info, -width1/2, 0);
}
import org.simantics.db.common.procedure.adapter.TransientCacheListener;
import org.simantics.db.common.request.ResourceRead;
import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.exception.MissingVariableException;
import org.simantics.db.layer0.exception.MissingVariableValueException;
import org.simantics.db.layer0.exception.PendingVariableException;
import org.simantics.db.layer0.util.Layer0Utils;
import org.simantics.scl.runtime.function.Function1;
import org.simantics.scl.runtime.tuple.Tuple3;
import org.simantics.structural.stubs.StructuralResource2;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class DistrictNetworkHoverInfoStyle extends StyleBase<DistrictNetworkHoverInfoStyle.StyleResult> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(DistrictNetworkHoverInfoStyle.class);
+
private static final String ACTIONS_MODULE = "Actions";
private static final String HOVER_CONTRIBUTION = "hoverContribution";
result = Simantics.applySCLRead(graph, function, moduleVariable);
} catch (PendingVariableException | MissingVariableValueException e) {
result = Collections.singletonList(new Tuple3("<pending>", "", ""));
- }
+ } catch (MissingVariableException e) {
+ // the requested variable is missing from the UC
+ String message = e.getMessage();
+ LOGGER.warn("Missing variable for calculating style with function {} {}", function, message);
+ result = Collections.singletonList(new Tuple3("<" + message +">", "", ""));
+ }
Point2D point;
DistrictNetworkResource DN = DistrictNetworkResource.getInstance(graph);
import org.simantics.db.common.procedure.adapter.TransientCacheListener;
import org.simantics.db.common.request.ResourceRead;
import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.exception.MissingVariableException;
import org.simantics.db.layer0.exception.MissingVariableValueException;
import org.simantics.db.layer0.exception.PendingVariableException;
import org.simantics.db.layer0.util.Layer0Utils;
import org.simantics.scl.runtime.SCLContext;
import org.simantics.scl.runtime.function.Function1;
import org.simantics.structural.stubs.StructuralResource2;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
public class DistrictNetworkStaticInfoStyle extends StyleBase<DistrictNetworkStaticInfoStyle.StyleResult> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(DistrictNetworkStaticInfoStyle.class);
+
private static final String ACTIONS_MODULE = "Actions";
private static final String PIPELINE_INFO = "pipelineInfo";
result = Simantics.applySCLRead(graph, function, moduleVariable);
} catch (PendingVariableException | MissingVariableValueException e) {
result = null;
+ } catch (MissingVariableException e) {
+ // the requested variable is missing from the UC
+ String message = e.getMessage();
+ LOGGER.warn("Missing variable for calculating style with function {} {}", function, message);
+ result = "<" + message + ">";
}
if (isVertex) {