|
Graphics2D Actor API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectg2d.glyph.Identifiable
g2d.glyph.Attributable
g2d.glyph.Glyphish
g2d.glyph.GlyphList
g2d.graph.IOPGraph
public class IOPGraph
Represents a directed graph as a list of glyphish things. The graph
consists of nodes and edges, and is laid out by querying dot. For
large graphs it is possible to optimize the expensive methods of
painting and hit detecting by using a superimposed
subgrid Manifold. One can also request a thumbnail Image
of the graph.
| Field Summary |
|---|
| Fields inherited from class g2d.glyph.Glyphish |
|---|
DEBUG |
| Fields inherited from class g2d.glyph.Identifiable |
|---|
uid |
| Constructor Summary | |
|---|---|
IOPGraph()
Constructs an IOPGraph object. |
|
IOPGraph(String r)
Constructs an IOPGraph object with given layout. |
|
| Method Summary | |
|---|---|
void |
add2Manifold(Glyphish glyph)
Adds a glyph to the appropriate charts in the manifold. |
void |
addChangeListener(ChangeListener cl)
Adds a listener to those registered for change events. |
void |
addEdge(IOPEdge e)
Adds an edge to the graph. |
void |
addNode(IOPNode n)
Adds a node to the graph. |
void |
clear()
Resets the graph to be empty. |
void |
cloneFromGraph(IOPGraph clone)
Clone nodes and edges in this graph from given graph. |
void |
createManifold()
This procedure creates, but doesn't initialize, the covering manifold. |
boolean |
doLayout()
Lays out an already existing graph. |
void |
fireChange()
Is used to notify all those listeners registered that the graph has changed. |
static boolean |
getAntiAliased()
Fetches the current antialiasing setting. |
BufferedImage |
getBufferedImage(double scale)
Obtain a scaled, buffered image of this graph. |
IOPEdge |
getEdge(IOPNode source,
IOPNode sink)
Obtain edge between given source and sink nodes. |
IOPEdge |
getEdge(Point2D p)
Obtain (one) edge that contains given point or null if
none of the edges intersects with point. |
IOPEdge |
getEdge(Point2D p,
double distance)
Obtain edge that intersects with square around given point of side length distance/2, or null if no such edge is found. |
IOPEdge[] |
getEdgesInArray()
Returns the edges in an array of IOPEdges. |
Glyphish |
getGlyphThing(Point2D p)
Overrides the method in the Glyphish hierarchy. |
GraphItem |
getGraphItem(Point2D p,
double distance)
Find a graph item (node or edge) that contains given point. |
double |
getHeight()
Returns the height of the graph. |
IOPNode |
getNode(Point2D p)
Attempt to find a node located at a particular point. |
IOPNode |
getNode(String id)
Obtain node with given ID in this graph. |
IOPNode[] |
getNodesInArray()
Returns the nodes in an array of IOPNodes. |
Image |
getThumbNail(int how,
int thumbWidth,
int thumbHeight,
Component comp,
int hints)
Constructs an thumbnail image of the graph. |
double |
getWidth()
Returns the width of the graph. |
HashMap |
makeAdjacencyList()
Creates a new adjacency list. |
String |
makeDotInput()
Produces a string that describes this graph, in dot format. |
void |
paint(Graphics2D g2d,
Rectangle2D r)
Overrides the method in the Glyphish hierarchy. |
void |
printAdjacencyList()
Prints, to the error stream, the adjacency list. |
void |
removeChangeListener(ChangeListener cl)
Removes a listener to those registered for change events. |
void |
rmEdge(IOPEdge e)
Removes an edge from the graph. |
void |
rmNode(IOPNode n)
Removes a node the graph. |
static void |
setAntiAliased(boolean value)
Sets whether or not antialiasing is used in drawing the graph. |
boolean |
setGraph(File file)
Creates a graph from a stored file, in dot format. |
void |
setHeight(double h)
Sets the height of the graph. |
void |
setStrokeWidth(float width)
Sets the stroke width of all edges. |
void |
setWidth(double w)
Sets the width of the graph. |
int |
size()
The size of the glyph, i.e. the sum of the number of nodes and edges. |
void |
writeGraph(File file)
Writes the graph out to a file, in dot format. |
| Methods inherited from class g2d.glyph.GlyphList |
|---|
add, add, contains, getBounds, getListIterator, inside, intersects, length, paint, remove, transform |
| Methods inherited from class g2d.glyph.Glyphish |
|---|
keyPressed, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, rotate, rotate, scale, setKeyAction, setMouseAction, shear, translate |
| Methods inherited from class g2d.glyph.Attributable |
|---|
getAttribute, getAttributeAsBoolean, getAttributeAsByte, getAttributeAsChar, getAttributeAsDouble, getAttributeAsFloat, getAttributeAsInt, getAttributeAsShort, getAttributeAsString, getKeys, getStaticAttribute, getStaticKeys, isAttribute, isStaticAttribute, setAttribute, setStaticAttribute |
| Methods inherited from class g2d.glyph.Identifiable |
|---|
getObject, getUID, setUID |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public IOPGraph()
"TB" for
top to bottom.
public IOPGraph(String r)
r - String indicating how to layout the graph, it should
either be "LR" for left to right, or "TB" for
top to bottom.| Method Detail |
|---|
public void cloneFromGraph(IOPGraph clone)
clone - IOPGraph to be cloned in this graphpublic BufferedImage getBufferedImage(double scale)
scale - Factor by which image should be scaled
null if size is 0
public Image getThumbNail(int how,
int thumbWidth,
int thumbHeight,
Component comp,
int hints)
If the graph is empty returns NULL.
how - specifies the way the thumbnail is made. -1
requests that its is made by Java using an offscreen image.
Alternatively it can be made via dot using various formats:
g2d.graph.Dot.GIF
g2d.graph.Dot.PNG
g2d.graph.Dot.JPG
thumbWidth - is the maximum width in pixels of the resulting thumbnail.thumbHeight - is the maximum height in pixels of the resulting thumbnail.comp - is a component used to obtain the necessary media tracker.hints - is the scaling hint used to produce the thumbnail, see
Image.
Reasonable choices are:
java.awt.Image.SCALE_SMOOTH and java.awt.Image.SCALE_FAST.
public void createManifold()
Manifold class.
public void add2Manifold(Glyphish glyph)
glyph - the glyph to be added to all those charts that it's
bounding rectangle has non-trivial intersection with.
public void paint(Graphics2D g2d,
Rectangle2D r)
Glyphish hierarchy.
Is optimized to use the manifold, if it is present.
paint in class Glyphishg2d - the graphics object to be used to do the painting.r - the rectangle that requires painting.public Glyphish getGlyphThing(Point2D p)
Glyphish hierarchy.
Is optimized to use the manifold, if it is present.
getGlyphThing in class GlyphListp - the point where a glyph is sort.
public int size()
THRESHOLD
in the Manifold then a manifold is constructed for
this graph.
public static void setAntiAliased(boolean value)
value - the desired settinggetAntiAliased()public static boolean getAntiAliased()
setAntiAliased(boolean)public void setStrokeWidth(float width)
width - the desired stroke width, a float.public void addNode(IOPNode n)
null.
Notifies all the registered change listeners otherwise.
n - IOPNode to be addedpublic void rmNode(IOPNode n)
null.
Notifies all the registered change listeners otherwise.
n - IOPNode to be removedpublic void addEdge(IOPEdge e)
null.
Notifies all the registered change listeners otherwise.
e - IOPEdge to be addedpublic void rmEdge(IOPEdge e)
null.
Notifies all the registered change listeners otherwise.
e - IOPEdge to be removedpublic HashMap makeAdjacencyList()
public void printAdjacencyList()
public void clear()
clear in class GlyphListpublic boolean setGraph(File file)
file - from which the graph is to be loaded
public String makeDotInput()
public boolean doLayout()
public void writeGraph(File file)
file - to be written.public IOPEdge getEdge(Point2D p)
null if
none of the edges intersects with point.
p - Point that indicates edge to be retrieved
null
if no edge is found intersecting)
public IOPEdge getEdge(Point2D p,
double distance)
null if no such edge is found.
This method first computes all eligible candidates by intersecting
all edges with a square of side length distance/2 and then
determines the (approximately) closest one among these.
p - Point to define center of square where to look for edgedistance - side length of square to find edge
null if no edge is found intersecting)public IOPNode getNode(Point2D p)
p - the desired location
null if there is none
public GraphItem getGraphItem(Point2D p,
double distance)
p - Point to use for finding graph item (cannot be NULL)distance - Maximum distance that clicked point may be away from edge
public IOPNode[] getNodesInArray()
IOPNodes.
public IOPNode getNode(String id)
id - String with ID of desired node
null otherwisepublic IOPEdge[] getEdgesInArray()
IOPEdges.
public IOPEdge getEdge(IOPNode source,
IOPNode sink)
source - IOPNode that is source of desired edge
(cannot be null!)sink - IOPNode that is sink of desired edge
(cannot be null!)
null otherwisepublic void setHeight(double h)
h - the desired height, a double.getHeight()public void setWidth(double w)
w - the desired width, a double.getWidth()public double getHeight()
setHeight(double)public double getWidth()
setWidth(double)public void addChangeListener(ChangeListener cl)
cl - the new listenerremoveChangeListener(javax.swing.event.ChangeListener)public void removeChangeListener(ChangeListener cl)
cl - the new listeneraddChangeListener(javax.swing.event.ChangeListener)public void fireChange()
|
Graphics2D Actor API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||