Commit 2ef6c710 authored by Romain Loth's avatar Romain Loth

distinct size ratio updating for each type

also fixed an fa2 condition
parent 9532a8e0
......@@ -186,10 +186,26 @@
<div id="unranged-value" class="settingslider"></div>
</a></li>
<li><a>
Label size<br>
<div id="sliderlabelsize" class="settingslider"></div>
</a></li>
<li class="tworow-selectors">
<!-- Adjust the node sizes per nodetype-->
<table>
<tr class="for-nodecategory-0">
<td class="slider-legend">
Node 0 Size
</td>
<td id="sliderlabelsize0" class="settingslider">
</td>
</tr>
<tr class="for-nodecategory-1">
<td class="slider-legend">
Node 1 Size
</td>
<td id="sliderlabelsize1" class="settingslider">
</td>
</tr>
</table>
</li>
<li id="setcolorsMenu" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
......@@ -199,7 +215,7 @@
</ul>
</a></li>
<li class="weight-selectors for-nodecategory-0">
<li class="tworow-selectors for-nodecategory-0">
<!-- Create a subgraph over nodes from TW.categories[0] (terms or def nodes)-->
<table>
<tr>
......@@ -218,7 +234,7 @@
</tr>
</table>
</li>
<li class="weight-selectors for-nodecategory-1">
<li class="tworow-selectors for-nodecategory-1">
<!-- Create a subgraph over nodes from TW.categories[1] (docs or people)-->
<table>
<tr class="weight-selector">
......
......@@ -147,7 +147,7 @@ TW.conf = (function(TW){
// to normalize node sizes: (NB not very useful because tina normalizes them at display)
TWConf.desirableNodeSizeMin=1;
TWConf.desirableNodeSizeMax=12;
TWConf.desirableNodeSizeMax=2;
// =============
......@@ -155,8 +155,8 @@ TW.conf = (function(TW){
// =============
// Node typology: categories (resp. 0 and 1) will get these default labels
TWConf.catSem = "term";
TWConf.catSoc = "person";
TWConf.catSem = "NGram";
TWConf.catSoc = "Document";
// NB: these labels may be superseded by the input data's node types values
// cf. sortNodeTypes()
......@@ -316,7 +316,7 @@ TW.conf = (function(TW){
logFacets: false, // ...about parsing node attribute:value facets
logSettings: false, // ...about settings at Tina and Sigma init time
logStates: false, // ...about TW.states array
logSelections: false
logSelections: true
}
......
......@@ -43,7 +43,7 @@
#defaultop #searchnav {
padding-left: 15px !important;
}
#defaultop .weight-selectors {
#defaultop .tworow-selectors {
padding-left: 15px !important;
margin-left: 0 !important;
}
......
......@@ -104,13 +104,13 @@ html.waiting {
max-width: 300px;
}
#defaultop .weight-selectors {
#defaultop .tworow-selectors {
width: 135px !important;
padding-top: 15px;
margin: 0 25px ;
}
#defaultop .weight-selectors td {
#defaultop .tworow-selectors td {
width: 135px !important;
padding: 0 0 10px 0 ;
}
......
......@@ -1093,27 +1093,48 @@ var TinaWebJS = function ( sigmacanvas ) {
// node's label size
var labelSizeTimeout = null
$("#sliderlabelsize").freshslider({
$("#sliderlabelsize0").freshslider({
step:.25,
min:0,
max:5,
value: TW.conf.sigmaJsDrawingProperties['labelSizeRatio'] || 1,
value: 1,
bgcolor:"#FFA500",
onchange:function(value){
if (labelSizeTimeout) {
clearTimeout(labelSizeTimeout)
}
labelSizeTimeout = setTimeout(function(){
if (TW.gui.sizeRatios[0] != value) {
TW.gui.sizeRatios[0] = value
// -------------------------------------------------------------
// generic efficient method acting on entire graphs label ratio
// (can't use it b/c we need to distinguish by type)
// var adaptedLabelThreshold = 7 - value
// TW.partialGraph.settings('labelSizeRatio', value)
// TW.partialGraph.settings('labelThreshold', adaptedLabelThreshold)
// -------------------------------------------------------------
TW.partialGraph.render()
}
}, 200)
}
});
var labelSizeTimeout = null
$("#sliderlabelsize1").freshslider({
step:.25,
min:0,
max:5,
value: 1,
bgcolor:"#27c470",
onchange:function(value){
if (labelSizeTimeout) {
clearTimeout(labelSizeTimeout)
}
labelSizeTimeout = setTimeout(function(){
if (TW.partialGraph.settings('labelSizeRatio') != value) {
var adaptedLabelThreshold = 7 - value
// console.log("value", value, "thres", adaptedLabelThreshold)
TW.partialGraph.settings('labelSizeRatio', value)
TW.partialGraph.settings('labelThreshold', adaptedLabelThreshold)
if (TW.gui.sizeRatios[1] != value) {
TW.gui.sizeRatios[1] = value
TW.partialGraph.render()
}
}, 200)
}
});
......
......@@ -25,6 +25,8 @@ TW.gui.manuallyChecked = false;
TW.gui.handpickedcolor = false; // <= changes edge rendering strategy
TW.gui.lastFilters = {}
TW.gui.sizeRatios = [1,1] // sizeRatios per nodetype
// POSS: themed variants (ex: for dark bg vs light bg)
// contrasted color list for clusterColoring()
......@@ -576,7 +578,7 @@ function changeLevel() {
// recreate FA2 nodes array after you change the nodes
reInitFa2({
useSoftMethod: !futurelevel,
useSoftMethod: false,
callback: function() {
TW.gui.elHtml.classList.remove('waiting');
......
......@@ -534,7 +534,7 @@ function mainStartGraph(inFormat, inData, twInstance) {
if (!TW.conf.filterSliders) {
var filterEls = document.getElementsByClassName('weight-selectors')
var filterEls = document.getElementsByClassName('tworow-selectors')
for (var k in filterEls) {
if (filterEls[k] && filterEls[k].style) filterEls[k].style.display="none"
......
......@@ -702,6 +702,8 @@ function saveGraphIMG(){
function reInitFa2 (params) {
if (!params) params = {}
sigma_utils.ourStopFA2()
if (params.useSoftMethod) {
// soft method: we just update FA2 internal index
// (is good enough if new nodes are subset of previous nodes)
......
......@@ -89,9 +89,6 @@ var SigmaUtils = function () {
let X = node[prefix + 'x']
let Y = node[prefix + 'y']
if (!activeFlag && size < settings('labelThreshold'))
return;
if (!node.label || typeof node.label !== 'string')
return;
......@@ -99,6 +96,14 @@ var SigmaUtils = function () {
settings('defaultLabelSize') :
settings('labelSizeRatio') * size;
// apply type-specific size slider ratios
var typeId = TW.categories.indexOf(node.type) || 0
fontSize *= TW.gui.sizeRatios[typeId]
if (!activeFlag && fontSize < settings('labelThreshold') * settings('labelSizeRatio'))
return;
// our customization: active nodes like zoom x2 post-its
if (activeFlag) {
fontSize *= 2
......@@ -277,14 +282,20 @@ var SigmaUtils = function () {
// our shapes are dependant on flags, type AND categories
// so we need the bool and conditions
// type-specific actions
// ----------------------
// other POSS: we rename n.type at parsing
// and each action (recoloring/selection)
// to use sigma's "def vs someType" syntax
// NB cost of this condition seems small:
// - without: [11 - 30] ms for 23 nodes
// - with : [11 - 33] ms for 23 nodes
var catSocFlag = (node.type != TW.categories[0])
var typeId = TW.categories.indexOf(node.type) || 0
// apply type-specific size slider ratios
nodeSize *= TW.gui.sizeRatios[typeId]
borderSize *= TW.gui.sizeRatios[typeId]
// mode variants 1: if a coloringFunction is active
if (! TW.gui.handpickedcolor) {
......@@ -335,7 +346,7 @@ var SigmaUtils = function () {
context.fillStyle = borderColor
context.beginPath();
if (catSocFlag) {
if (typeId == 1) {
// (Square shape)
// thinner borderSize for squares looks better
// otherwise hb = (nodeSize + borderSize) / 2
......@@ -364,7 +375,7 @@ var SigmaUtils = function () {
context.beginPath();
if (catSocFlag) {
if (typeId == 1) {
// (Square shape)
let hn = nodeSize / 2
context.moveTo(X + hn, Y + hn);
......@@ -407,6 +418,11 @@ var SigmaUtils = function () {
settings('labelSizeRatio') * size;
// largerall: our customized size boosts
// apply type-specific size slider ratios
var typeId = TW.categories.indexOf(node.type) || 0
fontSize *= TW.gui.sizeRatios[typeId]
if (!node.customAttrs.active) {
fontSize *= 1.3
......@@ -514,12 +530,14 @@ var SigmaUtils = function () {
this.ourStopFA2 = function() {
TW.partialGraph.stopForceAtlas2();
try {
TW.partialGraph.stopForceAtlas2();
}
catch(e) {console.log(e)}
if(document.getElementById('layoutwait')) {
document.getElementById('layoutwait').remove()
}
catch(e) {}
// restore edges if needed
if (document.getElementById('edges-switch').checked) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment