public abstract class InteractiveRouter extends Router
Note: 'Interactive' is somewhat of a misnomer, as it would imply the route can be incrementally 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
Router.ContactSize, Router.CreateRouteJob
Constructor and Description |
---|
InteractiveRouter(EditingPreferences ep) |
Modifier and Type | Method and Description |
---|---|
protected static RouteElementArc |
addConnectingArc(Route route,
Cell cell,
RouteElementPort startRE,
RouteElementPort endRE,
java.awt.geom.Point2D startPoint,
java.awt.geom.Point2D endPoint,
ArcProto arc,
double width,
int arcAngle,
boolean extendArcHead,
boolean extendArcTail,
PolyMerge stayInside,
EDimension alignment) |
protected RouteElementPort |
bisectArc(Route route,
ArcInst arc,
java.awt.geom.Point2D bisectPoint,
PolyMerge stayInside,
EDimension alignment)
Splits an arc at bisectPoint and updates the route to reflect the change.
|
void |
cancelInteractiveRoute()
Cancels interactive 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 connectingPoint,
PolyMerge stayInside,
EDimension alignment)
If drawing to/from an ArcInst, we may connect to some
point along the arc.
|
protected static int |
findQuadrant(java.awt.geom.Point2D refPoint,
java.awt.geom.Point2D pt)
Determines what route quadrant a point is compared to a reference point.
|
protected static java.awt.geom.Rectangle2D |
getBounds(ElectricObject obj)
Get bounds of primitive instance.
|
static java.awt.geom.Point2D |
getClosestAngledPoint(java.awt.geom.Point2D startPoint,
java.awt.geom.Point2D clicked,
int angleIncrement,
EDimension alignment)
Method to find the closest point to the clicked point when routed from a starting point.
|
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,
double alignment)
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,
EDimension alignment,
EditingPreferences ep)
Get the connecting points for the start and end objects of the route.
|
protected static Poly |
getConnectingSite(ElectricObject obj,
java.awt.geom.Point2D clicked,
EditingPreferences ep,
double arcWidth)
Get the connecting site of the electric object.
|
protected static java.awt.geom.Point2D |
getCornerLocation(java.awt.geom.Point2D startLoc,
java.awt.geom.Point2D endLoc,
java.awt.geom.Point2D clicked,
ArcProto startArc,
ArcProto endArc,
boolean contactsOnEndObj,
PolyMerge stayInside,
java.awt.geom.Rectangle2D contactArea,
Poly startPolyFull,
Poly endPolyFull,
EditingPreferences ep) |
protected static boolean |
getExtendArcEnd(RouteElementPort re,
java.awt.geom.Point2D point,
double arcWidth,
ArcProto arc,
int arcAngle,
boolean defExtends,
EDimension alignment) |
static java.awt.geom.Point2D |
getIntersection(java.awt.geom.Point2D[] points1,
java.awt.geom.Point2D[] points2)
Get the intersection point of the two line segments, or null if none
|
protected static java.awt.geom.Rectangle2D |
getLayerArea(ElectricObject obj,
Layer layer) |
protected static PortProto |
getRoutePort(ElectricObject routeObj,
EditingPreferences ep,
java.awt.geom.Point2D clicked)
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_.
|
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,
EditingPreferences ep,
boolean extendArcHead,
boolean extendArcTail,
java.awt.geom.Rectangle2D contactArea,
EDimension alignment)
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,
EditingPreferences ep,
boolean extendArcHead,
boolean extendArcTail,
java.awt.geom.Rectangle2D contactArea,
EDimension alignment,
java.lang.Boolean evenHor)
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 static void |
updateContactArea(java.awt.geom.Rectangle2D contactArea,
RouteElementPort re,
java.awt.geom.Point2D cornerLoc,
double arcWidth,
int arcAngle) |
protected boolean |
withinBounds(double point,
double bound1,
double bound2) |
createRoute, createRouteNoJob, getArcToUse, getArcWidthToUse, reportRoutingResults, setTool
public InteractiveRouter(EditingPreferences ep)
public java.lang.String toString()
toString
in class java.lang.Object
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)
public void startInteractiveRoute(EditWindow wnd)
public void cancelInteractiveRoute()
public void makeRoute(EditWindow wnd, Cell cell, ElectricObject startObj, ElectricObject endObj, java.awt.geom.Point2D clicked)
wnd
- the EditWindow_ the user is editingcell
- the cell in which to create the routestartObj
- a PortInst or ArcInst from which to start the routeendObj
- 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 clickedpublic boolean makeVerticalRoute(EditWindow wnd, PortInst startPort, ArcProto arc)
wnd
- the EditWindow_ the user is editingstartPort
- the start of the routearc
- the arc type that the last contact will be able to connect topublic void highlightRoute(EditWindow wnd, Cell cell, ElectricObject startObj, ElectricObject endObj, java.awt.geom.Point2D clicked)
cell
- the cell in which to create the routestartObj
- a PortInst or ArcInst from which to start the routeendObj
- 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 clickedpublic void highlightRoute(EditWindow wnd, Route route, Cell cell)
route
- the route to be highlightedpublic Route planRoute(Cell cell, ElectricObject startObj, ElectricObject endObj, java.awt.geom.Point2D clicked, PolyMerge stayInside, EditingPreferences ep, boolean extendArcHead, boolean extendArcTail, java.awt.geom.Rectangle2D contactArea, EDimension alignment)
cell
- the cell in which to create the arcstartObj
- a PortInst or ArcInst from which to start the routeendObj
- 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 clickedstayInside
- the area in which to route (null if not applicable).ep
- EditingPreferencesextendArcHead
- true to use default arc extension; false to force no arc extension. (head connects to startObj).extendArcTail
- true to use default arc extension; false to force no arc extension. (tail connects to endObj).contactArea
- alignment
- edge alignment factors (null for no alignment).public Route planRoute(Cell cell, ElectricObject startObj, ElectricObject endObj, java.awt.geom.Point2D clicked, PolyMerge stayInside, EditingPreferences ep, boolean extendArcHead, boolean extendArcTail, java.awt.geom.Rectangle2D contactArea, EDimension alignment, java.lang.Boolean evenHor)
cell
- the cell in which to create the arcstartObj
- a PortInst or ArcInst from which to start the routeendObj
- 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 clickedstayInside
- the area in which to route (null if not applicable).ep
- EditingPreferencesextendArcHead
- true to use default arc extension; false to force no arc extension. (head connects to startObj).extendArcTail
- true to use default arc extension; false to force no arc extension. (tail connects to endObj).contactArea
- alignment
- edge alignment factors (null for no alignment).evenHor
- if even metals should go horizontal. Only if data is availableprotected static ElectricObject filterRouteObject(ElectricObject routeObj, java.awt.geom.Point2D clicked)
routeObj
- the route object (possibly a NodeInst).clicked
- where the user clickedprotected static PortProto getRoutePort(ElectricObject routeObj, EditingPreferences ep, java.awt.geom.Point2D clicked)
routeObj
- the route objectep
- EditingPreferencesprotected 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, EDimension alignment, EditingPreferences ep)
startObj
- the start route objectendObj
- the end route objectclicked
- where the user clickedstartPoint
- point inside startPoly on startObj to connect arc toendPoint
- point inside endPoly on endObj to connect arc tostartPoly
- valid port site on startObjendPoly
- valid port site on endObjstartArc
- the arc type to connect to startObjendArc
- the arc type to connect to endObjep
- EditingPreferences.public static java.awt.geom.Point2D getIntersection(java.awt.geom.Point2D[] points1, java.awt.geom.Point2D[] points2)
points1
- An array of two points that define line 1points2
- An array of two points that define line 2protected static java.awt.geom.Rectangle2D getBounds(ElectricObject obj)
obj
- the objectprotected static Poly getConnectingSite(ElectricObject obj, java.awt.geom.Point2D clicked, EditingPreferences ep, double arcWidth)
obj
- the object to get a connection site forclicked
- used to find the nearest portinst on a nodeinst, and nearest
site on a multi-site portarcWidth
- contacts port sites are restricted by the size of arcs connecting
to them, such that the arc width does extend beyond the contact edges.protected static java.awt.geom.Rectangle2D getLayerArea(ElectricObject obj, Layer layer)
protected RouteElementPort findArcConnectingPoint(Route route, ArcInst arc, java.awt.geom.Point2D connectingPoint, PolyMerge stayInside, EDimension alignment)
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.
route
- the route so fararc
- the arc to draw from/toconnectingPoint
- point on or near arcstayInside
- the area in which to route (null if not applicable).alignment
- if non-null, alignment to align toprotected RouteElementPort bisectArc(Route route, ArcInst arc, java.awt.geom.Point2D bisectPoint, PolyMerge stayInside, EDimension alignment)
route
- the current routearc
- the arc to splitbisectPoint
- point on arc from which to split itstayInside
- the area in which to route (null if not applicable).alignment
- alignment to align to, if non-nullprotected static java.awt.geom.Point2D getCornerLocation(java.awt.geom.Point2D startLoc, java.awt.geom.Point2D endLoc, java.awt.geom.Point2D clicked, ArcProto startArc, ArcProto endArc, boolean contactsOnEndObj, PolyMerge stayInside, java.awt.geom.Rectangle2D contactArea, Poly startPolyFull, Poly endPolyFull, EditingPreferences ep)
protected static void updateContactArea(java.awt.geom.Rectangle2D contactArea, RouteElementPort re, java.awt.geom.Point2D cornerLoc, double arcWidth, int arcAngle)
protected static RouteElementArc addConnectingArc(Route route, Cell cell, RouteElementPort startRE, RouteElementPort endRE, java.awt.geom.Point2D startPoint, java.awt.geom.Point2D endPoint, ArcProto arc, double width, int arcAngle, boolean extendArcHead, boolean extendArcTail, PolyMerge stayInside, EDimension alignment)
protected static boolean getExtendArcEnd(RouteElementPort re, java.awt.geom.Point2D point, double arcWidth, ArcProto arc, int arcAngle, boolean defExtends, EDimension alignment)
protected static double getClosestValue(double min, double max, double clicked, double alignment)
protected static java.awt.geom.Point2D getClosestOrthogonalPoint(java.awt.geom.Point2D startPoint, java.awt.geom.Point2D clicked)
startPoint
- start point of the arcclicked
- where the user clickedpublic static java.awt.geom.Point2D getClosestAngledPoint(java.awt.geom.Point2D startPoint, java.awt.geom.Point2D clicked, int angleIncrement, EDimension alignment)
startPoint
- the starting point of the route.clicked
- the location of the user's click.angleIncrement
- the increment of possible angles.alignment
- the grid alignment to use.protected boolean withinBounds(double point, double bound1, double bound2)
protected boolean onSegment(java.awt.geom.Point2D point, java.awt.geom.Line2D line)
protected static int findQuadrant(java.awt.geom.Point2D refPoint, java.awt.geom.Point2D pt)
quadrant : angle (theta)
0 : -45 degrees to 45 degrees
1 : 45 degrees to 135 degrees
2 : 135 degrees to 225 degrees
3 : 225 degrees to 315 degrees (-45 degrees)
refPoint
- reference pointpt
- variable point