diff --git a/build.sbt b/build.sbt index 33ed0cb..0f4ad5c 100644 --- a/build.sbt +++ b/build.sbt @@ -4,7 +4,7 @@ organization := "com.github.mdr" version := "0.0.6" -scalaVersion := "2.10.1" +scalaVersion := "2.12.1" crossScalaVersions := Seq("2.9.1", "2.9.2", "2.10.1") @@ -12,9 +12,9 @@ scalacOptions ++= Seq("-deprecation") javacOptions ++= Seq("-source", "1.6", "-target", "1.6") -libraryDependencies += "org.scalatest" %% "scalatest" % "1.9.1" % "test" +libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test" -libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.10.1" % "test" +libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.13.4" % "test" // Screen-sized dependency graph: // libraryDependencies += "org.vert-x" % "vertx-core" % "1.3.1.final" @@ -23,12 +23,12 @@ EclipseKeys.withSource := true EclipseKeys.eclipseOutput := Some("bin") -net.virtualvoid.sbt.graph.Plugin.graphSettings +//net.virtualvoid.sbt.graph.Plugin.graphSettings -scalariformSettings +import com.typesafe.sbt.SbtScalariform.ScalariformKeys ScalariformKeys.preferences <<= baseDirectory.apply { dir => - scalariform.formatter.preferences.PreferencesImporterExporter.loadPreferences((dir / "formatterPreferences.properties").getPath) + scalariform.formatter.preferences.PreferencesImporterExporter.loadPreferences((dir / "formatterPreferences.properties").getPath) } publishMavenStyle := true diff --git a/project/build.properties b/project/build.properties index 9b860e2..24be09b 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1,2 @@ -sbt.version=0.12.3 +sbt.version=0.13.13 + diff --git a/project/plugins.sbt b/project/plugins.sbt index 233bdbd..afe242f 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,11 +1,10 @@ addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.2.0") -addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.3") - -// addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.4-SNAPSHOT") +addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2") addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8") -addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.4.0") +resolvers += Resolver.typesafeRepo("releases") + +addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0") -addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.0.1") diff --git a/src/main/java/com/github/mdr/ascii/java/ScalaJavaHelper.scala b/src/main/java/com/github/mdr/ascii/java/ScalaJavaHelper.scala index 4672e38..16afb6f 100644 --- a/src/main/java/com/github/mdr/ascii/java/ScalaJavaHelper.scala +++ b/src/main/java/com/github/mdr/ascii/java/ScalaJavaHelper.scala @@ -1,6 +1,6 @@ package com.github.mdr.ascii.java -import java.{ util ⇒ ju } +import java.{util ⇒ ju} import scala.collection.JavaConverters._ import com.github.mdr.ascii.graph.Graph import com.github.mdr.ascii.layout.GraphLayout diff --git a/src/main/scala/com/github/mdr/ascii/diagram/Box.scala b/src/main/scala/com/github/mdr/ascii/diagram/Box.scala index 91ab2c7..f5ab23e 100644 --- a/src/main/scala/com/github/mdr/ascii/diagram/Box.scala +++ b/src/main/scala/com/github/mdr/ascii/diagram/Box.scala @@ -15,6 +15,6 @@ trait Box extends Container { edge ← edges if edgeType.includeEdge(edge, this) otherBox = edge.otherBox(this) - } yield edge -> otherBox + } yield edge → otherBox } diff --git a/src/main/scala/com/github/mdr/ascii/diagram/parser/DiagramImplementation.scala b/src/main/scala/com/github/mdr/ascii/diagram/parser/DiagramImplementation.scala index ceaee2a..8d6c7f0 100644 --- a/src/main/scala/com/github/mdr/ascii/diagram/parser/DiagramImplementation.scala +++ b/src/main/scala/com/github/mdr/ascii/diagram/parser/DiagramImplementation.scala @@ -95,10 +95,13 @@ trait DiagramImplementation { self: DiagramParser ⇒ Region( Point( points.map(_.row).min, - points.map(_.column).min), + points.map(_.column).min + ), Point( points.map(_.row).max, - points.map(_.column).max)) + points.map(_.column).max + ) + ) } diff --git a/src/main/scala/com/github/mdr/ascii/diagram/parser/DiagramParser.scala b/src/main/scala/com/github/mdr/ascii/diagram/parser/DiagramParser.scala index 53e4f67..8c45611 100644 --- a/src/main/scala/com/github/mdr/ascii/diagram/parser/DiagramParser.scala +++ b/src/main/scala/com/github/mdr/ascii/diagram/parser/DiagramParser.scala @@ -35,7 +35,7 @@ class DiagramParser(s: String) innerBox ← diagram.allBoxes if outerBox != innerBox if outerBox.region contains innerBox.region - } yield outerBox -> innerBox).toMap + } yield outerBox → innerBox).toMap for { (box, containingBoxMap) ← boxContains.groupBy(_._2) diff --git a/src/main/scala/com/github/mdr/ascii/graph/DiagramToGraphConverter.scala b/src/main/scala/com/github/mdr/ascii/graph/DiagramToGraphConverter.scala index 6c0ec2f..5a3d9f1 100644 --- a/src/main/scala/com/github/mdr/ascii/graph/DiagramToGraphConverter.scala +++ b/src/main/scala/com/github/mdr/ascii/graph/DiagramToGraphConverter.scala @@ -17,9 +17,9 @@ object DiagramToGraphConvertor { vertex2 ← boxToVertexMap.get(edge.box2) } yield { if (edge.hasArrow2) - vertex1 -> vertex2 + vertex1 → vertex2 else - vertex2 -> vertex1 + vertex2 → vertex1 } Graph(vertices, edges) } diff --git a/src/main/scala/com/github/mdr/ascii/layout/GraphLayout.scala b/src/main/scala/com/github/mdr/ascii/layout/GraphLayout.scala index be73d04..24461d5 100644 --- a/src/main/scala/com/github/mdr/ascii/layout/GraphLayout.scala +++ b/src/main/scala/com/github/mdr/ascii/layout/GraphLayout.scala @@ -19,7 +19,8 @@ object GraphLayout { def renderGraph[V]( graph: Graph[V], vertexRenderingStrategy: VertexRenderingStrategy[V] = ToStringVertexRenderingStrategy, - layoutPrefs: LayoutPrefs = LayoutPrefsImpl()): String = { + layoutPrefs: LayoutPrefs = LayoutPrefsImpl() + ): String = { val cycleRemovalResult = CycleRemover.removeCycles(graph) val (layering, _) = new LayeringCalculator[V].assignLayers(cycleRemovalResult) val reorderedLayering = LayerOrderingCalculator.reorder(layering) @@ -30,12 +31,6 @@ object GraphLayout { drawing = KinkRemover.removeKinks(drawing) if (layoutPrefs.elevateEdges) drawing = EdgeElevator.elevateEdges(drawing) - - // if (layoutPrefs.removeKinks) - // drawing = KinkRemover.removeKinks(drawing) - // if (layoutPrefs.elevateEdges) - // drawing = EdgeElevator.elevateEdges(drawing) - // if (layoutPrefs.compactify) drawing = RedundantRowRemover.removeRedundantRows(drawing) diff --git a/src/main/scala/com/github/mdr/ascii/layout/coordAssign/EdgeBendCalculator.scala b/src/main/scala/com/github/mdr/ascii/layout/coordAssign/EdgeBendCalculator.scala index b8609ef..a3522f5 100644 --- a/src/main/scala/com/github/mdr/ascii/layout/coordAssign/EdgeBendCalculator.scala +++ b/src/main/scala/com/github/mdr/ascii/layout/coordAssign/EdgeBendCalculator.scala @@ -90,8 +90,8 @@ class EdgeBendCalculator(edgeInfos: List[EdgeInfo], edgeZoneTopRow: Int, selfEdg if row1 > row2 if !swappedEdges.contains((edgeInfo1, edgeInfo2)) // Prevents more involved infinite loops } { - updatedEdgeToRowMap += edgeInfo1 -> row2 - updatedEdgeToRowMap += edgeInfo2 -> row1 + updatedEdgeToRowMap += edgeInfo1 → row2 + updatedEdgeToRowMap += edgeInfo2 → row1 swappedEdges += ((edgeInfo1, edgeInfo2)) continue = true } diff --git a/src/main/scala/com/github/mdr/ascii/layout/coordAssign/Layouter.scala b/src/main/scala/com/github/mdr/ascii/layout/coordAssign/Layouter.scala index c75b7d1..61c0298 100644 --- a/src/main/scala/com/github/mdr/ascii/layout/coordAssign/Layouter.scala +++ b/src/main/scala/com/github/mdr/ascii/layout/coordAssign/Layouter.scala @@ -45,7 +45,7 @@ class Layouter(vertexRenderingStrategy: VertexRenderingStrategy[_], vertical: Bo var layerInfos: Map[Layer, LayerInfo] = Map() for ((previousLayerOpt, currentLayer, nextLayerOpt) ← Utils.withPreviousAndNext(layering.layers)) { val layerInfo = calculateLayerInfo(currentLayer, layering.edges, previousLayerOpt, nextLayerOpt) - layerInfos += currentLayer -> layerInfo + layerInfos += currentLayer → layerInfo } PortNudger.nudge(layering, spaceVertices(layerInfos)) } @@ -99,8 +99,8 @@ class Layouter(vertexRenderingStrategy: VertexRenderingStrategy[_], vertical: Bo private def makeVertexInfo(vertex: DummyVertex, boxRegion: Region, greaterRegion: Region, inEdges: List[Edge], outEdges: List[Edge]): VertexInfo = { val (List(inVertex), List(outVertex)) = (inEdges, outEdges) val port = boxRegion.topLeft - val inEdgeToPortMap = Map(inVertex -> port) - val outEdgeToPortMap = Map(outVertex -> port) + val inEdgeToPortMap = Map(inVertex → port) + val outEdgeToPortMap = Map(outVertex → port) VertexInfo(boxRegion, greaterRegion, inEdgeToPortMap, outEdgeToPortMap, Nil, Nil) } @@ -164,7 +164,7 @@ class Layouter(vertexRenderingStrategy: VertexRenderingStrategy[_], vertical: Bo case _ ⇒ 0 } val greaterRegion = boxRegion.expandRight(selfEdgesSpacing).expandUp(selfEdgesSpacing).expandDown(selfEdgesSpacing) - regions += vertex -> (boxRegion, greaterRegion) + regions += vertex → (boxRegion, greaterRegion) nextVertexTopLeft = boxRegion.topRight.right(selfEdgesSpacing + 2) } regions @@ -185,7 +185,7 @@ class Layouter(vertexRenderingStrategy: VertexRenderingStrategy[_], vertical: Bo private def spaceVertices(layerInfos: Map[Layer, LayerInfo]): Map[Layer, LayerInfo] = { val diagramWidth = calculateDiagramWidth(layerInfos) - layerInfos.map { case (layer, info) ⇒ layer -> spaceVertices(layer, info, diagramWidth) } + layerInfos.map { case (layer, info) ⇒ layer → spaceVertices(layer, info, diagramWidth) } } /** @@ -209,7 +209,7 @@ class Layouter(vertexRenderingStrategy: VertexRenderingStrategy[_], vertical: Bo leftColumn += vertexInfo.greaterRegion.width leftColumn += horizontalSpacing val verticalCenteringOffset = (layerHeight - vertexInfo.boxRegion.height) / 2 - v -> vertexInfo.setLeft(oldLeftColumn).down(verticalCenteringOffset) + v → vertexInfo.setLeft(oldLeftColumn).down(verticalCenteringOffset) } LayerInfo(newVertexInfos.toMap) } @@ -217,7 +217,8 @@ class Layouter(vertexRenderingStrategy: VertexRenderingStrategy[_], vertical: Bo private case class LayerLayoutResult( drawingElements: List[DrawingElement], layerInfo: LayerInfo, - updatedIncompletedEdges: Map[DummyVertex, List[Point]]) + updatedIncompletedEdges: Map[DummyVertex, List[Point]] + ) /** * 1) Decide the (vertical) order of edges coming into the currentLayer -- that is, what row they bend on (if required) @@ -233,7 +234,8 @@ class Layouter(vertexRenderingStrategy: VertexRenderingStrategy[_], vertical: Bo previousLayerInfo: LayerInfo, currentLayerInfo: LayerInfo, edges: List[Edge], - incompleteEdges: Map[DummyVertex, List[Point]]): LayerLayoutResult = { + incompleteEdges: Map[DummyVertex, List[Point]] + ): LayerLayoutResult = { val edgeInfos: List[EdgeInfo] = makeEdgeInfos(edges, previousLayerInfo, currentLayerInfo) @@ -245,7 +247,7 @@ class Layouter(vertexRenderingStrategy: VertexRenderingStrategy[_], vertical: Bo val updatedIncompleteEdges: Map[DummyVertex, List[Point]] = for ((EdgeInfo(_, finishVertex: DummyVertex, _, _, _), points) ← edgeInfoToPoints) - yield finishVertex -> points + yield finishVertex → points val updatedLayerInfo = currentLayerInfo.down(edgeBendCalculator.edgeZoneBottomRow + 1) @@ -317,7 +319,7 @@ class Layouter(vertexRenderingStrategy: VertexRenderingStrategy[_], vertical: Bo val p4 = p3.up(vertexInfo.boxRegion.height + 2 * (selfEdgeIndex + 1) + 1) val p5 = p4.left(p4.column - inPort.column) val p6 = inPort.up(1) - EdgeDrawingElement(List(p1, p2, p3, p4, p5, p6), false, true) + EdgeDrawingElement(List(p1, p2, p3, p4, p5, p6), hasArrow1 = false, hasArrow2 = true) } private def makeVertexElements(layerInfo: LayerInfo): List[VertexDrawingElement] = diff --git a/src/main/scala/com/github/mdr/ascii/layout/coordAssign/PortNudger.scala b/src/main/scala/com/github/mdr/ascii/layout/coordAssign/PortNudger.scala index 7c9f345..fceac37 100644 --- a/src/main/scala/com/github/mdr/ascii/layout/coordAssign/PortNudger.scala +++ b/src/main/scala/com/github/mdr/ascii/layout/coordAssign/PortNudger.scala @@ -36,7 +36,7 @@ object PortNudger { val previousLayerInfoOpt = previousLayerOpt.map(updatedLayerInfos) val currentLayerInfo = layerInfos(currentLayer) val updatedLayerInfo = nudgeLayer(previousLayerInfoOpt, currentLayerInfo) - updatedLayerInfos += currentLayer -> updatedLayerInfo + updatedLayerInfos += currentLayer → updatedLayerInfo } updatedLayerInfos } @@ -53,7 +53,7 @@ object PortNudger { val newVertexInfos = currentLayerInfo.vertexInfos.map { case (vertex, vertexInfo) ⇒ - vertex -> nudgeVertexInfo(vertex, vertexInfo, previousLayerInfoOpt, previousEdgeColumns) + vertex → nudgeVertexInfo(vertex, vertexInfo, previousLayerInfoOpt, previousEdgeColumns) } currentLayerInfo.copy(vertexInfos = newVertexInfos) } @@ -67,14 +67,14 @@ object PortNudger { val newInEdgeToPortMap = vertexInfo.inEdgeToPortMap.map { case (edge, port) if shouldNudge(edge, port) ⇒ nudgedColumns += port.column - edge -> port.right + edge → port.right case pair ⇒ pair } // We need to also nudge the out ports for dummy vertices we nudged earlier val newOutEdgeToPortMap = vertex match { case _: DummyVertex ⇒ vertexInfo.outEdgeToPortMap.map { - case (edge, port) if nudgedColumns contains port.column ⇒ edge -> port.right + case (edge, port) if nudgedColumns contains port.column ⇒ edge → port.right case pair ⇒ pair } case _: RealVertex ⇒ vertexInfo.outEdgeToPortMap diff --git a/src/main/scala/com/github/mdr/ascii/layout/coordAssign/VertexInfo.scala b/src/main/scala/com/github/mdr/ascii/layout/coordAssign/VertexInfo.scala index 2c72a4f..2b13009 100644 --- a/src/main/scala/com/github/mdr/ascii/layout/coordAssign/VertexInfo.scala +++ b/src/main/scala/com/github/mdr/ascii/layout/coordAssign/VertexInfo.scala @@ -20,7 +20,8 @@ case class VertexInfo( inEdgeToPortMap: Map[Edge, Point], outEdgeToPortMap: Map[Edge, Point], selfInPorts: List[Point], - selfOutPorts: List[Point]) + selfOutPorts: List[Point] +) extends Translatable[VertexInfo] { /** @@ -35,7 +36,8 @@ case class VertexInfo( Utils.transformValues(inEdgeToPortMap)(_.translate(down, right)), Utils.transformValues(outEdgeToPortMap)(_.translate(down, right)), selfInPorts.map(_.translate(down, right)), - selfOutPorts.map(_.translate(down, right))) + selfOutPorts.map(_.translate(down, right)) + ) def setLeft(column: Int): VertexInfo = translate(right = column - boxRegion.leftColumn) diff --git a/src/main/scala/com/github/mdr/ascii/layout/cycles/CycleRemovalInfo.scala b/src/main/scala/com/github/mdr/ascii/layout/cycles/CycleRemovalInfo.scala index 199fbda..6cc9efc 100644 --- a/src/main/scala/com/github/mdr/ascii/layout/cycles/CycleRemovalInfo.scala +++ b/src/main/scala/com/github/mdr/ascii/layout/cycles/CycleRemovalInfo.scala @@ -68,8 +68,8 @@ class CycleRemovalInfo[V](graph: Graph[V]) { } private def addVertexToDegreeDiffMaps(v: V, degreeDiff: Int) = { - degreeDiffToVertices += degreeDiff -> (v :: degreeDiffToVertices.getOrElse(degreeDiff, Nil)) - verticesToDegreeDiff += v -> degreeDiff + degreeDiffToVertices += degreeDiff → (v :: degreeDiffToVertices.getOrElse(degreeDiff, Nil)) + verticesToDegreeDiff += v → degreeDiff } private def removeVertexFromDegreeDiffMaps(v: V): Int = { @@ -79,7 +79,7 @@ class CycleRemovalInfo[V](graph: Graph[V]) { if (updatedVertices.isEmpty) degreeDiffToVertices -= degreeDiff else - degreeDiffToVertices += degreeDiff -> updatedVertices + degreeDiffToVertices += degreeDiff → updatedVertices verticesToDegreeDiff -= v degreeDiff } diff --git a/src/main/scala/com/github/mdr/ascii/layout/drawing/DrawingElement.scala b/src/main/scala/com/github/mdr/ascii/layout/drawing/DrawingElement.scala index 96adab4..39655c3 100644 --- a/src/main/scala/com/github/mdr/ascii/layout/drawing/DrawingElement.scala +++ b/src/main/scala/com/github/mdr/ascii/layout/drawing/DrawingElement.scala @@ -50,7 +50,8 @@ case class VertexDrawingElement(region: Region, textLines: List[String]) case class EdgeDrawingElement( bendPoints: List[Point], hasArrow1: Boolean, - hasArrow2: Boolean) + hasArrow2: Boolean +) extends DrawingElement with Translatable[EdgeDrawingElement] with Transposable[EdgeDrawingElement] { lazy val points: List[Point] = segments.flatMap(_.points).distinct diff --git a/src/main/scala/com/github/mdr/ascii/layout/drawing/EdgeElevator.scala b/src/main/scala/com/github/mdr/ascii/layout/drawing/EdgeElevator.scala index f186103..d6f218c 100644 --- a/src/main/scala/com/github/mdr/ascii/layout/drawing/EdgeElevator.scala +++ b/src/main/scala/com/github/mdr/ascii/layout/drawing/EdgeElevator.scala @@ -38,7 +38,7 @@ object EdgeElevator { for { segmentInfo ← segmentInfos.sortBy(_.row) updatedEdgeSegment ← elevate(segmentInfo, edgeTracker) - } segmentUpdates = addToMultimap(segmentUpdates, segmentInfo.edgeElement, segmentInfo.segment2 -> updatedEdgeSegment) + } segmentUpdates = addToMultimap(segmentUpdates, segmentInfo.edgeElement, segmentInfo.segment2 → updatedEdgeSegment) for ((edge, updates) ← segmentUpdates) currentDrawing = currentDrawing.replaceElement(edge, updateEdge(edge, updates)) diff --git a/src/main/scala/com/github/mdr/ascii/layout/drawing/EdgeSegmentInfo.scala b/src/main/scala/com/github/mdr/ascii/layout/drawing/EdgeSegmentInfo.scala index 03cdcb0..becc249 100644 --- a/src/main/scala/com/github/mdr/ascii/layout/drawing/EdgeSegmentInfo.scala +++ b/src/main/scala/com/github/mdr/ascii/layout/drawing/EdgeSegmentInfo.scala @@ -11,7 +11,8 @@ package com.github.mdr.ascii.layout.drawing * v */ case class EdgeSegmentInfo( - edgeElement: EdgeDrawingElement, segment1: EdgeSegment, segment2: EdgeSegment, segment3: EdgeSegment) { + edgeElement: EdgeDrawingElement, segment1: EdgeSegment, segment2: EdgeSegment, segment3: EdgeSegment +) { def row = segment2.start.row diff --git a/src/main/scala/com/github/mdr/ascii/layout/drawing/KinkRemover.scala b/src/main/scala/com/github/mdr/ascii/layout/drawing/KinkRemover.scala index fc5612b..3435ca5 100644 --- a/src/main/scala/com/github/mdr/ascii/layout/drawing/KinkRemover.scala +++ b/src/main/scala/com/github/mdr/ascii/layout/drawing/KinkRemover.scala @@ -40,7 +40,7 @@ object KinkRemover { for { edgeElement ← drawing.edgeElements newEdgeElement ← removeKink(edgeElement, drawing, edgeTracker) - } return Some(edgeElement -> newEdgeElement) + } return Some(edgeElement → newEdgeElement) None } diff --git a/src/main/scala/com/github/mdr/ascii/layout/layering/LayeringCalculator.scala b/src/main/scala/com/github/mdr/ascii/layout/layering/LayeringCalculator.scala index 95b6a93..cd199c2 100644 --- a/src/main/scala/com/github/mdr/ascii/layout/layering/LayeringCalculator.scala +++ b/src/main/scala/com/github/mdr/ascii/layout/layering/LayeringCalculator.scala @@ -70,7 +70,7 @@ class LayeringCalculator[V] { if (count == 1) revEdges -= graphEdge else - revEdges += graphEdge -> (count - 1) + revEdges += graphEdge → (count - 1) true case None ⇒ false @@ -83,7 +83,7 @@ class LayeringCalculator[V] { private def makeRealVertices(cycleRemovalResult: CycleRemovalResult[V]): Map[V, RealVertex] = cycleRemovalResult.dag.vertices.map { v ⇒ val selfEdges = cycleRemovalResult.countSelfEdges(v) - v -> new RealVertex(v, selfEdges) + v → new RealVertex(v, selfEdges) }.toMap } \ No newline at end of file diff --git a/src/main/scala/com/github/mdr/ascii/layout/layering/LongestDistancesToSinkCalculator.scala b/src/main/scala/com/github/mdr/ascii/layout/layering/LongestDistancesToSinkCalculator.scala index 04d0517..ac061ea 100644 --- a/src/main/scala/com/github/mdr/ascii/layout/layering/LongestDistancesToSinkCalculator.scala +++ b/src/main/scala/com/github/mdr/ascii/layout/layering/LongestDistancesToSinkCalculator.scala @@ -20,7 +20,7 @@ object LongestDistancesToSinkCalculator { /** * The current known longest distances to a sink. */ - var distances: Map[V, Int] = graph.vertices.map(_ -> 0).toMap + var distances: Map[V, Int] = graph.vertices.map(_ → 0).toMap var boundary = finalisedVertices @@ -31,7 +31,7 @@ object LongestDistancesToSinkCalculator { v1 ← graph.inVertices(v2) } { val newDistance = math.max(distances(v1), distances(v2) + 1) - distances += v1 -> newDistance + distances += v1 → newDistance if (graph.outVertices(v1).forall(finalisedVertices)) { finalisedVertices += v1 newBoundary += v1 diff --git a/src/main/scala/com/github/mdr/ascii/layout/prefs/LayoutPrefsImpl.scala b/src/main/scala/com/github/mdr/ascii/layout/prefs/LayoutPrefsImpl.scala index e53563e..ca30476 100644 --- a/src/main/scala/com/github/mdr/ascii/layout/prefs/LayoutPrefsImpl.scala +++ b/src/main/scala/com/github/mdr/ascii/layout/prefs/LayoutPrefsImpl.scala @@ -17,5 +17,6 @@ case class LayoutPrefsImpl( unicode: Boolean = true, doubleVertices: Boolean = false, rounded: Boolean = false, // Typical Windows fonts don't render bend characters correctly - explicitAsciiBends: Boolean = false) + explicitAsciiBends: Boolean = false +) extends LayoutPrefs diff --git a/src/main/scala/com/github/mdr/ascii/util/QuadTree.scala b/src/main/scala/com/github/mdr/ascii/util/QuadTree.scala index 07c56b8..589859a 100644 --- a/src/main/scala/com/github/mdr/ascii/util/QuadTree.scala +++ b/src/main/scala/com/github/mdr/ascii/util/QuadTree.scala @@ -33,7 +33,8 @@ class QuadTree[T <: HasRegion](dimension: Dimension) { } private case class QuadNode( - region: Region, items: Set[T], topLeft: Node, topRight: Node, bottomLeft: Node, bottomRight: Node) + region: Region, items: Set[T], topLeft: Node, topRight: Node, bottomLeft: Node, bottomRight: Node + ) extends Node { override def childNodes: List[Node] = List(topLeft, topRight, bottomLeft, bottomRight) diff --git a/src/main/scala/com/github/mdr/ascii/util/Utils.scala b/src/main/scala/com/github/mdr/ascii/util/Utils.scala index 4a1c23e..afef559 100644 --- a/src/main/scala/com/github/mdr/ascii/util/Utils.scala +++ b/src/main/scala/com/github/mdr/ascii/util/Utils.scala @@ -44,7 +44,7 @@ object Utils { } def makeMap[T, U](s: Iterable[T], f: T ⇒ U): Map[T, U] = - s.map(t ⇒ t -> f(t))(collection.breakOut) + s.map(t ⇒ t → f(t))(collection.breakOut) def signum(x: Int) = x match { case _ if x < 0 ⇒ -1 @@ -64,6 +64,6 @@ object Utils { xs.map { t ⇒ if (fn isDefinedAt t) fn(t) else t } def addToMultimap[K, V](m: Map[K, List[V]], k: K, v: V): Map[K, List[V]] = - m + (k -> (v :: m.getOrElse(k, Nil))) + m + (k → (v :: m.getOrElse(k, Nil))) } \ No newline at end of file diff --git a/src/test/scala/com/github/mdr/ascii/RunLayout.scala b/src/test/scala/com/github/mdr/ascii/RunLayout.scala index a0abc88..7cd0906 100644 --- a/src/test/scala/com/github/mdr/ascii/RunLayout.scala +++ b/src/test/scala/com/github/mdr/ascii/RunLayout.scala @@ -18,16 +18,19 @@ object RunLayout extends App { val graph1 = Graph( vertices = Set( - 1, 2, 3, 4, 5, 6, 7, 8123, 9, 120), + 1, 2, 3, 4, 5, 6, 7, 8123, 9, 120 + ), edges = List( - 1 -> 3, - 1 -> 4, - 3 -> 8123, - 2 -> 5, - 2 -> 6, - 3 -> 7, - 5 -> 9, - 7 -> 9)) + 1 → 3, + 1 → 4, + 3 → 8123, + 2 → 5, + 2 → 6, + 3 → 7, + 5 → 9, + 7 → 9 + ) + ) val V1 = "111111" val V2 = "22222222" @@ -39,16 +42,19 @@ object RunLayout extends App { val graph2 = Graph( vertices = Set( - V1, V2, V3, V4, V5, V6, V7), + V1, V2, V3, V4, V5, V6, V7 + ), edges = List( - V1 -> V2, - V7 -> V1, - V1 -> V3, - V1 -> V4, - V2 -> V5, - V2 -> V6, - V6 -> V1, - V3 -> V7)) + V1 → V2, + V7 → V1, + V1 → V3, + V1 → V4, + V2 → V5, + V2 → V6, + V6 → V1, + V3 → V7 + ) + ) val graph3 = Graph.fromDiagram( """ @@ -108,7 +114,8 @@ object RunLayout extends App { |org.apache.geronimo.specs| |org.apache.lucene| |org.scala-lang| | 1.1.1 | | 3.5.0 | | 2.9.1 | +-------------------------+ +-----------------+ +--------------+ -""") +""" + ) val v1 = """Person |──────────── @@ -123,7 +130,7 @@ object RunLayout extends App { |name = "Thingies Ltd" |employees = 123""".stripMargin val vertices4 = Set(v1, v2, v3) - val edges4 = List(v1 -> v2, v3 -> v1, v3 -> v2) + val edges4 = List(v1 → v2, v3 → v1, v3 → v2) val graph4 = Graph(vertices4, edges4) diff --git a/src/test/scala/com/github/mdr/ascii/diagram/parser/DiagramParserTest.scala b/src/test/scala/com/github/mdr/ascii/diagram/parser/DiagramParserTest.scala index ddc5875..04f3ccb 100644 --- a/src/test/scala/com/github/mdr/ascii/diagram/parser/DiagramParserTest.scala +++ b/src/test/scala/com/github/mdr/ascii/diagram/parser/DiagramParserTest.scala @@ -1,13 +1,13 @@ package com.github.mdr.ascii.diagram.parser -import org.scalatest.matchers.ShouldMatchers -import org.scalatest.FlatSpec +import org.scalatest.{FlatSpec, Matchers} import com.github.mdr.ascii.diagram.Diagram import com.github.mdr.ascii.diagram.Box import com.github.mdr.ascii.util.Utils + import scala.io.Source -class GraphDiagramParserTest extends FlatSpec with ShouldMatchers { +class GraphDiagramParserTest extends FlatSpec with Matchers { "Parser" should "parse labels" in { @@ -47,7 +47,7 @@ class GraphDiagramParserTest extends FlatSpec with ShouldMatchers { |C| |D| +-+ +-+ """) - checkEdges(diagram, "A" -> "D", "B" -> "C") + checkEdges(diagram, "A" → "D", "B" → "C") } it should "support Unicode box-drawing characters" in { @@ -65,7 +65,7 @@ class GraphDiagramParserTest extends FlatSpec with ShouldMatchers { ╰───╯ ╰───╯""") diagram.allBoxes.map(text).toSet should equal(Set("A", "B", "C")) - checkEdges(diagram, "A" -> "B", "A" -> "C") + checkEdges(diagram, "A" → "B", "A" → "C") } it should "support Unicode box-drawing characters 2" in { @@ -79,7 +79,7 @@ class GraphDiagramParserTest extends FlatSpec with ShouldMatchers { ╰─>│fb│ ╰──╯ """) - checkEdges(diagram, "feadda" -> "ee", "feadda" -> "db\nfb") + checkEdges(diagram, "feadda" → "ee", "feadda" → "db\nfb") } it should "support Unicode box-drawing characters 3" in { @@ -93,7 +93,7 @@ class GraphDiagramParserTest extends FlatSpec with ShouldMatchers { ╰──────╯ """) - checkEdges(diagram, "foobar" -> "xx", "foobar" -> "yy") + checkEdges(diagram, "foobar" → "xx", "foobar" → "yy") } it should "parse an empty box" in { @@ -113,7 +113,7 @@ class GraphDiagramParserTest extends FlatSpec with ShouldMatchers { ╰─╯╰─╯ """) diagram.allBoxes.map(text).toSet should equal(Set("A", "B")) - checkEdges(diagram, "A" -> "B") + checkEdges(diagram, "A" → "B") } it should "not find an edge between adjacent connected boxes (ASCII)" in { @@ -133,7 +133,7 @@ class GraphDiagramParserTest extends FlatSpec with ShouldMatchers { │foobar├──╯ │yyy│ ╰──────╯ ╰───╯ """) - checkEdges(diagram, "foobar" -> "yyy") + checkEdges(diagram, "foobar" → "yyy") } it should "handle misc arrows" in { @@ -154,15 +154,17 @@ class GraphDiagramParserTest extends FlatSpec with ShouldMatchers { │ │ ╰────┤ │ ╰──────╯ ╰──╯ """) - checkEdges(diagram, - "AA" -> "FF", - "AA" -> "D", - "BB" -> "AA", - "BB" -> "EE", - "CC" -> "D", - "D" -> "BB", - "D" -> "EE", - "EE" -> "D") + checkEdges( + diagram, + "AA" → "FF", + "AA" → "D", + "BB" → "AA", + "BB" → "EE", + "CC" → "D", + "D" → "BB", + "D" → "EE", + "EE" → "D" + ) } @@ -192,14 +194,16 @@ class GraphDiagramParserTest extends FlatSpec with ShouldMatchers { │ N │ └─────┘ """) - checkEdges(diagram, - "P" -> "T", - "P" -> "O", - "P" -> "N", - "T" -> "O", - "H" -> "T", - "T" -> "O", - "O" -> "N") + checkEdges( + diagram, + "P" → "T", + "P" → "O", + "P" → "N", + "T" → "O", + "H" → "T", + "T" → "O", + "O" → "N" + ) } it should "support ASCII edge bend characters" in { @@ -213,7 +217,7 @@ class GraphDiagramParserTest extends FlatSpec with ShouldMatchers { | |-----/ +-+ """) - checkEdges(diagram, "I" -> "H", "H" -> "D", "I" -> "D") + checkEdges(diagram, "I" → "H", "H" → "D", "I" → "D") } it should "support ASCII edge bend characters 2" in { @@ -236,7 +240,7 @@ class GraphDiagramParserTest extends FlatSpec with ShouldMatchers { | | +-+ """) - checkEdges(diagram, "A" -> "D", "E" -> "W", "D" -> "A", "A" -> "M", "A" -> "M", "M" -> "W") + checkEdges(diagram, "A" → "D", "E" → "W", "D" → "A", "A" → "M", "A" → "M", "M" → "W") } it should "support ASCII edge bend characters 3" in { @@ -259,13 +263,13 @@ class GraphDiagramParserTest extends FlatSpec with ShouldMatchers { |S| +-+ """) - checkEdges(diagram, "F" -> "L", - "J" -> "K", - "L" -> "K", - "K" -> "J", - "F" -> "K", - "J" -> "F", - "K" -> "L") + checkEdges(diagram, "F" → "L", + "J" → "K", + "L" → "K", + "K" → "J", + "F" → "K", + "J" → "F", + "K" → "L") } it should "support ASCII edge bend characters 4" in { @@ -286,10 +290,12 @@ class GraphDiagramParserTest extends FlatSpec with ShouldMatchers { | C | | H | +-----+ +-----+ """) - checkEdges(diagram, - "R" -> "C", - "I" -> "H", - "D" -> "H") + checkEdges( + diagram, + "R" → "C", + "I" → "H", + "D" → "H" + ) } it should "Parse double-edged boxes" in { @@ -309,7 +315,7 @@ class GraphDiagramParserTest extends FlatSpec with ShouldMatchers { } private def checkEdges(diagram: Diagram, expectedEdges: (String, String)*) { - val edges = diagram.allEdges.map(e ⇒ text(e.box1) -> text(e.box2)) + val edges = diagram.allEdges.map(e ⇒ text(e.box1) → text(e.box2)) edges.toSet should equal(expectedEdges.toSet) Utils.multisetCompare(edges, expectedEdges.toList) should be(true) } diff --git a/src/test/scala/com/github/mdr/ascii/diagram/parser/Issue1DirectedEdgeNotParsedTest.scala b/src/test/scala/com/github/mdr/ascii/diagram/parser/Issue1DirectedEdgeNotParsedTest.scala index 648fdd7..bd43d73 100644 --- a/src/test/scala/com/github/mdr/ascii/diagram/parser/Issue1DirectedEdgeNotParsedTest.scala +++ b/src/test/scala/com/github/mdr/ascii/diagram/parser/Issue1DirectedEdgeNotParsedTest.scala @@ -1,11 +1,10 @@ package com.github.mdr.ascii.diagram.parser -import org.scalatest.matchers.ShouldMatchers -import org.scalatest.FlatSpec +import org.scalatest.{FlatSpec, Matchers} import com.github.mdr.ascii.graph.Graph import com.github.mdr.ascii.diagram.Diagram -class Issue1DirectedEdgeNotParsedTest extends FlatSpec with ShouldMatchers { +class Issue1DirectedEdgeNotParsedTest extends FlatSpec with Matchers { "Parser" should "detect directed edge" in { diff --git a/src/test/scala/com/github/mdr/ascii/graph/GraphGenerators.scala b/src/test/scala/com/github/mdr/ascii/graph/GraphGenerators.scala index d2f3757..d320ca1 100644 --- a/src/test/scala/com/github/mdr/ascii/graph/GraphGenerators.scala +++ b/src/test/scala/com/github/mdr/ascii/graph/GraphGenerators.scala @@ -1,13 +1,15 @@ package com.github.mdr.ascii.graph import org.scalacheck._ -import org.scalacheck.Gen.Params +import org.scalacheck.Gen.Parameters + import scala.util.Random import com.github.mdr.ascii.layout.cycles.CycleRemover +import org.scalacheck.rng.Seed object GraphGenerators { - implicit val graphGen: Gen[Graph[String]] = Gen { p: Params ⇒ Some(RandomGraph.randomGraph(new Random(p.rng))) } + implicit val graphGen: Gen[Graph[String]] = Gen.choose(0, 9999999).map { seed ⇒ RandomGraph.randomGraph(new Random(scala.util.Random.nextLong)) } implicit val arbitraryGraph = Arbitrary(graphGen) diff --git a/src/test/scala/com/github/mdr/ascii/graph/TopologicalSortSpecification.scala b/src/test/scala/com/github/mdr/ascii/graph/TopologicalSortSpecification.scala index b28764e..eafa8e0 100644 --- a/src/test/scala/com/github/mdr/ascii/graph/TopologicalSortSpecification.scala +++ b/src/test/scala/com/github/mdr/ascii/graph/TopologicalSortSpecification.scala @@ -1,14 +1,9 @@ package com.github.mdr.ascii.graph -import org.scalacheck.Arbitrary -import org.scalacheck.Gen -import org.scalacheck.Gen.Params -import org.scalacheck.Prop.forAll -import org.scalacheck.Properties -import org.scalacheck.Shrink -import com.github.mdr.ascii.util.Utils import com.github.mdr.ascii.graph.GraphGenerators._ import com.github.mdr.ascii.layout.cycles.CycleRemover +import org.scalacheck.Prop.forAll +import org.scalacheck.Properties object TopologicalSortSpecification extends Properties("Topological sort") { diff --git a/src/test/scala/com/github/mdr/ascii/graph/TopologicalSortTest.scala b/src/test/scala/com/github/mdr/ascii/graph/TopologicalSortTest.scala index ccdaa2e..433713f 100644 --- a/src/test/scala/com/github/mdr/ascii/graph/TopologicalSortTest.scala +++ b/src/test/scala/com/github/mdr/ascii/graph/TopologicalSortTest.scala @@ -1,10 +1,9 @@ package com.github.mdr.ascii.graph -import org.scalatest.FlatSpec -import org.scalatest.matchers.ShouldMatchers +import org.scalatest.{FlatSpec, Matchers} import org.scalatest.prop.Checkers -class TopologicalSortTest extends FlatSpec with ShouldMatchers with Checkers { +class TopologicalSortTest extends FlatSpec with Matchers with Checkers { check(""" +-+ +-+ diff --git a/src/test/scala/com/github/mdr/ascii/gui/GUI.scala b/src/test/scala/com/github/mdr/ascii/gui/GUI.scala index e9a3bf1..d2930e1 100644 --- a/src/test/scala/com/github/mdr/ascii/gui/GUI.scala +++ b/src/test/scala/com/github/mdr/ascii/gui/GUI.scala @@ -107,7 +107,8 @@ object Frame extends JFrame { vertical = verticalBox.isSelected, doubleVertices = doubleVerticesBox.isSelected, rounded = roundedBox.isSelected, - explicitAsciiBends = explicitAsciiBendsBox.isSelected) + explicitAsciiBends = explicitAsciiBendsBox.isSelected + ) } diff --git a/src/test/scala/com/github/mdr/ascii/layout/Issue3InfiniteLoopTest.scala b/src/test/scala/com/github/mdr/ascii/layout/Issue3InfiniteLoopTest.scala index da17a30..65ce24a 100644 --- a/src/test/scala/com/github/mdr/ascii/layout/Issue3InfiniteLoopTest.scala +++ b/src/test/scala/com/github/mdr/ascii/layout/Issue3InfiniteLoopTest.scala @@ -1,15 +1,14 @@ package com.github.mdr.ascii.layout -import org.scalatest.matchers.ShouldMatchers -import org.scalatest.FlatSpec +import org.scalatest.{FlatSpec, Matchers} import com.github.mdr.ascii.graph.Graph // https://github.com/mdr/ascii-graphs/issues/3 -class Issue3InfiniteLoopTest extends FlatSpec with ShouldMatchers { +class Issue3InfiniteLoopTest extends FlatSpec with Matchers { "Layouter" should "not go into an infinite loop" in { val v = Set("1", "2", "3", "7", "9") - val e = List("1" -> "3", "1" -> "7", "3" -> "2", "3" -> "9", "7" -> "9", "7" -> "2") + val e = List("1" → "3", "1" → "7", "3" → "2", "3" → "9", "7" → "9", "7" → "2") val graph = Graph(vertices = v, edges = e) GraphLayout.renderGraph(graph) @@ -19,9 +18,9 @@ class Issue3InfiniteLoopTest extends FlatSpec with ShouldMatchers { "Layouter" should "really not go into an infinite loop this time" in { val v = Set("1", "2", "3", "4", "5", "6", "7", "8", "9", "10") - val e = List("1" -> "2", "1" -> "3", "1" -> "4", "1" -> "6", "1" -> "7", "1" -> "10", - "2" -> "3", "2" -> "4", "2" -> "5", "2" -> "6", "2" -> "7", "2" -> "8", "2" -> "10", - "3" -> "9", "4" -> "5", "4" -> "8", "7" -> "9") + val e = List("1" → "2", "1" → "3", "1" → "4", "1" → "6", "1" → "7", "1" → "10", + "2" → "3", "2" → "4", "2" → "5", "2" → "6", "2" → "7", "2" → "8", "2" → "10", + "3" → "9", "4" → "5", "4" → "8", "7" → "9") val graph = Graph(vertices = v, edges = e) GraphLayout.renderGraph(graph) diff --git a/src/test/scala/com/github/mdr/ascii/layout/RoundTripTest.scala b/src/test/scala/com/github/mdr/ascii/layout/RoundTripTest.scala index 784dbe1..59bde5f 100644 --- a/src/test/scala/com/github/mdr/ascii/layout/RoundTripTest.scala +++ b/src/test/scala/com/github/mdr/ascii/layout/RoundTripTest.scala @@ -1,11 +1,10 @@ package com.github.mdr.ascii.layout -import org.scalatest.FlatSpec -import org.scalatest.matchers.ShouldMatchers +import org.scalatest.{FlatSpec, Matchers} import com.github.mdr.ascii.graph.Graph import com.github.mdr.ascii.layout.RoundTripSpecification._ -class RoundTripTest extends FlatSpec with ShouldMatchers { +class RoundTripTest extends FlatSpec with Matchers { "Round trip" should ("not overwrite an arrow") in { checkRoundTrip(Graph.fromDiagram(""" diff --git a/src/test/scala/com/github/mdr/ascii/layout/cycles/CycleRemoverSpecification.scala b/src/test/scala/com/github/mdr/ascii/layout/cycles/CycleRemoverSpecification.scala index 7b356c6..0543eff 100644 --- a/src/test/scala/com/github/mdr/ascii/layout/cycles/CycleRemoverSpecification.scala +++ b/src/test/scala/com/github/mdr/ascii/layout/cycles/CycleRemoverSpecification.scala @@ -1,18 +1,10 @@ package com.github.mdr.ascii.layout.cycles -import scala.util.Random._ - -import org.scalacheck.Arbitrary -import org.scalacheck.Gen -import org.scalacheck.Gen.Params +import com.github.mdr.ascii.graph.{Graph, GraphUtils} +import com.github.mdr.ascii.graph.GraphGenerators._ +import com.github.mdr.ascii.util.Utils import org.scalacheck.Prop.forAll import org.scalacheck.Properties -import org.scalacheck.Shrink - -import com.github.mdr.ascii.graph.Graph -import com.github.mdr.ascii.graph.GraphUtils -import com.github.mdr.ascii.util.Utils -import com.github.mdr.ascii.graph.GraphGenerators._ object CycleRemoverSpecification extends Properties("CycleRemover") { diff --git a/src/test/scala/com/github/mdr/ascii/layout/cycles/CycleRemoverTest.scala b/src/test/scala/com/github/mdr/ascii/layout/cycles/CycleRemoverTest.scala index 201c4b1..60276e7 100644 --- a/src/test/scala/com/github/mdr/ascii/layout/cycles/CycleRemoverTest.scala +++ b/src/test/scala/com/github/mdr/ascii/layout/cycles/CycleRemoverTest.scala @@ -1,13 +1,11 @@ package com.github.mdr.ascii.layout.cycles -import org.scalatest.FlatSpec -import org.scalatest.matchers.ShouldMatchers - +import org.scalatest.{FlatSpec, Matchers} import com.github.mdr.ascii.graph.Graph import com.github.mdr.ascii.graph.GraphUtils import com.github.mdr.ascii.util.Utils -class CycleRemoverTest extends FlatSpec with ShouldMatchers { +class CycleRemoverTest extends FlatSpec with Matchers { check(""" +-+ +-+ diff --git a/src/test/scala/com/github/mdr/ascii/layout/cycles/GraphReflowTest.scala b/src/test/scala/com/github/mdr/ascii/layout/cycles/GraphReflowTest.scala index eba1d34..732a9e5 100644 --- a/src/test/scala/com/github/mdr/ascii/layout/cycles/GraphReflowTest.scala +++ b/src/test/scala/com/github/mdr/ascii/layout/cycles/GraphReflowTest.scala @@ -1,12 +1,10 @@ package com.github.mdr.ascii.layout.cycles -import org.scalatest.FlatSpec -import org.scalatest.matchers.ShouldMatchers - +import org.scalatest.{FlatSpec, Matchers} import com.github.mdr.ascii.graph.Graph import com.github.mdr.ascii.util.Utils -class GraphReflowTest extends FlatSpec with ShouldMatchers { +class GraphReflowTest extends FlatSpec with Matchers { reflowingGraph(""" +-+ +-+ @@ -28,7 +26,7 @@ class GraphReflowTest extends FlatSpec with ShouldMatchers { +-+ +-+ |A|-->|B| +-+ +-+ """). - havingReversedEdges("A" -> "B") + havingReversedEdges("A" → "B") reflowingGraph(""" +-+ +-+ +-+ @@ -45,7 +43,7 @@ class GraphReflowTest extends FlatSpec with ShouldMatchers { ^ | | | ------------- """). - havingReversedEdges("B" -> "A", "C" -> "B") + havingReversedEdges("B" → "A", "C" → "B") reflowingGraph(""" +-+ +-+ @@ -62,7 +60,7 @@ class GraphReflowTest extends FlatSpec with ShouldMatchers { | ^ | | ------- """). - havingReversedEdges("A" -> "C") + havingReversedEdges("A" → "C") reflowingGraph(""" +-+ +-+ @@ -81,7 +79,7 @@ class GraphReflowTest extends FlatSpec with ShouldMatchers { | | | | | ------- | --------------- """). - havingReversedEdges("A" -> "C", "A" -> "C") + havingReversedEdges("A" → "C", "A" → "C") reflowingGraph(""" +-+ diff --git a/src/test/scala/com/github/mdr/ascii/layout/layering/AssignLayersSpecification.scala b/src/test/scala/com/github/mdr/ascii/layout/layering/AssignLayersSpecification.scala index b958939..093d845 100644 --- a/src/test/scala/com/github/mdr/ascii/layout/layering/AssignLayersSpecification.scala +++ b/src/test/scala/com/github/mdr/ascii/layout/layering/AssignLayersSpecification.scala @@ -1,11 +1,7 @@ package com.github.mdr.ascii.layout.layering -import org.scalacheck.Arbitrary -import org.scalacheck.Gen -import org.scalacheck.Gen.Params import org.scalacheck.Prop.forAll import org.scalacheck.Properties -import org.scalacheck.Shrink import com.github.mdr.ascii.graph.Graph import com.github.mdr.ascii.graph.GraphGenerators._ import com.github.mdr.ascii.layout.cycles.CycleRemover @@ -19,7 +15,7 @@ object AssignLayersSpecification extends Properties("Assign Layers") { (for { (layer, index) ← layering.layers.zipWithIndex v ← layer.vertices - } yield v -> index).toMap + } yield v → index).toMap cycleRemovalResult.dag.edges.forall { case (from, to) ⇒ getLayerIndex(realVertices(from)) < getLayerIndex(realVertices(to)) diff --git a/src/test/scala/com/github/mdr/ascii/layout/layering/CrossingCalculatorTest.scala b/src/test/scala/com/github/mdr/ascii/layout/layering/CrossingCalculatorTest.scala index 6385167..0c9b235 100644 --- a/src/test/scala/com/github/mdr/ascii/layout/layering/CrossingCalculatorTest.scala +++ b/src/test/scala/com/github/mdr/ascii/layout/layering/CrossingCalculatorTest.scala @@ -1,14 +1,12 @@ package com.github.mdr.ascii.layout.layering -import org.scalatest.FlatSpec -import org.scalatest.matchers.ShouldMatchers - +import org.scalatest.{FlatSpec, Matchers} import com.github.mdr.ascii.graph.GraphUtils import com.github.mdr.ascii.graph.Graph import com.github.mdr.ascii.util.Utils import com.github.mdr.ascii.layout.cycles.CycleRemover -class CrossingCalculatorTest extends FlatSpec with ShouldMatchers { +class CrossingCalculatorTest extends FlatSpec with Matchers { // Note: layer ordering in test data is done alphabetically diff --git a/src/test/scala/com/github/mdr/ascii/layout/layering/LongestDistanceToSinkSpecification.scala b/src/test/scala/com/github/mdr/ascii/layout/layering/LongestDistanceToSinkSpecification.scala index 5e17a35..87151cb 100644 --- a/src/test/scala/com/github/mdr/ascii/layout/layering/LongestDistanceToSinkSpecification.scala +++ b/src/test/scala/com/github/mdr/ascii/layout/layering/LongestDistanceToSinkSpecification.scala @@ -1,15 +1,10 @@ package com.github.mdr.ascii.layout.layering -import org.scalacheck.Arbitrary -import org.scalacheck.Gen -import org.scalacheck.Gen.Params import org.scalacheck.Prop.forAll import org.scalacheck.Properties -import org.scalacheck.Shrink import com.github.mdr.ascii.graph.Graph import com.github.mdr.ascii.graph.GraphGenerators._ -import com.github.mdr.ascii.layout.cycles.CycleRemover object LongestDistanceToSinkSpecification extends Properties("LongestDistanceToSink") { diff --git a/src/test/scala/com/github/mdr/ascii/layout/layering/LongestDistanceToSinkTest.scala b/src/test/scala/com/github/mdr/ascii/layout/layering/LongestDistanceToSinkTest.scala index 0843f01..30c47ef 100644 --- a/src/test/scala/com/github/mdr/ascii/layout/layering/LongestDistanceToSinkTest.scala +++ b/src/test/scala/com/github/mdr/ascii/layout/layering/LongestDistanceToSinkTest.scala @@ -1,18 +1,15 @@ package com.github.mdr.ascii.layout.layering -import org.scalatest.FlatSpec -import org.scalatest.matchers.ShouldMatchers +import org.scalatest.{FlatSpec, Matchers} import com.github.mdr.ascii.graph.Graph -import com.github.mdr.ascii.graph.GraphUtils -import com.github.mdr.ascii.util.Utils -class LongestDistanceToSinkTest extends FlatSpec with ShouldMatchers { +class LongestDistanceToSinkTest extends FlatSpec with Matchers { distancesToSinks(""" +-+ +-+ +-+ |A|-->|B|-->|C| +-+ +-+ +-+ """) shouldBe - ("A" -> 2, "B" -> 1, "C" -> 0) + ("A" → 2, "B" → 1, "C" → 0) distancesToSinks(""" +-+ +-+ +-+ @@ -21,7 +18,7 @@ class LongestDistanceToSinkTest extends FlatSpec with ShouldMatchers { | ^ | | ------------- """) shouldBe - ("A" -> 1, "B" -> 1, "C" -> 0) + ("A" → 1, "B" → 1, "C" → 0) distancesToSinks(""" +-+ +-+ +-+ @@ -30,14 +27,14 @@ class LongestDistanceToSinkTest extends FlatSpec with ShouldMatchers { | ^ | | ------------- """) shouldBe - ("A" -> 2, "B" -> 1, "C" -> 0) + ("A" → 2, "B" → 1, "C" → 0) distancesToSinks(""" +-+ |B| +-+ """) shouldBe - ("B" -> 0) + ("B" → 0) distancesToSinks("") shouldBe () diff --git a/src/test/scala/com/github/mdr/ascii/util/QuadTreeTest.scala b/src/test/scala/com/github/mdr/ascii/util/QuadTreeTest.scala index 6a0c6d6..eb9f510 100644 --- a/src/test/scala/com/github/mdr/ascii/util/QuadTreeTest.scala +++ b/src/test/scala/com/github/mdr/ascii/util/QuadTreeTest.scala @@ -1,10 +1,9 @@ package com.github.mdr.ascii.util -import org.scalatest.FlatSpec -import org.scalatest.matchers.ShouldMatchers +import org.scalatest.{FlatSpec, Matchers} import com.github.mdr.ascii.common._ -class QuadTreeTest extends FlatSpec with ShouldMatchers { +class QuadTreeTest extends FlatSpec with Matchers { "A QuadTree" should "work with one element" in { val tree = new QuadTree[Region](Dimension(16, 16))