use of org.eclipse.titanium.graph.components.NodeDescriptor in project titan.EclipsePlug-ins by eclipse.
the class ModuleNameCluster method createNames.
/**
* Slice up the module names to guess the "package" name.
*/
private void createNames(final IProgressMonitor monitor) {
addCluster(ALL);
for (final NodeDescriptor v : moduleGraph.getVertices()) {
final String name = v.getDisplayName();
monitor.subTask("Checking " + name);
boolean small = false;
int i = 0;
int splits = 0;
final int length = name.length();
char prev = '0';
while (i < length && splits < depth) {
final char c = name.charAt(i);
if (checkDash(prev, c)) {
addSubName(name, i);
++splits;
}
if (checkAlternatingCase) {
if (small && Character.isUpperCase(c)) {
addSubName(name, i);
++splits;
}
small = Character.isLowerCase(c);
}
prev = c;
++i;
}
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
monitor.worked(1);
}
}
use of org.eclipse.titanium.graph.components.NodeDescriptor in project titan.EclipsePlug-ins by eclipse.
the class GraphEditor method elemChosen.
@Override
public void elemChosen(final NodeDescriptor element) {
final CustomVisualizationViewer visualisator = handler.getVisualizator();
visualisator.jumpToPlace(visualisator.getGraphLayout().apply(element));
for (final NodeDescriptor node : graph.getVertices()) {
node.setNodeColour(NodeColours.NOT_RESULT_COLOUR);
}
element.setNodeColour(NodeColours.RESULT_COLOUR);
}
use of org.eclipse.titanium.graph.components.NodeDescriptor in project titan.EclipsePlug-ins by eclipse.
the class ModuleGraphGenerator method createGraph.
@Override
protected void createGraph() {
// analyze the project if needed
final ProjectSourceParser sourceParser = GlobalParser.getProjectSourceParser(project);
if (sourceParser.getLastTimeChecked() == null) {
WorkspaceJob job = sourceParser.analyzeAll();
while (job == null) {
try {
Thread.sleep(500);
job = sourceParser.analyzeAll();
} catch (InterruptedException e) {
ErrorReporter.logExceptionStackTrace("Error while waiting for analyzis result", e);
}
}
try {
job.join();
} catch (InterruptedException e) {
ErrorReporter.logExceptionStackTrace("Error while parsing the project", e);
}
}
final List<IProject> visitedProjects = ProjectBasedBuilder.getProjectBasedBuilder(project).getAllReachableProjects();
final Map<String, Identifier> globalKnownModules = new HashMap<String, Identifier>();
for (int i = 0; i < visitedProjects.size(); ++i) {
final IProject currentProject = visitedProjects.get(i);
final ProjectStructureDataCollector collector = GlobalProjectStructureTracker.getDataCollector(currentProject);
collector.evaulateMissingModules();
// adding known modules
for (final Identifier moduleName : collector.knownModules.values()) {
final NodeDescriptor actNode = new NodeDescriptor(moduleName.getDisplayName(), moduleName.getName(), currentProject, false, moduleName.getLocation());
globalKnownModules.put(moduleName.getName(), moduleName);
if (!graph.containsVertex(actNode)) {
graph.addVertex(actNode);
labels.put(actNode.getName(), actNode);
}
}
// adding missing modules
for (final Identifier moduleName : collector.missingModules.values()) {
if (!globalKnownModules.containsKey(moduleName.getName())) {
final NodeDescriptor actNode = new NodeDescriptor(moduleName.getDisplayName(), moduleName.getName(), currentProject, true, moduleName.getLocation());
if (!graph.containsVertex(actNode)) {
graph.addVertex(actNode);
labels.put(actNode.getName(), actNode);
}
}
}
// building edges
for (final String from : collector.importations.keySet()) {
for (final String to : collector.importations.get(from)) {
final EdgeDescriptor edge = new EdgeDescriptor(from + "->" + to, Color.black);
// if(!graph.containsEdge(edge))
graph.addEdge(edge, labels.get(from), labels.get(to), EdgeType.DIRECTED);
}
}
}
}
use of org.eclipse.titanium.graph.components.NodeDescriptor in project titan.EclipsePlug-ins by eclipse.
the class RegexpCluster method createMatchers.
/**
* Creates the matcher objects.
*
* @return True if the regular expressions are correct.
*/
private boolean createMatchers() {
matchers = new ArrayList<Matcher>();
mapPatternCluster = new HashMap<String, Set<NodeDescriptor>>();
final String stringList = Platform.getPreferencesService().getString(Activator.PLUGIN_ID, PreferenceConstants.CLUSTER_REGEXP, "", null);
final List<String> splittedList = ResourceExclusionHelper.intelligentSplit(stringList, '#', '\\');
if (splittedList.isEmpty()) {
setErronous("No regular expressions were defined.\n" + "Please visit the 'Clusters' Preference page to define them.");
return false;
}
for (final String item : splittedList) {
try {
final Pattern pattern = Pattern.compile(item);
final Set<NodeDescriptor> cluster = new HashSet<NodeDescriptor>();
mapPatternCluster.put(pattern.toString(), cluster);
final Matcher matcher = pattern.matcher("");
matchers.add(matcher);
} catch (PatternSyntaxException e) {
final String errorString = "At least one of the regular expressions used is not correct.\n" + "Please visit the 'Clusters' Preference page to correct it.\n" + "Reason: " + e.getLocalizedMessage() + "\n" + "Incorrect pattern: " + item;
ErrorReporter.logExceptionStackTrace(errorString, e);
setErronous(errorString);
return false;
}
}
return true;
}
use of org.eclipse.titanium.graph.components.NodeDescriptor in project titan.EclipsePlug-ins by eclipse.
the class ClusterTransformer method groupCluster.
/**
* Calculate positions for one cluster
*
* @param vertices
* : the set of vertices inside the cluster
*/
protected void groupCluster(final Set<NodeDescriptor> vertices) {
if (vertices.size() < mainLayout.getGraph().getVertexCount()) {
final Point2D center = mainLayout.apply(vertices.iterator().next());
final DirectedSparseGraph<NodeDescriptor, EdgeDescriptor> subGraph = new DirectedSparseGraph<NodeDescriptor, EdgeDescriptor>();
for (final NodeDescriptor v : vertices) {
subGraph.addVertex(v);
}
final Layout<NodeDescriptor, EdgeDescriptor> subLayout = new CircleLayout<NodeDescriptor, EdgeDescriptor>(subGraph);
subLayout.setInitializer(mainLayout);
// TODO Could we calculate the needed space for one cluster?
final Dimension canvasSize = new Dimension(100, 100);
subLayout.setSize(canvasSize);
mainLayout.put(subLayout, center);
}
}
Aggregations