com.sun.electric.tool.routing
Class InteractiveRouter

java.lang.Object
  extended by com.sun.electric.tool.routing.Router
      extended by com.sun.electric.tool.routing.InteractiveRouter
Direct Known Subclasses:
SimpleWirer

public abstract class InteractiveRouter
extends Router

An Interactive Router has several methods that build on Router methods to provide interactive control to user. It also provides methods for highlighting routes to provide visual feedback to the user. Finally, non-interactive routing is done only from PortInst to PortInst, whereas interactive routing can start and end on any arc, and can end in space.

Note: 'Interactive' is somewhat of a misnomer, as it would imply the route can be incremently built or changed by the user. In reality, it is expected that the route simply be rebuilt whenever the user input changes, until the user decides that the route is acceptable, at which point the route can be made.

User: gainsley Date: Feb 24, 2004 Time: 4:58:24 PM


Nested Class Summary
 
Nested classes/interfaces inherited from class com.sun.electric.tool.routing.Router
Router.ArcWidth, Router.CreateRouteJob
 
Field Summary
 
Fields inherited from class com.sun.electric.tool.routing.Router
tool, verbose
 
Constructor Summary
InteractiveRouter()
           
 
Method Summary
protected  RouteElementPort bisectArc(Route route, ArcInst arc, java.awt.geom.Point2D bisectPoint, PolyMerge stayInside)
          Splits an arc at bisectPoint and updates the route to reflect the change.
 void cancelInteractiveRoute()
          Cancels interative routing and restores original highlights
protected static ElectricObject filterRouteObject(ElectricObject routeObj, java.awt.geom.Point2D clicked)
          If routeObj is a NodeInst, first thing we do is get the nearest PortInst to where the user clicked, and use that instead.
protected  RouteElementPort findArcConnectingPoint(Route route, ArcInst arc, java.awt.geom.Point2D point, PolyMerge stayInside)
          If drawing to/from an ArcInst, we may connect to some point along the arc.
protected static double getArcWidthToUse(ElectricObject routeObj, ArcProto ap)
           
protected static java.awt.geom.Point2D getClosestAngledPoint(java.awt.geom.Point2D startPoint, java.awt.geom.Point2D clicked, int angleIncrement)
          Use to find the closest point to clicked to route a wire from startPoint.
protected static java.awt.geom.Point2D getClosestOrthogonalPoint(java.awt.geom.Point2D startPoint, java.awt.geom.Point2D clicked)
          Gets the closest orthogonal point from the startPoint to the clicked point.
protected static double getClosestValue(double min, double max, double clicked)
          Get closest value to clicked within a range from min to max
protected static void getConnectingPoints(ElectricObject startObj, ElectricObject endObj, java.awt.geom.Point2D clicked, java.awt.geom.Point2D startPoint, java.awt.geom.Point2D endPoint, Poly startPoly, Poly endPoly, ArcProto startArc, ArcProto endArc)
          Get the connecting points for the start and end objects of the route.
protected static Poly getConnectingSite(ElectricObject obj, java.awt.geom.Point2D clicked, double arcWidth)
          Get the connecting site of the electric object.
protected static PortProto getRoutePort(ElectricObject routeObj)
          Get the PortProto associated with routeObj (it should be either a ArcInst or a PortInst, otherwise this will return null).
 void highlightRoute(EditWindow wnd, Cell cell, ElectricObject startObj, ElectricObject endObj, java.awt.geom.Point2D clicked)
          Make a route and highlight it in the window.
 void highlightRoute(EditWindow wnd, Route route, Cell cell)
          Highlight a route in the window
 void makeRoute(EditWindow wnd, Cell cell, ElectricObject startObj, ElectricObject endObj, java.awt.geom.Point2D clicked)
          Make a route between startObj and endObj in the EditWindow_ wnd.
 boolean makeVerticalRoute(EditWindow wnd, PortInst startPort, ArcProto arc)
          Make a vertical route.
protected  boolean onSegment(java.awt.geom.Point2D point, java.awt.geom.Line2D line)
          Returns true if point is on the line segment, false otherwise.
 Route planRoute(Cell cell, ElectricObject startObj, ElectricObject endObj, java.awt.geom.Point2D clicked, PolyMerge stayInside, boolean extendArcHead, boolean extendArcTail)
          Plan a route from startObj to endObj, taking into account where the user clicked in the cell.
 Route planRoute(Cell cell, ElectricObject startObj, ElectricObject endObj, java.awt.geom.Point2D clicked, PolyMerge stayInside, boolean extendArcHead, boolean extendArcTail, java.awt.geom.Rectangle2D contactArea)
          Plan a route from startObj to endObj, taking into account where the user clicked in the cell.
