diff --git a/src/main/java/widoco/Configuration.java b/src/main/java/widoco/Configuration.java index 22bb781..409b21a 100644 --- a/src/main/java/widoco/Configuration.java +++ b/src/main/java/widoco/Configuration.java @@ -91,7 +91,7 @@ public class Configuration { */ private boolean includeDiagram; - private Properties propertyFile = null; + private Properties propertyFile; // Lode configuration parameters private boolean useOwlAPI; @@ -672,6 +672,12 @@ private void completeOntologyMetadata(OWLAnnotation a, OWLOntology o) { value = WidocoUtils.getValueAsLiteralOrURI(a.getValue()); mainOntologyMetadata.setIncompatibleWith(value); break; + case Constants.PROP_SCHEMA_IMAGE: + case Constants.PROP_FOAF_IMAGE: + case Constants.PROP_FOAF_DEPICTION: + value = WidocoUtils.getValueAsLiteralOrURI(a.getValue()); + mainOntologyMetadata.addImage(value); + break; } } diff --git a/src/main/java/widoco/Constants.java b/src/main/java/widoco/Constants.java index 4dd7b0f..b99c2f3 100644 --- a/src/main/java/widoco/Constants.java +++ b/src/main/java/widoco/Constants.java @@ -92,6 +92,7 @@ public class Constants { public static final String PROP_SCHEMA_URL = NS_SCHEMA + "url"; public static final String PROP_SCHEMA_EMAIL = NS_SCHEMA + "email"; public static final String PROP_SCHEMA_AFFILIATION = NS_SCHEMA + "affiliation"; + public static final String PROP_SCHEMA_IMAGE = NS_SCHEMA + "image"; public static final String PROP_OWL_VERSION_INFO = NS_OWL + "versionInfo"; public static final String PROP_OWL_PRIOR_VERSION = NS_OWL + "priorVersion"; @@ -157,6 +158,8 @@ public class Constants { public static final String PROP_FOAF_FAMILY_NAME = NS_FOAF + "familyName"; public static final String PROP_FOAF_MBOX = NS_FOAF + "mbox"; public static final String PROP_FOAF_HOME_PAGE = NS_FOAF + "homepage"; + public static final String PROP_FOAF_IMAGE = NS_FOAF + "img"; + public static final String PROP_FOAF_DEPICTION = NS_FOAF + "depiction"; public static final String PROP_ORG_MEMBER_OF = NS_ORG + "memberOf"; @@ -958,14 +961,18 @@ public static String getOverviewSectionTitleAndPlaceHolder(Configuration c, Prop } public static String getDescriptionSectionTitleAndPlaceHolder(Configuration c, Properties lang) { - return "

" + c.getMainOntology().getName() + ": " + String descriptionString = "

" + c.getMainOntology().getName() + ": " + lang.getProperty(LANG_DESCRIPTION_PLACEHOLDER) + "\n"; + for (String image: c.getMainOntology().getImages()){ + descriptionString += ""; + } + return descriptionString; } public static String getCrossReferenceSectionTitleAndPlaceHolder(Configuration c, Properties lang) { return "

" + lang.getProperty(LANG_CROSS_REF_TITLE) + " " + c.getMainOntology().getName() + " " + lang.getProperty(LANG_CROSS_REF_TITLE2) + "

" + "\n" - + lang.getProperty(LANG_CROSS_REF_PLACEHOLDER) + c.getMainOntology().getName() + ".\n"; + + lang.getProperty(LANG_CROSS_REF_PLACEHOLDER) +" "+ c.getMainOntology().getName() + ".\n"; } public static String getProvenanceHtml(Configuration c, Properties lang) { diff --git a/src/main/java/widoco/entities/Ontology.java b/src/main/java/widoco/entities/Ontology.java index 50651bb..b93a6aa 100644 --- a/src/main/java/widoco/entities/Ontology.java +++ b/src/main/java/widoco/entities/Ontology.java @@ -127,13 +127,20 @@ public class Ontology { */ private String incompatibleWith; + /** + * images used to illustrate the ontology + */ + private ArrayList images; + public Ontology() { + this.images = new ArrayList<>(); } public Ontology(String name, String namespacePrefix, String namespaceURI) { this.name = name; this.namespacePrefix = namespacePrefix; this.namespaceURI = namespaceURI; + this.images = new ArrayList<>(); } public String getName() { @@ -340,4 +347,16 @@ public String getIncompatibleWith() { public void setIncompatibleWith(String incompatibleWith) { this.incompatibleWith = incompatibleWith; } + + public ArrayList getImages(){ + return images; + } + + public void addImage(String image){ + this.images.add(image); + } + + public void setImages(ArrayList images){ + this.images = images; + } } diff --git a/src/main/java/widoco/gui/EditProperty.java b/src/main/java/widoco/gui/EditProperty.java index bbd1ef6..469e72f 100644 --- a/src/main/java/widoco/gui/EditProperty.java +++ b/src/main/java/widoco/gui/EditProperty.java @@ -16,7 +16,7 @@ */ public class EditProperty extends javax.swing.JFrame { - public enum PropertyType{authors, contributors, publisher, extended, imported, license}; + public enum PropertyType{authors, contributors, publisher, extended, imported, license, image}; private final GuiStep2 step2Gui; private final Configuration c; private final PropertyType type; @@ -40,7 +40,7 @@ public EditProperty(GuiStep2 g, Configuration c, PropertyType p) { this.step2Gui = g; this.c = c; //needed because for authors/contributors we are going to load additional stuff this.type = p; - //The properties have to correspon to those in the config + //The properties have to correspond to those in the config switch(type){ case authors: this.setTitle("Editing Authors"); @@ -86,6 +86,13 @@ public EditProperty(GuiStep2 g, Configuration c, PropertyType p) { createTable(new String[]{"License Name","License URI", "License Logo URL"}); loadLicense(c.getMainOntology().getLicense()); break; + case image: + this.setTitle("Editing Images"); + this.addRowButton.setText("Add image..."); + this.deleteRowButton.setText("Delete image..."); + createTable(new String[]{"Image URL"}); + loadImages(c.getMainOntology().getImages()); + break; } } @@ -122,6 +129,13 @@ private void loadLicense (License l){ this.addRowButton.setEnabled(false); this.deleteRowButton.setEnabled(false); } + + private void loadImages(ArrayList images) { + for(String img:images){ + Object[] row = new Object[]{img}; + ((DefaultTableModel)tableProperties.getModel()).addRow(row); + } + } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always @@ -247,6 +261,8 @@ private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS case imported:this.c.getMainOntology().setImportedOntologies(getOntologiesFromTable()); break; case license:this.c.getMainOntology().setLicense(getLicenseFromTable()); + break; + case image:this.c.getMainOntology().setImages(getImagesFromTable()); } this.step2Gui.refreshPropertyTable(); this.dispose(); @@ -293,6 +309,17 @@ private License getLicenseFromTable() { String licLogo = (String)tableProperties.getValueAt(0,2); return new License(licURI, licName, licLogo); } + + private ArrayList getImagesFromTable() { + ArrayList images = new ArrayList(); + for(int row = 0;row < tableProperties.getRowCount();row++) { + String imageURL = (String)tableProperties.getValueAt(row, 0); + if(!imageURL.equals("") || !imageURL.equals("")){ + images.add(imageURL); + } + } + return images; + } private void deleteRowButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteRowButtonActionPerformed if(tableProperties.getSelectedRow()!=-1){ @@ -310,57 +337,6 @@ private void deleteRowButtonActionPerformed(java.awt.event.ActionEvent evt) {//G private void deleteSelectedRow(int rowNumber){ ((DefaultTableModel)tableProperties.getModel()).removeRow(rowNumber); } - /** - * @param args the command line arguments - */ -// public static void main(String args[]) { -// /* Set the Nimbus look and feel */ -// // -// /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. -// * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html -// */ -// try { -// for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { -// if ("Nimbus".equals(info.getName())) { -// javax.swing.UIManager.setLookAndFeel(info.getClassName()); -// break; -// } -// } -// } catch (ClassNotFoundException ex) { -// java.util.logging.Logger.getLogger(EditProperty.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); -// } catch (InstantiationException ex) { -// java.util.logging.Logger.getLogger(EditProperty.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); -// } catch (IllegalAccessException ex) { -// java.util.logging.Logger.getLogger(EditProperty.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); -// } catch (javax.swing.UnsupportedLookAndFeelException ex) { -// java.util.logging.Logger.getLogger(EditProperty.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); -// } -// // -// -// /* Create and display the form */ -// java.awt.EventQueue.invokeLater(new Runnable() { -// public void run() { -// Configuration config = new Configuration(); -// Agent a = new Agent("Dani","http://bananen", "oeg",""); -// Agent a2 = new Agent("Dani2","http://bananen", "oeg",""); -// Agent a3 = new Agent("Dani3","http://bananen", "oeg",""); -// -// Ontology o1 = new Ontology("blah", "ble","bli"); -// -// ArrayList creators = new ArrayList(); -// -// creators.add(a); -// creators.add(a2); -// creators.add(a3); -// -// ArrayList onto = new ArrayList(); -// onto.add(o1); -// config.setCreators(creators); -// config.setExtendedOntologies(onto); -// new EditProperty(null, config, PropertyType.extended).setVisible(true); -// } -// }); -// } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton addRowButton; diff --git a/src/main/java/widoco/gui/GuiStep2.java b/src/main/java/widoco/gui/GuiStep2.java index cbd65ad..e720338 100644 --- a/src/main/java/widoco/gui/GuiStep2.java +++ b/src/main/java/widoco/gui/GuiStep2.java @@ -134,6 +134,8 @@ public void mouseClicked(java.awt.event.MouseEvent evt) { form = new EditProperty(gAux, conf, EditProperty.PropertyType.imported); } else if (prop.equals("license")) { form = new EditProperty(gAux, conf, EditProperty.PropertyType.license); + } else if (prop.equals("images")) { + form = new EditProperty(gAux, conf, EditProperty.PropertyType.image); } if (form != null) { gAux.saveMetadata(); @@ -165,7 +167,7 @@ public void stopLoadingAnimation() { } private void refreshTable() { - String authors = "", contributors = "", imported = "", extended = "", publisher = ""; + String authors = "", contributors = "", imported = "", extended = "", publisher = "", images =""; for (Agent a : conf.getMainOntology().getCreators()) { if (a.getName() == null || a.getName().equals("")) { authors += "creator; "; @@ -202,6 +204,13 @@ private void refreshTable() { } else { publisher += p.getName(); } + for (String img: conf.getMainOntology().getImages()){ + if(!img.equals("")){ + images +=img + ";"; + }else{ + images +="image;"; + } + } tableProperties.setModel(new javax.swing.table.DefaultTableModel(new Object[][] { { "abstract", conf.getAbstractSection() }, { "ontology title", conf.getMainOntology().getTitle() }, { "ontology name", conf.getMainOntology().getName() }, @@ -217,7 +226,8 @@ private void refreshTable() { { "cite as", conf.getMainOntology().getCiteAs() }, { "doi", conf.getMainOntology().getDoi() }, { "status", conf.getMainOntology().getStatus() }, { "backwards compatible with", conf.getMainOntology().getBackwardsCompatibleWith() }, - { "incompatible with", conf.getMainOntology().getIncompatibleWith()} }, + { "incompatible with", conf.getMainOntology().getIncompatibleWith()}, + { "images", images }}, new String[] { "Property", "Value" }) { Class[] types = new Class[] { java.lang.String.class, java.lang.Object.class }; boolean[] canEdit = new boolean[] { false, true }; @@ -234,6 +244,7 @@ public boolean isCellEditable(int rowIndex, int columnIndex) { || getValueAt(rowIndex, 0).equals("publisher") || ((String) getValueAt(rowIndex, 0)).toLowerCase().contains("extended") || ((String) getValueAt(rowIndex, 0)).toLowerCase().contains("license") + || ((String) getValueAt(rowIndex, 0)).toLowerCase().contains("images") || ((String) getValueAt(rowIndex, 0)).toLowerCase().contains("imported")) { return false; } @@ -370,14 +381,14 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { labelSteps.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N labelSteps.setText("Steps"); - tableProperties.setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { "abstract", "" }, { "ontology title", null }, { "ontology name", null }, { "ontology prefix", null }, { "ontology ns URI", null }, { "date of release", null }, { "this version URI", null }, { "latest version URI", null }, { "previous version URI", null }, { "ontology revision", null }, { "authors", null }, { "contributors", null }, { "publisher", null }, { "imported ontologies", null }, { "extended ontologies", null }, - { "license", null }, { "cite as", null }, { "doi", null }, { "status", null } }, + { "license", null }, { "cite as", null }, { "doi", null }, { "status", null }, + { "backwards compatible with", null },{ "incompatible with", null }}, new String[] { "Property", "Value" }) { Class[] types = new Class[] { java.lang.String.class, java.lang.Object.class }; boolean[] canEdit = new boolean[] { false, false }; diff --git a/test/example_annotated.owl b/test/example_annotated.owl index 892f45f..af09a9b 100644 --- a/test/example_annotated.owl +++ b/test/example_annotated.owl @@ -17,6 +17,8 @@ "The example ontology"@en ; "February 5th, 2020"@en ; "Maria Poveda-Villalon"@en ; + schema:image ; + foaf:img "https://knowledgecaptureanddiscovery.github.io/SoftwareDescriptionOntology/release/1.9.0/images/overviewSDv5.png"; [ foaf:name "Oscar Corcho"; foaf:mbox "mailto:MyEmail@example.org";