diff --git a/.gitignore b/.gitignore index bb49aa9..8ddb90d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,45 +1,5 @@ -*.class - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.ear - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - -*.pydevproject -.metadata -.gradle -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.settings/ -.loadpath - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - -# sbteclipse plugin -.target - -# TeXlipse plugin -.texlipse - -*/target/* +.project +.settings/* +**/.classpath +*/bin/ +*/target/* \ No newline at end of file diff --git a/GraphDrawingTheory/.classpath b/GraphDrawingTheory/.classpath deleted file mode 100644 index 3f5ccfb..0000000 --- a/GraphDrawingTheory/.classpath +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/GraphDrawingTheory/.gitignore b/GraphDrawingTheory/.gitignore deleted file mode 100644 index f0e3219..0000000 --- a/GraphDrawingTheory/.gitignore +++ /dev/null @@ -1,44 +0,0 @@ -*.class - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.ear - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - -*.pydevproject -.metadata -.gradle -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.settings/ -.loadpath - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - -# sbteclipse plugin -.target - -# TeXlipse plugin -.texlipse -/target diff --git a/GraphDrawingTheory/.project b/GraphDrawingTheory/.project deleted file mode 100644 index 057bae7..0000000 --- a/GraphDrawingTheory/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - GraphDrawingTheory - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.jdt.core.javanature - - diff --git a/GraphDrawingTheory/pom.xml b/GraphDrawingTheory/pom.xml index 227a223..ee2f9f8 100644 --- a/GraphDrawingTheory/pom.xml +++ b/GraphDrawingTheory/pom.xml @@ -1,73 +1,71 @@ - - 4.0.0 - GraphDrawingTheory - GraphDrawingTheory - 0.1.0-SNAPSHOT - - src - test - - - maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - - - - - - - org.tinyjee.jgraphx - jgraphx - 3.4.1.3 - compile - - - log4j - log4j - 1.2.17 - compile - - - org.prefuse - prefuse - beta-20071021 - compile - - - gov.nist.math - jama - 1.0.3 - compile - - - net.sf.jung - jung-visualization - 2.0.1 - compile - - - net.sf.jung - jung-algorithms - 2.0.1 - compile - - - net.sf.jung - jung-graph-impl - 2.0.1 - compile - - - org.python - jython-standalone - 2.7.1b2 - compile - - + - - + + GraphDrawing + GraphDrawing + 0.1.0-SNAPSHOT + .. + + + 4.0.0 + GraphDrawingTheory + GraphDrawingTheory + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + + + + org.tinyjee.jgraphx + jgraphx + + + log4j + log4j + + + org.prefuse + prefuse + + + gov.nist.math + jama + + + net.sf.jung + jung-visualization + + + net.sf.jung + jung-algorithms + + + net.sf.jung + jung-graph-impl + + + org.python + jython-standalone + + + GraphLayoutDSL + GraphLayoutDSL + ${project.version} + + + junit + junit + test + + \ No newline at end of file diff --git a/GraphDrawingTheory/src/graph/algorithm/AlgorithmExecutor.java b/GraphDrawingTheory/src/main/java/graph/algorithm/AlgorithmExecutor.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithm/AlgorithmExecutor.java rename to GraphDrawingTheory/src/main/java/graph/algorithm/AlgorithmExecutor.java diff --git a/GraphDrawingTheory/src/graph/algorithm/ExecuteResult.java b/GraphDrawingTheory/src/main/java/graph/algorithm/ExecuteResult.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithm/ExecuteResult.java rename to GraphDrawingTheory/src/main/java/graph/algorithm/ExecuteResult.java diff --git a/GraphDrawingTheory/src/graph/algorithm/cycles/JohnsonSimpleCycles.java b/GraphDrawingTheory/src/main/java/graph/algorithm/cycles/JohnsonSimpleCycles.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithm/cycles/JohnsonSimpleCycles.java rename to GraphDrawingTheory/src/main/java/graph/algorithm/cycles/JohnsonSimpleCycles.java index d8e5726..1727ef8 100644 --- a/GraphDrawingTheory/src/graph/algorithm/cycles/JohnsonSimpleCycles.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithm/cycles/JohnsonSimpleCycles.java @@ -17,10 +17,6 @@ =============================================================================*/ package graph.algorithm.cycles; -import graph.elements.Edge; -import graph.elements.Graph; -import graph.elements.Vertex; - import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -30,6 +26,10 @@ import java.util.Set; import java.util.Stack; +import graph.elements.Edge; +import graph.elements.Graph; +import graph.elements.Vertex; + /** * Find all simple cycles of a directed graph using the Johnson's * algorithm. diff --git a/GraphDrawingTheory/src/graph/algorithm/cycles/PatonSimpleCycles.java b/GraphDrawingTheory/src/main/java/graph/algorithm/cycles/PatonSimpleCycles.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithm/cycles/PatonSimpleCycles.java rename to GraphDrawingTheory/src/main/java/graph/algorithm/cycles/PatonSimpleCycles.java index 15628d3..65683db 100644 --- a/GraphDrawingTheory/src/graph/algorithm/cycles/PatonSimpleCycles.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithm/cycles/PatonSimpleCycles.java @@ -17,10 +17,6 @@ =============================================================================*/ package graph.algorithm.cycles; -import graph.elements.Edge; -import graph.elements.Graph; -import graph.elements.Vertex; - import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -29,6 +25,10 @@ import java.util.Set; import java.util.Stack; +import graph.elements.Edge; +import graph.elements.Graph; +import graph.elements.Vertex; + /** * Find a cycle basis of an undirected graph using the Paton's * algorithm. diff --git a/GraphDrawingTheory/src/graph/algorithm/cycles/SimpleCyclesFinder.java b/GraphDrawingTheory/src/main/java/graph/algorithm/cycles/SimpleCyclesFinder.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithm/cycles/SimpleCyclesFinder.java rename to GraphDrawingTheory/src/main/java/graph/algorithm/cycles/SimpleCyclesFinder.java index 45c573f..ac7d245 100644 --- a/GraphDrawingTheory/src/graph/algorithm/cycles/SimpleCyclesFinder.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithm/cycles/SimpleCyclesFinder.java @@ -1,11 +1,11 @@ package graph.algorithm.cycles; +import java.util.List; + import graph.elements.Edge; import graph.elements.Graph; import graph.elements.Vertex; -import java.util.List; - public class SimpleCyclesFinder> { public SimpleCyclesFinder(){ diff --git a/GraphDrawingTheory/src/graph/algorithm/cycles/SimpleUndirectedCyclesFinder.java b/GraphDrawingTheory/src/main/java/graph/algorithm/cycles/SimpleUndirectedCyclesFinder.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithm/cycles/SimpleUndirectedCyclesFinder.java rename to GraphDrawingTheory/src/main/java/graph/algorithm/cycles/SimpleUndirectedCyclesFinder.java index 32de41b..9d76aa0 100644 --- a/GraphDrawingTheory/src/graph/algorithm/cycles/SimpleUndirectedCyclesFinder.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithm/cycles/SimpleUndirectedCyclesFinder.java @@ -1,9 +1,5 @@ package graph.algorithm.cycles; -import graph.elements.Edge; -import graph.elements.Graph; -import graph.elements.Vertex; - import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -11,6 +7,10 @@ import java.util.Map; import java.util.Set; +import graph.elements.Edge; +import graph.elements.Graph; +import graph.elements.Vertex; + public class SimpleUndirectedCyclesFinder> { diff --git a/GraphDrawingTheory/src/graph/algorithms/connectivity/PlanarAugmentation.java b/GraphDrawingTheory/src/main/java/graph/algorithms/connectivity/PlanarAugmentation.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/connectivity/PlanarAugmentation.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/connectivity/PlanarAugmentation.java index 1a6bcc4..d9bc2c2 100644 --- a/GraphDrawingTheory/src/graph/algorithms/connectivity/PlanarAugmentation.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithms/connectivity/PlanarAugmentation.java @@ -17,10 +17,10 @@ import graph.elements.Vertex; import graph.exception.CannotBeAppliedException; import graph.traversal.GraphTraversal; +import graph.tree.bc.BCNodeType; import graph.tree.bc.BCTree; import graph.tree.bc.BCTreeEdge; import graph.tree.bc.BCTreeNode; -import graph.tree.bc.BCNodeType; import graph.util.Util; /** diff --git a/GraphDrawingTheory/src/graph/algorithms/connectivity/PlanarAugmentationLabel.java b/GraphDrawingTheory/src/main/java/graph/algorithms/connectivity/PlanarAugmentationLabel.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/connectivity/PlanarAugmentationLabel.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/connectivity/PlanarAugmentationLabel.java index 388f185..cca4402 100644 --- a/GraphDrawingTheory/src/graph/algorithms/connectivity/PlanarAugmentationLabel.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithms/connectivity/PlanarAugmentationLabel.java @@ -6,8 +6,8 @@ import graph.elements.Edge; import graph.elements.Graph; import graph.elements.Vertex; -import graph.tree.bc.BCTreeNode; import graph.tree.bc.BCNodeType; +import graph.tree.bc.BCTreeNode; /** * A bundle of pendants together with its parent diff --git a/GraphDrawingTheory/src/graph/algorithms/drawing/ConvexDrawing.java b/GraphDrawingTheory/src/main/java/graph/algorithms/drawing/ConvexDrawing.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/drawing/ConvexDrawing.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/drawing/ConvexDrawing.java diff --git a/GraphDrawingTheory/src/graph/algorithms/drawing/CyclicSymmetricGraphDrawing.java b/GraphDrawingTheory/src/main/java/graph/algorithms/drawing/CyclicSymmetricGraphDrawing.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/drawing/CyclicSymmetricGraphDrawing.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/drawing/CyclicSymmetricGraphDrawing.java index f9c0df5..2582fb0 100644 --- a/GraphDrawingTheory/src/graph/algorithms/drawing/CyclicSymmetricGraphDrawing.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithms/drawing/CyclicSymmetricGraphDrawing.java @@ -1,5 +1,10 @@ package graph.algorithms.drawing; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import graph.elements.Edge; import graph.elements.Graph; import graph.elements.Vertex; @@ -9,11 +14,6 @@ import graph.symmetry.nauty.McKayGraphLabelingAlgorithm; import graph.util.Pair; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - /** * Concentric symmrtic drawing algorithms based on Car and Kocay's algorithm * @author xx diff --git a/GraphDrawingTheory/src/graph/algorithms/drawing/PlanarConvexEmbedding.java b/GraphDrawingTheory/src/main/java/graph/algorithms/drawing/PlanarConvexEmbedding.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/drawing/PlanarConvexEmbedding.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/drawing/PlanarConvexEmbedding.java diff --git a/GraphDrawingTheory/src/graph/algorithms/drawing/TutteEmbedding.java b/GraphDrawingTheory/src/main/java/graph/algorithms/drawing/TutteEmbedding.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/drawing/TutteEmbedding.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/drawing/TutteEmbedding.java index e30ee3b..d8d37cc 100644 --- a/GraphDrawingTheory/src/graph/algorithms/drawing/TutteEmbedding.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithms/drawing/TutteEmbedding.java @@ -1,5 +1,11 @@ package graph.algorithms.drawing; +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import graph.elements.Edge; import graph.elements.Graph; import graph.elements.Vertex; @@ -7,12 +13,6 @@ import graph.math.CramersRule; import graph.math.Matrix; -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - public class TutteEmbedding> { diff --git a/GraphDrawingTheory/src/graph/algorithms/drawing/VisibilityRepresentation.java b/GraphDrawingTheory/src/main/java/graph/algorithms/drawing/VisibilityRepresentation.java similarity index 99% rename from GraphDrawingTheory/src/graph/algorithms/drawing/VisibilityRepresentation.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/drawing/VisibilityRepresentation.java index f41fb62..1548a2f 100644 --- a/GraphDrawingTheory/src/graph/algorithms/drawing/VisibilityRepresentation.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithms/drawing/VisibilityRepresentation.java @@ -1,5 +1,12 @@ package graph.algorithms.drawing; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + import graph.algorithms.numbering.STNumbering; import graph.algorithms.planarity.BoyerMyrvoldPlanarity; import graph.algorithms.planarity.PlanarFaces; @@ -11,14 +18,6 @@ import graph.exception.CannotBeAppliedException; import graph.exception.NotPlanarException; import graph.ordering.TopologicalOrdering; -import jnr.ffi.Struct.ssize_t; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; /** Given a graph G = (V, E), a visibility representation Γ, for G maps every vertex v in V to a horizontal vertex segment Γ(v) and every edge (u, v) ∈ E to a diff --git a/GraphDrawingTheory/src/graph/algorithms/interlacement/InterlacementGraphEdge.java b/GraphDrawingTheory/src/main/java/graph/algorithms/interlacement/InterlacementGraphEdge.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/interlacement/InterlacementGraphEdge.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/interlacement/InterlacementGraphEdge.java diff --git a/GraphDrawingTheory/src/graph/algorithms/interlacement/InterlacementGraphVertex.java b/GraphDrawingTheory/src/main/java/graph/algorithms/interlacement/InterlacementGraphVertex.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/interlacement/InterlacementGraphVertex.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/interlacement/InterlacementGraphVertex.java index 395f778..3425f86 100644 --- a/GraphDrawingTheory/src/graph/algorithms/interlacement/InterlacementGraphVertex.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithms/interlacement/InterlacementGraphVertex.java @@ -1,11 +1,11 @@ package graph.algorithms.interlacement; +import java.awt.Dimension; + import graph.elements.Edge; import graph.elements.Path; import graph.elements.Vertex; -import java.awt.Dimension; - public class InterlacementGraphVertex> implements Vertex{ private Path content; diff --git a/GraphDrawingTheory/src/graph/algorithms/lrpartition/LRPartition.java b/GraphDrawingTheory/src/main/java/graph/algorithms/lrpartition/LRPartition.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/lrpartition/LRPartition.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/lrpartition/LRPartition.java index 6ee1740..0bc6211 100644 --- a/GraphDrawingTheory/src/graph/algorithms/lrpartition/LRPartition.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithms/lrpartition/LRPartition.java @@ -1,16 +1,16 @@ package graph.algorithms.lrpartition; +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; + import graph.elements.Edge; import graph.elements.Graph; import graph.elements.Vertex; import graph.traversal.DFSTreeTraversal; import graph.trees.DFSTree; -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; - /** * A partition B = L U R of DFS oriented graph's diff --git a/GraphDrawingTheory/src/graph/algorithms/lrpartition/LRPartitionEdge.java b/GraphDrawingTheory/src/main/java/graph/algorithms/lrpartition/LRPartitionEdge.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/lrpartition/LRPartitionEdge.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/lrpartition/LRPartitionEdge.java index aa56015..30ee940 100644 --- a/GraphDrawingTheory/src/graph/algorithms/lrpartition/LRPartitionEdge.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithms/lrpartition/LRPartitionEdge.java @@ -1,12 +1,12 @@ package graph.algorithms.lrpartition; -import graph.elements.Edge; -import graph.elements.Vertex; - import java.util.ArrayList; import java.util.List; import java.util.Set; +import graph.elements.Edge; +import graph.elements.Vertex; + public class LRPartitionEdge >{ diff --git a/GraphDrawingTheory/src/graph/algorithms/lrpartition/LRPartitionSet.java b/GraphDrawingTheory/src/main/java/graph/algorithms/lrpartition/LRPartitionSet.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/lrpartition/LRPartitionSet.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/lrpartition/LRPartitionSet.java index 3c2170a..e82f641 100644 --- a/GraphDrawingTheory/src/graph/algorithms/lrpartition/LRPartitionSet.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithms/lrpartition/LRPartitionSet.java @@ -1,15 +1,15 @@ package graph.algorithms.lrpartition; -import graph.elements.Edge; -import graph.elements.Vertex; -import graph.trees.DFSTree; - import java.util.ArrayList; import java.util.List; import java.util.Random; import org.apache.log4j.Logger; +import graph.elements.Edge; +import graph.elements.Vertex; +import graph.trees.DFSTree; + public class LRPartitionSet> { diff --git a/GraphDrawingTheory/src/graph/algorithms/numbering/DFSNumbering.java b/GraphDrawingTheory/src/main/java/graph/algorithms/numbering/DFSNumbering.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/numbering/DFSNumbering.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/numbering/DFSNumbering.java index 56db1df..eea3f37 100644 --- a/GraphDrawingTheory/src/graph/algorithms/numbering/DFSNumbering.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithms/numbering/DFSNumbering.java @@ -1,15 +1,15 @@ package graph.algorithms.numbering; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; + import graph.elements.Edge; import graph.elements.Graph; import graph.elements.Vertex; import graph.traversal.DFSTreeTraversal; import graph.trees.DFSTree; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; - public class DFSNumbering> extends Numbering{ private DFSTree dfsTree; diff --git a/GraphDrawingTheory/src/graph/algorithms/numbering/Numbering.java b/GraphDrawingTheory/src/main/java/graph/algorithms/numbering/Numbering.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/numbering/Numbering.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/numbering/Numbering.java index 0482794..3fad7da 100644 --- a/GraphDrawingTheory/src/graph/algorithms/numbering/Numbering.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithms/numbering/Numbering.java @@ -1,10 +1,10 @@ package graph.algorithms.numbering; +import java.util.List; + import graph.elements.Edge; import graph.elements.Vertex; -import java.util.List; - public abstract class Numbering> { protected List order; diff --git a/GraphDrawingTheory/src/graph/algorithms/numbering/STNumbering.java b/GraphDrawingTheory/src/main/java/graph/algorithms/numbering/STNumbering.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/numbering/STNumbering.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/numbering/STNumbering.java diff --git a/GraphDrawingTheory/src/graph/algorithms/planarity/BoyerMyrvoldPlanarity.java b/GraphDrawingTheory/src/main/java/graph/algorithms/planarity/BoyerMyrvoldPlanarity.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/planarity/BoyerMyrvoldPlanarity.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/planarity/BoyerMyrvoldPlanarity.java index 9431210..6f772f4 100644 --- a/GraphDrawingTheory/src/graph/algorithms/planarity/BoyerMyrvoldPlanarity.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithms/planarity/BoyerMyrvoldPlanarity.java @@ -1,14 +1,5 @@ package graph.algorithms.planarity; -import graph.algorithms.numbering.DFSNumbering; -import graph.algorithms.numbering.Numbering; -import graph.elements.Edge; -import graph.elements.Graph; -import graph.elements.Vertex; -import graph.enumerations.Direction; -import graph.traversal.DFSTreeTraversal; -import graph.trees.DFSTree; - import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -20,6 +11,15 @@ import org.apache.log4j.Logger; +import graph.algorithms.numbering.DFSNumbering; +import graph.algorithms.numbering.Numbering; +import graph.elements.Edge; +import graph.elements.Graph; +import graph.elements.Vertex; +import graph.enumerations.Direction; +import graph.traversal.DFSTreeTraversal; +import graph.trees.DFSTree; + /** * The Boyer-Myrvold algorithm is a planarity testing algorithm which uses reverse DFS order as numbering diff --git a/GraphDrawingTheory/src/graph/algorithms/planarity/Embedding.java b/GraphDrawingTheory/src/main/java/graph/algorithms/planarity/Embedding.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/planarity/Embedding.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/planarity/Embedding.java diff --git a/GraphDrawingTheory/src/graph/algorithms/planarity/FraysseixMendezPlanarity.java b/GraphDrawingTheory/src/main/java/graph/algorithms/planarity/FraysseixMendezPlanarity.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/planarity/FraysseixMendezPlanarity.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/planarity/FraysseixMendezPlanarity.java index 989445d..87c7451 100644 --- a/GraphDrawingTheory/src/graph/algorithms/planarity/FraysseixMendezPlanarity.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithms/planarity/FraysseixMendezPlanarity.java @@ -1,5 +1,9 @@ package graph.algorithms.planarity; +import java.util.List; + +import org.apache.log4j.Logger; + import graph.algorithms.lrpartition.LRPartition; import graph.elements.Edge; import graph.elements.EdgeDirection; @@ -9,10 +13,6 @@ import graph.traversal.GraphTraversal; import graph.trees.DFSTree; -import java.util.List; - -import org.apache.log4j.Logger; - /** * An algorithm for checking the planarity of a graph based on Fraysseix and Mendez's algorithm * @author xxx diff --git a/GraphDrawingTheory/src/graph/algorithms/planarity/MaximumPlanaritySubgraph.java b/GraphDrawingTheory/src/main/java/graph/algorithms/planarity/MaximumPlanaritySubgraph.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/planarity/MaximumPlanaritySubgraph.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/planarity/MaximumPlanaritySubgraph.java index b009927..1f42a62 100644 --- a/GraphDrawingTheory/src/graph/algorithms/planarity/MaximumPlanaritySubgraph.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithms/planarity/MaximumPlanaritySubgraph.java @@ -1,14 +1,14 @@ package graph.algorithms.planarity; +import java.util.ArrayList; +import java.util.List; + import graph.elements.Edge; import graph.elements.Graph; import graph.elements.Vertex; import graph.traversal.DFSTreeTraversal; import graph.trees.DFSTree; -import java.util.ArrayList; -import java.util.List; - /** * A widely used standard heuristic for finding a maximal planar subgraph is to start with * a spanning tree of G, and to iteratively try to add the remaining edges one by one diff --git a/GraphDrawingTheory/src/graph/algorithms/planarity/PQTreePlanarity.java b/GraphDrawingTheory/src/main/java/graph/algorithms/planarity/PQTreePlanarity.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/planarity/PQTreePlanarity.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/planarity/PQTreePlanarity.java diff --git a/GraphDrawingTheory/src/graph/algorithms/planarity/PlanarEmbedding.java b/GraphDrawingTheory/src/main/java/graph/algorithms/planarity/PlanarEmbedding.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/planarity/PlanarEmbedding.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/planarity/PlanarEmbedding.java diff --git a/GraphDrawingTheory/src/graph/algorithms/planarity/PlanarFaces.java b/GraphDrawingTheory/src/main/java/graph/algorithms/planarity/PlanarFaces.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/planarity/PlanarFaces.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/planarity/PlanarFaces.java diff --git a/GraphDrawingTheory/src/graph/algorithms/planarity/PlanarityTestingAlgorithm.java b/GraphDrawingTheory/src/main/java/graph/algorithms/planarity/PlanarityTestingAlgorithm.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/planarity/PlanarityTestingAlgorithm.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/planarity/PlanarityTestingAlgorithm.java diff --git a/GraphDrawingTheory/src/graph/algorithms/planarity/dual/DualGraphEdge.java b/GraphDrawingTheory/src/main/java/graph/algorithms/planarity/dual/DualGraphEdge.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/planarity/dual/DualGraphEdge.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/planarity/dual/DualGraphEdge.java diff --git a/GraphDrawingTheory/src/graph/algorithms/planarity/dual/DualGraphVertex.java b/GraphDrawingTheory/src/main/java/graph/algorithms/planarity/dual/DualGraphVertex.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/planarity/dual/DualGraphVertex.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/planarity/dual/DualGraphVertex.java diff --git a/GraphDrawingTheory/src/graph/algorithms/planarity/dual/STDualGraph.java b/GraphDrawingTheory/src/main/java/graph/algorithms/planarity/dual/STDualGraph.java similarity index 100% rename from GraphDrawingTheory/src/graph/algorithms/planarity/dual/STDualGraph.java rename to GraphDrawingTheory/src/main/java/graph/algorithms/planarity/dual/STDualGraph.java index b12a439..a0be052 100644 --- a/GraphDrawingTheory/src/graph/algorithms/planarity/dual/STDualGraph.java +++ b/GraphDrawingTheory/src/main/java/graph/algorithms/planarity/dual/STDualGraph.java @@ -1,14 +1,14 @@ package graph.algorithms.planarity.dual; +import java.util.ArrayList; +import java.util.List; + import graph.algorithms.planarity.PlanarFaces; import graph.elements.Edge; import graph.elements.Graph; import graph.elements.Vertex; import graph.exception.NotPlanarException; -import java.util.ArrayList; -import java.util.List; - /** * Given a planar st-graph G, the dual planar st-graph G = (V ∗, E∗) is a digraph with the following properties: diff --git a/GraphDrawingTheory/src/graph/drawing/Drawing.java b/GraphDrawingTheory/src/main/java/graph/drawing/Drawing.java similarity index 100% rename from GraphDrawingTheory/src/graph/drawing/Drawing.java rename to GraphDrawingTheory/src/main/java/graph/drawing/Drawing.java index 3283511..b69a5f0 100644 --- a/GraphDrawingTheory/src/graph/drawing/Drawing.java +++ b/GraphDrawingTheory/src/main/java/graph/drawing/Drawing.java @@ -1,8 +1,5 @@ package graph.drawing; -import graph.elements.Edge; -import graph.elements.Vertex; - import java.awt.Point; import java.awt.geom.Point2D; import java.util.ArrayList; @@ -10,6 +7,9 @@ import java.util.List; import java.util.Map; +import graph.elements.Edge; +import graph.elements.Vertex; + /** * A drawing Γ of a graph G = (V, E) is a mapping of each vertex v in V to a distinct point Γ(v) and of each edge e = (u, v) in E to a simple open Jordan curve Γ(e), diff --git a/GraphDrawingTheory/src/graph/elements/Edge.java b/GraphDrawingTheory/src/main/java/graph/elements/Edge.java similarity index 100% rename from GraphDrawingTheory/src/graph/elements/Edge.java rename to GraphDrawingTheory/src/main/java/graph/elements/Edge.java diff --git a/GraphDrawingTheory/src/graph/elements/EdgeDirection.java b/GraphDrawingTheory/src/main/java/graph/elements/EdgeDirection.java similarity index 100% rename from GraphDrawingTheory/src/graph/elements/EdgeDirection.java rename to GraphDrawingTheory/src/main/java/graph/elements/EdgeDirection.java diff --git a/GraphDrawingTheory/src/graph/elements/Graph.java b/GraphDrawingTheory/src/main/java/graph/elements/Graph.java similarity index 100% rename from GraphDrawingTheory/src/graph/elements/Graph.java rename to GraphDrawingTheory/src/main/java/graph/elements/Graph.java diff --git a/GraphDrawingTheory/src/graph/elements/Path.java b/GraphDrawingTheory/src/main/java/graph/elements/Path.java similarity index 100% rename from GraphDrawingTheory/src/graph/elements/Path.java rename to GraphDrawingTheory/src/main/java/graph/elements/Path.java diff --git a/GraphDrawingTheory/src/graph/elements/Vertex.java b/GraphDrawingTheory/src/main/java/graph/elements/Vertex.java similarity index 100% rename from GraphDrawingTheory/src/graph/elements/Vertex.java rename to GraphDrawingTheory/src/main/java/graph/elements/Vertex.java diff --git a/GraphDrawingTheory/src/graph/elements/VertexDegreeComparator.java b/GraphDrawingTheory/src/main/java/graph/elements/VertexDegreeComparator.java similarity index 100% rename from GraphDrawingTheory/src/graph/elements/VertexDegreeComparator.java rename to GraphDrawingTheory/src/main/java/graph/elements/VertexDegreeComparator.java diff --git a/GraphDrawingTheory/src/graph/elements/impl/GraphEdge.java b/GraphDrawingTheory/src/main/java/graph/elements/impl/GraphEdge.java similarity index 100% rename from GraphDrawingTheory/src/graph/elements/impl/GraphEdge.java rename to GraphDrawingTheory/src/main/java/graph/elements/impl/GraphEdge.java diff --git a/GraphDrawingTheory/src/graph/elements/impl/GraphVertex.java b/GraphDrawingTheory/src/main/java/graph/elements/impl/GraphVertex.java similarity index 100% rename from GraphDrawingTheory/src/graph/elements/impl/GraphVertex.java rename to GraphDrawingTheory/src/main/java/graph/elements/impl/GraphVertex.java diff --git a/GraphDrawingTheory/src/graph/enumerations/Direction.java b/GraphDrawingTheory/src/main/java/graph/enumerations/Direction.java similarity index 100% rename from GraphDrawingTheory/src/graph/enumerations/Direction.java rename to GraphDrawingTheory/src/main/java/graph/enumerations/Direction.java diff --git a/GraphDrawingTheory/src/graph/exception/CannotBeAppliedException.java b/GraphDrawingTheory/src/main/java/graph/exception/CannotBeAppliedException.java similarity index 100% rename from GraphDrawingTheory/src/graph/exception/CannotBeAppliedException.java rename to GraphDrawingTheory/src/main/java/graph/exception/CannotBeAppliedException.java diff --git a/GraphDrawingTheory/src/graph/exception/DSLException.java b/GraphDrawingTheory/src/main/java/graph/exception/DSLException.java similarity index 100% rename from GraphDrawingTheory/src/graph/exception/DSLException.java rename to GraphDrawingTheory/src/main/java/graph/exception/DSLException.java diff --git a/GraphDrawingTheory/src/graph/exception/NotPlanarException.java b/GraphDrawingTheory/src/main/java/graph/exception/NotPlanarException.java similarity index 100% rename from GraphDrawingTheory/src/graph/exception/NotPlanarException.java rename to GraphDrawingTheory/src/main/java/graph/exception/NotPlanarException.java diff --git a/GraphDrawingTheory/src/graph/layout/AbstractJGraphXLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/AbstractJGraphXLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/AbstractJGraphXLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/AbstractJGraphXLayouter.java index bb611f3..03344b1 100644 --- a/GraphDrawingTheory/src/graph/layout/AbstractJGraphXLayouter.java +++ b/GraphDrawingTheory/src/main/java/graph/layout/AbstractJGraphXLayouter.java @@ -1,10 +1,5 @@ package graph.layout; -import graph.drawing.Drawing; -import graph.elements.Edge; -import graph.elements.Graph; -import graph.elements.Vertex; - import java.awt.Dimension; import java.awt.geom.Point2D; import java.util.ArrayList; @@ -17,6 +12,11 @@ import com.mxgraph.model.mxIGraphModel; import com.mxgraph.view.mxGraph; +import graph.drawing.Drawing; +import graph.elements.Edge; +import graph.elements.Graph; +import graph.elements.Vertex; + public abstract class AbstractJGraphXLayouter> extends AbstractLayouter{ diff --git a/GraphDrawingTheory/src/graph/layout/AbstractJungLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/AbstractJungLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/AbstractJungLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/AbstractJungLayouter.java index 6479ceb..6ef8eb5 100644 --- a/GraphDrawingTheory/src/graph/layout/AbstractJungLayouter.java +++ b/GraphDrawingTheory/src/main/java/graph/layout/AbstractJungLayouter.java @@ -1,5 +1,7 @@ package graph.layout; +import java.awt.geom.Point2D; + import edu.uci.ics.jung.algorithms.layout.Layout; import edu.uci.ics.jung.visualization.DefaultVisualizationModel; import graph.drawing.Drawing; @@ -7,8 +9,6 @@ import graph.elements.Graph; import graph.elements.Vertex; -import java.awt.geom.Point2D; - public abstract class AbstractJungLayouter> extends AbstractLayouter{ diff --git a/GraphDrawingTheory/src/graph/layout/AbstractLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/AbstractLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/AbstractLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/AbstractLayouter.java diff --git a/GraphDrawingTheory/src/graph/layout/AbstractPrefuseLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/AbstractPrefuseLayouter.java similarity index 99% rename from GraphDrawingTheory/src/graph/layout/AbstractPrefuseLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/AbstractPrefuseLayouter.java index 10ec178..dc90d88 100644 --- a/GraphDrawingTheory/src/graph/layout/AbstractPrefuseLayouter.java +++ b/GraphDrawingTheory/src/main/java/graph/layout/AbstractPrefuseLayouter.java @@ -1,15 +1,14 @@ package graph.layout; +import java.awt.geom.Point2D; +import java.util.HashMap; +import java.util.Map; + import graph.drawing.Drawing; import graph.elements.Edge; import graph.elements.Graph; import graph.elements.Vertex; import graph.layout.util.PositionAction; - -import java.awt.geom.Point2D; -import java.util.HashMap; -import java.util.Map; - import prefuse.Display; import prefuse.Visualization; import prefuse.action.ActionList; diff --git a/GraphDrawingTheory/src/graph/layout/AestheticCriteria.java b/GraphDrawingTheory/src/main/java/graph/layout/AestheticCriteria.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/AestheticCriteria.java rename to GraphDrawingTheory/src/main/java/graph/layout/AestheticCriteria.java diff --git a/GraphDrawingTheory/src/graph/layout/DefaultGraphLayoutProperties.java b/GraphDrawingTheory/src/main/java/graph/layout/DefaultGraphLayoutProperties.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/DefaultGraphLayoutProperties.java rename to GraphDrawingTheory/src/main/java/graph/layout/DefaultGraphLayoutProperties.java diff --git a/GraphDrawingTheory/src/graph/layout/GraphLayoutProperties.java b/GraphDrawingTheory/src/main/java/graph/layout/GraphLayoutProperties.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/GraphLayoutProperties.java rename to GraphDrawingTheory/src/main/java/graph/layout/GraphLayoutProperties.java diff --git a/GraphDrawingTheory/src/graph/layout/LayoutAestheticMap.java b/GraphDrawingTheory/src/main/java/graph/layout/LayoutAestheticMap.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/LayoutAestheticMap.java rename to GraphDrawingTheory/src/main/java/graph/layout/LayoutAestheticMap.java diff --git a/GraphDrawingTheory/src/graph/layout/LayoutAlgorithms.java b/GraphDrawingTheory/src/main/java/graph/layout/LayoutAlgorithms.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/LayoutAlgorithms.java rename to GraphDrawingTheory/src/main/java/graph/layout/LayoutAlgorithms.java diff --git a/GraphDrawingTheory/src/graph/layout/Layouter.java b/GraphDrawingTheory/src/main/java/graph/layout/Layouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/Layouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/Layouter.java diff --git a/GraphDrawingTheory/src/graph/layout/LayouterFactory.java b/GraphDrawingTheory/src/main/java/graph/layout/LayouterFactory.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/LayouterFactory.java rename to GraphDrawingTheory/src/main/java/graph/layout/LayouterFactory.java diff --git a/GraphDrawingTheory/src/graph/layout/PropertyEnums.java b/GraphDrawingTheory/src/main/java/graph/layout/PropertyEnums.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/PropertyEnums.java rename to GraphDrawingTheory/src/main/java/graph/layout/PropertyEnums.java diff --git a/GraphDrawingTheory/src/graph/layout/automatic/AutomaticPropertiesLayout.java b/GraphDrawingTheory/src/main/java/graph/layout/automatic/AutomaticPropertiesLayout.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/automatic/AutomaticPropertiesLayout.java rename to GraphDrawingTheory/src/main/java/graph/layout/automatic/AutomaticPropertiesLayout.java diff --git a/GraphDrawingTheory/src/graph/layout/automatic/LayoutPicker.java b/GraphDrawingTheory/src/main/java/graph/layout/automatic/LayoutPicker.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/automatic/LayoutPicker.java rename to GraphDrawingTheory/src/main/java/graph/layout/automatic/LayoutPicker.java diff --git a/GraphDrawingTheory/src/graph/layout/box/BoxLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/box/BoxLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/box/BoxLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/box/BoxLayouter.java index 7526129..b8f29b1 100644 --- a/GraphDrawingTheory/src/graph/layout/box/BoxLayouter.java +++ b/GraphDrawingTheory/src/main/java/graph/layout/box/BoxLayouter.java @@ -1,5 +1,9 @@ package graph.layout.box; +import java.awt.Dimension; +import java.awt.Point; +import java.util.List; + import graph.drawing.Drawing; import graph.elements.Edge; import graph.elements.Graph; @@ -8,10 +12,6 @@ import graph.layout.GraphLayoutProperties; import graph.layout.PropertyEnums.BoxProperties; -import java.awt.Dimension; -import java.awt.Point; -import java.util.List; - /** * A simple layout algorithm which places elements in a table like structure * Suitable if the elements are not linked diff --git a/GraphDrawingTheory/src/graph/layout/circle/CircleLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/circle/CircleLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/circle/CircleLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/circle/CircleLayouter.java index 8c2a355..0f7536b 100644 --- a/GraphDrawingTheory/src/graph/layout/circle/CircleLayouter.java +++ b/GraphDrawingTheory/src/main/java/graph/layout/circle/CircleLayouter.java @@ -1,5 +1,9 @@ package graph.layout.circle; +import java.awt.geom.Point2D; +import java.util.List; +import java.util.Map; + import graph.drawing.Drawing; import graph.elements.Edge; import graph.elements.Graph; @@ -10,10 +14,6 @@ import graph.math.CircleLayoutCalc; import graph.ordering.circular.Circular; -import java.awt.geom.Point2D; -import java.util.List; -import java.util.Map; - public class CircleLayouter> extends AbstractLayouter{ public CircleLayouter() { diff --git a/GraphDrawingTheory/src/graph/layout/circle/CircleWithCenterLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/circle/CircleWithCenterLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/circle/CircleWithCenterLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/circle/CircleWithCenterLayouter.java index fd84f97..687250a 100644 --- a/GraphDrawingTheory/src/graph/layout/circle/CircleWithCenterLayouter.java +++ b/GraphDrawingTheory/src/main/java/graph/layout/circle/CircleWithCenterLayouter.java @@ -1,5 +1,7 @@ package graph.layout.circle; +import java.awt.geom.Point2D; + import graph.drawing.Drawing; import graph.elements.Edge; import graph.elements.Graph; @@ -7,8 +9,6 @@ import graph.layout.AbstractLayouter; import graph.layout.GraphLayoutProperties; -import java.awt.geom.Point2D; - /** * This layouter takes places vertices on a circumference of a circle, diff --git a/GraphDrawingTheory/src/graph/layout/dsl/DSLLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/dsl/DSLLayouter.java similarity index 99% rename from GraphDrawingTheory/src/graph/layout/dsl/DSLLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/dsl/DSLLayouter.java index 30a9cbf..7a476ef 100644 --- a/GraphDrawingTheory/src/graph/layout/dsl/DSLLayouter.java +++ b/GraphDrawingTheory/src/main/java/graph/layout/dsl/DSLLayouter.java @@ -1,5 +1,11 @@ package graph.layout.dsl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.swing.SwingConstants; + import graph.algorithms.drawing.ConvexDrawing; import graph.algorithms.planarity.FraysseixMendezPlanarity; import graph.drawing.Drawing; @@ -8,7 +14,6 @@ import graph.elements.Vertex; import graph.exception.CannotBeAppliedException; import graph.exception.DSLException; -import graph.layout.AestheticCriteria; import graph.layout.DefaultGraphLayoutProperties; import graph.layout.GraphLayoutProperties; import graph.layout.LayoutAlgorithms; @@ -30,13 +35,6 @@ import interfaces.ILayout; import interfaces.ILayoutGraph; import interpreter.java.Interpreter; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.swing.SwingConstants; - import models.java.LayoutGraph; import models.java.LayoutSubgraphs; diff --git a/GraphDrawingTheory/src/graph/layout/force/directed/AbstractForceDirectedLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/force/directed/AbstractForceDirectedLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/force/directed/AbstractForceDirectedLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/force/directed/AbstractForceDirectedLayouter.java diff --git a/GraphDrawingTheory/src/graph/layout/force/directed/DAGLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/force/directed/DAGLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/force/directed/DAGLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/force/directed/DAGLayouter.java diff --git a/GraphDrawingTheory/src/graph/layout/force/directed/FruchtermanReingoldLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/force/directed/FruchtermanReingoldLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/force/directed/FruchtermanReingoldLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/force/directed/FruchtermanReingoldLayouter.java diff --git a/GraphDrawingTheory/src/graph/layout/force/directed/KamadaKawaiLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/force/directed/KamadaKawaiLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/force/directed/KamadaKawaiLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/force/directed/KamadaKawaiLayouter.java diff --git a/GraphDrawingTheory/src/graph/layout/force/directed/PrefuseForceDirectedLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/force/directed/PrefuseForceDirectedLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/force/directed/PrefuseForceDirectedLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/force/directed/PrefuseForceDirectedLayouter.java diff --git a/GraphDrawingTheory/src/graph/layout/force/directed/SpringLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/force/directed/SpringLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/force/directed/SpringLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/force/directed/SpringLayouter.java diff --git a/GraphDrawingTheory/src/graph/layout/organic/JGraphFastorganicLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/organic/JGraphFastorganicLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/organic/JGraphFastorganicLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/organic/JGraphFastorganicLayouter.java diff --git a/GraphDrawingTheory/src/graph/layout/organic/JGraphHierarchicalLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/organic/JGraphHierarchicalLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/organic/JGraphHierarchicalLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/organic/JGraphHierarchicalLayouter.java index 0c92fb0..66665cc 100644 --- a/GraphDrawingTheory/src/graph/layout/organic/JGraphHierarchicalLayouter.java +++ b/GraphDrawingTheory/src/main/java/graph/layout/organic/JGraphHierarchicalLayouter.java @@ -1,13 +1,13 @@ package graph.layout.organic; +import com.mxgraph.layout.hierarchical.mxHierarchicalLayout; + import graph.elements.Edge; import graph.elements.Vertex; import graph.layout.AbstractJGraphXLayouter; import graph.layout.GraphLayoutProperties; import graph.layout.PropertyEnums.HierarchicalProperties; -import com.mxgraph.layout.hierarchical.mxHierarchicalLayout; - public class JGraphHierarchicalLayouter> extends AbstractJGraphXLayouter { public JGraphHierarchicalLayouter(){ diff --git a/GraphDrawingTheory/src/graph/layout/organic/JGraphOrganicLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/organic/JGraphOrganicLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/organic/JGraphOrganicLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/organic/JGraphOrganicLayouter.java diff --git a/GraphDrawingTheory/src/graph/layout/organic/JungISOMLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/organic/JungISOMLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/organic/JungISOMLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/organic/JungISOMLayouter.java diff --git a/GraphDrawingTheory/src/graph/layout/orthogonal/EntryDirection.java b/GraphDrawingTheory/src/main/java/graph/layout/orthogonal/EntryDirection.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/orthogonal/EntryDirection.java rename to GraphDrawingTheory/src/main/java/graph/layout/orthogonal/EntryDirection.java diff --git a/GraphDrawingTheory/src/graph/layout/orthogonal/OrthogonalConnector.java b/GraphDrawingTheory/src/main/java/graph/layout/orthogonal/OrthogonalConnector.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/orthogonal/OrthogonalConnector.java rename to GraphDrawingTheory/src/main/java/graph/layout/orthogonal/OrthogonalConnector.java index 9d53a5b..f26fa2a 100644 --- a/GraphDrawingTheory/src/graph/layout/orthogonal/OrthogonalConnector.java +++ b/GraphDrawingTheory/src/main/java/graph/layout/orthogonal/OrthogonalConnector.java @@ -1,11 +1,11 @@ package graph.layout.orthogonal; -import graph.elements.Vertex; - import java.awt.geom.Point2D; import java.util.ArrayList; import java.util.List; +import graph.elements.Vertex; + public class OrthogonalConnector { private V vertex; diff --git a/GraphDrawingTheory/src/graph/layout/orthogonal/VisibilityRepresentationLayout.java b/GraphDrawingTheory/src/main/java/graph/layout/orthogonal/VisibilityRepresentationLayout.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/orthogonal/VisibilityRepresentationLayout.java rename to GraphDrawingTheory/src/main/java/graph/layout/orthogonal/VisibilityRepresentationLayout.java diff --git a/GraphDrawingTheory/src/graph/layout/router/OrthogonalEdgeRouter.java b/GraphDrawingTheory/src/main/java/graph/layout/router/OrthogonalEdgeRouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/router/OrthogonalEdgeRouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/router/OrthogonalEdgeRouter.java diff --git a/GraphDrawingTheory/src/graph/layout/straight/line/ConvexLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/straight/line/ConvexLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/straight/line/ConvexLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/straight/line/ConvexLayouter.java index db0a658..e446aa3 100644 --- a/GraphDrawingTheory/src/graph/layout/straight/line/ConvexLayouter.java +++ b/GraphDrawingTheory/src/main/java/graph/layout/straight/line/ConvexLayouter.java @@ -1,5 +1,8 @@ package graph.layout.straight.line; +import java.awt.geom.Point2D; +import java.util.Map; + import graph.algorithms.drawing.ConvexDrawing; import graph.drawing.Drawing; import graph.elements.Edge; @@ -8,9 +11,6 @@ import graph.layout.AbstractLayouter; import graph.layout.GraphLayoutProperties; -import java.awt.geom.Point2D; -import java.util.Map; - public class ConvexLayouter> extends AbstractLayouter { @Override diff --git a/GraphDrawingTheory/src/graph/layout/straight/line/TutteLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/straight/line/TutteLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/straight/line/TutteLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/straight/line/TutteLayouter.java index 1e41f07..af98e78 100644 --- a/GraphDrawingTheory/src/graph/layout/straight/line/TutteLayouter.java +++ b/GraphDrawingTheory/src/main/java/graph/layout/straight/line/TutteLayouter.java @@ -1,5 +1,9 @@ package graph.layout.straight.line; +import java.awt.geom.Point2D; +import java.util.List; +import java.util.Map; + import graph.algorithms.drawing.TutteEmbedding; import graph.algorithms.planarity.BoyerMyrvoldPlanarity; import graph.drawing.Drawing; @@ -10,10 +14,6 @@ import graph.layout.PropertyEnums.TutteProperties; import graph.layout.symmetric.SymmetricLayouter; -import java.awt.geom.Point2D; -import java.util.List; -import java.util.Map; - public class TutteLayouter > extends SymmetricLayouter{ diff --git a/GraphDrawingTheory/src/graph/layout/symmetric/SymmetricCircleLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/symmetric/SymmetricCircleLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/symmetric/SymmetricCircleLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/symmetric/SymmetricCircleLayouter.java index 4425182..8b28303 100644 --- a/GraphDrawingTheory/src/graph/layout/symmetric/SymmetricCircleLayouter.java +++ b/GraphDrawingTheory/src/main/java/graph/layout/symmetric/SymmetricCircleLayouter.java @@ -1,5 +1,11 @@ package graph.layout.symmetric; +import java.awt.geom.Point2D; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Map; + import graph.algorithms.drawing.CyclicSymmetricGraphDrawing; import graph.drawing.Drawing; import graph.elements.Edge; @@ -9,12 +15,6 @@ import graph.layout.PropertyEnums.SymmetricProperties; import graph.symmetry.Permutation; -import java.awt.geom.Point2D; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; - public class SymmetricCircleLayouter > extends SymmetricLayouter{ diff --git a/GraphDrawingTheory/src/graph/layout/symmetric/SymmetricLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/symmetric/SymmetricLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/symmetric/SymmetricLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/symmetric/SymmetricLayouter.java index ff47d61..1c87a1a 100644 --- a/GraphDrawingTheory/src/graph/layout/symmetric/SymmetricLayouter.java +++ b/GraphDrawingTheory/src/main/java/graph/layout/symmetric/SymmetricLayouter.java @@ -1,5 +1,7 @@ package graph.layout.symmetric; +import java.awt.geom.Point2D; + import graph.elements.Edge; import graph.elements.Graph; import graph.elements.Vertex; @@ -8,8 +10,6 @@ import graph.symmetry.Permutation; import graph.symmetry.nauty.McKayGraphLabelingAlgorithm; -import java.awt.geom.Point2D; - public abstract class SymmetricLayouter > extends AbstractLayouter{ protected Permutation p; diff --git a/GraphDrawingTheory/src/graph/layout/tree/JGraphCompactTreeLayout.java b/GraphDrawingTheory/src/main/java/graph/layout/tree/JGraphCompactTreeLayout.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/tree/JGraphCompactTreeLayout.java rename to GraphDrawingTheory/src/main/java/graph/layout/tree/JGraphCompactTreeLayout.java diff --git a/GraphDrawingTheory/src/graph/layout/tree/JungTreeLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/tree/JungTreeLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/tree/JungTreeLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/tree/JungTreeLayouter.java diff --git a/GraphDrawingTheory/src/graph/layout/tree/PrefuseBalloonLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/tree/PrefuseBalloonLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/tree/PrefuseBalloonLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/tree/PrefuseBalloonLayouter.java diff --git a/GraphDrawingTheory/src/graph/layout/tree/PrefuseNodeLinkTreeLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/tree/PrefuseNodeLinkTreeLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/tree/PrefuseNodeLinkTreeLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/tree/PrefuseNodeLinkTreeLayouter.java index a224b3b..44e990d 100644 --- a/GraphDrawingTheory/src/graph/layout/tree/PrefuseNodeLinkTreeLayouter.java +++ b/GraphDrawingTheory/src/main/java/graph/layout/tree/PrefuseNodeLinkTreeLayouter.java @@ -1,11 +1,11 @@ package graph.layout.tree; -import prefuse.action.layout.graph.NodeLinkTreeLayout; import graph.elements.Edge; import graph.elements.Vertex; import graph.layout.AbstractPrefuseLayouter; import graph.layout.GraphLayoutProperties; import graph.layout.PropertyEnums.NodeLinkTreeProperties; +import prefuse.action.layout.graph.NodeLinkTreeLayout; public class PrefuseNodeLinkTreeLayouter> extends AbstractPrefuseLayouter{ diff --git a/GraphDrawingTheory/src/graph/layout/tree/PrefuseRadialTreeLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/tree/PrefuseRadialTreeLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/tree/PrefuseRadialTreeLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/tree/PrefuseRadialTreeLayouter.java index b58b1f3..5e15343 100644 --- a/GraphDrawingTheory/src/graph/layout/tree/PrefuseRadialTreeLayouter.java +++ b/GraphDrawingTheory/src/main/java/graph/layout/tree/PrefuseRadialTreeLayouter.java @@ -1,11 +1,11 @@ package graph.layout.tree; -import prefuse.action.layout.graph.RadialTreeLayout; import graph.elements.Edge; import graph.elements.Vertex; import graph.layout.AbstractPrefuseLayouter; import graph.layout.GraphLayoutProperties; import graph.layout.PropertyEnums.RadialTree2Properties; +import prefuse.action.layout.graph.RadialTreeLayout; public class PrefuseRadialTreeLayouter> extends AbstractPrefuseLayouter{ diff --git a/GraphDrawingTheory/src/graph/layout/tree/RadialTreeLayouter.java b/GraphDrawingTheory/src/main/java/graph/layout/tree/RadialTreeLayouter.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/tree/RadialTreeLayouter.java rename to GraphDrawingTheory/src/main/java/graph/layout/tree/RadialTreeLayouter.java diff --git a/GraphDrawingTheory/src/graph/layout/util/PositionAction.java b/GraphDrawingTheory/src/main/java/graph/layout/util/PositionAction.java similarity index 100% rename from GraphDrawingTheory/src/graph/layout/util/PositionAction.java rename to GraphDrawingTheory/src/main/java/graph/layout/util/PositionAction.java diff --git a/GraphDrawingTheory/src/graph/math/Calc.java b/GraphDrawingTheory/src/main/java/graph/math/Calc.java similarity index 100% rename from GraphDrawingTheory/src/graph/math/Calc.java rename to GraphDrawingTheory/src/main/java/graph/math/Calc.java diff --git a/GraphDrawingTheory/src/graph/math/CircleLayoutCalc.java b/GraphDrawingTheory/src/main/java/graph/math/CircleLayoutCalc.java similarity index 100% rename from GraphDrawingTheory/src/graph/math/CircleLayoutCalc.java rename to GraphDrawingTheory/src/main/java/graph/math/CircleLayoutCalc.java index 5b533fa..d4e358b 100644 --- a/GraphDrawingTheory/src/graph/math/CircleLayoutCalc.java +++ b/GraphDrawingTheory/src/main/java/graph/math/CircleLayoutCalc.java @@ -1,7 +1,5 @@ package graph.math; -import graph.elements.Vertex; - import java.awt.Point; import java.awt.geom.Point2D; import java.util.ArrayList; @@ -11,6 +9,8 @@ import java.util.List; import java.util.Map; +import graph.elements.Vertex; + public class CircleLayoutCalc { diff --git a/GraphDrawingTheory/src/graph/math/CramersRule.java b/GraphDrawingTheory/src/main/java/graph/math/CramersRule.java similarity index 100% rename from GraphDrawingTheory/src/graph/math/CramersRule.java rename to GraphDrawingTheory/src/main/java/graph/math/CramersRule.java diff --git a/GraphDrawingTheory/src/graph/math/CzekanovskiDiceDistance.java b/GraphDrawingTheory/src/main/java/graph/math/CzekanovskiDiceDistance.java similarity index 100% rename from GraphDrawingTheory/src/graph/math/CzekanovskiDiceDistance.java rename to GraphDrawingTheory/src/main/java/graph/math/CzekanovskiDiceDistance.java index 4b21f7d..af7b9d3 100644 --- a/GraphDrawingTheory/src/graph/math/CzekanovskiDiceDistance.java +++ b/GraphDrawingTheory/src/main/java/graph/math/CzekanovskiDiceDistance.java @@ -1,14 +1,14 @@ package graph.math; -import graph.elements.Edge; -import graph.elements.Graph; -import graph.elements.Vertex; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import graph.elements.Edge; +import graph.elements.Graph; +import graph.elements.Vertex; + /** With respect to Czekanovski-Dice distance, * two vertices are close to each other if they * have many common vertices*/ diff --git a/GraphDrawingTheory/src/graph/math/GramSchmidt.java b/GraphDrawingTheory/src/main/java/graph/math/GramSchmidt.java similarity index 100% rename from GraphDrawingTheory/src/graph/math/GramSchmidt.java rename to GraphDrawingTheory/src/main/java/graph/math/GramSchmidt.java diff --git a/GraphDrawingTheory/src/graph/math/Line.java b/GraphDrawingTheory/src/main/java/graph/math/Line.java similarity index 100% rename from GraphDrawingTheory/src/graph/math/Line.java rename to GraphDrawingTheory/src/main/java/graph/math/Line.java diff --git a/GraphDrawingTheory/src/graph/math/Matrix.java b/GraphDrawingTheory/src/main/java/graph/math/Matrix.java similarity index 100% rename from GraphDrawingTheory/src/graph/math/Matrix.java rename to GraphDrawingTheory/src/main/java/graph/math/Matrix.java diff --git a/GraphDrawingTheory/src/graph/math/MatrixUtil.java b/GraphDrawingTheory/src/main/java/graph/math/MatrixUtil.java similarity index 100% rename from GraphDrawingTheory/src/graph/math/MatrixUtil.java rename to GraphDrawingTheory/src/main/java/graph/math/MatrixUtil.java diff --git a/GraphDrawingTheory/src/graph/math/Triangle.java b/GraphDrawingTheory/src/main/java/graph/math/Triangle.java similarity index 100% rename from GraphDrawingTheory/src/graph/math/Triangle.java rename to GraphDrawingTheory/src/main/java/graph/math/Triangle.java diff --git a/GraphDrawingTheory/src/graph/operations/GraphOperations.java b/GraphDrawingTheory/src/main/java/graph/operations/GraphOperations.java similarity index 100% rename from GraphDrawingTheory/src/graph/operations/GraphOperations.java rename to GraphDrawingTheory/src/main/java/graph/operations/GraphOperations.java index b5c5357..395cf96 100644 --- a/GraphDrawingTheory/src/graph/operations/GraphOperations.java +++ b/GraphDrawingTheory/src/main/java/graph/operations/GraphOperations.java @@ -1,12 +1,12 @@ package graph.operations; +import java.util.ArrayList; +import java.util.List; + import graph.elements.Edge; import graph.elements.Graph; import graph.elements.Vertex; -import java.util.ArrayList; -import java.util.List; - public class GraphOperations> { diff --git a/GraphDrawingTheory/src/graph/ordering/CanonicalOrdering.java b/GraphDrawingTheory/src/main/java/graph/ordering/CanonicalOrdering.java similarity index 100% rename from GraphDrawingTheory/src/graph/ordering/CanonicalOrdering.java rename to GraphDrawingTheory/src/main/java/graph/ordering/CanonicalOrdering.java diff --git a/GraphDrawingTheory/src/graph/ordering/TopologicalOrdering.java b/GraphDrawingTheory/src/main/java/graph/ordering/TopologicalOrdering.java similarity index 100% rename from GraphDrawingTheory/src/graph/ordering/TopologicalOrdering.java rename to GraphDrawingTheory/src/main/java/graph/ordering/TopologicalOrdering.java diff --git a/GraphDrawingTheory/src/graph/ordering/circular/Circular.java b/GraphDrawingTheory/src/main/java/graph/ordering/circular/Circular.java similarity index 100% rename from GraphDrawingTheory/src/graph/ordering/circular/Circular.java rename to GraphDrawingTheory/src/main/java/graph/ordering/circular/Circular.java index fb4a66e..743b4f6 100644 --- a/GraphDrawingTheory/src/graph/ordering/circular/Circular.java +++ b/GraphDrawingTheory/src/main/java/graph/ordering/circular/Circular.java @@ -1,5 +1,11 @@ package graph.ordering.circular; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.log4j.Logger; + import graph.elements.Edge; import graph.elements.Graph; import graph.elements.Path; @@ -7,12 +13,6 @@ import graph.elements.VertexDegreeComparator; import graph.traversal.GraphTraversal; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.apache.log4j.Logger; - public class Circular> { private Graph graph; diff --git a/GraphDrawingTheory/src/graph/ordering/circular/GraphCopy.java b/GraphDrawingTheory/src/main/java/graph/ordering/circular/GraphCopy.java similarity index 100% rename from GraphDrawingTheory/src/graph/ordering/circular/GraphCopy.java rename to GraphDrawingTheory/src/main/java/graph/ordering/circular/GraphCopy.java index 8ced70c..6608ca2 100644 --- a/GraphDrawingTheory/src/graph/ordering/circular/GraphCopy.java +++ b/GraphDrawingTheory/src/main/java/graph/ordering/circular/GraphCopy.java @@ -1,12 +1,12 @@ package graph.ordering.circular; +import java.util.ArrayList; +import java.util.List; + import graph.elements.Edge; import graph.elements.Graph; import graph.elements.Vertex; -import java.util.ArrayList; -import java.util.List; - public class GraphCopy> extends Graph { diff --git a/GraphDrawingTheory/src/graph/ordering/circular/TriangulatedEdge.java b/GraphDrawingTheory/src/main/java/graph/ordering/circular/TriangulatedEdge.java similarity index 100% rename from GraphDrawingTheory/src/graph/ordering/circular/TriangulatedEdge.java rename to GraphDrawingTheory/src/main/java/graph/ordering/circular/TriangulatedEdge.java diff --git a/GraphDrawingTheory/src/graph/properties/Bipartite.java b/GraphDrawingTheory/src/main/java/graph/properties/Bipartite.java similarity index 100% rename from GraphDrawingTheory/src/graph/properties/Bipartite.java rename to GraphDrawingTheory/src/main/java/graph/properties/Bipartite.java index 8c5bc52..4187926 100644 --- a/GraphDrawingTheory/src/graph/properties/Bipartite.java +++ b/GraphDrawingTheory/src/main/java/graph/properties/Bipartite.java @@ -1,14 +1,14 @@ package graph.properties; -import graph.elements.Edge; -import graph.elements.Graph; -import graph.elements.Vertex; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import graph.elements.Edge; +import graph.elements.Graph; +import graph.elements.Vertex; + /** * Bipartite graph (or bigraph) is a graph whose vertices can be divided into two disjoint sets U and V *(that is, U and V are each independent sets) such that every edge connects a vertex in U to one in V. diff --git a/GraphDrawingTheory/src/graph/properties/GraphProperties.java b/GraphDrawingTheory/src/main/java/graph/properties/GraphProperties.java similarity index 100% rename from GraphDrawingTheory/src/graph/properties/GraphProperties.java rename to GraphDrawingTheory/src/main/java/graph/properties/GraphProperties.java diff --git a/GraphDrawingTheory/src/graph/properties/components/Block.java b/GraphDrawingTheory/src/main/java/graph/properties/components/Block.java similarity index 100% rename from GraphDrawingTheory/src/graph/properties/components/Block.java rename to GraphDrawingTheory/src/main/java/graph/properties/components/Block.java diff --git a/GraphDrawingTheory/src/graph/properties/components/Component.java b/GraphDrawingTheory/src/main/java/graph/properties/components/Component.java similarity index 100% rename from GraphDrawingTheory/src/graph/properties/components/Component.java rename to GraphDrawingTheory/src/main/java/graph/properties/components/Component.java index c42d6a0..68835f0 100644 --- a/GraphDrawingTheory/src/graph/properties/components/Component.java +++ b/GraphDrawingTheory/src/main/java/graph/properties/components/Component.java @@ -1,11 +1,11 @@ package graph.properties.components; -import graph.elements.Edge; -import graph.elements.Vertex; - import java.util.ArrayList; import java.util.List; +import graph.elements.Edge; +import graph.elements.Vertex; + public class Component> { protected List edges; diff --git a/GraphDrawingTheory/src/graph/properties/components/HopcroftTarjanSplitComponent.java b/GraphDrawingTheory/src/main/java/graph/properties/components/HopcroftTarjanSplitComponent.java similarity index 100% rename from GraphDrawingTheory/src/graph/properties/components/HopcroftTarjanSplitComponent.java rename to GraphDrawingTheory/src/main/java/graph/properties/components/HopcroftTarjanSplitComponent.java diff --git a/GraphDrawingTheory/src/graph/properties/components/SplitComponent.java b/GraphDrawingTheory/src/main/java/graph/properties/components/SplitComponent.java similarity index 100% rename from GraphDrawingTheory/src/graph/properties/components/SplitComponent.java rename to GraphDrawingTheory/src/main/java/graph/properties/components/SplitComponent.java diff --git a/GraphDrawingTheory/src/graph/properties/components/SplitPair.java b/GraphDrawingTheory/src/main/java/graph/properties/components/SplitPair.java similarity index 100% rename from GraphDrawingTheory/src/graph/properties/components/SplitPair.java rename to GraphDrawingTheory/src/main/java/graph/properties/components/SplitPair.java diff --git a/GraphDrawingTheory/src/graph/properties/components/SplitTriconnectedComponentType.java b/GraphDrawingTheory/src/main/java/graph/properties/components/SplitTriconnectedComponentType.java similarity index 100% rename from GraphDrawingTheory/src/graph/properties/components/SplitTriconnectedComponentType.java rename to GraphDrawingTheory/src/main/java/graph/properties/components/SplitTriconnectedComponentType.java diff --git a/GraphDrawingTheory/src/graph/properties/splitting/AlgorithmErrorException.java b/GraphDrawingTheory/src/main/java/graph/properties/splitting/AlgorithmErrorException.java similarity index 100% rename from GraphDrawingTheory/src/graph/properties/splitting/AlgorithmErrorException.java rename to GraphDrawingTheory/src/main/java/graph/properties/splitting/AlgorithmErrorException.java diff --git a/GraphDrawingTheory/src/graph/properties/splitting/BiconnectedSplitting.java b/GraphDrawingTheory/src/main/java/graph/properties/splitting/BiconnectedSplitting.java similarity index 100% rename from GraphDrawingTheory/src/graph/properties/splitting/BiconnectedSplitting.java rename to GraphDrawingTheory/src/main/java/graph/properties/splitting/BiconnectedSplitting.java index ab63c8f..29be0bf 100644 --- a/GraphDrawingTheory/src/graph/properties/splitting/BiconnectedSplitting.java +++ b/GraphDrawingTheory/src/main/java/graph/properties/splitting/BiconnectedSplitting.java @@ -1,13 +1,13 @@ package graph.properties.splitting; -import graph.elements.Edge; -import graph.elements.Graph; -import graph.elements.Vertex; - import java.util.ArrayList; import java.util.List; import java.util.Stack; +import graph.elements.Edge; +import graph.elements.Graph; +import graph.elements.Vertex; + /** * Finds all biconnected components of a graph * efficiently, by using the depth-first search diff --git a/GraphDrawingTheory/src/graph/properties/splitting/HopcroftTarjanSplitting.java b/GraphDrawingTheory/src/main/java/graph/properties/splitting/HopcroftTarjanSplitting.java similarity index 100% rename from GraphDrawingTheory/src/graph/properties/splitting/HopcroftTarjanSplitting.java rename to GraphDrawingTheory/src/main/java/graph/properties/splitting/HopcroftTarjanSplitting.java index ef3ca7c..2bf8e14 100644 --- a/GraphDrawingTheory/src/graph/properties/splitting/HopcroftTarjanSplitting.java +++ b/GraphDrawingTheory/src/main/java/graph/properties/splitting/HopcroftTarjanSplitting.java @@ -1,12 +1,5 @@ package graph.properties.splitting; -import graph.elements.Edge; -import graph.elements.Graph; -import graph.elements.Vertex; -import graph.properties.components.HopcroftTarjanSplitComponent; -import graph.properties.components.SplitTriconnectedComponentType; -import graph.util.Util; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -15,6 +8,13 @@ import org.apache.log4j.Logger; +import graph.elements.Edge; +import graph.elements.Graph; +import graph.elements.Vertex; +import graph.properties.components.HopcroftTarjanSplitComponent; +import graph.properties.components.SplitTriconnectedComponentType; +import graph.util.Util; + /** * Implementation based on Hopcroft and Tarjan's algorithm: * J. E. Hopcroft and R. E. Tarjan, Dividing a graph into triconnected components, diff --git a/GraphDrawingTheory/src/graph/properties/splitting/SeparationPair.java b/GraphDrawingTheory/src/main/java/graph/properties/splitting/SeparationPair.java similarity index 100% rename from GraphDrawingTheory/src/graph/properties/splitting/SeparationPair.java rename to GraphDrawingTheory/src/main/java/graph/properties/splitting/SeparationPair.java diff --git a/GraphDrawingTheory/src/graph/properties/splitting/SeparationPairSplitting.java b/GraphDrawingTheory/src/main/java/graph/properties/splitting/SeparationPairSplitting.java similarity index 100% rename from GraphDrawingTheory/src/graph/properties/splitting/SeparationPairSplitting.java rename to GraphDrawingTheory/src/main/java/graph/properties/splitting/SeparationPairSplitting.java index 35e0b96..5fbe45c 100644 --- a/GraphDrawingTheory/src/graph/properties/splitting/SeparationPairSplitting.java +++ b/GraphDrawingTheory/src/main/java/graph/properties/splitting/SeparationPairSplitting.java @@ -1,11 +1,5 @@ package graph.properties.splitting; -import graph.elements.Edge; -import graph.elements.Graph; -import graph.elements.Vertex; -import graph.properties.components.SplitPair; -import graph.trees.DFSTree; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -13,6 +7,12 @@ import org.apache.log4j.Logger; +import graph.elements.Edge; +import graph.elements.Graph; +import graph.elements.Vertex; +import graph.properties.components.SplitPair; +import graph.trees.DFSTree; + public class SeparationPairSplitting> { /** diff --git a/GraphDrawingTheory/src/graph/properties/splitting/Splitting.java b/GraphDrawingTheory/src/main/java/graph/properties/splitting/Splitting.java similarity index 100% rename from GraphDrawingTheory/src/graph/properties/splitting/Splitting.java rename to GraphDrawingTheory/src/main/java/graph/properties/splitting/Splitting.java diff --git a/GraphDrawingTheory/src/graph/properties/splitting/Triple.java b/GraphDrawingTheory/src/main/java/graph/properties/splitting/Triple.java similarity index 100% rename from GraphDrawingTheory/src/graph/properties/splitting/Triple.java rename to GraphDrawingTheory/src/main/java/graph/properties/splitting/Triple.java diff --git a/GraphDrawingTheory/src/graph/symmetry/CyclicPermutation.java b/GraphDrawingTheory/src/main/java/graph/symmetry/CyclicPermutation.java similarity index 100% rename from GraphDrawingTheory/src/graph/symmetry/CyclicPermutation.java rename to GraphDrawingTheory/src/main/java/graph/symmetry/CyclicPermutation.java index 4b519d3..4329468 100644 --- a/GraphDrawingTheory/src/graph/symmetry/CyclicPermutation.java +++ b/GraphDrawingTheory/src/main/java/graph/symmetry/CyclicPermutation.java @@ -1,10 +1,10 @@ package graph.symmetry; -import graph.elements.Vertex; - import java.util.ArrayList; import java.util.List; +import graph.elements.Vertex; + public class CyclicPermutation { diff --git a/GraphDrawingTheory/src/graph/symmetry/DeFrayseeixHeuristic.java b/GraphDrawingTheory/src/main/java/graph/symmetry/DeFrayseeixHeuristic.java similarity index 99% rename from GraphDrawingTheory/src/graph/symmetry/DeFrayseeixHeuristic.java rename to GraphDrawingTheory/src/main/java/graph/symmetry/DeFrayseeixHeuristic.java index df292b9..2e9ecfe 100644 --- a/GraphDrawingTheory/src/graph/symmetry/DeFrayseeixHeuristic.java +++ b/GraphDrawingTheory/src/main/java/graph/symmetry/DeFrayseeixHeuristic.java @@ -1,13 +1,5 @@ package graph.symmetry; -import graph.elements.Edge; -import graph.elements.Graph; -import graph.elements.Vertex; -import graph.math.CzekanovskiDiceDistance; -import graph.math.GramSchmidt; -import graph.math.MatrixUtil; -import graph.util.Pair; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -15,6 +7,13 @@ import Jama.EigenvalueDecomposition; import Jama.Matrix; +import graph.elements.Edge; +import graph.elements.Graph; +import graph.elements.Vertex; +import graph.math.CzekanovskiDiceDistance; +import graph.math.GramSchmidt; +import graph.math.MatrixUtil; +import graph.util.Pair; public class DeFrayseeixHeuristic> { diff --git a/GraphDrawingTheory/src/graph/symmetry/Permutation.java b/GraphDrawingTheory/src/main/java/graph/symmetry/Permutation.java similarity index 100% rename from GraphDrawingTheory/src/graph/symmetry/Permutation.java rename to GraphDrawingTheory/src/main/java/graph/symmetry/Permutation.java diff --git a/GraphDrawingTheory/src/graph/symmetry/PermutationAnalyzator.java b/GraphDrawingTheory/src/main/java/graph/symmetry/PermutationAnalyzator.java similarity index 100% rename from GraphDrawingTheory/src/graph/symmetry/PermutationAnalyzator.java rename to GraphDrawingTheory/src/main/java/graph/symmetry/PermutationAnalyzator.java index d640327..9b8a340 100644 --- a/GraphDrawingTheory/src/graph/symmetry/PermutationAnalyzator.java +++ b/GraphDrawingTheory/src/main/java/graph/symmetry/PermutationAnalyzator.java @@ -1,15 +1,15 @@ package graph.symmetry; -import graph.elements.Edge; -import graph.elements.Graph; -import graph.elements.Vertex; -import graph.symmetry.nauty.McKayGraphLabelingAlgorithm; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import graph.elements.Edge; +import graph.elements.Graph; +import graph.elements.Vertex; +import graph.symmetry.nauty.McKayGraphLabelingAlgorithm; + public class PermutationAnalyzator> { private List permutations; diff --git a/GraphDrawingTheory/src/graph/symmetry/PermutationCycle.java b/GraphDrawingTheory/src/main/java/graph/symmetry/PermutationCycle.java similarity index 100% rename from GraphDrawingTheory/src/graph/symmetry/PermutationCycle.java rename to GraphDrawingTheory/src/main/java/graph/symmetry/PermutationCycle.java index a28a47a..7ca2835 100644 --- a/GraphDrawingTheory/src/graph/symmetry/PermutationCycle.java +++ b/GraphDrawingTheory/src/main/java/graph/symmetry/PermutationCycle.java @@ -1,10 +1,10 @@ package graph.symmetry; -import graph.elements.Vertex; - import java.util.ArrayList; import java.util.List; +import graph.elements.Vertex; + public class PermutationCycle { private List cycle = new ArrayList(); diff --git a/GraphDrawingTheory/src/graph/symmetry/PermutationGroup.java b/GraphDrawingTheory/src/main/java/graph/symmetry/PermutationGroup.java similarity index 100% rename from GraphDrawingTheory/src/graph/symmetry/PermutationGroup.java rename to GraphDrawingTheory/src/main/java/graph/symmetry/PermutationGroup.java diff --git a/GraphDrawingTheory/src/graph/symmetry/nauty/BinaryRepresentation.java b/GraphDrawingTheory/src/main/java/graph/symmetry/nauty/BinaryRepresentation.java similarity index 100% rename from GraphDrawingTheory/src/graph/symmetry/nauty/BinaryRepresentation.java rename to GraphDrawingTheory/src/main/java/graph/symmetry/nauty/BinaryRepresentation.java index fa458c7..ccf034b 100644 --- a/GraphDrawingTheory/src/graph/symmetry/nauty/BinaryRepresentation.java +++ b/GraphDrawingTheory/src/main/java/graph/symmetry/nauty/BinaryRepresentation.java @@ -1,11 +1,11 @@ package graph.symmetry.nauty; +import java.util.List; + import graph.elements.Edge; import graph.elements.Graph; import graph.elements.Vertex; -import java.util.List; - public class BinaryRepresentation> { private Graph graph; diff --git a/GraphDrawingTheory/src/graph/symmetry/nauty/McKayGraphLabelingAlgorithm.java b/GraphDrawingTheory/src/main/java/graph/symmetry/nauty/McKayGraphLabelingAlgorithm.java similarity index 100% rename from GraphDrawingTheory/src/graph/symmetry/nauty/McKayGraphLabelingAlgorithm.java rename to GraphDrawingTheory/src/main/java/graph/symmetry/nauty/McKayGraphLabelingAlgorithm.java index 5a68a02..108b1d5 100644 --- a/GraphDrawingTheory/src/graph/symmetry/nauty/McKayGraphLabelingAlgorithm.java +++ b/GraphDrawingTheory/src/main/java/graph/symmetry/nauty/McKayGraphLabelingAlgorithm.java @@ -1,17 +1,17 @@ package graph.symmetry.nauty; -import graph.elements.Edge; -import graph.elements.Graph; -import graph.elements.Vertex; -import graph.symmetry.Permutation; -import graph.util.Pair; - import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import graph.elements.Edge; +import graph.elements.Graph; +import graph.elements.Vertex; +import graph.symmetry.Permutation; +import graph.util.Pair; + /** * Implementation of McKay's canonical graph labeling algorithm * @author xx diff --git a/GraphDrawingTheory/src/graph/symmetry/nauty/OrderedPartition.java b/GraphDrawingTheory/src/main/java/graph/symmetry/nauty/OrderedPartition.java similarity index 100% rename from GraphDrawingTheory/src/graph/symmetry/nauty/OrderedPartition.java rename to GraphDrawingTheory/src/main/java/graph/symmetry/nauty/OrderedPartition.java index 45614a4..9ab518b 100644 --- a/GraphDrawingTheory/src/graph/symmetry/nauty/OrderedPartition.java +++ b/GraphDrawingTheory/src/main/java/graph/symmetry/nauty/OrderedPartition.java @@ -1,10 +1,10 @@ package graph.symmetry.nauty; -import graph.elements.Vertex; - import java.util.ArrayList; import java.util.List; +import graph.elements.Vertex; + public class OrderedPartition { private List> partition; diff --git a/GraphDrawingTheory/src/graph/symmetry/nauty/SearchTree.java b/GraphDrawingTheory/src/main/java/graph/symmetry/nauty/SearchTree.java similarity index 100% rename from GraphDrawingTheory/src/graph/symmetry/nauty/SearchTree.java rename to GraphDrawingTheory/src/main/java/graph/symmetry/nauty/SearchTree.java index 8f746fc..ba6f004 100644 --- a/GraphDrawingTheory/src/graph/symmetry/nauty/SearchTree.java +++ b/GraphDrawingTheory/src/main/java/graph/symmetry/nauty/SearchTree.java @@ -1,10 +1,10 @@ package graph.symmetry.nauty; -import graph.elements.Vertex; - import java.util.ArrayList; import java.util.List; +import graph.elements.Vertex; + public class SearchTree{ private SearchTreeNode root; diff --git a/GraphDrawingTheory/src/graph/symmetry/nauty/SearchTreeNode.java b/GraphDrawingTheory/src/main/java/graph/symmetry/nauty/SearchTreeNode.java similarity index 100% rename from GraphDrawingTheory/src/graph/symmetry/nauty/SearchTreeNode.java rename to GraphDrawingTheory/src/main/java/graph/symmetry/nauty/SearchTreeNode.java index 613bbaf..d15f1b1 100644 --- a/GraphDrawingTheory/src/graph/symmetry/nauty/SearchTreeNode.java +++ b/GraphDrawingTheory/src/main/java/graph/symmetry/nauty/SearchTreeNode.java @@ -1,10 +1,10 @@ package graph.symmetry.nauty; -import graph.elements.Vertex; - import java.util.ArrayList; import java.util.List; +import graph.elements.Vertex; + public class SearchTreeNode{ private OrderedPartition nodePartition; diff --git a/GraphDrawingTheory/src/graph/traversal/DFSTreeTraversal.java b/GraphDrawingTheory/src/main/java/graph/traversal/DFSTreeTraversal.java similarity index 100% rename from GraphDrawingTheory/src/graph/traversal/DFSTreeTraversal.java rename to GraphDrawingTheory/src/main/java/graph/traversal/DFSTreeTraversal.java diff --git a/GraphDrawingTheory/src/graph/traversal/DijkstraAlgorithm.java b/GraphDrawingTheory/src/main/java/graph/traversal/DijkstraAlgorithm.java similarity index 100% rename from GraphDrawingTheory/src/graph/traversal/DijkstraAlgorithm.java rename to GraphDrawingTheory/src/main/java/graph/traversal/DijkstraAlgorithm.java index ac8465e..7e5a730 100644 --- a/GraphDrawingTheory/src/graph/traversal/DijkstraAlgorithm.java +++ b/GraphDrawingTheory/src/main/java/graph/traversal/DijkstraAlgorithm.java @@ -1,11 +1,5 @@ package graph.traversal; -import graph.elements.Edge; -import graph.elements.EdgeDirection; -import graph.elements.Graph; -import graph.elements.Path; -import graph.elements.Vertex; - import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -14,6 +8,12 @@ import java.util.Map; import java.util.Set; +import graph.elements.Edge; +import graph.elements.EdgeDirection; +import graph.elements.Graph; +import graph.elements.Path; +import graph.elements.Vertex; + /** * Algorithm for finding a path between two graph vertices in a graph diff --git a/GraphDrawingTheory/src/graph/traversal/GraphTraversal.java b/GraphDrawingTheory/src/main/java/graph/traversal/GraphTraversal.java similarity index 100% rename from GraphDrawingTheory/src/graph/traversal/GraphTraversal.java rename to GraphDrawingTheory/src/main/java/graph/traversal/GraphTraversal.java diff --git a/GraphDrawingTheory/src/graph/traversal/TraversalUtil.java b/GraphDrawingTheory/src/main/java/graph/traversal/TraversalUtil.java similarity index 100% rename from GraphDrawingTheory/src/graph/traversal/TraversalUtil.java rename to GraphDrawingTheory/src/main/java/graph/traversal/TraversalUtil.java diff --git a/GraphDrawingTheory/src/graph/tree/bc/BCNodeType.java b/GraphDrawingTheory/src/main/java/graph/tree/bc/BCNodeType.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/bc/BCNodeType.java rename to GraphDrawingTheory/src/main/java/graph/tree/bc/BCNodeType.java diff --git a/GraphDrawingTheory/src/graph/tree/bc/BCTree.java b/GraphDrawingTheory/src/main/java/graph/tree/bc/BCTree.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/bc/BCTree.java rename to GraphDrawingTheory/src/main/java/graph/tree/bc/BCTree.java diff --git a/GraphDrawingTheory/src/graph/tree/bc/BCTreeEdge.java b/GraphDrawingTheory/src/main/java/graph/tree/bc/BCTreeEdge.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/bc/BCTreeEdge.java rename to GraphDrawingTheory/src/main/java/graph/tree/bc/BCTreeEdge.java diff --git a/GraphDrawingTheory/src/graph/tree/bc/BCTreeNode.java b/GraphDrawingTheory/src/main/java/graph/tree/bc/BCTreeNode.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/bc/BCTreeNode.java rename to GraphDrawingTheory/src/main/java/graph/tree/bc/BCTreeNode.java diff --git a/GraphDrawingTheory/src/graph/tree/binary/BinaryTree.java b/GraphDrawingTheory/src/main/java/graph/tree/binary/BinaryTree.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/binary/BinaryTree.java rename to GraphDrawingTheory/src/main/java/graph/tree/binary/BinaryTree.java index a46cdc9..a6cc4a2 100644 --- a/GraphDrawingTheory/src/graph/tree/binary/BinaryTree.java +++ b/GraphDrawingTheory/src/main/java/graph/tree/binary/BinaryTree.java @@ -1,10 +1,5 @@ package graph.tree.binary; -import graph.elements.Edge; -import graph.elements.Graph; -import graph.elements.Vertex; -import graph.exception.CannotBeAppliedException; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -12,6 +7,11 @@ import org.apache.log4j.Logger; +import graph.elements.Edge; +import graph.elements.Graph; +import graph.elements.Vertex; +import graph.exception.CannotBeAppliedException; + /** * A binary tree constructed from a given undirected graph */ diff --git a/GraphDrawingTheory/src/graph/tree/binary/BinaryTreeNode.java b/GraphDrawingTheory/src/main/java/graph/tree/binary/BinaryTreeNode.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/binary/BinaryTreeNode.java rename to GraphDrawingTheory/src/main/java/graph/tree/binary/BinaryTreeNode.java diff --git a/GraphDrawingTheory/src/graph/tree/pq/PQNodeLabel.java b/GraphDrawingTheory/src/main/java/graph/tree/pq/PQNodeLabel.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/pq/PQNodeLabel.java rename to GraphDrawingTheory/src/main/java/graph/tree/pq/PQNodeLabel.java diff --git a/GraphDrawingTheory/src/graph/tree/pq/PQNodeMark.java b/GraphDrawingTheory/src/main/java/graph/tree/pq/PQNodeMark.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/pq/PQNodeMark.java rename to GraphDrawingTheory/src/main/java/graph/tree/pq/PQNodeMark.java diff --git a/GraphDrawingTheory/src/graph/tree/pq/PQNodeOrderValid.java b/GraphDrawingTheory/src/main/java/graph/tree/pq/PQNodeOrderValid.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/pq/PQNodeOrderValid.java rename to GraphDrawingTheory/src/main/java/graph/tree/pq/PQNodeOrderValid.java diff --git a/GraphDrawingTheory/src/graph/tree/pq/PQNodeType.java b/GraphDrawingTheory/src/main/java/graph/tree/pq/PQNodeType.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/pq/PQNodeType.java rename to GraphDrawingTheory/src/main/java/graph/tree/pq/PQNodeType.java diff --git a/GraphDrawingTheory/src/graph/tree/pq/PQTree.java b/GraphDrawingTheory/src/main/java/graph/tree/pq/PQTree.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/pq/PQTree.java rename to GraphDrawingTheory/src/main/java/graph/tree/pq/PQTree.java diff --git a/GraphDrawingTheory/src/graph/tree/pq/PQTreeEdge.java b/GraphDrawingTheory/src/main/java/graph/tree/pq/PQTreeEdge.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/pq/PQTreeEdge.java rename to GraphDrawingTheory/src/main/java/graph/tree/pq/PQTreeEdge.java diff --git a/GraphDrawingTheory/src/graph/tree/pq/PQTreeNode.java b/GraphDrawingTheory/src/main/java/graph/tree/pq/PQTreeNode.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/pq/PQTreeNode.java rename to GraphDrawingTheory/src/main/java/graph/tree/pq/PQTreeNode.java diff --git a/GraphDrawingTheory/src/graph/tree/pq/PQTreeReduction.java b/GraphDrawingTheory/src/main/java/graph/tree/pq/PQTreeReduction.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/pq/PQTreeReduction.java rename to GraphDrawingTheory/src/main/java/graph/tree/pq/PQTreeReduction.java index 65fd0ed..94ece4d 100644 --- a/GraphDrawingTheory/src/graph/tree/pq/PQTreeReduction.java +++ b/GraphDrawingTheory/src/main/java/graph/tree/pq/PQTreeReduction.java @@ -1,8 +1,5 @@ package graph.tree.pq; -import graph.elements.Edge; -import graph.elements.Vertex; - import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -11,6 +8,9 @@ import org.apache.log4j.Logger; +import graph.elements.Edge; +import graph.elements.Vertex; + public class PQTreeReduction> { diff --git a/GraphDrawingTheory/src/graph/tree/spqr/AbstractTree.java b/GraphDrawingTheory/src/main/java/graph/tree/spqr/AbstractTree.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/spqr/AbstractTree.java rename to GraphDrawingTheory/src/main/java/graph/tree/spqr/AbstractTree.java diff --git a/GraphDrawingTheory/src/graph/tree/spqr/NodeType.java b/GraphDrawingTheory/src/main/java/graph/tree/spqr/NodeType.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/spqr/NodeType.java rename to GraphDrawingTheory/src/main/java/graph/tree/spqr/NodeType.java diff --git a/GraphDrawingTheory/src/graph/tree/spqr/ProtoSPQRTree.java b/GraphDrawingTheory/src/main/java/graph/tree/spqr/ProtoSPQRTree.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/spqr/ProtoSPQRTree.java rename to GraphDrawingTheory/src/main/java/graph/tree/spqr/ProtoSPQRTree.java diff --git a/GraphDrawingTheory/src/graph/tree/spqr/SPQRTree.java b/GraphDrawingTheory/src/main/java/graph/tree/spqr/SPQRTree.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/spqr/SPQRTree.java rename to GraphDrawingTheory/src/main/java/graph/tree/spqr/SPQRTree.java diff --git a/GraphDrawingTheory/src/graph/tree/spqr/SPQRTreeNode.java b/GraphDrawingTheory/src/main/java/graph/tree/spqr/SPQRTreeNode.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/spqr/SPQRTreeNode.java rename to GraphDrawingTheory/src/main/java/graph/tree/spqr/SPQRTreeNode.java index aaab61b..4b2f5b7 100644 --- a/GraphDrawingTheory/src/graph/tree/spqr/SPQRTreeNode.java +++ b/GraphDrawingTheory/src/main/java/graph/tree/spqr/SPQRTreeNode.java @@ -1,13 +1,13 @@ package graph.tree.spqr; -import graph.elements.Edge; -import graph.elements.Graph; -import graph.elements.Vertex; - import java.awt.Dimension; import java.util.ArrayList; import java.util.List; +import graph.elements.Edge; +import graph.elements.Graph; +import graph.elements.Vertex; + public class SPQRTreeNode> implements Vertex{ diff --git a/GraphDrawingTheory/src/graph/tree/spqr/Skeleton.java b/GraphDrawingTheory/src/main/java/graph/tree/spqr/Skeleton.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/spqr/Skeleton.java rename to GraphDrawingTheory/src/main/java/graph/tree/spqr/Skeleton.java diff --git a/GraphDrawingTheory/src/graph/tree/spqr/TreeEdgeWithContent.java b/GraphDrawingTheory/src/main/java/graph/tree/spqr/TreeEdgeWithContent.java similarity index 100% rename from GraphDrawingTheory/src/graph/tree/spqr/TreeEdgeWithContent.java rename to GraphDrawingTheory/src/main/java/graph/tree/spqr/TreeEdgeWithContent.java diff --git a/GraphDrawingTheory/src/graph/trees/DFSTree.java b/GraphDrawingTheory/src/main/java/graph/trees/DFSTree.java similarity index 100% rename from GraphDrawingTheory/src/graph/trees/DFSTree.java rename to GraphDrawingTheory/src/main/java/graph/trees/DFSTree.java index 96b4c50..6da7419 100644 --- a/GraphDrawingTheory/src/graph/trees/DFSTree.java +++ b/GraphDrawingTheory/src/main/java/graph/trees/DFSTree.java @@ -1,11 +1,5 @@ package graph.trees; -import graph.elements.Edge; -import graph.elements.EdgeDirection; -import graph.elements.Graph; -import graph.elements.Path; -import graph.elements.Vertex; - import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -14,6 +8,12 @@ import java.util.List; import java.util.Map; +import graph.elements.Edge; +import graph.elements.EdgeDirection; +import graph.elements.Graph; +import graph.elements.Path; +import graph.elements.Vertex; + public class DFSTree> extends Graph{ private V root; diff --git a/GraphDrawingTheory/src/graph/util/Pair.java b/GraphDrawingTheory/src/main/java/graph/util/Pair.java similarity index 100% rename from GraphDrawingTheory/src/graph/util/Pair.java rename to GraphDrawingTheory/src/main/java/graph/util/Pair.java diff --git a/GraphDrawingTheory/src/graph/util/Util.java b/GraphDrawingTheory/src/main/java/graph/util/Util.java similarity index 100% rename from GraphDrawingTheory/src/graph/util/Util.java rename to GraphDrawingTheory/src/main/java/graph/util/Util.java index 3e4fa58..396cf26 100644 --- a/GraphDrawingTheory/src/graph/util/Util.java +++ b/GraphDrawingTheory/src/main/java/graph/util/Util.java @@ -1,13 +1,13 @@ package graph.util; -import graph.elements.Edge; -import graph.elements.Graph; -import graph.elements.Vertex; - import java.util.ArrayList; import java.util.List; import java.util.Random; +import graph.elements.Edge; +import graph.elements.Graph; +import graph.elements.Vertex; + public class Util { @SuppressWarnings("unchecked") diff --git a/GraphDrawingTheory/src/log4j.properties b/GraphDrawingTheory/src/main/resources/log4j.properties similarity index 100% rename from GraphDrawingTheory/src/log4j.properties rename to GraphDrawingTheory/src/main/resources/log4j.properties diff --git a/GraphDrawingTheory/test/graph/test/algorithms/GraphTestCase.java b/GraphDrawingTheory/src/test/java/graph/test/algorithms/GraphTestCase.java similarity index 95% rename from GraphDrawingTheory/test/graph/test/algorithms/GraphTestCase.java rename to GraphDrawingTheory/src/test/java/graph/test/algorithms/GraphTestCase.java index 88b207e..c62ed18 100644 --- a/GraphDrawingTheory/test/graph/test/algorithms/GraphTestCase.java +++ b/GraphDrawingTheory/src/test/java/graph/test/algorithms/GraphTestCase.java @@ -1,11 +1,12 @@ package graph.test.algorithms; +import org.junit.Before; + import graph.elements.Graph; import graph.test.elements.TestEdge; import graph.test.elements.TestVertex; -import junit.framework.TestCase; -public class GraphTestCase extends TestCase{ +public class GraphTestCase{ protected Graph graph; protected TestVertex vert1 = new TestVertex("1"); @@ -36,7 +37,8 @@ public class GraphTestCase extends TestCase{ protected TestEdge edge14 = new TestEdge(vert1, vert11); protected TestEdge edge15 = new TestEdge(vert7, vert3); - @Override + + @Before public void setUp(){ graph = new Graph(false); diff --git a/GraphDrawingTheory/test/graph/test/algorithms/TestDFSTree.java b/GraphDrawingTheory/src/test/java/graph/test/algorithms/TestDFSTree.java similarity index 94% rename from GraphDrawingTheory/test/graph/test/algorithms/TestDFSTree.java rename to GraphDrawingTheory/src/test/java/graph/test/algorithms/TestDFSTree.java index 52f5a0b..8fdfd41 100644 --- a/GraphDrawingTheory/test/graph/test/algorithms/TestDFSTree.java +++ b/GraphDrawingTheory/src/test/java/graph/test/algorithms/TestDFSTree.java @@ -1,16 +1,19 @@ package graph.test.algorithms; +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; + import graph.elements.Graph; import graph.test.elements.TestEdge; import graph.test.elements.TestVertex; import graph.traversal.DFSTreeTraversal; import graph.trees.DFSTree; -import org.junit.Test; - +@Ignore public class TestDFSTree extends GraphTestCase{ - @Test public void test(){ DFSTreeTraversal traversal = new DFSTreeTraversal<>(graph); diff --git a/GraphDrawingTheory/test/graph/test/algorithms/TestDijkstra.java b/GraphDrawingTheory/src/test/java/graph/test/algorithms/TestDijkstra.java similarity index 93% rename from GraphDrawingTheory/test/graph/test/algorithms/TestDijkstra.java rename to GraphDrawingTheory/src/test/java/graph/test/algorithms/TestDijkstra.java index 56073fc..f1e4e7a 100644 --- a/GraphDrawingTheory/test/graph/test/algorithms/TestDijkstra.java +++ b/GraphDrawingTheory/src/test/java/graph/test/algorithms/TestDijkstra.java @@ -1,11 +1,13 @@ package graph.test.algorithms; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + import graph.test.elements.TestEdge; import graph.test.elements.TestVertex; import graph.traversal.DijkstraAlgorithm; -import org.junit.Test; - public class TestDijkstra extends GraphTestCase{ diff --git a/GraphDrawingTheory/test/graph/test/algorithms/TestLRPartitioning.java b/GraphDrawingTheory/src/test/java/graph/test/algorithms/TestLRPartitioning.java similarity index 95% rename from GraphDrawingTheory/test/graph/test/algorithms/TestLRPartitioning.java rename to GraphDrawingTheory/src/test/java/graph/test/algorithms/TestLRPartitioning.java index 7affeaf..94ce77b 100644 --- a/GraphDrawingTheory/test/graph/test/algorithms/TestLRPartitioning.java +++ b/GraphDrawingTheory/src/test/java/graph/test/algorithms/TestLRPartitioning.java @@ -1,16 +1,20 @@ package graph.test.algorithms; +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + import graph.algorithms.lrpartition.LRPartition; import graph.elements.Graph; import graph.test.elements.TestEdge; import graph.test.elements.TestVertex; import graph.traversal.DFSTreeTraversal; import graph.trees.DFSTree; -import junit.framework.TestCase; - -import org.junit.Test; -public class TestLRPartitioning extends TestCase{ +@Ignore +public class TestLRPartitioning { private Graph graph; private TestVertex vert1 = new TestVertex("1"); @@ -41,7 +45,7 @@ public class TestLRPartitioning extends TestCase{ private TestEdge edge14 = new TestEdge(vert1, vert11); private TestEdge edge15 = new TestEdge(vert7, vert3); - @Override + @Before public void setUp(){ graph = new Graph(false); diff --git a/GraphDrawingTheory/test/graph/test/elements/TestEdge.java b/GraphDrawingTheory/src/test/java/graph/test/elements/TestEdge.java similarity index 100% rename from GraphDrawingTheory/test/graph/test/elements/TestEdge.java rename to GraphDrawingTheory/src/test/java/graph/test/elements/TestEdge.java diff --git a/GraphDrawingTheory/test/graph/test/elements/TestVertex.java b/GraphDrawingTheory/src/test/java/graph/test/elements/TestVertex.java similarity index 100% rename from GraphDrawingTheory/test/graph/test/elements/TestVertex.java rename to GraphDrawingTheory/src/test/java/graph/test/elements/TestVertex.java index b1874f9..ac883ee 100644 --- a/GraphDrawingTheory/test/graph/test/elements/TestVertex.java +++ b/GraphDrawingTheory/src/test/java/graph/test/elements/TestVertex.java @@ -1,9 +1,9 @@ package graph.test.elements; -import graph.elements.Vertex; - import java.awt.Dimension; +import graph.elements.Vertex; + public class TestVertex implements Vertex{ @Override diff --git a/GraphDrawingTheory/test/graph/test/graph/properties/TestGraph.java b/GraphDrawingTheory/src/test/java/graph/test/graph/properties/TestGraph.java similarity index 100% rename from GraphDrawingTheory/test/graph/test/graph/properties/TestGraph.java rename to GraphDrawingTheory/src/test/java/graph/test/graph/properties/TestGraph.java index e80bd43..fb3b650 100644 --- a/GraphDrawingTheory/test/graph/test/graph/properties/TestGraph.java +++ b/GraphDrawingTheory/src/test/java/graph/test/graph/properties/TestGraph.java @@ -1,5 +1,7 @@ package graph.test.graph.properties; +import org.junit.Test; + import graph.elements.Graph; import graph.properties.Bipartite; import graph.test.elements.TestEdge; @@ -7,8 +9,6 @@ import graph.traversal.GraphTraversal; import junit.framework.TestCase; -import org.junit.Test; - public class TestGraph extends TestCase{ diff --git a/GraphDrawingTheory/test/graph/test/graph/properties/TestSplitting.java b/GraphDrawingTheory/src/test/java/graph/test/graph/properties/TestSplitting.java similarity index 99% rename from GraphDrawingTheory/test/graph/test/graph/properties/TestSplitting.java rename to GraphDrawingTheory/src/test/java/graph/test/graph/properties/TestSplitting.java index 4658a7a..42fb6f0 100644 --- a/GraphDrawingTheory/test/graph/test/graph/properties/TestSplitting.java +++ b/GraphDrawingTheory/src/test/java/graph/test/graph/properties/TestSplitting.java @@ -1,17 +1,16 @@ package graph.test.graph.properties; +import java.util.List; + +import org.junit.Test; + import graph.elements.Graph; import graph.properties.components.SplitPair; import graph.properties.splitting.Splitting; import graph.test.elements.TestEdge; import graph.test.elements.TestVertex; - -import java.util.List; - import junit.framework.TestCase; -import org.junit.Test; - public class TestSplitting extends TestCase{ TestVertex vert1 = new TestVertex("1"); diff --git a/GraphDrawingTheory/test/graph/test/layout/LayoutsSpeedTest.java b/GraphDrawingTheory/src/test/java/graph/test/layout/LayoutsSpeedTest.java similarity index 96% rename from GraphDrawingTheory/test/graph/test/layout/LayoutsSpeedTest.java rename to GraphDrawingTheory/src/test/java/graph/test/layout/LayoutsSpeedTest.java index 55ee678..9f01a59 100644 --- a/GraphDrawingTheory/test/graph/test/layout/LayoutsSpeedTest.java +++ b/GraphDrawingTheory/src/test/java/graph/test/layout/LayoutsSpeedTest.java @@ -5,18 +5,12 @@ import java.util.List; import java.util.Map; -import org.apache.commons.collections15.map.HashedMap; - import graph.algorithm.AlgorithmExecutor; import graph.algorithm.ExecuteResult; import graph.elements.Graph; -import graph.layout.DefaultGraphLayoutProperties; import graph.layout.GraphLayoutProperties; import graph.layout.LayoutAlgorithms; import graph.layout.Layouter; -import graph.layout.PropertyEnums.CircleProperties; -import graph.layout.PropertyEnums.SymmetricProperties; -import graph.symmetry.Permutation; import graph.test.elements.TestEdge; import graph.test.elements.TestVertex; import graph.traversal.DFSTreeTraversal; diff --git a/GraphDrawingTheory/test/graph/test/operations/TestGraphOperations.java b/GraphDrawingTheory/src/test/java/graph/test/operations/TestGraphOperations.java similarity index 99% rename from GraphDrawingTheory/test/graph/test/operations/TestGraphOperations.java rename to GraphDrawingTheory/src/test/java/graph/test/operations/TestGraphOperations.java index bfe97c3..2560f72 100644 --- a/GraphDrawingTheory/test/graph/test/operations/TestGraphOperations.java +++ b/GraphDrawingTheory/src/test/java/graph/test/operations/TestGraphOperations.java @@ -1,17 +1,16 @@ package graph.test.operations; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + import graph.elements.Graph; import graph.operations.GraphOperations; import graph.test.elements.TestEdge; import graph.test.elements.TestVertex; - -import java.util.ArrayList; -import java.util.List; - import junit.framework.TestCase; -import org.junit.Test; - public class TestGraphOperations extends TestCase{ @Test diff --git a/GraphDrawingTheory/test/graph/test/planarity/BoyerMyrvoldPlanarityTest.java b/GraphDrawingTheory/src/test/java/graph/test/planarity/BoyerMyrvoldPlanarityTest.java similarity index 99% rename from GraphDrawingTheory/test/graph/test/planarity/BoyerMyrvoldPlanarityTest.java rename to GraphDrawingTheory/src/test/java/graph/test/planarity/BoyerMyrvoldPlanarityTest.java index e144f92..29b4fbd 100644 --- a/GraphDrawingTheory/test/graph/test/planarity/BoyerMyrvoldPlanarityTest.java +++ b/GraphDrawingTheory/src/test/java/graph/test/planarity/BoyerMyrvoldPlanarityTest.java @@ -1,13 +1,12 @@ package graph.test.planarity; +import org.junit.Test; + import graph.algorithms.planarity.BoyerMyrvoldPlanarity; import graph.algorithms.planarity.PlanarityTestingAlgorithm; import graph.elements.Graph; import graph.test.elements.TestEdge; import graph.test.elements.TestVertex; - -import org.junit.Test; - import junit.framework.TestCase; public class BoyerMyrvoldPlanarityTest extends TestCase { diff --git a/GraphDrawingTheory/test/graph/test/planarity/TestPlanarity.java b/GraphDrawingTheory/src/test/java/graph/test/planarity/TestPlanarity.java similarity index 100% rename from GraphDrawingTheory/test/graph/test/planarity/TestPlanarity.java rename to GraphDrawingTheory/src/test/java/graph/test/planarity/TestPlanarity.java diff --git a/GraphDrawingTheory/test/graph/test/symmetry/GramSchmidtTest.java b/GraphDrawingTheory/src/test/java/graph/test/symmetry/GramSchmidtTest.java similarity index 99% rename from GraphDrawingTheory/test/graph/test/symmetry/GramSchmidtTest.java rename to GraphDrawingTheory/src/test/java/graph/test/symmetry/GramSchmidtTest.java index 22116c0..83ba3ff 100644 --- a/GraphDrawingTheory/test/graph/test/symmetry/GramSchmidtTest.java +++ b/GraphDrawingTheory/src/test/java/graph/test/symmetry/GramSchmidtTest.java @@ -1,11 +1,10 @@ package graph.test.symmetry; -import graph.math.GramSchmidt; -import junit.framework.TestCase; - import org.junit.Test; import Jama.Matrix; +import graph.math.GramSchmidt; +import junit.framework.TestCase; public class GramSchmidtTest extends TestCase{ diff --git a/GraphDrawingTheory/test/graph/test/tree/TestBCTree.java b/GraphDrawingTheory/src/test/java/graph/test/tree/TestBCTree.java similarity index 100% rename from GraphDrawingTheory/test/graph/test/tree/TestBCTree.java rename to GraphDrawingTheory/src/test/java/graph/test/tree/TestBCTree.java index 81a69f1..9ea0fec 100644 --- a/GraphDrawingTheory/test/graph/test/tree/TestBCTree.java +++ b/GraphDrawingTheory/src/test/java/graph/test/tree/TestBCTree.java @@ -1,13 +1,13 @@ package graph.test.tree; +import org.junit.Test; + import graph.elements.Graph; import graph.test.elements.TestEdge; import graph.test.elements.TestVertex; import graph.tree.bc.BCTree; import junit.framework.TestCase; -import org.junit.Test; - public class TestBCTree extends TestCase { TestVertex vertA = new TestVertex("A"); diff --git a/GraphDrawingTheory/test/graph/test/tree/TestSPQR.java b/GraphDrawingTheory/src/test/java/graph/test/tree/TestSPQR.java similarity index 100% rename from GraphDrawingTheory/test/graph/test/tree/TestSPQR.java rename to GraphDrawingTheory/src/test/java/graph/test/tree/TestSPQR.java index 39dab67..c79a5bd 100644 --- a/GraphDrawingTheory/test/graph/test/tree/TestSPQR.java +++ b/GraphDrawingTheory/src/test/java/graph/test/tree/TestSPQR.java @@ -1,5 +1,7 @@ package graph.test.tree; +import org.junit.Test; + import graph.elements.Graph; import graph.exception.CannotBeAppliedException; import graph.test.elements.TestEdge; @@ -8,8 +10,6 @@ import graph.tree.spqr.SPQRTree; import junit.framework.TestCase; -import org.junit.Test; - public class TestSPQR extends TestCase{ TestVertex vert1 = new TestVertex("1"); diff --git a/GraphDrawingTheory/target/.gitignore b/GraphDrawingTheory/target/.gitignore deleted file mode 100644 index 751bd89..0000000 --- a/GraphDrawingTheory/target/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/test-classes/ diff --git a/GraphEditor/.classpath b/GraphEditor/.classpath deleted file mode 100644 index d89c37c..0000000 --- a/GraphEditor/.classpath +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/GraphEditor/.project b/GraphEditor/.project deleted file mode 100644 index bcc9b9f..0000000 --- a/GraphEditor/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - GraphEditor - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.jdt.core.javanature - - diff --git a/GraphEditor/pom.xml b/GraphEditor/pom.xml index cdae5df..4fa1060 100644 --- a/GraphEditor/pom.xml +++ b/GraphEditor/pom.xml @@ -1,46 +1,46 @@ - - 4.0.0 - GraphEditor - GraphEditor - 0.1.0-SNAPSHOT - - src - - - src - - **/*.java - - - - - - maven-compiler-plugin - 3.1 - - - - - - - - - - log4j - log4j - 1.2.17 - - - com.miglayout - miglayout-swing - 5.0 - - - com.thoughtworks.xstream - xstream - 1.4.8 - - - - + + + GraphDrawing + GraphDrawing + 0.1.0-SNAPSHOT + .. + + + 4.0.0 + GraphEditor + GraphEditor + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + + + + + GraphDrawingTheory + GraphDrawingTheory + ${project.version} + + + log4j + log4j + + + com.miglayout + miglayout-swing + + + com.thoughtworks.xstream + xstream + + \ No newline at end of file diff --git a/GraphEditor/src/gui/actions/main/frame/ExitAction.java b/GraphEditor/src/main/java/gui/actions/main/frame/ExitAction.java similarity index 83% rename from GraphEditor/src/gui/actions/main/frame/ExitAction.java rename to GraphEditor/src/main/java/gui/actions/main/frame/ExitAction.java index b89f269..81d7d8e 100644 --- a/GraphEditor/src/gui/actions/main/frame/ExitAction.java +++ b/GraphEditor/src/main/java/gui/actions/main/frame/ExitAction.java @@ -16,7 +16,7 @@ public class ExitAction extends AbstractAction{ public ExitAction(){ putValue(NAME, "Exit"); putValue(SHORT_DESCRIPTION, "Close application"); - putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/gui/resources/exit.png"))); + putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/icons/exit.png"))); } diff --git a/GraphEditor/src/gui/actions/main/frame/LoadAction.java b/GraphEditor/src/main/java/gui/actions/main/frame/LoadAction.java similarity index 93% rename from GraphEditor/src/gui/actions/main/frame/LoadAction.java rename to GraphEditor/src/main/java/gui/actions/main/frame/LoadAction.java index d7a3322..3e61a86 100644 --- a/GraphEditor/src/gui/actions/main/frame/LoadAction.java +++ b/GraphEditor/src/main/java/gui/actions/main/frame/LoadAction.java @@ -1,9 +1,5 @@ package gui.actions.main.frame; -import gui.main.frame.MainFrame; -import gui.model.GraphModel; -import gui.view.GraphView; - import java.awt.event.ActionEvent; import java.io.File; @@ -15,6 +11,10 @@ import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.xml.StaxDriver; +import gui.main.frame.MainFrame; +import gui.model.GraphModel; +import gui.view.GraphView; + public class LoadAction extends AbstractAction { private static final long serialVersionUID = 1L; @@ -22,7 +22,7 @@ public class LoadAction extends AbstractAction { public LoadAction(){ putValue(NAME, "Load"); - putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/gui/resources/load.png"))); + putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/icons/load.png"))); putValue(SHORT_DESCRIPTION, "Load graph"); xstream = new XStream(new StaxDriver()); } diff --git a/GraphEditor/src/gui/actions/main/frame/NewGraphAction.java b/GraphEditor/src/main/java/gui/actions/main/frame/NewGraphAction.java similarity index 84% rename from GraphEditor/src/gui/actions/main/frame/NewGraphAction.java rename to GraphEditor/src/main/java/gui/actions/main/frame/NewGraphAction.java index c35ae86..e60628e 100644 --- a/GraphEditor/src/gui/actions/main/frame/NewGraphAction.java +++ b/GraphEditor/src/main/java/gui/actions/main/frame/NewGraphAction.java @@ -1,12 +1,12 @@ package gui.actions.main.frame; -import gui.main.frame.MainFrame; - import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.ImageIcon; +import gui.main.frame.MainFrame; + public class NewGraphAction extends AbstractAction { private static final long serialVersionUID = 1L; @@ -14,7 +14,7 @@ public class NewGraphAction extends AbstractAction { public NewGraphAction(){ putValue(NAME, "New"); putValue(SHORT_DESCRIPTION, "Create new graph"); - putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/gui/resources/new.png"))); + putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/icons/new.png"))); } @Override diff --git a/GraphEditor/src/gui/actions/main/frame/SaveAction.java b/GraphEditor/src/main/java/gui/actions/main/frame/SaveAction.java similarity index 95% rename from GraphEditor/src/gui/actions/main/frame/SaveAction.java rename to GraphEditor/src/main/java/gui/actions/main/frame/SaveAction.java index b5b8648..2c031a3 100644 --- a/GraphEditor/src/gui/actions/main/frame/SaveAction.java +++ b/GraphEditor/src/main/java/gui/actions/main/frame/SaveAction.java @@ -1,8 +1,5 @@ package gui.actions.main.frame; -import gui.main.frame.MainFrame; -import gui.model.GraphModel; - import java.awt.event.ActionEvent; import java.io.File; import java.io.FileOutputStream; @@ -15,6 +12,9 @@ import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.xml.StaxDriver; +import gui.main.frame.MainFrame; +import gui.model.GraphModel; + public class SaveAction extends AbstractAction { private static final long serialVersionUID = 1L; @@ -22,7 +22,7 @@ public class SaveAction extends AbstractAction { public SaveAction(){ putValue(NAME, "Save"); - putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/gui/resources/save.png"))); + putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/icons/save.png"))); putValue(SHORT_DESCRIPTION, "Save graph"); xstream = new XStream(new StaxDriver()); } diff --git a/GraphEditor/src/gui/actions/palette/AddVertexAction.java b/GraphEditor/src/main/java/gui/actions/palette/AddVertexAction.java similarity index 100% rename from GraphEditor/src/gui/actions/palette/AddVertexAction.java rename to GraphEditor/src/main/java/gui/actions/palette/AddVertexAction.java index 3d81d72..89d96b9 100644 --- a/GraphEditor/src/gui/actions/palette/AddVertexAction.java +++ b/GraphEditor/src/main/java/gui/actions/palette/AddVertexAction.java @@ -1,12 +1,12 @@ package gui.actions.palette; -import gui.main.frame.ElementsEnum; -import gui.main.frame.MainFrame; - import java.awt.event.ActionEvent; import javax.swing.AbstractAction; +import gui.main.frame.ElementsEnum; +import gui.main.frame.MainFrame; + public class AddVertexAction extends AbstractAction{ /** diff --git a/GraphEditor/src/gui/actions/palette/LayoutAction.java b/GraphEditor/src/main/java/gui/actions/palette/LayoutAction.java similarity index 100% rename from GraphEditor/src/gui/actions/palette/LayoutAction.java rename to GraphEditor/src/main/java/gui/actions/palette/LayoutAction.java index 7291733..461f065 100644 --- a/GraphEditor/src/gui/actions/palette/LayoutAction.java +++ b/GraphEditor/src/main/java/gui/actions/palette/LayoutAction.java @@ -1,10 +1,17 @@ package gui.actions.palette; +import java.awt.event.ActionEvent; +import java.awt.geom.Point2D; +import java.util.List; + +import javax.swing.AbstractAction; +import javax.swing.JOptionPane; + import graph.drawing.Drawing; import graph.elements.Graph; import graph.exception.CannotBeAppliedException; -import graph.layout.LayoutAlgorithms; import graph.layout.GraphLayoutProperties; +import graph.layout.LayoutAlgorithms; import graph.layout.Layouter; import gui.dialogs.LayoutDialog; import gui.main.frame.MainFrame; @@ -12,13 +19,6 @@ import gui.model.GraphVertex; import gui.view.GraphView; -import java.awt.event.ActionEvent; -import java.awt.geom.Point2D; -import java.util.List; - -import javax.swing.AbstractAction; -import javax.swing.JOptionPane; - public class LayoutAction extends AbstractAction{ /** diff --git a/GraphEditor/src/gui/actions/palette/LinkAction.java b/GraphEditor/src/main/java/gui/actions/palette/LinkAction.java similarity index 100% rename from GraphEditor/src/gui/actions/palette/LinkAction.java rename to GraphEditor/src/main/java/gui/actions/palette/LinkAction.java index 36791a1..52b946e 100644 --- a/GraphEditor/src/gui/actions/palette/LinkAction.java +++ b/GraphEditor/src/main/java/gui/actions/palette/LinkAction.java @@ -1,11 +1,11 @@ package gui.actions.palette; -import gui.main.frame.MainFrame; - import java.awt.event.ActionEvent; import javax.swing.AbstractAction; +import gui.main.frame.MainFrame; + public class LinkAction extends AbstractAction{ /** diff --git a/GraphEditor/src/gui/actions/palette/SelectAction.java b/GraphEditor/src/main/java/gui/actions/palette/SelectAction.java similarity index 100% rename from GraphEditor/src/gui/actions/palette/SelectAction.java rename to GraphEditor/src/main/java/gui/actions/palette/SelectAction.java index 57739c0..456cf2f 100644 --- a/GraphEditor/src/gui/actions/palette/SelectAction.java +++ b/GraphEditor/src/main/java/gui/actions/palette/SelectAction.java @@ -1,11 +1,11 @@ package gui.actions.palette; -import gui.main.frame.MainFrame; - import java.awt.event.ActionEvent; import javax.swing.AbstractAction; +import gui.main.frame.MainFrame; + public class SelectAction extends AbstractAction{ /** diff --git a/GraphEditor/src/gui/actions/toolbar/RedoAction.java b/GraphEditor/src/main/java/gui/actions/toolbar/RedoAction.java similarity index 84% rename from GraphEditor/src/gui/actions/toolbar/RedoAction.java rename to GraphEditor/src/main/java/gui/actions/toolbar/RedoAction.java index 384a908..00693e0 100644 --- a/GraphEditor/src/gui/actions/toolbar/RedoAction.java +++ b/GraphEditor/src/main/java/gui/actions/toolbar/RedoAction.java @@ -1,12 +1,12 @@ package gui.actions.toolbar; -import gui.commands.CommandExecutor; - import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.ImageIcon; +import gui.commands.CommandExecutor; + public class RedoAction extends AbstractAction{ /** @@ -15,7 +15,7 @@ public class RedoAction extends AbstractAction{ private static final long serialVersionUID = 1L; public RedoAction() { - putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/gui/resources/redo.png"))); + putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/icons/redo.png"))); putValue(NAME, "Redo"); putValue(SHORT_DESCRIPTION, "Redo previous action"); diff --git a/GraphEditor/src/gui/actions/toolbar/RemoveAction.java b/GraphEditor/src/main/java/gui/actions/toolbar/RemoveAction.java similarity index 91% rename from GraphEditor/src/gui/actions/toolbar/RemoveAction.java rename to GraphEditor/src/main/java/gui/actions/toolbar/RemoveAction.java index 0a2deba..e025832 100644 --- a/GraphEditor/src/gui/actions/toolbar/RemoveAction.java +++ b/GraphEditor/src/main/java/gui/actions/toolbar/RemoveAction.java @@ -1,11 +1,5 @@ package gui.actions.toolbar; -import gui.commands.CommandExecutor; -import gui.commands.RemoveCommand; -import gui.main.frame.MainFrame; -import gui.model.GraphElement; -import gui.view.GraphView; - import java.awt.event.ActionEvent; import java.util.ArrayList; import java.util.List; @@ -13,6 +7,12 @@ import javax.swing.AbstractAction; import javax.swing.ImageIcon; +import gui.commands.CommandExecutor; +import gui.commands.RemoveCommand; +import gui.main.frame.MainFrame; +import gui.model.GraphElement; +import gui.view.GraphView; + public class RemoveAction extends AbstractAction { /** @@ -21,7 +21,7 @@ public class RemoveAction extends AbstractAction { private static final long serialVersionUID = 1L; public RemoveAction(){ - putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/gui/resources/remove.png"))); + putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/icons/remove.png"))); putValue(NAME, "Delete"); putValue(SHORT_DESCRIPTION, "Delete selected elements"); diff --git a/GraphEditor/src/gui/actions/toolbar/UndoAction.java b/GraphEditor/src/main/java/gui/actions/toolbar/UndoAction.java similarity index 84% rename from GraphEditor/src/gui/actions/toolbar/UndoAction.java rename to GraphEditor/src/main/java/gui/actions/toolbar/UndoAction.java index 39af3bf..e522269 100644 --- a/GraphEditor/src/gui/actions/toolbar/UndoAction.java +++ b/GraphEditor/src/main/java/gui/actions/toolbar/UndoAction.java @@ -1,12 +1,12 @@ package gui.actions.toolbar; -import gui.commands.CommandExecutor; - import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.ImageIcon; +import gui.commands.CommandExecutor; + public class UndoAction extends AbstractAction{ /** @@ -15,7 +15,7 @@ public class UndoAction extends AbstractAction{ private static final long serialVersionUID = 1L; public UndoAction(){ - putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/gui/resources/undo.png"))); + putValue(SMALL_ICON, new ImageIcon(getClass().getResource("/icons/undo.png"))); putValue(NAME, "Undo"); putValue(SHORT_DESCRIPTION, "Undo previous action"); diff --git a/GraphEditor/src/gui/app/Applcation.java b/GraphEditor/src/main/java/gui/app/Application.java similarity index 84% rename from GraphEditor/src/gui/app/Applcation.java rename to GraphEditor/src/main/java/gui/app/Application.java index e3e05b3..38d3760 100644 --- a/GraphEditor/src/gui/app/Applcation.java +++ b/GraphEditor/src/main/java/gui/app/Application.java @@ -2,7 +2,7 @@ import gui.main.frame.MainFrame; -public class Applcation { +public class Application { public static void main(String[] args){ MainFrame.getInstance().setVisible(true); diff --git a/GraphEditor/src/gui/command/panel/CommandPanel.java b/GraphEditor/src/main/java/gui/command/panel/CommandPanel.java similarity index 99% rename from GraphEditor/src/gui/command/panel/CommandPanel.java rename to GraphEditor/src/main/java/gui/command/panel/CommandPanel.java index 89c74de..2cfce4e 100644 --- a/GraphEditor/src/gui/command/panel/CommandPanel.java +++ b/GraphEditor/src/main/java/gui/command/panel/CommandPanel.java @@ -1,14 +1,23 @@ package gui.command.panel; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; + import graph.algorithm.AlgorithmExecutor; import graph.algorithm.ExecuteResult; import graph.algorithm.cycles.SimpleCyclesFinder; import graph.algorithm.cycles.SimpleUndirectedCyclesFinder; import graph.algorithms.drawing.ConvexDrawing; import graph.algorithms.drawing.VisibilityRepresentation; -import graph.algorithms.planarity.BoyerMyrvoldPlanarity; import graph.algorithms.planarity.FraysseixMendezPlanarity; -import graph.algorithms.planarity.PQTreePlanarity; import graph.algorithms.planarity.PlanarityTestingAlgorithm; import graph.drawing.Drawing; import graph.elements.Graph; @@ -31,18 +40,6 @@ import gui.view.GraphView; import gui.view.painters.EdgePainter; import gui.view.painters.VertexPainter; - -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; -import javax.swing.JTextField; - import net.miginfocom.swing.MigLayout; public class CommandPanel extends JPanel{ diff --git a/GraphEditor/src/gui/commands/AddElementCommand.java b/GraphEditor/src/main/java/gui/commands/AddElementCommand.java similarity index 100% rename from GraphEditor/src/gui/commands/AddElementCommand.java rename to GraphEditor/src/main/java/gui/commands/AddElementCommand.java diff --git a/GraphEditor/src/gui/commands/Command.java b/GraphEditor/src/main/java/gui/commands/Command.java similarity index 100% rename from GraphEditor/src/gui/commands/Command.java rename to GraphEditor/src/main/java/gui/commands/Command.java diff --git a/GraphEditor/src/gui/commands/CommandExecutor.java b/GraphEditor/src/main/java/gui/commands/CommandExecutor.java similarity index 100% rename from GraphEditor/src/gui/commands/CommandExecutor.java rename to GraphEditor/src/main/java/gui/commands/CommandExecutor.java diff --git a/GraphEditor/src/gui/commands/MoveCommand.java b/GraphEditor/src/main/java/gui/commands/MoveCommand.java similarity index 100% rename from GraphEditor/src/gui/commands/MoveCommand.java rename to GraphEditor/src/main/java/gui/commands/MoveCommand.java index bfe4c8c..c939f04 100644 --- a/GraphEditor/src/gui/commands/MoveCommand.java +++ b/GraphEditor/src/main/java/gui/commands/MoveCommand.java @@ -1,14 +1,14 @@ package gui.commands; +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.List; + import gui.model.GraphEdge; import gui.model.GraphElement; import gui.model.GraphVertex; import gui.view.GraphView; -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.List; - public class MoveCommand extends Command { diff --git a/GraphEditor/src/gui/commands/RemoveCommand.java b/GraphEditor/src/main/java/gui/commands/RemoveCommand.java similarity index 100% rename from GraphEditor/src/gui/commands/RemoveCommand.java rename to GraphEditor/src/main/java/gui/commands/RemoveCommand.java index 26a0045..f535fa4 100644 --- a/GraphEditor/src/gui/commands/RemoveCommand.java +++ b/GraphEditor/src/main/java/gui/commands/RemoveCommand.java @@ -1,5 +1,8 @@ package gui.commands; +import java.util.ArrayList; +import java.util.List; + import gui.model.GraphEdge; import gui.model.GraphElement; import gui.model.GraphModel; @@ -9,9 +12,6 @@ import gui.view.painters.IElementPainter; import gui.view.painters.VertexPainter; -import java.util.ArrayList; -import java.util.List; - public class RemoveCommand extends Command{ diff --git a/GraphEditor/src/gui/components/JDigitsTextField.java b/GraphEditor/src/main/java/gui/components/JDigitsTextField.java similarity index 100% rename from GraphEditor/src/gui/components/JDigitsTextField.java rename to GraphEditor/src/main/java/gui/components/JDigitsTextField.java diff --git a/GraphEditor/src/gui/components/JDoubleTextField.java b/GraphEditor/src/main/java/gui/components/JDoubleTextField.java similarity index 100% rename from GraphEditor/src/gui/components/JDoubleTextField.java rename to GraphEditor/src/main/java/gui/components/JDoubleTextField.java diff --git a/GraphEditor/src/gui/components/NumberFilter.java b/GraphEditor/src/main/java/gui/components/NumberFilter.java similarity index 100% rename from GraphEditor/src/gui/components/NumberFilter.java rename to GraphEditor/src/main/java/gui/components/NumberFilter.java diff --git a/GraphEditor/src/gui/components/TypeComponents.java b/GraphEditor/src/main/java/gui/components/TypeComponents.java similarity index 100% rename from GraphEditor/src/gui/components/TypeComponents.java rename to GraphEditor/src/main/java/gui/components/TypeComponents.java diff --git a/GraphEditor/src/gui/dialogs/LayoutDialog.java b/GraphEditor/src/main/java/gui/dialogs/LayoutDialog.java similarity index 99% rename from GraphEditor/src/gui/dialogs/LayoutDialog.java rename to GraphEditor/src/main/java/gui/dialogs/LayoutDialog.java index 3d606cc..a412065 100644 --- a/GraphEditor/src/gui/dialogs/LayoutDialog.java +++ b/GraphEditor/src/main/java/gui/dialogs/LayoutDialog.java @@ -1,12 +1,5 @@ package gui.dialogs; -import graph.layout.LayoutAlgorithms; -import graph.layout.DefaultGraphLayoutProperties; -import graph.layout.GraphLayoutProperties; -import gui.main.frame.MainFrame; -import gui.panels.layout.LayoutPanelFactory; -import gui.panels.layout.LayoutPropertyPanel; - import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; @@ -18,6 +11,12 @@ import javax.swing.JLabel; import javax.swing.JPanel; +import graph.layout.DefaultGraphLayoutProperties; +import graph.layout.GraphLayoutProperties; +import graph.layout.LayoutAlgorithms; +import gui.main.frame.MainFrame; +import gui.panels.layout.LayoutPanelFactory; +import gui.panels.layout.LayoutPropertyPanel; import net.miginfocom.swing.MigLayout; public class LayoutDialog extends JDialog{ diff --git a/GraphEditor/src/gui/main/frame/ElementsEnum.java b/GraphEditor/src/main/java/gui/main/frame/ElementsEnum.java similarity index 100% rename from GraphEditor/src/gui/main/frame/ElementsEnum.java rename to GraphEditor/src/main/java/gui/main/frame/ElementsEnum.java diff --git a/GraphEditor/src/gui/main/frame/MainFrame.java b/GraphEditor/src/main/java/gui/main/frame/MainFrame.java similarity index 84% rename from GraphEditor/src/gui/main/frame/MainFrame.java rename to GraphEditor/src/main/java/gui/main/frame/MainFrame.java index 4ace46e..d23db28 100644 --- a/GraphEditor/src/gui/main/frame/MainFrame.java +++ b/GraphEditor/src/main/java/gui/main/frame/MainFrame.java @@ -1,5 +1,23 @@ package gui.main.frame; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.geom.Point2D; + +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.JToggleButton; +import javax.swing.JToolBar; + import graph.elements.Graph; import gui.actions.main.frame.ExitAction; import gui.actions.main.frame.LoadAction; @@ -24,29 +42,11 @@ import gui.util.GuiUtil; import gui.util.StatusBar; import gui.view.GraphView; - -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.geom.Point2D; - -import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; -import javax.swing.JToggleButton; -import javax.swing.JToolBar; - import net.miginfocom.swing.MigLayout; -public class MainFrame extends JFrame{ +public class MainFrame extends JFrame { + private static final String MESSAGE_GRAPH_NOT_FOUND = "Graph not found, select the option create a new Graph!"; /** * */ @@ -68,7 +68,7 @@ public class MainFrame extends JFrame{ private RedoAction redoAction = new RedoAction(); private UndoAction undoAction = new UndoAction(); - public MainFrame(){ + public MainFrame() { setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); setSize(800, 600); @@ -93,15 +93,15 @@ public void windowClosing(WindowEvent e) { } - private void initGui(){ - + private void initGui() { + JPanel centralPanel = new JPanel(new MigLayout("fill")); add(centralPanel, "grow"); - + JPanel leftPanel = new JPanel(new MigLayout("fill")); pane = new JTabbedPane(); leftPanel.add(pane, "grow"); - + JSplitPane rightSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); JPanel palettePanel = new JPanel(new MigLayout()); ButtonGroup group = new ButtonGroup(); @@ -113,34 +113,34 @@ private void initGui(){ btnEdge = new JToggleButton(new LinkAction()); palettePanel.add(btnEdge, "wrap"); group.add(btnEdge); - + btnSelect = new JToggleButton(new SelectAction()); palettePanel.add(btnSelect, "wrap"); group.add(btnSelect); - + palettePanel.add(new JButton(new LayoutAction())); - + propertiesPanel = new JPanel(new MigLayout("fill")); propertiesPanel.add(new JLabel("Properties"), "dock north"); - + rightSplitPane.setLeftComponent(palettePanel); rightSplitPane.setRightComponent(propertiesPanel); - + commandPanel = new CommandPanel(); leftPanel.add(commandPanel, "dock south"); - + JSplitPane centralSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); centralSplitPane.setRightComponent(rightSplitPane); centralSplitPane.setResizeWeight(0.9); centralSplitPane.setLeftComponent(leftPanel); centralPanel.add(centralSplitPane, "grow"); - + statusBar = new StatusBar(); add(statusBar, "height 20:20:20, dock south"); } - - private void initMenu(){ + + private void initMenu() { menuBar = new JMenuBar(); @@ -154,7 +154,7 @@ private void initMenu(){ JMenuItem undoMi = new JMenuItem(undoAction); JMenuItem redoMi = new JMenuItem(redoAction); JMenuItem removeMi = new JMenuItem(removeAction); - + editMenu.add(newMi); editMenu.addSeparator(); editMenu.add(undoMi); @@ -166,13 +166,13 @@ private void initMenu(){ fileMenu.add(loadMi); fileMenu.addSeparator(); fileMenu.add(exitMi); - + menuBar.add(fileMenu); menuBar.add(editMenu); setJMenuBar(menuBar); } - private void initToolBar(){ + private void initToolBar() { toolBar = new JToolBar(); add(toolBar, "dock north"); toolBar.add(newGraphAction); @@ -185,29 +185,30 @@ private void initToolBar(){ toolBar.add(redoAction); } - public static MainFrame getInstance(){ + public static MainFrame getInstance() { if (instance == null) instance = new MainFrame(); return instance; } - - public GraphView getCurrentView(){ + public GraphView getCurrentView() { if (pane.getComponentCount() > 0) return (GraphView) pane.getSelectedComponent(); return null; } - public void addNewDiagram(){ + + public void addNewDiagram() { Graph graph = new Graph(); GraphView view = new GraphView(graph); pane.add(view); } - public void addDiagram(GraphView view){ + + public void addDiagram(GraphView view) { pane.add(view); } - - public void setPropertiesPanel(PropertiesPanel panel){ + + public void setPropertiesPanel(PropertiesPanel panel) { if (propertiesPanel.getComponentCount() > 1) propertiesPanel.remove(1); if (panel != null) @@ -215,45 +216,49 @@ public void setPropertiesPanel(PropertiesPanel panel){ propertiesPanel.revalidate(); propertiesPanel.repaint(); } - - public void updateStatusBarPosition(Point2D position){ - statusBar.setPositionText((int)position.getX() + ", " + (int)position.getY()); + + public void updateStatusBarPosition(Point2D position) { + statusBar.setPositionText((int) position.getX() + ", " + (int) position.getY()); } - public void changeToAdd(ElementsEnum elementType){ + public void changeToAdd(ElementsEnum elementType) { btnVertex.setSelected(true); GraphView currentView = getCurrentView(); - currentView.setCurrentState(new AddState(currentView, ElementsEnum.VERTEX)); - statusBar.setLabelText("Add"); + if (currentView == null) { + JOptionPane.showMessageDialog(this, MESSAGE_GRAPH_NOT_FOUND); + } else { + currentView.setCurrentState(new AddState(currentView, ElementsEnum.VERTEX)); + statusBar.setLabelText("Add"); + } } - public void changeToLink(){ + public void changeToLink() { btnEdge.setSelected(true); GraphView currentView = getCurrentView(); currentView.setCurrentState(new LinkState(currentView)); statusBar.setLabelText("Link"); - } - public void changeToSelect(){ + public void changeToSelect() { btnSelect.setSelected(true); GraphView currentView = getCurrentView(); currentView.setCurrentState(new SelectState(currentView)); statusBar.setLabelText("Select"); } - - public void changeToLassoSelect(){ + + public void changeToLassoSelect() { GraphView currentView = getCurrentView(); currentView.setCurrentState(new LassoSelectState(currentView)); statusBar.setLabelText("Lasso selection"); - + } - public void changeToMoveState(Point2D mousePosition){ + public void changeToMoveState(Point2D mousePosition) { GraphView currentView = getCurrentView(); - currentView.setCurrentState(new MoveState(currentView.getSelectionModel().getSelectedVertices(), currentView, mousePosition)); + currentView.setCurrentState( + new MoveState(currentView.getSelectionModel().getSelectedVertices(), currentView, mousePosition)); statusBar.setLabelText("Move state"); } } diff --git a/GraphEditor/src/gui/model/GraphEdge.java b/GraphEditor/src/main/java/gui/model/GraphEdge.java similarity index 100% rename from GraphEditor/src/gui/model/GraphEdge.java rename to GraphEditor/src/main/java/gui/model/GraphEdge.java index ab9fefc..7871c0d 100644 --- a/GraphEditor/src/gui/model/GraphEdge.java +++ b/GraphEditor/src/main/java/gui/model/GraphEdge.java @@ -1,12 +1,12 @@ package gui.model; -import graph.elements.Edge; - import java.awt.Color; import java.awt.geom.Point2D; import java.util.ArrayList; import java.util.List; +import graph.elements.Edge; + public class GraphEdge extends GraphElement implements Edge{ private GraphVertex origin, destination; diff --git a/GraphEditor/src/gui/model/GraphElement.java b/GraphEditor/src/main/java/gui/model/GraphElement.java similarity index 100% rename from GraphEditor/src/gui/model/GraphElement.java rename to GraphEditor/src/main/java/gui/model/GraphElement.java diff --git a/GraphEditor/src/gui/model/GraphModel.java b/GraphEditor/src/main/java/gui/model/GraphModel.java similarity index 100% rename from GraphEditor/src/gui/model/GraphModel.java rename to GraphEditor/src/main/java/gui/model/GraphModel.java index 4fa2d2a..1e43cd6 100644 --- a/GraphEditor/src/gui/model/GraphModel.java +++ b/GraphEditor/src/main/java/gui/model/GraphModel.java @@ -1,11 +1,11 @@ package gui.model; -import graph.elements.Graph; -import gui.view.GraphView; - import java.awt.Color; import java.util.Observable; +import graph.elements.Graph; +import gui.view.GraphView; + public class GraphModel extends Observable implements IGraphElement{ private Graph graph; diff --git a/GraphEditor/src/gui/model/GraphVertex.java b/GraphEditor/src/main/java/gui/model/GraphVertex.java similarity index 100% rename from GraphEditor/src/gui/model/GraphVertex.java rename to GraphEditor/src/main/java/gui/model/GraphVertex.java index 88f77bf..521145e 100644 --- a/GraphEditor/src/gui/model/GraphVertex.java +++ b/GraphEditor/src/main/java/gui/model/GraphVertex.java @@ -1,11 +1,11 @@ package gui.model; -import graph.elements.Vertex; - import java.awt.Color; import java.awt.Dimension; import java.awt.geom.Point2D; +import graph.elements.Vertex; + public class GraphVertex extends GraphElement implements Vertex{ private Dimension size; diff --git a/GraphEditor/src/gui/model/IGraphElement.java b/GraphEditor/src/main/java/gui/model/IGraphElement.java similarity index 100% rename from GraphEditor/src/gui/model/IGraphElement.java rename to GraphEditor/src/main/java/gui/model/IGraphElement.java diff --git a/GraphEditor/src/gui/model/SelectionModel.java b/GraphEditor/src/main/java/gui/model/SelectionModel.java similarity index 100% rename from GraphEditor/src/gui/model/SelectionModel.java rename to GraphEditor/src/main/java/gui/model/SelectionModel.java index 03964e6..8956ee6 100644 --- a/GraphEditor/src/gui/model/SelectionModel.java +++ b/GraphEditor/src/main/java/gui/model/SelectionModel.java @@ -1,11 +1,11 @@ package gui.model; -import gui.view.GraphView; - import java.util.ArrayList; import java.util.List; import java.util.Observable; +import gui.view.GraphView; + public class SelectionModel extends Observable{ private List selectedVertices = new ArrayList(); diff --git a/GraphEditor/src/gui/panels/layout/HierarchicalLayoutPanel.java b/GraphEditor/src/main/java/gui/panels/layout/HierarchicalLayoutPanel.java similarity index 100% rename from GraphEditor/src/gui/panels/layout/HierarchicalLayoutPanel.java rename to GraphEditor/src/main/java/gui/panels/layout/HierarchicalLayoutPanel.java index ec891a1..b7f1cd3 100644 --- a/GraphEditor/src/gui/panels/layout/HierarchicalLayoutPanel.java +++ b/GraphEditor/src/main/java/gui/panels/layout/HierarchicalLayoutPanel.java @@ -1,12 +1,12 @@ package gui.panels.layout; -import graph.layout.GraphLayoutProperties; -import graph.layout.PropertyEnums.HierarchicalProperties; - import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.SwingConstants; +import graph.layout.GraphLayoutProperties; +import graph.layout.PropertyEnums.HierarchicalProperties; + public class HierarchicalLayoutPanel extends LayoutPropertyPanel{ private static final long serialVersionUID = 1L; diff --git a/GraphEditor/src/gui/panels/layout/LayoutPanelFactory.java b/GraphEditor/src/main/java/gui/panels/layout/LayoutPanelFactory.java similarity index 100% rename from GraphEditor/src/gui/panels/layout/LayoutPanelFactory.java rename to GraphEditor/src/main/java/gui/panels/layout/LayoutPanelFactory.java index 79efd45..b981f35 100644 --- a/GraphEditor/src/gui/panels/layout/LayoutPanelFactory.java +++ b/GraphEditor/src/main/java/gui/panels/layout/LayoutPanelFactory.java @@ -1,5 +1,8 @@ package gui.panels.layout; +import java.util.HashMap; +import java.util.Map; + import graph.layout.LayoutAlgorithms; import graph.layout.PropertyEnums.BalloonProperties; import graph.layout.PropertyEnums.BoxProperties; @@ -19,9 +22,6 @@ import graph.layout.PropertyEnums.TreeProperties; import graph.layout.PropertyEnums.TutteProperties; -import java.util.HashMap; -import java.util.Map; - public class LayoutPanelFactory { private static Map panelsMap= new HashMap(); diff --git a/GraphEditor/src/gui/panels/layout/LayoutPropertyPanel.java b/GraphEditor/src/main/java/gui/panels/layout/LayoutPropertyPanel.java similarity index 99% rename from GraphEditor/src/gui/panels/layout/LayoutPropertyPanel.java rename to GraphEditor/src/main/java/gui/panels/layout/LayoutPropertyPanel.java index c8c7fe1..81ea28f 100644 --- a/GraphEditor/src/gui/panels/layout/LayoutPropertyPanel.java +++ b/GraphEditor/src/main/java/gui/panels/layout/LayoutPropertyPanel.java @@ -1,11 +1,5 @@ package gui.panels.layout; -import graph.layout.GraphLayoutProperties; -import graph.layout.PropertyEnums; -import gui.components.JDigitsTextField; -import gui.components.JDoubleTextField; -import gui.components.TypeComponents; - import java.awt.Component; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -19,6 +13,11 @@ import javax.swing.JPanel; import javax.swing.JTextField; +import graph.layout.GraphLayoutProperties; +import graph.layout.PropertyEnums; +import gui.components.JDigitsTextField; +import gui.components.JDoubleTextField; +import gui.components.TypeComponents; import net.miginfocom.swing.MigLayout; public class LayoutPropertyPanel extends JPanel { diff --git a/GraphEditor/src/gui/panels/layout/NodeLinkTreeLayoutPanel.java b/GraphEditor/src/main/java/gui/panels/layout/NodeLinkTreeLayoutPanel.java similarity index 100% rename from GraphEditor/src/gui/panels/layout/NodeLinkTreeLayoutPanel.java rename to GraphEditor/src/main/java/gui/panels/layout/NodeLinkTreeLayoutPanel.java index 60351b3..fa0ac83 100644 --- a/GraphEditor/src/gui/panels/layout/NodeLinkTreeLayoutPanel.java +++ b/GraphEditor/src/main/java/gui/panels/layout/NodeLinkTreeLayoutPanel.java @@ -1,11 +1,11 @@ package gui.panels.layout; -import graph.layout.GraphLayoutProperties; -import graph.layout.PropertyEnums.NodeLinkTreeProperties; - import javax.swing.JComboBox; import javax.swing.JLabel; +import graph.layout.GraphLayoutProperties; +import graph.layout.PropertyEnums.NodeLinkTreeProperties; + public class NodeLinkTreeLayoutPanel extends LayoutPropertyPanel{ private static final long serialVersionUID = 1L; diff --git a/GraphEditor/src/gui/panels/layout/SymmetricLayoutPanel.java b/GraphEditor/src/main/java/gui/panels/layout/SymmetricLayoutPanel.java similarity index 100% rename from GraphEditor/src/gui/panels/layout/SymmetricLayoutPanel.java rename to GraphEditor/src/main/java/gui/panels/layout/SymmetricLayoutPanel.java index 3a83dd4..d462599 100644 --- a/GraphEditor/src/gui/panels/layout/SymmetricLayoutPanel.java +++ b/GraphEditor/src/main/java/gui/panels/layout/SymmetricLayoutPanel.java @@ -1,5 +1,10 @@ package gui.panels.layout; +import java.awt.Component; +import java.util.List; + +import javax.swing.JComboBox; + import graph.elements.Graph; import graph.layout.PropertyEnums.SymmetricProperties; import graph.symmetry.Permutation; @@ -8,11 +13,6 @@ import gui.model.GraphEdge; import gui.model.GraphVertex; -import java.awt.Component; -import java.util.List; - -import javax.swing.JComboBox; - public class SymmetricLayoutPanel extends LayoutPropertyPanel{ /** diff --git a/GraphEditor/src/gui/properties/EdgePropertiesPanel.java b/GraphEditor/src/main/java/gui/properties/EdgePropertiesPanel.java similarity index 99% rename from GraphEditor/src/gui/properties/EdgePropertiesPanel.java rename to GraphEditor/src/main/java/gui/properties/EdgePropertiesPanel.java index 72822eb..5af4d7e 100644 --- a/GraphEditor/src/gui/properties/EdgePropertiesPanel.java +++ b/GraphEditor/src/main/java/gui/properties/EdgePropertiesPanel.java @@ -1,9 +1,5 @@ package gui.properties; -import gui.main.frame.MainFrame; -import gui.model.GraphEdge; -import gui.model.IGraphElement; - import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -13,6 +9,9 @@ import javax.swing.JLabel; import javax.swing.JTextField; +import gui.main.frame.MainFrame; +import gui.model.GraphEdge; +import gui.model.IGraphElement; import net.miginfocom.swing.MigLayout; public class EdgePropertiesPanel extends PropertiesPanel { diff --git a/GraphEditor/src/gui/properties/GraphModelPropertiesPanel.java b/GraphEditor/src/main/java/gui/properties/GraphModelPropertiesPanel.java similarity index 99% rename from GraphEditor/src/gui/properties/GraphModelPropertiesPanel.java rename to GraphEditor/src/main/java/gui/properties/GraphModelPropertiesPanel.java index f01a02a..0fc94a4 100644 --- a/GraphEditor/src/gui/properties/GraphModelPropertiesPanel.java +++ b/GraphEditor/src/main/java/gui/properties/GraphModelPropertiesPanel.java @@ -1,9 +1,5 @@ package gui.properties; -import gui.main.frame.MainFrame; -import gui.model.GraphModel; -import gui.model.IGraphElement; - import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -18,6 +14,9 @@ import javax.swing.JLabel; import javax.swing.JTextField; +import gui.main.frame.MainFrame; +import gui.model.GraphModel; +import gui.model.IGraphElement; import net.miginfocom.swing.MigLayout; public class GraphModelPropertiesPanel extends PropertiesPanel{ diff --git a/GraphEditor/src/gui/properties/PropertiesFactory.java b/GraphEditor/src/main/java/gui/properties/PropertiesFactory.java similarity index 100% rename from GraphEditor/src/gui/properties/PropertiesFactory.java rename to GraphEditor/src/main/java/gui/properties/PropertiesFactory.java index 567711e..af2b022 100644 --- a/GraphEditor/src/gui/properties/PropertiesFactory.java +++ b/GraphEditor/src/main/java/gui/properties/PropertiesFactory.java @@ -1,12 +1,12 @@ package gui.properties; +import java.util.HashMap; +import java.util.Map; + import gui.model.GraphEdge; import gui.model.GraphModel; -import gui.model.IGraphElement; import gui.model.GraphVertex; - -import java.util.HashMap; -import java.util.Map; +import gui.model.IGraphElement; public class PropertiesFactory { diff --git a/GraphEditor/src/gui/properties/PropertiesPanel.java b/GraphEditor/src/main/java/gui/properties/PropertiesPanel.java similarity index 100% rename from GraphEditor/src/gui/properties/PropertiesPanel.java rename to GraphEditor/src/main/java/gui/properties/PropertiesPanel.java index 835ca18..9170eea 100644 --- a/GraphEditor/src/gui/properties/PropertiesPanel.java +++ b/GraphEditor/src/main/java/gui/properties/PropertiesPanel.java @@ -1,9 +1,9 @@ package gui.properties; -import gui.model.IGraphElement; - import javax.swing.JPanel; +import gui.model.IGraphElement; + public abstract class PropertiesPanel extends JPanel{ private static final long serialVersionUID = 1L; diff --git a/GraphEditor/src/gui/properties/VertexPropertiesPanel.java b/GraphEditor/src/main/java/gui/properties/VertexPropertiesPanel.java similarity index 99% rename from GraphEditor/src/gui/properties/VertexPropertiesPanel.java rename to GraphEditor/src/main/java/gui/properties/VertexPropertiesPanel.java index a3574bd..347783d 100644 --- a/GraphEditor/src/gui/properties/VertexPropertiesPanel.java +++ b/GraphEditor/src/main/java/gui/properties/VertexPropertiesPanel.java @@ -1,9 +1,5 @@ package gui.properties; -import gui.main.frame.MainFrame; -import gui.model.IGraphElement; -import gui.model.GraphVertex; - import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -15,6 +11,9 @@ import javax.swing.JLabel; import javax.swing.JTextField; +import gui.main.frame.MainFrame; +import gui.model.GraphVertex; +import gui.model.IGraphElement; import net.miginfocom.swing.MigLayout; public class VertexPropertiesPanel extends PropertiesPanel{ diff --git a/GraphEditor/src/gui/state/AddState.java b/GraphEditor/src/main/java/gui/state/AddState.java similarity index 100% rename from GraphEditor/src/gui/state/AddState.java rename to GraphEditor/src/main/java/gui/state/AddState.java index 59abd39..ada18c9 100644 --- a/GraphEditor/src/gui/state/AddState.java +++ b/GraphEditor/src/main/java/gui/state/AddState.java @@ -1,5 +1,9 @@ package gui.state; +import java.awt.event.MouseEvent; + +import javax.swing.SwingUtilities; + import gui.commands.AddElementCommand; import gui.commands.Command; import gui.commands.CommandExecutor; @@ -8,10 +12,6 @@ import gui.model.GraphVertex; import gui.view.GraphView; -import java.awt.event.MouseEvent; - -import javax.swing.SwingUtilities; - public class AddState extends State{ private ElementsEnum currentElementType; diff --git a/GraphEditor/src/gui/state/LassoSelectState.java b/GraphEditor/src/main/java/gui/state/LassoSelectState.java similarity index 100% rename from GraphEditor/src/gui/state/LassoSelectState.java rename to GraphEditor/src/main/java/gui/state/LassoSelectState.java index ead23d4..6756ce8 100644 --- a/GraphEditor/src/gui/state/LassoSelectState.java +++ b/GraphEditor/src/main/java/gui/state/LassoSelectState.java @@ -1,11 +1,11 @@ package gui.state; +import java.awt.event.MouseEvent; + import gui.main.frame.MainFrame; import gui.properties.PropertiesFactory; import gui.view.GraphView; -import java.awt.event.MouseEvent; - public class LassoSelectState extends State{ diff --git a/GraphEditor/src/gui/state/LinkState.java b/GraphEditor/src/main/java/gui/state/LinkState.java similarity index 100% rename from GraphEditor/src/gui/state/LinkState.java rename to GraphEditor/src/main/java/gui/state/LinkState.java index 9a66127..78013fa 100644 --- a/GraphEditor/src/gui/state/LinkState.java +++ b/GraphEditor/src/main/java/gui/state/LinkState.java @@ -1,5 +1,12 @@ package gui.state; +import java.awt.event.MouseEvent; +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.SwingUtilities; + import gui.commands.AddElementCommand; import gui.commands.Command; import gui.commands.CommandExecutor; @@ -8,13 +15,6 @@ import gui.model.GraphVertex; import gui.view.GraphView; -import java.awt.event.MouseEvent; -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.SwingUtilities; - public class LinkState extends State{ diff --git a/GraphEditor/src/gui/state/MoveState.java b/GraphEditor/src/main/java/gui/state/MoveState.java similarity index 100% rename from GraphEditor/src/gui/state/MoveState.java rename to GraphEditor/src/main/java/gui/state/MoveState.java index fa634f1..def3191 100644 --- a/GraphEditor/src/gui/state/MoveState.java +++ b/GraphEditor/src/main/java/gui/state/MoveState.java @@ -1,5 +1,12 @@ package gui.state; +import java.awt.event.MouseEvent; +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.SwingUtilities; + import gui.commands.Command; import gui.commands.CommandExecutor; import gui.commands.MoveCommand; @@ -9,13 +16,6 @@ import gui.model.GraphVertex; import gui.view.GraphView; -import java.awt.event.MouseEvent; -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.SwingUtilities; - public class MoveState extends State{ private List vertices; diff --git a/GraphEditor/src/gui/state/SelectState.java b/GraphEditor/src/main/java/gui/state/SelectState.java similarity index 100% rename from GraphEditor/src/gui/state/SelectState.java rename to GraphEditor/src/main/java/gui/state/SelectState.java index 47240eb..6f9ca0f 100644 --- a/GraphEditor/src/gui/state/SelectState.java +++ b/GraphEditor/src/main/java/gui/state/SelectState.java @@ -1,14 +1,14 @@ package gui.state; +import java.awt.event.MouseEvent; + import gui.main.frame.MainFrame; import gui.model.GraphEdge; -import gui.model.IGraphElement; import gui.model.GraphVertex; +import gui.model.IGraphElement; import gui.properties.PropertiesFactory; import gui.view.GraphView; -import java.awt.event.MouseEvent; - public class SelectState extends State{ diff --git a/GraphEditor/src/gui/state/State.java b/GraphEditor/src/main/java/gui/state/State.java similarity index 100% rename from GraphEditor/src/gui/state/State.java rename to GraphEditor/src/main/java/gui/state/State.java index 48adfd9..cd061f7 100644 --- a/GraphEditor/src/gui/state/State.java +++ b/GraphEditor/src/main/java/gui/state/State.java @@ -1,14 +1,14 @@ package gui.state; -import gui.main.frame.MainFrame; -import gui.view.GraphView; - import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; +import gui.main.frame.MainFrame; +import gui.view.GraphView; + public abstract class State implements MouseListener, MouseMotionListener, KeyListener { diff --git a/GraphEditor/src/gui/util/GuiUtil.java b/GraphEditor/src/main/java/gui/util/GuiUtil.java similarity index 100% rename from GraphEditor/src/gui/util/GuiUtil.java rename to GraphEditor/src/main/java/gui/util/GuiUtil.java index a93c644..fd1eb9d 100644 --- a/GraphEditor/src/gui/util/GuiUtil.java +++ b/GraphEditor/src/main/java/gui/util/GuiUtil.java @@ -1,9 +1,9 @@ package gui.util; -import gui.main.frame.MainFrame; - import javax.swing.JOptionPane; +import gui.main.frame.MainFrame; + public class GuiUtil { public static int showConfirmDialogCancel(String message){ diff --git a/GraphEditor/src/gui/util/StatusBar.java b/GraphEditor/src/main/java/gui/util/StatusBar.java similarity index 100% rename from GraphEditor/src/gui/util/StatusBar.java rename to GraphEditor/src/main/java/gui/util/StatusBar.java diff --git a/GraphEditor/src/gui/view/GraphView.java b/GraphEditor/src/main/java/gui/view/GraphView.java similarity index 100% rename from GraphEditor/src/gui/view/GraphView.java rename to GraphEditor/src/main/java/gui/view/GraphView.java index 5316543..382aebb 100644 --- a/GraphEditor/src/gui/view/GraphView.java +++ b/GraphEditor/src/main/java/gui/view/GraphView.java @@ -1,21 +1,5 @@ package gui.view; -import graph.elements.Graph; -import gui.actions.toolbar.RemoveAction; -import gui.main.frame.MainFrame; -import gui.model.GraphEdge; -import gui.model.GraphElement; -import gui.model.GraphModel; -import gui.model.GraphVertex; -import gui.model.IGraphElement; -import gui.model.SelectionModel; -import gui.state.SelectState; -import gui.state.State; -import gui.view.GraphView.GraphController.CancelAction; -import gui.view.painters.EdgePainter; -import gui.view.painters.IElementPainter; -import gui.view.painters.VertexPainter; - import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics; @@ -40,6 +24,22 @@ import javax.swing.AbstractAction; import javax.swing.JPanel; +import graph.elements.Graph; +import gui.actions.toolbar.RemoveAction; +import gui.main.frame.MainFrame; +import gui.model.GraphEdge; +import gui.model.GraphElement; +import gui.model.GraphModel; +import gui.model.GraphVertex; +import gui.model.IGraphElement; +import gui.model.SelectionModel; +import gui.state.SelectState; +import gui.state.State; +import gui.view.GraphView.GraphController.CancelAction; +import gui.view.painters.EdgePainter; +import gui.view.painters.IElementPainter; +import gui.view.painters.VertexPainter; + public class GraphView extends JPanel implements Observer{ private static final long serialVersionUID = 1L; diff --git a/GraphEditor/src/gui/view/painters/EdgePainter.java b/GraphEditor/src/main/java/gui/view/painters/EdgePainter.java similarity index 100% rename from GraphEditor/src/gui/view/painters/EdgePainter.java rename to GraphEditor/src/main/java/gui/view/painters/EdgePainter.java index ecbf90a..5edbdc9 100644 --- a/GraphEditor/src/gui/view/painters/EdgePainter.java +++ b/GraphEditor/src/main/java/gui/view/painters/EdgePainter.java @@ -1,9 +1,5 @@ package gui.view.painters; -import graph.elements.Graph; -import gui.model.GraphEdge; -import gui.model.GraphVertex; - import java.awt.BasicStroke; import java.awt.Graphics2D; import java.awt.Rectangle; @@ -11,6 +7,10 @@ import java.awt.geom.Line2D; import java.awt.geom.Point2D; +import graph.elements.Graph; +import gui.model.GraphEdge; +import gui.model.GraphVertex; + public class EdgePainter implements IElementPainter{ private GraphEdge edge; diff --git a/GraphEditor/src/gui/view/painters/IElementPainter.java b/GraphEditor/src/main/java/gui/view/painters/IElementPainter.java similarity index 100% rename from GraphEditor/src/gui/view/painters/IElementPainter.java rename to GraphEditor/src/main/java/gui/view/painters/IElementPainter.java diff --git a/GraphEditor/src/gui/view/painters/PaintingUtil.java b/GraphEditor/src/main/java/gui/view/painters/PaintingUtil.java similarity index 100% rename from GraphEditor/src/gui/view/painters/PaintingUtil.java rename to GraphEditor/src/main/java/gui/view/painters/PaintingUtil.java diff --git a/GraphEditor/src/gui/view/painters/VertexPainter.java b/GraphEditor/src/main/java/gui/view/painters/VertexPainter.java similarity index 100% rename from GraphEditor/src/gui/view/painters/VertexPainter.java rename to GraphEditor/src/main/java/gui/view/painters/VertexPainter.java index 2b9d897..97e360d 100644 --- a/GraphEditor/src/gui/view/painters/VertexPainter.java +++ b/GraphEditor/src/main/java/gui/view/painters/VertexPainter.java @@ -1,7 +1,5 @@ package gui.view.painters; -import gui.model.GraphVertex; - import java.awt.BasicStroke; import java.awt.Color; import java.awt.Dimension; @@ -12,6 +10,8 @@ import java.awt.geom.Ellipse2D; import java.awt.geom.Point2D; +import gui.model.GraphVertex; + public class VertexPainter implements IElementPainter { private GraphVertex vertex; diff --git a/GraphEditor/src/gui/resources/edit-icon-png-16x16-540.png b/GraphEditor/src/main/resources/icons/edit-icon-png-16x16-540.png similarity index 100% rename from GraphEditor/src/gui/resources/edit-icon-png-16x16-540.png rename to GraphEditor/src/main/resources/icons/edit-icon-png-16x16-540.png diff --git a/GraphEditor/src/gui/resources/exit.png b/GraphEditor/src/main/resources/icons/exit.png similarity index 100% rename from GraphEditor/src/gui/resources/exit.png rename to GraphEditor/src/main/resources/icons/exit.png diff --git a/GraphEditor/src/gui/resources/load.png b/GraphEditor/src/main/resources/icons/load.png similarity index 100% rename from GraphEditor/src/gui/resources/load.png rename to GraphEditor/src/main/resources/icons/load.png diff --git a/GraphEditor/src/gui/resources/new.png b/GraphEditor/src/main/resources/icons/new.png similarity index 100% rename from GraphEditor/src/gui/resources/new.png rename to GraphEditor/src/main/resources/icons/new.png diff --git a/GraphEditor/src/gui/resources/newundo_largeimage_1.png b/GraphEditor/src/main/resources/icons/newundo_largeimage_1.png similarity index 100% rename from GraphEditor/src/gui/resources/newundo_largeimage_1.png rename to GraphEditor/src/main/resources/icons/newundo_largeimage_1.png diff --git a/GraphEditor/src/gui/resources/redo.png b/GraphEditor/src/main/resources/icons/redo.png similarity index 100% rename from GraphEditor/src/gui/resources/redo.png rename to GraphEditor/src/main/resources/icons/redo.png diff --git a/GraphEditor/src/gui/resources/remove.png b/GraphEditor/src/main/resources/icons/remove.png similarity index 100% rename from GraphEditor/src/gui/resources/remove.png rename to GraphEditor/src/main/resources/icons/remove.png diff --git a/GraphEditor/src/gui/resources/save.png b/GraphEditor/src/main/resources/icons/save.png similarity index 100% rename from GraphEditor/src/gui/resources/save.png rename to GraphEditor/src/main/resources/icons/save.png diff --git a/GraphEditor/src/gui/resources/undo.png b/GraphEditor/src/main/resources/icons/undo.png similarity index 100% rename from GraphEditor/src/gui/resources/undo.png rename to GraphEditor/src/main/resources/icons/undo.png diff --git a/GraphEditor/test_graphs/23queenstourgraph.graph b/GraphEditor/src/test/resources/test_graphs/23queenstourgraph.graph similarity index 100% rename from GraphEditor/test_graphs/23queenstourgraph.graph rename to GraphEditor/src/test/resources/test_graphs/23queenstourgraph.graph diff --git a/GraphEditor/test_graphs/33fangraph.graph b/GraphEditor/src/test/resources/test_graphs/33fangraph.graph similarity index 100% rename from GraphEditor/test_graphs/33fangraph.graph rename to GraphEditor/src/test/resources/test_graphs/33fangraph.graph diff --git a/GraphEditor/test_graphs/6graph114.graph b/GraphEditor/src/test/resources/test_graphs/6graph114.graph similarity index 100% rename from GraphEditor/test_graphs/6graph114.graph rename to GraphEditor/src/test/resources/test_graphs/6graph114.graph diff --git a/GraphEditor/test_graphs/convex1.graph b/GraphEditor/src/test/resources/test_graphs/convex1.graph similarity index 100% rename from GraphEditor/test_graphs/convex1.graph rename to GraphEditor/src/test/resources/test_graphs/convex1.graph diff --git a/GraphEditor/test_graphs/convex2.graph b/GraphEditor/src/test/resources/test_graphs/convex2.graph similarity index 100% rename from GraphEditor/test_graphs/convex2.graph rename to GraphEditor/src/test/resources/test_graphs/convex2.graph diff --git a/GraphEditor/test_graphs/convex3.graph b/GraphEditor/src/test/resources/test_graphs/convex3.graph similarity index 100% rename from GraphEditor/test_graphs/convex3.graph rename to GraphEditor/src/test/resources/test_graphs/convex3.graph diff --git a/GraphEditor/test_graphs/convex3_1.graph b/GraphEditor/src/test/resources/test_graphs/convex3_1.graph similarity index 100% rename from GraphEditor/test_graphs/convex3_1.graph rename to GraphEditor/src/test/resources/test_graphs/convex3_1.graph diff --git a/GraphEditor/test_graphs/convex3_2.graph b/GraphEditor/src/test/resources/test_graphs/convex3_2.graph similarity index 100% rename from GraphEditor/test_graphs/convex3_2.graph rename to GraphEditor/src/test/resources/test_graphs/convex3_2.graph diff --git a/GraphEditor/test_graphs/convex4.graph b/GraphEditor/src/test/resources/test_graphs/convex4.graph similarity index 100% rename from GraphEditor/test_graphs/convex4.graph rename to GraphEditor/src/test/resources/test_graphs/convex4.graph diff --git a/GraphEditor/test_graphs/convex5.graph b/GraphEditor/src/test/resources/test_graphs/convex5.graph similarity index 100% rename from GraphEditor/test_graphs/convex5.graph rename to GraphEditor/src/test/resources/test_graphs/convex5.graph diff --git a/GraphEditor/test_graphs/convex6.graph b/GraphEditor/src/test/resources/test_graphs/convex6.graph similarity index 100% rename from GraphEditor/test_graphs/convex6.graph rename to GraphEditor/src/test/resources/test_graphs/convex6.graph diff --git a/GraphEditor/test_graphs/convex7.graph b/GraphEditor/src/test/resources/test_graphs/convex7.graph similarity index 100% rename from GraphEditor/test_graphs/convex7.graph rename to GraphEditor/src/test/resources/test_graphs/convex7.graph diff --git a/GraphEditor/test_graphs/pentatope.graph b/GraphEditor/src/test/resources/test_graphs/pentatope.graph similarity index 100% rename from GraphEditor/test_graphs/pentatope.graph rename to GraphEditor/src/test/resources/test_graphs/pentatope.graph diff --git a/GraphEditor/test_graphs/planarfacestest1.graph b/GraphEditor/src/test/resources/test_graphs/planarfacestest1.graph similarity index 100% rename from GraphEditor/test_graphs/planarfacestest1.graph rename to GraphEditor/src/test/resources/test_graphs/planarfacestest1.graph diff --git a/GraphEditor/test_graphs/pqembedding.graph b/GraphEditor/src/test/resources/test_graphs/pqembedding.graph similarity index 100% rename from GraphEditor/test_graphs/pqembedding.graph rename to GraphEditor/src/test/resources/test_graphs/pqembedding.graph diff --git a/GraphEditor/test_graphs/pqtreeplanar.graph b/GraphEditor/src/test/resources/test_graphs/pqtreeplanar.graph similarity index 100% rename from GraphEditor/test_graphs/pqtreeplanar.graph rename to GraphEditor/src/test/resources/test_graphs/pqtreeplanar.graph diff --git a/GraphEditor/test_graphs/separations pair paper graph.graph b/GraphEditor/src/test/resources/test_graphs/separations pair paper graph.graph similarity index 100% rename from GraphEditor/test_graphs/separations pair paper graph.graph rename to GraphEditor/src/test/resources/test_graphs/separations pair paper graph.graph diff --git a/GraphEditor/test_graphs/triconnectivity test.graph b/GraphEditor/src/test/resources/test_graphs/triconnectivity test.graph similarity index 100% rename from GraphEditor/test_graphs/triconnectivity test.graph rename to GraphEditor/src/test/resources/test_graphs/triconnectivity test.graph diff --git a/GraphEditor/test_graphs/utility graph.graph b/GraphEditor/src/test/resources/test_graphs/utility graph.graph similarity index 100% rename from GraphEditor/test_graphs/utility graph.graph rename to GraphEditor/src/test/resources/test_graphs/utility graph.graph diff --git a/GraphEditor/test_graphs/visibility.graph b/GraphEditor/src/test/resources/test_graphs/visibility.graph similarity index 100% rename from GraphEditor/test_graphs/visibility.graph rename to GraphEditor/src/test/resources/test_graphs/visibility.graph diff --git a/GraphEditor/target/classes/gui/resources/edit-icon-png-16x16-540.png b/GraphEditor/target/classes/gui/resources/edit-icon-png-16x16-540.png deleted file mode 100644 index 1e60329..0000000 Binary files a/GraphEditor/target/classes/gui/resources/edit-icon-png-16x16-540.png and /dev/null differ diff --git a/GraphEditor/target/classes/gui/resources/exit.png b/GraphEditor/target/classes/gui/resources/exit.png deleted file mode 100644 index b68f53d..0000000 Binary files a/GraphEditor/target/classes/gui/resources/exit.png and /dev/null differ diff --git a/GraphEditor/target/classes/gui/resources/load.png b/GraphEditor/target/classes/gui/resources/load.png deleted file mode 100644 index f47d630..0000000 Binary files a/GraphEditor/target/classes/gui/resources/load.png and /dev/null differ diff --git a/GraphEditor/target/classes/gui/resources/new.png b/GraphEditor/target/classes/gui/resources/new.png deleted file mode 100644 index d459c5b..0000000 Binary files a/GraphEditor/target/classes/gui/resources/new.png and /dev/null differ diff --git a/GraphEditor/target/classes/gui/resources/newundo_largeimage_1.png b/GraphEditor/target/classes/gui/resources/newundo_largeimage_1.png deleted file mode 100644 index 5ebee3e..0000000 Binary files a/GraphEditor/target/classes/gui/resources/newundo_largeimage_1.png and /dev/null differ diff --git a/GraphEditor/target/classes/gui/resources/redo.png b/GraphEditor/target/classes/gui/resources/redo.png deleted file mode 100644 index fad330a..0000000 Binary files a/GraphEditor/target/classes/gui/resources/redo.png and /dev/null differ diff --git a/GraphEditor/target/classes/gui/resources/remove.png b/GraphEditor/target/classes/gui/resources/remove.png deleted file mode 100644 index 5276f00..0000000 Binary files a/GraphEditor/target/classes/gui/resources/remove.png and /dev/null differ diff --git a/GraphEditor/target/classes/gui/resources/save.png b/GraphEditor/target/classes/gui/resources/save.png deleted file mode 100644 index ad61e67..0000000 Binary files a/GraphEditor/target/classes/gui/resources/save.png and /dev/null differ diff --git a/GraphEditor/target/classes/gui/resources/undo.png b/GraphEditor/target/classes/gui/resources/undo.png deleted file mode 100644 index 4c79cca..0000000 Binary files a/GraphEditor/target/classes/gui/resources/undo.png and /dev/null differ diff --git a/GraphLayoutDSL/.classpath b/GraphLayoutDSL/.classpath deleted file mode 100644 index 03abcad..0000000 --- a/GraphLayoutDSL/.classpath +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/GraphLayoutDSL/.gitignore b/GraphLayoutDSL/.gitignore deleted file mode 100644 index 751c70c..0000000 --- a/GraphLayoutDSL/.gitignore +++ /dev/null @@ -1,45 +0,0 @@ -*.class - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.ear - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - -*.pydevproject -.metadata -.gradle -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.settings/ -.loadpath - -*/target/* - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - -# sbteclipse plugin -.target - -# TeXlipse plugin -.texlipse diff --git a/GraphLayoutDSL/.project b/GraphLayoutDSL/.project deleted file mode 100644 index fa376d8..0000000 --- a/GraphLayoutDSL/.project +++ /dev/null @@ -1,29 +0,0 @@ - - - GraphLayoutDSL - - - - - - org.python.pydev.PyDevBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.jdt.core.javanature - org.python.pydev.pythonNature - - diff --git a/GraphLayoutDSL/pom.xml b/GraphLayoutDSL/pom.xml index 01c09ae..176f557 100644 --- a/GraphLayoutDSL/pom.xml +++ b/GraphLayoutDSL/pom.xml @@ -1,31 +1,44 @@ - - 4.0.0 - GraphLayoutDSL - GraphLayoutDSL - 0.0.1-SNAPSHOT - - src - - - maven-compiler-plugin - 3.1 - - - - - - - - - - org.python - jython-standalone - 2.7.1b2 - - - commons-io - commons-io - 2.5 - - + + 4.0.0 + + + GraphDrawing + GraphDrawing + 0.1.0-SNAPSHOT + .. + + + GraphLayoutDSL + GraphLayoutDSL + jar + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + + + + + org.python + jython-standalone + + + commons-io + commons-io + + + junit + junit + test + + \ No newline at end of file diff --git a/GraphLayoutDSL/src/app/App.java b/GraphLayoutDSL/src/main/java/app/App.java similarity index 100% rename from GraphLayoutDSL/src/app/App.java rename to GraphLayoutDSL/src/main/java/app/App.java diff --git a/GraphLayoutDSL/src/interfaces/ILayout.java b/GraphLayoutDSL/src/main/java/interfaces/ILayout.java similarity index 100% rename from GraphLayoutDSL/src/interfaces/ILayout.java rename to GraphLayoutDSL/src/main/java/interfaces/ILayout.java diff --git a/GraphLayoutDSL/src/interfaces/ILayoutGraph.java b/GraphLayoutDSL/src/main/java/interfaces/ILayoutGraph.java similarity index 100% rename from GraphLayoutDSL/src/interfaces/ILayoutGraph.java rename to GraphLayoutDSL/src/main/java/interfaces/ILayoutGraph.java diff --git a/GraphLayoutDSL/src/interfaces/ILayoutSubgraphs.java b/GraphLayoutDSL/src/main/java/interfaces/ILayoutSubgraphs.java similarity index 100% rename from GraphLayoutDSL/src/interfaces/ILayoutSubgraphs.java rename to GraphLayoutDSL/src/main/java/interfaces/ILayoutSubgraphs.java diff --git a/GraphLayoutDSL/src/interpreter/Interpreter.py b/GraphLayoutDSL/src/main/java/interpreter/Interpreter.py similarity index 100% rename from GraphLayoutDSL/src/interpreter/Interpreter.py rename to GraphLayoutDSL/src/main/java/interpreter/Interpreter.py diff --git a/GraphLayoutDSL/src/interpreter/__init__.py b/GraphLayoutDSL/src/main/java/interpreter/__init__.py similarity index 100% rename from GraphLayoutDSL/src/interpreter/__init__.py rename to GraphLayoutDSL/src/main/java/interpreter/__init__.py diff --git a/GraphLayoutDSL/src/interpreter/java/Interpreter.java b/GraphLayoutDSL/src/main/java/interpreter/java/Interpreter.java similarity index 96% rename from GraphLayoutDSL/src/interpreter/java/Interpreter.java rename to GraphLayoutDSL/src/main/java/interpreter/java/Interpreter.java index b5ba151..2dc2f2f 100644 --- a/GraphLayoutDSL/src/interpreter/java/Interpreter.java +++ b/GraphLayoutDSL/src/main/java/interpreter/java/Interpreter.java @@ -1,23 +1,21 @@ package interpreter.java; -import interfaces.ILayout; -import interfaces.ILayoutGraph; -import interfaces.ILayoutSubgraphs; - import java.io.File; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; -import models.java.LayoutGraph; -import models.java.LayoutSubgraphs; - import org.python.core.PyInstance; import org.python.core.PyObjectDerived; import org.python.core.PyString; import org.python.util.PythonInterpreter; +import interfaces.ILayout; +import interfaces.ILayoutGraph; +import interfaces.ILayoutSubgraphs; +import models.java.LayoutGraph; +import models.java.LayoutSubgraphs; import util.Factory; /** @@ -54,8 +52,8 @@ public Interpreter() { interpreter.exec("import sys; sys.path.insert(0, '" + languageDir + "')"); - // interpreter.exec("import sys; sys.path.insert(0, '" + modulesDir + "')"); - // interpreter.exec("import sys; sys.path.insert(0, '" + modelsDir + "')"); +// interpreter.exec("import sys; sys.path.insert(0, '" + modulesDir + "')"); +// interpreter.exec("import sys; sys.path.insert(0, '" + modelsDir + "')"); interpreter.exec("import sys; print sys.path"); interpreter.exec("from interpreter.Interpreter import Interpreter"); grammarInterpreter = (PyInstance) interpreter.eval("Interpreter()"); diff --git a/GraphLayoutDSL/src/language/layout.dot b/GraphLayoutDSL/src/main/java/language/layout.dot similarity index 100% rename from GraphLayoutDSL/src/language/layout.dot rename to GraphLayoutDSL/src/main/java/language/layout.dot diff --git a/GraphLayoutDSL/src/language/layout.png b/GraphLayoutDSL/src/main/java/language/layout.png similarity index 100% rename from GraphLayoutDSL/src/language/layout.png rename to GraphLayoutDSL/src/main/java/language/layout.png diff --git a/GraphLayoutDSL/src/language/layout.tx b/GraphLayoutDSL/src/main/java/language/layout.tx similarity index 100% rename from GraphLayoutDSL/src/language/layout.tx rename to GraphLayoutDSL/src/main/java/language/layout.tx diff --git a/GraphLayoutDSL/src/models/java/LayoutGraph.java b/GraphLayoutDSL/src/main/java/models/java/LayoutGraph.java similarity index 100% rename from GraphLayoutDSL/src/models/java/LayoutGraph.java rename to GraphLayoutDSL/src/main/java/models/java/LayoutGraph.java index 2c3cfd0..3b139f1 100644 --- a/GraphLayoutDSL/src/models/java/LayoutGraph.java +++ b/GraphLayoutDSL/src/main/java/models/java/LayoutGraph.java @@ -1,10 +1,10 @@ package models.java; -import interfaces.ILayoutGraph; - import java.util.List; import java.util.Map; +import interfaces.ILayoutGraph; + public class LayoutGraph implements ILayoutGraph{ diff --git a/GraphLayoutDSL/src/models/java/LayoutSubgraphs.java b/GraphLayoutDSL/src/main/java/models/java/LayoutSubgraphs.java similarity index 100% rename from GraphLayoutDSL/src/models/java/LayoutSubgraphs.java rename to GraphLayoutDSL/src/main/java/models/java/LayoutSubgraphs.java index 9c01cab..f096f5d 100644 --- a/GraphLayoutDSL/src/models/java/LayoutSubgraphs.java +++ b/GraphLayoutDSL/src/main/java/models/java/LayoutSubgraphs.java @@ -1,10 +1,10 @@ package models.java; +import java.util.List; + import interfaces.ILayoutGraph; import interfaces.ILayoutSubgraphs; -import java.util.List; - public class LayoutSubgraphs implements ILayoutSubgraphs{ private List subgraphs; diff --git a/GraphLayoutDSL/src/models/pythonmodels.py b/GraphLayoutDSL/src/main/java/models/pythonmodels.py similarity index 100% rename from GraphLayoutDSL/src/models/pythonmodels.py rename to GraphLayoutDSL/src/main/java/models/pythonmodels.py diff --git a/GraphLayoutDSL/src/modules/arpeggio/__init__.py b/GraphLayoutDSL/src/main/java/modules/arpeggio/__init__.py similarity index 100% rename from GraphLayoutDSL/src/modules/arpeggio/__init__.py rename to GraphLayoutDSL/src/main/java/modules/arpeggio/__init__.py diff --git a/GraphLayoutDSL/src/modules/arpeggio/cleanpeg.py b/GraphLayoutDSL/src/main/java/modules/arpeggio/cleanpeg.py similarity index 100% rename from GraphLayoutDSL/src/modules/arpeggio/cleanpeg.py rename to GraphLayoutDSL/src/main/java/modules/arpeggio/cleanpeg.py diff --git a/GraphLayoutDSL/src/modules/arpeggio/export.py b/GraphLayoutDSL/src/main/java/modules/arpeggio/export.py similarity index 100% rename from GraphLayoutDSL/src/modules/arpeggio/export.py rename to GraphLayoutDSL/src/main/java/modules/arpeggio/export.py diff --git a/GraphLayoutDSL/src/modules/arpeggio/peg.py b/GraphLayoutDSL/src/main/java/modules/arpeggio/peg.py similarity index 100% rename from GraphLayoutDSL/src/modules/arpeggio/peg.py rename to GraphLayoutDSL/src/main/java/modules/arpeggio/peg.py diff --git a/GraphLayoutDSL/src/modules/arpeggio/utils.py b/GraphLayoutDSL/src/main/java/modules/arpeggio/utils.py similarity index 100% rename from GraphLayoutDSL/src/modules/arpeggio/utils.py rename to GraphLayoutDSL/src/main/java/modules/arpeggio/utils.py diff --git a/GraphLayoutDSL/src/modules/textx/__init__.py b/GraphLayoutDSL/src/main/java/modules/textx/__init__.py similarity index 100% rename from GraphLayoutDSL/src/modules/textx/__init__.py rename to GraphLayoutDSL/src/main/java/modules/textx/__init__.py diff --git a/GraphLayoutDSL/src/modules/textx/const.py b/GraphLayoutDSL/src/main/java/modules/textx/const.py similarity index 100% rename from GraphLayoutDSL/src/modules/textx/const.py rename to GraphLayoutDSL/src/main/java/modules/textx/const.py diff --git a/GraphLayoutDSL/src/modules/textx/exceptions.py b/GraphLayoutDSL/src/main/java/modules/textx/exceptions.py similarity index 100% rename from GraphLayoutDSL/src/modules/textx/exceptions.py rename to GraphLayoutDSL/src/main/java/modules/textx/exceptions.py diff --git a/GraphLayoutDSL/src/modules/textx/export.py b/GraphLayoutDSL/src/main/java/modules/textx/export.py similarity index 100% rename from GraphLayoutDSL/src/modules/textx/export.py rename to GraphLayoutDSL/src/main/java/modules/textx/export.py diff --git a/GraphLayoutDSL/src/modules/textx/metamodel.py b/GraphLayoutDSL/src/main/java/modules/textx/metamodel.py similarity index 100% rename from GraphLayoutDSL/src/modules/textx/metamodel.py rename to GraphLayoutDSL/src/main/java/modules/textx/metamodel.py diff --git a/GraphLayoutDSL/src/modules/textx/model.py b/GraphLayoutDSL/src/main/java/modules/textx/model.py similarity index 100% rename from GraphLayoutDSL/src/modules/textx/model.py rename to GraphLayoutDSL/src/main/java/modules/textx/model.py diff --git a/GraphLayoutDSL/src/modules/textx/textx.py b/GraphLayoutDSL/src/main/java/modules/textx/textx.py similarity index 100% rename from GraphLayoutDSL/src/modules/textx/textx.py rename to GraphLayoutDSL/src/main/java/modules/textx/textx.py diff --git a/GraphLayoutDSL/src/util/Factory.java b/GraphLayoutDSL/src/main/java/util/Factory.java similarity index 100% rename from GraphLayoutDSL/src/util/Factory.java rename to GraphLayoutDSL/src/main/java/util/Factory.java diff --git a/GraphLayoutDSL/test/dsl/test/TestLanguageAndInterpreter.java b/GraphLayoutDSL/src/test/java/dsl/test/TestLanguageAndInterpreter.java similarity index 72% rename from GraphLayoutDSL/test/dsl/test/TestLanguageAndInterpreter.java rename to GraphLayoutDSL/src/test/java/dsl/test/TestLanguageAndInterpreter.java index 449c591..034fe65 100644 --- a/GraphLayoutDSL/test/dsl/test/TestLanguageAndInterpreter.java +++ b/GraphLayoutDSL/src/test/java/dsl/test/TestLanguageAndInterpreter.java @@ -1,34 +1,39 @@ package dsl.test; -import interpreter.java.Interpreter; -import models.java.LayoutGraph; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; -import junit.framework.TestCase; +import interpreter.java.Interpreter; +import models.java.LayoutGraph; -public class TestLanguageAndInterpreter extends TestCase{ +@Ignore +public class TestLanguageAndInterpreter { private Interpreter interpreter; - - @Override - public void setUp(){ + + @Before + public void setUp() { interpreter = Interpreter.getInstance(); } - + @Test - public void testAlgorithms(){ + public void testAlgorithms() { LayoutGraph result; - result = (LayoutGraph) interpreter.execute("layout graph algorithm level based tree horizontal = 5, vertical = 10"); + result = (LayoutGraph) interpreter + .execute("layout graph algorithm level based tree horizontal = 5, vertical = 10"); assertEquals("level", result.getAlgorithm().get("name")); assertEquals(5, result.getAlgorithm().get("xDist")); assertEquals(10, result.getAlgorithm().get("yDist")); - + result = (LayoutGraph) interpreter.execute("layout graph algorithm node link tree orientation = left"); assertEquals("node", result.getAlgorithm().get("name")); assertEquals("left", result.getAlgorithm().get("orientation")); - + result = (LayoutGraph) interpreter.execute("layout graph algorithm hierarchical same " + "layer spacing = 10, parent border = 10, move parent, hierarchy spacing = 3, fine tune "); assertEquals("hierarchical", result.getAlgorithm().get("name")); @@ -37,16 +42,18 @@ public void testAlgorithms(){ assertEquals(true, result.getAlgorithm().get("moveParent")); assertEquals(3.0, result.getAlgorithm().get("interHierarchySpacing")); assertEquals(true, result.getAlgorithm().get("fineTune")); - + result = (LayoutGraph) interpreter.execute("layout graph algorithm circular"); assertEquals("circular", result.getAlgorithm().get("name")); - - result = (LayoutGraph) interpreter.execute("layout graph algorithm Kamada Kawai distance multiplier = 23.2, length factor = 4"); + + result = (LayoutGraph) interpreter + .execute("layout graph algorithm Kamada Kawai distance multiplier = 23.2, length factor = 4"); assertEquals("Kamada", result.getAlgorithm().get("name")); assertEquals(23.2, result.getAlgorithm().get("distanceMultiplier")); assertEquals(4.0, result.getAlgorithm().get("lengthFactor")); - - result = (LayoutGraph) interpreter.execute("layout graph algorithm organic fine tune, fine tuning radius = 12.2, optimize edge crossings, edge crossing factor = 12, optimize node distribution, average scale factor = 23, optimize border line, border line factor = 12"); + + result = (LayoutGraph) interpreter.execute( + "layout graph algorithm organic fine tune, fine tuning radius = 12.2, optimize edge crossings, edge crossing factor = 12, optimize node distribution, average scale factor = 23, optimize border line, border line factor = 12"); assertEquals("organic", result.getAlgorithm().get("name")); assertEquals(true, result.getAlgorithm().get("fineTune")); assertEquals(12.2, result.getAlgorithm().get("fineTuningRadius")); @@ -56,13 +63,14 @@ public void testAlgorithms(){ assertEquals(23.0, result.getAlgorithm().get("averageScaleFactor")); assertEquals(true, result.getAlgorithm().get("optimizeBorderLine")); assertEquals(12.0, result.getAlgorithm().get("borderLineFactor")); - + } - + @Test - public void testAestheticCriteria(){ + public void testAestheticCriteria() { LayoutGraph result; - result = (LayoutGraph) interpreter.execute("layout graph criteria maximize minimal angle threshold=5, uniform flow direction = left, distribute nodes evenly "); + result = (LayoutGraph) interpreter.execute( + "layout graph criteria maximize minimal angle threshold=5, uniform flow direction = left, distribute nodes evenly "); assertNotNull(result); assertEquals(3, result.getAestheticCriteria().size()); assertEquals(5, result.getAestheticCriteria().get(0).get("threshold")); @@ -70,7 +78,7 @@ public void testAestheticCriteria(){ assertEquals("flow", result.getAestheticCriteria().get(1).get("criterion")); assertEquals("left", result.getAestheticCriteria().get(1).get("direction")); assertEquals("distribute", result.getAestheticCriteria().get(2).get("criterion")); - + } } diff --git a/GraphLayoutDSL/target/classes/interpreter/Interpreter.py b/GraphLayoutDSL/target/classes/interpreter/Interpreter.py deleted file mode 100644 index 268aaeb..0000000 --- a/GraphLayoutDSL/target/classes/interpreter/Interpreter.py +++ /dev/null @@ -1,102 +0,0 @@ -from textx.metamodel import metamodel_from_file -from textx.export import metamodel_export, model_export -from textx.exceptions import TextXSyntaxError -from pythonmodels import MLayoutGraph, MLayoutSubgraphs -import os -import sys - -class Interpreter(): - - def __init__(self,): - metamodel_dir = sys.path[0] - metamodel_path = os.path.join(metamodel_dir, "layout.tx") - metamodel = metamodel_from_file(metamodel_path) - self.metamodel = metamodel - - def execute(self, model_str): - - try: - model = self.metamodel.model_from_str(model_str) - except TextXSyntaxError as e: - print(e.message) - return MLayoutGraph(exception = e.message) - - - if model.__class__.__name__ == 'LayoutGraph': - layoutGraph = Interpreter.execute_one(model.layoutType, 'graph') - print('graph') - return layoutGraph - else: - print('subgraphs') - subgraphs = [] - for layoutSubgraph in model.layoutSubgraphs: - - subgraph = layoutSubgraph.subgraph - if subgraph == None: - graph = 'others' - else: - vertices = '' - content = True - for i,vertex in enumerate(subgraph.vertices): - if vertex.index: - vertices = vertices + str(vertex.index) - content = False - else: - vertices = vertices + vertex.content - if i < len(subgraph.vertices) - 1: - vertices = vertices + ',' - graph = vertices - - - layoutType = layoutSubgraph.layoutType - layoutOneSubgraph = Interpreter.execute_one(layoutType, graph) - layoutOneSubgraph.attr_graphContent = content - - subgraphs.append(layoutOneSubgraph) - - return MLayoutSubgraphs(subgraphs) - - return 'executed' - - @staticmethod - def execute_one(layout, graph): - - if layout.__class__.__name__ == "LayoutStyle": - layoutType = "style" - elif layout.__class__.__name__ == "LayoutAlgorithm": - layoutType = "algorithm" - else: - layoutType = "criteria" - - if layoutType == 'algorithm': - #a map that will contain all information about the algorithm - algorithmProperties = {} - algorithm = layout.algorithm - #the algorithm could be of numerous classes - for attr, value in algorithm.__dict__.iteritems(): - if not (attr.startswith('_') or attr == 'parent'): - if attr == 'properties': - for property in value: - for propertyAttr, propertyValue in property.__dict__.iteritems(): - if not (propertyAttr.startswith('_') or propertyAttr == 'parent'): - algorithmProperties[propertyAttr] = propertyValue - else: - algorithmProperties[attr] = value - - layoutGraph = MLayoutGraph(graph = graph, type = layoutType, algorithm = algorithmProperties) - return layoutGraph - elif layoutType == 'style': - style = layout.style - layoutGraph = MLayoutGraph(graph = graph, type = layoutType, style = style) - return layoutGraph - elif layoutType == 'criteria': - criteriaList = []; - criteria = layout.aestheticCriteria - for criterion in criteria: - criterionProperties = {} - for attr, value in criterion.__dict__.iteritems(): - if not (attr.startswith('_') or attr == 'parent'): - criterionProperties[attr] = value - criteriaList.append(criterionProperties) - layoutGraph = MLayoutGraph(graph = graph, type = layoutType, aestheticCriteria = criteriaList) - return layoutGraph diff --git a/GraphLayoutDSL/target/classes/interpreter/__init__.py b/GraphLayoutDSL/target/classes/interpreter/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/GraphLayoutDSL/target/classes/language/layout.dot b/GraphLayoutDSL/target/classes/language/layout.dot deleted file mode 100644 index 731649e..0000000 --- a/GraphLayoutDSL/target/classes/language/layout.dot +++ /dev/null @@ -1,177 +0,0 @@ - - digraph xtext { - fontname = "Bitstream Vera Sans" - fontsize = 8 - node[ - shape=record, - style=filled, - fillcolor=aliceblue - ] - edge[dir=black,arrowtail=empty] - - -85336648[ label="{OrthogonalAlgorithm|+name:STRING\lrectangular:BOOL\l}"] - -85340296[ label="{Comment|\/\/.*$}"] - -49028264[ label="{AestheticCriteion|}"] -49028264 -> 49029176 [dir=back] -49028264 -> 49031912 [dir=back] -49028264 -> 85310200 [dir=back] -49028264 -> 85311112 [dir=back] -49028264 -> 85312024 [dir=back] -49028264 -> 85312936 [dir=back] -49028264 -> 85313848 [dir=back] -49028264 -> 85314760 [dir=back] - -85327528[ label="{ForceDirectedAlgorithm|}"] -85327528 -> 85328440 [dir=back] -85327528 -> 85329352 [dir=back] -85327528 -> 85330264 [dir=back] -85327528 -> 85331176 [dir=back] -85327528 -> 85332088 [dir=back] - -85334824[ label="{TutteEmbedding|+name:STRING\l+dist:INT\l}"] - -85317496[ label="{RadialTreeAlgorithm|+name:STRING\l+xDist:INT\l+yDist:INT\l}"] - -85328440[ label="{KamadaKawai|+name:STRING\l+distanceMultiplier:FLOAT\l+lengthFactor:FLOAT\l+maxIterations:INT\l}"] - -49020968 -> 49021880[arrowtail=diamond, dir=both, headlabel="layoutSubgraphs 1..*"] -49020968[ label="{LayoutSubgraphs|}"] - -85325704 -> 85338472[arrowtail=diamond, dir=both, headlabel="automorphism "] -85325704[ label="{ConcentricSymmetricAlgorithm|+name:STRING\l}"] - -85315672[ label="{LayoutAlgorithmEnum|}"] -85315672 -> 85316584 [dir=back] -85315672 -> 85333912 [dir=back] -85315672 -> 85322968 [dir=back] -85315672 -> 85323880 [dir=back] -85315672 -> 85324792 [dir=back] -85315672 -> 85327528 [dir=back] -85315672 -> 85333000 [dir=back] - -49022792 -> 85337560[arrowtail=diamond, dir=both, headlabel="vertices 1..*"] -49022792[ label="{Subgraph|}"] - -85330264[ label="{Spring|+name:STRING\l+stretch:FLOAT\l+resolutionRange:INT\l+forceMultiplier:FLOAT\l}"] - -49023704[ label="{LayoutEnum|}"] -49023704 -> 49024616 [dir=back] -49023704 -> 49026440 [dir=back] -49023704 -> 49027352 [dir=back] - -85312024 -> 85338472[arrowtail=diamond, dir=both, headlabel="automorphism "] -85312024[ label="{Symmetry|+criterion:STRING\l}"] - -85332088[ label="{Organic|+name:STRING\loptimizeEdgeCrossings:BOOL\l+edgeCrossingFactor:FLOAT\loptimizeEdgeDistance:BOOL\l+edgeDistanceFactor:FLOAT\loptimizeBorderLine:BOOL\l+borderLineFactor:FLOAT\loptimizeNodeDistribution:BOOL\l+nodeDistributionFactor:FLOAT\lfineTune:BOOL\l+fineTuningRadius:FLOAT\l+averageNodeArea:FLOAT\l+averageScaleFactor:FLOAT\l+maxIterations:INT\l}"] - -85339384[ label="{Orientation|left\|right\|up\|down}"] - -85333000[ label="{BoxAlgorithm|+name:STRING\l+numOfColumns:INT\l}"] - -85322968[ label="{HierarchicalAlgorithm|+name:STRING\lresizeParent:BOOL\lmoveParent:BOOL\l+parentBorder:INT\l+interCellSpacing:FLOAT\l+interRankSpacing:FLOAT\l+interHierarchySpacing:FLOAT\l+parallelEdgeSpacing:FLOAT\l+orientation:Orientation\lfineTuning:BOOL\l}"] - -85310200[ label="{MinimumBands|+criterion:STRING\l}"] - -85331176[ label="{FastOrganic|+type:STRING\l+name:STRING\l+forceConstant:FLOAT\l+minimalDistanceLimit:FLOAT\l+initialTemperature:FLOAT\l+maxIterations:INT\l}"] - -49025528[ label="{LayoutStyleEnum|automatic\|circular\|tree\|hierarchical\|symmetric\|general}"] - -85333912[ label="{StraightLineAlgorithm|}"] -85333912 -> 85334824 [dir=back] -85333912 -> 85335736 [dir=back] -85333912 -> 85336648 [dir=back] - -85311112[ label="{UniformFlow|+direction:Orientation\l}"] - -85329352[ label="{FruchtermanReingold|+name:STRING\l+attractionMultiplier:FLOAT\l+resolutionMultiplier:FLOAT\l+maxIterations:INT\l}"] - -85321144[ label="{BalloonTreeAlgorithm|+name:STRING\l+minRadius:INT\l}"] - -49020056 -> 49023704[arrowtail=diamond, dir=both, headlabel="layoutType "] -49020056[ label="{LayoutGraph|}"] - -49031000[ label="{Planar|+criterion:STRING\l}"] - -85319320[ label="{CompactTreeAlgorithm|+name:STRING\lhorizontal:BOOL\linvert:BOOL\lresizeParents:BOOL\l+levelDistance:INT\l+nodeDistance:INT\l}"] - -85320232[ label="{NodeLinkTreeAlgorithm|+name:STRING\l+orientation:Orientation\l+spacingSiblings:FLOAT\l+spacingSubtrees:FLOAT\l+spacingLevels:FLOAT\l+offsetRootNode:FLOAT\l}"] - -85318408[ label="{LevelBasedTreeAlgorithm|+name:STRING\l+xDist:INT\l+yDist:INT\l}"] - -49026440 -> 49028264[arrowtail=diamond, dir=both, headlabel="aestheticCriteria 1..*"] -49026440[ label="{AestheticCriteria|+howToLayout:STRING\l}"] - -85314760[ label="{EdgeVariation|+criterion:STRING\l}"] - -85316584[ label="{TreeAlgorithm|}"] -85316584 -> 85317496 [dir=back] -85316584 -> 85318408 [dir=back] -85316584 -> 85319320 [dir=back] -85316584 -> 85320232 [dir=back] -85316584 -> 85321144 [dir=back] - -49021880 -> 49022792[arrowtail=diamond, dir=both, headlabel="subgraph "] -49021880 -> 49023704[arrowtail=diamond, dir=both, headlabel="layoutType "] -49021880[ label="{LayoutSubraph|}"] - -49029176[ label="{EdgeCrossings|}"] -49029176 -> 49030088 [dir=back] -49029176 -> 49031000 [dir=back] - -85337560[ label="{Vertex|+index:INT\l}"] - -85312936[ label="{NodeDistribution|+criterion:STRING\l}"] - -85324792[ label="{SymmetricAlgorithm|}"] -85324792 -> 85325704 [dir=back] -85324792 -> 85326616 [dir=back] - -49024616[ label="{LayoutStyle|+howToLayout:STRING\l+style:LayoutStyleEnum\l}"] - -49031912[ label="{MinimumAngles|+criterion:STRING\l+threshold:INT\l}"] - -49019144[ label="{Layout|}"] -49019144 -> 49020056 [dir=back] -49019144 -> 49020968 [dir=back] - -85323880[ label="{CircularAlgorithm|+name:STRING\loptimize:BOOL\l+dist:INT\l}"] - -85338472 -> 85337560[arrowtail=diamond, dir=both, headlabel="vertices 1..*"] -85338472[ label="{Automorphism|}"] - -49027352 -> 85315672[arrowtail=diamond, dir=both, headlabel="algorithm "] -49027352[ label="{LayoutAlgorithm|+howToLayout:STRING\l}"] - -49030088[ label="{MinimizeCrossings|+criterion:STRING\l}"] - -85335736[ label="{ConvexAlgorithm|+name:STRING\l+dist:INT\l}"] - -85326616[ label="{PlanarSymmetricAlgorithm|+type:STRING\l}"] - -85313848[ label="{EdgeLengths|+criterion:STRING\l}"] - -44763880[ label="{STRING|}"] - -49017320[ label="{NUMBER|}"] -49017320 -> 44766616 [dir=back] -49017320 -> 44765704 [dir=back] - -44766616[ label="{FLOAT|}"] - -49018232[ label="{BASETYPE|}"] -49018232 -> 49017320 [dir=back] -49018232 -> 44762968 [dir=back] -49018232 -> 44763880 [dir=back] -49018232 -> 44764792 [dir=back] - -44765704[ label="{INT|}"] - -44762968[ label="{ID|}"] - -44764792[ label="{BOOL|}"] - - -} diff --git a/GraphLayoutDSL/target/classes/language/layout.png b/GraphLayoutDSL/target/classes/language/layout.png deleted file mode 100644 index 7f12d51..0000000 Binary files a/GraphLayoutDSL/target/classes/language/layout.png and /dev/null differ diff --git a/GraphLayoutDSL/target/classes/language/layout.tx b/GraphLayoutDSL/target/classes/language/layout.tx deleted file mode 100644 index 758398f..0000000 --- a/GraphLayoutDSL/target/classes/language/layout.tx +++ /dev/null @@ -1,494 +0,0 @@ -Layout: - LayoutGraph | LayoutSubgraphs -; - -LayoutGraph: - 'lay' 'out' 'graph' layoutType = LayoutEnum -; - -LayoutSubgraphs: - 'lay' 'out' layoutSubgraphs += LayoutSubraph[';'] -; - -LayoutSubraph: - (subgraph = Subgraph | 'others') layoutType = LayoutEnum -; - -Subgraph: - 'subgraph' vertices += Vertex[','] -; - - -LayoutEnum: - LayoutStyle | AestheticCriteria | LayoutAlgorithm -; - -LayoutStyle: - 'style' style = LayoutStyleEnum -; - -LayoutStyleEnum: - 'automatic' | 'circular' | 'tree' | 'hierarchical' | 'symmetric' | 'general' -; - -AestheticCriteria: - 'criteria' aestheticCriteria += AestheticCriteion[','] -; - -LayoutAlgorithm: - 'algorithm' algorithm = LayoutAlgorithmEnum -; - -AestheticCriteion: - EdgeCrossings | MinimumAngles | MinimumBands | - UniformFlow | Symmetry | - NodeDistribution | EdgeLengths | EdgeVariation -; - -EdgeCrossings: - MinimizeCrossings | Planar -; - -MinimizeCrossings: - 'minimize'? 'edge' criterion = 'crossings' -; -Planar: - criterion = 'planar' -; - -MinimumAngles: - ('maximize' 'minimal')? criterion = 'angle' ('threshold' '=' threshold = INT)? -; - -MinimumBands: - 'minimize'? criterion = 'bands' -; - -UniformFlow: - 'uniform'? criterion = 'flow' ('direction' '=' direction = Orientation)? -; - -Symmetry: - criterion = 'symmetric' ('automorphism' automorphism = Automorphism)? -; - - -NodeDistribution: - criterion = 'distribute' 'nodes' 'evenly' -; - -EdgeLengths: - criterion = 'optimize' 'edges' 'lengths' -; - -EdgeVariation: - criterion = 'similar' 'edges' 'lengths' -; - - -LayoutAlgorithmEnum: - TreeAlgorithm | StraightLineAlgorithm | HierarchicalAlgorithm | - CircularAlgorithm | SymmetricAlgorithm | ForceDirectedAlgorithm | - BoxAlgorithm -; - -TreeAlgorithm: - RadialTreeAlgorithm | LevelBasedTreeAlgorithm | CompactTreeAlgorithm | - NodeLinkTreeAlgorithm | BalloonTreeAlgorithm -; - -RadialTreeAlgorithm: - name = 'radial' 'tree' - properties *= RadialTreeAlgorithmProperty[','] -; - -RadialTreeAlgorithmProperty: - HorizontalTreeProperty | VerticalTreeProperty -; - -HorizontalTreeProperty: - 'horizontal' 'distance'? '=' xDist = INT -; - -VerticalTreeProperty: - 'vertical' 'distance'? '=' yDist = INT -; - -LevelBasedTreeAlgorithm: - name = 'level' 'based' 'tree' - properties *= LevelBasedTreeAlgorithmProperty[','] -; - -LevelBasedTreeAlgorithmProperty: - HorizontalTreeProperty | VerticalTreeProperty -; - -CompactTreeAlgorithm: - name = 'compact' 'tree' - properties *= CompactTreeAlgorithmProperty[','] -; - -CompactTreeAlgorithmProperty: - IsHorizontalProperty | IsInvertProperty | IsResizeParentsProperty | - LevelDistanceProperty | NodeDistanceProperty -; - -IsHorizontalProperty: - horizontal ?= 'horizontal' -; - -IsInvertProperty: - invert ?= 'invert' -; - -IsResizeParentsProperty: - resizeParents ?= 'resize' 'parents' -; - -LevelDistanceProperty: - 'level' ' distance' '=' levelDistance = INT -; - -NodeDistanceProperty: - 'node' 'distance' '=' nodeDistance = INT -; - -NodeLinkTreeAlgorithm: - name = 'node' 'link' 'tree' - properties *= NodeLinkTreeAlgorithmProperty[','] -; - -NodeLinkTreeAlgorithmProperty: - OrientationProperty | SpacingSiblingsProperty | SpacingSubtreesProperty | - SpacingLevelsProperty | OffsetForRootNodeProperty -; - -OrientationProperty: - 'orientation' '=' orientation = Orientation -; - -SpacingSiblingsProperty: - 'spacing' 'between'? 'siblings' '=' spacingSiblings = FLOAT -; - -SpacingSubtreesProperty: - 'spacing' 'between'? 'subtrees' '=' spacingSubtrees = FLOAT -; - -SpacingLevelsProperty: - 'spacing' 'between'? 'depth'? 'levels' '=' spacingLevels = FLOAT -; - -OffsetForRootNodeProperty: - 'offset' 'for'? 'root' 'node'? '=' offsetRootNode = FLOAT -; - -BalloonTreeAlgorithm: - name = 'balloon' 'tree' - properties *= BalloonTreeAlgorithmProperty[','] -; - -//this was done in order to avoid inconsistencies with other rules of this kind and to enable easy addition of additional properties -BalloonTreeAlgorithmProperty: - MinimalRadiusProperty -; - -MinimalRadiusProperty: - 'minimal' 'radius' '=' minRadius = INT -; - -HierarchicalAlgorithm: - name = 'hierarchical' - properties *= HierarchicalAlgorithmProperty[','] -; - -HierarchicalAlgorithmProperty: - IsResizeParentsProperty | ParentBorderProperty | IsMoveParentProperty | - IntraCellSpacingProperty | InterRankSpacingProperty | InterHierarchySpacingProperty | - ParallelEdgesSpacingProperty | OrientationProperty | IsFineTuneProperty -; - -IsMoveParentProperty: - moveParent ?= 'move' 'parent' -; - -ParentBorderProperty: - 'parent' 'border' '=' parentBorder = INT -; - -IntraCellSpacingProperty: - 'same' 'layer' 'spacing' '=' intraCellSpacing = FLOAT -; - -InterRankSpacingProperty: - 'adjacent' 'layers' 'spacing' '=' interRankSpacing = FLOAT -; - -InterHierarchySpacingProperty: - 'hierarchy' 'spacing' '=' interHierarchySpacing = FLOAT -; - -ParallelEdgesSpacingProperty: - 'parallel' 'edges' 'spacing' '=' parallelEdgesSpacing = FLOAT -; - -IsFineTuneProperty: - fineTune ?= 'fine' 'tune' -; - -CircularAlgorithm: - name = 'circular' - properties *= CircularAlgorithmProperty[','] -; - -CircularAlgorithmProperty: - IsOptimizeCrossingProperty | DistanceProperty -; - -IsOptimizeCrossingProperty: - optimize ?= 'optimize' 'crossings' -; -DistanceProperty: - 'distance' '=' dist = INT -; - -SymmetricAlgorithm: - ConcentricSymmetricAlgorithm | PlanarSymmetricAlgorithm -; - -ConcentricSymmetricAlgorithm: - name = 'concentric' 'symmetric' - properties *= ConcentricSymmetricAlgorithmProperty[','] - -; - -ConcentricSymmetricAlgorithmProperty: - AutomorphismProperty -; -AutomorphismProperty: - 'automorphism' '=' automorphism = Automorphism -; - -PlanarSymmetricAlgorithm: - type = 'planar' 'name = symmetric' -; - -ForceDirectedAlgorithm: - KamadaKawai | FruchtermanReingold | Spring | - FastOrganic | Organic -; - -KamadaKawai: - name = 'Kamada' 'Kawai' - properties *= KamadaKawaiProperties[','] -; - -KamadaKawaiProperties: - DisconnectedDistanceMultiplierProperty | LengthFactorProperty | - MaxIterationsProperty -; - -DisconnectedDistanceMultiplierProperty: - 'disconnected'? 'distance' 'multiplier' '=' distanceMultiplier = FLOAT -; -LengthFactorProperty: - 'length' 'factor' '=' lengthFactor = FLOAT -; -MaxIterationsProperty: - 'maximum' 'iterations' '=' maxIterations = INT -; - -FruchtermanReingold: - name = 'Fruchterman' 'Reingold' - properties *= FruchtermanReingoldProperty[','] -; - -FruchtermanReingoldProperty: - AttractionMultiplierProperty | ResolutionMultiplierProperty | MaxIterationsProperty -; - -AttractionMultiplierProperty: - 'attraction' 'multiplier' '=' attractionMultiplier = FLOAT -; - -ResolutionMultiplierProperty: - 'resolution' 'multiplier' '=' resolutionMultiplier = FLOAT -; - -Spring: - name = 'spring' - properties *= SpringProperty[','] -; - -SpringProperty: - StretchProperty | RepulsionRangeProperty | ForceMultiplierProperty -; - -StretchProperty: - 'stretch' '=' stretch = FLOAT -; - -RepulsionRangeProperty: - 'repulsion' 'range' '=' resolutionRange = INT -; - -ForceMultiplierProperty: - 'force' 'multiplier' '=' forceMultiplier = FLOAT -; - -FastOrganic: - type = 'fast' name = 'organic' - properties *= FastOrganicProperty[','] -; - -FastOrganicProperty: - ForceConstantProperty | MinimalDistanceLimitProperty | - InitialTemperatureProperty | MaxIterationsProperty -; - -ForceConstantProperty: - 'force' 'constant' '=' forceConstant = FLOAT -; - -MinimalDistanceLimitProperty: - 'minimal' 'distance' 'limit' '=' minimalDistanceLimit = FLOAT -; - -InitialTemperatureProperty: - 'initial' 'temperature' '=' initialTemperature = FLOAT -; - -Organic: - name = 'organic' - properties *= OrganicProperty[','] -; - -OrganicProperty: - EdgeCrossingFactorProperty | IsOptimizeEdgeCrossingsProperty | - EdgeDistanceFactorProperty | IsOptimizeEdgeDistanceProperty | - BorderLineFactorProperty | IsOptimizeBorderLineProperty | - NodeDistributionFactorProperty | IsOptimizeNodeDistributionProperty | - FineTuningRadiusProperty | IsFineTuneProperty | - AverageNodeAreaProperty | AverageScaleFactorProperty | - MaxIterationsProperty -; - -IsOptimizeEdgeCrossingsProperty: - optimizeEdgeCrossings ?= 'optimize' 'edge' 'crossings' -; - -EdgeCrossingFactorProperty: - 'edge' 'crossing' 'factor' '=' edgeCrossingFactor = FLOAT -; - -IsOptimizeEdgeDistanceProperty: - optimizeEdgeDistance ?= 'optimize' 'edge' 'distance' -; - -EdgeDistanceFactorProperty: - 'edge' 'distance' 'factor' '=' edgeDistanceFactor = FLOAT -; - - -IsOptimizeBorderLineProperty: - optimizeBorderLine ?= 'optimize' 'border' 'line' -; - -BorderLineFactorProperty: - 'border' 'line' 'factor' '=' borderLineFactor = FLOAT -; - - -IsOptimizeNodeDistributionProperty: - optimizeNodeDistribution ?= 'optimize' 'node' 'distribution' -; - -NodeDistributionFactorProperty: - 'node' 'distribution' 'factor' '=' nodeDistributionFactor = FLOAT -; - -FineTuningRadiusProperty: - 'fine' 'tuning' 'radius' '=' fineTuningRadius = FLOAT -; - -AverageNodeAreaProperty: - 'average' 'node' 'area' '=' averageNodeArea = FLOAT -; - -AverageScaleFactorProperty: - 'average' 'scale' 'factor' '=' averageScaleFactor = FLOAT -; - - -BoxAlgorithm: - name = 'box' - properties *= BoxAlgorithmPropery[','] -; - -BoxAlgorithmPropery: - ColumnsProperty -; - -ColumnsProperty: - 'columns' '=' numOfColumns = INT -; - - -StraightLineAlgorithm: - TutteEmbedding | ConvexAlgorithm | OrthogonalAlgorithm -; - -TutteEmbedding: - name = 'Tutte' 'embedding' - properties *= TutteEmbeddingProperty[','] -; - -TutteEmbeddingProperty: - DistanceProperty -; - -DistanceProperty: - 'distance' '=' dist = INT -; - -ConvexAlgorithm: - name = 'convex' - properties *= ConvexAlgorithmProperty[','] -; - -ConvexAlgorithmProperty: - DistanceProperty -; - -OrthogonalAlgorithm: - name = 'orthogonal' - properties *= OrthogonalAlgorithmProperty[','] -; - -//it is almost certain that there will be more properties -OrthogonalAlgorithmProperty: - RectnagularProperty -; - -RectnagularProperty: - rectangular ?= 'rectangular' -; - - -Vertex: - 'v' index = INT | content = STRING -; - -Automorphism: - '(' vertices += Vertex[','] ')' -; - -Orientation: - 'left' | 'right' | 'up' | 'down' -; - -Comment: - /\/\/.*$/ -; - - \ No newline at end of file diff --git a/GraphLayoutDSL/target/classes/models/pythonmodels.py b/GraphLayoutDSL/target/classes/models/pythonmodels.py deleted file mode 100644 index 960efda..0000000 --- a/GraphLayoutDSL/target/classes/models/pythonmodels.py +++ /dev/null @@ -1,49 +0,0 @@ -from interfaces import ILayoutSubgraphs, ILayoutGraph - -class MLayoutGraph(ILayoutGraph): - '''This class contains all information regarding - how a graph should be laid out. It is also used - to describe how a subgraph should be laid out''' - - - def __init__(self, graph = None, type = None, style = "", graphContent = False, aestheticCriteria = None, - algorithm = None, exception = ""): - self.attr_graph = graph - self.attr_type = type - self.attr_style = style - self.attr_aestheticCriteria = aestheticCriteria - self.attr_algorithm = algorithm - self.attr_graphContent = graphContent - self.attr_exception = exception - - def getGraph(self): - return self.attr_graph - - def getType(self): - return self.attr_type - - def getStyle(self): - return self.attr_style - - def getAestheticCriteria(self): - return self.attr_aestheticCriteria - - def getAlgorithm(self): - return self.attr_algorithm - - def isGraphContent(self): - return self.attr_graphContent - - def getException(self): - return self.attr_exception - - -class MLayoutSubgraphs(ILayoutSubgraphs): - '''This class contains a list of instructions - regarding how to lay out subgraphs''' - - def __init__(self, subgraphs): - self.att_subgraphs = subgraphs - - def getSubgraphs(self): - return self.att_subgraphs \ No newline at end of file diff --git a/GraphLayoutDSL/target/classes/modules/arpeggio/__init__.py b/GraphLayoutDSL/target/classes/modules/arpeggio/__init__.py deleted file mode 100644 index 705551b..0000000 --- a/GraphLayoutDSL/target/classes/modules/arpeggio/__init__.py +++ /dev/null @@ -1,1734 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################### -# Name: arpeggio.py -# Purpose: PEG parser interpreter -# Author: Igor R. Dejanović -# Copyright: (c) 2009-2015 Igor R. Dejanović -# License: MIT License -# -# This is an implementation of packrat parser interpreter based on PEG -# grammars. Grammars are defined using Python language constructs or the PEG -# textual notation. -############################################################################### - -from __future__ import print_function, unicode_literals -import sys -if sys.version < '3': - text = unicode -else: - text = str - -import codecs -import re -import bisect -from arpeggio.utils import isstr -import types - -DEFAULT_WS = '\t\n\r ' -NOMATCH_MARKER = 0 - - -class ArpeggioError(Exception): - """ - Base class for arpeggio errors. - """ - def __init__(self, message): - self.message = message - - def __str__(self): - return repr(self.message) - - -class GrammarError(ArpeggioError): - """ - Error raised during parser building phase used to indicate error in the - grammar definition. - """ - - -class SemanticError(ArpeggioError): - """ - Error raised during the phase of semantic analysis used to indicate - semantic error. - """ - - -class NoMatch(Exception): - """ - Exception raised by the Match classes during parsing to indicate that the - match is not successful. - - Args: - rules (list of ParserExpression): Rules that are tried at the position - of the exception. - position (int): A position in the input stream where exception - occurred. - parser (Parser): An instance of a parser. - """ - def __init__(self, rules, position, parser): - self.rules = rules - self.position = position - self.parser = parser - - def __str__(self): - def rule_to_exp_str(rule): - if hasattr(rule, '_exp_str'): - # Rule may override expected report string - return rule._exp_str - elif rule.root: - return rule.rule_name - elif isinstance(rule, Match) and \ - not isinstance(rule, EndOfFile): - return "'{}'".format(rule.to_match) - else: - return rule.name - - what_is_expected = ["{}".format(rule_to_exp_str(r)) for r in self.rules] - - if len(what_is_expected) == 0: - what_str = "'{}'".format(what_is_expected[0]) - else: - what_str = " or ".join(what_is_expected) - - if self.parser.file_name: - return "Expected {} at {}:{} => '{}'."\ - .format(what_str, - self.parser.file_name, - text(self.parser.pos_to_linecol(self.position)), - self.parser.context(position=self.position)) - else: - return "Expected {} at position {} => '{}'."\ - .format(what_str, - text(self.parser.pos_to_linecol(self.position)), - self.parser.context(position=self.position)) - - def __unicode__(self): - return self.__str__() - - -def flatten(_iterable): - '''Flattening of python iterables.''' - result = [] - for e in _iterable: - if hasattr(e, "__iter__") and not type(e) in [text, NonTerminal]: - result.extend(flatten(e)) - else: - result.append(e) - return result - - -class DebugPrinter(object): - """ - Mixin class for adding debug print support. - - Attributes: - debug (bool): If true debugging messages will be printed. - _current_ident(int): Current identation level for prints. - """ - - def __init__(self, **kwargs): - - self.debug = kwargs.pop("debug", False) - self._current_ident = 0 - - super(DebugPrinter, self).__init__(**kwargs) - - def dprint(self, message, ident_change=0): - """ - Handle debug message. Current implementation will print to stdout using - the current identation level. - """ - if ident_change < 0: - self._current_ident += ident_change - - print(("%s%s" % (" " * self._current_ident, message))) - - if ident_change > 0: - self._current_ident += ident_change - - -# --------------------------------------------------------- -# Parser Model (PEG Abstract Semantic Graph) elements - - -class ParsingExpression(object): - """ - An abstract class for all parsing expressions. - Represents the node of the Parser Model. - - Attributes: - elements: A list (or other python object) used as a staging structure - for python based grammar definition. Used in _from_python for - building nodes list of child parser expressions. - rule_name (str): The name of the parser rule if this is the root rule. - root (bool): Does this parser expression represents the - root of the parser rule? The root parser rule will create - non-terminal node of the parse tree during parsing. - nodes (list of ParsingExpression): A list of child parser expressions. - suppress (bool): If this is set to True than no ParseTreeNode will be - created for this ParsingExpression. Default False. - """ - def __init__(self, *elements, **kwargs): - - if len(elements) == 1: - elements = elements[0] - self.elements = elements - - self.rule_name = kwargs.get('rule_name', '') - self.root = kwargs.get('root', False) - - nodes = kwargs.get('nodes', []) - if not hasattr(nodes, '__iter__'): - nodes = [nodes] - self.nodes = nodes - - self.suppress = kwargs.get('suppress', False) - - # Memoization. Every node cache the parsing results for the given input - # positions. - self._result_cache = {} # position -> parse tree at the position - - @property - def desc(self): - return "{}{}".format(self.name, "-" if self.suppress else "") - - @property - def name(self): - if self.root: - return "%s=%s" % (self.rule_name, self.__class__.__name__) - else: - return self.__class__.__name__ - - @property - def id(self): - if self.root: - return self.rule_name - else: - return id(self) - - def _clear_cache(self, processed=None): - """ - Clears memoization cache. Should be called on input change and end - of parsing. - - Args: - processed (set): Set of processed nodes to prevent infinite loops. - """ - - self._result_cache = {} - - if not processed: - processed = set() - - for node in self.nodes: - if node not in processed: - processed.add(node) - node._clear_cache(processed) - - def parse(self, parser): - - if parser.debug: - name = self.name - if name.startswith('__asgn'): - name = "{}[{}]".format(self.name, self._attr_name) - parser.dprint(">> Matching rule {}{} at position {} => {}" - .format(name, - " in {}".format(parser.in_rule) - if parser.in_rule else "", - parser.position, - parser.context()), 1) - - # Current position could change in recursive calls - # so save it. - c_pos = parser.position - - # Memoization. - # If this position is already parsed by this parser expression use - # the result - if parser.memoization: - try: - result, new_pos = self._result_cache[c_pos] - parser.position = new_pos - parser.cache_hits += 1 - if parser.debug: - parser.dprint( - "** Cache hit for [{}, {}] = '{}' : new_pos={}" - .format(name, c_pos, text(result), text(new_pos))) - parser.dprint( - "<<+ Matched rule {} at position {}" - .format(name, new_pos), -1) - - # If NoMatch is recorded at this position raise. - if result is NOMATCH_MARKER: - raise parser.nm - - # else return cached result - return result - - except KeyError: - parser.cache_misses += 1 - - - # Remember last parsing expression and set this as - # the new last. - last_pexpression = parser.last_pexpression - parser.last_pexpression = self - - if self.rule_name: - # If we are entering root rule - # remember previous root rule name and set - # this one on the parser to be available for - # debugging messages - previous_root_rule_name = parser.in_rule - parser.in_rule = self.rule_name - - try: - result = self._parse(parser) - if self.suppress or (type(result) is list and - result and result[0] is None): - result = None - - except NoMatch: - parser.position = c_pos # Backtracking - # Memoize NoMatch at this position for this rule - if parser.memoization: - self._result_cache[c_pos] = (NOMATCH_MARKER, c_pos) - raise - - finally: - # Recover last parsing expression. - parser.last_pexpression = last_pexpression - - if parser.debug: - parser.dprint("<<{} rule {}{} at position {} => {}" - .format("- Not matched" - if parser.position is c_pos - else "+ Matched", - name, - " in {}".format(parser.in_rule) - if parser.in_rule else "", - parser.position, - parser.context()), -1) - - # If leaving root rule restore previous root rule name. - if self.rule_name: - parser.in_rule = previous_root_rule_name - - # For root rules flatten non-terminal/list - if self.root and result and not isinstance(result, Terminal): - if not isinstance(result, NonTerminal): - result = flatten(result) - - # Tree reduction will eliminate Non-terminal with single child. - if parser.reduce_tree and len(result) == 1: - result = result[0] - - # If the result is not parse tree node it must be a plain list - # so create a new NonTerminal. - if not isinstance(result, ParseTreeNode): - result = NonTerminal(self, result) - - # Result caching for use by memoization. - if parser.memoization: - self._result_cache[c_pos] = (result, parser.position) - - return result - - -class Sequence(ParsingExpression): - """ - Will match sequence of parser expressions in exact order they are defined. - """ - - def __init__(self, *elements, **kwargs): - super(Sequence, self).__init__(*elements, **kwargs) - self.ws = kwargs.pop('ws', None) - self.skipws = kwargs.pop('skipws', None) - - def _parse(self, parser): - results = [] - c_pos = parser.position - - if self.ws is not None: - old_ws = parser.ws - parser.ws = self.ws - - if self.skipws is not None: - old_skipws = parser.skipws - parser.skipws = self.skipws - - # Prefetching - append = results.append - - try: - for e in self.nodes: - result = e.parse(parser) - if result: - append(result) - - except NoMatch: - parser.position = c_pos # Backtracking - raise - - finally: - if self.ws is not None: - parser.ws = old_ws - if self.skipws is not None: - parser.skipws = old_skipws - - if results: - return results - - -class OrderedChoice(Sequence): - """ - Will match one of the parser expressions specified. Parser will try to - match expressions in the order they are defined. - """ - def _parse(self, parser): - result = None - match = False - c_pos = parser.position - for e in self.nodes: - try: - result = e.parse(parser) - if result is not None: - match = True - result = [result] - break - except NoMatch: - parser.position = c_pos # Backtracking - - if not match: - parser._nm_raise(self, c_pos, parser) - - return result - - -class Repetition(ParsingExpression): - """ - Base class for all repetition-like parser expressions (?,*,+) - Args: - eolterm(bool): Flag that indicates that end of line should - terminate repetition match. - """ - def __init__(self, *elements, **kwargs): - super(Repetition, self).__init__(*elements, **kwargs) - if 'eolterm' in kwargs: - self.eolterm = kwargs['eolterm'] - else: - self.eolterm = False - - -class Optional(Repetition): - """ - Optional will try to match parser expression specified and will not fail - in case match is not successful. - """ - def _parse(self, parser): - result = None - c_pos = parser.position - - # Set parser for optional mode - oldin_optional = parser.in_optional - parser.in_optional = True - - try: - result = [self.nodes[0].parse(parser)] - except NoMatch: - parser.position = c_pos # Backtracking - - # Restore in_optional state - parser.in_optional = oldin_optional - - return result - - -class ZeroOrMore(Repetition): - """ - ZeroOrMore will try to match parser expression specified zero or more - times. It will never fail. - """ - def _parse(self, parser): - results = [] - - if self.eolterm: - # Remember current eolterm and set eolterm of - # this repetition - old_eolterm = parser.eolterm - parser.eolterm = self.eolterm - - # Set parser for optional mode - oldin_optional = parser.in_optional - parser.in_optional = True - - # Prefetching - append = results.append - p = self.nodes[0].parse - - while True: - try: - c_pos = parser.position - result = p(parser) - if not result: - break - append(result) - except NoMatch: - parser.position = c_pos # Backtracking - break - - if self.eolterm: - # Restore previous eolterm - parser.eolterm = old_eolterm - - # Restore in_optional state - parser.in_optional = oldin_optional - - return results - - -class OneOrMore(Repetition): - """ - OneOrMore will try to match parser expression specified one or more times. - """ - def _parse(self, parser): - results = [] - first = True - - if self.eolterm: - # Remember current eolterm and set eolterm of - # this repetition - old_eolterm = parser.eolterm - parser.eolterm = self.eolterm - - # Set parser for optional mode - oldin_optional = parser.in_optional - - # Prefetching - append = results.append - p = self.nodes[0].parse - - try: - while True: - try: - c_pos = parser.position - result = p(parser) - if not result: - break - append(result) - first = False - parser.in_optional = True - except NoMatch: - parser.position = c_pos # Backtracking - - if first: - raise - - break - finally: - if self.eolterm: - # Restore previous eolterm - parser.eolterm = old_eolterm - - # Restore in_optional state - parser.in_optional = oldin_optional - - return results - - -class SyntaxPredicate(ParsingExpression): - """ - Base class for all syntax predicates (and, not, empty). - Predicates are parser expressions that will do the match but will not - consume any input. - """ - - -class And(SyntaxPredicate): - """ - This predicate will succeed if the specified expression matches current - input. - """ - def _parse(self, parser): - c_pos = parser.position - for e in self.nodes: - try: - e.parse(parser) - except NoMatch: - parser.position = c_pos - raise - parser.position = c_pos - - -class Not(SyntaxPredicate): - """ - This predicate will succeed if the specified expression doesn't match - current input. - """ - def _parse(self, parser): - c_pos = parser.position - for e in self.nodes: - try: - e.parse(parser) - except NoMatch: - parser.position = c_pos - return - parser.position = c_pos - parser._nm_raise(self, c_pos, parser) - - -class Empty(SyntaxPredicate): - """ - This predicate will always succeed without consuming input. - """ - def _parse(self, parser): - pass - - -class Decorator(ParsingExpression): - """ - Decorator are special kind of parsing expression used to mark - a containing pexpression and give it some special semantics. - For example, decorators are used to mark pexpression as lexical - rules (see :class:Lex). - """ - - -class Combine(Decorator): - """ - This decorator defines pexpression that represents a lexeme rule. - This rules will always return a Terminal parse tree node. - Whitespaces will be preserved. Comments will not be matched. - """ - def _parse(self, parser): - results = [] - - oldin_lex_rule = parser.in_lex_rule - parser.in_lex_rule = True - c_pos = parser.position - try: - for parser_model_node in self.nodes: - results.append(parser_model_node.parse(parser)) - - results = flatten(results) - - # Create terminal from result - return Terminal(self, c_pos, - "".join([x.flat_str() for x in results])) - except NoMatch: - parser.position = c_pos # Backtracking - raise - finally: - parser.in_lex_rule = oldin_lex_rule - - -class Match(ParsingExpression): - """ - Base class for all classes that will try to match something from the input. - """ - def __init__(self, rule_name, root=False): - super(Match, self).__init__(rule_name=rule_name, root=root) - - @property - def name(self): - if self.root: - return "%s=%s(%s)" % (self.rule_name, self.__class__.__name__, - self.to_match) - else: - return "%s(%s)" % (self.__class__.__name__, self.to_match) - - def _parse_comments(self, parser): - """Parse comments.""" - - try: - parser.in_parse_comments = True - if parser.comments_model: - try: - while True: - # TODO: Consumed whitespaces and comments should be - # attached to the first match ahead. - parser.comments.append( - parser.comments_model.parse(parser)) - if parser.skipws: - parser._skip_ws() - except NoMatch: - # NoMatch in comment matching is perfectly - # legal and no action should be taken. - pass - finally: - parser.in_parse_comments = False - - def parse(self, parser): - - if parser.skipws and not parser.in_lex_rule: - parser._skip_ws() - - if parser.debug: - parser.dprint( - "?? Try match rule {}{} at position {} => {}" - .format(self.name, - " in {}".format(parser.in_rule) - if parser.in_rule else "", - parser.position, - parser.context())) - - if parser.position in parser.comment_positions: - # Skip comments if already parsed. - parser.position = parser.comment_positions[parser.position] - else: - if not parser.in_parse_comments and not parser.in_lex_rule: - comment_start = parser.position - self._parse_comments(parser) - parser.comment_positions[comment_start] = parser.position - - result = self._parse(parser) - if not self.suppress: - return result - - -class RegExMatch(Match): - ''' - This Match class will perform input matching based on Regular Expressions. - - Args: - to_match (regex string): A regular expression string to match. - It will be used to create regular expression using re.compile. - ignore_case(bool): If case insensitive match is needed. - Default is None to support propagation from global parser setting. - str_repr(str): A string that is used to represent this regex. - - ''' - def __init__(self, to_match, rule_name='', root=False, ignore_case=None, - str_repr=None): - super(RegExMatch, self).__init__(rule_name, root) - self.to_match_regex = to_match - self.ignore_case = ignore_case - - self.to_match = str_repr if str_repr is not None else to_match - - def compile(self): - flags = re.MULTILINE - if self.ignore_case: - flags |= re.IGNORECASE - self.regex = re.compile(self.to_match_regex, flags) - - def __str__(self): - return self.to_match - - def __unicode__(self): - return self.__str__() - - def _parse(self, parser): - c_pos = parser.position - m = self.regex.match(parser.input, c_pos) - if m: - matched = m.group() - if parser.debug: - parser.dprint( - "++ Match '%s' at %d => '%s'" % - (matched, c_pos, parser.context(len(matched)))) - parser.position += len(matched) - if matched: - return Terminal(self, c_pos, matched) - else: - if parser.debug: - parser.dprint("-- NoMatch at {}".format(c_pos)) - parser._nm_raise(self, c_pos, parser) - - -class StrMatch(Match): - """ - This Match class will perform input matching by a string comparison. - - Args: - to_match (str): A string to match. - ignore_case(bool): If case insensitive match is needed. - Default is None to support propagation from global parser setting. - """ - def __init__(self, to_match, rule_name='', root=False, ignore_case=None): - super(StrMatch, self).__init__(rule_name, root) - self.to_match = to_match - self.ignore_case = ignore_case - - def _parse(self, parser): - c_pos = parser.position - input_frag = parser.input[c_pos:c_pos+len(self.to_match)] - if self.ignore_case: - match = input_frag.lower() == self.to_match.lower() - else: - match = input_frag == self.to_match - if match: - if parser.debug: - parser.dprint( - "++ Match '{}' at {} => '{}'" - .format(self.to_match, c_pos, - parser.context(len(self.to_match)))) - parser.position += len(self.to_match) - - # If this match is inside sequence than mark for suppression - suppress = type(parser.last_pexpression) is Sequence - - return Terminal(self, c_pos, self.to_match, suppress=suppress) - else: - if parser.debug: - parser.dprint( - "-- No match '{}' at {} => '{}'" - .format(self.to_match, c_pos, - parser.context(len(self.to_match)))) - parser._nm_raise(self, c_pos, parser) - - def __str__(self): - return self.to_match - - def __unicode__(self): - return self.__str__() - - def __eq__(self, other): - return self.to_match == text(other) - - def __hash__(self): - return hash(self.to_match) - - -# HACK: Kwd class is a bit hackish. Need to find a better way to -# introduce different classes of string tokens. -class Kwd(StrMatch): - """ - A specialization of StrMatch to specify keywords of the language. - """ - def __init__(self, to_match): - super(Kwd, self).__init__(to_match) - self.to_match = to_match - self.root = True - self.rule_name = 'keyword' - - -class EndOfFile(Match): - """ - The Match class that will succeed in case end of input is reached. - """ - def __init__(self): - super(EndOfFile, self).__init__("EOF") - - @property - def name(self): - return "EOF" - - def _parse(self, parser): - c_pos = parser.position - if len(parser.input) == c_pos: - return Terminal(EOF(), c_pos, '', suppress=True) - else: - if parser.debug: - parser.dprint("!! EOF not matched.") - parser._nm_raise(self, c_pos, parser) - - -def EOF(): - return EndOfFile() - -# --------------------------------------------------------- - - -# --------------------------------------------------- -# Parse Tree node classes - -class ParseTreeNode(object): - """ - Abstract base class representing node of the Parse Tree. - The node can be terminal(the leaf of the parse tree) or non-terminal. - - Attributes: - rule (ParsingExpression): The rule that created this node. - rule_name (str): The name of the rule that created this node if - root rule or empty string otherwise. - position (int): A position in the input stream where the match - occurred. - error (bool): Is this a false parse tree node created during error - recovery. - comments : A parse tree of comment(s) attached to this node. - """ - def __init__(self, rule, position, error): - assert rule - assert rule.rule_name is not None - self.rule = rule - self.rule_name = rule.rule_name - self.position = position - self.error = error - self.comments = None - - @property - def name(self): - return "%s [%s]" % (self.rule_name, self.position) - - def visit(self, visitor): - """ - Visitor pattern implementation. - - Args: - visitor(PTNodeVisitor): The visitor object. - """ - if visitor.debug: - visitor.dprint("Visiting {} type:{} str:{}" - .format(self.name, type(self).__name__, text(self))) - - children = SemanticActionResults() - if isinstance(self, NonTerminal): - for node in self: - child = node.visit(visitor) - # If visit returns None suppress that child node - if child is not None: - children.append_result(node.rule_name, child) - - visit_name = "visit_%s" % self.rule_name - if hasattr(visitor, visit_name): - # Call visit method. - result = getattr(visitor, visit_name)(self, children) - - # If there is a method with 'second' prefix save - # the result of visit for post-processing - if hasattr(visitor, "second_%s" % self.rule_name): - visitor.for_second_pass.append((self.rule_name, result)) - - return result - - elif visitor.defaults: - # If default actions are enabled - return visitor.visit__default__(self, children) - - -class Terminal(ParseTreeNode): - """ - Leaf node of the Parse Tree. Represents matched string. - - Attributes: - rule (ParsingExpression): The rule that created this terminal. - position (int): A position in the input stream where match occurred. - value (str): Matched string at the given position or missing token - name in the case of an error node. - suppress(bool): If True this terminal can be ignored in semantic - analysis. - """ - - __slots__ = ['rule', 'rule_name', 'position', 'error', 'comments', - 'value', 'suppress'] - - def __init__(self, rule, position, value, error=False, suppress=False): - super(Terminal, self).__init__(rule, position, error) - self.value = value - self.suppress = suppress - - @property - def desc(self): - if self.value: - return "%s '%s' [%s]" % (self.rule_name, self.value, self.position) - else: - return "%s [%s]" % (self.rule_name, self.position) - - def flat_str(self): - return self.value - - def __str__(self): - return self.value - - def __unicode__(self): - return self.__str__() - - def __repr__(self): - return self.desc - - def __eq__(self, other): - return text(self) == text(other) - - -class NonTerminal(ParseTreeNode, list): - """ - Non-leaf node of the Parse Tree. Represents language syntax construction. - At the same time used in ParseTreeNode navigation expressions. - See test_ptnode_navigation_expressions.py for examples of navigation - expressions. - - Attributes: - nodes (list of ParseTreeNode): Children parse tree nodes. - _filtered (bool): Is this NT a dynamically created filtered NT. - This is used internally. - - """ - - __slots__ = ['rule', 'rule_name', 'position', 'error', 'comments', - '_filtered', '_expr_cache'] - - def __init__(self, rule, nodes, error=False, _filtered=False): - - # Inherit position from the first child node - position = nodes[0].position - - super(NonTerminal, self).__init__(rule, position, error) - - self.extend(flatten([nodes])) - self._filtered = _filtered - - @property - def value(self): - """Terminal protocol.""" - return text(self) - - @property - def desc(self): - return self.name - - def flat_str(self): - """ - Return flatten string representation. - """ - return "".join([x.flat_str() for x in self]) - - def __str__(self): - return " | ".join([text(x) for x in self]) - - def __unicode__(self): - return self.__str__() - - def __repr__(self): - return "[ %s ]" % ", ".join([repr(x) for x in self]) - - def __getattr__(self, rule_name): - """ - Find a child (non)terminal by the rule name. - - Args: - rule_name(str): The name of the rule that is referenced from - this node rule. - """ - # Prevent infinite recursion - if rule_name in ['_expr_cache', '_filtered', 'rule', 'rule_name', - 'position', 'append', 'extend']: - raise AttributeError - - try: - # First check the cache - if rule_name in self._expr_cache: - return self._expr_cache[rule_name] - except AttributeError: - # Navigation expression cache. Used for lookup by rule name. - self._expr_cache = {} - - # If result is not found in the cache collect all nodes - # with the given rule name and create new NonTerminal - # and cache it for later access. - nodes = [] - rule = None - for n in self: - if self._filtered: - # For filtered NT rule_name is a rule on - # each of its children - for m in n: - if m.rule_name == rule_name: - nodes.append(m) - rule = m.rule - else: - if n.rule_name == rule_name: - nodes.append(n) - rule = n.rule - - result = NonTerminal(rule=rule, nodes=nodes, _filtered=True) - self._expr_cache[rule_name] = result - return result - - -# ---------------------------------------------------- -# Semantic Actions -# -class PTNodeVisitor(DebugPrinter): - """ - Base class for all parse tree visitors. - """ - def __init__(self, defaults=True, **kwargs): - """ - Args: - defaults(bool): If the default visit method should be applied in - case no method is defined. - """ - self.for_second_pass = [] - self.defaults = defaults - - super(PTNodeVisitor, self).__init__(**kwargs) - - def visit__default__(self, node, children): - """ - Called if no visit method is defined for the node. - - Args: - node(ParseTreeNode): - children(processed children ParseTreeNode-s): - """ - if isinstance(node, Terminal): - # Default for Terminal is to convert to string unless suppress flag - # is set in which case it is suppressed by setting to None. - retval = text(node) if not node.suppress else None - else: - retval = node - # Special case. If only one child exist return it. - if len(children) == 1: - retval = children[0] - else: - # If there is only one non-string child return - # that by default. This will support e.g. bracket - # removals. - last_non_str = None - for c in children: - if not isstr(c): - if last_non_str is None: - last_non_str = c - else: - # If there is multiple non-string objects - # by default convert non-terminal to string - if self.debug: - self.dprint("*** Warning: Multiple " - "non-string objects found in " - "default visit. Converting non-" - "terminal to a string.") - retval = text(node) - break - else: - # Return the only non-string child - retval = last_non_str - - return retval - - -def visit_parse_tree(parse_tree, visitor): - """ - Applies visitor to parse_tree and runs the second pass - afterwards. - - Args: - parse_tree(ParseTreeNode): - visitor(PTNodeVisitor): - """ - if not parse_tree: - raise Exception( - "Parse tree is empty. You did call parse(), didn't you?") - - if visitor.debug: - visitor.dprint("ASG: First pass") - - # Visit tree. - result = parse_tree.visit(visitor) - - # Second pass - if visitor.debug: - visitor.dprint("ASG: Second pass") - for sa_name, asg_node in visitor.for_second_pass: - getattr(visitor, "second_%s" % sa_name)(asg_node) - - return result - - -class SemanticAction(object): - """ - Semantic actions are executed during semantic analysis. They are in charge - of producing Abstract Semantic Graph (ASG) out of the parse tree. - Every non-terminal and terminal can have semantic action defined which will - be triggered during semantic analysis. - Semantic action triggering is separated in two passes. first_pass method is - required and the method called second_pass is optional and will be called - if exists after the first pass. Second pass can be used for forward - referencing, e.g. linking to the declaration registered in the first pass - stage. - """ - def first_pass(self, parser, node, nodes): - """ - Called in the first pass of tree walk. - This is the default implementation used if no semantic action is - defined. - """ - if isinstance(node, Terminal): - # Default for Terminal is to convert to string unless suppress flag - # is set in which case it is suppressed by setting to None. - retval = text(node) if not node.suppress else None - else: - retval = node - # Special case. If only one child exist return it. - if len(nodes) == 1: - retval = nodes[0] - else: - # If there is only one non-string child return - # that by default. This will support e.g. bracket - # removals. - last_non_str = None - for c in nodes: - if not isstr(c): - if last_non_str is None: - last_non_str = c - else: - # If there is multiple non-string objects - # by default convert non-terminal to string - if parser.debug: - parser.dprint( - "*** Warning: Multiple non-" - "string objects found in applying " - "default semantic action. Converting " - "non-terminal to string.") - retval = text(node) - break - else: - # Return the only non-string child - retval = last_non_str - - return retval - - -class SemanticActionResults(list): - """ - Used in visitor methods call to supply results of semantic analysis - of children parse tree nodes. - Enables dot access by the name of the rule similar to NonTerminal - tree navigation. - Enables index access as well as iteration. - """ - def __init__(self): - self.results = {} - - def append_result(self, name, result): - if name: - if name not in self.results: - self.results[name] = [] - self.results[name].append(result) - - self.append(result) - - def __getattr__(self, attr_name): - if attr_name == 'results': - raise AttributeError - - return self.results.get(attr_name, []) - - -# Common semantic actions -class SemanticActionSingleChild(SemanticAction): - def first_pass(self, parser, node, children): - return children[0] - - -class SemanticActionBodyWithBraces(SemanticAction): - def first_pass(self, parser, node, children): - return children[1:-1] - - -class SemanticActionToString(SemanticAction): - def first_pass(self, parser, node, children): - return text(node) - -# ---------------------------------------------------- -# Parsers - - -class Parser(DebugPrinter): - """ - Abstract base class for all parsers. - - Attributes: - comments_model: parser model for comments. - comments(list): A list of ParseTreeNode for matched comments. - sem_actions(dict): A dictionary of semantic actions keyed by the - rule name. - parse_tree(NonTerminal): The parse tree consisting of NonTerminal and - Terminal instances. - in_rule (str): Current rule name. - in_parse_comments (bool): True if parsing comments. - in_optional (bool): True if parsing optionals (Optional, ZeroOrMore or - OneOrMore after first). - in_lex_rule (bool): True if in lexical rule. Currently used in Combine - decorator to convert match to a single Terminal. - last_pexpression (ParsingExpression): Last parsing expression traversed. - """ - def __init__(self, skipws=True, ws=None, reduce_tree=False, - autokwd=False, ignore_case=False, memoization=False, **kwargs): - """ - Args: - skipws (bool): Should the whitespace skipping be done. Default is - True. - ws (str): A string consisting of whitespace characters. - reduce_tree (bool): If true non-terminals with single child will be - eliminated from the parse tree. Default is False. - autokwd(bool): If keyword-like StrMatches are matched on word - boundaries. Default is False. - ignore_case(bool): If case is ignored (default=False) - memoization(bool): If memoization should be used - (a.k.a. packrat parsing) - """ - - super(Parser, self).__init__(**kwargs) - - # Used to indicate state in which parser should not - # treat newlines as whitespaces. - self._eolterm = False - - self.skipws = skipws - if ws is not None: - self.ws = ws - else: - self.ws = DEFAULT_WS - - self.reduce_tree = reduce_tree - self.autokwd = autokwd - self.ignore_case = ignore_case - self.memoization = memoization - self.comments_model = None - self.comments = [] - self.comment_positions = {} - self.sem_actions = {} - - self.parse_tree = None - - # Create regex used for autokwd matching - flags = 0 - if ignore_case: - flags = re.IGNORECASE - self.keyword_regex = re.compile(r'[^\d\W]\w*', flags) - - # Keep track of root rule we are currently in. - # Used for debugging purposes - self.in_rule = '' - - self.in_parse_comments = False - - # If under optional PE (Optional or ZeroOrMore or OneOrMore after - # first occurence) we do not store NoMatch for error reporting. - self.in_optional = False - - # Are we in lexical rule. If so do not - # skip whitespaces. - self.in_lex_rule = False - - # Last parsing expression traversed - self.last_pexpression = None - - @property - def ws(self): - return self._ws - - @ws.setter - def ws(self, new_value): - self._real_ws = new_value - self._ws = new_value - if self.eolterm: - self._ws = self._ws.replace('\n', '').replace('\r', '') - - @property - def eolterm(self): - return self._eolterm - - @eolterm.setter - def eolterm(self, new_value): - # Toggle newline char in ws on eolterm property set. - # During eolterm state parser should not treat - # newline as a whitespace. - self._eolterm = new_value - if self._eolterm: - self._ws = self._ws.replace('\n', '').replace('\r', '') - else: - self._ws = self._real_ws - - def parse(self, _input, file_name=None): - """ - Parses input and produces parse tree. - - Args: - _input(str): An input string to parse. - file_name(str): If input is loaded from file this can be - set to file name. It is used in error messages. - """ - self.position = 0 # Input position - self.nm = None # Last NoMatch exception - self.line_ends = [] - self.input = _input - self.file_name = file_name - self.comment_positions = {} - self.cache_hits = 0 - self.cache_misses = 0 - try: - self.parse_tree = self._parse() - finally: - # At end of parsing clear all memoization caches. - # Do this here to free memory. - if self.memoization: - self._clear_caches() - - # In debug mode export parse tree to dot file for - # visualization - if self.debug: - from arpeggio.export import PTDOTExporter - root_rule_name = self.parse_tree.rule_name - PTDOTExporter().exportFile( - self.parse_tree, "{}_parse_tree.dot".format(root_rule_name)) - return self.parse_tree - - def parse_file(self, file_name): - """ - Parses content from the given file. - Args: - file_name(str): A file name. - """ - with codecs.open(file_name, 'r', 'utf-8') as f: - content = f.read() - - return self.parse(content, file_name=file_name) - - def getASG(self, sem_actions=None, defaults=True): - """ - Creates Abstract Semantic Graph (ASG) from the parse tree. - - Args: - sem_actions (dict): The semantic actions dictionary to use for - semantic analysis. Rule names are the keys and semantic action - objects are values. - defaults (bool): If True a default semantic action will be - applied in case no action is defined for the node. - """ - if not self.parse_tree: - raise Exception( - "Parse tree is empty. You did call parse(), didn't you?") - - if sem_actions is None: - if not self.sem_actions: - raise Exception("Semantic actions not defined.") - else: - sem_actions = self.sem_actions - - if type(sem_actions) is not dict: - raise Exception("Semantic actions parameter must be a dictionary.") - - for_second_pass = [] - - def tree_walk(node): - """ - Walking the parse tree and calling first_pass for every registered - semantic actions and creating list of object that needs to be - called in the second pass. - """ - - if self.debug: - self.dprint( - "Walking down %s type: %s str: %s" % - (node.name, type(node).__name__, text(node))) - - children = SemanticActionResults() - if isinstance(node, NonTerminal): - for n in node: - child = tree_walk(n) - if child is not None: - children.append_result(n.rule_name, child) - - if self.debug: - self.dprint("Processing %s = '%s' type:%s len:%d" % - (node.name, text(node), type(node).__name__, - len(node) if isinstance(node, list) else 0)) - for i, a in enumerate(children): - self.dprint(" %d:%s type:%s" % - (i+1, text(a), type(a).__name__)) - - if node.rule_name in sem_actions: - sem_action = sem_actions[node.rule_name] - if isinstance(sem_action, types.FunctionType): - retval = sem_action(self, node, children) - else: - retval = sem_action.first_pass(self, node, children) - - if hasattr(sem_action, "second_pass"): - for_second_pass.append((node.rule_name, retval)) - - if self.debug: - action_name = sem_action.__name__ \ - if hasattr(sem_action, '__name__') \ - else sem_action.__class__.__name__ - self.dprint(" Applying semantic action %s" % action_name) - - else: - if defaults: - # If no rule is present use some sane defaults - if self.debug: - self.dprint(" Applying default semantic action.") - - retval = SemanticAction().first_pass(self, node, children) - - else: - retval = node - - if self.debug: - if retval is None: - self.dprint(" Suppressed.") - else: - self.dprint(" Resolved to = %s type:%s" % - (text(retval), type(retval).__name__)) - return retval - - if self.debug: - self.dprint("ASG: First pass") - asg = tree_walk(self.parse_tree) - - # Second pass - if self.debug: - self.dprint("ASG: Second pass") - for sa_name, asg_node in for_second_pass: - sem_actions[sa_name].second_pass(self, asg_node) - - return asg - - def pos_to_linecol(self, pos): - """ - Calculate (line, column) tuple for the given position in the stream. - """ - if not self.line_ends: - try: - # TODO: Check this implementation on Windows. - self.line_ends.append(self.input.index("\n")) - while True: - try: - self.line_ends.append( - self.input.index("\n", self.line_ends[-1] + 1)) - except ValueError: - break - except ValueError: - pass - - line = bisect.bisect_left(self.line_ends, pos) - col = pos - if line > 0: - col -= self.line_ends[line - 1] - if self.input[self.line_ends[line - 1]] in '\n\r': - col -= 1 - return line + 1, col + 1 - - def context(self, length=None, position=None): - """ - Returns current context substring, i.e. the substring around current - position. - Args: - length(int): If given used to mark with asterisk a length chars - from the current position. - position(int): The position in the input stream. - """ - if not position: - position = self.position - if length: - retval = "{}*{}*{}".format( - text(self.input[max(position - 10, 0):position]), - text(self.input[position:position + length]), - text(self.input[position + length:position + 10])) - else: - retval = "{}*{}".format( - text(self.input[max(position - 10, 0):position]), - text(self.input[position:position + 10])) - - return retval.replace('\n', ' ').replace('\r', '') - - def _skip_ws(self): - """ - Skiping whitespace characters. - """ - pos = self.position - ws = self.ws - while pos < len(self.input) and \ - self.input[pos] in ws: - pos += 1 - self.position = pos - - def _nm_raise(self, *args): - """ - Register new NoMatch object if the input is consumed - from the last NoMatch and raise last NoMatch. - - Args: - args: A NoMatch instance or (value, position, parser) - """ - - if len(args) == 1: - exc = args[0] - if exc.position > self.nm.position: - self.nm = exc - else: - rule, position, parser = args - if self.nm is None or not parser.in_parse_comments: - if not self.nm or position > self.nm.position: - self.nm = NoMatch([rule], position, parser) - elif position == self.nm.position and isinstance(rule, Match): - self.nm.rules.append(rule) - - raise self.nm - - def _clear_caches(self): - """ - Clear memoization caches if packrat parser is used. - """ - self.parser_model._clear_cache() - if self.comments_model: - self.comments_model._clear_cache() - - -class CrossRef(object): - ''' - Used for rule reference resolving. - ''' - def __init__(self, target_rule_name, position=-1): - self.target_rule_name = target_rule_name - self.position = position - - -class ParserPython(Parser): - - def __init__(self, language_def, comment_def=None, *args, **kwargs): - """ - Constructs parser from python statements and expressions. - - Args: - language_def (python function): A python function that defines - the root rule of the grammar. - comment_def (python function): A python function that defines - the root rule of the comments grammar. - """ - super(ParserPython, self).__init__(*args, **kwargs) - - # PEG Abstract Syntax Graph - self.parser_model = self._from_python(language_def) - - self.comments_model = None - if comment_def: - self.comments_model = self._from_python(comment_def) - self.comments_model.root = True - self.comments_model.rule_name = comment_def.__name__ - - # In debug mode export parser model to dot for - # visualization - if self.debug: - from arpeggio.export import PMDOTExporter - root_rule = language_def.__name__ - PMDOTExporter().exportFile(self.parser_model, - "{}_parser_model.dot".format(root_rule)) - - def _parse(self): - return self.parser_model.parse(self) - - def _from_python(self, expression): - """ - Create parser model from the definition given in the form of python - functions returning lists, tuples, callables, strings and - ParsingExpression objects. - - Returns: - Parser Model (PEG Abstract Semantic Graph) - """ - __rule_cache = {"EndOfFile": EndOfFile()} - __for_resolving = [] # Expressions that needs crossref resolvnih - self.__cross_refs = 0 - - def inner_from_python(expression): - retval = None - if isinstance(expression, types.FunctionType): - # If this expression is a parser rule - rule_name = expression.__name__ - if rule_name in __rule_cache: - c_rule = __rule_cache.get(rule_name) - if self.debug: - self.dprint("Rule {} founded in cache." - .format(rule_name)) - if isinstance(c_rule, CrossRef): - self.__cross_refs += 1 - if self.debug: - self.dprint("CrossRef usage: {}" - .format(c_rule.target_rule_name)) - return c_rule - - # Semantic action for the rule - if hasattr(expression, "sem"): - self.sem_actions[rule_name] = expression.sem - - # Register rule cross-ref to support recursion - __rule_cache[rule_name] = CrossRef(rule_name) - - curr_expr = expression - while isinstance(curr_expr, types.FunctionType): - # If function directly returns another function - # go into until non-function is returned. - curr_expr = curr_expr() - retval = inner_from_python(curr_expr) - retval.rule_name = rule_name - retval.root = True - - # Update cache - __rule_cache[rule_name] = retval - if self.debug: - self.dprint("New rule: {} -> {}" - .format(rule_name, retval.__class__.__name__)) - - elif type(expression) is text or isinstance(expression, StrMatch): - if type(expression) is text: - retval = StrMatch(expression, ignore_case=self.ignore_case) - else: - retval = expression - if expression.ignore_case is None: - expression.ignore_case = self.ignore_case - - if self.autokwd: - to_match = retval.to_match - match = self.keyword_regex.match(to_match) - if match and match.span() == (0, len(to_match)): - retval = RegExMatch(r'{}\b'.format(to_match), - ignore_case=self.ignore_case, - str_repr=to_match) - retval.compile() - - elif isinstance(expression, RegExMatch): - # Regular expression are not compiled yet - # to support global settings propagation from - # parser. - if expression.ignore_case is None: - expression.ignore_case = self.ignore_case - expression.compile() - - retval = expression - - elif isinstance(expression, Match): - retval = expression - - elif isinstance(expression, Sequence) or \ - isinstance(expression, Repetition) or \ - isinstance(expression, SyntaxPredicate) or \ - isinstance(expression, Decorator): - retval = expression - retval.nodes.append(inner_from_python(retval.elements)) - if any((isinstance(x, CrossRef) for x in retval.nodes)): - __for_resolving.append(retval) - - elif type(expression) in [list, tuple]: - if type(expression) is list: - retval = OrderedChoice(expression) - else: - retval = Sequence(expression) - - retval.nodes = [inner_from_python(e) for e in expression] - if any((isinstance(x, CrossRef) for x in retval.nodes)): - __for_resolving.append(retval) - - else: - raise GrammarError("Unrecognized grammar element '%s'." % - text(expression)) - - return retval - - # Cross-ref resolving - def resolve(): - for e in __for_resolving: - for i, node in enumerate(e.nodes): - if isinstance(node, CrossRef): - self.__cross_refs -= 1 - e.nodes[i] = __rule_cache[node.target_rule_name] - - parser_model = inner_from_python(expression) - resolve() - assert self.__cross_refs == 0, "Not all crossrefs are resolved!" - return parser_model - - def errors(self): - pass diff --git a/GraphLayoutDSL/target/classes/modules/arpeggio/cleanpeg.py b/GraphLayoutDSL/target/classes/modules/arpeggio/cleanpeg.py deleted file mode 100644 index 1283064..0000000 --- a/GraphLayoutDSL/target/classes/modules/arpeggio/cleanpeg.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- -####################################################################### -# Name: cleanpeg.py -# Purpose: This module is a variation of the original peg.py. -# The syntax is slightly changed to be more readable and familiar to -# python users. It is based on the Yash's suggestion - issue 11 -# Author: Igor R. Dejanovic -# Copyright: (c) 2014 Igor R. Dejanovic -# License: MIT License -####################################################################### - -from __future__ import print_function, unicode_literals - -from arpeggio import * -from arpeggio import RegExMatch as _ -from .peg import PEGVisitor -from .peg import ParserPEG as ParserPEGOrig - -__all__ = ['ParserPEG'] - - -# PEG syntax rules -def peggrammar(): return OneOrMore(rule), EOF -def rule(): return rule_name, ASSIGNMENT, ordered_choice -def ordered_choice(): return sequence, ZeroOrMore(SLASH, sequence) -def sequence(): return OneOrMore(prefix) -def prefix(): return Optional([AND,NOT]), sufix -def sufix(): return expression, Optional([QUESTION, STAR, PLUS]) -def expression(): return [regex, rule_crossref, - (OPEN, ordered_choice, CLOSE), - str_match], Not(ASSIGNMENT) - -# PEG Lexical rules -def ASSIGNMENT(): return "=" -def SLASH(): return "/" -def STAR(): return "*" -def QUESTION(): return "?" -def PLUS(): return "+" -def AND(): return "&" -def NOT(): return "!" -def OPEN(): return "(" -def CLOSE(): return ")" -def regex(): return "r'", _(r"(\\\'|[^\'])*"),"'" -def rule_name(): return _(r"[a-zA-Z_]([a-zA-Z_]|[0-9])*") -def rule_crossref(): return rule_name -#def literal(): return [_(r"\'(\\\'|[^\'])*\'"),_(r'"[^"]*"')] -def str_match(): return _(r'(\'(\\\'|[^\'])*\')|("[^"]*")') -def comment(): return _("#.*\n") - - -class ParserPEG(ParserPEGOrig): - - def _from_peg(self, language_def): - parser = ParserPython(peggrammar, comment, reduce_tree=False, - debug=self.debug) - parser.root_rule_name = self.root_rule_name - parse_tree = parser.parse(language_def) - - return visit_parse_tree(parse_tree, PEGVisitor(self.root_rule_name, - self.comment_rule_name, - self.ignore_case, - debug=self.debug)) diff --git a/GraphLayoutDSL/target/classes/modules/arpeggio/export.py b/GraphLayoutDSL/target/classes/modules/arpeggio/export.py deleted file mode 100644 index 5b92784..0000000 --- a/GraphLayoutDSL/target/classes/modules/arpeggio/export.py +++ /dev/null @@ -1,221 +0,0 @@ -# -*- coding: utf-8 -*- -####################################################################### -# Name: export.py -# Purpose: Export support for arpeggio -# Author: Igor R. Dejanović -# Copyright: (c) 2009 Igor R. Dejanović -# License: MIT License -####################################################################### - -from __future__ import unicode_literals -import io -from arpeggio import Terminal - - -class Exporter(object): - """ - Base class for all Exporters. - """ - - def __init__(self): - super(Exporter, self).__init__() - - # Export initialization - self._render_set = set() # Used in rendering to prevent - # rendering - # of the same node multiple times - - self._adapter_map = {} # Used as a registry of adapters to - # ensure that the same adapter is - # returned for the same adaptee object - - def export(self, obj): - """ - Export of an obj to a string. - """ - self._outf = io.StringIO() - self._export(obj) - content = self._outf.getvalue() - self._outf.close() - return content - - def exportFile(self, obj, file_name): - """ - Export of obj to a file. - """ - self._outf = io.open(file_name, "w", encoding="utf-8") - self._export(obj) - self._outf.close() - - def _export(self, obj): - self._outf.write(self._start()) - self._render_node(obj) - self._outf.write(self._end()) - - def _start(self): - """ - Override this to specify the beginning of the graph representation. - """ - return "" - - def _end(self): - """ - Override this to specify the end of the graph representation. - """ - return "" - - -class ExportAdapter(object): - """ - Base adapter class for the export support. - Adapter should be defined for every export and graph type. - - Attributes: - adaptee: A node to adapt. - export: An export object used as a context of the export. - """ - def __init__(self, node, export): - self.adaptee = node # adaptee is adapted graph node - self.export = export - - -# ------------------------------------------------------------------------- -# Support for DOT language - - -class DOTExportAdapter(ExportAdapter): - """ - Base adapter class for the DOT export support. - """ - @property - def id(self): - """ - Graph node unique identification. - """ - raise NotImplementedError() - - @property - def desc(self): - """ - Graph node textual description. - """ - raise NotImplementedError() - - @property - def neighbours(self): - """ - A set of adjacent graph nodes. - """ - raise NotImplementedError() - - -class PMDOTExportAdapter(DOTExportAdapter): - """ - Adapter for ParsingExpression graph types (parser model). - """ - @property - def id(self): - return id(self.adaptee) - - @property - def desc(self): - return self.adaptee.desc - - @property - def neighbours(self): - if not hasattr(self, "_neighbours"): - self._neighbours= [] - - # Registry of adapters used in this export - adapter_map = self.export._adapter_map - - for c, n in enumerate(self.adaptee.nodes): - if isinstance(n, PMDOTExportAdapter): - # if the neighbour node is already adapted use that adapter - self._neighbours.append((str(c + 1), n)) - elif id(n) in adapter_map: - # current node is adaptee -> there is registered adapter - self._neighbours.append((str(c + 1), adapter_map[id(n)])) - else: - # Create new adapter - adapter = PMDOTExportAdapter(n, self.export) - self._neighbours.append((str(c + 1), adapter)) - adapter_map[adapter.id] = adapter - - return self._neighbours - - -class PTDOTExportAdapter(PMDOTExportAdapter): - """ - Adapter for ParseTreeNode graph types. - """ - @property - def neighbours(self): - if isinstance(self.adaptee, Terminal): - return [] - else: - if not hasattr(self, "_neighbours"): - self._neighbours = [] - for c, n in enumerate(self.adaptee): - adapter = PTDOTExportAdapter(n, self.export) - self._neighbours.append((str(c + 1), adapter)) - return self._neighbours - - -class DOTExporter(Exporter): - """ - Export to DOT language (part of GraphViz, see http://www.graphviz.org/) - """ - def _render_node(self, node): - if not node in self._render_set: - self._render_set.add(node) - self._outf.write('\n%s [label="%s"];' % - (node.id, self._dot_label_esc(node.desc))) - #TODO Comment handling -# if hasattr(node, "comments") and root.comments: -# retval += self.node(root.comments) -# retval += '\n%s->%s [label="comment"]' % \ - #(id(root), id(root.comments)) - for name, n in node.neighbours: - self._outf.write('\n%s->%s [label="%s"]' % - (node.id, n.id, name)) - self._outf.write('\n') - self._render_node(n) - - def _start(self): - return "digraph arpeggio_graph {" - - def _end(self): - return "\n}" - - def _dot_label_esc(self, to_esc): - to_esc = to_esc.replace("\\", "\\\\") - to_esc = to_esc.replace('\"', '\\"') - to_esc = to_esc.replace('\n', '\\n') - return to_esc - - -class PMDOTExporter(DOTExporter): - """ - A convenience DOTExport extension that uses ParserExpressionDOTExportAdapter - """ - def export(self, obj): - return super(PMDOTExporter, self).\ - export(PMDOTExportAdapter(obj, self)) - - def exportFile(self, obj, file_name): - return super(PMDOTExporter, self).\ - exportFile(PMDOTExportAdapter(obj, self), file_name) - - -class PTDOTExporter(DOTExporter): - """ - A convenience DOTExport extension that uses PTDOTExportAdapter - """ - def export(self, obj): - return super(PTDOTExporter, self).\ - export(PTDOTExportAdapter(obj, self)) - - def exportFile(self, obj, file_name): - return super(PTDOTExporter, self).\ - exportFile(PTDOTExportAdapter(obj, self), file_name) diff --git a/GraphLayoutDSL/target/classes/modules/arpeggio/peg.py b/GraphLayoutDSL/target/classes/modules/arpeggio/peg.py deleted file mode 100644 index ae00a23..0000000 --- a/GraphLayoutDSL/target/classes/modules/arpeggio/peg.py +++ /dev/null @@ -1,258 +0,0 @@ -# -*- coding: utf-8 -*- -####################################################################### -# Name: peg.py -# Purpose: Implementing PEG language -# Author: Igor R. Dejanovic -# Copyright: (c) 2009-2014 Igor R. Dejanovic -# License: MIT License -####################################################################### - -from __future__ import print_function, unicode_literals -import sys -if sys.version < '3': - text = unicode -else: - text = str - -import copy -from arpeggio import * -from arpeggio import RegExMatch as _ - -__all__ = ['ParserPEG'] - - -# PEG syntax rules -def peggrammar(): return OneOrMore(rule), EOF -def rule(): return rule_name, LEFT_ARROW, ordered_choice, ";" -def ordered_choice(): return sequence, ZeroOrMore(SLASH, sequence) -def sequence(): return OneOrMore(prefix) -def prefix(): return Optional([AND,NOT]), sufix -def sufix(): return expression, Optional([QUESTION, STAR, PLUS]) -def expression(): return [regex, rule_crossref, - (OPEN, ordered_choice, CLOSE), - str_match] - -# PEG Lexical rules -def LEFT_ARROW(): return "<-" -def SLASH(): return "/" -def STAR(): return "*" -def QUESTION(): return "?" -def PLUS(): return "+" -def AND(): return "&" -def NOT(): return "!" -def OPEN(): return "(" -def CLOSE(): return ")" -def regex(): return "r'", _(r"(\\\'|[^\'])*"),"'" -def rule_name(): return _(r"[a-zA-Z_]([a-zA-Z_]|[0-9])*") -def rule_crossref(): return rule_name -#def literal(): return [_(r"\'(\\\'|[^\'])*\'"),_(r'"[^"]*"')] -def str_match(): return _(r'(\'(\\\'|[^\'])*\')|("[^"]*")') -def comment(): return "//", _(".*\n") - - -class PEGVisitor(PTNodeVisitor): - """ - Visitor that transforms parse tree to a PEG parser for the given language. - """ - - def __init__(self, root_rule_name, comment_rule_name, ignore_case, - *args, **kwargs): - super(PEGVisitor, self).__init__(*args, **kwargs) - self.root_rule_name = root_rule_name - self.comment_rule_name = comment_rule_name - self.ignore_case = ignore_case - # Used for linking phase - self.peg_rules = { - "EOF": EndOfFile() - } - - def visit_peggrammar(self, node, children): - - def _resolve(node): - """ - Resolves CrossRefs from the parser model. - """ - - if node in self.resolved: - return node - self.resolved.add(node) - - def get_rule_by_name(rule_name): - try: - return self.peg_rules[rule_name] - except KeyError: - raise SemanticError("Rule \"{}\" does not exists." - .format(rule_name)) - - def resolve_rule_by_name(rule_name): - - if self.debug: - self.dprint("Resolving crossref {}".format(rule_name)) - - resolved_rule = get_rule_by_name(rule_name) - while type(resolved_rule) is CrossRef: - target_rule = resolved_rule.target_rule_name - resolved_rule = get_rule_by_name(target_rule) - - # If resolved rule hasn't got the same name it - # should be cloned and preserved in the peg_rules cache - if resolved_rule.rule_name != rule_name: - resolved_rule = copy.copy(resolved_rule) - resolved_rule.rule_name = rule_name - self.peg_rules[rule_name] = resolved_rule - if self.debug: - self.dprint("Resolving: cloned to {} = > {}" - .format(resolved_rule.rule_name, - resolved_rule.name)) - return resolved_rule - - if isinstance(node, CrossRef): - # The root rule is a cross-ref - resolved_rule = resolve_rule_by_name(node.target_rule_name) - return _resolve(resolved_rule) - else: - # Resolve children nodes - for i, n in enumerate(node.nodes): - node.nodes[i] = _resolve(n) - self.resolved.add(node) - return node - - # Find root and comment rules - self.resolved = set() - comment_rule = None - for rule in children: - if rule.rule_name == self.root_rule_name: - root_rule = _resolve(rule) - if rule.rule_name == self.comment_rule_name: - comment_rule = _resolve(rule) - - assert root_rule, "Root rule not found!" - return root_rule, comment_rule - - def visit_rule(self, node, children): - rule_name = children[0] - if len(children) > 2: - retval = Sequence(nodes=children[1:]) - else: - retval = children[1] - - retval.rule_name = rule_name - retval.root = True - - # Keep a map of parser rules for cross reference - # resolving. - self.peg_rules[rule_name] = retval - return retval - - def visit_sequence(self, node, children): - if len(children) > 1: - return Sequence(nodes=children[:]) - else: - # If only one child rule exists reduce. - return children[0] - - def visit_ordered_choice(self, node, children): - if len(children) > 1: - retval = OrderedChoice(nodes=children[:]) - else: - # If only one child rule exists reduce. - retval = children[0] - return retval - - def visit_prefix(self, node, children): - if len(children) == 2: - if children[0] == NOT(): - retval = Not() - else: - retval = And() - if type(children[1]) is list: - retval.nodes = children[1] - else: - retval.nodes = [children[1]] - else: - # If there is no optional prefix reduce. - retval = children[0] - - return retval - - def visit_sufix(self, node, children): - if len(children) == 2: - if children[1] == STAR(): - retval = ZeroOrMore(children[0]) - elif children[1] == QUESTION(): - retval = Optional(children[0]) - else: - retval = OneOrMore(children[0]) - if type(children[0]) is list: - retval.nodes = children[0] - else: - retval.nodes = [children[0]] - else: - retval = children[0] - - return retval - - def visit_rule_crossref(self, node, children): - return CrossRef(node.value) - - def visit_regex(self, node, children): - match = RegExMatch(children[0], - ignore_case=self.ignore_case) - match.compile() - return match - - def visit_str_match(self, node, children): - match_str = node.value[1:-1] - match_str = match_str.replace("\\'", "'")\ - .replace("\\\\", "\\")\ - .replace("\\n", "\n")\ - .replace("\\t", "\t") - match_str - return StrMatch(match_str, ignore_case=self.ignore_case) - - -class ParserPEG(Parser): - - def __init__(self, language_def, root_rule_name, comment_rule_name=None, - *args, **kwargs): - """ - Constructs parser from textual PEG definition. - - Args: - language_def (str): A string describing language grammar using - PEG notation. - root_rule_name(str): The name of the root rule. - comment_rule_name(str): The name of the rule for comments. - """ - super(ParserPEG, self).__init__(*args, **kwargs) - self.root_rule_name = root_rule_name - self.comment_rule_name = comment_rule_name - - # PEG Abstract Syntax Graph - self.parser_model, self.comments_model = self._from_peg(language_def) - # Comments should be optional and there can be more of them - if self.comments_model: - self.comments_model.root = True - self.comments_model.rule_name = comment_rule_name - - # In debug mode export parser model to dot for - # visualization - if self.debug: - from arpeggio.export import PMDOTExporter - root_rule = self.parser_model.rule_name - PMDOTExporter().exportFile( - self.parser_model, "{}_peg_parser_model.dot".format(root_rule)) - - def _parse(self): - return self.parser_model.parse(self) - - def _from_peg(self, language_def): - parser = ParserPython(peggrammar, comment, reduce_tree=False, - debug=self.debug) - parser.root_rule_name = self.root_rule_name - parse_tree = parser.parse(language_def) - - return visit_parse_tree(parse_tree, PEGVisitor(self.root_rule_name, - self.comment_rule_name, - self.ignore_case, - debug=self.debug)) diff --git a/GraphLayoutDSL/target/classes/modules/arpeggio/utils.py b/GraphLayoutDSL/target/classes/modules/arpeggio/utils.py deleted file mode 100644 index 93905ea..0000000 --- a/GraphLayoutDSL/target/classes/modules/arpeggio/utils.py +++ /dev/null @@ -1,14 +0,0 @@ -""" -Various utilities. -""" - -# isstr check if object is of string type. -# This works for both python 2 and 3 -# Taken from http://stackoverflow.com/questions/11301138/how-to-check-if-variable-is-string-with-python-2-and-3-compatibility -try: - basestring # attempt to evaluate basestring - def isstr(s): - return isinstance(s, basestring) -except NameError: - def isstr(s): - return isinstance(s, str) \ No newline at end of file diff --git a/GraphLayoutDSL/target/classes/modules/textx/__init__.py b/GraphLayoutDSL/target/classes/modules/textx/__init__.py deleted file mode 100644 index 8d1c8b6..0000000 --- a/GraphLayoutDSL/target/classes/modules/textx/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/GraphLayoutDSL/target/classes/modules/textx/const.py b/GraphLayoutDSL/target/classes/modules/textx/const.py deleted file mode 100644 index 835a03d..0000000 --- a/GraphLayoutDSL/target/classes/modules/textx/const.py +++ /dev/null @@ -1,14 +0,0 @@ -# Multiplicities -MULT_ONE = '1' -MULT_OPTIONAL = '0..1' -MULT_ZEROORMORE = '0..*' -MULT_ONEORMORE = '1..*' - -# Rule types -# Common rules are rules that have direct or indirect assignments. -RULE_COMMON = "common" -# If the rule is ordered choice of other rules where there *MUST BE* assignments -# down the reference tree that this rule is abstract. -RULE_ABSTRACT = "abstract" -# If there is no direct or indirect assignments the rule is match rule. -RULE_MATCH = "match" diff --git a/GraphLayoutDSL/target/classes/modules/textx/exceptions.py b/GraphLayoutDSL/target/classes/modules/textx/exceptions.py deleted file mode 100644 index ede1f39..0000000 --- a/GraphLayoutDSL/target/classes/modules/textx/exceptions.py +++ /dev/null @@ -1,15 +0,0 @@ -# TextX Exceptions -class TextXError(Exception): - def __init__(self, message, line=None, col=None): - super(TextXError, self).__init__(message) - self.line = line - self.col = col - - -class TextXSemanticError(TextXError): - pass - - -class TextXSyntaxError(TextXError): - pass - diff --git a/GraphLayoutDSL/target/classes/modules/textx/export.py b/GraphLayoutDSL/target/classes/modules/textx/export.py deleted file mode 100644 index 0a12ddc..0000000 --- a/GraphLayoutDSL/target/classes/modules/textx/export.py +++ /dev/null @@ -1,221 +0,0 @@ -# -*- coding: utf-8 -*- -####################################################################### -# Name: export.py -# Purpose: Export of textX based models and metamodels to dot file -# Author: Igor R. Dejanovic -# Copyright: (c) 2014-2016 Igor R. Dejanovic -# License: MIT License -####################################################################### -from __future__ import unicode_literals -from arpeggio import Match, OrderedChoice, Sequence, OneOrMore, ZeroOrMore,\ - Optional, SyntaxPredicate -from .const import MULT_ZEROORMORE, MULT_ONEORMORE, MULT_ONE, RULE_ABSTRACT, \ - RULE_COMMON, RULE_MATCH -from .textx import PRIMITIVE_PYTHON_TYPES, BASE_TYPE_NAMES -import codecs -import sys -if sys.version < '3': - text = unicode -else: - text = str - - -HEADER = ''' - digraph xtext { - fontname = "Bitstream Vera Sans" - fontsize = 8 - node[ - shape=record, - style=filled, - fillcolor=aliceblue - ] - nodesep = 0.3 - edge[dir=black,arrowtail=empty] - - -''' - -def match_abstract_str(cls): - """ - For a given abstract or match rule meta-class returns a nice string - representation for the body. - """ - def r(s): - if s.root: - if s in visited or s.rule_name in BASE_TYPE_NAMES or \ - (hasattr(s, '_tx_class') and - s._tx_class._tx_type is not RULE_MATCH): - return s.rule_name - - visited.add(s) - if isinstance(s, Match): - result = text(s) - elif isinstance(s, OrderedChoice): - result = "|".join([r(x) for x in s.nodes]) - elif isinstance(s, Sequence): - result = " ".join([r(x) for x in s.nodes]) - elif isinstance(s, ZeroOrMore): - result = "({})*".format(r(s.nodes[0])) - elif isinstance(s, OneOrMore): - result = "({})+".format(r(s.nodes[0])) - elif isinstance(s, Optional): - result = "{}?".format(r(s.nodes[0])) - elif isinstance(s, SyntaxPredicate): - result = "" - return "{}{}".format(result, "-" if s.suppress else "") - - mstr = "" - if cls.__name__ not in BASE_TYPE_NAMES and \ - not (cls._tx_type is RULE_ABSTRACT and - cls.__name__ != cls._tx_peg_rule.rule_name): - e = cls._tx_peg_rule - visited = set() - if not isinstance(e, Match): - visited.add(e) - if isinstance(e, OrderedChoice): - mstr = "|".join([r(x) for x in e.nodes - if x.rule_name in BASE_TYPE_NAMES or not x.root]) - elif isinstance(e, Sequence): - mstr = " ".join([r(x) for x in e.nodes]) - else: - mstr = r(e) - - mstr = dot_escape(mstr) - - return mstr - -def dot_escape(s): - return s.replace('\n', r'\n')\ - .replace('\\', '\\\\')\ - .replace('"', r'\"')\ - .replace('|', r'\|')\ - .replace('{', r'\{')\ - .replace('}', r'\}')\ - .replace('>', r'\>')\ - .replace('<', r'\<')\ - .replace('?', r'\?') - - -def dot_repr(o): - if type(o) is text: - return "'{}'".format(dot_escape(text(o))) - else: - return text(o) - - -def metamodel_export(metamodel, file_name): - - with codecs.open(file_name, 'w', encoding="utf-8") as f: - f.write(HEADER) - - for cls in metamodel: - name = cls.__name__ - attrs = "" - if cls._tx_type is not RULE_COMMON: - attrs = match_abstract_str(cls) - else: - for attr in cls._tx_attrs.values(): - arrowtail = "arrowtail=diamond, dir=both, " \ - if attr.cont else "" - mult_list = attr.mult in [MULT_ZEROORMORE, MULT_ONEORMORE] - required = "+" if attr.mult in \ - [MULT_ONE, MULT_ONEORMORE] else "" - attr_type = "list[{}]".format(attr.cls.__name__) \ - if mult_list else attr.cls.__name__ - if attr.ref: - # If attribute is a reference - mult = attr.mult if not attr.mult == MULT_ONE else "" - f.write('{} -> {}[{}headlabel="{} {}"]\n' - .format(id(cls), id(attr.cls), arrowtail, - attr.name, mult)) - else: - # If it is plain type - attrs += "{}{}:{}\\l".format(required, - attr.name, attr_type) - - f.write('{}[ label="{{{}|{}}}"]\n'.format( - id(cls), "*{}".format(name) - if cls._tx_type is RULE_ABSTRACT else name, attrs)) - - for inherited_by in cls._tx_inh_by: - f.write('{} -> {} [dir=back]\n' - .format(id(cls), id(inherited_by))) - - f.write("\n") - - f.write("\n}\n") - - -def model_export(model, file_name): - - processed_set = set() - - with codecs.open(file_name, 'w', encoding="utf-8") as f: - f.write(HEADER) - - def _export(obj): - - if obj is None or obj in processed_set or type(obj) \ - in PRIMITIVE_PYTHON_TYPES: - return - - processed_set.add(obj) - - attrs = "" - obj_cls = obj.__class__ - name = "" - for attr_name, attr in obj_cls._tx_attrs.items(): - - attr_value = getattr(obj, attr_name) - - endmark = 'arrowtail=diamond dir=both' if attr.cont else "" - required = "+" if attr.mult in \ - [MULT_ONE, MULT_ONEORMORE] else "" - - if attr.mult in [MULT_ONEORMORE, MULT_ZEROORMORE]: - if all([type(x) in PRIMITIVE_PYTHON_TYPES for x in attr_value]): - attrs += "{}{}:list=[".format(required, attr_name) - attrs += ",".join([dot_repr(x) for x in attr_value]) - attrs += "]\\l" - else: - for idx, list_obj in enumerate(attr_value): - if list_obj is not None: - if type(list_obj) in PRIMITIVE_PYTHON_TYPES: - f.write( - '{} -> "{}:{}" [label="{}:{}" {}]\n' - .format(id(obj), list_obj, - type(list_obj).__name__, - attr_name, idx, endmark)) - else: - f.write('{} -> {} [label="{}:{}" {}]\n' - .format(id(obj), id(list_obj), - attr_name, idx, endmark)) - _export(list_obj) - else: - - # Plain attributes - if type(attr_value) is text and attr_name != 'name': - attr_value = dot_repr(attr_value) - - if type(attr_value) in PRIMITIVE_PYTHON_TYPES: - if attr_name == 'name': - name = attr_value - else: - attrs += "{}{}:{}={}\\l".format( - required, attr_name, type(attr_value) - .__name__, attr_value) - else: - # Object references - if attr_value is not None: - f.write('{} -> {} [label="{}" {}]\n'.format( - id(obj), id(attr_value), - attr_name, endmark)) - _export(attr_value) - - name = "{}:{}".format(name, obj_cls.__name__) - - f.write('{}[label="{{{}|{}}}"]\n'.format(id(obj), name, attrs)) - - _export(model) - - f.write('\n}\n') diff --git a/GraphLayoutDSL/target/classes/modules/textx/metamodel.py b/GraphLayoutDSL/target/classes/modules/textx/metamodel.py deleted file mode 100644 index a20b607..0000000 --- a/GraphLayoutDSL/target/classes/modules/textx/metamodel.py +++ /dev/null @@ -1,498 +0,0 @@ -####################################################################### -# Name: metamodel.py -# Purpose: Meta-model construction. -# Author: Igor R. Dejanovic -# Copyright: (c) 2014 Igor R. Dejanovic -# License: MIT License -####################################################################### - -import codecs -import os -from collections import OrderedDict -from arpeggio import DebugPrinter -from .textx import language_from_str, python_type, BASE_TYPE_NAMES, ID, BOOL,\ - INT, FLOAT, STRING, NUMBER, BASETYPE -from .const import MULT_ONE, MULT_ZEROORMORE, MULT_ONEORMORE, RULE_MATCH - - -class MetaAttr(object): - """ - A metaclass for attribute description. - - Attributes: - name(str): Attribute name. - cls(str, TextXClass or base python type): The type of the attribute. - mult(str): Multiplicity - cont(bool): Is this attribute contained inside object. - ref(bool): Is this attribute a reference. If it is not a reference - it must be containment. - bool_assignment(bool): Is this attribute specified using bool - assignment '?='. Default is False. - position(int): A position in the input string where attribute is - defined. - """ - def __init__(self, name, cls=None, mult=MULT_ONE, cont=True, ref=False, - bool_assignment=False, position=0): - self.name = name - self.cls = cls - self.mult = mult - self.cont = cont - self.ref = ref - self.bool_assignment = bool_assignment - self.position = position - - -class TextXClass(object): - """Base class for all language classes.""" - pass - - -class TextXMetaModel(DebugPrinter): - """ - Meta-model contains all information about language abstract syntax. - Furthermore, this class is in charge for model instantiation and new - language class creation. - - Attributes: - rootcls(TextXClass): A language class that is a root of the metamodel. - namespaces(dict): A dict from abs. file name to the dict in the form - {clsname: cls} that holds meta-classes imported from the given - grammar file. Special key 'base' is used for BASETYPE classes. - None key is used for all classes imported from the grammar - given as a string. - _namespace_stack(list): A stack of namespace names (usually absolute - filenames). Used to keep track of the current namespace. - imported_namespaces(dict): A dict from namespace name to the list of - references to imported namespaces. Used in searches for the - unqualified rules. - builtins(dict): A dict of named object used in linking phase. - References to named objects not defined in the model will be - searched here. - user_classes(dict): A dict of user supplied classes to use instead of - generic ones. - obj_processors(dict): A dict of user supplied object processors. - """ - - def __init__(self, file_name=None, classes=None, builtins=None, - auto_init_attributes=True, ignore_case=False, - skipws=True, ws=None, autokwd=False, memoization=False, - **kwargs): - """ - Args: - file_name(str): A file name if meta-model is going to be - constructed from file or None otherwise. - classes(list of python classes): Custom meta-classes used - instead of generic ones. - builtins(dict of named objects): Named objects used in linking - phase. This objects are part of each model. - auto_init_attributes(bool): If set than model attributes will be - automatically initialized to non-None values (e.g. for INT - attribute value will be 0, for BOOL it will be False). If this - parameter is False than all attributes will have a value - of None if not defined in the model. The only exception is - bool assignment ('?=') which always have a default of False. - Default is True. - ignore_case(bool): If case is ignored (default=False) - skipws (bool): Should the whitespace skipping be done. - Default is True. - ws (str): A string consisting of whitespace characters. - autokwd(bool): If keyword-like matches should be matched on word - boundaries. Default is False. - memoization(bool): If memoization should be used (a.k.a. packrat - parsing). Default is False. - debug(bool): Should debug messages be printed. - """ - super(TextXMetaModel, self).__init__(**kwargs) - - self.file_name = file_name - self.rootcls = None - - self.builtins = builtins - - # Convert classes to dict for easier lookup - self.user_classes = {} - if classes: - for c in classes: - self.user_classes[c.__name__] = c - - self.auto_init_attributes = auto_init_attributes - self.ignore_case = ignore_case - self.skipws = skipws - self.ws = ws - self.autokwd = autokwd - self.memoization = memoization - - # Registered model processors - self._model_processors = [] - - # Registered object processors - self.obj_processors = {} - - # Namespaces - self.namespaces = {} - self._namespace_stack = [] - - # Imported namespaces - self.imported_namespaces = {} - - # Create new namespace for BASETYPE classes - self._enter_namespace('base') - - # Base types hierarchy should exist in each meta-model - base_id = self._new_class('ID', ID, 0) - base_string = self._new_class('STRING', STRING, 0) - base_bool = self._new_class('BOOL', BOOL, 0) - base_int = self._new_class('INT', INT, 0) - base_float = self._new_class('FLOAT', FLOAT, 0) - base_number = self._new_class('NUMBER', NUMBER, 0, - [base_float, base_int]) - self._new_class('BASETYPE', BASETYPE, 0, - [base_number, base_bool, base_id, base_string]) - - # If file_name is given its absolute path will be a namespace - if file_name: - file_name = os.path.abspath(file_name) - - # Enter namespace for given file or None if metamodel is - # constructed from string. - self._enter_namespace(file_name) - - def _enter_namespace(self, namespace_name): - """ - A namespace is usually an absolute file name of the grammar. - A special namespace 'base' is used for BASETYPE namespace. - """ - if namespace_name not in self.namespaces: - self.namespaces[namespace_name] = {} - - # BASETYPE namespace is imported in each namespace - self.imported_namespaces[namespace_name] = \ - [self.namespaces['base']] - - self._namespace_stack.append(namespace_name) - - def _leave_namespace(self): - """ - Leaves current namespace (i.e. grammar file). - """ - self._namespace_stack.pop() - - def _fqn_to_namespace(self, fqn): - """ - Based on current namespace and given fqn returns the absolute - filename of the fqn cls grammar file. - Args: - fqn(str): A fully qualified name of the class. - Returns: - An absolute file name of the grammar fqn rule/class came from. - """ - - current_namespace = self._namespace_stack[-1] - current_dir = '' - if current_namespace and current_namespace != 'base': - current_dir = os.path.dirname(current_namespace) - namespace = "%s.tx" % os.path.join(current_dir, - *(fqn.split("."))[:-1]) - - return namespace - - def _set_rule(self, name, rule): - """ - For the given rule/class name sets PEG rule. - """ - self[name]._tx_peg_rule = rule - rule._tx_class = self[name] - - def _new_import(self, import_name): - """ - Starts a new import. - Args: - import_name(str): A relative import in the dot syntax - (e.g. "first.second.expressions") - """ - - # Find the absolute file name of the import based on the relative - # import_name and current grammar file (namespace) - current_namespace = self._namespace_stack[-1] - current_dir = '' - if current_namespace and current_namespace != 'base': - current_dir = os.path.dirname(current_namespace) - import_file_name = "%s.tx" % os.path.join(current_dir, - *import_name.split(".")) - - if import_file_name not in self.namespaces: - self._enter_namespace(import_file_name) - if self.debug: - self.dprint("*** IMPORTING FILE: %s" % import_file_name) - metamodel_from_file(import_file_name, metamodel=self) - self._leave_namespace() - - # Add the import to the imported_namespaces for current namespace - # so that resolving of current grammar searches imported grammars - # in the order of import - self.imported_namespaces[current_namespace].append( - self.namespaces[import_file_name]) - - def _new_class(self, name, peg_rule, position, inherits=None, root=False, - rule_type=RULE_MATCH): - """ - Creates a new class with the given name in the current namespace. - Args: - name(str): The name of the class. - peg_rule(ParserExpression): An arpeggio peg rule used to match - this class. - positon(int): A position in the input where class is defined. - root(bool): Is this class a root class of the metamodel. - rule_type: The type of the rule this meta-class is for. One of - RULE_COMMON, RULE_ABSTRACT or RULE_MATCH. - """ - - class Meta(TextXClass): - """ - Dynamic metaclass. Each textX rule will result in creating - one Meta class with the type name of the rule. - Model is a graph of python instances of this metaclasses. - Attributes: - _tx_attrs(dict): A dict of meta-attributes keyed by name. Used by - common rules. - _tx_inh_by(list): Classes that inherits this one. Used by - abstract rules. - _tx_position(int): A position in the input string where this - class is defined. - _tx_type(int): The type of the textX rule this class is created - for. See textx.const - _tx_metamodel(TextXMetaModel): A metamodel this class belongs - to. - _tx_peg_rule(ParsingExpression): An arpeggio PEG rule that - matches this class. - """ - - def __repr__(self): - return "".format(name, hex(id(self))) - - cls = Meta - cls.__name__ = name - - self._init_class(cls, peg_rule, position, inherits, root, rule_type) - - return cls - - def _init_class(self, cls, peg_rule, position, inherits=None, root=False, - rule_type=RULE_MATCH): - """ - Setup meta-class special attributes, namespaces etc. This is called - both for textX created classes as well as user classes. - """ - cls._tx_metamodel = self - - # Attribute information (MetaAttr instances) keyed by name. - cls._tx_attrs = OrderedDict() - - # A list of inheriting classes - cls._tx_inh_by = inherits if inherits else [] - - cls._tx_position = position - - # The type of the rule this meta-class results from. - # There are three rule types: common, abstract and match - # Base types are match rules. - cls._tx_type = rule_type - - cls._tx_peg_rule = peg_rule - if peg_rule: - peg_rule._tx_class = cls - - # Push this class and PEG rule in the current namespace - current_namespace = self.namespaces[self._namespace_stack[-1]] - current_namespace[cls.__name__] = cls - - if root: - self.rootcls = cls - - def _init_obj_attrs(self, obj, user=False): - """ - Initialize obj attributes. - Args: - obj(object): A python object to set attributes to. - user(bool): If this object is a user object mangle attribute names. - """ - for attr in obj.__class__._tx_attrs.values(): - - if user: - # Mangle name to prvent name clashing - attr_name = "_txa_%s" % attr.name - else: - attr_name = attr.name - - if attr.mult in [MULT_ZEROORMORE, MULT_ONEORMORE]: - # list - setattr(obj, attr_name, []) - elif attr.cls.__name__ in BASE_TYPE_NAMES: - # Instantiate base python type - if self.auto_init_attributes: - setattr(obj, attr_name, - python_type(attr.cls.__name__)()) - else: - # See https://github.com/igordejanovic/textX/issues/11 - if attr.bool_assignment: - # Only ?= assignments shall have default - # value of False. - setattr(obj, attr_name, False) - else: - # Set base type attribute to None initially - # in order to be able to detect if an optional - # values are given in the model. Default values - # can be specified using object processors. - setattr(obj, attr_name, None) - else: - # Reference to other obj - setattr(obj, attr_name, None) - - def _new_cls_attr(self, clazz, name, cls=None, mult=MULT_ONE, cont=True, - ref=False, bool_assignment=False, position=0): - """Creates new meta attribute of this class.""" - attr = MetaAttr(name, cls, mult, cont, ref, bool_assignment, - position) - clazz._tx_attrs[name] = attr - return attr - - def validate(self): - """ - Validates metamodel. Called after construction to check for some - textX rules. - """ - # TODO: Implement complex textX validations. - - def __getitem__(self, name): - """ - Search for and return class and peg_rule with the given name. - Returns: - TextXClass, ParsingExpression - """ - if "." in name: - # Name is fully qualified - # Find the absolute file from the current namespace and - # the fully qualified name. - namespace = self._fqn_to_namespace(name) - name = name.split(".")[-1] - return self.namespaces[namespace][name] - else: - # If not fully qualified search in the current namespace - # and after that in the imported_namespaces - if name in self._current_namespace: - return self._current_namespace[name] - - for namespace in \ - self.imported_namespaces[self._namespace_stack[-1]]: - if name in namespace: - return namespace[name] - - raise KeyError("{} metaclass does not exists in the metamodel " - .format(name)) - - def __iter__(self): - """ - Iterate over all classes in the current namespace and imported - namespaces. - """ - - # Current namespace - for name in self._current_namespace: - yield self._current_namespace[name] - - # Imported namespaces - for namespace in \ - self.imported_namespaces[self._namespace_stack[-1]]: - for name in namespace: - # yield class - yield namespace[name] - - def __contains__(self, name): - """ - Check if given name is contained in the current namespace. - The name can be fully qualified. - """ - try: - self[name] - return True - except KeyError: - return False - - @property - def _current_namespace(self): - return self.namespaces[self._namespace_stack[-1]] - - def model_from_str(self, model_str, debug=None): - """ - Instantiates model from the given string. - """ - model = self.parser.get_model_from_str(model_str, debug=debug) - for p in self._model_processors: - p(model, self) - return model - - def model_from_file(self, file_name, encoding='utf-8', debug=None): - """ - Instantiates model from the given file. - """ - model = self.parser.get_model_from_file(file_name, - encoding, debug=debug) - for p in self._model_processors: - p(model, self) - return model - - def register_model_processor(self, model_processor): - """ - Model processor is callable that will be called after - each successful model parse. - This callable receives model and meta-model as its parameters. - """ - self._model_processors.append(model_processor) - - def register_obj_processors(self, obj_processors): - """ - Object processors are callables that will be called after - each successful model object construction. - Those callables receive model object as its parameter. - Registration of new object processors will replace previous. - - Args: - obj_processors(dict): A dictionary where key=class name, - value=callable - """ - self.obj_processors = obj_processors - - -def metamodel_from_str(lang_desc, metamodel=None, **kwargs): - """ - Creates a new metamodel from the textX description given as a string. - - Args: - lang_desc(str): A textX language description. - metamodel(TextXMetaModel): A metamodel that should be used. - other params: See TextXMetaModel. - - """ - if not metamodel: - metamodel = TextXMetaModel(**kwargs) - - language_from_str(lang_desc, metamodel) - - return metamodel - - -def metamodel_from_file(file_name, **kwargs): - """ - Creates new metamodel from the given file. - - Args: - file_name(str): The name of the file with textX language description. - other params: See metamodel_from_str. - """ - with codecs.open(file_name, 'r', 'utf-8') as f: - lang_desc = f.read() - - metamodel = metamodel_from_str(lang_desc=lang_desc, - file_name=file_name, **kwargs) - - return metamodel diff --git a/GraphLayoutDSL/target/classes/modules/textx/model.py b/GraphLayoutDSL/target/classes/modules/textx/model.py deleted file mode 100644 index b858733..0000000 --- a/GraphLayoutDSL/target/classes/modules/textx/model.py +++ /dev/null @@ -1,452 +0,0 @@ -####################################################################### -# Name: model.py -# Purpose: Model construction. -# Author: Igor R. Dejanovic -# Copyright: (c) 2014 Igor R. Dejanovic -# License: MIT License -####################################################################### - -import sys -if sys.version < '3': - text = unicode -else: - text = str -import codecs -import traceback -from arpeggio import Parser, Sequence, NoMatch, EOF, Terminal -from .exceptions import TextXSyntaxError, TextXSemanticError -from .const import MULT_ONE, MULT_ONEORMORE, MULT_ZEROORMORE, RULE_COMMON,\ - RULE_ABSTRACT, RULE_MATCH -from .textx import PRIMITIVE_PYTHON_TYPES - - -def convert(value, _type): - """ - Convert instances of textx types to python types. - """ - return { - 'BOOL' : lambda x: x == '1' or x.lower() == 'true', - 'INT' : lambda x: int(x), - 'FLOAT' : lambda x: float(x), - 'STRING': lambda x: x[1:-1].replace(r'\"', r'"').replace(r"\'", "'"), - }.get(_type, lambda x: x)(value) - - -class ObjCrossRef(object): - """ - Used for object cross reference resolving. - - Attributes: - obj_name(str): A name of the target object. - cls(TextXClass): The target object class. - position(int): A position in the input string of this cross-ref. - """ - def __init__(self, obj_name, cls, position): - self.obj_name = obj_name - self.cls = cls - self.position = position - - -def get_model_parser(top_rule, comments_model, **kwargs): - """ - Creates model parser for the given language. - """ - - class TextXModelParser(Parser): - """ - Parser created from textual textX language description. - Semantic actions for this parser will construct object - graph representing model on the given language. - """ - def __init__(self, *args, **kwargs): - super(TextXModelParser, self).__init__(*args, **kwargs) - - # By default first rule is starting rule - # and must be followed by the EOF - self.parser_model = Sequence( - nodes=[top_rule, EOF()], rule_name='Model', root=True) - self.comments_model = comments_model - - # Stack for metaclass instances - self._inst_stack = [] - - # Dict for cross-ref resolving - # { id(class): { obj.name: obj}} - self._instances = {} - - def _parse(self): - try: - return self.parser_model.parse(self) - except NoMatch as e: - line, col = e.parser.pos_to_linecol(e.position) - raise TextXSyntaxError(text(e), line, col) - - def get_model_from_file(self, file_name, encoding, debug): - """ - Creates model from the parse tree from the previous parse call. - If file_name is given file will be parsed before model - construction. - """ - with codecs.open(file_name, 'r', encoding) as f: - model_str = f.read() - - model = self.get_model_from_str(model_str, file_name=file_name, - debug=debug) - - # Register filename of the model for later use. - try: - model._tx_filename = file_name - except AttributeError: - # model is some primitive python type (e.g. str) - pass - return model - - def get_model_from_str(self, model_str, file_name=None, debug=None): - """ - Parses given string and creates model object graph. - """ - old_debug_state = self.debug - - try: - if debug is not None: - self.debug = debug - - if self.debug: - self.dprint("*** PARSING MODEL ***") - - self.parse(model_str, file_name=file_name) - # Transform parse tree to model. Skip root node which - # represents the whole file ending in EOF. - model = parse_tree_to_objgraph(self, self.parse_tree[0]) - finally: - if debug is not None: - self.debug = old_debug_state - - try: - model._tx_filename = None - except AttributeError: - # model is some primitive python type (e.g. str) - pass - return model - - return TextXModelParser(**kwargs) - - -def parse_tree_to_objgraph(parser, parse_tree): - """ - Transforms parse_tree to object graph representing model in a - new language. - """ - - metamodel = parser.metamodel - - def process_match(nt): - """ - Process subtree for match rules. - """ - if isinstance(nt, Terminal): - return convert(nt.value, nt.rule_name) - else: - # If RHS of assignment is NonTerminal it is a product of - # complex match rule. Convert nodes to text and do the join. - if len(nt) > 1: - return "".join([text(process_match(n)) for n in nt]) - else: - return process_match(nt[0]) - - def process_node(node): - if isinstance(node, Terminal): - return convert(node.value, node.rule_name) - - assert node.rule.root,\ - "Not a root node: {}".format(node.rule.rule_name) - # If this node is created by some root rule - # create metaclass instance. - inst = None - if not node.rule_name.startswith('__asgn'): - # If not assignment - # Get class - mclass = metamodel[node.rule_name] - - if mclass._tx_type == RULE_ABSTRACT: - # If this meta-class is product of abstract rule replace it - # with matched concrete meta-class down the inheritance tree. - # Abstract meta-class should never be instantiated. - return process_node(node[0]) - elif mclass._tx_type == RULE_MATCH: - # If this is a product of match rule handle it as a RHS - # of assignment and return plain python type. - return process_match(node) - - if parser.debug: - parser.dprint("CREATING INSTANCE {}".format(node.rule_name)) - - # If user class is given - # use it instead of generic one - if node.rule_name in metamodel.user_classes: - user_class = metamodel.user_classes[node.rule_name] - - # Object initialization will be done afterwards - # At this point we need object to be allocated - # So that nested object get correct reference - inst = user_class.__new__(user_class) - - # Initialize object attributes for user class - parser.metamodel._init_obj_attrs(inst, user=True) - else: - # Generic class will call attributes init - # from the constructor - inst = mclass.__new__(mclass) - - # Initialize object attributes - parser.metamodel._init_obj_attrs(inst) - - # Collect attributes directly on meta-class instance - obj_attrs = inst - - inst._tx_position = node.position - - # Push real obj. and dummy attr obj on the instance stack - parser._inst_stack.append((inst, obj_attrs)) - - for n in node: - if parser.debug: - parser.dprint("Recursing into {} = '{}'" - .format(type(n).__name__, text(n))) - process_node(n) - - parser._inst_stack.pop() - - # If this object is nested add 'parent' reference - if parser._inst_stack: - if node.rule_name in metamodel.user_classes: - obj_attrs._txa_parent = parser._inst_stack[-1][0] - else: - obj_attrs.parent = parser._inst_stack[-1][0] - - # If the class is user supplied we need to done - # proper initialization at this point. - if node.rule_name in metamodel.user_classes: - try: - # Get only attributes defined by the grammar as well - # as `parent` if exists - attrs = {} - if hasattr(obj_attrs, '_txa_parent'): - attrs['parent'] = obj_attrs._txa_parent - del obj_attrs._txa_parent - for a in obj_attrs.__class__._tx_attrs: - attrs[a] = getattr(obj_attrs, "_txa_%s" % a) - delattr(obj_attrs, "_txa_%s" % a) - inst.__init__(**attrs) - except TypeError as e: - # Add class name information in case of - # wrong constructor parameters - # print("Constructor params: {}".format(text(obj_attrs.__dict__))) - e.args += ("for class %s" % - inst.__class__.__name__,) - parser.dprint(traceback.print_exc()) - raise e - - # Special case for 'name' attrib. It is used for cross-referencing - if hasattr(inst, 'name') and inst.name: - # Objects of each class are in its own namespace - if not id(inst.__class__) in parser._instances: - parser._instances[id(inst.__class__)] = {} - parser._instances[id(inst.__class__)][inst.name] = inst - - if parser.debug: - parser.dprint("LEAVING INSTANCE {}".format(node.rule_name)) - - else: - # Handle assignments - attr_name = node.rule._attr_name - op = node.rule_name.split('_')[-1] - model_obj, obj_attr = parser._inst_stack[-1] - cls = metamodel[model_obj.__class__.__name__] - metaattr = cls._tx_attrs[attr_name] - - # Mangle attribute name to prevent name clashing with property - # setters on user classes - if cls.__name__ in metamodel.user_classes: - txa_attr_name = "_txa_%s" % attr_name - else: - txa_attr_name = attr_name - - if parser.debug: - parser.dprint('Handling assignment: {} {}...' - .format(op, txa_attr_name)) - - if op == 'optional': - setattr(obj_attr, txa_attr_name, True) - - elif op == 'plain': - attr_value = getattr(obj_attr, txa_attr_name) - if attr_value and type(attr_value) is not list: - raise TextXSemanticError( - "Multiple assignments to attribute {} at {}" - .format(attr_name, - parser.pos_to_linecol(node.position))) - - # Convert tree bellow assignment to proper value - value = process_node(node[0]) - - if metaattr.ref and not metaattr.cont: - # If this is non-containing reference create ObjCrossRef - value = ObjCrossRef(obj_name=value, cls=metaattr.cls, - position=node[0].position) - - if type(attr_value) is list: - attr_value.append(value) - else: - setattr(obj_attr, txa_attr_name, value) - - elif op in ['list', 'oneormore', 'zeroormore']: - for n in node: - # If the node is separator skip - if n.rule_name != 'sep': - # Convert node to proper type - # Rule links will be resolved later - value = process_node(n) - - if metaattr.ref and not metaattr.cont: - # If this is non-containing reference - # create ObjCrossRef - value = ObjCrossRef(obj_name=value, - cls=metaattr.cls, - position=node[0].position) - - if not hasattr(obj_attr, txa_attr_name) or \ - getattr(obj_attr, txa_attr_name) is None: - setattr(obj_attr, txa_attr_name, []) - getattr(obj_attr, txa_attr_name).append(value) - else: - # This shouldn't happen - assert False - - return inst - - def resolve_refs(model): - """ - Resolves model references. - """ - # TODO: Scoping and name-space rules. - - resolved_set = set() - metamodel = parser.metamodel - - def _resolve_link_rule_ref(obj_ref): - - if obj_ref is None: - return - - assert type(obj_ref) is ObjCrossRef, type(obj_ref) - - if parser.debug: - parser.dprint("Resolving obj crossref: {}:{}" - .format(obj_ref.cls, obj_ref.obj_name)) - - def _inner_resolve_link_rule_ref(cls, obj_name): - """ - Depth-first resolving of link rule reference. - """ - if cls._tx_type is RULE_ABSTRACT: - for inherited in cls._tx_inh_by: - result = _inner_resolve_link_rule_ref(inherited, obj_name) - if result: - return result - elif cls._tx_type == RULE_COMMON: - if id(cls) in parser._instances: - objs = parser._instances[id(cls)] - if obj_name in objs: - return objs[obj_name] - - result = _inner_resolve_link_rule_ref(obj_ref.cls, obj_ref.obj_name) - if result: - return result - - # As a fall-back search builtins if given - if metamodel.builtins: - if obj_ref.obj_name in metamodel.builtins: - # TODO: Classes must match - return metamodel.builtins[obj_ref.obj_name] - - line, col = parser.pos_to_linecol(obj_ref.position) - raise TextXSemanticError( - 'Unknown object "{}" of class "{}" at {}' - .format(obj_ref.obj_name, obj_ref.cls.__name__, (line, col)), - line=line, col=col) - - def _resolve_obj_attributes(o): - if parser.debug: - parser.dprint("RESOLVING CLASS: {}" - .format(o.__class__.__name__)) - if o in resolved_set: - return - resolved_set.add(o) - - # If this object has attributes (created using a common rule) - if hasattr(o.__class__, "_tx_attrs"): - for attr in o.__class__._tx_attrs.values(): - if parser.debug: - parser.dprint("RESOLVING ATTR: {}".format(attr.name)) - parser.dprint("mult={}, ref={}, con={}".format( - attr.mult, - attr.ref, attr.cont)) - attr_value = getattr(o, attr.name) - if attr.mult in [MULT_ONEORMORE, MULT_ZEROORMORE]: - for idx, list_attr_value in enumerate(attr_value): - if attr.ref: - if attr.cont: - _resolve_obj_attributes(list_attr_value) - else: - attr_value[idx] = \ - _resolve_link_rule_ref(list_attr_value) - else: - if attr.ref: - if attr.cont: - _resolve_obj_attributes(attr_value) - else: - setattr(o, attr.name, - _resolve_link_rule_ref(attr_value)) - - _resolve_obj_attributes(model) - - def call_obj_processors(model_obj): - """ - Depth-first model object processing. - """ - - if type(model_obj) in PRIMITIVE_PYTHON_TYPES: - metaclass = type(model_obj) - else: - metaclass = metamodel[model_obj.__class__.__name__] - - for metaattr in metaclass._tx_attrs.values(): - # If attribute is containment reference go down - if metaattr.ref and metaattr.cont: - attr = getattr(model_obj, metaattr.name) - if attr: - if metaattr.mult != MULT_ONE: - for obj in attr: - if obj: - call_obj_processors(obj) - else: - call_obj_processors(attr) - - obj_processor = metamodel.obj_processors.get(metaclass.__name__, None) - if obj_processor: - obj_processor(model_obj) - - model = process_node(parse_tree) - resolve_refs(model) - assert not parser._inst_stack - - # We have model loaded and all link resolved - # So we shall do a depth-first call of object - # processors if any processor is defined. - if metamodel.obj_processors: - if parser.debug: - parser.dprint("CALLING OBJECT PROCESSORS") - call_obj_processors(model) - - return model diff --git a/GraphLayoutDSL/target/classes/modules/textx/textx.py b/GraphLayoutDSL/target/classes/modules/textx/textx.py deleted file mode 100644 index b2bbcb6..0000000 --- a/GraphLayoutDSL/target/classes/modules/textx/textx.py +++ /dev/null @@ -1,915 +0,0 @@ -####################################################################### -# Name: textx.py -# Purpose: Implementation of textX language in Arpeggio. -# Author: Igor R. Dejanovic -# Copyright: (c) 2014 Igor R. Dejanovic -# License: MIT License -# -# The idea for this language is shamelessly stolen from the Xtext language -# but there are some subtle differences in both syntax and semantics. -# To make things clear I have named this language textX ;) -####################################################################### - -from __future__ import unicode_literals -import sys -if sys.version < '3': - text = unicode -else: - text = str - -import re -from arpeggio import StrMatch, Optional, ZeroOrMore, OneOrMore, Sequence,\ - OrderedChoice, Not, And, RegExMatch, Match, NoMatch, EOF, \ - ParsingExpression, SemanticAction, ParserPython, SemanticActionSingleChild -from arpeggio.export import PMDOTExporter -from arpeggio import RegExMatch as _ - -from .exceptions import TextXSyntaxError, TextXSemanticError -from .const import MULT_ZEROORMORE, MULT_ONEORMORE, \ - MULT_OPTIONAL, RULE_COMMON, RULE_MATCH, RULE_ABSTRACT - - -# textX grammar -def textx_model(): return ZeroOrMore(import_stm), ZeroOrMore(textx_rule), EOF - -def import_stm(): return 'import', grammar_to_import -def grammar_to_import(): return _(r'(\w|\.)+') - -# Rules -def textx_rule(): return rule_name, Optional(rule_params), ":", textx_rule_body, ";" -def rule_params(): return '[', rule_param, ZeroOrMore(',', rule_param), ']' -def rule_param(): return param_name, Optional('=', string_value) -def param_name(): return ident -def textx_rule_body(): return choice - -def choice(): return sequence, ZeroOrMore("|", sequence) -def sequence(): return OneOrMore(repeatable_expr) -def repeatable_expr(): return expression, Optional(repeat_operator), Optional('-') -def expression(): return [assignment, (Optional(syntactic_predicate), - [simple_match, rule_ref, - bracketed_choice])] -def bracketed_choice(): return '(', choice, ')' -def repeat_operator(): return ['*', '?', '+'], Optional(repeat_modifiers) -def repeat_modifiers(): return '[', OneOrMore([simple_match, - 'eolterm']), ']' -def syntactic_predicate(): return ['!', '&'] -def simple_match(): return [str_match, re_match] - -# Assignment -def assignment(): return attribute, assignment_op, assignment_rhs -def attribute(): return ident -def assignment_op(): return ["=", "*=", "+=", "?="] -def assignment_rhs(): return [simple_match, reference], Optional(repeat_modifiers) - -# References -def reference(): return [rule_ref, obj_ref] -def rule_ref(): return ident -def obj_ref(): return '[', class_name, Optional('|', obj_ref_rule), ']' - -def rule_name(): return ident -def obj_ref_rule(): return ident -def class_name(): return ident - -def str_match(): return [("'", _(r"((\\')|[^'])*"),"'"),\ - ('"', _(r'((\\")|[^"])*'),'"')] -def re_match(): return "/", _(r"((\\/)|[^/])*"), "/" -def ident(): return _(r'\w+') -def integer(): return _(r'[-+]?[0-9]+') -def string_value(): return [_(r"'((\\')|[^'])*'"), - _(r'"((\\")|[^"])*"')] - -# Comments -def comment(): return [comment_line, comment_block] -def comment_line(): return _(r'//.*?$') -def comment_block(): return _(r'/\*(.|\n)*?\*/') - - - -# Special rules - primitive types -ID = _(r'[^\d\W]\w*\b', rule_name='ID', root=True) -BOOL = _(r'(True|true|False|false|0|1)\b', rule_name='BOOL', root=True) -INT = _(r'[-+]?[0-9]+\b', rule_name='INT', root=True) -FLOAT = _(r'[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\b', 'FLOAT', root=True) -STRING = _(r'("(\\"|[^"])*")|(\'(\\\'|[^\'])*\')', 'STRING', root=True) -NUMBER = OrderedChoice(nodes=[FLOAT, INT], rule_name='NUMBER', root=True) -BASETYPE = OrderedChoice(nodes=[NUMBER, BOOL, ID, STRING], - rule_name='BASETYPE', root=True) - -BASE_TYPE_RULES = {rule.rule_name: rule - for rule in [ID, BOOL, INT, FLOAT, - STRING, NUMBER, BASETYPE]} -BASE_TYPE_NAMES = BASE_TYPE_RULES.keys() - -PRIMITIVE_PYTHON_TYPES = [int, float, text, bool] - -for regex in [ID, BOOL, INT, FLOAT, STRING]: - regex.compile() - - -def python_type(textx_type_name): - """Return Python type from the name of base textx type.""" - return { - 'ID': text, - 'BOOL': bool, - 'INT': int, - 'FLOAT': float, - 'STRING': text, - 'NUMBER': float, - 'BASETYPE': text, - }.get(textx_type_name, textx_type_name) - - -class RuleCrossRef(object): - """ - Used during meta-model parser construction for cross reference resolving - of PEG rules, to support forward references. - - Attributes: - rule_name(str): A name of the PEG rule that should be used to match - this cross-ref. For link rule references it will be ID by default. - cls(str or ClassCrossRef): Target class which is matched by the - rule_name rule or which name is matched by the rule_name rule (for - link rule references). - Used for rule references in the RHS of the assignments to - determine attribute type. - position(int): A position in the input string of this cross-ref. - """ - def __init__(self, rule_name, cls, position): - self.rule_name = rule_name - self.cls = cls - self.position = position - self.suppress = False - - def __str__(self): - return self.rule_name - - def __unicode__(self): - return self.__str__() - - -class ClassCrossRef(object): - """ - Used for class reference resolving on the meta-model level. - References will be resolved after semantic analysis of the meta-model - parse tree. After resolving phase the meta-model will be fully linked. - - Attributes: - cls_name(str): A name of the target meta-model class. - position(int): The position in the input string of this cross-ref. - """ - def __init__(self, cls_name, position=0): - self.cls_name = cls_name - self.position = position - - -# TextX semantic actions -class TextXModelSA(SemanticAction): - def first_pass(self, grammar_parser, node, children): - - metamodel = grammar_parser.metamodel - - if 'Comment' in metamodel: - comments_model = metamodel['Comment']._tx_peg_rule - else: - comments_model = None - - root_rule = children[0] - from .model import get_model_parser - model_parser = get_model_parser(root_rule, comments_model, - ignore_case=metamodel.ignore_case, - skipws=metamodel.skipws, - ws=metamodel.ws, - autokwd=metamodel.autokwd, - memoization=metamodel.memoization, - debug=metamodel.debug) - - model_parser.metamodel = metamodel - - return model_parser - - def _resolve_rule_refs(self, grammar_parser, model_parser): - """Resolves parser ParsingExpression crossrefs.""" - - def _resolve_rule(rule): - """ - Recursively resolve peg rule references. - - Args: - rule(ParsingExpression or RuleCrossRef) - """ - if not isinstance(rule, RuleCrossRef) and rule in resolved_rules: - return rule - resolved_rules.add(rule) - - if grammar_parser.debug: - grammar_parser.dprint("Resolving rule: {}".format(rule)) - - if type(rule) is RuleCrossRef: - rule_name = rule.rule_name - suppress = rule.suppress - if rule_name in model_parser.metamodel: - rule = model_parser.metamodel[rule_name]._tx_peg_rule - if type(rule) is RuleCrossRef: - rule = _resolve_rule(rule) - model_parser.metamodel[rule_name]._tx_peg_rule = rule - if suppress: - # Special case. Suppression on rule reference. - _tx_class = rule._tx_class - rule = Sequence(nodes=[rule], - rule_name=rule_name, - suppress=suppress) - rule._tx_class = _tx_class - else: - line, col = grammar_parser.pos_to_linecol(rule.position) - raise TextXSemanticError( - 'Unexisting rule "{}" at position {}.' - .format(rule.rule_name, - (line, col)), line, col) - - assert isinstance(rule, ParsingExpression),\ - "{}:{}".format(type(rule), text(rule)) - - # Recurse into subrules, and resolve rules. - for idx, child in enumerate(rule.nodes): - if child not in resolved_rules: - child = _resolve_rule(child) - rule.nodes[idx] = child - - return rule - - # Two pass resolving - for i in range(2): - if grammar_parser.debug: - grammar_parser.dprint("RESOLVING RULE CROSS-REFS - PASS {}" - .format(i + 1)) - resolved_rules = set() - # Start from the root of the parser - _resolve_rule(model_parser.parser_model) - # Resolve rules of all meta-classes to handle unreferenced - # rules also. - for cls in model_parser.metamodel: - cls._tx_peg_rule = _resolve_rule(cls._tx_peg_rule) - - - def _determine_rule_types(self, metamodel): - """Determine textX rule/metaclass types""" - - def _determine_rule_type(cls): - """ - Determine rule type (abstract, match, common) and inherited classes. - """ - - if cls in resolved_classes: - return - resolved_classes.add(cls) - - # If there are attributes collected than this is a common - # rule - if len(cls._tx_attrs) > 0: - cls._tx_type = RULE_COMMON - return - - rule = cls._tx_peg_rule - - # Check if this rule is abstract - # Abstract are root rules which haven't got any attributes - # and reference at least one non-match rule. - abstract = False - if rule.rule_name and cls.__name__ != rule.rule_name: - # Special case. Body of the rule is a single rule - # reference and the referenced rule is not match rule. - target_cls = metamodel[rule.rule_name] - _determine_rule_type(target_cls) - abstract = target_cls._tx_type != RULE_MATCH - else: - # Find at leat one referenced rule that is not match - # rule by going down the parser - # model and finding root rules. - def _has_nonmatch_ref(rule): - for r in rule.nodes: - if r.root: - _determine_rule_type(r._tx_class) - result = r._tx_class._tx_type != RULE_MATCH - else: - result = _has_nonmatch_ref(r) - if result: - return True - abstract = _has_nonmatch_ref(rule) - - if abstract: - cls._tx_type = RULE_ABSTRACT - # Add inherited classes to this rule's meta-class - if rule.rule_name and cls.__name__ != rule.rule_name: - if rule._tx_class not in cls._tx_inh_by: - cls._tx_inh_by.append(rule._tx_class) - else: - # Recursivelly append all referenced classes. - def _add_reffered_classes(rule, inh_by): - for r in rule.nodes: - if r.root: - if hasattr(r, '_tx_class'): - _determine_rule_type(r._tx_class) - if r._tx_class._tx_type != RULE_MATCH and\ - r._tx_class not in inh_by: - inh_by.append(r._tx_class) - else: - _add_reffered_classes(r, inh_by) - _add_reffered_classes(rule, cls._tx_inh_by) - - resolved_classes = set() - for cls in metamodel: - _determine_rule_type(cls) - - def _resolve_cls_refs(self, grammar_parser, model_parser): - - resolved_classes = {} - - def _resolve_cls(cls): - - if cls in resolved_classes: - return resolved_classes[cls] - - metamodel = model_parser.metamodel - - to_resolve = cls - if isinstance(cls, ClassCrossRef): - if cls.cls_name not in metamodel: - line, col = grammar_parser.pos_to_linecol(cls.position) - raise TextXSemanticError( - 'Unknown class/rule "{}" at {}.' - .format(cls.cls_name, (line, col)), line, col) - cls = metamodel[cls.cls_name] - resolved_classes[to_resolve] = cls - - if cls._tx_type == RULE_ABSTRACT: - # Resolve inherited classes - for idx, inh in enumerate(cls._tx_inh_by): - inh = _resolve_cls(inh) - cls._tx_inh_by[idx] = inh - - else: - - # If this is not abstract class than it must be common or match. - # Resolve referred classes. - # If there is no attributes collected than it `` - for attr in cls._tx_attrs.values(): - attr.cls = _resolve_cls(attr.cls) - - # If target cls is of a base type or match rule - # then attr can not be a reference. - if attr.cls.__name__ in BASE_TYPE_NAMES \ - or attr.cls._tx_type == RULE_MATCH: - attr.ref = False - attr.cont = True - else: - attr.ref = True - - if grammar_parser.debug: - grammar_parser.dprint( - "Resolved attribute {}:{}[cls={}, cont={}, " - "ref={}, mult={}, pos={}]" - .format(cls.__name__, attr.name, - attr.cls.__name__, - attr.cont, attr.ref, attr.mult, - attr.position)) - - return cls - - - if grammar_parser.debug: - grammar_parser.dprint("RESOLVING METACLASS REFS") - - for cls in model_parser.metamodel: - _resolve_cls(cls) - - def second_pass(self, grammar_parser, model_parser): - """Cross reference resolving for parser model.""" - - if grammar_parser.debug: - grammar_parser.dprint("RESOLVING MODEL PARSER: second_pass") - - self._resolve_rule_refs(grammar_parser, model_parser) - self._determine_rule_types(model_parser.metamodel) - self._resolve_cls_refs(grammar_parser, model_parser) - - return model_parser -textx_model.sem = TextXModelSA() - - -def import_stm_SA(parser, node, children): - parser.metamodel._new_import(children[0]) -import_stm.sem = import_stm_SA - - -def grammar_to_import_SA(parser, node, children): - return text(node) -grammar_to_import.sem = grammar_to_import_SA - - -def textx_rule_SA(parser, node, children): - if len(children) > 2: - rule_name, rule_params, rule = children - else: - rule_name, rule = children - rule_params = {} - - if rule.rule_name.startswith('__asgn') or\ - ((isinstance(rule, Match) or isinstance(rule, RuleCrossRef)) and - rule_params): - # If it is assignment node it must be kept because it could be - # e.g., single assignment in the rule. - # Also, handle a special case where rule consists only of a single match - # or single rule reference and there are rule modifiers defined. - rule = Sequence(nodes=[rule], rule_name=rule_name, - root=True, **rule_params) - else: - if not isinstance(rule, RuleCrossRef): - # Promote rule node to root node. - rule.rule_name = rule_name - rule.root = True - for param in rule_params: - setattr(rule, param, rule_params[param]) - - # Connect meta-class and the PEG rule - parser.metamodel._set_rule(rule_name, rule) - - return rule -textx_rule.sem = textx_rule_SA - - -def rule_name_SA(parser, node, children): - rule_name = str(node) - - if parser.debug: - parser.dprint("Creating class: {}".format(rule_name)) - - # If a class is given by the user use it. Else, create new class. - if rule_name in parser.metamodel.user_classes: - - cls = parser.metamodel.user_classes[rule_name] - - # Initialize special attributes - parser.metamodel._init_class(cls, None, node.position) - else: - # Create class to collect attributes. At this time PEG rule - # is not known. - cls = parser.metamodel._new_class(rule_name, None, node.position) - - parser._current_cls = cls - - # First class will be the root of the meta-model - if not parser.metamodel.rootcls: - parser.metamodel.rootcls = cls - - return rule_name -rule_name.sem = rule_name_SA - - -def rule_params_SA(parser, node, children): - params = {} - for name, value in children[0].items(): - if name not in ['skipws', 'ws']: - raise TextXSyntaxError( - 'Invalid rule param "{}" at {}.' - .format(name, parser.pos_to_linecol(node.position))) - - if name == 'ws' and '\\' in value: - new_value = "" - if "\\n" in value: - new_value += "\n" - if "\\r" in value: - new_value += "\r" - if "\\t" in value: - new_value += "\t" - if " " in value: - new_value += " " - value = new_value - - params[name] = value - - return params -rule_params.sem = rule_params_SA - - -def rule_param_SA(parser, node, children): - if len(children) > 1: - param_name, param_value = children - else: - param_name = children[0] - param_value = True - if param_name.startswith('no'): - param_name = param_name[2:] - param_value = False - - if parser.debug: - parser.dprint("TextX rule param: {}, {}".format(param_name, - param_value)) - - return {param_name: param_value} -rule_param.sem = rule_param_SA - - -def rule_ref_SA(parser, node, children): - rule_name = text(node) - # Here a name of the meta-class (rule) is expected but to support - # forward referencing we are postponing resolving to second_pass. - return RuleCrossRef(rule_name, rule_name, node.position) -rule_ref.sem = rule_ref_SA - - -def textx_rule_body_SA(parser, node, children): - if len(children) > 1: - return OrderedChoice(nodes=children[:]) - else: - return children[0] -textx_rule_body.sem = textx_rule_body_SA - - -def sequence_SA(parser, node, children): - if len(children) > 1: - return Sequence(nodes=children[:]) - else: - return children[0] -sequence.sem = sequence_SA - - -def choice_SA(parser, node, children): - # If there is only one child reduce as - # this ordered choice is unnecessary - if len(children) > 1: - return OrderedChoice(nodes=children[:]) - else: - return children[0] -choice.sem = choice_SA - - -def expression_SA(parser, node, children): - if len(children) > 1: - if children[0] == '!': - return Not(nodes=[children[1]]) - else: - return And(nodes=[children[1]]) - else: - return children[0] -expression.sem=expression_SA - - -def repeat_modifiers_SA(parser, node, children): - modifiers = {} - for modifier in children: - if isinstance(modifier, Match): - # Separator - modifier.rule_name = 'sep' - modifiers['sep'] = modifier - elif type(modifier) == tuple: - modifiers['multiplicity'] = modifier - else: - modifiers['eolterm'] = True - return (modifiers, node.position) -repeat_modifiers.sem = repeat_modifiers_SA - - -def repeat_operator_SA(parser, node, children): - return children -repeat_operator.sem = repeat_operator_SA - - -def repeatable_expr_SA(parser, node, children): - expr = children[0] - rule = expr - repeat_op = False - suppress = False - if len(children) > 1: - # We can have repeat operator and/or suppression operator - if len(children) > 2: - repeat_op = children[1] - suppress = True - else: - if children[1] == '-': - suppress = True - else: - repeat_op = children[1] - - if repeat_op: - if len(repeat_op) > 1: - repeat_op, modifiers = repeat_op - else: - repeat_op = repeat_op[0] - modifiers = None - - if repeat_op == '?': - rule = Optional(nodes=[expr]) - elif repeat_op == '*': - rule = ZeroOrMore(nodes=[expr]) - else: - rule = OneOrMore(nodes=[expr]) - - if modifiers: - modifiers, position = modifiers - # Sanity check. Modifiers do not make - # sense for ? operator at the moment. - if repeat_op == '?': - line, col = parser.pos_to_linecol(position) - raise TextXSyntaxError( - 'Modifiers are not allowed for "?" operator at {}' - .format(text((line, col))), line, col) - # Separator modifier - if 'sep' in modifiers: - sep = modifiers['sep'] - rule = Sequence(nodes=[expr, - ZeroOrMore(nodes=[ - Sequence(nodes=[sep, expr])])]) - if repeat_op == '*': - rule = Optional(nodes=[rule]) - - # End of line termination modifier - if 'eolterm' in modifiers: - rule.eolterm = True - - # Mark rule for suppression - rule.suppress = suppress - - return rule -repeatable_expr.sem = repeatable_expr_SA - - -def assignment_rhs_SA(parser, node, children): - rule = children[0] - modifiers = None - if len(children) > 1: - modifiers = children[1] - - # At this level we do not know the type of assignment (=, +=, *=) - # and we do not have access to the PEG rule so postpone - # rule modification for assignment semantic action. - return (rule, modifiers) -assignment_rhs.sem = assignment_rhs_SA - - -def assignment_SA(parser, node, children): - """ - Create parser rule for assignments and register attribute types - on metaclass. - """ - attr_name = children[0] - op = children[1] - rhs_rule, modifiers = children[2] - cls = parser._current_cls - target_cls = None - - if parser.debug: - parser.dprint("Processing assignment {}{}...".format(attr_name, op)) - - if parser.debug: - parser.dprint("Creating attribute {}:{}".format(cls.__name__, - attr_name)) - parser.dprint("Assignment operation = {}".format(op)) - - if attr_name in cls._tx_attrs: - # If attribute already exists in the metamodel it is - # multiple assignment to the same attribute. - - # Cannot use operator ?= on multiple assignments - if op == '?=': - line, col = parser.pos_to_linecol(node.position) - raise TextXSemanticError( - 'Cannot use "?=" operator on multiple' - ' assignments for attribute "{}" at {}' - .format(attr_name, (line, col)), line, col) - - cls_attr = cls._tx_attrs[attr_name] - # Must be a many multiplicity. - # OneOrMore is "stronger" constraint. - if cls_attr.mult is not MULT_ONEORMORE: - cls_attr.mult = MULT_ZEROORMORE - else: - cls_attr = parser.metamodel._new_cls_attr(cls, name=attr_name, - position=node.position) - - # Keep track of metaclass references and containments - if type(rhs_rule) is tuple and rhs_rule[0] == "obj_ref": - cls_attr.cont = False - cls_attr.ref = True - # Override rhs by its PEG rule for further processing - rhs_rule = rhs_rule[1] - # Target class is not the same as target rule - target_cls = rhs_rule.cls - - base_rule_name = rhs_rule.rule_name - if op == '+=': - assignment_rule = OneOrMore( - nodes=[rhs_rule], - rule_name='__asgn_oneormore', root=True) - cls_attr.mult = MULT_ONEORMORE - elif op == '*=': - assignment_rule = ZeroOrMore( - nodes=[rhs_rule], - rule_name='__asgn_zeroormore', root=True) - if cls_attr.mult is not MULT_ONEORMORE: - cls_attr.mult = MULT_ZEROORMORE - elif op == '?=': - assignment_rule = Optional( - nodes=[rhs_rule], - rule_name='__asgn_optional', root=True) - cls_attr.mult = MULT_OPTIONAL - base_rule_name = 'BOOL' - - # ?= assigment should have default value of False. - # so we shall mark it as such. - cls_attr.bool_assignment = True - - else: - assignment_rule = Sequence( - nodes=[rhs_rule], - rule_name='__asgn_plain', root=True) - - # Modifiers - if modifiers: - modifiers, position = modifiers - # Sanity check. Modifiers do not make - # sense for ?= and = operator at the moment. - if op == '?=' or op == '=': - line, col = parser.pos_to_linecol(position) - raise TextXSyntaxError( - 'Modifiers are not allowed for "{}" operator at {}' - .format(op, text((line, col))), line, col) - - # Separator modifier - if 'sep' in modifiers: - sep = modifiers['sep'] - assignment_rule = Sequence( - nodes=[rhs_rule, - ZeroOrMore(nodes=[Sequence(nodes=[sep, rhs_rule])])], - rule_name='__asgn_list', root=True) - if op == "*=": - assignment_rule.root = False - assignment_rule = Optional(nodes=[assignment_rule], - rule_name='__asgn_list', root=True) - - # End of line termination modifier - if 'eolterm' in modifiers: - assignment_rule.eolterm = True - - if target_cls: - attr_type = target_cls - else: - # Use STRING as default attr class - attr_type = base_rule_name if base_rule_name else 'STRING' - cls_attr.cls = ClassCrossRef(cls_name=attr_type, position=node.position) - - if parser.debug: - parser.dprint("Created attribute {}:{}[cls={}, cont={}, " - "ref={}, mult={}, pos={}]" - .format(cls.__name__, attr_name, cls_attr.cls.cls_name, - cls_attr.cont, cls_attr.ref, cls_attr.mult, - cls_attr.position)) - - assignment_rule._attr_name = attr_name - assignment_rule._exp_str = attr_name # For nice error reporting - return assignment_rule -assignment.sem = assignment_SA - - -def str_match_SA(parser, node, children): - try: - to_match = children[0] - except: - to_match = '' - - # Support for autokwd metamodel param. - if parser.metamodel.autokwd: - match = parser.keyword_regex.match(to_match) - if match and match.span() == (0, len(to_match)): - regex_match = RegExMatch(r'{}\b'.format(to_match), - ignore_case=parser.metamodel.ignore_case, - str_repr=to_match) - regex_match.compile() - return regex_match - return StrMatch(to_match, ignore_case=parser.metamodel.ignore_case) -str_match.sem = str_match_SA - - -def re_match_SA(parser, node, children): - try: - to_match = children[0] - except: - to_match = '' - regex = RegExMatch(to_match, ignore_case=parser.metamodel.ignore_case) - try: - regex.compile() - except Exception as e: - line, col = parser.pos_to_linecol(node[1].position) - raise TextXSyntaxError( - "{} at {}" - .format(text(e), text((line, col))), line, col) - return regex -re_match.sem = re_match_SA - - -def obj_ref_SA(parser, node, children): - # A reference to some other class instance will be the value of - # its "name" attribute. - class_name = children[0] - if class_name in BASE_TYPE_NAMES: - line, col = parser.pos_to_linecol(node.position) - raise TextXSemanticError( - 'Primitive type instances can not be referenced at {}.' - .format((line, col)), line, col) - if len(children) > 1: - rule_name = children[1] - else: - # Default rule for matching obj cross-refs - rule_name = 'ID' - return ("obj_ref", RuleCrossRef(rule_name, class_name, node.position)) -obj_ref.sem = obj_ref_SA - - -def integer_SA(parser, node, children): - return int(node.value) -integer.sem = integer_SA - - -def string_value_SA(parser, node, children): - return node.value.strip("\"'") -string_value.sem = string_value_SA - - -# Default actions -bracketed_choice.sem = SemanticActionSingleChild() - - -# parser object cache. To speed up parser initialization (e.g. during imports) -textX_parsers = {} - - -def language_from_str(language_def, metamodel): - """ - Constructs parser and initializes metamodel from language description - given in textX language. - - Args: - language_def (str): A language description in textX. - metamodel (TextXMetaModel): A metamodel to initialize. - - Returns: - Parser for the new language. - """ - - if metamodel.debug: - metamodel.dprint("*** PARSING LANGUAGE DEFINITION ***") - - # Check the cache for already conctructed textX parser - if metamodel.debug in textX_parsers: - parser = textX_parsers[metamodel.debug] - else: - # Create parser for TextX descriptions from - # the textX grammar specified in this module - parser = ParserPython(textx_model, comment_def=comment, - ignore_case=False, - reduce_tree=False, - memoization=metamodel.memoization, - debug=metamodel.debug) - - # Prepare regex used in keyword-like strmatch detection. - # See str_match_SA - flags = 0 - if metamodel.ignore_case: - flags = re.IGNORECASE - parser.keyword_regex = re.compile(r'[^\d\W]\w*', flags) - - # Cache it for subsequent calls - textX_parsers[metamodel.debug] = parser - - # This is used during parser construction phase. - # Metamodel is filled in. Classes are created based on grammar rules. - parser.metamodel = metamodel - - # Builtin rules representing primitive types - parser.root_rule_name = None - - # Parse language description with textX parser - try: - parser.parse(language_def) - except NoMatch as e: - line, col = parser.pos_to_linecol(e.position) - raise TextXSyntaxError(text(e), line, col) - - # Construct new parser based on the given language description. - lang_parser = parser.getASG() - - # Meta-model is constructed. Validate semantics of metamodel. - parser.metamodel.validate() - - # Meta-model is constructed. Here we connect meta-model and language - # parser for convenience. - lang_parser.metamodel = parser.metamodel - metamodel.parser = lang_parser - - if metamodel.debug: - # Create dot file for debuging purposes - PMDOTExporter().exportFile( - lang_parser.parser_model, - "{}_parser_model.dot".format(metamodel.rootcls.__name__)) - - return lang_parser - diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..40f54af --- /dev/null +++ b/pom.xml @@ -0,0 +1,143 @@ + + + 4.0.0 + + GraphDrawing + GraphDrawing + 0.1.0-SNAPSHOT + pom + + GraphDrawing + http://maven.apache.org + + + UTF-8 + + + + GraphLayoutDSL + GraphDrawingTheory + GraphEditor + + + + + http://repo1.maven.org/maven2/ + maven2 + Maven 2 + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.1 + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-jar-plugin + 3.0.2 + + + + true + + + + + + maven-dependency-plugin + + + install + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.19.1 + + + + + + + + org.python + jython-standalone + 2.7.1b2 + + + commons-io + commons-io + 2.5 + + + org.tinyjee.jgraphx + jgraphx + 3.4.1.3 + + + log4j + log4j + 1.2.17 + + + org.prefuse + prefuse + beta-20071021 + + + gov.nist.math + jama + 1.0.3 + + + net.sf.jung + jung-visualization + 2.0.1 + + + net.sf.jung + jung-algorithms + 2.0.1 + + + net.sf.jung + jung-graph-impl + 2.0.1 + + + com.miglayout + miglayout-swing + 5.0 + + + com.thoughtworks.xstream + xstream + 1.4.8 + + + junit + junit + 4.12 + test + + + +