com.sun.electric.tool.user
Class Highlighter

java.lang.Object
  extended by com.sun.electric.tool.user.Highlighter
All Implemented Interfaces:
DatabaseChangeListener, java.util.EventListener

public class Highlighter
extends java.lang.Object
implements DatabaseChangeListener

Class for per-window highlighting information.


Field Summary
static int EXACTSELECTDISTANCE
          the max pixel distance that's acceptable selection
static int MOUSEOVER_HIGHLIGHTER
          the mouse over highlighter type
static int RULER_HIGHLIGHTER
          the "measurement" highlighter type
static int SELECT_HIGHLIGHTER
          the selection highlighter type
 
Constructor Summary
Highlighter(int type, WindowFrame wf)
          Create a new Highlighter object
 
Method Summary
 Highlight2 addArea(java.awt.geom.Rectangle2D area, Cell cell)
          Method to add an area to the list of highlighted objects.
 Highlight2 addElectricObject(ElectricObject eobj, Cell cell)
          Method to add an ElectricObject to the list of highlighted objects.
 Highlight2 addElectricObject(ElectricObject eobj, Cell cell, boolean highlightConnected)
          Method to add an ElectricObject to the list of highlighted objects.
 Highlight2 addElectricObject(ElectricObject eobj, Cell cell, boolean highlightConnected, java.awt.Color col)
          Method to add an ElectricObject to the list of highlighted objects.
 Highlight2 addElectricObject(ElectricObject eobj, Cell cell, java.awt.Color col)
          Method to add an ElectricObject to the list of highlighted objects.
 void addHighlight(Highlight2 h)
          Add a Highlight
static void addHighlightListener(HighlightListener l)
          Add a Highlight listener
 Highlight2 addLine(java.awt.geom.Point2D start, java.awt.geom.Point2D end, Cell cell)
          Method to add a line to the list of highlighted objects.
 Highlight2 addLine(java.awt.geom.Point2D start, java.awt.geom.Point2D end, Cell cell, boolean thick)
          Method to add a line to the list of highlighted objects.
 Highlight2 addMessage(Cell cell, java.lang.String message, java.awt.geom.Point2D loc)
          Method to add a message display to the list of highlighted objects.
 Highlight2 addMessage(Cell cell, java.lang.String message, java.awt.geom.Point2D loc, int corner)
          Method to add a message display to the list of highlighted objects.
 void addNetwork(Network net, Cell cell)
          Method to add a network to the list of highlighted objects.
 Highlight2 addObject(java.lang.Object obj, Cell cell)
          Method to generic Object.
 Highlight2 addPoly(Poly poly, Cell cell, java.awt.Color color)
          Method to add a Poly to the list of highlighted objects
 Highlight2 addText(ElectricObject eobj, Cell cell, Variable.Key varKey)
          Method to add a text selection to the list of highlighted objects.
 Highlight2 addThickLine(java.awt.geom.Point2D start, java.awt.geom.Point2D end, Cell cell)
          Method to add a line to the list of highlighted objects.
static Highlight2 checkOutObject(Geometric geom, boolean findPort, boolean findPoint, boolean findSpecial, java.awt.geom.Rectangle2D bounds, EditWindow wnd, double directHitDist, boolean areaMustEnclose)
          Method to determine whether an object is in a bounds.
 void clear()
          Method to clear the list of all highlighted objects in
 void copyState(Highlighter highlighter)
          Inherits the last selected object from the specified highlighter.
 void databaseChanged(DatabaseChangeEvent e)
          Invoked in the java AWT Event thread when the database state changes.
 void delete()
          Destructor
static java.awt.geom.Point2D[] describeHighlightText(EditWindow wnd, ElectricObject eObj, Variable.Key varKey)
          Method to describe an object/variable-key pair as a set of points to draw.
static double distToArc(java.awt.geom.Rectangle2D bounds, ArcInst ai, EditWindow wnd)
          Method to return the distance from a bounds to an ArcInst.
static double distToNode(java.awt.geom.Rectangle2D bounds, NodeInst ni, EditWindow wnd)
          Method to return the distance from a bound to a NodeInst.
 void ensureHighlightingSeen()
          Method to ensure that the highlighting is visible.
