public class Graph extends Concept implements Printable, KnowledgeSource
The drawing of graphs as contexts is outlined as follows:
GraphObject.Kind, GraphObject.ObjectIDComparator| Modifier and Type | Field and Description |
|---|---|
static int |
contextBorderWidth
The actual width of the context's displayed border; included in its
displayRect
|
static int |
contextInnerPadding
The "breathing room" spacing inside a context's border
|
String |
createdTimeStamp |
String |
modifiedTimeStamp |
HashMap<String,GraphObject> |
objectHashStore
Holds the list of objects owned by this graph.
|
protected EditFrame |
ownerFrame
The user interface frame that contains this graph.
|
Point2D |
textCenterPt |
int |
wrapColumns |
boolean |
wrapLabels |
refDone, referent, TEXT_HEIGHT, TEXT_WIDTHborderOutlineWidth, dashpattern, descriptors, mark, myedges, showBoringDebugInfoFont, typeLabelbackColor, defaultDim, defaultSelectColor, defaultWrapColumns, defaultWrapLabels, displayRect3D, foreColor, highlightColor, history, isSelected, labelFont, myKind, objectID, objectMargin, ownerGraph, TerritorialLimit, textLabel, textLabelLowerLeftPt| Constructor and Description |
|---|
Graph()
Constructs a new Graph object, with a given parent graph within which it
is enclosed.
|
Graph(Graph g)
Constructs a new Graph object, with a given parent graph within which it
is enclosed.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abandonObject()
Makes the object expendable from the CharGer graph.
|
void |
addHistory(chargerlib.history.ObjectHistoryRecord he)
Add the history event to all objects in the graph
|
boolean |
commitToKnowledgeBase(KnowledgeBase kb)
Perform whatever activities are required for this concept to be committed to a knowledge base.
|
boolean |
containsGraphObjects(ArrayList<GraphObject> graphobjects)
Determines whether every node in the list is contained in the
graph.
|
void |
dispose()
Invokes forgetObject on all the objects (including nested ones) in this
graph.
|
void |
draw(Graphics2D g2D,
boolean printing)
Renders the graph, recursively rendering all of it contents.
|
void |
drawBorder(Graphics2D g,
Color borderColor)
Draws the border of a context.
|
protected void |
finalize() |
GraphObject |
findByID(GraphObjectID ID)
Find an object by its ID at any level in the target graph.
|
AbstractTypeDescriptor[] |
findTypeDescriptors(String term)
Look for descriptors for the given term in the knowledge source, however
it may be remembered.
|
boolean |
forceDeepMove(Point2D.Double delta)
Forces an unverified move for the graph and all its contained objects.
|
static boolean |
forceMoveGraphObjects(ArrayList<GraphObject> objectsToMove,
Point2D.Double delta)
Forces an un-verified move of all objects, with identical moves for all objects.
|
void |
forgetObject(GraphObject go)
Removes object from this graph, removes it from the knowledge base and
logically garbages the object.
|
Graph[] |
getAllGraphs()
Get all the graphs known to this knowledge source.
|
AbstractTypeDescriptor[] |
getAllTypeDescriptors()
Get all the type descriptors known to this knowledge source.
|
String |
getBriefSummary()
Create a short summary of the number of objects and their types.
|
Rectangle2D.Double |
getContentBounds()
Determines the region that a graph's contents require.
|
Rectangle2D.Double |
getDisplayBounds()
Determines how much space it takes to render the graph on a canvas.
|
int |
getGraphObjectCount()
Return the number of objects (including edges) in this graph
|
ArrayList<GraphObject> |
getGraphObjects() |
EditFrame |
getOwnerFrame()
Find the user window (if any) associated with this graph.
|
Rectangle2D.Double |
getRegionAvailableForContent()
Starting with the graph's already-defined display rectangle,
takes into account the context's border, the margin, and the current
label's height.
|
Shape |
getShape()
Find the outer boundary of the graph, taking into account the border width,
but does NOT consider shadows (we let arrows and other things cover up shadows).
|
Shape |
getShapeForDrawing()
Finds the center line of the border, so that drawing the border will
take place entirely within the display rectangle.
|
private void |
graphConstructor(Graph g) |
Iterator<GraphObject> |
graphObjects()
Get an iterator for all the given graph's objects (including edges).
|
void |
handleContextLinks()
Recursively descend in target graph, cutting/changing links as needed.
|
void |
insertInCharGerGraph(GraphObject go)
Attaches the given graph object to a CharGer graph, but doesn't do any
consistency check.
|
void |
insertObject(GraphObject go)
Inserts an object into the graph, proposing the target graph as its
owner.
|
boolean |
isEmpty()
Determines whether there are any objects in this graph.
|
void |
layoutGraph()
Apply the spring graph layout algorithm to this graph, using
the preferred edge length.
|
void |
layoutGraph(double edgeLength)
Apply the spring graph layout algorithm to this graph.
|
EditingChangeState |
moveGraph(Point2D.Double translation)
Adjust all objects to be offset by the translation vector.
|
EditingChangeState |
moveGraphObjects(ArrayList<GraphObject> objectsToMove,
Point2D.Double delta)
Moves a set of objects on the canvas through a common x,y displacement.
|
boolean |
nestedWithin(Graph gouter)
Determines whether this graph is nested (at any level) within a given graph.
|
int |
print(Graphics g,
PageFormat pf,
int pageIndex)
Used by the PrintJob class to print the graph.
|
void |
removeFromGraph(GraphObject go)
Detaches the given graph object from a CharGer graph.
|
void |
resizeForContents(Point2D.Double center)
Looks at every object in target graph and adjusts the graph's displayRect
to enclose them.
|
String |
safeString()
String-ifies graph with objects in an order that has no internal forward
references, using version 3's format.
|
String |
safeString2()
String-ifies graph with objects in an order that has no internal forward
references.
|
void |
setCenter()
Sets the position of this graph to be its center.
|
void |
setCenter(Point2D.Double p)
Calls the super's setCenter, changes the textLabelLowerLeftPt
point to put the label in the upper left hand corner of the context.
|
void |
setOwnerFrame(EditFrame ef)
Sets the editing window frame that contains this graph.
|
void |
setRegionAvailableForContent(Rectangle2D.Double rect)
Sets the display rect of the graph to contain the content as well as the
border, margin and label.
|
void |
setSize(Dimension size) |
void |
setTextLabel(String s,
FontMetrics fmetrics,
Point2D.Double p)
Sets the text label of the graph object.
|
void |
setTextLabelPos()
Sets the position of the text label, based on the center point.
|
String |
toString()
Gives a CharGer-formatted version of the target graph, with objects in
arbitrary order.
|
String |
toStringDeep(boolean deep)
Returns graph objects in a CharGer-formatted string
|
boolean |
unCommitFromKnowledgeBase(KnowledgeBase kb)
Perform whatever activities are required for this concept to be deleted from a knowledge base.
|
getReferent, getTypeLabel, parseTextLabel, setReferent, setReferent, setTextLabel, setTypeLabel, setTypeLabel, UnCommitFromKnowledgeBaseadjustEdges, attachGEdge, CGIFStringGNodeEdges, clearDescriptors, deleteGEdge, drawActivated, drawDebuggingInfo, getDisplayRect, getEdges, getLinkedNodes, getLinkedNodes, getSize, getTypeDescriptor, getTypeDescriptors, isActive, isChanged, setActive, setChanged, setTypeDescriptor, setTypeDescriptorsaddHistoryRecord, adjustCustomDisplayRect, findDominantContext, forceMove, forgetObject, getBestFontMetrics, getCenter, getColor, getDepth, getDim, getDisplayRect3D, getHistory, getLabelFont, getMinimumContentSize, getObjectLocator, getOutermostGraph, getOwnerGraph, getTextLabel, getTextLabelSize, getUpperLeft, getWrapColumns, getWrapLabels, isNegated, isNegativelyNested, listToString, listToStringXML, putInCorrectContext, putInCorrectContext, resizeIfNecessary, resizeIfNecessary, selfCleanup, setBackground, setCenterOnly, setColor, setColor, setDepth, setDim, setDim, setDisplayRect, setDisplayRect, setDisplayRect3D, setForeground, setLabelFont, setNegated, setOwnerGraph, setTextLabel, setUpperLeft, setUpperLeftpublic HashMap<String,GraphObject> objectHashStore
findByID(charger.obj.GraphObjectID)public static int contextBorderWidth
public static int contextInnerPadding
public Point2D textCenterPt
protected EditFrame ownerFrame
public String createdTimeStamp
public String modifiedTimeStamp
public boolean wrapLabels
public int wrapColumns
public Graph(Graph g)
g - existing graph to which this one is to be subordinate; null if
there isn't one.public Graph()
private void graphConstructor(Graph g)
public EditFrame getOwnerFrame()
getOwnerFrame in class GraphObjectpublic void setOwnerFrame(EditFrame ef)
public void setCenter()
setCenter in class GNodesetCenter()public void setCenter(Point2D.Double p)
setCenter in class GNodep - the new center point, although internally the top left corner is
saved in the displayRect.GNode.setCenter()public void setTextLabelPos()
public int print(Graphics g,
PageFormat pf,
int pageIndex)
throws PrinterException
print in interface PrintablePrinterExceptionEditManager.performActionPrintGraph()public Shape getShape()
getShape in class ConceptGraphObject.getShape()public Shape getShapeForDrawing()
getShapeForDrawing in class GraphObjectpublic Rectangle2D.Double getRegionAvailableForContent()
public void setRegionAvailableForContent(Rectangle2D.Double rect)
rect - public void drawBorder(Graphics2D g,
Color borderColor)
drawBorder in class GNodeg - Graphics context on which the object is to be renderedborderColor - the color to drawdraw(java.awt.Graphics2D, boolean)public void draw(Graphics2D g2D,
boolean printing)
public void insertInCharGerGraph(GraphObject go)
public void removeFromGraph(GraphObject go)
public boolean forceDeepMove(Point2D.Double delta)
delta - public static boolean forceMoveGraphObjects(ArrayList<GraphObject> objectsToMove, Point2D.Double delta)
objectsToMove - delta - public EditingChangeState moveGraphObjects(ArrayList<GraphObject> objectsToMove, Point2D.Double delta)
delta - the translation displacementobjectsToMove - the collection of objects to be displacedpublic void insertObject(GraphObject go)
go - Object to be added to the target graph.insertInCharGerGraph(charger.obj.GraphObject),
forgetObject(charger.obj.GraphObject)public void forgetObject(GraphObject go)
go - object to be erased from target graphpublic void setTextLabel(String s,
FontMetrics fmetrics,
Point2D.Double p)
setTextLabel in class GraphObjects - new text label (erases the old text label)fmetrics - font metrics needed in case the label is too big or
requires resizing the graphp - the point around which the label is centeredpublic void resizeForContents(Point2D.Double center)
center - Center point around which to adjust the display rect;
null means to move the center point if necessary. Leaves
dimensions alone unless they don't enclose the contents.public boolean nestedWithin(Graph gouter)
gouter - is the potential outermost graphpublic boolean containsGraphObjects(ArrayList<GraphObject> graphobjects)
graphobjects - Collection of objectspublic void handleContextLinks()
Global.allowActorLinksAcrossContextspublic GraphObject findByID(GraphObjectID ID)
ID - a graph IDGlobal.applyForID()public void abandonObject()
abandonObject in class GNodeprotected void finalize()
throws Throwable
finalize in class ConceptThrowableforgetObject(charger.obj.GraphObject)public String getBriefSummary()
public Rectangle2D.Double getContentBounds()
getDisplayBounds()public Rectangle2D.Double getDisplayBounds()
getContentBounds()public EditingChangeState moveGraph(Point2D.Double translation)
translation - public boolean isEmpty()
true if there's at least one object in the
graph; false otherwise.public String safeString()
public String safeString2()
public String toString()
toString in class GraphObjectIOManagerpublic String toStringDeep(boolean deep)
deep - Whether to recursively fetch graph objects or not.GraphObject.toString(),
safeString(),
toStringDeep(boolean)public Iterator<GraphObject> graphObjects()
public int getGraphObjectCount()
public void dispose()
forgetObject(charger.obj.GraphObject)public ArrayList<GraphObject> getGraphObjects()
public void setSize(Dimension size)
public void layoutGraph(double edgeLength)
edgeLength - the equilibrium edge length desired.SpringGraphLayoutpublic void layoutGraph()
SpringGraphLayoutpublic void addHistory(chargerlib.history.ObjectHistoryRecord he)
he - public AbstractTypeDescriptor[] findTypeDescriptors(String term)
findTypeDescriptors in interface KnowledgeSourceterm - a phrase that may have type descriptors.public AbstractTypeDescriptor[] getAllTypeDescriptors()
getAllTypeDescriptors in interface KnowledgeSourcepublic Graph[] getAllGraphs()
getAllGraphs in interface KnowledgeSourcepublic boolean commitToKnowledgeBase(KnowledgeBase kb)
commitToKnowledgeBase in class Conceptkb - public boolean unCommitFromKnowledgeBase(KnowledgeBase kb)
unCommitFromKnowledgeBase in class GraphObjectkb -