1 /*******************************************************************************
\r
2 * Copyright (c) 2011 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.diagram.connection.rendering;
\r
14 import java.awt.BasicStroke;
\r
15 import java.awt.Color;
\r
16 import java.awt.Graphics2D;
\r
17 import java.awt.geom.Ellipse2D;
\r
18 import java.awt.geom.Line2D;
\r
19 import java.awt.geom.Path2D;
\r
20 import java.io.Serializable;
\r
22 public class ExampleConnectionStyle implements ConnectionStyle, Serializable {
\r
24 private static final long serialVersionUID = -5799681720482456895L;
\r
26 public final static BasicStroke SOLID =
\r
27 new BasicStroke(1f);
\r
29 public final static BasicStroke BOLD =
\r
30 new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);
\r
33 public void drawLine(Graphics2D g, double x1, double y1, double x2,
\r
34 double y2, boolean isTransient) {
\r
35 g.setColor(Color.BLACK);
\r
37 g.draw(new Line2D.Double(x1, y1, x2, y2));
\r
40 g.draw(new Line2D.Double(x1, y1, x2, y2));
\r
46 public void drawPath(Graphics2D g, Path2D path, boolean isTransient) {
\r
47 g.setColor(Color.BLACK);
\r
58 public void drawBranchPoint(Graphics2D g, double x, double y) {
\r
59 g.setColor(Color.BLACK);
\r
60 g.fill(new Ellipse2D.Double(x-3, y-3, 6, 6));
\r
64 public void drawDegeneratedLine(Graphics2D g, double x, double y,
\r
65 boolean isHorizontal, boolean isTransient) {
\r
66 double d = getDegeneratedLineLength()*0.5;
\r
68 g.draw(new Line2D.Double(x-d, y, x+d, y));
\r
70 g.draw(new Line2D.Double(x, y-d, x, y+d));
\r
74 public double getDegeneratedLineLength() {
\r