static java.util.List<Highlight2> findAllInArea(Highlighter highlighter, Cell cell, boolean exclusively, boolean another, boolean findPort, boolean findPoint, boolean findSpecial, boolean findText, java.awt.geom.Rectangle2D bounds, EditWindow wnd)
          Method to search a Cell for all objects at a point.
 Highlight2 findObject(java.awt.geom.Point2D pt, EditWindow wnd, boolean exclusively, boolean another, boolean invert, boolean findPort, boolean findPoint, boolean findSpecial, boolean findText)
          Method to handle a click in a window and select the appropriate objects.
 void finished()
          Method to indicate that changes to highlighting are finished.
 void gainedFocus()
          Called when the Highlighter owner has gained focus, and the current highlighter switches to this.
 java.util.List<ArcInst> getHighlightedArcs()
          Method to return a List of all highlighted ArcInsts.
 java.awt.geom.Rectangle2D getHighlightedArea(EditWindow wnd)
          Method to return the bounds of the highlighted objects.
 java.util.List<Geometric> getHighlightedEObjs(boolean wantNodes, boolean wantArcs)
          Method to return a List of all highlighted Geometrics.
 java.util.Set<Network> getHighlightedNetworks()
          Method to return a set of the currently selected networks.
 java.util.List<NodeInst> getHighlightedNodes()
          Method to return a List of all highlighted NodeInsts.
 java.util.List<DisplayedText> getHighlightedText(boolean unique)
          Method to return a List of all highlighted text.
 java.awt.geom.Point2D getHighlightOffset()
          Method to return the screen offset for the display of highlighting
 java.util.List<Highlight2> getHighlights()
          Method to return a list that is a copy of the list of current highlights.
 int getNumHighlights()
          Method to return the number of highlighted objects.
 ElectricObject getOneElectricObject(java.lang.Class type)
          Method to return the only highlighted object.
 Highlight2 getOneHighlight()
          Method to return the only highlight that encompases an object in Cell cell.
static Highlight2 getSimiliarHighlight(java.util.List<Highlight2> highlights, Highlight2 exampleHigh)
          Chooses a single Highlight from the list of Highlights 'highlights' that is most similar to Highlight 'exampleHigh'.
 WindowFrame getWindowFrame()
          Method to return the WindowFrame associated with this Highlighter.
 Highlight2 overHighlighted(EditWindow wnd, int x, int y)
          Method to tell whether a point is over this Highlight.
 void popHighlight()
          Method to pop the current highlight list from the stack.
 void pushHighlight()
          Method to push the current highlight list onto a stack.
 void remove(Highlight2 h)
          Removes a Highlight object from the current set of highlights.
static void removeHighlightListener(HighlightListener l)
          Remove a Highlight listener
 void selectArea(EditWindow wnd, double minSelX, double maxSelX, double minSelY, double maxSelY, boolean invertSelection, boolean findSpecial)
          Method to add everything in an area to the selection.
 void setHighlightList(java.util.List<Highlight2> newHighlights)
          Method to load a list of Highlights into the highlighting.
 void setHighlightListGeneral(java.util.List<Highlight2> newHighlights)
          Method to load a list of Highlights into the highlighting.
 void setHighlightOffset(int offX, int offY)
          Method to set a screen offset for the display of highlighting.
 void showHighlights(EditWindow wnd, java.awt.Graphics g)
          Shows highlights for the current EditWindow
 void showNetworks(Cell cell)
          This is the show network command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECT_HIGHLIGHTER

public static final int SELECT_HIGHLIGHTER
the selection highlighter type

See Also:
Constant Field Values

MOUSEOVER_HIGHLIGHTER

public static final int MOUSEOVER_HIGHLIGHTER
the mouse over highlighter type

See Also:
Constant Field Values

RULER_HIGHLIGHTER

public static final int RULER_HIGHLIGHTER
the "measurement" highlighter type

See Also:
Constant Field Values

EXACTSELECTDISTANCE

