public abstract class AbstractLayoutAlgorithm extends java.lang.Object implements LayoutAlgorithm, Stoppable
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Comparator |
comparator |
protected Filter |
filter |
protected boolean |
internalAsynchronous |
protected boolean |
internalContinuous |
protected int |
layout_styles |
protected boolean |
layoutStopped |
static int |
MIN_ENTITY_SIZE |
protected boolean |
resizeEntitiesAfterLayout |
| Constructor and Description |
|---|
AbstractLayoutAlgorithm(int styles)
Initializes the abstract layout algorithm.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEntity(LayoutEntity entity)
Queues up the given entity (if it isn't in the list) to be added to the algorithm.
|
void |
addProgressListener(ProgressListener listener)
A layout algorithm could take an uncomfortable amout of time to complete.
|
void |
addRelationship(LayoutRelationship relationship)
Queues up the given relationshp (if it isn't in the list) to be added to the algorithm.
|
void |
applyLayout(LayoutEntity[] entitiesToLayout,
LayoutRelationship[] relationshipsToConsider,
double x,
double y,
double width,
double height,
boolean asynchronous,
boolean continuous)
This actually applies the layout
|
protected abstract void |
applyLayoutInternal(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider,
double boundsX,
double boundsY,
double boundsWidth,
double boundsHeight)
Apply the layout to the given entities.
|
protected void |
defaultFitWithinBounds(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle realBounds)
Find an appropriate size for the given nodes, then fit them into the given bounds.
|
protected void |
defaultFitWithinBounds(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationships,
org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle realBounds)
Find an appropriate size for the given nodes, then fit them into the given bounds.
|
protected void |
fireProgressEnded(int totalNumberOfSteps) |
protected void |
fireProgressEvent(int currentStep,
int totalNumberOfSteps)
Fires an event to notify all of the registered ProgressListeners that another step
has been completed in the algorithm.
|
protected void |
fireProgressStarted(int totalNumberOfSteps) |
protected abstract int |
getCurrentLayoutStep()
Gets the current layout step
|
double |
getEntityAspectRatio()
Returns the width to height ratio this layout will use to set the size of the entities.
|
protected org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle |
getLayoutBounds(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
boolean includeNodeSize)
Find the bounds in which the nodes are located.
|
protected org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint |
getLocalLocation(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
double x,
double y,
org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle realBounds)
Gets the location in the layout bounds for this node
|
protected int |
getNumberOfProgressListeners() |
int |
getStyle()
Gets the current layout style
|
protected abstract int |
getTotalNumberOfLayoutSteps()
Gets the total number of steps in this layout
|
boolean |
isRunning()
Returns true if the layout algorithm is running
|
protected abstract boolean |
isValidConfiguration(boolean asynchronous,
boolean continuous)
Determines if the configuration is valid for this layout
|
protected abstract void |
postLayoutAlgorithm(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider)
Code called after the layout algorithm ends
|
protected abstract void |
preLayoutAlgorithm(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider,
double x,
double y,
double width,
double height)
Code called before the layout algorithm starts
|
void |
removeEntity(LayoutEntity entity)
Queues up the given entity to be removed from the algorithm next time it runs.
|
void |
removeProgressListener(ProgressListener listener)
Removes the given progress listener, preventing it from receiving any more updates.
|
void |
removeRelationship(LayoutRelationship relationship)
Queues up the given relationship to be removed from the algorithm next time it runs.
|
void |
removeRelationships(java.util.Collection collection) |
void |
removeRelationships(java.util.List relationships)
Queues up all the relationships in the list to be removed.
|
void |
setComparator(java.util.Comparator comparator)
Determines the order in which the objects should be displayed.
|
void |
setEntityAspectRatio(double ratio)
Set the width to height ratio you want the entities to use
|
void |
setFilter(Filter filter)
Filters the entities and relationships to apply the layout on
|
abstract void |
setLayoutArea(double x,
double y,
double width,
double height) |
void |
setStyle(int style)
Sets the current layout style.
|
void |
stop()
Stops the current layout from running.
|
protected void |
updateBendPoints(org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider)
Update external bend points from the internal bendpoints list.
|
protected org.eclipse.zest.layouts.dataStructures.InternalNode[] |
updateEntities(org.eclipse.zest.layouts.dataStructures.InternalNode[] entities)
Updates the given array of entities checking if any need to be removed or added.
|
protected void |
updateLayoutLocations(org.eclipse.zest.layouts.dataStructures.InternalNode[] nodes)
Updates the layout locations so the external nodes know about the new locations
|
protected org.eclipse.zest.layouts.dataStructures.InternalRelationship[] |
updateRelationships(org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationships)
Updates the given array of relationships checking if any need to be removed or added.
|
static boolean |
verifyInput(LayoutEntity[] entitiesToLayout,
LayoutRelationship[] relationshipsToConsider)
Verifies the endpoints of the relationships are entities in the entitiesToLayout list.
|
public static final int MIN_ENTITY_SIZE
protected java.util.Comparator comparator
protected Filter filter
protected boolean internalContinuous
protected boolean internalAsynchronous
protected boolean layoutStopped
protected int layout_styles
protected boolean resizeEntitiesAfterLayout
public AbstractLayoutAlgorithm(int styles)
LayoutStylespublic void removeRelationships(java.util.Collection collection)
public void addEntity(LayoutEntity entity)
addEntity in interface LayoutAlgorithmentity - public void addRelationship(LayoutRelationship relationship)
addRelationship in interface LayoutAlgorithmrelationship - public void removeEntity(LayoutEntity entity)
removeEntity in interface LayoutAlgorithmentity - The entity to removepublic void removeRelationship(LayoutRelationship relationship)
removeRelationship in interface LayoutAlgorithmrelationship - The relationship to remove.public void removeRelationships(java.util.List relationships)
removeRelationships in interface LayoutAlgorithmrelationships - public void setStyle(int style)
setStyle in interface LayoutAlgorithmstyle - public int getStyle()
getStyle in interface LayoutAlgorithmpublic abstract void setLayoutArea(double x,
double y,
double width,
double height)
protected abstract boolean isValidConfiguration(boolean asynchronous,
boolean continuous)
asynchronous - continuous - protected abstract void applyLayoutInternal(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider,
double boundsX,
double boundsY,
double boundsWidth,
double boundsHeight)
entitiesToLayout - Apply the algorithm to these entitiesrelationshipsToConsider - Only consider these relationships when applying the algorithm.x - The left side of the bounds in which the layout can place the entities.y - The top side of the bounds in which the layout can place the entities.width - The width of the bounds in which the layout can place the entities.height - The height of the bounds in which the layout can place the entities.protected org.eclipse.zest.layouts.dataStructures.InternalNode[] updateEntities(org.eclipse.zest.layouts.dataStructures.InternalNode[] entities)
entities - the current entitiesprotected org.eclipse.zest.layouts.dataStructures.InternalRelationship[] updateRelationships(org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationships)
relationships - the current relationshipspublic boolean isRunning()
isRunning in interface LayoutAlgorithmpublic void stop()
stop in interface LayoutAlgorithmstop in interface Stoppableprotected abstract void preLayoutAlgorithm(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider,
double x,
double y,
double width,
double height)
protected abstract void postLayoutAlgorithm(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider)
protected abstract int getTotalNumberOfLayoutSteps()
protected abstract int getCurrentLayoutStep()
public void applyLayout(LayoutEntity[] entitiesToLayout, LayoutRelationship[] relationshipsToConsider, double x, double y, double width, double height, boolean asynchronous, boolean continuous) throws InvalidLayoutConfiguration
applyLayout in interface LayoutAlgorithmentitiesToLayout - Apply the algorithm to these entitiesrelationshipsToConsider - Only consider these relationships when applying the algorithm.x - The left side of the bounds in which the layout can place the entities.y - The top side of the bounds in which the layout can place the entities.width - The width of the bounds in which the layout can place the entities.height - The height of the bounds in which the layout can place the entities.asynchronous - Should the algorithm run AsynchronouslyInvalidLayoutConfigurationprotected void updateBendPoints(org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationshipsToConsider)
relationshipsToConsider - public void setFilter(Filter filter)
setFilter in interface LayoutAlgorithmpublic void setComparator(java.util.Comparator comparator)
setComparator in interface LayoutAlgorithmpublic static boolean verifyInput(LayoutEntity[] entitiesToLayout, LayoutRelationship[] relationshipsToConsider)
protected org.eclipse.zest.layouts.dataStructures.DisplayIndependentPoint getLocalLocation(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
double x,
double y,
org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle realBounds)
x - y - protected void defaultFitWithinBounds(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle realBounds)
protected void defaultFitWithinBounds(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
org.eclipse.zest.layouts.dataStructures.InternalRelationship[] relationships,
org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle realBounds)
protected org.eclipse.zest.layouts.dataStructures.DisplayIndependentRectangle getLayoutBounds(org.eclipse.zest.layouts.dataStructures.InternalNode[] entitiesToLayout,
boolean includeNodeSize)
public void setEntityAspectRatio(double ratio)
setEntityAspectRatio in interface LayoutAlgorithmpublic double getEntityAspectRatio()
getEntityAspectRatio in interface LayoutAlgorithmpublic void addProgressListener(ProgressListener listener)
addProgressListener in interface LayoutAlgorithmaddProgressListener in interface Stoppablepublic void removeProgressListener(ProgressListener listener)
removeProgressListener in interface LayoutAlgorithmprotected void updateLayoutLocations(org.eclipse.zest.layouts.dataStructures.InternalNode[] nodes)
protected void fireProgressStarted(int totalNumberOfSteps)
protected void fireProgressEnded(int totalNumberOfSteps)
protected void fireProgressEvent(int currentStep,
int totalNumberOfSteps)
currentStep - The current step completed.totalNumberOfSteps - The total number of steps in the algorithm.protected int getNumberOfProgressListeners()
Copyright (c) IBM Corp. and others 2000, 2011. All Rights Reserved.