Commit df37869c authored by Carlos Galindo's avatar Carlos Galindo
Browse files

Initial commit (import into GIT)

parents
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+212 −0
Original line number Diff line number Diff line
# Created by https://www.toptal.com/developers/gitignore/api/intellij+all,java,windows,linux,macos,maven
# Edit at https://www.toptal.com/developers/gitignore?templates=intellij+all,java,windows,linux,macos,maven

### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn.  Uncomment if using
# auto-import.
.idea/artifacts
.idea/compiler.xml
.idea/jarRepositories.xml
.idea/modules.xml
.idea/*.iml
.idea/modules
*.iml
*.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij+all Patch ###
# Ignore everything but code style settings and run configurations
# that are supposed to be shared within teams.

.idea/*

!.idea/codeStyles
!.idea/runConfigurations

### Java ###
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar

# Eclipse m2e generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/intellij+all,java,windows,linux,macos,maven
 No newline at end of file

EDG/pom.xml

0 → 100644
+24 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <artifactId>EDG</artifactId>

    <parent>
        <artifactId>edg-java</artifactId>
        <groupId>es.upv.dsic.mist.edg-java</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>es.upv.dsic.mist.edg-java</groupId>
            <artifactId>Miscellanea</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
    
</project>
 No newline at end of file
+0 −0

File added.

Preview size limit exceeded, changes collapsed.

+185 −0
Original line number Diff line number Diff line
package edg;

import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import edg.constraint.EdgeConstraint;
import edg.graph.EDG;
import edg.graph.Edge;
import edg.graph.EdgeInfo;
import edg.graph.Node;
import misc.Misc;

public class DotFactory
{
	public static void createDot(File outputFile, EDG edg)
	{
		DotFactory.createDot(outputFile, edg, null, null, null);
	}
	public static void createDot(File outputFile, EDG edg, Map<EdgeInfo.Type, Boolean> edgeFlags)
	{
		DotFactory.createDot(outputFile, edg, null, null, edgeFlags);
	}
	public static void createDot(File outputFile, EDG edg, Node slicingCriterion, List<Node> slice)
	{
		DotFactory.createDot(outputFile, edg, slicingCriterion, slice, null);
	}
	public static void createDot(File outputFile, EDG edg, Node slicingCriterion, List<Node> slice, Map<EdgeInfo.Type, Boolean> edgeFlags)
	{
		final List<Node> nodes = edg.getNodes();
		final List<Edge> edges = edg.getEdges();
		String text = "digraph PDG {\n";
		int lines = 0;

		Misc.write(outputFile, "", false);
		for (Node node : nodes)
		{
			final boolean sliceCriterion = node == slicingCriterion;
			final boolean sliceNode = slice != null && slice.contains(node);
			final String nodeText = DotFactory.parseNode(node, sliceCriterion, sliceNode);
			text += "\t" + nodeText + ";\n";

			if (++lines % 100 == 0)
			{
				Misc.write(outputFile, text, true);
				text = "";
			}
		}
		for (Edge edge : edges)
		{
			final EdgeInfo.Type edgeType = edge.getData().getType();
			if (edgeType != EdgeInfo.Type.Structural && edgeFlags != null && !edgeFlags.get(edgeType))
				continue;

			final String edgeText = DotFactory.parseEdge(edge);
			text += edgeText.isEmpty() ? "" : "\t" + edgeText + ";\n";

			if (++lines % 100 == 0)
			{
				Misc.write(outputFile, text, true);
				text = "";
			}
		}
		text += "}";

		Misc.write(outputFile, text, true);
	}

	private static String parseNode(Node node, boolean sliceCriterion, boolean sliceNode)
	{
		final String id = node.getData().getId() + "";
		final String SDGid = node.getData().getSDGId() + "";
		final String name = node.getName().replace("\n", "\\n");
		String text = "";

		text += id + " ";
		text += "[";
		text += "shape=ellipse ";
		text += "penwidth=" + (sliceCriterion ? "4" : "1") + " ";
		text += "style=filled ";
		text += "color=\"" + (sliceCriterion ? "blue" : "gray") + "\" ";
		text += "label=\"" + "Id = " + id + "\\n" + "SDGId = " + SDGid + "\\n" + name + "\" ";
		text += "fontcolor=\"" + (sliceNode ? "blue" : "black") + "\" ";
		text += "fillcolor=\"" + (sliceNode ? "green" : "gray") + "\" ";
		text = text.trim();
		text += "]";

		return text;
	}
	private static String parseEdge(Edge edge)
	{
		final EdgeInfo.Type edgeType = edge.getData().getType();
		final EdgeConstraint constraint = edge.getData().getConstraint();
		final int idFrom = edge.getFrom().getData().getId();
		final int idTo = edge.getTo().getData().getId();
		String text = "";

// TODO Borrame
			
if (edgeType != EdgeInfo.Type.Structural) {
final List<EdgeInfo.Type> ignoreEdgeTypes = Arrays.asList(EdgeInfo.Type.ControlFlow);
final List<EdgeInfo.Type> edgeTypes = Arrays.asList();//EdgeInfo.Type.Value, EdgeInfo.Type.Flow, EdgeInfo.Type.Output, EdgeInfo.Type.Input); // Introducir aqui el tipo de arcos que quieres mostrar
final int[] boundNodeIds = {}; // Introducir aqui los extremos del intervalo en el que se quieren ver los arcos
final List<Integer> nodesIds = Arrays.asList(); // Introducir aqui los nodos de los que se quieren ver los arcos

if (ignoreEdgeTypes.contains(edgeType))
return "";
if (!edgeTypes.isEmpty() && !edgeTypes.contains(edgeType))
return "";
if (boundNodeIds.length == 2)
if (idFrom < boundNodeIds[0] || idTo < boundNodeIds[0] || idFrom > boundNodeIds[1] || idTo > boundNodeIds[1])
return "";
if (!nodesIds.isEmpty() && !nodesIds.contains(idFrom) && !nodesIds.contains(idTo))
return "";
}

		text += idFrom + " -> " + idTo + " ";
		text += "[";
		if (constraint != null && edgeType != EdgeInfo.Type.Structural && edgeType != EdgeInfo.Type.Control)
			text += "label=\"" + constraint + "\", ";

		switch (edgeType)
		{
			case Structural:
				text += "color=black, ";
				text += "penwidth=3";
				break;
			case ControlFlow:
				text += "color=red, ";
				text += "penwidth=3, ";
				text += "constraint=false";
				break;
			case Control:
				text += "color=orange, ";
				text += "constraint=false, ";
				text += "penwidth=3";
				break;
			case Value:
				text += "color=red, ";
				text += "constraint=false, ";
				text += "style=\"dotted\"";
				break;
			case Flow:
				text += "color=blue, ";
				text += "constraint=false, ";
				text += "style=\"dotted\"";
				break;
			case Call:
			case Input:
				text += "color=green3, ";
				text += "penwidth=3, ";
				text += "constraint=false, ";
				text += "style=\"dashed\"";
				break;
			case Output:
				text += "color=pink, ";
				text += "penwidth=3, ";
				text += "constraint=false, ";
				text += "style=\"dashed\"";
				break;
			case Summary:
				text += "color=brown, ";
				text += "penwidth=4, ";
				text += "constraint=false";
				break;
			case Exception:
				text += "color=orange, ";
				text += "penwidth=3, ";
				text += "constraint=false";
				break;
			default:
				throw new RuntimeException("Edge type not contemplated: " + edgeType);
		}
		text += "]";

		return text;
	}

	private DotFactory()
	{
		
	}
}
 No newline at end of file
+0 −0

File added.

Preview size limit exceeded, changes collapsed.