public static final int EXACTSELECTDISTANCE
the max pixel distance that's acceptable selection

See Also:
Constant Field Values
Constructor Detail

Highlighter

public Highlighter(int type,
                   WindowFrame wf)
Create a new Highlighter object

Parameters:
type -
Method Detail

delete

public void delete()
Destructor


addElectricObject

public Highlight2 addElectricObject(ElectricObject eobj,
                                    Cell cell)
Method to add an ElectricObject to the list of highlighted objects.

Parameters:
eobj - the ElectricObject to add to the list of highlighted objects.
cell - the Cell in which the ElectricObject resides.
Returns:
the newly created Highlight object.

addElectricObject

public Highlight2 addElectricObject(ElectricObject eobj,
                                    Cell cell,
                                    boolean highlightConnected)
Method to add an ElectricObject to the list of highlighted objects.

Parameters:
eobj - the ElectricObject to add to the list of highlighted objects.
cell - the Cell in which the ElectricObject resides.
highlightConnected - if true, highlight all objects that are in some way connected to this object. If false, do not. This is used by addNetwork to prevent extra things from being highlighted later that are not connected to the network.
Returns:
the newly created Highlight object.

addElectricObject

public Highlight2 addElectricObject(ElectricObject eobj,
                                    Cell cell,
                                    java.awt.Color col)
Method to add an ElectricObject to the list of highlighted objects.

Parameters:
eobj - the ElectricObject to add to the list of highlighted objects.
cell - the Cell in which the ElectricObject resides.
Returns:
the newly created Highlight object.

addElectricObject

public Highlight2 addElectricObject(ElectricObject eobj,
                                    Cell cell,
                                    boolean highlightConnected,
                                    java.awt.Color col)
Method to add an ElectricObject to the list of highlighted objects.

Parameters:
eobj - the ElectricObject to add to the list of highlighted objects.
cell - the Cell in which the ElectricObject resides.
highlightConnected - if true, highlight all objects that are in some way connected to this object. If false, do not. This is used by addNetwork to prevent extra things from being highlighted later that are not connected to the network.
Returns:
the newly created Highlight object.

addText

public Highlight2 addText(ElectricObject eobj,
                          Cell cell,
                          Variable.Key varKey)
Method to add a text selection to the list of highlighted objects.

Parameters:
cell - the Cell in which this area resides.
varKey - the Variable.Key associated with the text (text is then a visual of that variable).
Returns:
the newly created Highlight object.

addMessage

public Highlight2 addMessage(Cell cell,
                             java.lang.String message,
                             java.awt.geom.Point2D loc)
Method to add a message display to the list of highlighted objects.

Parameters:
cell - the Cell in which this area resides.
message - the String to display.
loc - the location of the string (in database units).
Returns:
the newly created Highlight object.

addMessage

public Highlight2 addMessage(Cell cell,
                             java.lang.String message,
                             java.awt.geom.Point2D loc,
                             int corner)
Method to add a message display to the list of highlighted objects.

Parameters:
cell - the Cell in which this area resides.
message - the String to display.
loc - the location of the string (in database units).
corner - 0=lowerLeft, 1=upperLeft, 2=upperRight, 3=lowerRight.
Returns:
the newly created Highlight object.

addArea

public Highlight2 addArea(java.awt.geom.Rectangle2D area,
                          Cell cell)
Method to add an area to the list of highlighted objects.

Parameters:
area - the Rectangular area to add to the list of highlighted objects.
cell - the Cell in which this area resides.
Returns:
the newly created Highlight object.

addObject

public Highlight2 addObject(java.lang.Object obj,
                            Cell cell)
Method to generic Object.

Parameters:
obj - object to add.
cell - the Cell in which this object resides.
Returns:
the newly created Highlight object.

addLine

public Highlight2 addLine(java.awt.geom.Point2D start,
                          java.awt.geom.Point2D end,
                          Cell cell)
Method to add a line to the list of highlighted objects.

Parameters:
start - the start point of the line to add to the list of highlighted objects.
end - the end point of the line to add to the list of highlighted objects.
cell - the Cell in which this line resides.
Returns:
the newly created Highlight object.

