org.grinvin.gui.icons

Class DefaultGraphIconFactory

Implemented Interfaces:
GraphIconFactory
Known Direct Subclasses:
AnnotatedIconFactory, ChemicalIconFactory, EdgesOnlyIconFactory, MissingGraphIconFactory

public class DefaultGraphIconFactory
extends java.lang.Object
implements GraphIconFactory

Factory which is to be used when a graph bundle does not explicitely request an icon factory.

Constructor Summary

DefaultGraphIconFactory()
Default constructor.

Method Summary

GraphIcon
createIcon(GraphBundleView bundle, int size)
protected GraphIcon
createIconForLargeGraph(GraphBundleView bundle, int size)
Create an icon for a 'large' graph.
protected GraphIcon
createIconForMissingGraph(GraphBundleView bundle, int size)
Create an icon for a graph bundle whose graph is missing.
protected GraphIcon
createIconForSmallGraph(GraphBundleView bundle, int size)
Create an icon for a 'small' graph.
protected Icon
getBackgroundIcon(int size)
Return the background icon for the large graph icon.
static GraphIconFactory
getInstance()
Return the sole instance of this class.
protected int
getVertexLimitFactor()
Return the vertex limit factor used to determine whether a graph should be classified as 'small' or 'large'.
protected boolean
isHugeGraph(GraphBundleView bundle)
protected boolean
isSmallGraph(GraphBundleView bundle, int size)
Determine whether a graph qualifies as 'small'.

Constructor Details

DefaultGraphIconFactory

protected DefaultGraphIconFactory()
Default constructor. Can be overridden, but should not be called directly.

Method Details

createIcon

public GraphIcon createIcon(GraphBundleView bundle,
                            int size)
Specified by:
createIcon in interface GraphIconFactory

createIconForLargeGraph

protected GraphIcon createIconForLargeGraph(GraphBundleView bundle,
                                            int size)
Create an icon for a 'large' graph.

createIconForMissingGraph

protected GraphIcon createIconForMissingGraph(GraphBundleView bundle,
                                              int size)
Create an icon for a graph bundle whose graph is missing.

createIconForSmallGraph

protected GraphIcon createIconForSmallGraph(GraphBundleView bundle,
                                            int size)
Create an icon for a 'small' graph.

getBackgroundIcon

protected Icon getBackgroundIcon(int size)
Return the background icon for the large graph icon.

getInstance

public static GraphIconFactory getInstance()
Return the sole instance of this class.

getVertexLimitFactor

protected int getVertexLimitFactor()
Return the vertex limit factor used to determine whether a graph should be classified as 'small' or 'large'.

isHugeGraph

protected boolean isHugeGraph(GraphBundleView bundle)

isSmallGraph

protected boolean isSmallGraph(GraphBundleView bundle,
                               int size)
Determine whether a graph qualifies as 'small'. Tyically small graphs use an icon that closely represents the graph embedding while large graphs use a more general icon.

This implementation checks whether the number of vertices is smaller than the square of the size divide by the vertex limit factor.

Parameters:
size - Size of the icon