Search in sources :

Example 21 with NodeDescriptor

use of org.eclipse.titanium.graph.components.NodeDescriptor in project titan.EclipsePlug-ins by eclipse.

the class AutomaticCluster method moveNode.

/**
 * Moves v from its original cluster to the one indexed by 'to'. It is much
 * faster than calculating the whole matrix again.
 *
 * @param v
 *            The node to be moved
 * @param to
 *            The index of the cluster
 */
private void moveNode(final NodeDescriptor v, final int to) {
    final int from = mapClusterIndex.get(v);
    if (from == to) {
        return;
    }
    if (size.get(to) == 0) {
        clusternum++;
    }
    if (size.get(from) == 1) {
        clusternum--;
    }
    for (final EdgeDescriptor e : moduleGraph.getInEdges(v)) {
        final NodeDescriptor u = moduleGraph.getSource(e);
        final int indexu = mapClusterIndex.get(u);
        changeCell(from, indexu, -1);
        changeCell(to, indexu, 1);
    }
    for (final EdgeDescriptor e : moduleGraph.getOutEdges(v)) {
        final NodeDescriptor w = moduleGraph.getDest(e);
        final int indexw = mapClusterIndex.get(w);
        changeCell(indexw, from, -1);
        changeCell(indexw, to, 1);
    }
    changeSize(from, -1);
    changeSize(to, 1);
    mapClusterIndex.put(v, to);
}
Also used : NodeDescriptor(org.eclipse.titanium.graph.components.NodeDescriptor) EdgeDescriptor(org.eclipse.titanium.graph.components.EdgeDescriptor)

Example 22 with NodeDescriptor

use of org.eclipse.titanium.graph.components.NodeDescriptor in project titan.EclipsePlug-ins by eclipse.

the class FullModuleNameCluster method createGraph.

@Override
public void createGraph() {
    mapNameNode = new HashMap<String, ClusterNode>();
    clusterGraph = new DirectedSparseGraph<NodeDescriptor, EdgeDescriptor>();
    stack = new LinkedList<String>();
    ClusterNode root = new ClusterNode(ALL, mapNameCluster.get(ALL));
    clusterGraph.addVertex(root);
    mapNameNode.put(ALL, root);
    traverseListOfNames();
}
Also used : ClusterNode(org.eclipse.titanium.graph.clustering.visualization.ClusterNode) NodeDescriptor(org.eclipse.titanium.graph.components.NodeDescriptor) EdgeDescriptor(org.eclipse.titanium.graph.components.EdgeDescriptor)

Example 23 with NodeDescriptor

use of org.eclipse.titanium.graph.components.NodeDescriptor in project titan.EclipsePlug-ins by eclipse.

the class ModuleNameCluster method fillClusters.

/**
 * Fill the clusters with the nodes.
 */
private void fillClusters() {
    for (final NodeDescriptor v : moduleGraph.getVertices()) {
        final String name = v.getDisplayName();
        int length = 0;
        String match = null;
        for (final String word : knownNames) {
            if (word.length() > length && name.startsWith(word)) {
                match = word;
                length = word.length();
            }
        }
        if (match == null) {
            final Set<NodeDescriptor> cluster = mapNameCluster.get(ALL);
            cluster.add(v);
            v.setCluster(cluster);
        } else {
            final Set<NodeDescriptor> cluster = mapNameCluster.get(match);
            cluster.add(v);
            v.setCluster(cluster);
        }
    }
    for (final String word : knownNames) {
        final Set<NodeDescriptor> cluster = mapNameCluster.get(word);
        if (!cluster.isEmpty()) {
            clusters.add(cluster);
        }
    }
}
Also used : NodeDescriptor(org.eclipse.titanium.graph.components.NodeDescriptor)

Example 24 with NodeDescriptor

use of org.eclipse.titanium.graph.components.NodeDescriptor in project titan.EclipsePlug-ins by eclipse.

the class PathCluster method addMissing.

/**
 * Adds the missing modules to a separate cluster.
 */
protected void addMissing() {
    final Set<NodeDescriptor> missing = new HashSet<NodeDescriptor>();
    for (final NodeDescriptor v : moduleGraph.getVertices()) {
        if (v.getCluster() == null) {
            missing.add(v);
            v.setCluster(missing);
        }
    }
    if (!missing.isEmpty()) {
        clusters.add(missing);
        mapNameCluster.put("missing", missing);
    }
}
Also used : NodeDescriptor(org.eclipse.titanium.graph.components.NodeDescriptor) HashSet(java.util.HashSet)

Example 25 with NodeDescriptor

use of org.eclipse.titanium.graph.components.NodeDescriptor in project titan.EclipsePlug-ins by eclipse.

the class PathCluster method init.

/**
 * Initializes the algorithm.
 */
protected void init() {
    for (final NodeDescriptor v : moduleGraph.getVertices()) {
        v.setCluster(null);
        mapNameNode.put(v.getName(), v);
    }
}
Also used : NodeDescriptor(org.eclipse.titanium.graph.components.NodeDescriptor)

Aggregations

NodeDescriptor (org.eclipse.titanium.graph.components.NodeDescriptor)30 EdgeDescriptor (org.eclipse.titanium.graph.components.EdgeDescriptor)10 HashSet (java.util.HashSet)7 HashMap (java.util.HashMap)5 Set (java.util.Set)5 Dimension (java.awt.Dimension)4 CustomVisualizationViewer (org.eclipse.titanium.graph.gui.common.CustomVisualizationViewer)3 DirectedSparseGraph (edu.uci.ics.jung.graph.DirectedSparseGraph)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 Point2D (java.awt.geom.Point2D)2 Matcher (java.util.regex.Matcher)2 JMenu (javax.swing.JMenu)2 JMenuItem (javax.swing.JMenuItem)2 IResource (org.eclipse.core.resources.IResource)2 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)2 ClusterNode (org.eclipse.titanium.graph.clustering.visualization.ClusterNode)2 LayoutEntry (org.eclipse.titanium.graph.gui.utils.LayoutEntry)2 MetricsLayoutEntry (org.eclipse.titanium.graph.gui.utils.MetricsLayoutEntry)2 Function (com.google.common.base.Function)1