]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/routing/TrivialRouter.java
Fixed invalid comparisons which were identified by Eclipse IDE 2018-09
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / routing / TrivialRouter.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in 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  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.g2d.routing;
13
14 import java.awt.geom.Path2D;
15
16 public class TrivialRouter implements IRouter {
17
18     @Override
19     public void update(IGraphModel model) {
20         for(Object c : model.getConnections()) {
21             Terminal begin = model.getBeginTerminal(c);            
22             Terminal end = model.getEndTerminal(c);
23             double[] routePoints = model.getRoutePoints(c);
24             
25             Path2D path = new Path2D.Double();
26             int i=0;
27             if(begin != null)
28                 path.moveTo(begin.x, begin.y);
29             else if(routePoints.length >= 2) {
30                 path.moveTo(routePoints[0], routePoints[1]);
31                 i = 2;
32             }
33             for(;i<routePoints.length;i += 2)
34                 path.lineTo(routePoints[i], routePoints[i+1]);
35             if(end != null)
36                 path.lineTo(end.x, end.y);
37             
38             model.setPath(c, path);
39         }
40     }
41
42 }