X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.diagram.connection%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fconnection%2Frendering%2FAggregateConnectionStyle.java;fp=bundles%2Forg.simantics.diagram.connection%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fconnection%2Frendering%2FAggregateConnectionStyle.java;h=7bf76246f203c4798de8e0adbc8aa5f2a35737ed;hp=0000000000000000000000000000000000000000;hb=e3f46ffc9d4a6930adc83ebb8e6730f19708cc94;hpb=08c2bc8c90c7342582fd792bbeeaa16d6c18f9b1 diff --git a/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/rendering/AggregateConnectionStyle.java b/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/rendering/AggregateConnectionStyle.java new file mode 100644 index 000000000..7bf76246f --- /dev/null +++ b/bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/rendering/AggregateConnectionStyle.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2020 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Semantum Oy - initial API and implementation + *******************************************************************************/ +package org.simantics.diagram.connection.rendering; + +import java.awt.Graphics2D; +import java.awt.geom.Path2D; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +public class AggregateConnectionStyle implements ConnectionStyle, Serializable{ + + private static final long serialVersionUID = 5888959070127628457L; + private List styles = new ArrayList<>(); + + public void addStyle(ConnectionStyle style) { + styles.add(style); + } + + @Override + public void drawBranchPoint(Graphics2D g, double x, double y) { + for (ConnectionStyle style : styles) { + style.drawBranchPoint(g, x, y); + } + } + + @Override + public void drawLine(Graphics2D g, double x1, double y1, double x2, double y2, boolean isTransient) { + for (ConnectionStyle style : styles) { + style.drawLine(g, x1, y1, x2, y2, isTransient); + } + } + + @Override + public void drawPath(Graphics2D g, Path2D path, boolean isTransient) { + for (ConnectionStyle style : styles) { + style.drawPath(g, path, isTransient); + } + } + + @Override + public void drawDegeneratedLine(Graphics2D g, double x, double y, boolean isHorizontal, boolean isTransient) { + for (ConnectionStyle style : styles) { + style.drawDegeneratedLine(g, x, y, isHorizontal, isTransient); + } + } + + @Override + public double getDegeneratedLineLength() { + double max = 0; + for (ConnectionStyle style : styles) { + max = Math.max(max, style.getDegeneratedLineLength()); + } + return max; + } + +}