addLine

public Highlight2 addLine(java.awt.geom.Point2D start,
                          java.awt.geom.Point2D end,
                          Cell cell,
                          boolean thick)
Method to add a line to the list of highlighted objects.

Parameters:
start - the start point of the line to add to the list of highlighted objects.
end - the end point of the line to add to the list of highlighted objects.
cell - the Cell in which this line resides.
thick - true for a thick line.
Returns:
the newly created Highlight object.

addThickLine

public Highlight2 addThickLine(java.awt.geom.Point2D start,
                               java.awt.geom.Point2D end,
                               Cell cell)
Method to add a line to the list of highlighted objects.

Parameters:
start - the start point of the line to add to the list of highlighted objects.
end - the end point of the line to add to the list of highlighted objects.
cell - the Cell in which this line resides.
Returns:
the newly created Highlight object.

addPoly

public Highlight2 addPoly(Poly poly,
                          Cell cell,
                          java.awt.Color color)
Method to add a Poly to the list of highlighted objects

Parameters:
poly - the poly to add
cell - the cell in which to display the poly
color - the color to draw the poly with (if null, uses default)
Returns:
the newly created highlight object

addNetwork

public void addNetwork(Network net,
                       Cell cell)
Method to add a network to the list of highlighted objects. Many arcs may be highlighted as a result.

Parameters:
net - the network to highlight.
cell - the Cell in which this line resides.

showNetworks

public void showNetworks(Cell cell)
This is the show network command. It is similar to addNetwork, however each time it is used without first clearing the highlighter, it shows connections to the network another level down in the hierarchy.

Parameters:
cell - the cell in which to create the highlights

addHighlight

public void addHighlight(Highlight2 h)
Add a Highlight


clear

public void clear()
Method to clear the list of all highlighted objects in


finished

public void finished()
Method to indicate that changes to highlighting are finished. Call this after any change to highlighting.


ensureHighlightingSeen

public void ensureHighlightingSeen()
Method to ensure that the highlighting is visible. If the highlighting is offscreen, flash an arrow towards it. If the highlighting is small, flash lines around it.


copyState

public void copyState(Highlighter highlighter)
Inherits the last selected object from the specified highlighter. This is a hack, don't use it.

Parameters:
highlighter -

showHighlights

public void showHighlights(EditWindow wnd,
                           java.awt.Graphics g)
Shows highlights for the current EditWindow

Parameters:
wnd -
g -

getWindowFrame

public WindowFrame getWindowFrame()
Method to return the WindowFrame associated with this Highlighter.

Returns:
the WindowFrame associated with this Highlighter. Returns null if no WindowFrame is associated.

addHighlightListener

public static void addHighlightListener(HighlightListener l)
Add a Highlight listener


removeHighlightListener

public static void removeHighlightListener(HighlightListener l)
Remove a Highlight listener


gainedFocus

public void gainedFocus()
Called when the Highlighter owner has gained focus, and the current highlighter switches to this.


pushHighlight

public void pushHighlight()
Method to push the current highlight list onto a stack.


popHighlight

public void popHighlight()
Method to pop the current highlight list from the stack.


remove

public void remove(Highlight2 h)
Removes a Highlight object from the current set of highlights.

Parameters:
h - the Highlight to remove

getNumHighlights

public int getNumHighlights()
Method to return the number of highlighted objects.

Returns:
the number of highlighted objects.

getHighlights

public java.util.List<Highlight2> getHighlights()
Method to return a list that is a copy of the list of current highlights.

Returns:
an list of highlights

setHighlightListGeneral

public void setHighlightListGeneral(java.util.List<Highlight2> newHighlights)
Method to load a list of Highlights into the highlighting.

Parameters:
newHighlights - a List of Highlight objects.

setHighlightList

public void setHighlightList(java.util.List<Highlight2> newHighlights)
Method to load a list of Highlights into the highlighting.

Parameters:
newHighlights - a List of Highlight objects.

getHighlightedEObjs

public java.util.List<Geometric> getHighlightedEObjs(boolean wantNodes,
                                                     boolean wantArcs)
