Skip to content

Commit

Permalink
0.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
zsviczian committed Aug 15, 2022
1 parent 0f86d9b commit e5031ed
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 39 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "excalibrain",
"name": "ExcaliBrain",
"version": "0.1.7",
"version": "0.1.8",
"minAppVersion": "0.15.6",
"description": "A clean, intuitive and editable graph view for Obsidian",
"author": "Zsolt Viczian",
Expand Down
54 changes: 20 additions & 34 deletions src/Scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,34 +377,20 @@ export class Scene {
this.nodesMap = new Map<string,Node>();
this.links = new Links(this.plugin);
this.layouts = [];
const manyChildren = children.length >10;
const manySiblings = siblings.length > 10;
const singleParent = parents.length <= 1
const manyFriends = friends.length >= 10;
const baseStyle = this.plugin.settings.baseNodeStyle;
const siblingsCols = siblings.length >= 20
? 3
: siblings.length >= 10
? 2
: 1;
const childrenCols = children.length <= 12
? [1, 1, 2, 3, 3, 3, 3, 4, 4, 5, 5, 4, 4][children.length]
: 5;
const parentCols = parents.length < 5
? [1, 1, 2, 3, 2][parents.length]
: 3;

//-----------------------------------
//-----------------------------------
//WIP: even columns
enum multitude {
one = 1,
few = 2,
more = 3,
many = 4
}

const count = (len:number):number => {
if(len <= 1) return multitude.one;
if(len <= 4) return multitude.few;
if(len < 10) return multitude.more;
return multitude.many;
}

const mChildren = count(children.length);
const mParent = count(parents.length);
const mSiblings = count(siblings.length);

//-----------------------------------
//-----------------------------------


const lCenter = new Layout({
Expand All @@ -423,14 +409,14 @@ export class Scene {
origoY: 2.5 * this.nodeHeight,
top: 2 * this.nodeHeight,
bottom: null,
columns: manyChildren ? 5 : 3,
columns: childrenCols,
columnWidth: this.nodeWidth,
rowHeight: this.nodeHeight
});
this.layouts.push(lChildren);

const lFriends = new Layout({
origoX: (manyChildren ? -3 : -2) * this.nodeWidth,
origoX: -(((manyFriends?1:0)+Math.max(childrenCols,parentCols)+1.9)/2.4) * this.nodeWidth, // (manyChildren ? -3 : -2) * this.nodeWidth,
origoY: 0,
top: null,
bottom: null,
Expand All @@ -445,7 +431,7 @@ export class Scene {
origoY: -2.5 * this.nodeHeight,
top: null,
bottom: -2 * this.nodeHeight,
columns: 3,
columns: parentCols, // 3,
columnWidth: this.nodeWidth,
rowHeight: this.nodeHeight
});
Expand All @@ -461,13 +447,13 @@ export class Scene {
const siblingsNodeHeight = 2 * (siblingsTextSize.height + 2 * siblingsPadding);

const lSiblings = new Layout({
origoX: this.nodeWidth * 1.3 * ((singleParent ? 0 : 1) + (manySiblings ? 2 : 1)),
origoX: this.nodeWidth * ((parentCols-1)/2 + (siblingsCols+1.5)/3),
origoY: -2.5 * this.nodeHeight,
top: null,
bottom: 0, //this.nodeHeight,
columns: (manySiblings ? 3 : 1),
columnWidth: siblingsNodeWidth, //this.nodeWidth,
rowHeight: siblingsNodeHeight, //this.nodeHeight
bottom: - this.nodeHeight/2,
columns: siblingsCols,
columnWidth: siblingsNodeWidth,
rowHeight: siblingsNodeHeight,
})
this.layouts.push(lSiblings);

Expand Down
2 changes: 1 addition & 1 deletion src/graph/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class Node {
const gateDiameter = this.style.gateRadius*2;
ea.style.fontSize = this.style.fontSize;
ea.style.fontFamily = this.style.fontFamily;
const labelSize = ea.measureText(label);
const labelSize = ea.measureText(`${label}m`);
ea.style.fillStyle = this.style.fillStyle;
ea.style.roughness = this.style.roughness;
ea.style.strokeSharpness = this.style.strokeShaprness;
Expand Down
12 changes: 9 additions & 3 deletions src/graph/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ export class Page {
if(neighbour) {
neighbour.isParent = true;
neighbour.parentType = relationTypeToSet(neighbour.parentType,relationType);
neighbour.parentTypeDefinition = concat(definition, neighbour.parentTypeDefinition);
if(definition && !neighbour.parentTypeDefinition?.contains(definition)) {
neighbour.parentTypeDefinition = concat(definition, neighbour.parentTypeDefinition);
}
neighbour.direction = directionToSet(neighbour.direction, direction);
return;
}
Expand All @@ -251,7 +253,9 @@ export class Page {
if(neighbour) {
neighbour.isChild = true;
neighbour.childType = relationTypeToSet(neighbour.childType,relationType);
neighbour.childTypeDefinition = concat(definition,neighbour.childTypeDefinition);
if(definition && !neighbour.childTypeDefinition?.contains(definition)) {
neighbour.childTypeDefinition = concat(definition,neighbour.childTypeDefinition);
}
neighbour.direction = directionToSet(neighbour.direction, direction);
return;
}
Expand All @@ -273,7 +277,9 @@ export class Page {
if(neighbour) {
neighbour.isFriend = true;
neighbour.friendType = relationTypeToSet(neighbour.friendType,relationType);
neighbour.friendTypeDefinition = concat(definition,neighbour.friendTypeDefinition);
if(definition && !neighbour.friendTypeDefinition?.contains(definition)) {
neighbour.friendTypeDefinition = concat(definition,neighbour.friendTypeDefinition);
}
neighbour.direction = directionToSet(neighbour.direction, direction);
return;
}
Expand Down

0 comments on commit e5031ed

Please sign in to comment.