]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/rendering/AggregateConnectionStyle.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.diagram.connection / src / org / simantics / diagram / connection / rendering / AggregateConnectionStyle.java
1 /*******************************************************************************
2  * Copyright (c) 2020 Association for Decentralized Information Management in
3  * Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     Semantum Oy - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.diagram.connection.rendering;
13
14 import java.awt.Graphics2D;
15 import java.awt.geom.Path2D;
16 import java.io.Serializable;
17 import java.util.ArrayList;
18 import java.util.List;
19
20 public class AggregateConnectionStyle implements ConnectionStyle, Serializable{
21
22     private static final long serialVersionUID = 5888959070127628457L;
23     private List<ConnectionStyle> styles = new ArrayList<>();
24     
25     public void addStyle(ConnectionStyle style) {
26         styles.add(style);
27     }
28     
29     @Override
30     public void drawBranchPoint(Graphics2D g, double x, double y) {
31         for (ConnectionStyle style : styles) {
32             style.drawBranchPoint(g, x, y);
33         }
34     }
35
36     @Override
37     public void drawLine(Graphics2D g, double x1, double y1, double x2, double y2, boolean isTransient) {
38         for (ConnectionStyle style : styles) {
39             style.drawLine(g, x1, y1, x2, y2, isTransient);
40         }
41     }
42
43     @Override
44     public void drawPath(Graphics2D g, Path2D path, boolean isTransient) {
45         for (ConnectionStyle style : styles) {
46             style.drawPath(g, path, isTransient);
47         }
48     }
49
50     @Override
51     public void drawDegeneratedLine(Graphics2D g, double x, double y, boolean isHorizontal, boolean isTransient) {
52         for (ConnectionStyle style : styles) {
53             style.drawDegeneratedLine(g, x, y, isHorizontal, isTransient);
54         }
55     }
56
57     @Override
58     public double getDegeneratedLineLength() {
59         double max = 0;
60         for (ConnectionStyle style : styles) {
61             max = Math.max(max, style.getDegeneratedLineLength());
62         }
63         return max;
64     }
65
66 }