1 /*******************************************************************************
2 * Copyright (c) 2011 Association for Decentralized Information Management in
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.diagram.connection.rendering;
14 import java.awt.BasicStroke;
15 import java.awt.Color;
16 import java.awt.Graphics2D;
17 import java.awt.geom.Ellipse2D;
18 import java.awt.geom.Line2D;
19 import java.awt.geom.Path2D;
20 import java.io.Serializable;
22 public class ExampleConnectionStyle implements ConnectionStyle, Serializable {
24 private static final long serialVersionUID = -5799681720482456895L;
26 public final static BasicStroke SOLID =
29 public final static BasicStroke BOLD =
30 new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);
33 public void drawLine(Graphics2D g, double x1, double y1, double x2,
34 double y2, boolean isTransient) {
35 g.setColor(Color.BLACK);
37 g.draw(new Line2D.Double(x1, y1, x2, y2));
40 g.draw(new Line2D.Double(x1, y1, x2, y2));
46 public void drawPath(Graphics2D g, Path2D path, boolean isTransient) {
47 g.setColor(Color.BLACK);
58 public void drawBranchPoint(Graphics2D g, double x, double y) {
59 g.setColor(Color.BLACK);
60 g.fill(new Ellipse2D.Double(x-3, y-3, 6, 6));
64 public void drawDegeneratedLine(Graphics2D g, double x, double y,
65 boolean isHorizontal, boolean isTransient) {
66 double d = getDegeneratedLineLength()*0.5;
68 g.draw(new Line2D.Double(x-d, y, x+d, y));
70 g.draw(new Line2D.Double(x, y-d, x, y+d));
74 public double getDegeneratedLineLength() {