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);
}
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;
}
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);
}
}
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;
}
}
}
}
}
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;
}
Aggregations