protected abstract  boolean planRoute(Route route, Cell cell, RouteElementPort endRE, java.awt.geom.Point2D startLoc, java.awt.geom.Point2D endLoc, java.awt.geom.Point2D clicked, PolyMerge stayInside, VerticalRoute vroute, boolean contactsOnEndObject, boolean extendArcHead, boolean extendArcTail, java.awt.geom.Rectangle2D contactArea)
           
 void startInteractiveRoute(EditWindow wnd)
          This stores the currently highlighted objects to highlight in addition to route highlighting.
 java.lang.String toString()
           
protected  boolean withinBounds(double point, double bound1, double bound2)
           
 
Methods inherited from class com.sun.electric.tool.routing.Router
createRoute, createRouteNoJob, getArcToUse, getArcWidthToUse, getArcWidthToUse, getArcWidthToUse, getContactSize, getContactSize, reportRoutingResults, setTool, useWidestWire
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InteractiveRouter

public InteractiveRouter()
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

planRoute

protected abstract boolean planRoute(Route route,
                                     Cell cell,
                                     RouteElementPort endRE,
                                     java.awt.geom.Point2D startLoc,
                                     java.awt.geom.Point2D endLoc,
                                     java.awt.geom.Point2D clicked,
                                     PolyMerge stayInside,
                                     VerticalRoute vroute,
                                     boolean contactsOnEndObject,
                                     boolean extendArcHead,
                                     boolean extendArcTail,
                                     java.awt.geom.Rectangle2D contactArea)

startInteractiveRoute

public void startInteractiveRoute(EditWindow wnd)
This stores the currently highlighted objects to highlight in addition to route highlighting. If routing it cancelled, it also restores the original highlighting.


cancelInteractiveRoute

public void cancelInteractiveRoute()
Cancels interative routing and restores original highlights


makeRoute

public void makeRoute(EditWindow wnd,
                      Cell cell,
                      ElectricObject startObj,
                      ElectricObject endObj,
                      java.awt.geom.Point2D clicked)
Make a route between startObj and endObj in the EditWindow_ wnd. Uses the point where the user clicked as a parameter to set the route.

Parameters:
wnd - the EditWindow_ the user is editing
cell - the cell in which to create the route
startObj - a PortInst or ArcInst from which to start the route
endObj - a PortInst or ArcInst to end the route on. May be null if the user is drawing to empty space.
clicked - the point where the user clicked

makeVerticalRoute

public boolean makeVerticalRoute(EditWindow wnd,
                                 PortInst startPort,
                                 ArcProto arc)
Make a vertical route. Will add in contacts in startPort's technology to be able to connect to endPort. The added contacts will be placed on top of startPort. The final contact will be able to connect to arc.

Parameters:
wnd - the EditWindow_ the user is editing
startPort - the start of the route
arc - the arc type that the last contact will be able to connect to
Returns:
true on sucess

highlightRoute

public void highlightRoute(EditWindow wnd,
                           Cell cell,
                           ElectricObject startObj,
                           ElectricObject endObj,
                           java.awt.geom.Point2D clicked)
Make a route and highlight it in the window.

Parameters:
cell - the cell in which to create the route
startObj - a PortInst or ArcInst from which to start the route
endObj - a PortInst or ArcInst to end the route on. May be null if the user is drawing to empty space.
clicked - the point where the user clicked

highlightRoute

public void highlightRoute(EditWindow wnd,
                           Route route,
                           Cell cell)
Highlight a route in the window

Parameters:
route - the route to be highlighted

planRoute

public Route planRoute(Cell cell,
                       ElectricObject startObj,
                       ElectricObject endObj,
                       java.awt.geom.Point2D clicked,
                       PolyMerge stayInside,
                       boolean extendArcHead,
                       boolean extendArcTail)
Plan a route from startObj to endObj, taking into account where the user clicked in the cell.

Parameters:
cell - the cell in which to create the arc
startObj - a PortInst or ArcInst from which to start the route
endObj - a PortInst or ArcInst to end the route on. May be null if the user is drawing to empty space.
clicked - the point where the user clicked
stayInside - the area in which to route (null if not applicable).
extendArcHead - true to use default arc extension; false to force no arc extension.
extendArcTail - true to use default arc extension; false to force no arc extension.
Returns:
a List of RouteElements denoting route

planRoute

public Route planRoute(Cell cell,
                       ElectricObject startObj,
                       ElectricObject endObj,
                       java.awt.geom.Point2D clicked,
                       PolyMerge stayInside,
                       boolean extendArcHead,
                       boolean extendArcTail,
                       java.awt.geom.Rectangle2D contactArea)
Plan a route from startObj to endObj, taking into account where the user clicked in the cell.

Parameters:
cell - the cell in which to create the arc
startObj - a PortInst or ArcInst from which to start the route
endObj - a PortInst or ArcInst to end the route on. May be null if the user is drawing to empty space.
clicked - the point where the user clicked
stayInside - the area in which to route (null if not applicable).
extendArcHead - true to use default arc extension; false to force no arc extension.
extendArcTail - true to use default arc extension; false to force no arc extension.
Returns:
a List of RouteElements denoting route

filterRouteObject

protected static ElectricObject filterRouteObject(ElectricObject routeObj,
                                                  java.awt.geom.Point2D clicked)