Method to return a List of all highlighted Geometrics.

Parameters:
wantNodes - true if NodeInsts should be included in the list.
wantArcs - true if ArcInsts should be included in the list.
Returns:
a list with the highlighted Geometrics.

getHighlightedNodes

public java.util.List<NodeInst> getHighlightedNodes()
Method to return a List of all highlighted NodeInsts.

Returns:
a list with the highlighted NodeInsts.

getHighlightedArcs

public java.util.List<ArcInst> getHighlightedArcs()
Method to return a List of all highlighted ArcInsts.

Returns:
a list with the highlighted ArcInsts.

getHighlightedNetworks

public java.util.Set<Network> getHighlightedNetworks()
Method to return a set of the currently selected networks.

Returns:
a set of the currently selected networks. If there are no selected networks, the list is empty.

getHighlightedText

public java.util.List<DisplayedText> getHighlightedText(boolean unique)
Method to return a List of all highlighted text.

Parameters:
unique - true to request that the text objects be unique, and not attached to another object that is highlighted. For example, if a node and an export on that node are selected, the export text will not be included if "unique" is true.
Returns:
a list with the Highlight objects that point to text.

getHighlightedArea

public java.awt.geom.Rectangle2D getHighlightedArea(EditWindow wnd)
Method to return the bounds of the highlighted objects.

Parameters:
wnd - the window in which to get bounds.
Returns:
the bounds of the highlighted objects (null if nothing is highlighted).

getOneHighlight

public Highlight2 getOneHighlight()
Method to return the only highlight that encompases an object in Cell cell. If there is not one highlighted object, an error is issued.

Returns:
the highlight that selects an object (null if error).

getOneElectricObject

public ElectricObject getOneElectricObject(java.lang.Class type)
Method to return the only highlighted object. If there is not one highlighted object, an error is issued.

Returns:
the highlighted object (null if error).

setHighlightOffset

public void setHighlightOffset(int offX,
                               int offY)
Method to set a screen offset for the display of highlighting.

Parameters:
offX - the X offset (in pixels) of the highlighting.
offY - the Y offset (in pixels) of the highlighting.

getHighlightOffset

public java.awt.geom.Point2D getHighlightOffset()
Method to return the screen offset for the display of highlighting

Returns:
a Point2D containing the x and y offset.

selectArea

public void selectArea(EditWindow wnd,
                       double minSelX,
                       double maxSelX,
                       double minSelY,
                       double maxSelY,
                       boolean invertSelection,
                       boolean findSpecial)
Method to add everything in an area to the selection.

Parameters:
wnd - the window being examined.
minSelX - the low X coordinate of the area in database units.
maxSelX - the high X coordinate of the area in database units.
minSelY - the low Y coordinate of the area in database units.
maxSelY - the high Y coordinate of the area in database units.
invertSelection - is true to invert the selection (remove what is already highlighted and add what is new).
findSpecial - is true to find hard-to-select objects.

overHighlighted

public Highlight2 overHighlighted(EditWindow wnd,
                                  int x,
                                  int y)
Method to tell whether a point is over this Highlight.

Parameters:
wnd - the window being examined.
x - the X screen coordinate of the point.
y - the Y screen coordinate of the point.
Returns:
Highlight2 if the point is over this Highlight.

describeHighlightText

public static java.awt.geom.Point2D[] describeHighlightText(EditWindow wnd,
                                                            ElectricObject eObj,
                                                            Variable.Key varKey)
Method to describe an object/variable-key pair as a set of points to draw.

Parameters:
wnd - the EditWindow in which the object/variable-key is displayed.
eObj - the object.
varKey - the variable-key.
Returns:
the set of points to draw, two points per line. Returns null on error.

findObject

public Highlight2 findObject(java.awt.geom.Point2D pt,
                             EditWindow wnd,
                             boolean exclusively,
                             boolean another,
                             boolean invert,
                             boolean findPort,
                             boolean findPoint,
                             boolean findSpecial,
                             boolean findText)
Method to handle a click in a window and select the appropriate objects.

