Skip to content

Commit

Permalink
fine tuning the node edges
Browse files Browse the repository at this point in the history
  • Loading branch information
tmushayahama committed Feb 28, 2019
1 parent ca14933 commit 3187699
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 24 deletions.
3 changes: 2 additions & 1 deletion src/@noctua.form/models/annoton/annoton-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class AnnotonNode {

self.term.control.value = node.term.control.value;
self.evidence = node.evidence;

self.location = node.location;
self.modelId = node.modelId;
self.annoton = node.annoton;
self.ontologyClass = node.ontologyClass;
Expand All @@ -200,6 +200,7 @@ export class AnnotonNode {
copyValues(node) {
const self = this;

self.location = node.location;
self.term.control.value = node.term.control.value;
self.evidence = node.evidence;
self.assignedBy = node.assignedBy;
Expand Down
21 changes: 21 additions & 0 deletions src/@noctua.form/services/config/noctua-form-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,27 @@ export class NoctuaFormConfigService {
}
}

getCausalEffectByEdge(edge) {
let result = noctuaFormConfig.causalEffect.options.positive.name;

switch (edge.id) {
case noctuaFormConfig.edge.causallyUpstreamOfPositiveEffect:
case noctuaFormConfig.edge.directlyPositivelyRegulates:
result = noctuaFormConfig.causalEffect.options.positive.name;
break;
case noctuaFormConfig.edge.causallyUpstreamOfNegativeEffect:
case noctuaFormConfig.edge.directlyNegativelyRegulates:
result = noctuaFormConfig.causalEffect.options.negative.name;
break;
case noctuaFormConfig.edge.causallyUpstreamOf:
case noctuaFormConfig.edge.directlyRegulates:
result = noctuaFormConfig.causalEffect.options.neutral.name;
break;
}

return result;
}

get noctuaFormExample() {
return noctuaFormExample;
}
Expand Down
21 changes: 16 additions & 5 deletions src/@noctua.form/services/form-grid.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { CamFormMetadata } from './../models/forms/cam-form-metadata';
providedIn: 'root'
})
export class NoctuaFormGridService {
public mfLocation;
public annoton: Annoton;
public annotonPresentation;
private camForm: CamForm;
Expand All @@ -42,14 +43,29 @@ export class NoctuaFormGridService {
}

initalizeForm(annoton?: Annoton) {
const self = this;

if (annoton) {
this.annoton = annoton;
}

if (self.mfLocation) {
let mfNode = self.annoton.getNode('mf');

if (mfNode) {
mfNode.location = self.mfLocation;
}
}
this.annotonPresentation = this.getAnnotonPresentation(this.annoton);
this.camForm = this.createCamForm()
this.camFormGroup.next(this._fb.group(this.camForm));
}

initalizeFormData(nodes) {
this.annoton = this.noctuaFormConfigService.createAnnotonModelFakeData(nodes);
this.initalizeForm()
}

createCamForm() {
const self = this;

Expand Down Expand Up @@ -154,11 +170,6 @@ export class NoctuaFormGridService {
this.noctuaFormConfigService.addGPAnnotonData(annoton, id);
}

initalizeFormData(nodes) {
this.annoton = this.noctuaFormConfigService.createAnnotonModelFakeData(nodes);
this.initalizeForm();
}

linkFormNode(entity, srcNode) {
entity.modelId = srcNode.modelId;
entity.setTerm(srcNode.getTerm());
Expand Down
21 changes: 12 additions & 9 deletions src/@noctua.form/services/graph.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,11 @@ export class NoctuaGraphService {
}

node.modelId = node.saveMeta.term;

if (node.location && node.location.x > 0 && node.id === 'mf') {
// reqs.update_annotations(node.saveMeta.term, 'hint-layout-x', node.location.x);
// reqs.update_annotations(node.saveMeta.term, 'hint-layout-y', node.location.y);
}
}
}

Expand All @@ -748,30 +753,28 @@ export class NoctuaGraphService {

let reqs = new minerva_requests.request_set(this.noctuaConfigService.baristaToken, cam.modelId);

cam.manager.user_token(this.noctuaConfigService.baristaToken);
cam.manager.request_with(reqs);


// Update all of the nodes with their current local (should be
// most recent) positions before saving.
each(cam.graph.all_nodes(), function (node) {
var nid = node.id();

// Extract the current local coord.
var pos = self.locationStore.get(nid);
var new_x = pos['x'];
var new_y = pos['y'];
// var pos = self.locationStore.get(nid);
//var new_x = pos['x'];
// var new_y = pos['y'];

console.log('node pos', pos)
// console.log('node pos', pos)

// reqs.update_annotations(node, 'hint-layout-x', new_x);
reqs.update_annotations(node, 'hint-layout-y', new_y);
// reqs.update_annotations(node, 'hint-layout-y', new_y);

});

// And add the actual storage.
reqs.store_model();
// manager.request_with(reqs);
// cam.manager.user_token(this.noctuaConfigService.baristaToken);
// cam.manager.request_with(reqs);
}

edit(cam, srcNode, destNode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export class NodeComponent implements OnInit, AfterViewInit {
const self = this;

let nodeEl = this.elRef.nativeElement.children[0]

// if()
let locationX = self.connector.location.x * self.camDiagramService.scale.x + 'px';
let locationY = self.connector.location.y * self.camDiagramService.scale.y + 'px'

Expand Down Expand Up @@ -87,7 +89,7 @@ export class NodeComponent implements OnInit, AfterViewInit {
extract: {
"action": "the-action"
},
maxConnections: 2,
// maxConnections: 2,
onMaxConnections: function (info, e) {
alert("Maximum connections (" + info.maxConnections + ") reached");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id="cam-canvas" [contextMenu]="basicMenu">
<context-menu class="noc-context-menu">
<ng-template contextMenuItem (execute)="addActivity($event.event)">
<ng-template contextMenuItem (execute)="addAnnoton($event.event)">
<button mat-button>
Add Activity
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@ export class NodesContainerComponent implements OnChanges, AfterViewInit {
public noctuaFormGridService: NoctuaFormGridService,
private nodeService: NodeService) { }

addActivity(event) {
addAnnoton(event) {
let location = {
x: event.clientX,
y: event.clientY
}
console.log(event.clientX + 'px');
console.log(event.clientY + 'px');

this.openForm();
this.openForm(location);
}

openForm() {
openForm(location?) {
this.noctuaFormGridService.mfLocation = location;
this.noctuaFormGridService.initalizeForm();
this.camDiagramService.openRightDrawer(this.camDiagramService.panel.camForm)
}
Expand Down Expand Up @@ -74,7 +79,9 @@ export class NodesContainerComponent implements OnChanges, AfterViewInit {
self.camDiagramService.jsPlumbInstance.connect({
source: annoton.connectionId,
target: connection.object.modelId,
type: "basic"
type: "basic",
paintStyle: { strokeWidth: 15, stroke: 'rgb(243,230,18)' },
endpointStyle: { fill: 'rgb(243,229,0)' }
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class CamDiagramService {

onNodesReady: Subject<any>[] = [];
private _jsPlumbInstance
private _jsPlumbInstance2
private _scale = {
x: 0.4,
y: 0.5
Expand Down Expand Up @@ -87,6 +88,22 @@ export class CamDiagramService {
Container: "cam-canvas"
});

self._jsPlumbInstance2 = jsPlumb.getInstance({
Endpoint: ["Dot", <any>{ radius: 2 }],
Connector: "StateMachine",
HoverPaintStyle: { stroke: "#000000", strokeWidth: 2 },
ConnectionOverlays: [
["Arrow", {
location: 1,
id: "arrow",
length: 14,
foldback: 0.8
}],
// ["Label", { label: "FOO", id: "label", cssClass: "aLabel" }]
],
Container: "cam-canvas"
});

}

registeJSPlumbrEvents() {
Expand All @@ -107,12 +124,15 @@ export class CamDiagramService {
get jsPlumbInstance() {
const self = this;

if (!this._jsPlumbInstance) {
self.initJsPlumbInstance()
}
return this._jsPlumbInstance;
}

get jsPlumbInstance2() {
const self = this;

return this._jsPlumbInstance2;
}

get scale() {
return this._scale;
}
Expand Down

0 comments on commit 3187699

Please sign in to comment.