5858import static com .brunomnsilva .smartgraph .graphview .UtilitiesJavaFX .pick ;
5959import static com .brunomnsilva .smartgraph .graphview .UtilitiesPoint2D .attractiveForce ;
6060import static com .brunomnsilva .smartgraph .graphview .UtilitiesPoint2D .repellingForce ;
61+ import java .net .URI ;
6162import java .util .concurrent .Callable ;
6263import java .util .concurrent .ExecutionException ;
6364import java .util .concurrent .FutureTask ;
@@ -142,7 +143,7 @@ public SmartGraphPanel(Graph<V, E> theGraph, SmartGraphProperties properties) {
142143 * vertices.
143144 *
144145 * @param theGraph underlying graph
145- * @param placementStrategy placement strategy
146+ * @param placementStrategy placement strategy, null for default
146147 */
147148 public SmartGraphPanel (Graph <V , E > theGraph , SmartPlacementStrategy placementStrategy ) {
148149 this (theGraph , null , placementStrategy );
@@ -154,11 +155,27 @@ public SmartGraphPanel(Graph<V, E> theGraph, SmartPlacementStrategy placementStr
154155 * vertices.
155156 *
156157 * @param theGraph underlying graph
157- * @param properties custom properties
158- * @param placementStrategy placement strategy
158+ * @param properties custom properties, null for default
159+ * @param placementStrategy placement strategy, null for default
159160 */
160161 public SmartGraphPanel (Graph <V , E > theGraph , SmartGraphProperties properties ,
161162 SmartPlacementStrategy placementStrategy ) {
163+
164+ this (theGraph , properties , placementStrategy , null );
165+ }
166+
167+ /**
168+ * Constructs a visualization of the graph referenced by
169+ * <code>theGraph</code>, using custom properties and custom placement of
170+ * vertices.
171+ *
172+ * @param theGraph underlying graph
173+ * @param properties custom properties, null for default
174+ * @param placementStrategy placement strategy, null for default
175+ * @param cssFile alternative css file, instead of default 'smartgraph.css'
176+ */
177+ public SmartGraphPanel (Graph <V , E > theGraph , SmartGraphProperties properties ,
178+ SmartPlacementStrategy placementStrategy , URI cssFile ) {
162179
163180 if (theGraph == null ) {
164181 throw new IllegalArgumentException ("The graph cannot be null." );
@@ -177,7 +194,7 @@ public SmartGraphPanel(Graph<V, E> theGraph, SmartGraphProperties properties,
177194 edgeNodes = new HashMap <>();
178195
179196 //set stylesheet and class
180- loadStylesheet ();
197+ loadStylesheet (cssFile );
181198
182199 initNodes ();
183200
@@ -934,13 +951,18 @@ public SmartStylableNode getStylableEdge(E edgeElement) {
934951 }
935952
936953 /**
937- * Loads the default stylesheet and applies the .graph class to this panel.
954+ * Loads the stylesheet and applies the .graph class to this panel.
938955 */
939- private void loadStylesheet () {
956+ private void loadStylesheet (URI cssFile ) {
940957 try {
941- File f = new File ("smartgraph.css" );
958+ String css ;
959+ if ( cssFile != null ) {
960+ css = cssFile .toURL ().toExternalForm ();
961+ } else {
962+ File f = new File ("smartgraph.css" );
963+ css = f .toURI ().toURL ().toExternalForm ();
964+ }
942965
943- String css = f .toURI ().toURL ().toExternalForm ();
944966 getStylesheets ().add (css );
945967 this .getStyleClass ().add ("graph" );
946968 } catch (MalformedURLException ex ) {
0 commit comments