Parameters:
pt - the coordinates of the click (in database units).
wnd - the window being examined.
exclusively - true if the currently selected object must remain selected. This happens during "outline edit" when the node doesn't change, just the point on it.
another - true to find another object under the point (when there are multiple ones).
invert - true to invert selection (add if not selected, remove if already selected).
findPort - true to also show the closest port on a selected node.
findPoint - true to also show the closest point on a selected outline node.
findSpecial - true to select hard-to-find objects.
findText - true to select text objects. The name of an unexpanded cell instance is always hard-to-select. Other objects are set this way by the user (although the cell-center is usually set this way).

findAllInArea

public static java.util.List<Highlight2> findAllInArea(Highlighter highlighter,
                                                       Cell cell,
                                                       boolean exclusively,
                                                       boolean another,
                                                       boolean findPort,
                                                       boolean findPoint,
                                                       boolean findSpecial,
                                                       boolean findText,
                                                       java.awt.geom.Rectangle2D bounds,
                                                       EditWindow wnd)
Method to search a Cell for all objects at a point.

Parameters:
cell - the cell to search.
exclusively - true if the currently selected object must remain selected. This happens during "outline edit" when the node doesn't change, just the point on it.
another - true to find another object under the point (when there are multiple ones).
findPort - true to also show the closest port on a selected node.
findPoint - true to also show the closest point on a selected outline node.
findSpecial - true to select hard-to-find objects.
findText - true to select text objects. The name of an unexpanded cell instance is always hard-to-select. Other objects are set this way by the user (although the cell-center is usually set this way).
bounds - the area of the search (in database units).
wnd - the window being examined (null to ignore window scaling).
Returns:
a list of Highlight objects. The list is ordered by importance, so the deault action is to select the first entry.

checkOutObject

public static Highlight2 checkOutObject(Geometric geom,
                                        boolean findPort,
                                        boolean findPoint,
                                        boolean findSpecial,
                                        java.awt.geom.Rectangle2D bounds,
                                        EditWindow wnd,
                                        double directHitDist,
                                        boolean areaMustEnclose)
Method to determine whether an object is in a bounds.

Parameters:
geom - the Geometric being tested for selection.
findPort - true if a port should be selected with a NodeInst.
findPoint - true if a point should be selected with an outline NodeInst.
findSpecial - true if hard-to-select and other special selection is being done.
bounds - the selected area or point.
wnd - the window being examined (null to ignore window scaling).
directHitDist - the slop area to forgive when searching (a few pixels in screen space, transformed to database units).
areaMustEnclose - true if the object must be completely inside of the selection area.
Returns:
a Highlight that defines the object, or null if the point is not over any part of this object.

getSimiliarHighlight

public static Highlight2 getSimiliarHighlight(java.util.List<Highlight2> highlights,
                                              Highlight2 exampleHigh)
Chooses a single Highlight from the list of Highlights 'highlights' that is most similar to Highlight 'exampleHigh'.

Parameters:
highlights - a list of Highlight Objects
exampleHigh - the Highlight that serves as an example of what type of Highlight should be retrieved from the highlights list.

distToNode

public static double distToNode(java.awt.geom.Rectangle2D bounds,
                                NodeInst ni,
                                EditWindow wnd)
Method to return the distance from a bound to a NodeInst.

Parameters:
bounds - the bounds in question.
ni - the NodeInst.
wnd - the window being examined (null to ignore text/window scaling).
Returns:
the distance from the bounds to the NodeInst. Negative values are direct hits.

distToArc

public static double distToArc(java.awt.geom.Rectangle2D bounds,
                               ArcInst ai,
                               EditWindow wnd)
Method to return the distance from a bounds to an ArcInst.

Parameters:
bounds - the bounds in question.
ai - the ArcInst.
wnd - the window being examined.
Returns:
the distance from the bounds to the ArcInst. Negative values are direct hits or intersections.

databaseChanged

public void databaseChanged(DatabaseChangeEvent e)
Description copied from interface: DatabaseChangeListener
Invoked in the java AWT Event thread when the database state changes.

Specified by:
databaseChanged in interface DatabaseChangeListener
Parameters:
e - database change event.