1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\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.g2d.routing;
\r
14 import java.awt.geom.Path2D;
\r
16 public class TrivialRouter implements IRouter {
\r
19 public void update(IGraphModel model) {
\r
20 for(Object c : model.getConnections()) {
\r
21 Terminal begin = model.getBeginTerminal(c);
\r
22 Terminal end = model.getEndTerminal(c);
\r
23 double[] routePoints = model.getRoutePoints(c);
\r
25 Path2D path = new Path2D.Double();
\r
28 path.moveTo(begin.x, begin.y);
\r
29 else if(routePoints.length >= 2) {
\r
30 path.moveTo(routePoints[0], routePoints[1]);
\r
33 for(;i<routePoints.length;i += 2)
\r
34 path.lineTo(routePoints[i], routePoints[i+1]);
\r
36 path.lineTo(end.x, end.y);
\r
38 model.setPath(c, path);
\r