Search in sources :

Example 26 with NodeDescriptor

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

the class PathCluster method addNodeToCluster.

/**
 * Adds the node to the given cluster.
 *
 * @param name
 *            The name of the node
 * @param cluster
 *            The cluster
 */
protected void addNodeToCluster(final String name, final Set<NodeDescriptor> cluster) {
    final NodeDescriptor v = mapNameNode.get(name);
    cluster.add(v);
    v.setCluster(cluster);
}
Also used : NodeDescriptor(org.eclipse.titanium.graph.components.NodeDescriptor)

Example 27 with NodeDescriptor

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

the class RegexpCluster method fillClusters.

/**
 * Creates the clusters.
 *
 * @return True if a node has more than one matching pattern.
 */
private boolean fillClusters() {
    final Set<NodeDescriptor> missing = new HashSet<NodeDescriptor>();
    mapPatternCluster.put("missing", missing);
    boolean moreThanOneMatch = false;
    for (final NodeDescriptor v : moduleGraph.getVertices()) {
        final List<String> matching = mapNodeMatching.get(v);
        if (matching.isEmpty()) {
            missing.add(v);
            v.setCluster(missing);
        } else if (matching.size() == 1) {
            final Set<NodeDescriptor> cluster = mapPatternCluster.get(matching.get(0));
            cluster.add(v);
            v.setCluster(cluster);
        } else {
            moreThanOneMatch = true;
            final StringBuilder message = new StringBuilder(msg);
            message.append(v.getDisplayName()).append(":\t");
            for (final String pattern : matching) {
                message.append("   ").append(pattern);
            }
            message.append('\n');
            msg = message.toString();
        }
    }
    return moreThanOneMatch;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) NodeDescriptor(org.eclipse.titanium.graph.components.NodeDescriptor) HashSet(java.util.HashSet)

Example 28 with NodeDescriptor

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

the class RegexpCluster method collectMatchingNodes.

/**
 * Collects the nodes belonging to the matchers.
 *
 * @param progress
 *            A progress monitor
 */
private void collectMatchingNodes(final IProgressMonitor progress) {
    mapNodeMatching = new HashMap<NodeDescriptor, List<String>>();
    for (final NodeDescriptor v : moduleGraph.getVertices()) {
        final String name = v.getDisplayName();
        progress.subTask("Checking " + name);
        final List<String> matching = new LinkedList<String>();
        for (final Matcher matcher : matchers) {
            matcher.reset(name);
            if (matcher.matches()) {
                matching.add(matcher.pattern().toString());
            }
        }
        mapNodeMatching.put(v, matching);
    }
}
Also used : Matcher(java.util.regex.Matcher) NodeDescriptor(org.eclipse.titanium.graph.components.NodeDescriptor) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) LinkedList(java.util.LinkedList)

Example 29 with NodeDescriptor

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

the class MetricLayoutAlgorithm method init.

private void init() {
    values = new HashMap<NodeDescriptor, Double>();
    levels = new HashMap<NodeDescriptor, Integer>();
    badNodes = new HashSet<NodeDescriptor>();
    minValue = Double.POSITIVE_INFINITY;
    maxValue = Double.NEGATIVE_INFINITY;
    filledLevels = 0;
    if (!PreferenceManager.isEnabledOnModuleGraph(chosenMetric)) {
        ErrorReporter.logError("Error during metric layout generating: The requested metric is not" + " enabled. Only enabled metrics can be chosen!");
        ErrorMessage.show("Error", "The chosen metric must be enabled for calculation in the properties." + "Have you enabled it?", MessageDialog.ERROR);
        return;
    }
    final Iterator<NodeDescriptor> it = nodes.iterator();
    while (it.hasNext()) {
        final NodeDescriptor node = it.next();
        final ModuleMetricsWrapper wrapper = WrapperStore.getWrapper(node.getProject());
        final Number val = wrapper.getValue(chosenMetric, node.getName());
        if (val == null) {
            it.remove();
            badNodes.add(node);
        } else {
            final Double tempVal = Double.valueOf(val.toString());
            if (tempVal != null) {
                values.put(node, tempVal);
                if (minValue > tempVal) {
                    minValue = tempVal;
                }
                if (maxValue < tempVal) {
                    maxValue = tempVal;
                }
            }
        }
    }
}
Also used : NodeDescriptor(org.eclipse.titanium.graph.components.NodeDescriptor) ModuleMetricsWrapper(org.eclipse.titanium.metrics.utils.ModuleMetricsWrapper)

Example 30 with NodeDescriptor

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

the class GraphRenderer method getVertexLabelRendererComponent.

/**
 * <b>Important: </b> This method is normally never called from our code,
 * Jung itself calls it inside while rendering graph.
 *
 * @param vv
 *            : The current context of visualizing (see
 *            {@link CustomVisualizationViewer})
 * @param value
 *            : The value to assign to the label of the vertex
 * @param font
 *            : A font object describing which font to use
 * @param isSelected
 *            : Indicates whether the node is selected now
 * @param vertex
 *            : A reference to the node to render
 * @return Returns an object describing the current rendering of node text
 */
@Override
public <W extends Object> Component getVertexLabelRendererComponent(final JComponent vv, final Object value, final Font font, final boolean isSelected, final W vertex) {
    final Component comp = super.getVertexLabelRendererComponent(vv, value, font, isSelected, vertex);
    if (vertex instanceof NodeDescriptor) {
        final NodeDescriptor v = (NodeDescriptor) vertex;
        comp.setFont(v.getFontType());
        if (!isSelected) {
            comp.setForeground(v.getFontColour());
        }
    }
    return comp;
}
Also used : NodeDescriptor(org.eclipse.titanium.graph.components.NodeDescriptor) JComponent(javax.swing.JComponent) Component(java.awt.Component)

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