From a68746a936054802e8578fe7dda6a231cb03aac0 Mon Sep 17 00:00:00 2001 From: lempinen Date: Tue, 29 Oct 2013 10:49:41 +0000 Subject: [PATCH] Improved appearance of diagram elements. No customization yet for arrow sizes. refs #4481 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@28144 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../sysdyn/ui/editor/routing/DependencyRouter.java | 6 +++--- .../sysdyn/ui/editor/routing/FlowRouter.java | 2 +- .../sysdyn/ui/elements/AuxiliaryFactory.java | 3 ++- .../simantics/sysdyn/ui/elements/CloudFactory.java | 6 +++--- .../simantics/sysdyn/ui/elements/InputFactory.java | 6 +++--- .../simantics/sysdyn/ui/elements/ModuleFactory.java | 2 +- .../org/simantics/sysdyn/ui/elements/ModuleNode.java | 11 +++++++---- .../simantics/sysdyn/ui/elements/StockFactory.java | 2 +- .../simantics/sysdyn/ui/elements/ValveFactory.java | 4 ++-- .../ui/elements/connections/DependencyEdgeClass.java | 9 ++++++++- .../ui/elements/connections/DependencyNode.java | 2 +- .../ui/elements/connections/FlowArrowLineStyle.java | 4 ++-- .../ui/elements/connections/FlowConnectionStyle.java | 6 ++++-- .../connections/RouteFlowConnectionFactory.java | 7 +++++-- 14 files changed, 43 insertions(+), 27 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/routing/DependencyRouter.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/routing/DependencyRouter.java index dc2e29fe..a43b708a 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/routing/DependencyRouter.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/routing/DependencyRouter.java @@ -40,9 +40,9 @@ public class DependencyRouter implements IRouter2 { /* * Total length of the arrow is ARROW_LENGTH1 + ARROW_LENGTH2 */ - public static double ARROW_LENGTH1 = 0.2; - public static double ARROW_LENGTH2 = 1.0; - public static double ARROW_WIDTH = 0.5; + public static double ARROW_LENGTH1 = 1; + public static double ARROW_LENGTH2 = 1.5; + public static double ARROW_WIDTH = 1; private static Path2D createArrow(Path2D shape, double x, double y, double dx, double dy) { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/routing/FlowRouter.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/routing/FlowRouter.java index 2e813118..fc64625a 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/routing/FlowRouter.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/routing/FlowRouter.java @@ -16,7 +16,7 @@ public class FlowRouter implements IRouter2{ SysdynLocalRouter localRouter; - public static final float OFFSET = 1.0f; + public static final float OFFSET = 0.5f; public FlowRouter() { this(false); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/AuxiliaryFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/AuxiliaryFactory.java index 48463e08..391a5829 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/AuxiliaryFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/AuxiliaryFactory.java @@ -30,6 +30,7 @@ import org.simantics.g2d.element.handler.impl.TextFontImpl; import org.simantics.g2d.element.handler.impl.TextImpl; import org.simantics.g2d.image.Image; import org.simantics.g2d.image.impl.ShapeImage; +import org.simantics.g2d.utils.Alignment; /** * @author Tuukka Lehtonen @@ -50,7 +51,7 @@ public class AuxiliaryFactory extends SysdynElementFactory { new StaticObjectAdapter(elementType), new StaticSymbolImpl(AUX_STATIC_IMAGE), StaticSymbolImageInitializer.INSTANCE, - HoverTextElementHandler.INSTANCE, + new HoverTextElementHandler(0, 0, Alignment.LEADING, 0, 1.5, 1.5, true), BoundsOutline.INSTANCE, new WholeElementTerminals(terminals) ).setId(AuxiliaryFactory.class.getSimpleName()); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/CloudFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/CloudFactory.java index 63453a38..64895012 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/CloudFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/CloudFactory.java @@ -58,8 +58,8 @@ import org.simantics.utils.datastructures.hints.IHintObservable; public class CloudFactory extends SysdynElementFactory { - public static final double CLOUD_SIZE_X = 5.0; - public static final double CLOUD_SIZE_Y = 3.0; + public static final double CLOUD_SIZE_X = 2.5; + public static final double CLOUD_SIZE_Y = 1.7; public static final double CLOUD_CURVES = 7; private static final BasicStroke STROKE = new BasicStroke(1f); @@ -172,7 +172,7 @@ public class CloudFactory extends SysdynElementFactory { public Rectangle2D getBounds(IElement e, Rectangle2D size) { if (size == null) size = new Rectangle2D.Double(); - size.setFrame(getCloudShape().getBounds2D()); + size.setFrame(CLOUD_IMAGE.getBounds()); return size; } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/InputFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/InputFactory.java index 34896576..42c2c0a6 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/InputFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/InputFactory.java @@ -90,7 +90,7 @@ public class InputFactory extends SysdynElementFactory { new StaticSymbolImpl(INPUT_IMAGE), StaticSymbolImageInitializer.INSTANCE, Input.INSTANCE, - new InputSceneGraph(0, 0, Alignment.LEADING), + new InputSceneGraph(0, 0, Alignment.LEADING, 0, 1.5, 1.5, true), BoundsOutline.INSTANCE, HoverImpl.INSTANCE, new WholeElementTerminals(terminals) @@ -177,8 +177,8 @@ public class InputFactory extends SysdynElementFactory { private final double originX; private final Alignment horizontalAlignment; - public InputSceneGraph(double originX, double originY, Alignment horizontalAlignment) { - super(originX, originY, horizontalAlignment, 0.0, 2.0, 2.0, true); + public InputSceneGraph(double originX, double originY, Alignment horizontalAlignment, double borderWidth, double paddingX, double paddingY, boolean editable) { + super(originX, originY, horizontalAlignment, borderWidth, paddingX, paddingY, editable); this.originX = originX; this.horizontalAlignment = horizontalAlignment; } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/ModuleFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/ModuleFactory.java index 93f0779e..e67b7967 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/ModuleFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/ModuleFactory.java @@ -56,7 +56,7 @@ public class ModuleFactory extends SysdynElementFactory { new StaticObjectAdapter(elementType), new StaticSymbolImpl(DEFAULT_IMAGE), StaticSymbolImageInitializer.INSTANCE, - new ModuleSceneGraph(0, 0, Alignment.LEADING, 1f , 4, 4, true), + new ModuleSceneGraph(0, 0, Alignment.LEADING, 1f , 2, 3, true), BoundsOutline.INSTANCE, new BorderColorImpl(Color.BLACK), new WholeElementTerminals(terminals) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/ModuleNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/ModuleNode.java index ad0431d8..fa843919 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/ModuleNode.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/ModuleNode.java @@ -38,11 +38,13 @@ public class ModuleNode extends HoverTextNode { BasicStroke oldStroke = (BasicStroke)g.getStroke(); Color oldColor = g.getColor(); - g.transform(transform); - + // Apply separate legacy scale + + Rectangle2D bounds = expandBounds( getTightAlignedBoundsInLocal( tempBounds.get() ) ); + Path2D path = new Path2D.Double(); // LEFT TOP path.moveTo(bounds.getMinX() + CORNER_LENGTH, bounds.getMinY() - CORNER_PADDING); @@ -65,7 +67,7 @@ public class ModuleNode extends HoverTextNode { path.lineTo(bounds.getMaxX() + CORNER_PADDING, bounds.getMaxY() - CORNER_LENGTH); g.translate(x, y); - g.setStroke(new BasicStroke((float) (scale*borderWidth))); + g.setStroke(new BasicStroke((float) (/*scale**/scale*borderWidth))); g.setColor(borderColor); g.draw(path); @@ -89,12 +91,13 @@ public class ModuleNode extends HoverTextNode { g.setComposite(oc); } - + g.setColor(oldColor); g.setStroke(oldStroke); g.translate(-x, -y); g.setTransform(ot); + } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/StockFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/StockFactory.java index 1aa0f971..1777033c 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/StockFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/StockFactory.java @@ -57,7 +57,7 @@ public class StockFactory extends SysdynElementFactory { new StaticObjectAdapter(elementType), new StaticSymbolImpl(STOCK_IMAGE), StaticSymbolImageInitializer.INSTANCE, - new HoverTextElementHandler(0, 0, Alignment.LEADING, 1f), + new HoverTextElementHandler(0, 0, Alignment.LEADING, 1f, 1.0, 1.0, true), BoundsOutline.INSTANCE, new BorderColorImpl(Color.BLACK), new WholeElementTerminals(terminals) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/ValveFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/ValveFactory.java index 25890ac0..edc3785e 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/ValveFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/ValveFactory.java @@ -58,7 +58,7 @@ public class ValveFactory extends SysdynElementFactory { public static final Key KEY_ROTATED = new KeyOf(Boolean.class, "ROTATED"); - public static final double VALVE_SIZE = 2.5; + public static final double VALVE_SIZE = 1.5; private static final BasicStroke STROKE = new BasicStroke(1f); public static final Image VALVE_STATIC_IMAGE = new ShapeImage(createShape(VALVE_SIZE, false), null, STROKE, true); @@ -151,7 +151,7 @@ public class ValveFactory extends SysdynElementFactory { public ValveSceneGraph() { // super(0, VALVE_SIZE + 3.0, Alignment.CENTER); // Move with affine transformation in init() - super(0, 0, Alignment.CENTER); + super(0, 0, Alignment.CENTER, 0, 1, 1, true); } @Override public void init(IElement e, G2DParentNode parent) { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/DependencyEdgeClass.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/DependencyEdgeClass.java index 372820ac..385a4492 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/DependencyEdgeClass.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/DependencyEdgeClass.java @@ -37,6 +37,7 @@ import org.simantics.g2d.element.ElementUtils; import org.simantics.g2d.element.IElement; import org.simantics.g2d.element.SceneGraphNodeKey; import org.simantics.g2d.element.handler.EdgeVisuals; +import org.simantics.g2d.element.handler.EdgeVisuals.ArrowType; import org.simantics.g2d.element.handler.EdgeVisuals.EdgeEnd; import org.simantics.g2d.element.handler.Pick; import org.simantics.g2d.element.handler.SceneGraph; @@ -91,7 +92,13 @@ public class DependencyEdgeClass { ElementClass.compile( SysdynEdgeSceneGraph.INSTANCE, EdgeHandler.INSTANCE, - ConfigurableEdgeVisuals.DEFAULT, + new ConfigurableEdgeVisuals( + ArrowType.None, ArrowType.Fill, + new BasicStroke(0.3f, + BasicStroke.CAP_BUTT, + BasicStroke.JOIN_ROUND, + 10.0f, null, 0.0f) + , 1.0, 1.0), FillColorImpl.BLACK, FixedTransform.INSTANCE, TextImpl.INSTANCE, diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/DependencyNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/DependencyNode.java index c1609423..bfb4474b 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/DependencyNode.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/DependencyNode.java @@ -54,7 +54,7 @@ public class DependencyNode extends TextNode implements ISelectionPainterNode { private static final long serialVersionUID = 1294351381209071074L; - private static final BasicStroke STROKE = new BasicStroke(1.0f); + private static final BasicStroke STROKE = new BasicStroke(2.0f); private Color color; private Stroke stroke; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/FlowArrowLineStyle.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/FlowArrowLineStyle.java index 73d0879a..017941c3 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/FlowArrowLineStyle.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/FlowArrowLineStyle.java @@ -30,8 +30,8 @@ public class FlowArrowLineStyle implements ILineEndStyle, Serializable { public static enum ArrowType { None, Stroke, Fill } - public static final double length = 8.0; - public static final double width = 4.0; + public static final double length = FlowConnectionStyle.LINE_WIDTH * 4; + public static final double width = FlowConnectionStyle.LINE_WIDTH * 2; public static final double space = 0.0; protected ArrowType type; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/FlowConnectionStyle.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/FlowConnectionStyle.java index 036a4556..d16bee92 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/FlowConnectionStyle.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/FlowConnectionStyle.java @@ -13,6 +13,8 @@ public class FlowConnectionStyle extends BasicConnectionStyle { Color lineColor; Stroke lineStroke; + + public static float LINE_WIDTH = 1.0f; public FlowConnectionStyle(Color lineColor, Stroke lineStroke) { super(lineColor, Color.BLACK, 0.5, lineStroke, lineStroke, 0.8); @@ -35,8 +37,8 @@ public class FlowConnectionStyle extends BasicConnectionStyle { if (lineStroke != null) g.setStroke(lineStroke); - Path2D p1 = Flows.createOffsetPath(path, 1); - Path2D p2 = Flows.createOffsetPath(path, -1); + Path2D p1 = Flows.createOffsetPath(path, LINE_WIDTH/2); + Path2D p2 = Flows.createOffsetPath(path, -LINE_WIDTH/2); p1.append(p2, false); g.draw(p1); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/RouteFlowConnectionFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/RouteFlowConnectionFactory.java index 3ad51509..17489d80 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/RouteFlowConnectionFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/RouteFlowConnectionFactory.java @@ -251,7 +251,8 @@ public class RouteFlowConnectionFactory extends SyncElementFactory { // Valve behaves differently. The flow must start inside the valve bounds if(te.getElementClass().containsClass(ValveSceneGraph.class)) { - bounds.setFrame(new Rectangle2D.Double(bounds.getCenterX() - 1, bounds.getCenterY() - 1, 2, 2)); + float lw = FlowConnectionStyle.LINE_WIDTH; + bounds.setFrame(new Rectangle2D.Double(bounds.getCenterX() - (lw/2), bounds.getCenterY() - (lw/2), lw, lw)); } x = bounds.getCenterX(); @@ -408,7 +409,9 @@ public class RouteFlowConnectionFactory extends SyncElementFactory { style = new FlowArrowLineStyle("none 0 0 0", color); } else { if (graph.isSubrelationOf(attachmentRelation, DIA.HasHeadConnector)) { - style = new FlowArrowLineStyle("fill 2 2 0", color); + float lineWidth = FlowConnectionStyle.LINE_WIDTH; + float arrowSize = lineWidth * 1.3f; + style = new FlowArrowLineStyle("fill " + arrowSize + " " + arrowSize + " 0", color); } else { style = new FlowArrowLineStyle("none 0 0 0", color); } -- 2.47.1