1111import javafx .scene .image .ImageView ;
1212import javafx .stage .Modality ;
1313import javafx .stage .Stage ;
14+ import model .conceptual .Class ;
1415import model .conceptual .Edge ;
16+ import model .conceptual .Literal ;
1517import model .conceptual .Vertex ;
1618import model .conceptual .Vertex .OutsideElementException ;
1719import model .conceptual .Vertex .UndefinedElementTypeException ;
@@ -162,12 +164,12 @@ public final class Controller implements Initializable {
162164 * @param title the title of the new window.
163165 * @param data the parameters passed to the Controller.
164166 * @param <C> a Controller that can pass data to and recieve data from this method (extending
165- * AbstractDataSharingController ).
167+ * DataSharingController ).
166168 * @param <T> the type of data passed to and from the Controller.
167169 * @return the data after it has been modified by the Controller.
168170 */
169171 @ FXML @ SuppressWarnings ("unchecked" )
170- private <C extends AbstractDataSharingController <T >, T > ArrayList <T > showWindow (String fxml , String title , ArrayList <T > data ){
172+ private <C extends DataSharingController <T >, T > ArrayList <T > showWindow (String fxml , String title , ArrayList <T > data ){
171173 try {
172174 FXMLLoader loader = new FXMLLoader (getClass ().getResource (fxml ));
173175 Parent parent = loader .load ();
@@ -250,8 +252,12 @@ private <C extends AbstractDataSharingController<T>, T> ArrayList<T> showWindow(
250252 properties .clear ();
251253
252254 try (BufferedReader reader = new BufferedReader (new FileReader (loadFile ))){
253- String graph = reader .readLine (); // TODO: 24/02/2019 may need to read more than one line in case of multiline rdfs:comment?
254- if (graph == null || graph .length () == 0 ){
255+ StringBuilder graphLines = new StringBuilder ();
256+ String line ;
257+ while ((line = reader .readLine ()) != null ) graphLines .append (line ).append ("\n " );
258+
259+ String graph = graphLines .toString ();
260+ if (graph .length () == 0 ){
255261 setWarnStatus ("Graph Read failed: nothing in graph file." );
256262 LOGGER .warning ("Nothing in graph file." );
257263 return ;
@@ -616,14 +622,17 @@ private void addElementSubaction(MouseEvent mouseEvent) {
616622
617623 if (elementName .getText ().equals ("" )){
618624 isClass = true ;
619- elementName = new Text ("_:" + Vertex .getNextBlankNodeName ());
625+ elementName = new Text ("_:" + Class .getNextBlankNodeName ());
620626 } else isClass = !elementName .getText ().matches (globalLiteralRegex + "|" + instanceLiteralRegex );
621627
622628 double textWidth = elementName .getBoundsInLocal ().getWidth ();
623629 if (isClass ){
624630 Ellipse elementType = new Ellipse (x , y , textWidth / 2 > 62.5 ? textWidth / 2 + 10 : 62.5 , 37.5 );
631+ boolean isPlaceholder = classInfo .size () >= 4 && Boolean .valueOf (classInfo .get (4 ));
632+
625633 elementType .setFill (JFX_DEFAULT_COLOUR );
626634 elementType .setStroke (Color .BLACK );
635+ if (isPlaceholder ) elementType .getStrokeDashArray ().addAll (10d , 10d );
627636 compiledElement .getChildren ().addAll (elementType , elementName );
628637 } else {
629638 Rectangle elementType = new Rectangle (textWidth > 125 ? textWidth + 15 : 125 , 75 );
@@ -641,13 +650,22 @@ private void addElementSubaction(MouseEvent mouseEvent) {
641650 if (isOntology && isClass ) {
642651 String rdfslabel = classInfo .get (2 );
643652 String rdfscomment = classInfo .get (3 );
644- classes .add (new Vertex (compiledElement , rdfslabel , rdfscomment ));
653+ classes .add (new Class (compiledElement , rdfslabel , rdfscomment ));
645654 } else if (isOntology ){
646655 String dataType = classInfo .get (1 );
647- classes .add (new Vertex (compiledElement , dataType ));
648- } else classes .add (new Vertex (compiledElement ));
649- } catch (OutsideElementException | UndefinedElementTypeException e ) {
650- e .printStackTrace ();
656+ classes .add (new Literal (compiledElement , dataType ));
657+ } else if (isClass ) {
658+ classes .add (new Class (compiledElement ));
659+ } else {
660+ classes .add (new Literal (compiledElement ));
661+ }
662+ } catch (UndefinedElementTypeException e ) {
663+ setErrorStatus ("Adding the element failed: The name does not match Turtle syntax. Recreate the" +
664+ " graph. " );
665+ LOGGER .log (Level .SEVERE , "Adding element failed: " , e );
666+ } catch (OutsideElementException e ) {
667+ setErrorStatus ("Somehow, you went outside the bounds of the canvas..." );
668+ LOGGER .log (Level .SEVERE , "Adding the element failed: " , e );
651669 }
652670 }
653671
@@ -739,20 +757,7 @@ private File showLoadFileDialog(String title, ExtensionFilter extFilter){
739757 * Creates an instructional alert.
740758 */
741759 private void showInstructionsAlert () {
742- Alert instrAlert = new Alert (Alert .AlertType .INFORMATION );
743- instrAlert .setTitle ("Instructions on using Drawing Turtles" );
744- instrAlert .setHeaderText (null );
745- instrAlert .setContentText (
746- "How to use Drawing Turtles:\n Click once on the button corresponding to the graph element you want to" +
747- " add to the canvas, then click somewhere on the canvas. Add a name (even in .ttl syntax!) an" +
748- "d the item will be created in that position. \n In regards to the Property button, you must c" +
749- "lick on a valid (already existing) element in the graph as the subject, and then another as " +
750- "the object. If you click on something that is not a Class or Literal, you will need toclick " +
751- "the subject-object pair again.\n Feel free to add elements near the edge of the graph, it aut" +
752- "omatically resizes! "
753- );
754-
755- instrAlert .showAndWait ();
760+ showWindow ("/view/instructions.fxml" , "Instructions for Drawing Turtles" , null );
756761 }
757762
758763 /**
@@ -809,9 +814,7 @@ private void showOptionsDialog() {
809814 return ;
810815 }
811816
812- LOGGER .info ("AFTER Correlation:" +
813- "\n Correlated: " + dataIntegrator .getCorrelations ().toString () +
814- "\n Uncorrelated (assumed constant): " + dataIntegrator .uncorrelatedClassesToString ());
817+ LOGGER .info ("AFTER Correlation:" + "\n Correlated: " + dataIntegrator .getCorrelations ().toString ());
815818
816819 try {
817820 instanceData = dataIntegrator .generate ();
0 commit comments