├── .github └── workflows │ └── build.yml ├── .gitignore ├── LICENSE ├── LayoutAlgorithms_and_LayoutModel.md ├── MouseGestures.md ├── README.md ├── Structure.md ├── images ├── CircleLayout.jpg ├── ReducedEdgeCrossingCircleLayout.jpg ├── bettercircle.jpg ├── brandeskopftestgraph.jpg ├── brandeskopftestgraph.png ├── circle.jpg ├── eiglspergersugiyama.jpg ├── eiglspergersugiyama.png ├── sugiyama.jpg ├── sugiyama2.jpg ├── sugiyamabrandeskopf.jpg └── tidiertree.jpg ├── jungrapht-layout ├── package.html ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── jungrapht │ │ │ └── visualization │ │ │ └── layout │ │ │ ├── algorithms │ │ │ ├── AbstractHierarchicalMinCrossLayoutAlgorithm.java │ │ │ ├── AbstractIterativeLayoutAlgorithm.java │ │ │ ├── AbstractLayoutAlgorithm.java │ │ │ ├── AbstractTreeLayoutAlgorithm.java │ │ │ ├── Balloon.java │ │ │ ├── BalloonLayoutAlgorithm.java │ │ │ ├── CircleLayoutAlgorithm.java │ │ │ ├── DAGLayoutAlgorithm.java │ │ │ ├── EdgeAwareLayoutAlgorithm.java │ │ │ ├── EdgeAwareTreeLayoutAlgorithm.java │ │ │ ├── EdgePredicated.java │ │ │ ├── EdgeSorting.java │ │ │ ├── EiglspergerLayoutAlgorithm.java │ │ │ ├── ExtendedEiglspergerLayoutAlgorithm.java │ │ │ ├── FRLayoutAlgorithm.java │ │ │ ├── ForceAtlas2LayoutAlgorithm.java │ │ │ ├── GEMLayoutAlgorithm.java │ │ │ ├── HierarchicalMinCrossLayoutAlgorithm.java │ │ │ ├── ISOMLayoutAlgorithm.java │ │ │ ├── IterativeLayoutAlgorithm.java │ │ │ ├── KKLayoutAlgorithm.java │ │ │ ├── Layered.java │ │ │ ├── LayoutAlgorithm.java │ │ │ ├── MultiRow.java │ │ │ ├── MultiRowEdgeAwareTreeLayoutAlgorithm.java │ │ │ ├── MultiRowTreeLayoutAlgorithm.java │ │ │ ├── NormalizesFavoredEdge.java │ │ │ ├── Radial.java │ │ │ ├── RadialEdgeAwareTreeLayoutAlgorithm.java │ │ │ ├── RadialTreeLayout.java │ │ │ ├── RadialTreeLayoutAlgorithm.java │ │ │ ├── ShapeFunctionAware.java │ │ │ ├── SpringLayoutAlgorithm.java │ │ │ ├── StaticLayoutAlgorithm.java │ │ │ ├── SugiyamaLayoutAlgorithm.java │ │ │ ├── TidierRadialTreeLayoutAlgorithm.java │ │ │ ├── TidierTreeLayoutAlgorithm.java │ │ │ ├── TreeLayout.java │ │ │ ├── TreeLayoutAlgorithm.java │ │ │ ├── VertexPredicated.java │ │ │ ├── VertexSorting.java │ │ │ ├── eiglsperger │ │ │ │ ├── Container.java │ │ │ │ ├── EiglspergerRunnable.java │ │ │ │ ├── EiglspergerSteps.java │ │ │ │ ├── EiglspergerStepsBackward.java │ │ │ │ ├── EiglspergerStepsForward.java │ │ │ │ ├── EiglspergerUtil.java │ │ │ │ ├── ExtendedEiglspergerRunnable.java │ │ │ │ ├── HorizontalCompaction.java │ │ │ │ ├── HorizontalCompactionDeprecated.java │ │ │ │ ├── HorizontalCoordinateAssignment.java │ │ │ │ ├── HorizontalCoordinateAssignmentDeprecated.java │ │ │ │ ├── InsertionOrderSplayTree.java │ │ │ │ ├── PVertex.java │ │ │ │ ├── QVertex.java │ │ │ │ ├── Segment.java │ │ │ │ ├── SegmentEdge.java │ │ │ │ ├── SegmentVertex.java │ │ │ │ ├── SelectiveEiglspergerHorizontalCoordinateAssignment.java │ │ │ │ ├── SyntheticLV.java │ │ │ │ ├── Synthetics.java │ │ │ │ ├── VerticalAlignment.java │ │ │ │ ├── VerticalAlignmentDeprecated.java │ │ │ │ └── VirtualEdge.java │ │ │ ├── package.html │ │ │ ├── repulsion │ │ │ │ ├── BarnesHutFA2Repulsion.java │ │ │ │ ├── BarnesHutFRRepulsion.java │ │ │ │ ├── BarnesHutRepulsion.java │ │ │ │ ├── BarnesHutSpringRepulsion.java │ │ │ │ ├── StandardFA2Repulsion.java │ │ │ │ ├── StandardFRRepulsion.java │ │ │ │ ├── StandardRepulsion.java │ │ │ │ └── StandardSpringRepulsion.java │ │ │ ├── sugiyama │ │ │ │ ├── AccumulatorTree.java │ │ │ │ ├── AccumulatorTreeUtil.java │ │ │ │ ├── AllLevelCross.java │ │ │ │ ├── ArticulatedEdge.java │ │ │ │ ├── AverageMedian.java │ │ │ │ ├── BrandesKopf.java │ │ │ │ ├── Comparators.java │ │ │ │ ├── ConstructiveCycleRemoval.java │ │ │ │ ├── ConstructiveFeedbackArcFunction.java │ │ │ │ ├── DFSCycleRemoval.java │ │ │ │ ├── DFSFeedbackArcGraphTransformer.java │ │ │ │ ├── DfsFeedbackArcFunction.java │ │ │ │ ├── GraphLayers.java │ │ │ │ ├── GreedyCycleRemoval.java │ │ │ │ ├── GreedyFeedbackArcFunction.java │ │ │ │ ├── GreedyFeedbackArcGraphTransformer.java │ │ │ │ ├── HorizontalCompaction.java │ │ │ │ ├── HorizontalCoordinateAssignment.java │ │ │ │ ├── LE.java │ │ │ │ ├── LEI.java │ │ │ │ ├── LV.java │ │ │ │ ├── LVI.java │ │ │ │ ├── Layering.java │ │ │ │ ├── LevelCross.java │ │ │ │ ├── LinearTimeMedian.java │ │ │ │ ├── NLogNMedian.java │ │ │ │ ├── RemoveCycles.java │ │ │ │ ├── SugiyamaRunnable.java │ │ │ │ ├── SyntheticLE.java │ │ │ │ ├── SyntheticLV.java │ │ │ │ ├── Synthetics.java │ │ │ │ ├── TransformedGraphSupplier.java │ │ │ │ ├── Unaligned.java │ │ │ │ ├── VertexMetadata.java │ │ │ │ └── VerticalAlignment.java │ │ │ └── util │ │ │ │ ├── AfterRunnable.java │ │ │ │ ├── Cancellable.java │ │ │ │ ├── CircleLayoutReduceEdgeCrossing.java │ │ │ │ ├── ComponentGrouping.java │ │ │ │ ├── DimensionConsumer.java │ │ │ │ ├── DimensionSummaryStatistics.java │ │ │ │ ├── EdgeArticulationFunctionSupplier.java │ │ │ │ ├── ExecutorConsumer.java │ │ │ │ ├── InitialDimensionFunction.java │ │ │ │ ├── InsertionSortCounter.java │ │ │ │ ├── IterativeContext.java │ │ │ │ ├── LayeredRunnable.java │ │ │ │ ├── NetworkSimplex.java │ │ │ │ ├── NetworkSimplexDevelopment.java │ │ │ │ ├── Pair.java │ │ │ │ ├── PointConsumer.java │ │ │ │ ├── PointSummaryStatistics.java │ │ │ │ ├── RectangleConsumer.java │ │ │ │ ├── RectangleSummaryStatistics.java │ │ │ │ ├── SubGraphFunction.java │ │ │ │ ├── Threaded.java │ │ │ │ ├── TreeView.java │ │ │ │ ├── VertexBoundsFunctionConsumer.java │ │ │ │ └── VertexShapeAware.java │ │ │ ├── event │ │ │ ├── LayoutSizeChange.java │ │ │ ├── LayoutStateChange.java │ │ │ ├── LayoutVertexPositionChange.java │ │ │ ├── ModelChange.java │ │ │ ├── ViewChange.java │ │ │ └── package.html │ │ │ ├── model │ │ │ ├── AbstractLayoutModel.java │ │ │ ├── AggregateLayoutModel.java │ │ │ ├── Circle.java │ │ │ ├── DefaultLayoutModel.java │ │ │ ├── Dimension.java │ │ │ ├── Expansion.java │ │ │ ├── LayoutModel.java │ │ │ ├── LocationUtil.java │ │ │ ├── Point.java │ │ │ ├── PolarPoint.java │ │ │ ├── Rectangle.java │ │ │ └── package.html │ │ │ ├── package.html │ │ │ ├── quadtree │ │ │ ├── BarnesHutQuadTree.java │ │ │ ├── ForceObject.java │ │ │ ├── Node.java │ │ │ ├── TreeNode.java │ │ │ └── package.html │ │ │ └── util │ │ │ ├── Caching.java │ │ │ ├── EdgeAccessor.java │ │ │ ├── LeftToRight.java │ │ │ ├── PropertyLoader.java │ │ │ ├── RadiusVertexAccessor.java │ │ │ ├── RandomLocationTransformer.java │ │ │ ├── RightToLeft.java │ │ │ ├── VertexAccessor.java │ │ │ ├── VisRunnable.java │ │ │ ├── package.html │ │ │ └── synthetics │ │ │ ├── ArticulatedEdge.java │ │ │ ├── SE.java │ │ │ ├── SEI.java │ │ │ ├── SV.java │ │ │ ├── SVI.java │ │ │ ├── SVTransformedGraphSupplier.java │ │ │ ├── SingletonTransformer.java │ │ │ ├── Synthetic.java │ │ │ ├── SyntheticSE.java │ │ │ ├── SyntheticSV.java │ │ │ └── TransformingGraphView.java │ └── resources │ │ └── sample.jungrapht.properties │ ├── site │ └── site.xml │ └── test │ ├── java │ └── org │ │ └── jungrapht │ │ └── visualization │ │ └── layout │ │ ├── algorithms │ │ ├── ForceObjectIterator.java │ │ ├── TestTreeLayouts.java │ │ ├── ThingTest.java │ │ ├── eiglsperger │ │ │ ├── EiglspergerTests.java │ │ │ ├── LayoutTests.java │ │ │ ├── TestInsertionOrderSplayTree.java │ │ │ └── TestSmallGraph.java │ │ ├── sugiyama │ │ │ ├── AccumulatorTreeCrossCountingTest.java │ │ │ ├── AvgMedianTests.java │ │ │ ├── BiLayerCrossCountingTest.java │ │ │ ├── BrandesKopfTest.java │ │ │ ├── TestAccumulatorTree.java │ │ │ ├── TestDelegateVerticesAndEdges.java │ │ │ ├── TestGreedyCycleRemoval.java │ │ │ ├── TestLevelCross.java │ │ │ ├── TestSugiyamaFunctions.java │ │ │ └── TestTransformingGraphView.java │ │ └── util │ │ │ ├── TestCircles.java │ │ │ ├── TestComponentGrouping.java │ │ │ ├── TestInsertionSortCounter.java │ │ │ ├── TestNetworkSimplex.java │ │ │ ├── TestNetworkSimplexFive.java │ │ │ ├── TestNetworkSimplexFour.java │ │ │ ├── TestNetworkSimplexOne.java │ │ │ ├── TestNetworkSimplexSix.java │ │ │ ├── TestNetworkSimplexThree.java │ │ │ ├── TestNetworkSimplexTwo.java │ │ │ └── synthetics │ │ │ ├── SingletonTransformerTest.java │ │ │ ├── TestDelegateVerticesAndEdges.java │ │ │ └── TestTransformingGraphView.java │ │ ├── model │ │ └── ModelTest.java │ │ ├── quadtree │ │ └── BarnesHutQuadTreeTests.java │ │ └── spatial │ │ ├── FA2LayoutsTest.java │ │ ├── FRLayoutsTest.java │ │ ├── FRLayoutsTimingTest.java │ │ └── SpringLayoutsTest.java │ └── resources │ └── logback.xml ├── jungrapht-visualization-samples ├── pom.xml └── src │ ├── main │ ├── assembly │ │ └── assembly.xml │ ├── java │ │ └── org │ │ │ └── jungrapht │ │ │ └── samples │ │ │ ├── AddRemoveVertexDemo.java │ │ │ ├── AnnotationsDemo.java │ │ │ ├── CircleLayoutDemo.java │ │ │ ├── DrawnIconVertexDemo.java │ │ │ ├── EdgeLabelDemo.java │ │ │ ├── GraphEditorDemo.java │ │ │ ├── GraphEditorDemoWithPalette.java │ │ │ ├── GraphEditorDemoWithPaletteDefaultMouse.java │ │ │ ├── ImageEdgeLabelDemo.java │ │ │ ├── InternalFrameSatelliteViewDemo.java │ │ │ ├── LensDemo.java │ │ │ ├── LensDemoWithDefaultGraphMouse.java │ │ │ ├── LensDemoWithDefaultGraphMouseProperyDriven.java │ │ │ ├── LensDemoWithMultiSelectStrategy.java │ │ │ ├── LensVertexImageFromLabelShaperDemo.java │ │ │ ├── LensVertexImageShaperDemo.java │ │ │ ├── MinimalEiglsperger.java │ │ │ ├── MinimalVisualization.java │ │ │ ├── MinimalVisualizationLayoutPaintable.java │ │ │ ├── MinimalVisualizationWithVertexSelectionOnly.java │ │ │ ├── MultiViewDemo.java │ │ │ ├── MultiViewDemoModal.java │ │ │ ├── RectangularLensDemo.java │ │ │ ├── SatelliteViewDemo.java │ │ │ ├── SatelliteViewRefactoredMouseDemo.java │ │ │ ├── ShortestPathDemo.java │ │ │ ├── ShowLayouts.java │ │ │ ├── ShowLayoutsGridGraph.java │ │ │ ├── ShowLayoutsWithGeneratedGraphs.java │ │ │ ├── ShowLayoutsWithGreedyVertexColoring.java │ │ │ ├── ShowLayoutsWithGuavaGraphs.java │ │ │ ├── ShowLayoutsWithGuavaNetworks.java │ │ │ ├── ShowLayoutsWithImageIconVertices.java │ │ │ ├── SubLayoutDemo.java │ │ │ ├── TwoModelDemo.java │ │ │ ├── UnicodeLabelDemo.java │ │ │ ├── VertexCollapseDemo.java │ │ │ ├── VertexCollapseDemoWithCollapseIds.java │ │ │ ├── VertexCollapseDemoWithLayouts.java │ │ │ ├── VertexImageShaperDemo.java │ │ │ ├── VertexImagesOrNotDemo.java │ │ │ ├── VertexLabelAsShapeDemo.java │ │ │ ├── VertexLabelPositionDemo.java │ │ │ ├── VisualizationImageServerDemo.java │ │ │ ├── VisualizationScrollPaneDemo.java │ │ │ ├── WorldMapGraphDemo.java │ │ │ ├── control │ │ │ └── modal │ │ │ │ └── Controllers.java │ │ │ ├── experimental │ │ │ ├── AttributedJSONImporter.java │ │ │ ├── EdgeComparator.java │ │ │ ├── LayoutHelperEiglsperger.java │ │ │ ├── ShowLayoutsWithGhidraGraphInputOneComponents.java │ │ │ ├── ShowLayoutsWithGhidraGraphInputThreeComponents.java │ │ │ ├── ShowLayoutsWithGhidraGraphInputTwoComponents.java │ │ │ └── ShowLayoutsWithGhidraGraphTwo.java │ │ │ ├── flow │ │ │ └── MaxFlowDemo.java │ │ │ ├── io │ │ │ └── CreateOutputFiles.java │ │ │ ├── large │ │ │ ├── AttributedShowLayoutsWithGraphFileImport.java │ │ │ ├── EiglspergerWithGhidraGraphInputExp.java │ │ │ ├── ForceAtlas2WithJGraphtIO.java │ │ │ ├── PerformanceGraph.java │ │ │ ├── ShowLayoutsWithDirectedGraphFileImport.java │ │ │ ├── ShowLayoutsWithGhidraGraphInput.java │ │ │ ├── ShowLayoutsWithGraphFileImport.java │ │ │ ├── ShowLayoutsWithIO7MGraph.java │ │ │ ├── ShowLayoutsWithJGraphtIO.java │ │ │ ├── SpatialLensLargeGraphDemo.java │ │ │ └── package.html │ │ │ ├── package.html │ │ │ ├── quadtree │ │ │ ├── BarnesHutVisualizer.java │ │ │ └── package.html │ │ │ ├── rtree │ │ │ ├── RTreeVisualizer.java │ │ │ └── package.html │ │ │ ├── spatial │ │ │ ├── RTreeVisualization.java │ │ │ ├── ShowLayoutsWithBarnesHutVisualization.java │ │ │ ├── SimpleGraphSpatialEdgeSearchTest.java │ │ │ ├── SimpleGraphSpatialSearchTest.java │ │ │ ├── SimpleGraphSpatialTest.java │ │ │ ├── SpatialLensDemo.java │ │ │ ├── SpatialLensDemoWithOneStarVertex.java │ │ │ ├── SpatialLensDemoWithThreeStarVertices.java │ │ │ ├── SpatialRTreeTest.java │ │ │ └── package.html │ │ │ ├── sugiyama │ │ │ ├── BrandesKopfSugiyamaGraphExample.java │ │ │ ├── BrandesKopfSugiyamaGraphExampleWithIsolatedVertices.java │ │ │ ├── BrandesKopfSugiyamaGraphExampleWithLayouts.java │ │ │ ├── BrandesKopfTestGraphExample.java │ │ │ ├── EiglspergerLayeringOptions.java │ │ │ ├── EiglspergerLayeringOptionsSmall.java │ │ │ ├── EiglspergerLayoutDemo.java │ │ │ ├── EiglspergerLayoutDemoLtoR.java │ │ │ ├── EiglspergerLongestPathComparison.java │ │ │ ├── EiglspergerMulticomponent.java │ │ │ ├── EiglspergerMulticomponentComparison.java │ │ │ ├── EiglspergerNetworkSimplex.java │ │ │ ├── EiglspergerNetworkSimplexComparison.java │ │ │ ├── EiglspergerSixSameGraphExample.java │ │ │ ├── EiglspergerSmallGraph.java │ │ │ ├── EiglspergerSmallNetworkSimplexComparison.java │ │ │ ├── EiglspergerWithWithoutTransposeSwapping.java │ │ │ ├── EiglspsergerSixTestGraphExample.java │ │ │ ├── LayeredTestGraphExample.java │ │ │ ├── MinCrossMulticomponent.java │ │ │ ├── MoreLayeringOptions.java │ │ │ ├── SugiyamaAndEiglsperger.java │ │ │ ├── SugiyamaAndEiglspergerAttributed.java │ │ │ ├── SugiyamaEiglspergerWithWithoutHorizontalCompaction.java │ │ │ ├── SugiyamaLayeringOptions.java │ │ │ ├── SugiyamaLayoutDemo.java │ │ │ ├── SugiyamaMulticomponent.java │ │ │ ├── SugiyamaSixSameGraphExample.java │ │ │ ├── SugiyamaSixTestGraphExample.java │ │ │ ├── SugiyamaWithWithoutStraighteningGraphExample.java │ │ │ ├── SugiyamaWithWithoutTransposeSwapping.java │ │ │ ├── package.html │ │ │ └── test │ │ │ │ └── algorithms │ │ │ │ ├── BrandesKopfLayoutAlgorithm.java │ │ │ │ ├── LayeredLayoutAlgorithm.java │ │ │ │ ├── SelectiveSugiyamaHorizontalCoordinateAssignment.java │ │ │ │ ├── TestSugiyamaLayoutAlgorithm.java │ │ │ │ └── TestSugiyamaRunnable.java │ │ │ ├── tree │ │ │ ├── ArbitraryShapeMultiSelectDemo.java │ │ │ ├── BalloonLayoutDemo.java │ │ │ ├── BalloonLayoutForestDemo.java │ │ │ ├── EdgePrioritizedTreeDAGLayoutDemo.java │ │ │ ├── GhidraModuleDependencyGraphDemo.java │ │ │ ├── L2RTreeLayoutDemo.java │ │ │ ├── MinimumSpanningTreeDemo.java │ │ │ ├── MultiRowTreeLayoutForestDemo.java │ │ │ ├── RadialTreeLensDemo.java │ │ │ ├── RandomDAGExample.java │ │ │ ├── RandomDAGExampleWithSatellite.java │ │ │ ├── SatelliteViewTreeDemo.java │ │ │ ├── TidierL2RTreeLayoutDemo.java │ │ │ ├── TidierTreeLayoutDemo.java │ │ │ ├── TreeCollapseDemo.java │ │ │ ├── TreeLayoutDemo.java │ │ │ ├── TreeLayoutDemoNoRoots.java │ │ │ ├── TreeLayoutDemoOneVertex.java │ │ │ ├── TreeLayoutDemoOverlapTest.java │ │ │ ├── TreeLayoutDemoWithIsolatedVertices.java │ │ │ ├── UniformVertexTreeDAGLayoutDemo.java │ │ │ ├── VertexSizeAwareTreeDAGLayoutDemo.java │ │ │ └── package.html │ │ │ └── util │ │ │ ├── ASAILoader.java │ │ │ ├── Colors.java │ │ │ ├── ControlHelpers.java │ │ │ ├── DemoTreeSupplier.java │ │ │ ├── ForceAtlas2ControlPanel.java │ │ │ ├── GeneratedGraphs.java │ │ │ ├── IconPalette.java │ │ │ ├── LayeringConfiguration.java │ │ │ ├── LayoutFunction.java │ │ │ ├── LayoutHelper.java │ │ │ ├── LayoutHelperDirectedGraphs.java │ │ │ ├── LensControlHelper.java │ │ │ ├── MultipleLayoutSelector.java │ │ │ ├── SpanningTreeAdapter.java │ │ │ ├── SubLayoutHelper.java │ │ │ ├── TestGraphs.java │ │ │ ├── TestGuavaGraphs.java │ │ │ ├── TestGuavaNetworks.java │ │ │ ├── TitlePaintable.java │ │ │ ├── TreeLayoutSelector.java │ │ │ ├── VerticalLabelUI.java │ │ │ └── package.html │ └── resources │ │ ├── 004018c0graph.json │ │ ├── AddRemoveVertexDemo.properties │ │ ├── BalloonLayoutDemo.properties │ │ ├── GraphEditorDemo.properties │ │ ├── L2RTreeLayoutDemo.properties │ │ ├── LensDemo.properties │ │ ├── LensDemoWithDefaultGraphMouseProperyDriven.properties │ │ ├── LensDemoWithMultiSelectStrategy.properties │ │ ├── MinimalOrthogonal.properties │ │ ├── PerformanceGraph.properties │ │ ├── RandomDAGExample.properties │ │ ├── SatelliteViewRefactoredMouseDemo.properties │ │ ├── ShowLayoutsWithJGraphtIO.properties │ │ ├── SpatialLensDemo.properties │ │ ├── SugiyamaAndEiglsperger.properties │ │ ├── SugiyamaAndEiglspergerCopy.properties │ │ ├── friends.graphml │ │ ├── ghidra.json │ │ ├── graph.json │ │ ├── images │ │ ├── Sandstone.jpg │ │ ├── china.gif │ │ ├── france.gif │ │ ├── germany.gif │ │ ├── japan.gif │ │ ├── lightning-s.gif │ │ ├── political_world_map.jpg │ │ ├── russia.gif │ │ ├── spain.gif │ │ ├── topicapple.gif │ │ ├── topicgamespcgames.gif │ │ ├── topicgraphics3.gif │ │ ├── topichumor.gif │ │ ├── topicinputdevices.gif │ │ ├── topiclinux.gif │ │ ├── topicmusic.gif │ │ ├── topicos.gif │ │ ├── topicprivacy.gif │ │ ├── topicsample.gif │ │ ├── topicsample2.gif │ │ ├── topicwireless.gif │ │ ├── topicx.gif │ │ └── united-states.gif │ │ ├── jungrapht.properties │ │ ├── logback.xml │ │ ├── marvel-movie-graph.graphml │ │ └── moduledeps.txt │ └── site │ └── site.xml ├── jungrapht-visualization ├── assembly.xml ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── jungrapht │ │ │ └── visualization │ │ │ ├── AbstractSatelliteVisualizationViewer.java │ │ │ ├── AbstractVisualizationModel.java │ │ │ ├── AbstractVisualizationServer.java │ │ │ ├── AbstractVisualizationViewer.java │ │ │ ├── DefaultRenderContext.java │ │ │ ├── DefaultSatelliteVisualizationViewer.java │ │ │ ├── DefaultTransformer.java │ │ │ ├── DefaultVisualizationModel.java │ │ │ ├── DefaultVisualizationServer.java │ │ │ ├── DefaultVisualizationViewer.java │ │ │ ├── FourPassImageShaper.java │ │ │ ├── LayeredIcon.java │ │ │ ├── MultiLayerTransformer.java │ │ │ ├── PivotingImageShaper.java │ │ │ ├── PropertyLoader.java │ │ │ ├── RenderContext.java │ │ │ ├── RenderContextStateChange.java │ │ │ ├── SatelliteVisualizationViewer.java │ │ │ ├── VisualizationComponent.java │ │ │ ├── VisualizationImageServer.java │ │ │ ├── VisualizationModel.java │ │ │ ├── VisualizationScrollPane.java │ │ │ ├── VisualizationServer.java │ │ │ ├── VisualizationViewer.java │ │ │ ├── annotations │ │ │ ├── AnnotatingGraphMousePlugin.java │ │ │ ├── AnnotatingModalGraphMouse.java │ │ │ ├── Annotation.java │ │ │ ├── AnnotationControls.java │ │ │ ├── AnnotationManager.java │ │ │ ├── AnnotationPaintable.java │ │ │ ├── AnnotationRenderer.java │ │ │ ├── MultiSelectedVertexPaintable.java │ │ │ ├── SelectedEdgePaintable.java │ │ │ ├── SelectedVertexPaintable.java │ │ │ ├── SingleSelectedVertexPaintable.java │ │ │ └── package.html │ │ │ ├── control │ │ │ ├── AbsoluteCrossoverScalingControl.java │ │ │ ├── AbstractGraphMouse.java │ │ │ ├── AbstractGraphMousePlugin.java │ │ │ ├── AbstractModalGraphMouse.java │ │ │ ├── AbstractPopupGraphMousePlugin.java │ │ │ ├── AnimatedPickingGraphMousePlugin.java │ │ │ ├── CrossoverScalingControl.java │ │ │ ├── CubicCurveEdgeEffects.java │ │ │ ├── DefaultGraphMouse.java │ │ │ ├── DefaultLensGraphMouse.java │ │ │ ├── DefaultModalGraphMouse.java │ │ │ ├── DefaultSatelliteGraphMouse.java │ │ │ ├── EdgeEffects.java │ │ │ ├── EdgeSelectingGraphMousePlugin.java │ │ │ ├── EdgeSupport.java │ │ │ ├── EditingDefaultGraphMouse.java │ │ │ ├── EditingGraphMousePlugin.java │ │ │ ├── EditingModalGraphMouse.java │ │ │ ├── EditingPopupGraphMousePlugin.java │ │ │ ├── GraphElementAccessor.java │ │ │ ├── GraphMouseAdapter.java │ │ │ ├── GraphMouseListener.java │ │ │ ├── GraphMousePlugin.java │ │ │ ├── LabelEditingGraphMousePlugin.java │ │ │ ├── LayoutScalingControl.java │ │ │ ├── LensGraphMouse.java │ │ │ ├── LensKillingGraphMousePlugin.java │ │ │ ├── LensMagnificationGraphMousePlugin.java │ │ │ ├── LensRegionSelectingGraphMousePlugin.java │ │ │ ├── LensSelectingGraphMousePlugin.java │ │ │ ├── LensTransformSupport.java │ │ │ ├── LensTranslatingGraphMousePlugin.java │ │ │ ├── LensVertexSelectingGraphMousePlugin.java │ │ │ ├── ModalGraphMouse.java │ │ │ ├── ModalLensGraphMouse.java │ │ │ ├── ModalSatelliteGraphMouse.java │ │ │ ├── Modifiers.java │ │ │ ├── MouseListenerTranslator.java │ │ │ ├── MultiSelectionStrategy.java │ │ │ ├── PluggableGraphMouse.java │ │ │ ├── RegionSelectingGraphMousePlugin.java │ │ │ ├── RotatingGraphMousePlugin.java │ │ │ ├── SatelliteAnimatedPickingGraphMousePlugin.java │ │ │ ├── SatelliteRotatingGraphMousePlugin.java │ │ │ ├── SatelliteScalingGraphMousePlugin.java │ │ │ ├── SatelliteShearingGraphMousePlugin.java │ │ │ ├── SatelliteTranslatingGraphMousePlugin.java │ │ │ ├── ScalingControl.java │ │ │ ├── ScalingGraphMousePlugin.java │ │ │ ├── SelectingGraphMousePlugin.java │ │ │ ├── SelectionIconListener.java │ │ │ ├── ShearingGraphMousePlugin.java │ │ │ ├── SimpleEdgeSupport.java │ │ │ ├── SimpleVertexSupport.java │ │ │ ├── TransformSupport.java │ │ │ ├── TranslatingGraphMousePlugin.java │ │ │ ├── VertexSelectingGraphMousePlugin.java │ │ │ ├── VertexSupport.java │ │ │ ├── ViewScalingControl.java │ │ │ ├── ViewTranslatingGraphMousePlugin.java │ │ │ ├── dnd │ │ │ │ ├── VertexImageDragGestureListener.java │ │ │ │ └── VertexImageDropTargetListener.java │ │ │ ├── modal │ │ │ │ ├── Modal.java │ │ │ │ ├── ModeComboBox.java │ │ │ │ ├── ModeContainer.java │ │ │ │ ├── ModeControl.java │ │ │ │ ├── ModeControls.java │ │ │ │ ├── ModeMenu.java │ │ │ │ └── ModePanel.java │ │ │ └── package.html │ │ │ ├── decorators │ │ │ ├── AbstractEdgeShapeFunction.java │ │ │ ├── AbstractShapeFunction.java │ │ │ ├── ArticulatedEdgeShapeFunction.java │ │ │ ├── ArticulatedEdgeShapeFunctions.java │ │ │ ├── EdgeShape.java │ │ │ ├── EllipseShapeFunction.java │ │ │ ├── ExpandXY.java │ │ │ ├── GradientEdgePaintFunction.java │ │ │ ├── GradientVertexPaintFunction.java │ │ │ ├── IconShapeFunction.java │ │ │ ├── ParallelEdgeShapeFunction.java │ │ │ ├── PickableElementPaintFunction.java │ │ │ ├── SettableShapeFunction.java │ │ │ └── package.html │ │ │ ├── package.html │ │ │ ├── renderers │ │ │ ├── AbstractEdgeRenderer.java │ │ │ ├── AbstractVertexRenderer.java │ │ │ ├── BiModalRenderer.java │ │ │ ├── BiModalSelectionRenderer.java │ │ │ ├── CenterEdgeArrowRenderingSupport.java │ │ │ ├── Checkmark.java │ │ │ ├── DefaultEdgeArrowRenderingSupport.java │ │ │ ├── DefaultModalRenderer.java │ │ │ ├── DefaultRenderer.java │ │ │ ├── EdgeArrowRenderingSupport.java │ │ │ ├── EdgeLabelRenderer.java │ │ │ ├── GradientVertexRenderer.java │ │ │ ├── HeavyweightEdgeRenderer.java │ │ │ ├── HeavyweightRenderer.java │ │ │ ├── HeavyweightVertexLabelRenderer.java │ │ │ ├── HeavyweightVertexRenderer.java │ │ │ ├── HeavyweightVertexSelectionRenderer.java │ │ │ ├── HeayweightEdgeLabelRenderer.java │ │ │ ├── JLabelEdgeLabelRenderer.java │ │ │ ├── JLabelVertexLabelRenderer.java │ │ │ ├── JTextAreaVertexLabelRenderer.java │ │ │ ├── LightweightEdgeRenderer.java │ │ │ ├── LightweightRenderer.java │ │ │ ├── LightweightVertexRenderer.java │ │ │ ├── LightweightVertexSelectionRenderer.java │ │ │ ├── ModalRenderer.java │ │ │ ├── Renderer.java │ │ │ ├── ReshapingEdgeRenderer.java │ │ │ ├── SelectionRenderer.java │ │ │ ├── VertexLabelAsShapeRenderer.java │ │ │ ├── VertexLabelRenderer.java │ │ │ ├── VertexShapeFunctionConsumer.java │ │ │ └── package.html │ │ │ ├── selection │ │ │ ├── AbstractMutableSelectedState.java │ │ │ ├── MultiMutableSelectedState.java │ │ │ ├── MutableSelectedState.java │ │ │ ├── MutableSelectedStateSink.java │ │ │ ├── SelectedState.java │ │ │ ├── ShapePickSupport.java │ │ │ ├── VertexEndpointsSelectedEdgeSelectedState.java │ │ │ ├── VertexSelectedEndpointsEdgeSelectionListener.java │ │ │ └── package.html │ │ │ ├── spatial │ │ │ ├── AbstractSpatial.java │ │ │ ├── Spatial.java │ │ │ ├── SpatialGrid.java │ │ │ ├── SpatialQuadTree.java │ │ │ ├── SpatialRTree.java │ │ │ ├── SwingThreadSpatial.java │ │ │ ├── package.html │ │ │ └── rtree │ │ │ │ ├── AbstractSplitter.java │ │ │ │ ├── Bounded.java │ │ │ │ ├── BoundedList.java │ │ │ │ ├── BoundedMap.java │ │ │ │ ├── HorizontalCenterNodeComparator.java │ │ │ │ ├── HorizontalEdgeMapEntryComparator.java │ │ │ │ ├── HorizontalEdgeNodeComparator.java │ │ │ │ ├── InnerNode.java │ │ │ │ ├── LeafNode.java │ │ │ │ ├── LeafSplitter.java │ │ │ │ ├── Node.java │ │ │ │ ├── NodeList.java │ │ │ │ ├── NodeMap.java │ │ │ │ ├── Pair.java │ │ │ │ ├── QuadraticLeafSplitter.java │ │ │ │ ├── QuadraticSplitter.java │ │ │ │ ├── RStarLeafSplitter.java │ │ │ │ ├── RStarSplitter.java │ │ │ │ ├── RTree.java │ │ │ │ ├── RTreeNode.java │ │ │ │ ├── Splitter.java │ │ │ │ ├── SplitterContext.java │ │ │ │ ├── TreeNode.java │ │ │ │ ├── VerticalEdgeMapEntryComparator.java │ │ │ │ ├── VerticalEdgeNodeComparator.java │ │ │ │ └── package.html │ │ │ ├── sublayout │ │ │ ├── Collapser.java │ │ │ ├── GraphCollapser.java │ │ │ ├── SubgraphSupplier.java │ │ │ ├── TreeCollapser.java │ │ │ ├── VisualGraphCollapser.java │ │ │ ├── VisualTreeCollapser.java │ │ │ └── package.html │ │ │ ├── transform │ │ │ ├── AbstractLensSupport.java │ │ │ ├── AffineTransformer.java │ │ │ ├── BidirectionalTransformer.java │ │ │ ├── HyperbolicTransformer.java │ │ │ ├── Intersections.java │ │ │ ├── LayoutLensSupport.java │ │ │ ├── Lens.java │ │ │ ├── LensManager.java │ │ │ ├── LensSupport.java │ │ │ ├── LensTransformer.java │ │ │ ├── MagnifyTransformer.java │ │ │ ├── MutableAffineTransformer.java │ │ │ ├── MutableTransformer.java │ │ │ ├── MutableTransformerDecorator.java │ │ │ ├── package.html │ │ │ └── shape │ │ │ │ ├── Graphics2DWrapper.java │ │ │ │ ├── GraphicsDecorator.java │ │ │ │ ├── HyperbolicShapeTransformer.java │ │ │ │ ├── Intersector.java │ │ │ │ ├── MagnifyIconGraphics.java │ │ │ │ ├── MagnifyImageLensSupport.java │ │ │ │ ├── MagnifyShapeTransformer.java │ │ │ │ ├── ShapeFlatnessTransformer.java │ │ │ │ ├── ShapeTransformer.java │ │ │ │ ├── TransformingFlatnessGraphics.java │ │ │ │ ├── TransformingGraphics.java │ │ │ │ ├── ViewLensSupport.java │ │ │ │ └── package.html │ │ │ └── util │ │ │ ├── AWT.java │ │ │ ├── AnimationLayoutAlgorithm.java │ │ │ ├── ArrowFactory.java │ │ │ ├── Attributed.java │ │ │ ├── BoundingRectangleCollector.java │ │ │ ├── BoundingRectanglePaintable.java │ │ │ ├── ChangeEventSupport.java │ │ │ ├── DefaultAttributed.java │ │ │ ├── DefaultChangeEventSupport.java │ │ │ ├── DimensionUtils.java │ │ │ ├── EdgeIndexFunction.java │ │ │ ├── GeneralPathAsString.java │ │ │ ├── GraphImage.java │ │ │ ├── IconCache.java │ │ │ ├── IconFunction.java │ │ │ ├── ImageShapeUtils.java │ │ │ ├── ItemSupport.java │ │ │ ├── LabelWrapper.java │ │ │ ├── LayoutAlgorithmTransition.java │ │ │ ├── LayoutPaintable.java │ │ │ ├── ParallelEdgeIndexFunction.java │ │ │ ├── PointUtils.java │ │ │ ├── PredicatedParallelEdgeIndexFunction.java │ │ │ ├── RadiusGraphElementAccessor.java │ │ │ ├── RectangleUtils.java │ │ │ ├── ShapeFactory.java │ │ │ ├── TreeUtils.java │ │ │ ├── VertexLocationAnimator.java │ │ │ ├── VertexStyleConfiguration.java │ │ │ └── package.html │ └── resources │ │ └── sample.jungrapht.properties │ ├── site │ └── site.xml │ └── test │ ├── java │ └── org │ │ └── jungrapht │ │ └── visualization │ │ ├── LayoutAlgorithmTransitionTest.java │ │ ├── ShapeTest.java │ │ ├── SpatialRTreeTest.java │ │ ├── TestImageShaper.java │ │ ├── VisualizationServerTest.java │ │ ├── layout │ │ ├── algorithms │ │ │ ├── ForceObjectIterator.java │ │ │ ├── eiglsperger │ │ │ │ ├── EiglspergerTests.java │ │ │ │ ├── TestInsertionOrderSplayTree.java │ │ │ │ └── TestSmallGraph.java │ │ │ ├── sugiyama │ │ │ │ ├── AccumulatorTreeCrossCountingTest.java │ │ │ │ ├── AvgMedianTests.java │ │ │ │ ├── BiLayerCrossCountingTest.java │ │ │ │ ├── BrandesKopfTest.java │ │ │ │ ├── TestAccumulatorTree.java │ │ │ │ ├── TestDelegateVerticesAndEdges.java │ │ │ │ ├── TestGreedyCycleRemoval.java │ │ │ │ ├── TestLevelCross.java │ │ │ │ ├── TestSugiyamaFunctions.java │ │ │ │ └── TestTransformingGraphView.java │ │ │ └── util │ │ │ │ ├── TestComponentGrouping.java │ │ │ │ ├── TestInsertionSortCounter.java │ │ │ │ ├── TestNetworkSimplex.java │ │ │ │ ├── TestNetworkSimplexFive.java │ │ │ │ ├── TestNetworkSimplexFour.java │ │ │ │ ├── TestNetworkSimplexOne.java │ │ │ │ ├── TestNetworkSimplexSix.java │ │ │ │ ├── TestNetworkSimplexThree.java │ │ │ │ ├── TestNetworkSimplexTwo.java │ │ │ │ └── synthetics │ │ │ │ ├── SingletonTransformerTest.java │ │ │ │ ├── TestDelegateVerticesAndEdges.java │ │ │ │ └── TestTransformingGraphView.java │ │ ├── model │ │ │ └── ModelTest.java │ │ └── quadtree │ │ │ └── BarnesHutQuadTreeTests.java │ │ ├── selection │ │ └── MultiMutableSelectedStateTest.java │ │ ├── spatial │ │ ├── RTreeTest.java │ │ ├── RTreeTest2.java │ │ ├── ShapesTest.java │ │ ├── SpatialGridTest.java │ │ └── SpatialQuadTreeTest.java │ │ ├── sublayout │ │ └── GraphCollapserTest.java │ │ └── transform │ │ └── IntersectionsTest.java │ └── resources │ └── logback.xml ├── pom.xml └── tools └── settings.xml /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Java CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - main 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v4 15 | - name: Set up JDK 17 16 | uses: actions/setup-java@v4 17 | with: 18 | java-version: '17' 19 | distribution: 'temurin' 20 | cache: 'maven' 21 | - name: Build with Maven 22 | run: mvn --batch-mode --update-snapshots package 23 | publish: 24 | runs-on: ubuntu-latest 25 | needs: build 26 | if: github.repository == 'tomnelson/jungrapht-visualization' 27 | steps: 28 | - uses: actions/checkout@v4 29 | - name: Set up Maven Snapshot Repository 30 | uses: actions/setup-java@v4 31 | with: 32 | java-version: '17' 33 | distribution: 'temurin' 34 | server-id: sonatype-nexus-snapshots 35 | server-username: MAVEN_USERNAME 36 | server-password: MAVEN_PASSWORD 37 | - name: Publish package 38 | run: mvn --batch-mode deploy 39 | env: 40 | MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }} 41 | MAVEN_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/bin 2 | **/*.iml 3 | **/*.orig 4 | **/*.prefs 5 | **/.classpath 6 | **/.idea 7 | **/.project 8 | **/.settings 9 | **/lib 10 | **/.idea? 11 | *.iml 12 | *.o 13 | *.orig 14 | *~ 15 | ~* 16 | *.bak 17 | .*.swp 18 | .classpath 19 | .idea 20 | .project 21 | .settings 22 | .metadata/ 23 | .factoryPath 24 | **/nb-configuration.xml 25 | nbactions.xml 26 | nbproject/ 27 | tags 28 | target 29 | target/ 30 | **/target/ 31 | **/logs/ 32 | pom.xml.releaseBackup 33 | **/pom.xml.releaseBackup 34 | **/dependency-reduced-pom.xml 35 | docs/javadoc* 36 | docs/_site 37 | generated -------------------------------------------------------------------------------- /Structure.md: -------------------------------------------------------------------------------- 1 | LayoutAlgorithm computes vertex locations. 2 | 3 | LayoutModel accepts a LayoutAlgorithm and contains a Map of vertex to Point locations 4 | 5 | VisualizationModel contains a LayoutModel and adds awt classes and event support. 6 | 7 | VisualizationServer contains a VisualizationModel and contains affine transforms and 8 | renderers to draw a graph. 9 | 10 | VisualizationViewer extends VisualizationServer and adds mouse-driven event handling 11 | 12 | -------------------------------------------------------------------------------- /images/CircleLayout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/images/CircleLayout.jpg -------------------------------------------------------------------------------- /images/ReducedEdgeCrossingCircleLayout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/images/ReducedEdgeCrossingCircleLayout.jpg -------------------------------------------------------------------------------- /images/bettercircle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/images/bettercircle.jpg -------------------------------------------------------------------------------- /images/brandeskopftestgraph.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/images/brandeskopftestgraph.jpg -------------------------------------------------------------------------------- /images/brandeskopftestgraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/images/brandeskopftestgraph.png -------------------------------------------------------------------------------- /images/circle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/images/circle.jpg -------------------------------------------------------------------------------- /images/eiglspergersugiyama.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/images/eiglspergersugiyama.jpg -------------------------------------------------------------------------------- /images/eiglspergersugiyama.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/images/eiglspergersugiyama.png -------------------------------------------------------------------------------- /images/sugiyama.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/images/sugiyama.jpg -------------------------------------------------------------------------------- /images/sugiyama2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/images/sugiyama2.jpg -------------------------------------------------------------------------------- /images/sugiyamabrandeskopf.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/images/sugiyamabrandeskopf.jpg -------------------------------------------------------------------------------- /images/tidiertree.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/images/tidiertree.jpg -------------------------------------------------------------------------------- /jungrapht-layout/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Support for graph layout models and graph layout algorithms

