1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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.g2d.routing.algorithm1;
14 import org.simantics.g2d.routing.algorithm1.StaticRouter.Cost;
16 public class Penalty {
17 static final double BEND_PENALTY = 1.0;
18 static final double CONNECTION_MARGINAL = 10.0;
19 static final Cost INFINITE_COST = new Cost(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
21 static final Penalty OBSTACLE_PENALTY = new Penalty(20.0, 0.0);
22 static final Penalty CONNECTION_SIDE_PENALTY = new Penalty(10.0, 0.0);
23 static final Penalty CONNECTION_CROSS_PENALTY = new Penalty(0.4, 2*CONNECTION_MARGINAL);
28 public Penalty(double penalty, double minDistance) {
29 this.penalty = penalty;
30 this.minDistance = minDistance;
34 public int hashCode() {
38 temp = Double.doubleToLongBits(minDistance);
39 result = prime * result + (int) (temp ^ (temp >>> 32));
40 temp = Double.doubleToLongBits(penalty);
41 result = prime * result + (int) (temp ^ (temp >>> 32));
45 public boolean equals(Object obj) {
50 if (getClass() != obj.getClass())
52 Penalty other = (Penalty) obj;
53 if (Double.doubleToLongBits(minDistance) != Double
54 .doubleToLongBits(other.minDistance))
56 if (Double.doubleToLongBits(penalty) != Double
57 .doubleToLongBits(other.penalty))