If routeObj is a NodeInst, first thing we do is get the nearest PortInst to where the user clicked, and use that instead.

Parameters:
routeObj - the route object (possibly a NodeInst).
clicked - where the user clicked
Returns:
the PortInst on the NodeInst closest to where the user clicked, or just the routeObj back if it is not a NodeInst.

getRoutePort

protected static PortProto getRoutePort(ElectricObject routeObj)
Get the PortProto associated with routeObj (it should be either a ArcInst or a PortInst, otherwise this will return null).

Parameters:
routeObj - the route object
Returns:
the PortProto for this route object

getArcWidthToUse

protected static double getArcWidthToUse(ElectricObject routeObj,
                                         ArcProto ap)

getConnectingPoints

protected static void getConnectingPoints(ElectricObject startObj,
                                          ElectricObject endObj,
                                          java.awt.geom.Point2D clicked,
                                          java.awt.geom.Point2D startPoint,
                                          java.awt.geom.Point2D endPoint,
                                          Poly startPoly,
                                          Poly endPoly,
                                          ArcProto startArc,
                                          ArcProto endArc)
Get the connecting points for the start and end objects of the route. This fills in the two Point2D's startPoint and endPoint. These will be the end points of an arc that connects to either startObj or endObj.

Parameters:
startObj - the start route object
endObj - the end route object
clicked - where the user clicked
startPoint - point inside startPoly on startObj to connect arc to
endPoint - point inside endPoly on endObj to connect arc to
startPoly - valid port site on startObj
endPoly - valid port site on endObj

getConnectingSite

protected static Poly getConnectingSite(ElectricObject obj,
                                        java.awt.geom.Point2D clicked,
                                        double arcWidth)
Get the connecting site of the electric object. See NodeInst.getShapeOfPort() for more details.

Parameters:
obj - the object to get a connection site for
clicked - used to find the nearest portinst on a nodeinst, and nearest site on a multisite port
arcWidth - contacts port sites are restricted by the size of arcs connecting to them, such that the arc width does extend beyond the contact edges.
Returns:
a poly describing where something can connect to

findArcConnectingPoint

protected RouteElementPort findArcConnectingPoint(Route route,
                                                  ArcInst arc,
                                                  java.awt.geom.Point2D point,
                                                  PolyMerge stayInside)
If drawing to/from an ArcInst, we may connect to some point along the arc. This may bisect the arc, in which case we delete the current arc, add in a pin at the appropriate place, and create 2 new arcs to the old arc head/tail points. The bisection point depends on where the user point, but it is always a point on the arc.

Note that this method adds the returned RouteElement to the route, and updates the route if the arc is bisected. This method should NOT add the returned RouteElement to the route.

Parameters:
route - the route so far
arc - the arc to draw from/to
point - point on or near arc
stayInside - the area in which to route (null if not applicable).
Returns:
a RouteElement holding the new pin at the bisection point, or a RouteElement holding an existingPortInst if drawing from either end of the ArcInst.

bisectArc

protected RouteElementPort bisectArc(Route route,
                                     ArcInst arc,
                                     java.awt.geom.Point2D bisectPoint,
                                     PolyMerge stayInside)
Splits an arc at bisectPoint and updates the route to reflect the change. This method should NOT add the returned RouteElement to the route.

Parameters:
route - the current route
arc - the arc to split
bisectPoint - point on arc from which to split it
stayInside - the area in which to route (null if not applicable).
Returns:
the RouteElement from which to continue the route

getClosestValue

protected static double getClosestValue(double min,
                                        double max,
                                        double clicked)
Get closest value to clicked within a range from min to max


getClosestOrthogonalPoint

protected static java.awt.geom.Point2D getClosestOrthogonalPoint(java.awt.geom.Point2D startPoint,
                                                                 java.awt.geom.Point2D clicked)
Gets the closest orthogonal point from the startPoint to the clicked point. This is used when the user clicks in space and the router draws only a single arc towards the clicked point in one dimension.

Parameters:
startPoint - start point of the arc
clicked - where the user clicked
Returns:
an end point to draw to from start point to make a single arc segment.

getClosestAngledPoint

protected static java.awt.geom.Point2D getClosestAngledPoint(java.awt.geom.Point2D startPoint,
                                                             java.awt.geom.Point2D clicked,
                                                             int angleIncrement)
Use to find the closest point to clicked to route a wire from startPoint. This point will be at an angel from startPoint which is a multiple of angleIncrement. If stayInside and useArc are not null, then the two possible closest points will be determined by if they reside inside stayInside, rather than the closest point.

Parameters:
startPoint -
clicked -
angleIncrement -
Returns:
the closest point to clicked to route a wire.

withinBounds

protected boolean withinBounds(double point,
                               double bound1,
                               double bound2)

onSegment

protected boolean onSegment(java.awt.geom.Point2D point,
                            java.awt.geom.Line2D line)
Returns true if point is on the line segment, false otherwise.