6 | 7 |

There are no java.awt imports in this package and its sub packages

8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/Balloon.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms; 2 | 3 | /** marker interface used only to signal that the balloon layout paintables might be applied */ 4 | public interface Balloon {} 5 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/EdgeAwareLayoutAlgorithm.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms; 2 | 3 | import org.jungrapht.visualization.layout.model.LayoutModel; 4 | 5 | /** 6 | * A marker interface for LayoutAlgorithms that are aware of graph edges and can use the edges as 7 | * part of the layout vertex positioning 8 | * 9 | * @author Tom Nelson. 10 | */ 11 | public interface EdgeAwareLayoutAlgorithm 12 | extends LayoutAlgorithm, 13 | EdgeSorting, 14 | EdgePredicated, 15 | VertexSorting, 16 | VertexPredicated { 17 | 18 | interface Builder, B extends Builder> 19 | extends LayoutAlgorithm.Builder {} 20 | 21 | /** 22 | * visit the passed layoutModel and set its locations 23 | * 24 | * @param layoutModel the mediator between the container for vertices (the Graph) and the mapping 25 | * from Vertex to Point 26 | */ 27 | void visit(LayoutModel layoutModel); 28 | } 29 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/EdgePredicated.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms; 2 | 3 | import java.util.function.Predicate; 4 | 5 | /** 6 | * an interface for {@code LayoutAlgorithm} that can set a {@code Predicate} to filter edges 7 | * 8 | * @param 9 | */ 10 | public interface EdgePredicated { 11 | 12 | void setEdgePredicate(Predicate edgePredicate); 13 | } 14 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/EdgeSorting.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms; 2 | 3 | import java.util.Comparator; 4 | 5 | /** 6 | * an interface for {@code LayoutAlgorithm}s with a settable Comparator for edges 7 | * 8 | * @param 9 | */ 10 | public interface EdgeSorting { 11 | 12 | void setEdgeComparator(Comparator comparator); 13 | } 14 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/IterativeLayoutAlgorithm.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms; 2 | 3 | import org.jungrapht.visualization.layout.algorithms.util.ExecutorConsumer; 4 | import org.jungrapht.visualization.layout.algorithms.util.IterativeContext; 5 | 6 | /** 7 | * A LayoutAlgorithm that may utilize a pre-relax phase, which is a loop of calls to step 8 | * that occurr in the current thread instead of in a new Thread. The purpose of 9 | * preRelax() is to rapidly reach an initial state before spawning a new Thread to perform a 10 | * more lengthy relax operation. 11 | * 12 | * @param the Vertex type 13 | */ 14 | public interface IterativeLayoutAlgorithm 15 | extends LayoutAlgorithm, IterativeContext, ExecutorConsumer { 16 | /** 17 | * may be a no-op depending on how the algorithm instance is created 18 | * 19 | * @return true if a prerelax was done, false otherwise 20 | */ 21 | boolean preRelax(); 22 | } 23 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/Layered.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms; 2 | 3 | import java.util.Comparator; 4 | import java.util.function.Function; 5 | import java.util.function.Predicate; 6 | import org.jgrapht.Graph; 7 | import org.jungrapht.visualization.layout.algorithms.sugiyama.Layering; 8 | 9 | public interface Layered { 10 | 11 | void setLayering(Layering layering); 12 | 13 | void setMaxLevelCrossFunction(Function, Integer> maxLevelCrossFunction); 14 | 15 | Comparator noopComparator = (v1, v2) -> 0; 16 | 17 | Predicate truePredicate = t -> true; 18 | 19 | Predicate falsePredicate = t -> false; 20 | } 21 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/LayoutAlgorithm.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms; 2 | 3 | import org.jungrapht.visualization.layout.algorithms.util.AfterRunnable; 4 | import org.jungrapht.visualization.layout.model.LayoutModel; 5 | 6 | /** 7 | * LayoutAlgorithm is a visitor to the LayoutModel. When it visits, it runs the algorithm to place 8 | * the graph vertices at locations. 9 | * 10 | * @author Tom Nelson. 11 | */ 12 | public interface LayoutAlgorithm extends AfterRunnable { 13 | 14 | interface Builder, B extends Builder> { 15 | T build(); 16 | } 17 | /** 18 | * visit the passed layoutModel and set its locations 19 | * 20 | * @param layoutModel the mediator between the container for vertices (the Graph) and the mapping 21 | * from Vertex to Point 22 | */ 23 | void visit(LayoutModel layoutModel); 24 | 25 | default void cancel() { 26 | // no op 27 | } 28 | 29 | default boolean constrained() { 30 | return true; 31 | } 32 | 33 | class NoOp implements LayoutAlgorithm { 34 | 35 | /** 36 | * visit the passed layoutModel and set its locations 37 | * 38 | * @param layoutModel the mediator between the container for vertices (the Graph) and the 39 | * mapping from Vertex to Point 40 | */ 41 | @Override 42 | public void visit(LayoutModel layoutModel) { 43 | // noop 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/MultiRow.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms; 2 | 3 | public interface MultiRow {} 4 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/NormalizesFavoredEdge.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms; 2 | 3 | import java.util.function.Predicate; 4 | 5 | public interface NormalizesFavoredEdge { 6 | 7 | void setFavoredEdgePredicate(Predicate favoredEdgePredicate); 8 | } 9 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/Radial.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms; 2 | 3 | /** marker interface used only to signal that the radial paintables might be applied */ 4 | public interface Radial {} 5 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/RadialTreeLayout.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms; 2 | 3 | import java.util.Map; 4 | import org.jungrapht.visualization.layout.model.LayoutModel; 5 | import org.jungrapht.visualization.layout.model.Point; 6 | import org.jungrapht.visualization.layout.model.PolarPoint; 7 | import org.jungrapht.visualization.layout.model.Rectangle; 8 | 9 | /** 10 | * a marker interface for Tree layouts in a radial pattern 11 | * 12 | * @param vertex type 13 | */ 14 | public interface RadialTreeLayout extends TreeLayout, Radial { 15 | 16 | Map getBaseBounds(); 17 | 18 | Map getPolarLocations(); 19 | 20 | Point getCenter(LayoutModel layoutModel); 21 | 22 | default boolean constrained() { 23 | return true; 24 | } 25 | 26 | int diameter(LayoutModel layoutModel); 27 | } 28 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/ShapeFunctionAware.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms; 2 | 3 | import java.util.function.Function; 4 | import org.jungrapht.visualization.layout.model.Rectangle; 5 | 6 | /** 7 | * an interface for {@code LayoutAlgorithm} with a settable Shape Function for vertices 8 | * 9 | * @param vertex type 10 | */ 11 | public interface ShapeFunctionAware { 12 | 13 | void setVertexShapeFunction(Function vertexShapeFunction); 14 | } 15 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/StaticLayoutAlgorithm.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms; 2 | 3 | import org.jungrapht.visualization.layout.model.LayoutModel; 4 | 5 | /** 6 | * StaticLayout leaves the vertices in the locations specified in the LayoutModel, and has no other 7 | * behavior. 8 | * 9 | * @author Tom Nelson 10 | */ 11 | public class StaticLayoutAlgorithm implements LayoutAlgorithm { 12 | 13 | public StaticLayoutAlgorithm() {} 14 | 15 | /** 16 | * a no-op, as the Vertex locations are unchanged from where they are in the layoutModel 17 | * 18 | * @param layoutModel the mediator between the container for vertices (the Graph) and the mapping 19 | * from Vertex to Point 20 | */ 21 | @Override 22 | public void visit(LayoutModel layoutModel) {} 23 | 24 | @Override 25 | public boolean constrained() { 26 | return false; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/VertexPredicated.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms; 2 | 3 | import java.util.function.Predicate; 4 | 5 | /** 6 | * an interface for {@code LayoutAlgorithm} with a settable {@link Predicate} to filter vertices 7 | * 8 | * @param 9 | */ 10 | public interface VertexPredicated { 11 | 12 | void setVertexPredicate(Predicate vertexPredicate); 13 | } 14 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/VertexSorting.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms; 2 | 3 | import java.util.Comparator; 4 | 5 | /** 6 | * an interface for {@code LayoutAlgorithm} with a settable Comparator for vertices 7 | * 8 | * @param 9 | */ 10 | public interface VertexSorting { 11 | 12 | void setVertexComparator(Comparator comparator); 13 | } 14 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/PVertex.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.eiglsperger; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | /** 7 | * a vertex that is not in the original graph, but is synthesized in order to position bends in the 8 | * articulated edges of the SugiyamaLayoutAlgorithm a PVertex is the top vertex of a vertical edge 9 | * segment 10 | * 11 | * @param vertex type 12 | */ 13 | class PVertex extends SegmentVertex { 14 | 15 | private static final Logger log = LoggerFactory.getLogger(PVertex.class); 16 | 17 | public static PVertex of() { 18 | return new PVertex(); 19 | } 20 | 21 | protected PVertex() { 22 | super(); 23 | } 24 | 25 | public PVertex copy() { 26 | return new PVertex<>(this); 27 | } 28 | 29 | public PVertex(PVertex other) { 30 | super(other); 31 | } 32 | 33 | public void setSegmentVertexPos(int pos) { 34 | segment.qVertex.setPos(pos); 35 | } 36 | 37 | @Override 38 | public void setPos(int pos) { 39 | super.setPos(pos); 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "PVertex{" 45 | + "vertex=" 46 | + hashCode() 47 | + ", segment=" 48 | + segment 49 | + ", rank=" 50 | + rank 51 | + ", index=" 52 | + index 53 | + ", pos=" 54 | + pos 55 | + ", measure=" 56 | + measure 57 | + ", p=" 58 | + p 59 | + '}'; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/QVertex.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.eiglsperger; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | /** 7 | * a vertex that is not in the original graph, but is synthesized in order to position bends in the 8 | * articulated edges of the SugiyamaLayoutAlgorithm A QVertex is the bottom vertex of a vertical 9 | * segment edge 10 | * 11 | * @param vertex type 12 | */ 13 | class QVertex extends SegmentVertex { 14 | 15 | private static final Logger log = LoggerFactory.getLogger(QVertex.class); 16 | 17 | public static QVertex of() { 18 | return new QVertex(); 19 | } 20 | 21 | protected QVertex() { 22 | super(); 23 | } 24 | 25 | public QVertex(QVertex other) { 26 | super(other); 27 | } 28 | 29 | public QVertex copy() { 30 | return new QVertex<>(this); 31 | } 32 | 33 | @Override 34 | public void setPos(int pos) { 35 | super.setPos(pos); 36 | } 37 | 38 | public void setSegmentVertexPos(int pos) { 39 | segment.pVertex.setPos(pos); 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "QVertex{" 45 | + "vertex=" 46 | + hashCode() 47 | + ", segment=" 48 | + segment 49 | + ", rank=" 50 | + rank 51 | + ", index=" 52 | + index 53 | + ", pos=" 54 | + pos 55 | + ", measure=" 56 | + measure 57 | + ", p=" 58 | + p 59 | + '}'; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/eiglsperger/SegmentEdge.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.eiglsperger; 2 | 3 | import org.jungrapht.visualization.layout.algorithms.sugiyama.LE; 4 | import org.jungrapht.visualization.layout.algorithms.sugiyama.SyntheticLE; 5 | import org.jungrapht.visualization.layout.util.synthetics.Synthetic; 6 | 7 | /** 8 | * A {@code SegmentEdge} is a renaming extention of {@SytheticSugiyamaEdge} It is renamed to match 9 | * its use in the algorithm 10 | * 11 | * @param 12 | * @param 13 | */ 14 | class SegmentEdge extends SyntheticLE implements Synthetic { 15 | 16 | public static SegmentEdge of(LE edge, PVertex pVertex, QVertex qVertex) { 17 | 18 | return new SegmentEdge<>(edge, pVertex, qVertex); 19 | } 20 | 21 | protected SegmentEdge(LE edge, PVertex pVertex, QVertex qVertex) { 22 | super(edge, pVertex, qVertex); 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return "SegmentEdge{" + "edge=" + edge + ", pVertex=" + source + ", qVertex" + target + '}'; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Support for graph layout algorithms

6 | 7 |

There are no java.awt imports in this package and its sub packages

8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/repulsion/BarnesHutRepulsion.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.repulsion; 2 | 3 | import org.jungrapht.visualization.layout.model.LayoutModel; 4 | 5 | /** 6 | * @author Tom Nelson 7 | * @param the vertex type 8 | * @param the Repulsion type 9 | * @param the Repulsion Builder type 10 | */ 11 | public interface BarnesHutRepulsion< 12 | V, R extends BarnesHutRepulsion, B extends BarnesHutRepulsion.Builder> 13 | extends StandardRepulsion { 14 | 15 | interface Builder, B extends Builder> 16 | extends StandardRepulsion.Builder { 17 | 18 | B layoutModel(LayoutModel layoutModel); 19 | 20 | B theta(double theta); 21 | 22 | R build(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/repulsion/StandardRepulsion.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.repulsion; 2 | 3 | import java.util.Random; 4 | import org.jungrapht.visualization.layout.model.LayoutModel; 5 | 6 | /** 7 | * @author Tom Nelson 8 | * @param the vertex type 9 | * @param the Repulsion type 10 | * @param the Repulsion Builder type 11 | */ 12 | public interface StandardRepulsion< 13 | V, R extends StandardRepulsion, B extends StandardRepulsion.Builder> { 14 | 15 | interface Builder, B extends Builder> { 16 | 17 | B layoutModel(LayoutModel layoutModel); 18 | 19 | B random(Random random); 20 | 21 | R build(); 22 | } 23 | 24 | /** 25 | * called from the layout algorithm on every step. this version is a noop but the subclass 26 | * BarnesHut version rebuilds the tree on every step 27 | */ 28 | void step(); 29 | 30 | void calculateRepulsion(); 31 | } 32 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AllLevelCross.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import org.jgrapht.Graph; 4 | 5 | /** 6 | * Counts edge crossing on all levels 7 | * 8 | * @see "An E log E Line Crossing Algorithm for Levelled Graphs. Vance Waddle and Ashok Malhotra IBM 9 | * Thomas J. Watson Research Center" 10 | * @see "Simple and Efficient Bilayer Cross Counting. Wilhelm Barth, Petra Mutzel, Institut für 11 | * Computergraphik und Algorithmen Technische Universität Wien, Michael Jünger, Institut für 12 | * Informatik Universität zu Köln" 13 | */ 14 | public class AllLevelCross { 15 | 16 | final LV[][] levels; 17 | final Graph, LE> graph; 18 | 19 | public AllLevelCross(Graph, LE> graph, LV[][] levels) { 20 | this.levels = levels; 21 | this.graph = graph; 22 | } 23 | 24 | public int allLevelCross() { 25 | int count = 0; 26 | for (int i = 0; i < levels.length - 2; i++) { 27 | LevelCross levelCross = 28 | new LevelCross(graph, levels[i].length, i, levels[i + 1].length, i + 1); 29 | count += levelCross.levelCross(); 30 | } 31 | return count; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AverageMedian.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import java.util.Arrays; 4 | import java.util.Comparator; 5 | import org.jungrapht.visualization.layout.model.Point; 6 | 7 | public class AverageMedian { 8 | 9 | private static int comparePoints(Point p1, Point p2) { 10 | return Double.compare(p1.x, p2.x); 11 | } 12 | 13 | public static Point averageMedianPoint(Point... points) { 14 | Arrays.sort(points, Comparator.comparingDouble(p -> p.x)); 15 | int n = points.length; 16 | int floor = (int) Math.floor((n - 1) / 2.0); 17 | int ceil = (int) Math.ceil((n - 1) / 2.0); 18 | double avgx = (points[floor].x + points[ceil].x) / 2.0; 19 | double avgy = (points[floor].y + points[ceil].y) / 2.0; 20 | return Point.of(avgx, avgy); 21 | } 22 | 23 | public static Point medianPoint(Point... points) { 24 | Arrays.sort(points, Comparator.comparingDouble(p -> p.x)); 25 | int n = points.length; 26 | int floor = (int) Math.floor((n - 1) / 2.0); 27 | double avgx = points[floor].x; 28 | double avgy = points[floor].y; 29 | return Point.of(avgx, avgy); 30 | } 31 | 32 | public static Point averagePoint(Point... points) { 33 | double avgx = Arrays.stream(points).mapToDouble(p -> p.x).average().getAsDouble(); 34 | double avgy = Arrays.stream(points).mapToDouble(p -> p.y).average().getAsDouble(); 35 | return Point.of(avgx, avgy); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/sugiyama/Comparators.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import java.util.Comparator; 4 | 5 | public class Comparators { 6 | 7 | public static Comparator> sourceIndexComparator() { 8 | return Comparator.comparingInt(e -> e.getSource().getIndex()); 9 | } 10 | 11 | public static Comparator> targetIndexComparator() { 12 | return Comparator.comparingInt(e -> e.getTarget().getIndex()); 13 | } 14 | 15 | public static Comparator> biLevelEdgeComparator() { 16 | return Comparator.>comparingInt(e -> e.getSource().getIndex()) 17 | .thenComparingInt(e -> e.getTarget().getIndex()); 18 | } 19 | 20 | public static Comparator> biLevelEdgeComparatorReverse() { 21 | return Comparator.>comparingInt(e -> e.getTarget().getIndex()) 22 | .thenComparingInt(e -> e.getSource().getIndex()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/sugiyama/ConstructiveFeedbackArcFunction.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import java.util.Collection; 4 | import java.util.Comparator; 5 | import java.util.function.Function; 6 | import org.jgrapht.Graph; 7 | 8 | public class ConstructiveFeedbackArcFunction implements Function, Collection> { 9 | 10 | Comparator comparator; 11 | 12 | public ConstructiveFeedbackArcFunction(Comparator comparator) { 13 | this.comparator = comparator; 14 | } 15 | 16 | @Override 17 | public Collection apply(Graph graph) { 18 | ConstructiveCycleRemoval cycleRemoval = new ConstructiveCycleRemoval(graph); 19 | return cycleRemoval.getFeedbackArcs(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/sugiyama/DFSFeedbackArcGraphTransformer.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import java.util.Collection; 4 | import java.util.function.Function; 5 | import org.jgrapht.Graph; 6 | 7 | public class DFSFeedbackArcGraphTransformer implements Function, Graph> { 8 | 9 | Function edgeFactory; 10 | 11 | public DFSFeedbackArcGraphTransformer(Function edgeFactory) { 12 | this.edgeFactory = edgeFactory; 13 | } 14 | 15 | @Override 16 | public Graph apply(Graph graph) { 17 | DFSCycleRemoval greedyCycleRemoval = new DFSCycleRemoval(graph); 18 | Collection feedbackArcs = greedyCycleRemoval.getFeedbackArcs(); 19 | // reverse the direction of feedback arcs so that they no longer introduce cycles in the graph 20 | // the feedback arcs will be processed later to draw with the correct direction and correct articulation points 21 | for (E se : feedbackArcs) { 22 | V source = graph.getEdgeSource(se); 23 | V target = graph.getEdgeTarget(se); 24 | graph.removeEdge(se); 25 | E newEdge = edgeFactory.apply(se); 26 | graph.addEdge(target, source, newEdge); 27 | } 28 | return graph; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/sugiyama/DfsFeedbackArcFunction.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import java.util.Collection; 4 | import java.util.Comparator; 5 | import java.util.function.BiFunction; 6 | import org.jgrapht.Graph; 7 | 8 | public class DfsFeedbackArcFunction 9 | implements BiFunction, Comparator, Collection> { 10 | 11 | @Override 12 | public Collection apply(Graph graph, Comparator comparator) { 13 | DFSCycleRemoval dfsCycleRemoval = new DFSCycleRemoval(graph, comparator); 14 | return dfsCycleRemoval.getFeedbackArcs(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/sugiyama/GreedyFeedbackArcFunction.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import java.util.Collection; 4 | import java.util.function.Function; 5 | import org.jgrapht.Graph; 6 | 7 | public class GreedyFeedbackArcFunction implements Function, Collection> { 8 | 9 | @Override 10 | public Collection apply(Graph graph) { 11 | GreedyCycleRemoval greedyCycleRemoval = new GreedyCycleRemoval(graph); 12 | return greedyCycleRemoval.getFeedbackArcs(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/sugiyama/GreedyFeedbackArcGraphTransformer.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import java.util.Collection; 4 | import java.util.function.Function; 5 | import org.jgrapht.Graph; 6 | 7 | public class GreedyFeedbackArcGraphTransformer implements Function, Graph> { 8 | 9 | Function edgeFactory; 10 | 11 | public GreedyFeedbackArcGraphTransformer(Function edgeFactory) { 12 | this.edgeFactory = edgeFactory; 13 | } 14 | 15 | @Override 16 | public Graph apply(Graph graph) { 17 | GreedyCycleRemoval greedyCycleRemoval = new GreedyCycleRemoval(graph); 18 | Collection feedbackArcs = greedyCycleRemoval.getFeedbackArcs(); 19 | // reverse the direction of feedback arcs so that they no longer introduce cycles in the graph 20 | // the feedback arcs will be processed later to draw with the correct direction and correct articulation points 21 | for (E se : feedbackArcs) { 22 | V source = graph.getEdgeSource(se); 23 | V target = graph.getEdgeTarget(se); 24 | graph.removeEdge(se); 25 | E newEdge = edgeFactory.apply(se); 26 | graph.addEdge(target, source, newEdge); 27 | } 28 | return graph; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/sugiyama/LE.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import org.jungrapht.visualization.layout.util.synthetics.SE; 4 | 5 | /** 6 | * Interface for an edge type used for the application of a layered graph layout algorithm
7 | * Instances of LE<V,E> replace instances of E during layout 8 | * 9 | * @param vertex type 10 | * @param edge type 11 | */ 12 | public interface LE extends SE { 13 | 14 | static LE of(E edge, LV source, LV target) { 15 | return new LEI(edge, source, target); 16 | } 17 | 18 | LE swapped(); 19 | 20 | LV getSource(); 21 | 22 | LV getTarget(); 23 | } 24 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/sugiyama/LEI.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import java.util.Objects; 4 | import org.jungrapht.visualization.layout.util.synthetics.SEI; 5 | 6 | /** 7 | * Implementation of an edge type used for the application of a layered layout algorithm.
8 | * Instances of LEI<V,E> replace instances of E during layout 9 | * 10 | * @param vertex type 11 | * @param edge type 12 | */ 13 | public class LEI extends SEI implements LE { 14 | 15 | public final LV source; 16 | public final LV target; 17 | 18 | public LEI(E edge, LV source, LV target) { 19 | super(edge); 20 | this.source = source; 21 | this.target = target; 22 | } 23 | 24 | @Override 25 | public LEI swapped() { 26 | return new LEI<>(edge, target, source); 27 | } 28 | 29 | @Override 30 | public LV getSource() { 31 | return source; 32 | } 33 | 34 | @Override 35 | public LV getTarget() { 36 | return target; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return "LEI{" + "edge=" + edge + ", source=" + source + ", target=" + target + '}'; 42 | } 43 | 44 | @Override 45 | public boolean equals(Object o) { 46 | if (this == o) return true; 47 | if (o == null || getClass() != o.getClass()) return false; 48 | if (!super.equals(o)) return false; 49 | LEI that = (LEI) o; 50 | return Objects.equals(source, that.source) && Objects.equals(target, that.target); 51 | } 52 | 53 | @Override 54 | public int hashCode() { 55 | return Objects.hash(super.hashCode(), source, target); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/sugiyama/LV.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import org.jungrapht.visualization.layout.model.Point; 4 | import org.jungrapht.visualization.layout.util.synthetics.SV; 5 | 6 | /** 7 | * Interface for a vertex type for the SugiyamaLayoutAlgorithm.
8 | * Implementations of LV replace instances of V during layout The LV<V> holds metadata 9 | * information about the position of the vertex in the layered graph for the SugiyamaLayoutAlgorithm 10 | * 11 | * @param 12 | */ 13 | public interface LV extends SV { 14 | 15 | static LV of(V vertex) { 16 | return new LVI(vertex); 17 | } 18 | 19 | static LV of(V vertex, int rank, int index) { 20 | return new LVI(vertex, rank, index); 21 | } 22 | 23 | > T copy(); 24 | 25 | void setRank(int rank); 26 | 27 | int getRank(); 28 | 29 | void setIndex(int index); 30 | 31 | int getIndex(); 32 | 33 | Point getPoint(); 34 | 35 | void setPoint(Point p); 36 | 37 | int getPos(); 38 | 39 | void setPos(int pos); 40 | 41 | double getMeasure(); 42 | 43 | void setMeasure(double measure); 44 | } 45 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/sugiyama/Layering.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | public enum Layering { 4 | TOP_DOWN, 5 | LONGEST_PATH, 6 | COFFMAN_GRAHAM, 7 | NETWORK_SIMPLEX 8 | } 9 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/sugiyama/LinearTimeMedian.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | public final class LinearTimeMedian { 4 | 5 | private LinearTimeMedian() {} 6 | 7 | public static int select(int[] list) { 8 | if (list.length < 1) { 9 | throw new IllegalArgumentException(); 10 | } 11 | int pos = select(list, 0, list.length, list.length / 2); 12 | return list[pos]; 13 | } 14 | 15 | public static int select(int[] list, int lo, int hi, int k) { 16 | int n = hi - lo; 17 | if (n < 2) { 18 | return lo; 19 | } 20 | double pivot = list[lo + (k * 7919) % n]; 21 | 22 | int nLess = 0; 23 | int nSame = 0; 24 | int nMore = 0; 25 | int lo3 = lo; 26 | int hi3 = hi; 27 | while (lo3 < hi3) { 28 | double e = list[lo3]; 29 | int cmp = (int) (e - pivot); 30 | if (cmp < 0) { 31 | nLess++; 32 | lo3++; 33 | } else if (cmp > 0) { 34 | swap(list, lo3, --hi3); 35 | if (nSame > 0) { 36 | swap(list, hi3, hi3 + nSame); 37 | } 38 | nMore++; 39 | } else { 40 | nSame++; 41 | swap(list, lo3, --hi3); 42 | } 43 | } 44 | assert nSame > 0; 45 | assert nLess + nSame + nMore == n; 46 | assert list[hi - nMore - 1] == pivot; 47 | if (k >= n - nMore) { 48 | return select(list, hi - nMore, hi, k - nLess - nSame); 49 | } else if (k < nLess) { 50 | return select(list, lo, lo + nLess, k); 51 | } 52 | return lo + k; 53 | } 54 | 55 | static void swap(int[] array, int i, int j) { 56 | if (i == j) return; 57 | int temp = array[i]; 58 | array[i] = array[j]; 59 | array[j] = temp; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/sugiyama/NLogNMedian.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import java.util.Arrays; 4 | 5 | public final class NLogNMedian { 6 | 7 | private NLogNMedian() {} 8 | 9 | public static int median(int[] list) { 10 | int[] copy = list; 11 | Arrays.sort(copy); 12 | return copy[copy.length / 2]; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/sugiyama/SyntheticLE.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import org.jungrapht.visualization.layout.util.synthetics.Synthetic; 4 | 5 | /** 6 | * an edge that is not in the original graph, but is synthesized to replace one or more original 7 | * graph edges. 8 | * 9 | * @param vertex type 10 | * @param edge type 11 | */ 12 | public class SyntheticLE extends LEI implements Synthetic { 13 | 14 | public static SyntheticLE of(LE edge, LV source, LV target) { 15 | 16 | return new SyntheticLE(edge, source, target); 17 | } 18 | 19 | protected SyntheticLE(LE edge, LV source, LV target) { 20 | 21 | super(edge.getEdge(), source, target); 22 | this.se = edge; 23 | } 24 | 25 | /** 26 | * two synthetic edges are created by splitting an existing SE<V,E> edge. This is a 27 | * reference to that edge The edge what was split will gain an intermediate vertex between the 28 | * source and target vertices each time it or one of its split-off edges is further split 29 | */ 30 | protected LE se; 31 | 32 | @Override 33 | public boolean equals(Object o) { 34 | return this == o; 35 | } 36 | 37 | @Override 38 | public int hashCode() { 39 | return System.identityHashCode(this); 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "SyntheticLE{" + "edge=" + edge + ", source=" + source + ", target=" + target + '}'; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/sugiyama/SyntheticLV.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import org.jungrapht.visualization.layout.util.synthetics.Synthetic; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | /** 8 | * a vertex that is not in the original graph, but is synthesized in order to position bends in the 9 | * articulated edges of the SugiyamaLayoutAlgorithm 10 | * 11 | * @param vertex type 12 | */ 13 | public class SyntheticLV extends LVI implements Synthetic { 14 | 15 | private static final Logger log = LoggerFactory.getLogger(SyntheticLV.class); 16 | 17 | final int hash; 18 | 19 | public static SyntheticLV of() { 20 | return new SyntheticLV(); 21 | } 22 | 23 | protected SyntheticLV() { 24 | super(); 25 | this.hash = System.identityHashCode(this); 26 | } 27 | 28 | public SyntheticLV(SyntheticLV other) { 29 | super(other); 30 | this.hash = other.hash; 31 | } 32 | 33 | public > T copy() { 34 | return (T) new SyntheticLV<>(this); 35 | } 36 | 37 | @Override 38 | public boolean equals(Object o) { 39 | if (o instanceof SyntheticLV) { 40 | return hash == ((SyntheticLV) o).hash; 41 | } 42 | return false; 43 | } 44 | 45 | @Override 46 | public int hashCode() { 47 | return hash; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "SyntheticLV{" 53 | + "vertex=" 54 | + hashCode() 55 | + ", rank=" 56 | + rank 57 | + ", index=" 58 | + index 59 | + ", pos=" 60 | + pos 61 | + ", measure=" 62 | + measure 63 | + ", p=" 64 | + p 65 | + '}'; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/sugiyama/VertexMetadata.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | /** Holds the metadata for LVI vertices as an alternative to copying them */ 7 | public class VertexMetadata { 8 | 9 | Logger log = LoggerFactory.getLogger(VertexMetadata.class); 10 | 11 | protected int rank; // the layer number for this vertex 12 | protected int index; // the index within the layer array for this vertex 13 | protected int pos = -1; 14 | protected double measure = -1; // the median of the positions of the neighbors of this LV 15 | 16 | /** 17 | * store the metadata for the supplied vertex 18 | * 19 | * @param vertex 20 | * @param 21 | * @return 22 | */ 23 | public static VertexMetadata of(LV vertex) { 24 | return new VertexMetadata<>(vertex); 25 | } 26 | 27 | /** 28 | * apply the saved metadata to the supplied vertex 29 | * 30 | * @param v 31 | */ 32 | public void applyTo(LV v) { 33 | v.setRank(this.rank); 34 | v.setIndex(this.index); 35 | v.setPos(this.pos); 36 | v.setMeasure(this.measure); 37 | } 38 | 39 | VertexMetadata(LV vertex) { 40 | this.rank = vertex.getRank(); 41 | this.index = vertex.getIndex(); 42 | this.pos = vertex.getPos(); 43 | this.measure = vertex.getMeasure(); 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return "VertexMetadata{" 49 | + "rank=" 50 | + rank 51 | + ", index=" 52 | + index 53 | + ", pos=" 54 | + pos 55 | + ", measure=" 56 | + measure 57 | + '}'; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/util/AfterRunnable.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.util; 2 | 3 | /** Used to cause a LayoutAlgorithm to call a Runnable once it has completed */ 4 | public interface AfterRunnable { 5 | 6 | default void setAfter(Runnable after) {} 7 | 8 | default void runAfter() {} 9 | } 10 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/util/Cancellable.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.util; 2 | 3 | public interface Cancellable { 4 | void cancel(); 5 | } 6 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/util/DimensionConsumer.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.util; 2 | 3 | import java.util.Objects; 4 | import org.jungrapht.visualization.layout.model.Dimension; 5 | 6 | @FunctionalInterface 7 | public interface DimensionConsumer { 8 | void accept(Dimension dimension); 9 | 10 | default DimensionConsumer andThen(DimensionConsumer after) { 11 | Objects.requireNonNull(after); 12 | return (t) -> { 13 | this.accept(t); 14 | after.accept(t); 15 | }; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/util/EdgeArticulationFunctionSupplier.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.util; 2 | 3 | import java.util.Collections; 4 | import java.util.List; 5 | import java.util.function.Function; 6 | import org.jungrapht.visualization.layout.model.Point; 7 | 8 | public interface EdgeArticulationFunctionSupplier { 9 | 10 | default Function> getEdgeArticulationFunction() { 11 | return e -> Collections.emptyList(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/util/ExecutorConsumer.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.util; 2 | 3 | import java.util.concurrent.Executor; 4 | 5 | public interface ExecutorConsumer { 6 | 7 | void setExecutor(Executor executor); 8 | 9 | Executor getExecutor(); 10 | } 11 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/util/InsertionSortCounter.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.util; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * InsertionSort counter. Both List and Array versions are provided. For larger sizes (>100), 7 | * array is faster 8 | */ 9 | public class InsertionSortCounter { 10 | 11 | public static int insertionSortCounter(List list) { 12 | int counter = 0; 13 | for (int i = 1; i < list.size(); i++) { 14 | int value = list.get(i); 15 | int j = i - 1; 16 | while (j >= 0 && list.get(j) > value) { 17 | list.set(j + 1, list.get(j)); 18 | counter++; 19 | j--; 20 | } 21 | list.set(j + 1, value); 22 | } 23 | return counter; 24 | } 25 | 26 | public static int insertionSortCounter(int[] array) { 27 | int counter = 0; 28 | for (int i = 1; i < array.length; i++) { 29 | int value = array[i]; 30 | int j = i - 1; 31 | while (j >= 0 && array[j] > value) { 32 | array[j + 1] = array[j]; 33 | counter++; 34 | j--; 35 | } 36 | array[j + 1] = value; 37 | } 38 | return counter; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/util/IterativeContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, The JUNG Authors 3 | * 4 | * All rights reserved. 5 | * 6 | * This software is open-source under the BSD license; see either 7 | * "license.txt" or 8 | * https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 9 | */ 10 | package org.jungrapht.visualization.layout.algorithms.util; 11 | 12 | /** 13 | * An interface for algorithms that proceed iteratively. Each call to step() will 14 | * advance the algorithm by one cycle thru the affected members. 15 | */ 16 | public interface IterativeContext { 17 | 18 | /** Advances one step. */ 19 | void step(); 20 | 21 | /** @return {@code true} if this iterative process is finished, and {@code false} otherwise. */ 22 | boolean done(); 23 | } 24 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/util/LayeredRunnable.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.util; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import org.jungrapht.visualization.layout.model.Point; 6 | 7 | public interface LayeredRunnable extends Runnable { 8 | 9 | Map> getEdgePointMap(); 10 | 11 | void cancel(); 12 | } 13 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/util/Pair.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.util; 2 | 3 | import java.util.Objects; 4 | 5 | public class Pair { 6 | public final V first; 7 | public final V second; 8 | 9 | public static Pair of(V first, V second) { 10 | return new Pair(first, second); 11 | } 12 | 13 | private Pair(V first, V second) { 14 | this.first = first; 15 | this.second = second; 16 | } 17 | 18 | @Override 19 | public boolean equals(Object o) { 20 | if (this == o) return true; 21 | if (o == null || getClass() != o.getClass()) return false; 22 | Pair pair = (Pair) o; 23 | return Objects.equals(first, pair.first) && Objects.equals(second, pair.second); 24 | } 25 | 26 | @Override 27 | public int hashCode() { 28 | return Objects.hash(first, second); 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "Pair{" + first + "," + second + '}'; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/util/PointConsumer.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.util; 2 | 3 | import java.util.Objects; 4 | import org.jungrapht.visualization.layout.model.Point; 5 | 6 | @FunctionalInterface 7 | public interface PointConsumer { 8 | void accept(Point p); 9 | 10 | default PointConsumer andThen(PointConsumer after) { 11 | Objects.requireNonNull(after); 12 | return (t) -> { 13 | this.accept(t); 14 | after.accept(t); 15 | }; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/util/RectangleConsumer.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.util; 2 | 3 | import java.util.Objects; 4 | import org.jungrapht.visualization.layout.model.Rectangle; 5 | 6 | @FunctionalInterface 7 | public interface RectangleConsumer { 8 | void accept(Rectangle rectangle); 9 | 10 | default RectangleConsumer andThen(RectangleConsumer after) { 11 | Objects.requireNonNull(after); 12 | return (t) -> { 13 | this.accept(t); 14 | after.accept(t); 15 | }; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/util/SubGraphFunction.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.util; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Set; 6 | import java.util.function.Function; 7 | import org.jgrapht.Graph; 8 | import org.jgrapht.Graphs; 9 | import org.jgrapht.alg.connectivity.ConnectivityInspector; 10 | import org.jgrapht.graph.builder.GraphTypeBuilder; 11 | 12 | public class SubGraphFunction implements Function, List>> { 13 | 14 | @Override 15 | public List> apply(Graph graph) { 16 | List> subGraphList = new ArrayList<>(); 17 | 18 | ConnectivityInspector connectivityInspector = new ConnectivityInspector<>(graph); 19 | List> componentVertices = connectivityInspector.connectedSets(); 20 | if (componentVertices.size() > 1) { 21 | for (Set vertexSet : componentVertices) { 22 | // get the graph for these vertices 23 | Graph subGraph = GraphTypeBuilder.forGraph(graph).buildGraph(); 24 | vertexSet.forEach(subGraph::addVertex); 25 | for (V v : vertexSet) { 26 | // get neighbors 27 | Graphs.successorListOf(graph, v) 28 | .forEach(s -> subGraph.addEdge(v, s, graph.getEdge(v, s))); 29 | Graphs.predecessorListOf(graph, v) 30 | .forEach(p -> subGraph.addEdge(p, v, graph.getEdge(p, v))); 31 | } 32 | subGraphList.add(subGraph); 33 | } 34 | } 35 | return subGraphList; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/util/Threaded.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.util; 2 | 3 | public interface Threaded { 4 | 5 | boolean isThreaded(); 6 | 7 | void setThreaded(boolean threaded); 8 | 9 | void cancel(); 10 | 11 | static Threaded noop() { 12 | if (NoOp.INSTANCE == null) { 13 | NoOp.INSTANCE = new NoOp(); 14 | } 15 | return NoOp.INSTANCE; 16 | } 17 | 18 | class NoOp implements Threaded { 19 | 20 | static Threaded INSTANCE; 21 | 22 | @Override 23 | public boolean isThreaded() { 24 | return false; 25 | } 26 | 27 | @Override 28 | public void setThreaded(boolean threaded) {} 29 | 30 | @Override 31 | public void cancel() {} 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/util/VertexBoundsFunctionConsumer.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.util; 2 | 3 | import java.util.function.Consumer; 4 | import java.util.function.Function; 5 | import org.jungrapht.visualization.layout.model.Rectangle; 6 | 7 | public interface VertexBoundsFunctionConsumer extends Consumer> { 8 | 9 | void setVertexBoundsFunction(Function vertexBoundsFunction); 10 | 11 | default void accept(Function vertexBoundsFunction) { 12 | setVertexBoundsFunction(vertexBoundsFunction); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/algorithms/util/VertexShapeAware.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.util; 2 | 3 | import java.util.function.Function; 4 | import org.jungrapht.visualization.layout.model.Rectangle; 5 | 6 | public interface VertexShapeAware { 7 | 8 | void setVertexShapeFunction(Function vertexShapeFunction); 9 | } 10 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/event/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Support for graph layout related events

6 | 7 |

There are no java.awt imports in this package and its sub packages

8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/model/LocationUtil.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.model; 2 | 3 | /** Utility to use where mutable points were required in older code */ 4 | public class LocationUtil { 5 | 6 | public static void set(LayoutModel layoutModel, V v, Point p) { 7 | layoutModel.set(v, p); 8 | } 9 | 10 | public static void offset(LayoutModel layoutModel, V v, Point p) { 11 | if (layoutModel.get(v) != null) { 12 | layoutModel.set(v, layoutModel.get(v).add(p)); 13 | } else { 14 | layoutModel.set(v, p); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/model/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Support for graph layout models mapping vertices to location points

6 | 7 |

There are no java.awt imports in this package and its sub packages

8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Support for graph layout models and graph layout algorithms

6 | 7 |

There are no java.awt imports in this package and its sub packages

8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/quadtree/TreeNode.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.quadtree; 2 | 3 | import java.util.Collection; 4 | import org.jungrapht.visualization.layout.model.Rectangle; 5 | 6 | /** @author Tom Nelson */ 7 | public interface TreeNode { 8 | 9 | Rectangle getBounds(); 10 | 11 | Collection getChildren(); 12 | } 13 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/quadtree/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Support for spatial optimization of graph layout algorithms

6 | 7 |

There are no java.awt imports in this package and its sub packages

8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/util/Caching.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * 9 | */ 10 | package org.jungrapht.visualization.layout.util; 11 | 12 | /** 13 | * Interface to provide external controls to an implementing class that manages a cache. 14 | * 15 | * @author Tom Nelson 16 | */ 17 | public interface Caching { 18 | /** clear cache */ 19 | void clear(); 20 | } 21 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/util/EdgeAccessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICEVSE for a description. 7 | * 8 | * 9 | */ 10 | package org.jungrapht.visualization.layout.util; 11 | 12 | import org.jungrapht.visualization.layout.model.LayoutModel; 13 | import org.jungrapht.visualization.layout.model.Point; 14 | 15 | /** 16 | * Interface for coordinate-based selection of graph edges. 17 | * 18 | * @author Tom Nelson 19 | */ 20 | public interface EdgeAccessor { 21 | 22 | /** 23 | * @param layoutModel the source of Edge positions 24 | * @param p the pick point 25 | * @return the vertex associated with the pick point 26 | */ 27 | E getEdge(LayoutModel layoutModel, Point p); 28 | 29 | /** 30 | * Returns the edge, if any, associated with (x, y). 31 | * 32 | * @param x the x coordinate of the pick point 33 | * @param y the y coordinate of the pick point 34 | * @return the edge associated with (x, y) 35 | */ 36 | E getEdge(LayoutModel layoutModel, double x, double y); 37 | } 38 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/util/LeftToRight.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.util; 2 | 3 | import org.jungrapht.visualization.layout.model.LayoutModel; 4 | import org.jungrapht.visualization.layout.model.Point; 5 | 6 | /** 7 | * When passed as the after function to a LayoutAlgorithm, will place the points from left to right 8 | * instead of top to bottom 9 | * 10 | * @param 11 | */ 12 | public class LeftToRight implements Runnable { 13 | LayoutModel layoutModel; 14 | 15 | public LeftToRight(LayoutModel layoutModel) { 16 | this.layoutModel = layoutModel; 17 | } 18 | 19 | @Override 20 | public void run() { 21 | layoutModel 22 | .getLocations() 23 | .forEach((v, p) -> layoutModel.set(v, Point.of(p.y, layoutModel.getWidth() - p.x))); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/util/PropertyLoader.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.util; 2 | 3 | import java.io.InputStream; 4 | 5 | public class PropertyLoader { 6 | 7 | public static final String PREFIX = "jungrapht."; 8 | 9 | private static boolean loaded; 10 | 11 | public static void load() { 12 | if (!loaded) { 13 | loadFromDefault(); 14 | loadFromAppName(); 15 | loaded = true; 16 | } 17 | } 18 | 19 | private PropertyLoader() {} 20 | 21 | private static final String PROPERTIES_FILE_NAME = 22 | System.getProperty("jungrapht.properties.file.name", PREFIX + "properties"); 23 | 24 | private static boolean loadFromAppName() { 25 | try { 26 | String launchProgram = System.getProperty("sun.java.command"); 27 | if (launchProgram != null && !launchProgram.isEmpty()) { 28 | launchProgram = launchProgram.substring(launchProgram.lastIndexOf('.') + 1) + ".properties"; 29 | InputStream stream = PropertyLoader.class.getResourceAsStream("/" + launchProgram); 30 | System.getProperties().load(stream); 31 | 32 | stream.close(); 33 | return true; 34 | } 35 | } catch (Exception ex) { 36 | } 37 | return false; 38 | } 39 | 40 | private static boolean loadFromDefault() { 41 | try { 42 | InputStream stream = PropertyLoader.class.getResourceAsStream("/" + PROPERTIES_FILE_NAME); 43 | System.getProperties().load(stream); 44 | stream.close(); 45 | return true; 46 | } catch (Exception ex) { 47 | } 48 | return false; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/util/RightToLeft.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.util; 2 | 3 | import org.jungrapht.visualization.layout.model.LayoutModel; 4 | import org.jungrapht.visualization.layout.model.Point; 5 | 6 | /** 7 | * When passed as the after function to a LayoutAlgorithm, will place the points from right to left 8 | * instead of top to bottom 9 | * 10 | * @param 11 | */ 12 | public class RightToLeft implements Runnable { 13 | LayoutModel layoutModel; 14 | 15 | public RightToLeft(LayoutModel layoutModel) { 16 | this.layoutModel = layoutModel; 17 | } 18 | 19 | @Override 20 | public void run() { 21 | layoutModel 22 | .getLocations() 23 | .forEach((v, p) -> layoutModel.set(v, Point.of(layoutModel.getHeight() - p.y, p.x))); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/util/VertexAccessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * 9 | */ 10 | package org.jungrapht.visualization.layout.util; 11 | 12 | import org.jungrapht.visualization.layout.model.LayoutModel; 13 | import org.jungrapht.visualization.layout.model.Point; 14 | 15 | /** 16 | * Interface for coordinate-based selection of graph vertices. 17 | * 18 | * @author Tom Nelson 19 | */ 20 | public interface VertexAccessor { 21 | 22 | /** 23 | * @param layoutModel the source of graph element locations 24 | * @param p the pick point 25 | * @return the vertex associated with the pick point 26 | */ 27 | V getVertex(LayoutModel layoutModel, Point p); 28 | 29 | /** 30 | * Returns the vertex, if any, associated with (x, y). 31 | * 32 | * @param x the x coordinate of the pick point 33 | * @param y the y coordinate of the pick point 34 | * @return the vertex associated with (x, y) 35 | */ 36 | V getVertex(LayoutModel layoutModel, double x, double y); 37 | 38 | V getClosestVertex(LayoutModel layoutModel, V v); 39 | } 40 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/util/VisRunnable.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.util; 2 | 3 | import org.jungrapht.visualization.layout.algorithms.util.IterativeContext; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | /** 8 | * a {@code Runnable} object to pass to the {@code Thread} that will perform the relax function on a 9 | * graph layout 10 | * 11 | * @author Tom Nelson 12 | */ 13 | public class VisRunnable implements Runnable { 14 | 15 | private static final Logger log = LoggerFactory.getLogger(VisRunnable.class); 16 | private final IterativeContext iterativeContext; 17 | private long sleepTime = 10; 18 | private boolean stop = false; 19 | 20 | public static VisRunnable noop() { 21 | return new VisRunnable(null) { 22 | public void run() {} 23 | }; 24 | } 25 | 26 | public VisRunnable(IterativeContext iterativeContext) { 27 | log.trace("created a VisRunnable {} for {}", hashCode(), iterativeContext); 28 | this.iterativeContext = iterativeContext; 29 | } 30 | 31 | public void stop() { 32 | log.trace("told {} to stop", this); 33 | stop = true; 34 | } 35 | 36 | @Override 37 | public void run() { 38 | while (!iterativeContext.done() && !stop) { 39 | try { 40 | iterativeContext.step(); 41 | try { 42 | Thread.sleep(sleepTime); 43 | } catch (InterruptedException ex) { 44 | } 45 | } catch (Exception ex) { 46 | ex.printStackTrace(); 47 | } 48 | } 49 | if (stop) { 50 | log.trace("done here because {} stop = {}", hashCode(), stop); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/util/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Utilities for graph layout models and graph layout algorithms

6 | 7 |

There are no java.awt imports in this package and its sub packages

8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/util/synthetics/SE.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.util.synthetics; 2 | 3 | /** 4 | * Interface for a delegate class for a generic edge of type E 5 | * 6 | * @param edge type 7 | */ 8 | public interface SE { 9 | 10 | static SE of(E edge) { 11 | return new SEI(edge); 12 | } 13 | 14 | E getEdge(); 15 | } 16 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/util/synthetics/SEI.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.util.synthetics; 2 | 3 | import java.util.Objects; 4 | 5 | /** 6 | * Implementation of a delegate class for a generic edge of type E 7 | * 8 | * @param edge type 9 | */ 10 | public class SEI implements SE { 11 | 12 | public final E edge; 13 | 14 | public SEI(E edge) { 15 | this.edge = edge; 16 | } 17 | 18 | @Override 19 | public E getEdge() { 20 | return edge; 21 | } 22 | 23 | @Override 24 | public String toString() { 25 | return "SE{" + "edge=" + edge + "hash:" + hashCode() + "'}'"; 26 | } 27 | 28 | @Override 29 | public boolean equals(Object o) { 30 | if (this == o) return true; 31 | if (o == null || getClass() != o.getClass()) return false; 32 | SEI se = (SEI) o; 33 | return Objects.equals(edge, se.edge); 34 | } 35 | 36 | @Override 37 | public int hashCode() { 38 | return Objects.hash(edge); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/util/synthetics/SV.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.util.synthetics; 2 | 3 | /** 4 | * Interface for a delegate class for a generic type V 5 | * 6 | * @param vertex type 7 | */ 8 | public interface SV { 9 | 10 | static SV of(V vertex) { 11 | return new SVI(vertex); 12 | } 13 | 14 | V getVertex(); 15 | } 16 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/util/synthetics/SVI.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.util.synthetics; 2 | 3 | import java.util.Objects; 4 | 5 | /** 6 | * Implementation of a delegate class for a generic type V 7 | * 8 | * @param vertex type 9 | */ 10 | public class SVI implements SV { 11 | 12 | public final V vertex; 13 | 14 | protected SVI() { 15 | this.vertex = null; 16 | } 17 | 18 | protected SVI(V vertex) { 19 | this.vertex = vertex; 20 | } 21 | 22 | public SVI(SVI other) { 23 | this(other.vertex); 24 | } 25 | 26 | @Override 27 | public V getVertex() { 28 | return vertex; 29 | } 30 | 31 | @Override 32 | public boolean equals(Object o) { 33 | if (this == o) return true; 34 | if (o == null || getClass() != o.getClass()) return false; 35 | SVI se = (SVI) o; 36 | if (o instanceof SyntheticSV) { 37 | return false; 38 | } 39 | return Objects.equals(vertex, se.vertex); 40 | } 41 | 42 | @Override 43 | public int hashCode() { 44 | return Objects.hash(vertex); 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "SV{" + "vertex=" + vertex + '}'; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/util/synthetics/SVTransformedGraphSupplier.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.util.synthetics; 2 | 3 | import java.util.function.Function; 4 | import java.util.function.Supplier; 5 | import org.jgrapht.Graph; 6 | 7 | /** 8 | * Serves as a {@code Supplier} for a Graph<V, E> transformed to a Graph<SV<V>, 9 | * SE<E>> 10 | * 11 | * @param 12 | * @param 13 | */ 14 | public class SVTransformedGraphSupplier implements Supplier, SE>> { 15 | 16 | protected Graph graph; 17 | 18 | public SVTransformedGraphSupplier(Graph graph) { 19 | this.graph = graph; 20 | } 21 | 22 | protected SingletonTransformer> vertexTransformer; 23 | 24 | public SingletonTransformer> getVertexTransformer() { 25 | return vertexTransformer; 26 | } 27 | 28 | /** 29 | * Transform and return the graph 30 | * 31 | * @return a Graph<SV<V>, SE<E>> 32 | */ 33 | @Override 34 | public Graph, SE> get() { 35 | Function> vertexTransformFunction = SV::of; 36 | vertexTransformer = new SingletonTransformer<>(vertexTransformFunction); 37 | 38 | Function> edgeTransformFunction = e -> SE.of(e); 39 | SingletonTransformer> edgeTransformer = 40 | new SingletonTransformer<>(edgeTransformFunction); 41 | 42 | TransformingGraphView.Builder, E, SE, ?, ?> builder = 43 | TransformingGraphView., E, SE>builder(graph) 44 | .vertexTransformFunction(vertexTransformer) 45 | .edgeTransformFunction(edgeTransformer); 46 | 47 | TransformingGraphView, E, SE> graphView = builder.build(); 48 | return graphView.build(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/util/synthetics/SingletonTransformer.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.util.synthetics; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import java.util.function.Function; 6 | 7 | /** 8 | * Transform the key of type S to a value of type T. If the transform has been accessed before, 9 | * return that cached result. 10 | * 11 | * @param the key type 12 | * @param the value type 13 | */ 14 | public class SingletonTransformer implements Function { 15 | 16 | Map transformedMap = new HashMap<>(); 17 | Function transformFunction; 18 | 19 | public SingletonTransformer(Function transformFunction) { 20 | this.transformFunction = transformFunction; 21 | } 22 | 23 | @Override 24 | public T apply(S s) { 25 | return transformedMap.computeIfAbsent(s, transformFunction); 26 | } 27 | 28 | public Map getTransformedMap() { 29 | return transformedMap; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/util/synthetics/Synthetic.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.util.synthetics; 2 | 3 | public interface Synthetic {} 4 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/util/synthetics/SyntheticSE.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.util.synthetics; 2 | 3 | /** 4 | * an edge that is not in the original graph, 5 | * 6 | * @param edge type 7 | */ 8 | public class SyntheticSE extends SEI implements Synthetic { 9 | 10 | public SyntheticSE() { 11 | super(null); 12 | } 13 | 14 | @Override 15 | public boolean equals(Object o) { 16 | return this == o; 17 | } 18 | 19 | @Override 20 | public int hashCode() { 21 | return System.identityHashCode(this); 22 | } 23 | 24 | @Override 25 | public String toString() { 26 | return "SyntheticEdge{" + "edge=" + edge + '}'; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /jungrapht-layout/src/main/java/org/jungrapht/visualization/layout/util/synthetics/SyntheticSV.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.util.synthetics; 2 | 3 | /** 4 | * a vertex that is not in the original graph, but is a subtype of SV 5 | * 6 | * @param vertex type 7 | */ 8 | public class SyntheticSV extends SVI implements Synthetic { 9 | 10 | final int hash; 11 | 12 | public SyntheticSV() { 13 | super(); 14 | this.hash = System.identityHashCode(this); 15 | } 16 | 17 | public SyntheticSV(SyntheticSV other) { 18 | super(); 19 | this.hash = other.hash; 20 | } 21 | 22 | @Override 23 | public boolean equals(Object o) { 24 | if (o instanceof SyntheticSV ssv) { 25 | return hash == ssv.hash; 26 | } 27 | return false; 28 | } 29 | 30 | @Override 31 | public int hashCode() { 32 | return hash; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "SyntheticVertex{" + "vertex=" + hashCode() + '}'; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /jungrapht-layout/src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ${project.name} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/ThingTest.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.stream.Collectors; 6 | import org.junit.jupiter.api.Test; 7 | 8 | public class ThingTest { 9 | 10 | static class Thing { 11 | static int counter; 12 | 13 | public boolean consider() { 14 | counter++; 15 | return true; 16 | } 17 | 18 | public int getCounter() { 19 | return counter; 20 | } 21 | } 22 | 23 | @Test 24 | public void testIt() { 25 | List list = new ArrayList(); 26 | for (int i = 0; i < 100; i++) { 27 | list.add(new Thing()); 28 | } 29 | 30 | int got = 31 | list.stream() 32 | .filter(Thing::consider) 33 | .map(Thing::getCounter) 34 | .collect(Collectors.toList()) 35 | .get(20); 36 | 37 | System.err.println("got " + got); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AvgMedianTests.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import java.util.Arrays; 4 | import org.junit.jupiter.api.Test; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | public class AvgMedianTests { 9 | 10 | private static Logger log = LoggerFactory.getLogger(AvgMedianTests.class); 11 | 12 | @Test 13 | public void testOne() { 14 | 15 | test(new int[] {0, 5, 10}); 16 | test(new int[] {5}); 17 | test(new int[0]); 18 | test(new int[] {0, 4}); 19 | test(new int[] {0, 5, 6, 10}); 20 | test(new int[] {0, 2, 3, 4, 5, 6, 9, 10}); 21 | } 22 | 23 | private void test(int[] P) { 24 | log.info("avg median of {} is {}", Arrays.toString(P), avgMedianValue(P)); 25 | } 26 | 27 | private double avgMedianValue(int[] P) { 28 | int m = (P.length) / 2; 29 | log.info("for {}, m = {}", Arrays.toString(P), m); 30 | if (P.length == 0) { 31 | return -1; 32 | } else if (P.length % 2 == 1) { 33 | return P[m]; 34 | } else if (P.length == 2) { 35 | return (P[0] + P[1]) / 2; 36 | } else { 37 | double left = P[m - 1] - P[0]; 38 | log.info("left is {}", left); 39 | double right = P[P.length - 1] - P[m]; 40 | log.info("right is {}", right); 41 | return (P[m - 1] * right + P[m] * left) / (left + right); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestDelegateVerticesAndEdges.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import static org.junit.jupiter.api.Assertions.*; 4 | 5 | import org.jungrapht.visualization.layout.util.synthetics.SVI; 6 | import org.jungrapht.visualization.layout.util.synthetics.Synthetic; 7 | import org.junit.jupiter.api.Test; 8 | 9 | public class TestDelegateVerticesAndEdges { 10 | 11 | @Test 12 | public void testVertices() { 13 | String a = "a"; 14 | String b = "b"; 15 | 16 | LV sa = LV.of(a); 17 | LV sb = LV.of(b); 18 | 19 | assertInstanceOf(SVI.class, sa); 20 | assertNotEquals(sa, sb); 21 | assertEquals(LV.of("a"), sa); 22 | LV syntheticA = new SyntheticLV<>(); 23 | assertNotEquals(syntheticA, sa); 24 | assertInstanceOf(Synthetic.class, syntheticA); 25 | } 26 | 27 | @Test 28 | public void testEdges() { 29 | 30 | LV sa = LV.of("a"); 31 | LV sb = LV.of("b"); 32 | LV sc = LV.of("c"); 33 | Integer edge1 = 1; 34 | int edge2 = 2; 35 | 36 | LE se1 = LE.of(edge1, sa, sb); 37 | LE se2 = LE.of(edge2, sa, sc); 38 | LE se3 = LE.of(2, sa, sc); 39 | assertInstanceOf(LEI.class, se1); 40 | assertInstanceOf(LEI.class, se2); 41 | assertNotEquals(se1, se2); 42 | assertEquals(se2, se3); 43 | assertInstanceOf(Synthetic.class, new SyntheticLE<>(se1, sa, sb)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/SingletonTransformerTest.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.util.synthetics; 2 | 3 | import static org.junit.jupiter.api.Assertions.*; 4 | 5 | import org.jungrapht.visualization.layout.util.synthetics.SingletonTransformer; 6 | import org.junit.jupiter.api.Test; 7 | 8 | /** 9 | * Test to ensure that keys return expected values, that a second transformation of the same key 10 | * will yield a result that is == to the first time, and that the underlying map does not grow when 11 | * a duplicate key is queried 12 | */ 13 | public class SingletonTransformerTest { 14 | 15 | @Test 16 | public void test() { 17 | SingletonTransformer singletonTransformer = 18 | new SingletonTransformer<>(i -> i + 1); 19 | 20 | int got2 = singletonTransformer.apply(1); 21 | int got3 = singletonTransformer.apply(2); 22 | 23 | assertEquals(2, got2); 24 | assertEquals(3, got3); 25 | 26 | int gotDupe = singletonTransformer.apply(1); 27 | assertTrue(gotDupe == got2); 28 | 29 | assertEquals(2, singletonTransformer.getTransformedMap().size()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/TestDelegateVerticesAndEdges.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.util.synthetics; 2 | 3 | import static org.junit.jupiter.api.Assertions.*; 4 | 5 | import org.jungrapht.visualization.layout.util.synthetics.SE; 6 | import org.jungrapht.visualization.layout.util.synthetics.SEI; 7 | import org.jungrapht.visualization.layout.util.synthetics.SV; 8 | import org.jungrapht.visualization.layout.util.synthetics.SVI; 9 | import org.jungrapht.visualization.layout.util.synthetics.Synthetic; 10 | import org.jungrapht.visualization.layout.util.synthetics.SyntheticSE; 11 | import org.jungrapht.visualization.layout.util.synthetics.SyntheticSV; 12 | import org.junit.jupiter.api.Test; 13 | 14 | public class TestDelegateVerticesAndEdges { 15 | 16 | @Test 17 | public void testVertices() { 18 | String a = "a"; 19 | String b = "b"; 20 | 21 | SV sa = SV.of(a); 22 | SV sb = SV.of(b); 23 | 24 | assertInstanceOf(SVI.class, sa); 25 | assertNotEquals(sa, sb); 26 | assertEquals(sa, SV.of("a")); 27 | SV syntheticA = new SyntheticSV(); 28 | assertNotEquals(syntheticA, sa); 29 | assertInstanceOf(Synthetic.class, syntheticA); 30 | } 31 | 32 | @Test 33 | public void testEdges() { 34 | 35 | Integer edge1 = 1; 36 | int edge2 = 2; 37 | 38 | SE se1 = SE.of(edge1); 39 | SE se2 = SE.of(edge2); 40 | SE se3 = SE.of(2); 41 | assertInstanceOf(SEI.class, se1); 42 | assertInstanceOf(SEI.class, se2); 43 | assertNotEquals(se1, se2); 44 | assertEquals(se2, se3); 45 | assertInstanceOf(Synthetic.class, new SyntheticSE<>()); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /jungrapht-layout/src/test/java/org/jungrapht/visualization/layout/model/ModelTest.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.model; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | public class ModelTest { 6 | 7 | @Test 8 | public void testIntersection() { 9 | Rectangle one = Rectangle.of(0, 0, 10, 10); 10 | Rectangle two = Rectangle.of(5, 5, 10, 10); 11 | 12 | Rectangle intersection = one.intersect(two); 13 | System.err.println("intersection is " + intersection); 14 | 15 | Rectangle three = Rectangle.of(20, 20, 10, 10); 16 | intersection = one.intersect(three); 17 | System.err.println("intersection is " + intersection); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /jungrapht-layout/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/assembly/assembly.xml: -------------------------------------------------------------------------------- 1 | 2 | dependencies 3 | 4 | zip 5 | 6 | false 7 | 8 | 9 | / 10 | false 11 | runtime 12 | 13 | 14 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/java/org/jungrapht/samples/io/CreateOutputFiles.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.samples.io; 2 | 3 | import static org.jungrapht.visualization.util.Attributed.*; 4 | 5 | import java.util.stream.Stream; 6 | import org.jgrapht.Graph; 7 | import org.jgrapht.graph.builder.GraphTypeBuilder; 8 | import org.jungrapht.samples.util.ASAILoader; 9 | 10 | public class CreateOutputFiles { 11 | 12 | public static void main(String[] args) { 13 | 14 | // make a graph 15 | Graph graph = 16 | GraphTypeBuilder.directed() 17 | .vertexSupplier(new ASSupplier()) 18 | .allowingSelfLoops(true) 19 | .allowingMultipleEdges(true) 20 | .edgeSupplier(new AISupplier()) 21 | .buildGraph(); 22 | 23 | String[] infiles = {"marvel-movie-graph.graphml", "ghidra.json"}; 24 | Stream.of(infiles) 25 | .forEach( 26 | f -> { 27 | // load from json 28 | ASAILoader.load(f, graph); 29 | // write to a format 30 | String location = "generated"; 31 | String name = f.substring(0, f.indexOf('.')); 32 | String[] suffix = {"graphml", "gml", "csv", "col", "json", "visio"}; 33 | Stream.of(suffix) 34 | .forEach(s -> ASAILoader.export(location + "/" + name + "." + s, graph)); 35 | }); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/java/org/jungrapht/samples/large/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 |

Sample applications to visualize 'larger' graphs. 13 | Current features demonstrated in the samples include: 14 |

    15 |
  • tunable ForceAtlas2 layout algorithm using I/O 16 |
  • Show Layouts with graphs from JGrapht io 17 |
18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/java/org/jungrapht/samples/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 |

Sample applications created using JUNGRAPHT 17 | Current features demonstrated in the samples include: 18 |

    19 |
  • visualization of changing graphs 20 |
  • visualization animation 21 |
  • layouts: BalloonLayout, TreeLayout, RadialTreeLayout, MinCross, TidierTree, GEM, and others 22 |
  • clustering, shortest path, minimum spanning tree 23 |
  • sublayouts 24 |
  • label variations: orientation, position 25 |
  • customization of color, shape, stroke 26 |
  • on-the-fly visualization filtering 27 |
  • graph editor 28 |
  • node 'collapsing' 29 |
  • multiple models, multiple views with the same model 30 |
  • nodes as Icons 31 |
  • magnifying lens overlay 32 |
  • satellite view 33 |
34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/java/org/jungrapht/samples/quadtree/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 |

Sample applications to visualize a Barnes Hut Quadtree 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/java/org/jungrapht/samples/rtree/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 |

Sample applications to visualize an RTree 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/java/org/jungrapht/samples/spatial/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 |

Sample applications showing spatial data structures 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/java/org/jungrapht/samples/sugiyama/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 |

Sample applications using Sugiyama layout and contributing algorithms 13 | Current features demonstrated in the samples include: 14 |

    15 |
  • BrandesKopf horizontal coordinate assignment 16 |
  • Eisperger optimization 17 |
  • LongestPath algorithm 18 |
  • NetworkSimplex algorithm 19 |
  • Coffman Graham algorithm 20 |
21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/java/org/jungrapht/samples/tree/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 |

Sample applications to visualize graphs with tree structure 12 | Current features demonstrated in the samples include: 13 |

    14 |
  • visualization of changing graphs 15 |
  • visualization animation 16 |
  • layouts: TidierTreeLayout, BalloonLayout, TreeLayout, RadialTreeLayout 17 |
  • minimum spanning tree 18 |
  • vertex 'collapsing' 19 |
20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/java/org/jungrapht/samples/util/IconPalette.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.samples.util; 2 | 3 | import java.awt.*; 4 | import java.awt.dnd.DnDConstants; 5 | import java.awt.dnd.DragSource; 6 | import javax.swing.*; 7 | import org.jungrapht.visualization.LayeredIcon; 8 | import org.jungrapht.visualization.control.dnd.VertexImageDragGestureListener; 9 | 10 | public class IconPalette extends JPanel { 11 | 12 | public IconPalette() { 13 | setLayout(new GridLayout(4, 3)); 14 | String[] iconNames = { 15 | "apple", 16 | "os", 17 | "x", 18 | "linux", 19 | "inputdevices", 20 | "wireless", 21 | "graphics3", 22 | "gamespcgames", 23 | "humor", 24 | "music", 25 | "privacy" 26 | }; 27 | 28 | var listener = new VertexImageDragGestureListener(); 29 | for (int i = 0; i < iconNames.length; i++) { 30 | String name = "/images/topic" + iconNames[i] + ".gif"; 31 | try { 32 | Icon icon = new LayeredIcon(new ImageIcon(IconPalette.class.getResource(name)).getImage()); 33 | var label = new JLabel(icon); 34 | DragSource ds = new DragSource(); 35 | ds.createDefaultDragGestureRecognizer(label, DnDConstants.ACTION_COPY, listener); 36 | label.setTransferHandler(new TransferHandler("icon")); 37 | add(label); 38 | } catch (Exception ex) { 39 | System.err.println("You need slashdoticons.jar in your classpath to see the image " + name); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/java/org/jungrapht/samples/util/SpanningTreeAdapter.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.samples.util; 2 | 3 | import org.jgrapht.Graph; 4 | import org.jgrapht.alg.interfaces.SpanningTreeAlgorithm; 5 | import org.jgrapht.alg.spanning.PrimMinimumSpanningTree; 6 | import org.jgrapht.graph.AsUndirectedGraph; 7 | import org.jgrapht.graph.DefaultGraphType; 8 | import org.jgrapht.graph.builder.GraphTypeBuilder; 9 | 10 | public class SpanningTreeAdapter { 11 | 12 | /** 13 | * @param graph input graph, directed or undirected 14 | * @param vertex type 15 | * @param edge type 16 | * @return a directed acyclic graph that contains all vertices and edges from the minimum spanning 17 | * tree of the input graph 18 | */ 19 | public static Graph getSpanningTree(Graph graph) { 20 | 21 | if (graph.getType().isDirected()) { 22 | // make a non-directed version 23 | graph = new AsUndirectedGraph(graph); 24 | } 25 | SpanningTreeAlgorithm prim = new PrimMinimumSpanningTree<>(graph); 26 | SpanningTreeAlgorithm.SpanningTree tree = prim.getSpanningTree(); 27 | Graph newGraph = GraphTypeBuilder.forGraphType(DefaultGraphType.dag()).buildGraph(); 28 | 29 | for (E edge : tree.getEdges()) { 30 | newGraph.addVertex(graph.getEdgeSource(edge)); 31 | newGraph.addVertex(graph.getEdgeTarget(edge)); 32 | newGraph.addEdge(graph.getEdgeSource(edge), graph.getEdgeTarget(edge), edge); 33 | } 34 | return newGraph; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/java/org/jungrapht/samples/util/TitlePaintable.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.samples.util; 2 | 3 | import java.awt.Color; 4 | import java.awt.Dimension; 5 | import java.awt.Font; 6 | import java.awt.FontMetrics; 7 | import java.awt.Graphics; 8 | import org.jungrapht.visualization.VisualizationViewer; 9 | 10 | public class TitlePaintable implements VisualizationViewer.Paintable { 11 | int x; 12 | int y; 13 | Font font; 14 | FontMetrics metrics; 15 | int swidth; 16 | int sheight; 17 | String title; 18 | Dimension overallSize; 19 | 20 | public TitlePaintable(String title, Dimension overallSize) { 21 | this.title = title; 22 | this.overallSize = overallSize; 23 | } 24 | 25 | public void setTitle(String title) { 26 | this.title = title; 27 | } 28 | 29 | public void paint(Graphics g) { 30 | Dimension d = overallSize; 31 | if (font == null) { 32 | font = new Font(g.getFont().getName(), Font.BOLD, 30); 33 | metrics = g.getFontMetrics(font); 34 | swidth = metrics.stringWidth(title); 35 | sheight = metrics.getMaxAscent() + metrics.getMaxDescent(); 36 | x = (d.width - swidth) / 2; 37 | y = (int) (d.height - sheight * 1.5); 38 | } 39 | g.setFont(font); 40 | Color oldColor = g.getColor(); 41 | g.setColor(Color.lightGray); 42 | 43 | x = overallSize.width / 4; 44 | y = 2 * overallSize.height / 3; 45 | drawString(g, title, x, y); 46 | g.setColor(oldColor); 47 | } 48 | 49 | void drawString(Graphics g, String text, int x, int y) { 50 | int lineHeight = g.getFontMetrics().getHeight(); 51 | for (String line : text.split("\n")) g.drawString(line, x, y += lineHeight); 52 | } 53 | 54 | public boolean useTransform() { 55 | return false; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/java/org/jungrapht/samples/util/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 |

Sample applications utilities 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/AddRemoveVertexDemo.properties: -------------------------------------------------------------------------------- 1 | jungrapht.edgeSpatialSupport=NONE 2 | jungrapht.vertexSpatialSupport=NONE 3 | 4 | jungrapht.lightweightCountThreshold=100 -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/BalloonLayoutDemo.properties: -------------------------------------------------------------------------------- 1 | #jungrapht.vertexFillColor=0x00FFFF 2 | jungrapht.pickedVertexFillColor=0x00FF00 3 | jungrapht.edgeShape=LINE 4 | #jungrapht.vertexSpatialSupport=GRID 5 | #jungrapht.edgeSpatialSupport=NONE 6 | jungrapht.vertexLabelPosition=CNTR 7 | #jungrapht.vertexShape=SQUARE 8 | jungrapht.vertexSize=20 9 | jungrapht.pickedEdgeColor=0xFF0000 10 | jungrapht.edgeColor=0x0000FF 11 | jungrapht.vertexLabelColor=0xFFFFFF 12 | jungrapht.edgeLabelColor=0x000000 13 | #jungrapht.vertexLabelFont=Arial-BOLD-18 14 | jungrapht.lightweightCountThreshold=10 15 | jungrapht.lightweightScaleThreshold=0.5 16 | 17 | jungrapht.edgeArrowLength=20 18 | # width of edge arrows 19 | jungrapht.edgeArrowWidth=16 20 | # depth of arrow notch 21 | jungrapht.edgeArrowNotchDepth=0.8 22 | jungrapht.edgeStroke=DASHED 23 | jungrapht.edgeWidth=2.f 24 | 25 | jungrapht.lensStrokeWidth=4.0 26 | 27 | jungrapht.arbitraryShapeSelection=true 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/GraphEditorDemo.properties: -------------------------------------------------------------------------------- 1 | jungrapht.enableDoubleClickScaleReset=false -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/L2RTreeLayoutDemo.properties: -------------------------------------------------------------------------------- 1 | #jungrapht.edgeSpatialSupport=NONE 2 | #jungrapht.vertexSpatialSupport=NONE 3 | 4 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/LensDemo.properties: -------------------------------------------------------------------------------- 1 | #jungrapht.vertexFillColor=0xFF00FF 2 | #jungrapht.pickedVertexFillColor=0x00FFFF 3 | jungrapht.edgeShape=QUAD_CURVE 4 | jungrapht.vertexSpatialSupport=RTREE 5 | jungrapht.edgeSpatialSupport=NONE 6 | jungrapht.vertexLabelPosition=CNTR 7 | #jungrapht.vertexShape=SQUARE 8 | jungrapht.vertexSize=20 9 | jungrapht.pickedEdgeColor=0xFF0000 10 | #jungrapht.edgeColor=0x0000FF 11 | jungrapht.vertexLabelColor=0xFFFFFF 12 | jungrapht.edgeLabelColor=0x000000 13 | #jungrapht.vertexLabelFont=Arial-BOLD-18 14 | 15 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/LensDemoWithDefaultGraphMouseProperyDriven.properties: -------------------------------------------------------------------------------- 1 | jungrapht.singleSelectionMask=MB1 2 | jungrapht.toggleSingleSelectionMask=MB1_MENU 3 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/LensDemoWithMultiSelectStrategy.properties: -------------------------------------------------------------------------------- 1 | #jungrapht.vertexFillColor=0xFF00FF 2 | #jungrapht.pickedVertexFillColor=0x00FFFF 3 | jungrapht.edgeShape=QUAD_CURVE 4 | #jungrapht.vertexSpatialSupport=GRID 5 | #jungrapht.edgeSpatialSupport=NONE 6 | jungrapht.vertexLabelPosition=CNTR 7 | jungrapht.vertexShape=SQUARE 8 | jungrapht.vertexSize=20 9 | jungrapht.pickedEdgeColor=0xFF0000 10 | #jungrapht.edgeColor=0x0000FF 11 | jungrapht.vertexLabelColor=0xFFFFFF 12 | jungrapht.edgeLabelColor=0x000000 13 | #jungrapht.vertexLabelFont=Arial-BOLD-18 14 | jungrapht.singleSelectionMask=MB1 15 | jungrapht.toggleSingleSelectionMask=MB1_MENU 16 | 17 | 18 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/MinimalOrthogonal.properties: -------------------------------------------------------------------------------- 1 | jungrapht.minScale=0.0000001 2 | jungrapht.maxScale=100000.0 -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/PerformanceGraph.properties: -------------------------------------------------------------------------------- 1 | #jungrapht.vertexFillColor=0xFF00FF 2 | #jungrapht.pickedVertexFillColor=0x00FFFF 3 | jungrapht.edgeShape=QUAD_CURVE 4 | jungrapht.vertexSpatialSupport=NONE 5 | jungrapht.edgeSpatialSupport=NONE 6 | jungrapht.vertexLabelPosition=CNTR 7 | #jungrapht.vertexShape=SQUARE 8 | jungrapht.vertexSize=20 9 | jungrapht.pickedEdgeColor=0xFF0000 10 | #jungrapht.edgeColor=0x0000FF 11 | jungrapht.vertexLabelColor=0xFFFFFF 12 | jungrapht.edgeLabelColor=0x000000 13 | #jungrapht.vertexLabelFont=Arial-BOLD-18 14 | 15 | jungrapht.lightweightScaleThreshold=1.1 16 | jungrapht.lightweightCountThreshold=100 17 | 18 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/RandomDAGExample.properties: -------------------------------------------------------------------------------- 1 | jungrapht.vertexFillColor=0xFF0000 2 | jungrapht.pickedVertexFillColor=0xFFFF00 3 | jungrapht.edgeShape=QUAD_CURVE 4 | jungrapht.vertexLabelPosition=SW 5 | jungrapht.vertexShape=CIRCLE 6 | jungrapht.vertexSize=20 7 | jungrapht.edgeColor=0x000000 8 | jungrapht.pickedEdgeColor=0xFFA500 9 | jungrapht.vertexLabelColor=0x000000 10 | jungrapht.edgeLabelColor=0x000000 11 | 12 | jungrapht.lightweightCountThreshold=10 13 | jungrapht.lightweightScaleThreshold=.5 14 | 15 | jungrapht.edgeSpatialSupport=RTREE 16 | jungrapht.vertexSpatialSupport=RTREE 17 | 18 | jungrapht.lensColor=0xEFEFEF 19 | 20 | jungrapht.pickAreaSize=10 21 | 22 | jungrapht.mincross.horizontalOffset=50 23 | jungrapht.mincross.verticalOffset=20 24 | 25 | #jungrapht.mincross.maxLevelCross=2 26 | 27 | 28 | # how many times to run the full all-level cross count 29 | #jungrapht.mincross.max.level.cross=2 30 | 31 | # how many time to iterate over the layers while swapping node positions 32 | #jungrapht.mincross.transpose.limit=2 33 | 34 | #jungrapht.mincross.eiglspergerThreshold=50 35 | jungrapht.mincross.useLongestPath=false 36 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/SatelliteViewRefactoredMouseDemo.properties: -------------------------------------------------------------------------------- 1 | jungrapht.singleSelectionMask=MB1 2 | jungrapht.toggleSingleSelectionMask=MB1_MENU 3 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/ShowLayoutsWithJGraphtIO.properties: -------------------------------------------------------------------------------- 1 | #jungrapht.vertexFillColor=0xFF00FF 2 | #jungrapht.pickedVertexFillColor=0x00FFFF 3 | jungrapht.edgeShape=QUAD_CURVE 4 | #jungrapht.vertexSpatialSupport=NONE 5 | jungrapht.edgeSpatialSupport=RTREE 6 | jungrapht.vertexLabelPosition=CNTR 7 | #jungrapht.vertexShape=SQUARE 8 | jungrapht.vertexSize=20 9 | jungrapht.pickedEdgeColor=0xFF0000 10 | #jungrapht.edgeColor=0x0000FF 11 | jungrapht.vertexLabelColor=0xFFFFFF 12 | jungrapht.edgeLabelColor=0x000000 13 | #jungrapht.vertexLabelFont=Arial-BOLD-18 14 | 15 | jungrapht.lightweightScaleThreshold=1.1 16 | jungrapht.lightweightCountThreshold=100 17 | 18 | jungrapht.pickAreaSize=50 19 | 20 | jungrapht.minScale=0.0001 21 | jungrapht.maxScale=1000 22 | 23 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/SpatialLensDemo.properties: -------------------------------------------------------------------------------- 1 | #jungrapht.vertexFillColor=0xFF00FF 2 | #jungrapht.pickedVertexFillColor=0x00FFFF 3 | jungrapht.edgeShape=QUAD_CURVE 4 | #jungrapht.vertexSpatialSupport=GRID 5 | #jungrapht.edgeSpatialSupport=NONE 6 | jungrapht.vertexLabelPosition=CNTR 7 | #jungrapht.vertexShape=SQUARE 8 | jungrapht.vertexSize=20 9 | jungrapht.pickedEdgeColor=0xFF0000 10 | #jungrapht.edgeColor=0x0000FF 11 | jungrapht.vertexLabelColor=0xFFFFFF 12 | jungrapht.edgeLabelColor=0x000000 13 | #jungrapht.vertexLabelFont=Arial-BOLD-18 14 | 15 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/SugiyamaAndEiglsperger.properties: -------------------------------------------------------------------------------- 1 | jungrapht.vertexFillColor=0xFF0000 2 | jungrapht.pickedVertexFillColor=0xFFFF00 3 | jungrapht.edgeShape=QUAD_CURVE 4 | jungrapht.vertexLabelPosition=SW 5 | jungrapht.vertexShape=CIRCLE 6 | jungrapht.vertexSize=20 7 | jungrapht.edgeColor=0x000000 8 | jungrapht.pickedEdgeColor=0xFFA500 9 | jungrapht.vertexLabelColor=0x000000 10 | jungrapht.edgeLabelColor=0x000000 11 | 12 | jungrapht.lightweightCountThreshold=10 13 | jungrapht.lightweightScaleThreshold=.5 14 | 15 | jungrapht.edgeSpatialSupport=RTREE 16 | jungrapht.vertexSpatialSupport=RTREE 17 | 18 | jungrapht.lensColor=0xEFEFEF 19 | 20 | jungrapht.pickAreaSize=10 21 | 22 | jungrapht.mincross.horizontalOffset=50 23 | jungrapht.mincross.verticalOffset=20 24 | 25 | jungrapht.mincross.maxLevelCross=10 26 | 27 | 28 | # how many times to run the full all-level cross count 29 | #jungrapht.mincross.max.level.cross=2 30 | 31 | # how many time to iterate over the layers while swapping node positions 32 | #jungrapht.mincross.transpose.limit=2 33 | 34 | jungrapht.mincross.eiglspergerThreshold=50 35 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/SugiyamaAndEiglspergerCopy.properties: -------------------------------------------------------------------------------- 1 | jungrapht.vertexFillColor=0xFF0000 2 | jungrapht.pickedVertexFillColor=0xFFFF00 3 | jungrapht.edgeShape=QUAD_CURVE 4 | jungrapht.vertexLabelPosition=SW 5 | jungrapht.vertexShape=CIRCLE 6 | jungrapht.vertexSize=20 7 | jungrapht.edgeColor=0x000000 8 | jungrapht.pickedEdgeColor=0xFFA500 9 | jungrapht.vertexLabelColor=0x000000 10 | jungrapht.edgeLabelColor=0x000000 11 | 12 | jungrapht.lightweightCountThreshold=10 13 | jungrapht.lightweightScaleThreshold=.5 14 | 15 | jungrapht.edgeSpatialSupport=RTREE 16 | jungrapht.vertexSpatialSupport=RTREE 17 | 18 | jungrapht.lensColor=0xEFEFEF 19 | 20 | jungrapht.pickAreaSize=10 21 | 22 | jungrapht.mincross.horizontalOffset=50 23 | jungrapht.mincross.verticalOffset=20 24 | 25 | jungrapht.mincross.maxLevelCross=10 26 | 27 | jungrapht.mincross.threaded=false 28 | 29 | 30 | # how many times to run the full all-level cross count 31 | #jungrapht.mincross.max.level.cross=2 32 | 33 | # how many time to iterate over the layers while swapping node positions 34 | #jungrapht.mincross.transpose.limit=2 35 | 36 | jungrapht.mincross.eiglspergerThreshold=50 37 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/Sandstone.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/Sandstone.jpg -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/china.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/china.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/france.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/france.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/germany.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/germany.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/japan.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/japan.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/lightning-s.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/lightning-s.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/political_world_map.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/political_world_map.jpg -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/russia.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/russia.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/spain.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/spain.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/topicapple.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/topicapple.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/topicgamespcgames.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/topicgamespcgames.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/topicgraphics3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/topicgraphics3.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/topichumor.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/topichumor.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/topicinputdevices.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/topicinputdevices.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/topiclinux.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/topiclinux.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/topicmusic.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/topicmusic.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/topicos.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/topicos.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/topicprivacy.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/topicprivacy.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/topicsample.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/topicsample.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/topicsample2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/topicsample2.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/topicwireless.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/topicwireless.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/topicx.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/topicx.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/images/united-states.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tomnelson/jungrapht-visualization/aa08d63795f2be6aa1bf59cc8e4ad6191c8b32a0/jungrapht-visualization-samples/src/main/resources/images/united-states.gif -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/main/resources/jungrapht.properties: -------------------------------------------------------------------------------- 1 | jungrapht.vertexFillColor=0xFF0000 2 | jungrapht.pickedVertexFillColor=0xFFFF00 3 | jungrapht.edgeShape=QUAD_CURVE 4 | jungrapht.vertexLabelPosition=SW 5 | jungrapht.vertexShape=CIRCLE 6 | jungrapht.vertexSize=20 7 | jungrapht.edgeColor=0x000000 8 | jungrapht.pickedEdgeColor=0xFFA500 9 | jungrapht.vertexLabelColor=0x000000 10 | jungrapht.edgeLabelColor=0x000000 11 | 12 | jungrapht.lightweightCountThreshold=19 13 | jungrapht.lightweightScaleThreshold=.5 14 | 15 | jungrapht.edgeSpatialSupport=RTREE 16 | jungrapht.vertexSpatialSupport=RTREE 17 | 18 | jungrapht.lensColor=0xEFEFEF 19 | 20 | jungrapht.pickAreaSize=10 21 | 22 | jungrapht.mincross.horizontalOffset=20 23 | jungrapht.mincross.verticalOffset=20 24 | 25 | 26 | # how many times to run the full all-level cross count 27 | #jungrapht.mincross.max.level.cross=2 28 | 29 | # how many time to iterate over the layers while swapping node positions 30 | #jungrapht.mincross.transpose.limit=2 31 | 32 | jungrapht.mincross.eiglspergerThreshold=100 33 | 34 | jungrapht.initialDimensionVertexDensity=0.2f 35 | -------------------------------------------------------------------------------- /jungrapht-visualization-samples/src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ${project.name} 4 | 5 | 6 | 7 | 8 | 9 |

10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /jungrapht-visualization/assembly.xml: -------------------------------------------------------------------------------- 1 | 2 | dependencies 3 | 4 | tar.gz 5 | 6 | false 7 | 8 | 9 | / 10 | false 11 | runtime 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/AbstractSatelliteVisualizationViewer.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization; 2 | 3 | /** 4 | * Provided as a public base class for extending the DefaultVisualizationViewer 5 | * 6 | * @param vertex type 7 | * @param edge type 8 | */ 9 | public abstract class AbstractSatelliteVisualizationViewer 10 | extends DefaultSatelliteVisualizationViewer { 11 | 12 | /** 13 | * Constructor for extending classes 14 | * 15 | * @param builder to set properties 16 | */ 17 | protected AbstractSatelliteVisualizationViewer( 18 | SatelliteVisualizationViewer.Builder builder) { 19 | super(builder); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/AbstractVisualizationModel.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization; 2 | 3 | /** 4 | * Provided as a public base class for extending the DefaultVisualizationModel 5 | * 6 | * @param vertex type 7 | * @param edge type 8 | */ 9 | public abstract class AbstractVisualizationModel extends DefaultVisualizationModel { 10 | 11 | /** 12 | * Constructor for extending classes 13 | * 14 | * @param builder to set properties 15 | */ 16 | protected AbstractVisualizationModel(VisualizationModel.Builder builder) { 17 | super(builder); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/AbstractVisualizationServer.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization; 2 | 3 | /** 4 | * Provided as a public base class for extending the DefaultVisualizationServer 5 | * 6 | * @param vertex type 7 | * @param edge type 8 | */ 9 | public class AbstractVisualizationServer extends DefaultVisualizationServer { 10 | 11 | /** 12 | * Constructor for extending classes 13 | * 14 | * @param builder to set properties 15 | */ 16 | protected AbstractVisualizationServer(Builder builder) { 17 | super(builder); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/AbstractVisualizationViewer.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization; 2 | 3 | /** 4 | * Provided as a public base class for extending the DefaultVisualizationViewer 5 | * 6 | * @param vertex type 7 | * @param edge type 8 | */ 9 | public abstract class AbstractVisualizationViewer extends DefaultVisualizationViewer { 10 | 11 | /** 12 | * Constructor for extending classes 13 | * 14 | * @param builder to set properties 15 | */ 16 | protected AbstractVisualizationViewer(VisualizationViewer.Builder builder) { 17 | super(builder); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/LayeredIcon.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization; 2 | 3 | import java.awt.Component; 4 | import java.awt.Dimension; 5 | import java.awt.Graphics; 6 | import java.awt.Image; 7 | import java.util.LinkedHashSet; 8 | import java.util.Set; 9 | import javax.swing.Icon; 10 | import javax.swing.ImageIcon; 11 | 12 | /** 13 | * An icon that is made up of a collection of Icons. They are rendered in layers starting with the 14 | * first Icon added (from the constructor). 15 | * 16 | * @author Tom Nelson 17 | */ 18 | @SuppressWarnings("serial") 19 | public class LayeredIcon extends ImageIcon { 20 | 21 | Set iconSet = new LinkedHashSet<>(); 22 | 23 | public LayeredIcon(Image image) { 24 | super(image); 25 | } 26 | 27 | public void paintIcon(Component c, Graphics g, int x, int y) { 28 | super.paintIcon(c, g, x, y); 29 | Dimension d = new Dimension(getIconWidth(), getIconHeight()); 30 | for (Icon icon : iconSet) { 31 | Dimension id = new Dimension(icon.getIconWidth(), icon.getIconHeight()); 32 | int dx = (d.width - id.width) / 2; 33 | int dy = (d.height - id.height) / 2; 34 | icon.paintIcon(c, g, x + dx, y + dy); 35 | } 36 | } 37 | 38 | public void add(Icon icon) { 39 | iconSet.add(icon); 40 | } 41 | 42 | public boolean remove(Icon icon) { 43 | return iconSet.remove(icon); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/MultiLayerTransformer.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization; 2 | 3 | import java.awt.Shape; 4 | import java.awt.geom.Point2D; 5 | import org.jungrapht.visualization.transform.BidirectionalTransformer; 6 | import org.jungrapht.visualization.transform.MutableTransformer; 7 | import org.jungrapht.visualization.transform.shape.ShapeTransformer; 8 | import org.jungrapht.visualization.util.ChangeEventSupport; 9 | 10 | public interface MultiLayerTransformer 11 | extends BidirectionalTransformer, ShapeTransformer, ChangeEventSupport { 12 | 13 | enum Layer { 14 | LAYOUT, 15 | VIEW 16 | } 17 | 18 | void setTransformer(Layer layer, MutableTransformer Function); 19 | 20 | MutableTransformer getTransformer(Layer layer); 21 | 22 | Point2D inverseTransform(Layer layer, Point2D p); 23 | 24 | Point2D inverseTransform(Layer layer, double x, double y); 25 | 26 | Point2D transform(Layer layer, Point2D p); 27 | 28 | Point2D transform(Layer layer, double x, double y); 29 | 30 | Shape transform(Layer layer, Shape shape); 31 | 32 | Shape inverseTransform(Layer layer, Shape shape); 33 | 34 | void setToIdentity(); 35 | } 36 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/PropertyLoader.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization; 2 | 3 | import java.io.InputStream; 4 | 5 | public class PropertyLoader { 6 | 7 | private static boolean loaded; 8 | 9 | public static void load() { 10 | if (!loaded) { 11 | loadFromDefault(); 12 | loadFromAppName(); 13 | loaded = true; 14 | } 15 | } 16 | 17 | private PropertyLoader() {} 18 | 19 | private static final String PREFIX = "jungrapht."; 20 | 21 | private static final String PROPERTIES_FILE_NAME = 22 | System.getProperty("jungrapht.properties.file.name", PREFIX + "properties"); 23 | 24 | private static boolean loadFromAppName() { 25 | try { 26 | String launchProgram = System.getProperty("sun.java.command"); 27 | if (launchProgram != null && !launchProgram.isEmpty()) { 28 | launchProgram = launchProgram.substring(launchProgram.lastIndexOf('.') + 1) + ".properties"; 29 | InputStream stream = PropertyLoader.class.getResourceAsStream("/" + launchProgram); 30 | System.getProperties().load(stream); 31 | 32 | // Properties props = System.getProperties(); 33 | return true; 34 | } 35 | } catch (Exception ex) { 36 | } 37 | return false; 38 | } 39 | 40 | private static boolean loadFromDefault() { 41 | try { 42 | InputStream stream = 43 | DefaultRenderContext.class.getResourceAsStream("/" + PROPERTIES_FILE_NAME); 44 | System.getProperties().load(stream); 45 | return true; 46 | } catch (Exception ex) { 47 | } 48 | return false; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/VisualizationComponent.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization; 2 | 3 | import java.awt.Color; 4 | import java.awt.Component; 5 | import java.awt.Cursor; 6 | import java.awt.Dimension; 7 | import java.awt.Font; 8 | import java.awt.LayoutManager; 9 | import java.awt.Rectangle; 10 | import javax.swing.*; 11 | 12 | public interface VisualizationComponent { 13 | 14 | JComponent getComponent(); 15 | 16 | /** @return the rectangular bounds */ 17 | Rectangle getBounds(); 18 | 19 | /** @return the background color */ 20 | Color getBackground(); 21 | 22 | /** @param backgroundColor the color to set */ 23 | void setBackground(Color backgroundColor); 24 | 25 | /** @param foregroundColor the color to set */ 26 | void setForeground(Color foregroundColor); 27 | /** @param cursor the cursor to set */ 28 | void setCursor(Cursor cursor); 29 | 30 | int getWidth(); 31 | 32 | int getHeight(); 33 | 34 | Dimension getPreferredSize(); 35 | 36 | void setPreferredSize(Dimension preferredSize); 37 | 38 | Dimension getSize(); 39 | 40 | String getToolTipText(); 41 | 42 | void setLayout(LayoutManager layout); 43 | 44 | void setFont(Font font); 45 | 46 | Font getFont(); 47 | 48 | Component add(Component component); 49 | 50 | void add(Component component, Object layout); 51 | } 52 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/annotations/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 |

Classes which support creating visual annotations for graphs. 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/control/EdgeEffects.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.control; 2 | 3 | import java.awt.geom.Point2D; 4 | import org.jungrapht.visualization.VisualizationServer; 5 | 6 | /** 7 | * @param vertex type 8 | * @param edge type 9 | */ 10 | public interface EdgeEffects { 11 | 12 | void startEdgeEffects(VisualizationServer vv, Point2D down, Point2D out); 13 | 14 | void midEdgeEffects(VisualizationServer vv, Point2D down, Point2D out); 15 | 16 | void endEdgeEffects(VisualizationServer vv); 17 | 18 | void startArrowEffects(VisualizationServer vv, Point2D down, Point2D out); 19 | 20 | void midArrowEffects(VisualizationServer vv, Point2D down, Point2D out); 21 | 22 | void endArrowEffects(VisualizationServer vv); 23 | } 24 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/control/EdgeSupport.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.control; 2 | 3 | import java.awt.geom.Point2D; 4 | import org.jungrapht.visualization.VisualizationServer; 5 | 6 | /** 7 | * interface to support the creation of new edges by the EditingGraphMousePlugin SimpleEdgeSupport 8 | * is a sample implementation 9 | * 10 | * @author Tom Nelson 11 | * @param the vertex type 12 | * @param the edge type 13 | */ 14 | public interface EdgeSupport { 15 | 16 | void startEdgeCreate(VisualizationServer vv, V startVertex, Point2D startPoint); 17 | 18 | void midEdgeCreate(VisualizationServer vv, Point2D midPoint); 19 | 20 | void endEdgeCreate(VisualizationServer vv, V endVertex); 21 | 22 | void abort(VisualizationServer vv); 23 | } 24 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/control/GraphElementAccessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * 9 | * Created on Apr 12, 2005 10 | */ 11 | package org.jungrapht.visualization.control; 12 | 13 | import java.awt.Shape; 14 | import java.util.Collection; 15 | import org.jungrapht.visualization.layout.model.LayoutModel; 16 | import org.jungrapht.visualization.layout.util.EdgeAccessor; 17 | import org.jungrapht.visualization.layout.util.VertexAccessor; 18 | 19 | /** 20 | * Interface for coordinate-based selection of graph components. 21 | * 22 | * @author Tom Nelson 23 | * @param the vertex type 24 | * @param the edge type 25 | */ 26 | public interface GraphElementAccessor extends VertexAccessor, EdgeAccessor { 27 | 28 | /** 29 | * @param shape the region in which the returned vertices are located 30 | * @return the vertices whose locations given by {@code layoutModel} are contained within {@code 31 | * shape} 32 | */ 33 | Collection getVertices(LayoutModel layoutModel, Shape shape); 34 | } 35 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/control/GraphMouseAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * Created on Jul 6, 2005 9 | */ 10 | 11 | package org.jungrapht.visualization.control; 12 | 13 | import java.awt.event.MouseAdapter; 14 | import java.awt.event.MouseEvent; 15 | 16 | /** 17 | * Simple extension of MouseAdapter that supplies modifier checking 18 | * 19 | * @author Tom Nelson 20 | */ 21 | public class GraphMouseAdapter extends MouseAdapter { 22 | 23 | protected int modifiers; 24 | 25 | public GraphMouseAdapter(int modifiers) { 26 | this.modifiers = modifiers; 27 | } 28 | 29 | public int getModifiersEx() { 30 | return modifiers; 31 | } 32 | 33 | public void setModifiers(int modifiers) { 34 | this.modifiers = modifiers; 35 | } 36 | 37 | protected boolean checkModifiers(MouseEvent e) { 38 | return e.getModifiersEx() == modifiers; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/control/GraphMouseListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, The JUNG Authors 3 | * 4 | * All rights reserved. 5 | * 6 | * This software is open-source under the BSD license; see either 7 | * "license.txt" or 8 | * https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 9 | */ 10 | /* 11 | * Created on Feb 17, 2004 12 | */ 13 | package org.jungrapht.visualization.control; 14 | 15 | import java.awt.event.MouseEvent; 16 | 17 | /** 18 | * This interface allows users to register listeners to register to receive vertex clicks. 19 | * 20 | * @author danyelf 21 | * @param vertex type 22 | */ 23 | @Deprecated 24 | public interface GraphMouseListener { 25 | 26 | void graphClicked(V v, MouseEvent me); 27 | 28 | void graphPressed(V v, MouseEvent me); 29 | 30 | void graphReleased(V v, MouseEvent me); 31 | } 32 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/control/GraphMousePlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * Created on Jul 6, 2005 9 | */ 10 | 11 | package org.jungrapht.visualization.control; 12 | 13 | import java.awt.event.MouseEvent; 14 | 15 | /** 16 | * the interface for all plugins to the PluggableGraphMouse 17 | * 18 | * @author Tom Nelson 19 | */ 20 | public interface GraphMousePlugin { 21 | 22 | /** @return the mouse event modifiers that will activate this plugin */ 23 | default int getModifiersEx() { 24 | return 0; 25 | } 26 | 27 | /** @param modifiers the mouse event modifiers that will activate this plugin */ 28 | default void setModifiers(int modifiers) {} 29 | 30 | /** 31 | * compare the set modifiers against those of the supplied event 32 | * 33 | * @param e an event to compare to 34 | * @return whether the member modifiers match the event modifiers 35 | */ 36 | default boolean checkModifiers(MouseEvent e) { 37 | return false; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/control/LensGraphMouse.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.control; 2 | 3 | import org.jungrapht.visualization.VisualizationViewer; 4 | 5 | public interface LensGraphMouse extends VisualizationViewer.GraphMouse { 6 | void setKillSwitch(Runnable killSwitch); 7 | } 8 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/control/ModalGraphMouse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * Created on Aug 26, 2005 9 | */ 10 | 11 | package org.jungrapht.visualization.control; 12 | 13 | import java.awt.event.KeyListener; 14 | import org.jungrapht.visualization.VisualizationViewer; 15 | import org.jungrapht.visualization.control.modal.Modal; 16 | 17 | /** 18 | * Interface for a GraphMouse that supports modality. 19 | * 20 | * @author Tom Nelson 21 | */ 22 | public interface ModalGraphMouse extends VisualizationViewer.GraphMouse, Modal { 23 | 24 | KeyListener getModeKeyListener(); 25 | } 26 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/control/ScalingControl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | */ 9 | package org.jungrapht.visualization.control; 10 | 11 | import static org.jungrapht.visualization.layout.util.PropertyLoader.PREFIX; 12 | 13 | import java.awt.geom.Point2D; 14 | import org.jungrapht.visualization.VisualizationServer; 15 | 16 | public interface ScalingControl { 17 | 18 | String MIN_SCALE = PREFIX + "minScale"; 19 | 20 | String MAX_SCALE = PREFIX + "maxScale"; 21 | 22 | String CROSSOVER = PREFIX + "crossover"; 23 | 24 | String ENABLE_SINGLE_AXIS_SCALING = PREFIX + "enableSingleAxisScaling"; 25 | 26 | enum Axis { 27 | XY, 28 | X, 29 | Y 30 | } 31 | /** 32 | * zoom the display in or out 33 | * 34 | * @param vv the VisualizationViewer 35 | * @param amount how much to adjust scale by 36 | * @param at where to adjust scale from 37 | */ 38 | @Deprecated 39 | default void scale(VisualizationServer vv, double amount, Point2D at) { 40 | scale(vv, amount, amount, at); 41 | } 42 | 43 | /** 44 | * zoom the display in or out 45 | * 46 | * @param vv the VisualizationViewer 47 | * @param horizontalAmount how much to adjust horizontal scale by 48 | * @param verticalAmount how much to adjust vertical scale by 49 | * @param at where to adjust scale from 50 | */ 51 | void scale( 52 | VisualizationServer vv, double horizontalAmount, double verticalAmount, Point2D at); 53 | } 54 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/control/SelectionIconListener.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.control; 2 | 3 | import java.awt.*; 4 | import java.awt.event.ItemEvent; 5 | import java.awt.event.ItemListener; 6 | import java.util.Collection; 7 | import java.util.function.Function; 8 | import javax.swing.*; 9 | import org.jungrapht.visualization.LayeredIcon; 10 | import org.jungrapht.visualization.renderers.Checkmark; 11 | 12 | public class SelectionIconListener implements ItemListener { 13 | Function imager; 14 | Icon checked; 15 | 16 | public SelectionIconListener(Function imager) { 17 | this.imager = imager; 18 | checked = new Checkmark(Color.red); 19 | } 20 | 21 | public void itemStateChanged(ItemEvent e) { 22 | if (e.getItem() instanceof Collection) { 23 | ((Collection) e.getItem()).forEach(n -> updatePickIcon(n, e.getStateChange())); 24 | } else { 25 | updatePickIcon((V) e.getItem(), e.getStateChange()); 26 | } 27 | } 28 | 29 | private void updatePickIcon(V n, int stateChange) { 30 | Icon icon = imager.apply(n); 31 | if (icon instanceof LayeredIcon layered) { 32 | if (stateChange == ItemEvent.SELECTED) { 33 | layered.add(checked); 34 | } else { 35 | layered.remove(checked); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/control/VertexSupport.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.control; 2 | 3 | import java.awt.geom.Point2D; 4 | import org.jungrapht.visualization.VisualizationServer; 5 | 6 | /** 7 | * interface to support the creation of new vertices by the EditingGraphMousePlugin. 8 | * SimpleVertexSupport is a sample implementation. 9 | * 10 | * @author Tom Nelson 11 | * @param vertex type 12 | * @param edge type 13 | */ 14 | public interface VertexSupport { 15 | 16 | void startVertexCreate(VisualizationServer vv, Point2D point); 17 | 18 | void midVertexCreate(VisualizationServer vv, Point2D point); 19 | 20 | void endVertexCreate(VisualizationServer vv, Point2D point); 21 | } 22 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/control/dnd/VertexImageDragGestureListener.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.control.dnd; 2 | 3 | import java.awt.datatransfer.DataFlavor; 4 | import java.awt.datatransfer.Transferable; 5 | import java.awt.datatransfer.UnsupportedFlavorException; 6 | import java.awt.dnd.DragGestureEvent; 7 | import java.awt.dnd.DragGestureListener; 8 | import java.io.IOException; 9 | import javax.swing.*; 10 | 11 | public class VertexImageDragGestureListener implements DragGestureListener { 12 | 13 | @Override 14 | public void dragGestureRecognized(DragGestureEvent event) { 15 | JLabel label = (JLabel) event.getComponent(); 16 | final ImageIcon ico = (ImageIcon) label.getIcon(); 17 | 18 | Transferable transferable = 19 | new Transferable() { 20 | @Override 21 | public DataFlavor[] getTransferDataFlavors() { 22 | return new DataFlavor[] {DataFlavor.imageFlavor}; 23 | } 24 | 25 | @Override 26 | public boolean isDataFlavorSupported(DataFlavor flavor) { 27 | return true; 28 | } 29 | 30 | @Override 31 | public Object getTransferData(DataFlavor flavor) 32 | throws UnsupportedFlavorException, IOException { 33 | return ico.getImage(); 34 | } 35 | }; 36 | event.startDrag(null, transferable); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/control/modal/Modal.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.control.modal; 2 | 3 | public interface Modal { 4 | 5 | void setMode(Mode mode); 6 | 7 | Mode getMode(); 8 | 9 | /** */ 10 | enum Mode { 11 | DEFAULT, 12 | TRANSFORMING, 13 | PICKING, 14 | ANNOTATING, 15 | EDITING 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/control/modal/ModeControl.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.control.modal; 2 | 3 | import java.util.LinkedHashSet; 4 | import java.util.Set; 5 | import java.util.stream.Collectors; 6 | import java.util.stream.Stream; 7 | 8 | public class ModeControl implements Modal { 9 | 10 | public static class Builder { 11 | protected Mode mode; 12 | protected Set modals = new LinkedHashSet<>(); 13 | 14 | public Builder mode(Mode mode) { 15 | this.mode = mode; 16 | return this; 17 | } 18 | 19 | public Builder modals(Modal... modals) { 20 | this.modals = Stream.of(modals).collect(Collectors.toCollection(LinkedHashSet::new)); 21 | return this; 22 | } 23 | 24 | public ModeControl build() { 25 | return new ModeControl(this); 26 | } 27 | } 28 | 29 | protected Mode mode; 30 | protected Set modals; 31 | 32 | public static Builder builder() { 33 | return new Builder(); 34 | } 35 | 36 | ModeControl(Builder builder) { 37 | this.mode = builder.mode; 38 | this.modals = builder.modals; 39 | } 40 | 41 | public boolean addModal(Modal modal) { 42 | return this.modals.add(modal); 43 | } 44 | 45 | public boolean removeModal(Modal modal) { 46 | return this.modals.remove(modal); 47 | } 48 | 49 | @Override 50 | public void setMode(Mode mode) { 51 | if (this.mode != mode) { 52 | this.mode = mode; 53 | modals.forEach(modal -> modal.setMode(mode)); 54 | } 55 | } 56 | 57 | @Override 58 | public Mode getMode() { 59 | return this.mode; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/control/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 |

Mechanisms for manipulating and controlling a graph visualization, largely 17 | in terms of mouse plugins. 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/decorators/AbstractEdgeShapeFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, the JUNG Project and the Regents of the University of 3 | * California All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or http://jung.sourceforge.net/license.txt for a description. 7 | * 8 | * Created on March 10, 2005 9 | */ 10 | package org.jungrapht.visualization.decorators; 11 | 12 | import java.awt.Shape; 13 | import java.util.function.BiFunction; 14 | import org.jgrapht.Graph; 15 | 16 | /** 17 | * An interface for decorators that return a Shape for a specified edge. 18 | * 19 | * @author Tom Nelson 20 | * @param vertex type 21 | * @param edge type 22 | */ 23 | public abstract class AbstractEdgeShapeFunction implements BiFunction, E, Shape> { 24 | 25 | /** Specifies how far apart to place the control points for edges being drawn in parallel. */ 26 | protected double controlOffsetIncrement = 20.f; 27 | 28 | /** Sets the value of control_offset_increment. */ 29 | public void setControlOffsetIncrement(double y) { 30 | controlOffsetIncrement = y; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/decorators/AbstractShapeFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on Jul 16, 2004 3 | * 4 | * Copyright (c) 2004, The JUNG Authors 5 | * 6 | * All rights reserved. 7 | * 8 | * This software is open-source under the BSD license; see either 9 | * "license.txt" or 10 | * https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 11 | */ 12 | package org.jungrapht.visualization.decorators; 13 | 14 | import java.util.function.Function; 15 | import org.jungrapht.visualization.util.ShapeFactory; 16 | 17 | public abstract class AbstractShapeFunction implements SettableShapeFunction { 18 | protected Function sizeFunction; 19 | protected Function aspectRatioFunction; 20 | protected ShapeFactory factory; 21 | public static final int DEFAULT_SIZE = 8; 22 | public static final float DEFAULT_ASPECT_RATIO = 1.0f; 23 | 24 | public AbstractShapeFunction( 25 | Function sizeFunction, Function aspectRatioFunction) { 26 | this.sizeFunction = sizeFunction; 27 | this.aspectRatioFunction = aspectRatioFunction; 28 | factory = new ShapeFactory<>(sizeFunction, aspectRatioFunction); 29 | } 30 | 31 | public AbstractShapeFunction() { 32 | this(n -> DEFAULT_SIZE, n -> DEFAULT_ASPECT_RATIO); 33 | } 34 | 35 | @Override 36 | public void setSizeFunction(Function sizeFunction) { 37 | this.sizeFunction = sizeFunction; 38 | factory = new ShapeFactory<>(sizeFunction, aspectRatioFunction); 39 | } 40 | 41 | @Override 42 | public void setAspectRatioFunction(Function aspectRatioFunction) { 43 | this.aspectRatioFunction = aspectRatioFunction; 44 | factory = new ShapeFactory<>(sizeFunction, aspectRatioFunction); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/decorators/ArticulatedEdgeShapeFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * Created on March 10, 2005 9 | */ 10 | package org.jungrapht.visualization.decorators; 11 | 12 | import java.awt.Shape; 13 | import java.util.Collections; 14 | import java.util.List; 15 | import java.util.function.BiFunction; 16 | import java.util.function.Function; 17 | import org.jgrapht.Graph; 18 | import org.jungrapht.visualization.layout.model.Point; 19 | 20 | /** 21 | * An abstract class for edge-to-Shape functions that work with passed articulation points. 22 | * 23 | * @author Tom Nelson 24 | * @param vertex type 25 | * @param edge type 26 | */ 27 | public abstract class ArticulatedEdgeShapeFunction 28 | implements BiFunction, E, Shape> { 29 | 30 | protected Function> edgeArticulationFunction = e -> Collections.emptyList(); 31 | 32 | public void setEdgeArticulationFunction(Function> edgeArticulationFunction) { 33 | this.edgeArticulationFunction = edgeArticulationFunction; 34 | } 35 | 36 | public Function> getEdgeArticulationFunction() { 37 | return edgeArticulationFunction; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/decorators/EllipseShapeFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on Jul 16, 2004 3 | * 4 | * Copyright (c) 2004, The JUNG Authors 5 | * 6 | * All rights reserved. 7 | * 8 | * This software is open-source under the BSD license; see either 9 | * "license.txt" or 10 | * https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 11 | */ 12 | package org.jungrapht.visualization.decorators; 13 | 14 | import java.awt.Shape; 15 | import java.util.function.Function; 16 | 17 | public class EllipseShapeFunction extends AbstractShapeFunction 18 | implements Function { 19 | 20 | public EllipseShapeFunction() {} 21 | 22 | public EllipseShapeFunction( 23 | Function sizeFunction, Function aspectRatioFunction) { 24 | super(sizeFunction, aspectRatioFunction); 25 | } 26 | 27 | @Override 28 | public Shape apply(T t) { 29 | return factory.getEllipse(t); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/decorators/ParallelEdgeShapeFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * Created on March 10, 2005 9 | */ 10 | package org.jungrapht.visualization.decorators; 11 | 12 | import java.awt.Shape; 13 | import java.util.function.BiFunction; 14 | import org.jgrapht.Graph; 15 | import org.jungrapht.visualization.util.EdgeIndexFunction; 16 | 17 | /** 18 | * An abstract class for edge-to-Shape functions that work with parallel edges. 19 | * 20 | * @author Tom Nelson 21 | * @param vertex type 22 | * @param edge type 23 | */ 24 | public abstract class ParallelEdgeShapeFunction implements BiFunction, E, Shape> { 25 | /** Specifies the distance between control points for edges being drawn in parallel. */ 26 | protected double controlOffsetIncrement = 20.f; 27 | 28 | protected EdgeIndexFunction edgeIndexFunction = new EdgeIndexFunction<>() {}; 29 | 30 | public void setControlOffsetIncrement(double y) { 31 | controlOffsetIncrement = y; 32 | } 33 | 34 | public void setEdgeIndexFunction(EdgeIndexFunction edgeIndexFunction) { 35 | this.edgeIndexFunction = edgeIndexFunction; 36 | } 37 | 38 | public EdgeIndexFunction getEdgeIndexFunction() { 39 | return edgeIndexFunction; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/decorators/PickableElementPaintFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on Mar 10, 2005 3 | * 4 | * Copyright (c) 2005, The JUNG Authors 5 | * 6 | * All rights reserved. 7 | * 8 | * This software is open-source under the BSD license; see either 9 | * "license.txt" or 10 | * https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 11 | */ 12 | package org.jungrapht.visualization.decorators; 13 | 14 | import java.util.Objects; 15 | import java.util.function.Function; 16 | import org.jungrapht.visualization.selection.SelectedState; 17 | 18 | /** 19 | * Paints each edge according to the P parameters given in the constructor, so that 20 | * selected and non-selected edges can be made to look different. 21 | * 22 | * @author Tom Nelson 23 | */ 24 | public class PickableElementPaintFunction implements Function { 25 | protected SelectedState selectedState; 26 | protected P drawPaint; 27 | protected P selectedPaint; 28 | 29 | /** 30 | * @param selectedState specifies which elements report as "selected" 31 | * @param drawPaint P used to draw element shapes 32 | * @param selectedPaint P used to draw selected element shapes 33 | */ 34 | public PickableElementPaintFunction( 35 | SelectedState selectedState, P drawPaint, P selectedPaint) { 36 | this.selectedState = Objects.requireNonNull(selectedState); 37 | this.drawPaint = Objects.requireNonNull(drawPaint); 38 | this.selectedPaint = Objects.requireNonNull(selectedPaint); 39 | } 40 | 41 | /** */ 42 | public P apply(E element) { 43 | if (selectedState.isSelected(element)) { 44 | return selectedPaint; 45 | } else { 46 | return drawPaint; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/decorators/SettableShapeFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on Jul 18, 2004 3 | * 4 | * Copyright (c) 2004, The JUNG Authors 5 | * 6 | * All rights reserved. 7 | * 8 | * This software is open-source under the BSD license; see either 9 | * "license.txt" or 10 | * https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 11 | */ 12 | package org.jungrapht.visualization.decorators; 13 | 14 | import java.awt.Shape; 15 | import java.util.function.Function; 16 | 17 | public interface SettableShapeFunction extends Function { 18 | 19 | void setSizeFunction(Function sizeFunction); 20 | 21 | void setAspectRatioFunction(Function aspectRatioFunction); 22 | } 23 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/decorators/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 |

Mechanisms for associating data (shapes, colors, values, strings, etc.) with 17 | graph elements. 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 |

Frameworks and mechanisms for visualizing JUNGRAPHT graphs using Swing/AWT. 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/renderers/DefaultModalRenderer.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.renderers; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | /** 7 | * A {@link Renderer} that delegates to either a {@link HeavyweightRenderer} or a {@link 8 | * LightweightRenderer} depending on the results of a count predicate and a scale predicate 9 | * 10 | *

The count predicate defaults to a comparison of the vertex count with the 11 | * lightweightCountThreshold 12 | * 13 | *

The scale predicate defauls to a comparison of the VIEW transform scale with the 14 | * lightweightScaleThreshold 15 | * 16 | *

if the scale threshold is less than 0.5, then the graph is always drawn with the lightweight 17 | * renderer 18 | * 19 | *

if the vertex count is less than (for example) 20 the the graph is always drawn with the 20 | * default renderer 21 | * 22 | * @param the vertex type 23 | * @param the edge type 24 | */ 25 | public class DefaultModalRenderer extends BiModalRenderer 26 | implements ModalRenderer { 27 | 28 | private static final Logger log = LoggerFactory.getLogger(DefaultModalRenderer.class); 29 | 30 | public static class Builder< 31 | V, 32 | E, 33 | M extends Enum, 34 | T extends DefaultModalRenderer, 35 | B extends Builder> 36 | extends BiModalRenderer.Builder { 37 | public T build() { 38 | return (T) new DefaultModalRenderer<>(this); 39 | } 40 | } 41 | 42 | public static Builder builder() { 43 | return new Builder(); 44 | } 45 | 46 | public DefaultModalRenderer(Builder builder) { 47 | super(builder); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/renderers/EdgeLabelRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * Created on Apr 14, 2005 9 | */ 10 | 11 | package org.jungrapht.visualization.renderers; 12 | 13 | import java.awt.Component; 14 | import java.awt.Font; 15 | import javax.swing.JComponent; 16 | 17 | /** @author Tom Nelson */ 18 | public interface EdgeLabelRenderer { 19 | /** 20 | * Returns the component used for drawing the label. This method is used to configure the renderer 21 | * appropriately before drawing. 22 | * 23 | * @param component the component that is asking the renderer to draw 24 | * @param value the value of the cell to be rendered; the details of how to render the value are 25 | * up to the renderer implementation. For example, if {@code value} is the string "true", it 26 | * could be rendered as the string or as a checked checkbox. 27 | * @param font the font to use in rendering the label 28 | * @param isSelected whether the edge is currently selected 29 | * @param edge the edge whose label is being drawn 30 | * @param the edge type 31 | * @return the component used for drawing the label 32 | */ 33 | Component getEdgeLabelRendererComponent( 34 | JComponent component, Object value, Font font, boolean isSelected, E edge); 35 | 36 | boolean isRotateEdgeLabels(); 37 | 38 | void setRotateEdgeLabels(boolean state); 39 | } 40 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/renderers/HeavyweightVertexSelectionRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * Created on Aug 23, 2005 9 | */ 10 | package org.jungrapht.visualization.renderers; 11 | 12 | import java.awt.BasicStroke; 13 | import java.awt.Shape; 14 | import java.awt.Stroke; 15 | import org.jungrapht.visualization.RenderContext; 16 | import org.jungrapht.visualization.layout.model.LayoutModel; 17 | import org.jungrapht.visualization.transform.shape.GraphicsDecorator; 18 | 19 | /** 20 | * @param vertex type 21 | * @param edge type 22 | */ 23 | public class HeavyweightVertexSelectionRenderer extends HeavyweightVertexRenderer 24 | implements Renderer.Vertex { 25 | 26 | protected void paintIconForVertex( 27 | RenderContext renderContext, LayoutModel layoutModel, V v) { 28 | int[] coords = new int[2]; 29 | Shape shape = prepareFinalVertexShape(renderContext, layoutModel, v, coords); 30 | paintShapeForVertex(renderContext, v, shape); 31 | } 32 | 33 | protected void paintShapeForVertex(RenderContext renderContext, V v, Shape shape) { 34 | GraphicsDecorator g = renderContext.getGraphicsContext(); 35 | Stroke oldStroke = g.getStroke(); 36 | Stroke stroke = new BasicStroke(4.f); 37 | g.setStroke(stroke); 38 | g.draw(shape); 39 | g.setStroke(oldStroke); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/renderers/LightweightVertexSelectionRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * Created on Aug 23, 2005 9 | */ 10 | package org.jungrapht.visualization.renderers; 11 | 12 | import java.awt.BasicStroke; 13 | import java.awt.Shape; 14 | import java.awt.Stroke; 15 | import org.jungrapht.visualization.RenderContext; 16 | import org.jungrapht.visualization.transform.shape.GraphicsDecorator; 17 | 18 | /** 19 | * @param vertex type 20 | * @param edge type 21 | */ 22 | public class LightweightVertexSelectionRenderer extends LightweightVertexRenderer 23 | implements Renderer.Vertex { 24 | 25 | protected void paintShapeForVertex(RenderContext renderContext, V v, Shape shape) { 26 | GraphicsDecorator g = renderContext.getGraphicsContext(); 27 | Stroke oldStroke = g.getStroke(); 28 | Stroke stroke = new BasicStroke(4.f); 29 | g.setStroke(stroke); 30 | g.draw(shape); 31 | g.setStroke(oldStroke); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/renderers/ModalRenderer.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.renderers; 2 | 3 | /** 4 | * Interface for Modality in Renderers. Properties may be set and fetched based on a {#code Mode} 5 | * parameter 6 | * 7 | * @param vertex type 8 | * @param edge type 9 | */ 10 | public interface ModalRenderer extends Renderer { 11 | 12 | /** the Modes for rendering */ 13 | class Mode {} 14 | 15 | void setMode(Mode mode); 16 | 17 | void setVertexRenderer(Mode mode, Vertex r); 18 | 19 | void setEdgeRenderer(Mode mode, Edge r); 20 | 21 | void setVertexLabelRenderer(Mode mode, VertexLabel r); 22 | 23 | void setEdgeLabelRenderer(Mode mode, EdgeLabel r); 24 | 25 | VertexLabel getVertexLabelRenderer(Mode mode); 26 | 27 | Vertex getVertexRenderer(Mode mode); 28 | 29 | Edge getEdgeRenderer(Mode mode); 30 | 31 | EdgeLabel getEdgeLabelRenderer(Mode mode); 32 | 33 | void setRenderer(Mode mode, Renderer renderer); 34 | 35 | Renderer getRenderer(Mode mode); 36 | } 37 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/renderers/VertexLabelRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * Created on Apr 14, 2005 9 | */ 10 | 11 | package org.jungrapht.visualization.renderers; 12 | 13 | import java.awt.Component; 14 | import java.awt.Font; 15 | import javax.swing.JComponent; 16 | 17 | /** @author Tom Nelson */ 18 | public interface VertexLabelRenderer { 19 | /** 20 | * Returns the component used for drawing the label. This method is used to configure the renderer 21 | * appropriately before drawing. 22 | * 23 | * @param vv the component that is asking the renderer to draw 24 | * @param value the value of the cell to be rendered; the details of how to render the value are 25 | * up to the renderer implementation. For example, if {@code value} is the string "true", it 26 | * could be rendered as the string or as a checked checkbox. 27 | * @param font the font to use in rendering the label 28 | * @param isSelected whether the vertex is currently selected 29 | * @param vertex the edge whose label is being drawn 30 | * @param the vertex type 31 | * @return the component used for drawing the label 32 | */ 33 | Component getVertexLabelRendererComponent( 34 | JComponent vv, Object value, Font font, boolean isSelected, V vertex); 35 | } 36 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/renderers/VertexShapeFunctionConsumer.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.renderers; 2 | 3 | import java.awt.Shape; 4 | import java.util.function.Consumer; 5 | import java.util.function.Function; 6 | 7 | public interface VertexShapeFunctionConsumer extends Consumer> { 8 | 9 | void setVertexShapeFunction(Function vertexBoundsFunction); 10 | 11 | default void accept(Function vertexShapeFunction) { 12 | setVertexShapeFunction(vertexShapeFunction); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/renderers/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 |

Visualization mechanisms relating to rendering. 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/selection/AbstractMutableSelectedState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * 9 | * Created on Apr 2, 2005 10 | */ 11 | package org.jungrapht.visualization.selection; 12 | 13 | import java.awt.event.ItemEvent; 14 | import java.awt.event.ItemListener; 15 | import javax.swing.event.EventListenerList; 16 | 17 | /** 18 | * An abstract class to support ItemEvents for {@link MutableSelectedState} 19 | * 20 | * @author Tom Nelson 21 | */ 22 | public abstract class AbstractMutableSelectedState implements MutableSelectedState { 23 | 24 | protected EventListenerList listenerList = new EventListenerList(); 25 | 26 | public void addItemListener(ItemListener l) { 27 | listenerList.add(ItemListener.class, l); 28 | } 29 | 30 | public void removeItemListener(ItemListener l) { 31 | listenerList.remove(ItemListener.class, l); 32 | } 33 | 34 | protected void fireItemStateChanged(ItemEvent e) { 35 | Object[] listeners = listenerList.getListenerList(); 36 | for (int i = listeners.length - 2; i >= 0; i -= 2) { 37 | if (listeners[i] == ItemListener.class) { 38 | ((ItemListener) listeners[i + 1]).itemStateChanged(e); 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/selection/SelectedState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, The JUNG Authors 3 | * 4 | * All rights reserved. 5 | * 6 | * This software is open-source under the BSD license; see either 7 | * "license.txt" or 8 | * https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 9 | */ 10 | package org.jungrapht.visualization.selection; 11 | 12 | import java.awt.event.ItemEvent; 13 | import java.awt.event.ItemListener; 14 | import java.util.Set; 15 | import java.util.function.Consumer; 16 | 17 | /** @author Tom Nelson */ 18 | public interface SelectedState { 19 | 20 | boolean isSelected(T t); 21 | 22 | /** @return all selected elements. */ 23 | Set getSelected(); 24 | 25 | class StateChangeListener implements ItemListener { 26 | 27 | private Consumer selectedFunction; 28 | private Consumer deselectedFunction; 29 | 30 | public StateChangeListener(Consumer selectedFunction, Consumer deselectedFunction) { 31 | this.selectedFunction = selectedFunction; 32 | this.deselectedFunction = deselectedFunction; 33 | } 34 | 35 | @Override 36 | public void itemStateChanged(ItemEvent e) { 37 | if (e.getStateChange() == ItemEvent.SELECTED) { 38 | selectedFunction.accept((T) e.getItem()); 39 | } else if (e.getStateChange() == ItemEvent.DESELECTED) { 40 | deselectedFunction.accept((T) e.getItem()); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/selection/VertexSelectedEndpointsEdgeSelectionListener.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.selection; 2 | 3 | import java.awt.event.ItemEvent; 4 | import java.awt.event.ItemListener; 5 | import java.util.stream.Collectors; 6 | import org.jgrapht.Graph; 7 | import org.jungrapht.visualization.VisualizationViewer; 8 | 9 | public class VertexSelectedEndpointsEdgeSelectionListener implements ItemListener { 10 | 11 | public VisualizationViewer vv; 12 | 13 | VertexSelectedEndpointsEdgeSelectionListener(VisualizationViewer vv) { 14 | this.vv = vv; 15 | } 16 | 17 | @Override 18 | public void itemStateChanged(ItemEvent evt) { 19 | // a vertex selection changed. Recompute the edge selections 20 | Graph graph = vv.getVisualizationModel().getGraph(); 21 | MutableSelectedState selectedVertexState = vv.getSelectedVertexState(); 22 | vv.getSelectedEdgeState() 23 | .select( 24 | graph 25 | .edgeSet() 26 | .stream() 27 | .filter( 28 | e -> { 29 | V source = graph.getEdgeSource(e); 30 | V target = graph.getEdgeTarget(e); 31 | return selectedVertexState.isSelected(source) 32 | && selectedVertexState.isSelected(target); 33 | }) 34 | .collect(Collectors.toSet())); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/selection/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 |

Visualization mechanisms for supporting the selection of graph elements. 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/spatial/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 |

Visualization mechanisms for supporting spatial data structures. 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/spatial/rtree/Bounded.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.spatial.rtree; 2 | 3 | import java.awt.geom.Rectangle2D; 4 | 5 | /** 6 | * Interface for items that present a bounding box rectangle 7 | * 8 | * @author Tom Nelson 9 | */ 10 | public interface Bounded { 11 | 12 | /** 13 | * return the Rectangle of the bounding box 14 | * 15 | * @return the rectangular bounds of the implementation 16 | */ 17 | Rectangle2D getBounds(); 18 | } 19 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/spatial/rtree/BoundedList.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.spatial.rtree; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * interface for a list of Bounded items. The bounding box of the list is the union of the list 7 | * contents bounding boxes 8 | * 9 | * @author Tom Nelson 10 | * @param the type of item stored in the list 11 | */ 12 | public interface BoundedList extends Bounded, List { 13 | 14 | /** recompute the bounding box for the list */ 15 | void recalculateBounds(); 16 | } 17 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/spatial/rtree/BoundedMap.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.spatial.rtree; 2 | 3 | import java.awt.geom.Rectangle2D; 4 | 5 | /** 6 | * @author Tom Nelson 7 | * @param 8 | */ 9 | public interface BoundedMap extends java.util.Map { 10 | 11 | Rectangle2D getBounds(); 12 | 13 | void recalculateBounds(); 14 | } 15 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/spatial/rtree/HorizontalCenterNodeComparator.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.spatial.rtree; 2 | 3 | import java.awt.geom.Rectangle2D; 4 | import java.util.Comparator; 5 | import java.util.Map; 6 | 7 | /** 8 | * A comparator to compare along the x-axis, Vertices where the values are Rectangle2D are compared 9 | * with the center x values 10 | * 11 | * @author Tom Nelson 12 | * @param 13 | */ 14 | public class HorizontalCenterNodeComparator implements Comparator> { 15 | 16 | /** 17 | * Compares its two arguments for order. Returns a negative integer, zero, or a positive integer 18 | * as the first argument is less than, equal to, or greater than the second. 19 | * 20 | * @param left the first object to be compared. 21 | * @param right the second object to be compared. 22 | * @return a negative integer, zero, or a positive integer as the first argument is less than, 23 | * equal to, or greater than the second. 24 | * @throws NullPointerException if an argument is null and this comparator does not permit null 25 | * arguments 26 | * @throws ClassCastException if the arguments' types prevent them from being compared by this 27 | * comparator. 28 | */ 29 | public int compare(Rectangle2D left, Rectangle2D right) { 30 | return Double.compare(left.getCenterX(), right.getCenterX()); 31 | } 32 | 33 | @Override 34 | public int compare(Map.Entry leftVertex, Map.Entry rightVertex) { 35 | return compare(leftVertex.getValue(), rightVertex.getValue()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/spatial/rtree/LeafSplitter.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.spatial.rtree; 2 | 3 | import java.awt.geom.Rectangle2D; 4 | import java.util.Collection; 5 | import java.util.Map; 6 | 7 | /** 8 | * Interface for splitting LeafVertices containing Map.Entries as children 9 | * 10 | * @param the type of the elements 11 | * @author Tom Nelson 12 | */ 13 | public interface LeafSplitter { 14 | 15 | Pair> split( 16 | Collection> entries, Map.Entry newEntry); 17 | } 18 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/spatial/rtree/Pair.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.spatial.rtree; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | /** 7 | * A collection of two items. Used for pairs of lists during R*-Tree split 8 | * 9 | * @author Tom Nelson 10 | */ 11 | public class Pair { 12 | 13 | private static final Logger log = LoggerFactory.getLogger(Pair.class); 14 | 15 | public final T left; 16 | public final T right; 17 | 18 | public static Pair of(T left, T right) { 19 | return new Pair<>(left, right); 20 | } 21 | 22 | public Pair(T left, T right) { 23 | if (left == right) 24 | throw new IllegalArgumentException("Attempt to create pair with 2 equal elements"); 25 | this.left = left; 26 | this.right = right; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return "Pair{" + "left=" + left + ", right=" + right + '}'; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/spatial/rtree/RTreeNode.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.spatial.rtree; 2 | 3 | import java.util.Optional; 4 | 5 | /** 6 | * contains the parent for Node implementations 7 | * 8 | * @author Tom Nelson 9 | * @param 10 | */ 11 | public abstract class RTreeNode implements Node { 12 | 13 | protected Optional> parent = Optional.empty(); 14 | 15 | public void setParent(Node node) { 16 | parent = Optional.of(node); 17 | } 18 | 19 | public Optional> getParent() { 20 | return parent; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/spatial/rtree/Splitter.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.spatial.rtree; 2 | 3 | import java.awt.geom.Rectangle2D; 4 | import java.util.List; 5 | import java.util.Optional; 6 | 7 | /** 8 | * interface for classes that hold semantics for R-Tree and R*-Tree 9 | * 10 | * @author Tom Nelson 11 | * @param the type of element stored in the RTree 12 | */ 13 | public interface Splitter { 14 | 15 | Pair> split(List> children, Node newEntry); 16 | 17 | Optional> chooseSubtree(InnerNode nodeToSplit, T element, Rectangle2D bounds); 18 | } 19 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/spatial/rtree/SplitterContext.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.spatial.rtree; 2 | 3 | /** 4 | * a container for the functions that support R-Tree and R*-Tree 5 | * 6 | * @param the type of element in the RTree 7 | * @author Tom Nelson 8 | */ 9 | public class SplitterContext { 10 | 11 | public final LeafSplitter leafSplitter; 12 | public final Splitter splitter; 13 | 14 | public static SplitterContext of(LeafSplitter leafSplitter, Splitter splitter) { 15 | return new SplitterContext<>(leafSplitter, splitter); 16 | } 17 | 18 | private SplitterContext(LeafSplitter leafSplitter, Splitter splitter) { 19 | this.leafSplitter = leafSplitter; 20 | this.splitter = splitter; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/spatial/rtree/TreeNode.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.spatial.rtree; 2 | 3 | import java.awt.geom.Rectangle2D; 4 | import java.util.Collection; 5 | 6 | /** @author Tom Nelson */ 7 | public interface TreeNode { 8 | 9 | Rectangle2D getBounds(); 10 | 11 | Collection getChildren(); 12 | } 13 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/spatial/rtree/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 |

Visualization mechanisms for supporting RTree spatial data structures. 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/sublayout/Collapser.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.sublayout; 2 | 3 | import java.util.Collection; 4 | import java.util.Map; 5 | import java.util.function.Function; 6 | import org.jgrapht.Graph; 7 | import org.jungrapht.visualization.VisualizationServer; 8 | 9 | public interface Collapser { 10 | 11 | V collapse(Collection vertices, Function, V> vertexFunction); 12 | 13 | void expand(Collection vertices); 14 | 15 | void expand(V vertex); 16 | 17 | Function> collapsedGraphFunction(); 18 | 19 | Map> getCollapsedGraphMap(); 20 | 21 | V findOwnerOf(V vertex); 22 | 23 | static Collapser forGraph(Graph graph) { 24 | return new GraphCollapser<>(graph); 25 | } 26 | 27 | static Collapser forVisualization(VisualizationServer vv) { 28 | return new VisualGraphCollapser<>(vv); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/sublayout/SubgraphSupplier.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.sublayout; 2 | 3 | import java.util.function.Supplier; 4 | import org.jgrapht.Graph; 5 | 6 | public interface SubgraphSupplier extends Supplier> {} 7 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/sublayout/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 |

Visualization mechanisms relating to grouping or hiding specified element sets. 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/transform/BidirectionalTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * Created on Apr 16, 2005 9 | */ 10 | 11 | package org.jungrapht.visualization.transform; 12 | 13 | import java.awt.geom.Point2D; 14 | 15 | /** 16 | * Provides methods to map points from one coordinate system to another: graph to screen and screen 17 | * to graph. 18 | * 19 | * @author Tom Nelson 20 | */ 21 | public interface BidirectionalTransformer { 22 | 23 | /** 24 | * convert the supplied graph coordinate to the screen coordinate 25 | * 26 | * @param p graph point to convert 27 | * @return screen point 28 | */ 29 | Point2D transform(Point2D p); 30 | 31 | Point2D transform(double x, double y); 32 | 33 | /** 34 | * convert the supplied screen coordinate to the graph coordinate. 35 | * 36 | * @param p screen point to convert 37 | * @return the graph point 38 | */ 39 | Point2D inverseTransform(Point2D p); 40 | 41 | Point2D inverseTransform(double x, double y); 42 | } 43 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/transform/LensManager.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.transform; 2 | 3 | import java.util.Arrays; 4 | import java.util.Collections; 5 | import java.util.HashSet; 6 | import java.util.Set; 7 | import java.util.stream.Collectors; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | public class LensManager { 12 | 13 | private static final Logger log = LoggerFactory.getLogger(LensManager.class); 14 | 15 | Set lensSet = new HashSet<>(); 16 | 17 | public LensManager(T... abstractLensSupport) { 18 | Collections.addAll(lensSet, abstractLensSupport); 19 | Arrays.stream(abstractLensSupport).forEach(a -> a.setManager(this::isolate)); 20 | } 21 | 22 | public void add(T lensSupport) { 23 | lensSet.add(lensSupport); 24 | } 25 | 26 | public void isolate() { 27 | T activeOne = lensSet.stream().filter(LensSupport::isActive).findFirst().get(); 28 | if (activeOne != null) { 29 | lensSet.stream().filter(l -> !activeOne.equals(l)).forEach(LensSupport::deactivate); 30 | } 31 | log.trace( 32 | "active Lens: {}", 33 | lensSet.stream().filter(LensSupport::isActive).collect(Collectors.toSet())); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/transform/LensSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * Created on Aug 5, 2005 9 | */ 10 | 11 | package org.jungrapht.visualization.transform; 12 | 13 | import java.awt.event.ItemListener; 14 | import org.jungrapht.visualization.control.LensGraphMouse; 15 | 16 | /** 17 | * basic API for implementing lens projection support 18 | * 19 | * @author Tom Nelson 20 | * @parm LensGraphMouse type 21 | */ 22 | public interface LensSupport { 23 | 24 | interface Builder> {} 25 | 26 | void activate(); 27 | 28 | void deactivate(); 29 | 30 | void activate(boolean state); 31 | 32 | boolean isActive(); 33 | 34 | void setManager(Runnable manager); 35 | 36 | LensTransformer getLensTransformer(); 37 | 38 | M getGraphMouse(); 39 | 40 | void addItemListener(ItemListener itemListener); 41 | } 42 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/transform/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 |

Visualization mechanisms related to transformations, including lens effects. 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/transform/shape/GraphicsDecorator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * Created on Jul 11, 2005 9 | */ 10 | 11 | package org.jungrapht.visualization.transform.shape; 12 | 13 | import java.awt.Component; 14 | import java.awt.Graphics2D; 15 | import java.awt.Shape; 16 | import javax.swing.CellRendererPane; 17 | import javax.swing.Icon; 18 | 19 | /** 20 | * an extendion of Graphics2DWrapper that adds enhanced methods for drawing icons and components 21 | * 22 | * @see TransformingGraphics as an example subclass 23 | * @author Tom Nelson 24 | */ 25 | public class GraphicsDecorator extends Graphics2DWrapper { 26 | 27 | public GraphicsDecorator() { 28 | this(null); 29 | } 30 | 31 | public GraphicsDecorator(Graphics2D delegate) { 32 | super(delegate); 33 | } 34 | 35 | public void draw(Icon icon, Component c, Shape clip, int x, int y) { 36 | int w = icon.getIconWidth(); 37 | int h = icon.getIconHeight(); 38 | icon.paintIcon(c, delegate, x - w / 2, y - h / 2); 39 | } 40 | 41 | public void draw( 42 | Component c, 43 | CellRendererPane rendererPane, 44 | int x, 45 | int y, 46 | int w, 47 | int h, 48 | boolean shouldValidate) { 49 | rendererPane.paintComponent(delegate, c, c.getParent(), x, y, w, h, shouldValidate); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/transform/shape/ShapeFlatnessTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * Created on Apr 16, 2005 9 | */ 10 | 11 | package org.jungrapht.visualization.transform.shape; 12 | 13 | import java.awt.Shape; 14 | 15 | /** 16 | * Provides methods to map points from one coordinate system to another: graph to screen and screen 17 | * to graph. The flatness parameter is used to break a curved shape into smaller segments in order 18 | * to perform a more detailed transformation. 19 | * 20 | * @author Tom Nelson 21 | */ 22 | public interface ShapeFlatnessTransformer extends ShapeTransformer { 23 | 24 | /** 25 | * map a shape from graph coordinate system to the screen coordinate system 26 | * 27 | * @param shape the shape to be transformed 28 | * @param flatness used to break the supplied shape into segments 29 | * @return a Path2D(Shape) representing the screen points of the shape 30 | */ 31 | Shape transform(Shape shape, double flatness); 32 | } 33 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/transform/shape/ShapeTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * Created on Apr 16, 2005 9 | */ 10 | 11 | package org.jungrapht.visualization.transform.shape; 12 | 13 | import java.awt.Shape; 14 | import org.jungrapht.visualization.transform.BidirectionalTransformer; 15 | 16 | /** 17 | * Provides methods to map points from one coordinate system to another: graph to screen and screen 18 | * to graph. 19 | * 20 | * @author Tom Nelson 21 | */ 22 | public interface ShapeTransformer extends BidirectionalTransformer { 23 | 24 | /** 25 | * map a shape from graph coordinate system to the screen coordinate system 26 | * 27 | * @param shape the Shape to transform 28 | * @return a Path2D(Shape) representing the screen points of the shape 29 | */ 30 | Shape transform(Shape shape); 31 | 32 | Shape inverseTransform(Shape shape); 33 | } 34 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/transform/shape/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 |

Visualization mechanisms related to transformation of graph element shapes. 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/util/AWT.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.util; 2 | 3 | import java.awt.geom.Ellipse2D; 4 | import java.awt.geom.Point2D; 5 | import java.awt.geom.Rectangle2D; 6 | import org.jungrapht.visualization.layout.model.Circle; 7 | import org.jungrapht.visualization.layout.model.Point; 8 | import org.jungrapht.visualization.layout.model.Rectangle; 9 | 10 | /** Functions to convert between awt geometry objects and jungrapht-layout geometry objects */ 11 | public final class AWT { 12 | 13 | private AWT() {} 14 | 15 | public static Point2D convert(Point p) { 16 | return PointUtils.convert(p); 17 | } 18 | 19 | public static Point convert(Point2D p2d) { 20 | return PointUtils.convert(p2d); 21 | } 22 | 23 | public static Rectangle2D convert(Rectangle r) { 24 | return RectangleUtils.convert(r); 25 | } 26 | 27 | public static Rectangle convert(java.awt.geom.Rectangle2D r2d) { 28 | return RectangleUtils.convert(r2d); 29 | } 30 | 31 | public static Ellipse2D convert(Circle circle) { 32 | return new Ellipse2D.Double( 33 | circle.center.x - circle.radius, 34 | circle.center.y - circle.radius, 35 | 2 * circle.radius, 36 | 2 * circle.radius); 37 | } 38 | 39 | public static Circle convert(Ellipse2D ellipse) { 40 | return Circle.of( 41 | Point.of(ellipse.getCenterX(), ellipse.getCenterY()), 42 | Math.max(ellipse.getWidth(), ellipse.getHeight())); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/util/Attributed.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.util; 2 | 3 | import java.util.Map; 4 | import java.util.function.Function; 5 | import java.util.function.Supplier; 6 | 7 | /** 8 | * wraps a delegate class and provides Map semantics for attributes 9 | * 10 | * @param 11 | */ 12 | public interface Attributed extends Map { 13 | 14 | T getValue(); 15 | 16 | Map getAttributeMap(); 17 | 18 | void set(String key, String value); 19 | 20 | /** convenience class to shorten generic declarations */ 21 | class AS extends DefaultAttributed { 22 | public AS(String value) { 23 | super(value); 24 | } 25 | } 26 | 27 | /** convenience class to shorten generic declarations */ 28 | class AI extends DefaultAttributed { 29 | public AI(Integer value) { 30 | super(value); 31 | } 32 | } 33 | 34 | class AISupplier implements Supplier { 35 | private static int i = 1; 36 | 37 | @Override 38 | public AI get() { 39 | return new AI(i++); 40 | } 41 | } 42 | 43 | class ASSupplier implements Supplier { 44 | private static int i = 1; 45 | 46 | @Override 47 | public AS get() { 48 | return new AS("" + i++); 49 | } 50 | } 51 | 52 | Function AS_FUNCTION = t -> new AS(t); 53 | 54 | Function AI_FUNCTION = t -> new AI(t); 55 | } 56 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/util/BoundingRectanglePaintable.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.util; 2 | 3 | import java.awt.*; 4 | import java.awt.geom.Rectangle2D; 5 | import java.util.List; 6 | import org.jgrapht.Graph; 7 | import org.jungrapht.visualization.MultiLayerTransformer; 8 | import org.jungrapht.visualization.RenderContext; 9 | import org.jungrapht.visualization.VisualizationServer; 10 | import org.jungrapht.visualization.layout.model.LayoutModel; 11 | 12 | public class BoundingRectanglePaintable implements VisualizationServer.Paintable { 13 | 14 | protected RenderContext rc; 15 | protected Graph graph; 16 | protected LayoutModel layoutModel; 17 | protected List rectangles; 18 | 19 | public BoundingRectanglePaintable(RenderContext rc, LayoutModel layoutModel) { 20 | super(); 21 | this.rc = rc; 22 | this.layoutModel = layoutModel; 23 | this.graph = layoutModel.getGraph(); 24 | final BoundingRectangleCollector.Vertices brc = 25 | new BoundingRectangleCollector.Vertices<>(rc.getVertexShapeFunction(), layoutModel); 26 | this.rectangles = brc.getRectangles(); 27 | if (layoutModel instanceof ChangeEventSupport ces) { 28 | ces.addChangeListener( 29 | e -> { 30 | brc.compute(); 31 | rectangles = brc.getRectangles(); 32 | }); 33 | } 34 | } 35 | 36 | public void paint(Graphics g) { 37 | Graphics2D g2d = (Graphics2D) g; 38 | g.setColor(Color.cyan); 39 | 40 | for (Rectangle2D r : rectangles) { 41 | g2d.draw(rc.getMultiLayerTransformer().transform(MultiLayerTransformer.Layer.LAYOUT, r)); 42 | } 43 | } 44 | 45 | public boolean useTransform() { 46 | return true; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/util/ChangeEventSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, The JUNG Authors 3 | * All rights reserved. 4 | * 5 | * This software is open-source under the BSD license; see either "license.txt" 6 | * or https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 7 | * 8 | * Created on Aug 18, 2005 9 | */ 10 | 11 | package org.jungrapht.visualization.util; 12 | 13 | import javax.swing.event.ChangeListener; 14 | 15 | /** 16 | * the implementing class provides support for ChangeEvents. 17 | * 18 | * @author Tom Nelson - tomnelson@dev.java.net 19 | */ 20 | public interface ChangeEventSupport { 21 | 22 | void addChangeListener(ChangeListener l); 23 | 24 | /** 25 | * Removes a ChangeListener. 26 | * 27 | * @param l the listener to be removed 28 | */ 29 | void removeChangeListener(ChangeListener l); 30 | 31 | /** 32 | * Returns an array of all the ChangeListeners added with addChangeListener(). 33 | * 34 | * @return all of the ChangeListeners added or an empty array if no listeners have 35 | * been added 36 | */ 37 | ChangeListener[] getChangeListeners(); 38 | 39 | void fireStateChanged(); 40 | } 41 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/util/DimensionUtils.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.util; 2 | 3 | import org.jungrapht.visualization.layout.model.Dimension; 4 | 5 | public final class DimensionUtils { 6 | 7 | private DimensionUtils() {} 8 | 9 | public static java.awt.Dimension convert(Dimension d) { 10 | return new java.awt.Dimension(d.width, d.height); 11 | } 12 | 13 | public static Dimension convert(java.awt.Dimension d) { 14 | return Dimension.of(d.width, d.height); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/util/IconFunction.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.util; 2 | 3 | import java.awt.*; 4 | import java.awt.image.BufferedImage; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | import java.util.function.Function; 8 | import javax.swing.*; 9 | 10 | public class IconFunction implements Function { 11 | 12 | Map iconMap = new HashMap<>(); 13 | Function vertexLabelFunction; 14 | JLabel stamp = new JLabel(); 15 | Map renderingHints = new HashMap<>(); 16 | 17 | public IconFunction(Function vertexLabelFunction) { 18 | this.vertexLabelFunction = vertexLabelFunction; 19 | renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 20 | } 21 | 22 | @Override 23 | public Icon apply(V n) { 24 | if (!iconMap.containsKey(n)) { 25 | cacheIconFor(n); 26 | } 27 | return iconMap.get(n); 28 | } 29 | 30 | private void cacheIconFor(V vertex) { 31 | stamp.setText(vertexLabelFunction.apply(vertex)); 32 | stamp.setForeground(Color.black); 33 | stamp.setBackground(Color.white); 34 | stamp.setOpaque(true); 35 | stamp.setSize(stamp.getPreferredSize()); 36 | stamp.addNotify(); 37 | BufferedImage bi = 38 | new BufferedImage(stamp.getWidth(), stamp.getHeight(), BufferedImage.TYPE_INT_RGB); 39 | Graphics2D graphics = bi.createGraphics(); 40 | graphics.setRenderingHints(renderingHints); 41 | stamp.paint(graphics); 42 | graphics.setPaint(Color.black); 43 | graphics.drawRect(0, 0, stamp.getWidth() - 1, stamp.getHeight() - 1); 44 | graphics.dispose(); 45 | Icon icon = new ImageIcon(bi); 46 | iconMap.put(vertex, icon); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/util/ItemSupport.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.util; 2 | 3 | import java.awt.ItemSelectable; 4 | import java.awt.event.ItemEvent; 5 | import java.awt.event.ItemListener; 6 | import javax.swing.event.EventListenerList; 7 | 8 | public class ItemSupport implements ItemSelectable { 9 | 10 | protected EventListenerList listenerList = new EventListenerList(); 11 | 12 | protected boolean selected; 13 | 14 | /** 15 | * Returns the selected items or {@code null} if no items are selected. 16 | * 17 | * @return the list with the class name of what is selected 18 | */ 19 | public Object[] getSelectedObjects() { 20 | if (!selected) { 21 | return null; 22 | } 23 | Object[] selectedObjects = new Object[1]; 24 | selectedObjects[0] = getClass().getSimpleName(); 25 | return selectedObjects; 26 | } 27 | 28 | public void addItemListener(ItemListener l) { 29 | listenerList.add(ItemListener.class, l); 30 | } 31 | 32 | public void removeItemListener(ItemListener l) { 33 | listenerList.remove(ItemListener.class, l); 34 | } 35 | 36 | protected void fireItemStateChanged(ItemEvent e) { 37 | Object[] listeners = listenerList.getListenerList(); 38 | for (int i = listeners.length - 2; i >= 0; i -= 2) { 39 | if (listeners[i] == ItemListener.class) { 40 | ((ItemListener) listeners[i + 1]).itemStateChanged(e); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/util/PointUtils.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.util; 2 | 3 | import java.awt.geom.Point2D; 4 | import org.jungrapht.visualization.layout.model.Point; 5 | 6 | public final class PointUtils { 7 | 8 | private PointUtils() {} 9 | 10 | public static Point2D convert(Point p) { 11 | return new Point2D.Double(p.x, p.y); 12 | } 13 | 14 | public static Point convert(Point2D p2d) { 15 | return Point.of(p2d.getX(), p2d.getY()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/util/PredicatedParallelEdgeIndexFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Created on Sep 24, 2005 3 | * 4 | * Copyright (c) 2005, The JUNG Authors 5 | * 6 | * All rights reserved. 7 | * 8 | * This software is open-source under the BSD license; see either 9 | * "license.txt" or 10 | * https://github.com/tomnelson/jungrapht-visualization/blob/master/LICENSE for a description. 11 | */ 12 | package org.jungrapht.visualization.util; 13 | 14 | import java.util.function.Predicate; 15 | import org.jgrapht.Graph; 16 | 17 | /** 18 | * A class which creates and maintains indices for parallel edges. Edges are evaluated by a 19 | * Predicate function and those that evaluate to true are excluded from computing a parallel offset. 20 | * 21 | * @author Tom Nelson 22 | */ 23 | public class PredicatedParallelEdgeIndexFunction extends ParallelEdgeIndexFunction { 24 | protected Predicate predicate; 25 | 26 | public PredicatedParallelEdgeIndexFunction(Predicate predicate) { 27 | this.predicate = predicate; 28 | } 29 | 30 | /** 31 | * Returns the index for the specified edge, or 0 if {@code edge} is accepted by the Predicate. 32 | * 33 | * @param graph the graph and the edge whose index is to be calculated 34 | */ 35 | @Override 36 | public Integer apply(Graph graph, E edge) { 37 | return predicate.test(edge) ? 0 : super.apply(graph, edge); 38 | } 39 | 40 | public Predicate getPredicate() { 41 | return predicate; 42 | } 43 | 44 | public void setPredicate(Predicate predicate) { 45 | this.predicate = predicate; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/util/RectangleUtils.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.util; 2 | 3 | import org.jungrapht.visualization.layout.model.Rectangle; 4 | 5 | public final class RectangleUtils { 6 | 7 | private RectangleUtils() {} 8 | 9 | public static java.awt.geom.Rectangle2D convert(Rectangle r) { 10 | return new java.awt.geom.Rectangle2D.Double(r.x, r.y, r.width, r.height); 11 | } 12 | 13 | public static Rectangle convert(java.awt.geom.Rectangle2D r2d) { 14 | return Rectangle.of(r2d.getX(), r2d.getY(), r2d.getWidth(), r2d.getHeight()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/main/java/org/jungrapht/visualization/util/package.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 |

Utilities for graph visualization. 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ${project.name} 4 | 5 | 6 | 7 | 8 | 9 |

10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/test/java/org/jungrapht/visualization/LayoutAlgorithmTransitionTest.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization; 2 | 3 | import org.jgrapht.Graph; 4 | import org.jgrapht.graph.DefaultGraphType; 5 | import org.jgrapht.graph.builder.GraphTypeBuilder; 6 | import org.jungrapht.visualization.layout.algorithms.LayoutAlgorithm; 7 | import org.jungrapht.visualization.layout.algorithms.StaticLayoutAlgorithm; 8 | import org.jungrapht.visualization.layout.model.LayoutModel; 9 | import org.junit.jupiter.api.Test; 10 | 11 | public class LayoutAlgorithmTransitionTest { 12 | 13 | @Test 14 | public void testTransition() { 15 | Graph graph = 16 | GraphTypeBuilder.forGraphType(DefaultGraphType.simple()).buildGraph(); 17 | graph.addVertex("A"); 18 | LayoutModel model = LayoutModel.builder().graph(graph).size(100, 100).build(); 19 | 20 | model.set("A", 0, 0); 21 | LayoutAlgorithm newLayoutAlgorithm = new StaticLayoutAlgorithm(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/test/java/org/jungrapht/visualization/ShapeTest.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization; 2 | 3 | import java.awt.geom.Point2D; 4 | import java.awt.geom.Rectangle2D; 5 | import org.junit.jupiter.api.Test; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | /** @author Tom Nelson */ 10 | public class ShapeTest { 11 | 12 | Logger log = LoggerFactory.getLogger(ShapeTest.class); 13 | 14 | @Test 15 | public void testInside() { 16 | Rectangle2D r = new Rectangle2D.Double(0, 0, 500, 500); 17 | Point2D p = new Point2D.Double(0, 0); 18 | 19 | log.info("{} is inside {}: {}", p, r, r.contains(p)); 20 | 21 | p = new Point2D.Double(500, 500); 22 | log.info("{} is inside {}: {}", p, r, r.contains(p)); 23 | log.info("{} is whatever {}: {}", p, r, r.intersects(0, 0, 1, 1)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/test/java/org/jungrapht/visualization/VisualizationServerTest.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | 5 | import java.awt.*; 6 | import org.jgrapht.Graph; 7 | import org.jgrapht.graph.DirectedPseudograph; 8 | import org.jungrapht.visualization.layout.algorithms.CircleLayoutAlgorithm; 9 | import org.jungrapht.visualization.selection.MutableSelectedState; 10 | import org.junit.jupiter.api.Test; 11 | 12 | public class VisualizationServerTest { 13 | 14 | /* 15 | * Previously, a bug was introduced where the RenderContext in DefaultVisualizationServer was reassigned, resulting 16 | * in data like pickedVertexState to be lost. 17 | */ 18 | @Test 19 | public void testRenderContextNotOverridden() { 20 | Graph graph = DirectedPseudograph.createBuilder(Object::new).build(); 21 | CircleLayoutAlgorithm algorithm = new CircleLayoutAlgorithm(); 22 | 23 | VisualizationServer server = 24 | VisualizationServer.builder(graph) 25 | .layoutAlgorithm(algorithm) 26 | .viewSize(new Dimension(600, 600)) 27 | .build(); 28 | 29 | MutableSelectedState pickedVertexState = 30 | server.getRenderContext().getSelectedVertexState(); 31 | assertNotNull(pickedVertexState); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/AvgMedianTests.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import java.util.Arrays; 4 | import org.junit.jupiter.api.Test; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | public class AvgMedianTests { 9 | 10 | private static Logger log = LoggerFactory.getLogger(AvgMedianTests.class); 11 | 12 | @Test 13 | public void testOne() { 14 | 15 | test(new int[] {0, 5, 10}); 16 | test(new int[] {5}); 17 | test(new int[0]); 18 | test(new int[] {0, 4}); 19 | test(new int[] {0, 5, 6, 10}); 20 | test(new int[] {0, 2, 3, 4, 5, 6, 9, 10}); 21 | } 22 | 23 | private void test(int[] P) { 24 | log.info("avg median of {} is {}", Arrays.toString(P), avgMedianValue(P)); 25 | } 26 | 27 | private double avgMedianValue(int[] P) { 28 | int m = (P.length) / 2; 29 | log.info("for {}, m = {}", Arrays.toString(P), m); 30 | if (P.length == 0) { 31 | return -1; 32 | } else if (P.length % 2 == 1) { 33 | return P[m]; 34 | } else if (P.length == 2) { 35 | return (P[0] + P[1]) / 2; 36 | } else { 37 | double left = P[m - 1] - P[0]; 38 | log.info("left is {}", left); 39 | double right = P[P.length - 1] - P[m]; 40 | log.info("right is {}", right); 41 | return (P[m - 1] * right + P[m] * left) / (left + right); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/sugiyama/TestDelegateVerticesAndEdges.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.sugiyama; 2 | 3 | import static org.junit.jupiter.api.Assertions.*; 4 | 5 | import org.jungrapht.visualization.layout.util.synthetics.SVI; 6 | import org.jungrapht.visualization.layout.util.synthetics.Synthetic; 7 | import org.junit.jupiter.api.Test; 8 | 9 | public class TestDelegateVerticesAndEdges { 10 | 11 | @Test 12 | public void testVertices() { 13 | String a = "a"; 14 | String b = "b"; 15 | 16 | LV sa = LV.of(a); 17 | LV sb = LV.of(b); 18 | 19 | assertInstanceOf(SVI.class, sa); 20 | assertNotEquals(sa, sb); 21 | assertEquals(sa, LV.of("a")); 22 | LV syntheticA = new SyntheticLV<>(); 23 | assertNotEquals(syntheticA, sa); 24 | assertInstanceOf(Synthetic.class, syntheticA); 25 | } 26 | 27 | @Test 28 | public void testEdges() { 29 | 30 | LV sa = LV.of("a"); 31 | LV sb = LV.of("b"); 32 | LV sc = LV.of("c"); 33 | Integer edge1 = 1; 34 | int edge2 = 2; 35 | 36 | LE se1 = LE.of(edge1, sa, sb); 37 | LE se2 = LE.of(edge2, sa, sc); 38 | LE se3 = LE.of(2, sa, sc); 39 | assertInstanceOf(LEI.class, se1); 40 | assertInstanceOf(LEI.class, se2); 41 | assertNotEquals(se1, se2); 42 | assertEquals(se2, se3); 43 | assertInstanceOf(Synthetic.class, new SyntheticLE<>(se1, sa, sb)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/SingletonTransformerTest.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.util.synthetics; 2 | 3 | import static org.junit.jupiter.api.Assertions.*; 4 | 5 | import org.jungrapht.visualization.layout.util.synthetics.SingletonTransformer; 6 | import org.junit.jupiter.api.Test; 7 | 8 | /** 9 | * Test to ensure that keys return expected values, that a second transformation of the same key 10 | * will yield a result that is == to the first time, and that the underlying map does not grow when 11 | * a duplicate key is queried 12 | */ 13 | public class SingletonTransformerTest { 14 | 15 | @Test 16 | public void test() { 17 | SingletonTransformer singletonTransformer = 18 | new SingletonTransformer<>(i -> i + 1); 19 | 20 | int got2 = singletonTransformer.apply(1); 21 | int got3 = singletonTransformer.apply(2); 22 | 23 | assertEquals(2, got2); 24 | assertEquals(3, got3); 25 | 26 | int gotDupe = singletonTransformer.apply(1); 27 | assertTrue(gotDupe == got2); 28 | 29 | assertEquals(2, singletonTransformer.getTransformedMap().size()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/algorithms/util/synthetics/TestDelegateVerticesAndEdges.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.algorithms.util.synthetics; 2 | 3 | import static org.junit.jupiter.api.Assertions.*; 4 | 5 | import org.jungrapht.visualization.layout.util.synthetics.SE; 6 | import org.jungrapht.visualization.layout.util.synthetics.SEI; 7 | import org.jungrapht.visualization.layout.util.synthetics.SV; 8 | import org.jungrapht.visualization.layout.util.synthetics.SVI; 9 | import org.jungrapht.visualization.layout.util.synthetics.Synthetic; 10 | import org.jungrapht.visualization.layout.util.synthetics.SyntheticSE; 11 | import org.jungrapht.visualization.layout.util.synthetics.SyntheticSV; 12 | import org.junit.jupiter.api.Test; 13 | 14 | public class TestDelegateVerticesAndEdges { 15 | 16 | @Test 17 | public void testVertices() { 18 | String a = "a"; 19 | String b = "b"; 20 | 21 | SV sa = SV.of(a); 22 | SV sb = SV.of(b); 23 | 24 | assertInstanceOf(SVI.class, sa); 25 | assertNotEquals(sa, sb); 26 | assertEquals(sa, SV.of("a")); 27 | SV syntheticA = new SyntheticSV(); 28 | assertNotEquals(syntheticA, sa); 29 | assertInstanceOf(Synthetic.class, syntheticA); 30 | } 31 | 32 | @Test 33 | public void testEdges() { 34 | 35 | Integer edge1 = 1; 36 | int edge2 = 2; 37 | 38 | SE se1 = SE.of(edge1); 39 | SE se2 = SE.of(edge2); 40 | SE se3 = SE.of(2); 41 | assertInstanceOf(SEI.class, se1); 42 | assertInstanceOf(SEI.class, se2); 43 | assertNotEquals(se1, se2); 44 | assertEquals(se2, se3); 45 | assertInstanceOf(Synthetic.class, new SyntheticSE<>()); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/test/java/org/jungrapht/visualization/layout/model/ModelTest.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.layout.model; 2 | 3 | public class ModelTest {} 4 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/test/java/org/jungrapht/visualization/spatial/SpatialGridTest.java: -------------------------------------------------------------------------------- 1 | package org.jungrapht.visualization.spatial; 2 | 3 | import java.awt.Rectangle; 4 | import java.util.Arrays; 5 | import org.junit.jupiter.api.Test; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | /** @author Tom Nelson */ 10 | public class SpatialGridTest { 11 | 12 | private static final Logger log = LoggerFactory.getLogger(SpatialGridTest.class); 13 | 14 | @Test 15 | public void testBoxLocations() { 16 | 17 | SpatialGrid spatial = new SpatialGrid(null, new Rectangle(0, 0, 100, 100), 4, 4); 18 | log.trace("grid is " + spatial.getGrid()); 19 | showBoxIndex(spatial, 10, 10); 20 | showBoxIndex(spatial, 49, 49); 21 | showBoxIndex(spatial, 50, 50); 22 | showBoxIndex(spatial, 99, 1); 23 | showBoxIndex(spatial, 70, 10); 24 | 25 | showVisibleTiles(spatial, new Rectangle(0, 0, 100, 100)); 26 | showVisibleTiles(spatial, new Rectangle(25, 25, 10, 10)); 27 | showVisibleTiles(spatial, new Rectangle(25, 25, 30, 30)); 28 | showVisibleTiles(spatial, new Rectangle(99, 99, 30, 30)); 29 | } 30 | 31 | private void showBoxIndex(SpatialGrid spatial, int x, int y) { 32 | log.info( 33 | "spatial.getBoxIndex(" + x + "," + y + "):" + Arrays.toString(spatial.getBoxIndex(x, y))); 34 | } 35 | 36 | private void showVisibleTiles(SpatialGrid spatial, Rectangle r) { 37 | log.info("spatial.getVisibleTiles(" + r + "):" + spatial.getVisibleTiles(r)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /jungrapht-visualization/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /tools/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | sonatype-nexus-snapshots 5 | ${env.CI_DEPLOY_USERNAME} 6 | ${env.CI_DEPLOY_PASSWORD} 7 | 8 | 9 | 10 | --------------------------------------------------------------------------------