Skip to content

Commit

Permalink
fixed fastUpdate issue in editor
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalis-wiens committed Dec 21, 2018
1 parent 77e8c2d commit 9466a5c
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 31 deletions.
11 changes: 8 additions & 3 deletions src/app/css/toolstyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -1457,8 +1457,11 @@ main {
cursor:pointer;
}
.reloadCachedOntologyIcon:disabled{
background: #ccc;
background: #f4f4f4;
cursor: auto;
border: solid 1px darkgray;


}


Expand All @@ -1472,12 +1475,14 @@ main {

.disabledReloadElement{
cursor:auto;
background: #cccccc;
background: #F4F4F4;
pointer-events: auto;
border: solid 1px darkgray;
color : #bbbbbb;
}
.disabledReloadElement:hover{
cursor:auto;
background: #dddddd;
background: #EEEEEE;
pointer-events: auto;
}

Expand Down
1 change: 1 addition & 0 deletions src/app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ module.exports = function () {

// give the options the pointer to the some menus for import and export
options.literalFilter(emptyLiteralFilter);
options.nodeDegreeFilter(nodeDegreeFilter);
options.loadingModule(loadingModule);
options.filterMenu(filterMenu);
options.modeMenu(modeMenu);
Expand Down
2 changes: 1 addition & 1 deletion src/app/js/menu/exportMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module.exports = function (graph) {
graph.options().warningModule().showExporterWarning();
console.log("Stay on the page! "+window.location.href);
exportTurtleButton.attr("href", window.location.href);

d3.event.preventDefault(); // prevent the href to be called ( reloads the page otherwise )


}
Expand Down
4 changes: 4 additions & 0 deletions src/app/js/menu/ontologyMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,14 @@ module.exports = function (graph) {
d3.select("#reloadSvgIcon").node().disabled=true;
d3.select("#reloadCachedOntology").node().title="reloading original version not possible, please reload the file";
d3.select("#reloadSvgIcon").classed("disabledReloadElement",true);
d3.select("#svgStringText").style("fill","gray");
d3.select("#svgStringText").classed("noselect",true);
}
else{
d3.select("#reloadCachedOntology").node().title="generate new visualization and overwrite cached ontology";
d3.select("#reloadSvgIcon").classed("disabledReloadElement",false);
d3.select("#svgStringText").style("fill","black");
d3.select("#svgStringText").classed("noselect",true);
}
}else {
graph.showReloadButtonAfterLayoutOptimization(false);
Expand Down
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h4 id="currentLoadingStep" style="margin: 0;font-style: italic; padding-bottom:

<svg viewBox="38 -12.5 18 18" class="reloadCachedOntologyIcon btn_shadowed" id="reloadSvgIcon">
<g>
<text dx="5px" dy="-1px" style="font-size:9px;">Reload ontology</text>
<text id="svgStringText" dx="5px" dy="-1px" style="font-size:9px;">Reload ontology</text>
<path style="fill : #444; stroke-width:0;"
d="m 42.277542,5.1367119 c -5.405,0 -10.444,1.577 -14.699,4.282 l -5.75,-5.75 0,16.1100001 16.11,0 -6.395,-6.395 c 3.18,-1.787 6.834,-2.82 10.734,-2.82 12.171,0 22.073,9.902 22.073,22.074 0,2.899 -0.577,5.664 -1.599,8.202 l 4.738,2.762 c 1.47,-3.363 2.288,-7.068 2.288,-10.964 0,-15.164 -12.337,-27.5010001 -27.5,-27.5010001 m 11.5,46.7460001 c -3.179,1.786 -6.826,2.827 -10.726,2.827 -12.171,0 -22.073,-9.902 -22.073,-22.073 0,-2.739 0.524,-5.35 1.439,-7.771 l -4.731,-2.851 c -1.375,3.271 -2.136,6.858 -2.136,10.622 0,15.164 12.336,27.5 27.5,27.5 5.406,0 10.434,-1.584 14.691,-4.289 l 5.758,5.759 0,-16.112 -16.111,0 6.389,6.388 z"
transform="matrix(0.20,0,0,0.20,75,-10)" >
Expand Down
108 changes: 86 additions & 22 deletions src/webvowl/js/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,7 @@ module.exports = function (graphContainerSelector) {

graph.fastUpdate = function () {
// fast update function for editor calls;
// -- experimental ;
quick_refreshGraphData();
updateNodeMap();
force.start();
Expand All @@ -1234,7 +1235,6 @@ module.exports = function (graphContainerSelector) {
refreshGraphStyle();
updateHaloStyles();


};
function updateNodeMap(){
nodeMap = [];
Expand Down Expand Up @@ -2525,9 +2525,9 @@ module.exports = function (graphContainerSelector) {
aNode.label(identifier);
}
}

var i;
// updates the property domain and range
for (var i = 0; i < unfilteredData.properties.length; i++) {
for (i = 0; i < unfilteredData.properties.length; i++) {
if (unfilteredData.properties[i].domain() === element) {
// unfilteredData.properties[i].toString();
unfilteredData.properties[i].domain( aNode );
Expand All @@ -2537,8 +2537,25 @@ module.exports = function (graphContainerSelector) {
// unfilteredData.properties[i].toString();
}
}
unfilteredData.nodes.splice(unfilteredData.nodes.indexOf(element), 1);

// update for fastUpdate:
for (i = 0; i < properties.length; i++) {
if (properties[i].domain() === element) {
// unfilteredData.properties[i].toString();
properties[i].domain( aNode );
}
if (properties[i].range() === element) {
properties[i].range( aNode );
// unfilteredData.properties[i].toString();
}
}

var remId=unfilteredData.nodes.indexOf(element);
if (remId!==-1)
unfilteredData.nodes.splice(remId, 1);
remId=classNodes.indexOf(element);
if (remId!==-1)
classNodes.splice(remId, 1);
// very important thing for selection!;
addNewNodeElement(aNode);
// handle focuser!
Expand Down Expand Up @@ -2601,10 +2618,16 @@ module.exports = function (graphContainerSelector) {

// add this to the data;
unfilteredData.properties.push(aProp);
unfilteredData.properties.splice(unfilteredData.properties.indexOf(element), 1);
properties.push(aProp);
properties.splice(properties.indexOf(element), 1);

if (properties.indexOf(aProp)===-1)
properties.push(aProp);
var remId=unfilteredData.properties.indexOf(element);
if (remId!==-1)
unfilteredData.properties.splice(remId, 1);
if (properties.indexOf(aProp)===-1)
properties.push(aProp);
remId=properties.indexOf(element);
if (remId!==-1)
properties.splice(remId, 1);
graph.fastUpdate();
aProp.domain().addProperty(aProp);
aProp.range().addProperty(aProp);
Expand Down Expand Up @@ -2803,7 +2826,10 @@ module.exports = function (graphContainerSelector) {


function addNewNodeElement(element){
classNodes.push(element);
unfilteredData.nodes.push(element);
if (classNodes.indexOf(element)===-1)
classNodes.push(element);

generateDictionary(unfilteredData);
graph.getUpdateDictionary();
graph.fastUpdate();
Expand Down Expand Up @@ -3118,7 +3144,8 @@ module.exports = function (graphContainerSelector) {

// add this to the data;
unfilteredData.properties.push(aProp);
properties.push(aProp);
if (properties.indexOf(aProp)===-1)
properties.push(aProp);
graph.fastUpdate();
aProp.labelObject().x =pX;
aProp.labelObject().px=pX;
Expand Down Expand Up @@ -3197,6 +3224,8 @@ module.exports = function (graphContainerSelector) {
aNode.id("NodeId" + eN++);
// add this property to the nodes;
unfilteredData.nodes.push(aNode);
if (classNodes.indexOf(aNode)===-1)
classNodes.push(aNode);


// add also the datatype Property to it
Expand All @@ -3216,8 +3245,8 @@ module.exports = function (graphContainerSelector) {
aProp.iri(ontoIri + aProp.id());
// add this to the data;
unfilteredData.properties.push(aProp);
properties.push(aProp);

if (properties.indexOf(aProp)===-1)
properties.push(aProp);
graph.fastUpdate();
generateDictionary(unfilteredData);
graph.getUpdateDictionary();
Expand All @@ -3236,17 +3265,28 @@ module.exports = function (graphContainerSelector) {
};

graph.removeNodesViaResponse=function(nodesToRemove,propsToRemove){
var i;
var i, remId;
// splice them;
for (i = 0; i < propsToRemove.length; i++) {
unfilteredData.properties.splice(unfilteredData.properties.indexOf(propsToRemove[i]), 1);
remId=unfilteredData.properties.indexOf(propsToRemove[i]);
if (remId!==-1)
unfilteredData.properties.splice(remId, 1);
remId=properties.indexOf(propsToRemove[i]);
if (remId!==-1)
properties.splice(remId, 1);
propsToRemove[i]=null;
}
for (i = 0; i < nodesToRemove.length; i++) {
unfilteredData.nodes.splice(unfilteredData.nodes.indexOf(nodesToRemove[i]), 1);
remId=unfilteredData.nodes.indexOf(nodesToRemove[i]);
if (remId!==-1) {
unfilteredData.nodes.splice(remId, 1);
}
remId=classNodes.indexOf(nodesToRemove[i]);
if (remId!==-1)
classNodes.splice(remId, 1);
nodesToRemove[i]=null;
}
graph.update();
graph.fastUpdate();
generateDictionary(unfilteredData);
graph.getUpdateDictionary();
options.focuserModule().handle(undefined);
Expand All @@ -3259,6 +3299,9 @@ module.exports = function (graphContainerSelector) {
var propsToRemove = [];
var nodesToRemove = [];
var datatypes=0;

var remId;

nodesToRemove.push(node);
for (var i = 0; i < unfilteredData.properties.length; i++) {
if (unfilteredData.properties[i].domain() === node || unfilteredData.properties[i].range() === node) {
Expand Down Expand Up @@ -3294,14 +3337,24 @@ module.exports = function (graphContainerSelector) {
}else{
// splice them;
for (i = 0; i < propsToRemove.length; i++) {
unfilteredData.properties.splice(unfilteredData.properties.indexOf(propsToRemove[i]), 1);
remId=unfilteredData.properties.indexOf(propsToRemove[i]);
if (remId!==-1)
unfilteredData.properties.splice(remId, 1);
remId=properties.indexOf(propsToRemove[i]);
if (remId!==-1)
properties.splice(remId, 1);
propsToRemove[i]=null;
}
for (i = 0; i < nodesToRemove.length; i++) {
unfilteredData.nodes.splice(unfilteredData.nodes.indexOf(nodesToRemove[i]), 1);
remId=unfilteredData.nodes.indexOf(nodesToRemove[i]);
if (remId!==-1)
unfilteredData.nodes.splice(remId, 1);
remId=classNodes.indexOf(nodesToRemove[i]);
if (remId!==-1)
classNodes.splice(remId, 1);
nodesToRemove[i]=null;
}
graph.update();
graph.fastUpdate();
generateDictionary(unfilteredData);
graph.getUpdateDictionary();
options.focuserModule().handle(undefined);
Expand All @@ -3313,13 +3366,24 @@ module.exports = function (graphContainerSelector) {
graph.removePropertyViaEditor = function (property) {
property.domain().removePropertyElement(property);
property.range().removePropertyElement(property);
var remId;

if (property.type().toLocaleLowerCase() === "owl:datatypeproperty") {
var datatype=property.range();
unfilteredData.nodes.splice(unfilteredData.nodes.indexOf(property.range()), 1);
remId=unfilteredData.nodes.indexOf(property.range());
if (remId!==-1)
unfilteredData.nodes.splice(remId, 1);
if (remId!==-1)
remId=classNodes.indexOf(property.range());
classNodes.splice(remId, 1);
datatype=null;
}
unfilteredData.properties.splice(unfilteredData.properties.indexOf(property), 1);
remId=unfilteredData.properties.indexOf(property);
if (remId!==-1)
unfilteredData.properties.splice(remId, 1);
remId=properties.indexOf(property);
if (remId!==-1)
properties.splice(remId, 1);
if (property.inverse()){
// so we have inverse
property.inverse().inverse(0);
Expand All @@ -3328,7 +3392,7 @@ module.exports = function (graphContainerSelector) {


hoveredPropertyElement = undefined;
graph.update();
graph.fastUpdate();
generateDictionary(unfilteredData);
graph.getUpdateDictionary();
options.focuserModule().handle(undefined);
Expand Down
4 changes: 0 additions & 4 deletions src/webvowl/js/modules/nodeDegreeFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ module.exports = function (menu) {
* @param untouchedProperties
*/
filter.filter = function (untouchedNodes, untouchedProperties) {
if (lastFiltedDegree!==degreeGetter()) {
nodes = untouchedNodes;
properties = untouchedProperties;

Expand All @@ -81,14 +80,11 @@ module.exports = function (menu) {
filteredProperties = properties;

if (filteredNodes.length === 0) {
// console.log("Error : filtered nodes are 0");
degreeSetter(0);
filteredNodes = untouchedNodes;
filteredProperties = untouchedProperties;
}
lastFiltedDegree=degreeGetter();
}

};

function findMaxLinkCount(nodes) {
Expand Down
6 changes: 6 additions & 0 deletions src/webvowl/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ module.exports = function () {
showRenderingStatistic=true,
showInputModality=false,
hideDebugOptions=true,
nodeDegreeFilter,
debugMenu,

supportedDatatypes=["rdfs:Literal", "xsd:boolean", "xsd:double", "xsd:integer", "xsd:string","undefined"],
Expand Down Expand Up @@ -571,6 +572,11 @@ module.exports = function () {
literalFilter=p;
return options;
};
options.nodeDegreeFilter=function (p) {
if (!arguments.length) return nodeDegreeFilter;
nodeDegreeFilter=p;
return options;
};

options.loadingModule=function (p) {
if (!arguments.length) return loadingModule;
Expand Down

0 comments on commit 9466a5c

Please sign in to comment.