Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented multiple properties view #79

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6080cc2
Updates jointjs and requirejs config
anastasia143 Feb 23, 2017
fe9a6a8
Updates jointjs in editor-core
anastasia143 Feb 23, 2017
eba2774
Changes pathes in requirejs
anastasia143 Feb 24, 2017
1d4ed39
Adds bacbone path to jointjs d ts
anastasia143 Feb 24, 2017
393ff0a
Adds attrs description to jointObjectAttributes in DefaultDiagramNode.ts
anastasia143 Feb 24, 2017
b165697
Updates grunt and typescript in package.json
anastasia143 Feb 24, 2017
d97537b
Changes diagramElementView to elementView in DiagramScene.ts
anastasia143 Feb 24, 2017
adea85c
Adds PortsModelInterface to jointjs.d.ts
anastasia143 Feb 24, 2017
3f6098a
Adds empty ImageWithPorts to DefaultDiagramNode.ts
anastasia143 Feb 24, 2017
fc72909
Removes TextAttrs from Text constructor
anastasia143 Feb 24, 2017
ed60e55
Updates requirejs with new libs in []
anastasia143 Feb 26, 2017
d89b147
Adds backbone
anastasia143 Feb 26, 2017
e2ec1f4
Adds lodash
anastasia143 Feb 26, 2017
80ce591
Fix requirejs config.
TanVD Mar 1, 2017
92e0c07
Adds ports tp the ImageWithPorts
anastasia143 Mar 5, 2017
547335d
Merge branch 'create-modules' of https://github.com/qreal/wmp into cr…
anastasia143 Mar 12, 2017
462ae1d
Merge branch 'create-modules' into jointjs-update-merge
anastasia143 Mar 12, 2017
9058ba7
Update joint.css
TanVD Mar 13, 2017
b8a629b
Change notation file format
saimonsaret Mar 19, 2017
2a9ec0a
Merge branch 'master' into containers
saimonsaret Mar 19, 2017
082aeb3
Add embedding saving and loading
saimonsaret Mar 20, 2017
b00aae5
Prepare for auto-embedding
saimonsaret Mar 20, 2017
c4c957c
Merge branch 'jointjs-update-merge' of https://github.com/anastasia14…
saimonsaret Mar 21, 2017
4c88447
Implement correct saving/loading/undo-redo/linking for containers
saimonsaret Mar 23, 2017
86ee3a1
Diagram saving and drawing bugfix
saimonsaret Mar 26, 2017
02928de
Fix resize and remove debug code
saimonsaret Mar 28, 2017
786929c
implemented multiple properties view
shavkunov Apr 1, 2017
2f19905
Merge remote-tracking branch 'origin/containers' into multiple-proper…
shavkunov May 5, 2017
73d9102
implemented text joint labels
shavkunov May 9, 2017
347eef1
few comments added
shavkunov May 9, 2017
162c400
replaced var into let
shavkunov May 9, 2017
2366a93
more cosmetic changes
shavkunov May 9, 2017
446702f
replaced magic numbers with magic variables
shavkunov May 9, 2017
2655512
added center text align
shavkunov May 14, 2017
bb2e3de
fixed requested changes
shavkunov May 14, 2017
614fa4a
fixed saving properties coordinates
shavkunov May 21, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,48 @@ class ImageWithPorts extends joint.shapes.basic.Generic {
return attrs;
}
}

/**
* Class which wraps diagram object.
*/
export class DefaultDiagramNode implements DiagramNode {
private logicalId: string;

/**
* Image object on the screen.
*/
private jointObject: ImageWithPorts;

/**
* Name and type of diagramm.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write one doc per one field.

*/
private name: string;
private type: string;

/**
* Default properties.
*/
private constPropertiesPack: PropertiesPack;

/**
* Properties, which can be changes by user.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changeD

*/
private changeableProperties: Map<String, Property>;

/**
* Path to image.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really helpful. What kind of path? Filepath, url?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea.

*/
private imagePath: string;

/**
* Text objects which are on the screen
*/
private propertyEditElements: Map<String, PropertyEditElement>;
private parentNode: DiagramContainer;

/**
* Graph, where diagram is located. Used to set new properties on the screen.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't understand it.

*/
private graph : joint.dia.Graph;

private resizeParameters = {
Expand All @@ -62,7 +94,10 @@ export class DefaultDiagramNode implements DiagramNode {
height: 0,
};

private lastPointermoveCursor = {
/**
* Coordinates of last diagram position.
*/
private lastDiagramPosition = {
x: 0,
y: 0,
};
Expand Down Expand Up @@ -106,13 +141,20 @@ export class DefaultDiagramNode implements DiagramNode {
this.parentNode = null;
}

/**
* Pointermove handler. All parameters comes from default pointermove listener.
* @param cellView joint.dia.CellView.
* @param evt event.
* @param x x position of event.
* @param y y position of event.
*/
pointermove(cellView, evt, x, y): void {
console.log("Default diagram node pointer move with x : " + x + " and y : " + y);
cellView.options.interactive = true;
var diffX = x - this.lastMousePosition.x;
var diffY = y - this.lastMousePosition.y;
this.lastPointermoveCursor.x = this.getX();
this.lastPointermoveCursor.y = this.getY();
this.lastDiagramPosition.x = this.getX();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Position of the whole diagram? Maybe lastCursorPosition?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Position of the whole diagram? -- Yes. Coordinates of underlying joint object.

this.lastDiagramPosition.y = this.getY();
console.log("Diagram pos in pointermove : " + this.getX() + ", " + this.getY());

if (this.resizeParameters.isBottomResizing || this.resizeParameters.isRightResizing) {
Expand Down Expand Up @@ -203,13 +245,16 @@ export class DefaultDiagramNode implements DiagramNode {
return String(this.boundingBox.width) + ", " + String(this.boundingBox.height);
}

/**
* Changes text position according to new diagram coordinates.
*/
changeTextPosition() : void {
var dx = this.getX() - this.lastPointermoveCursor.x;
var dy = this.getY() - this.lastPointermoveCursor.y;
var dx = this.getX() - this.lastDiagramPosition.x;
var dy = this.getY() - this.lastDiagramPosition.y;
console.log("Diagram pos in changeTextPosition : " + this.getX() + ", " + this.getY());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not use log levels, so it's better to remove unnecessary logs before merge to master.

//console.log("Last cursor was at " + this.lastPointermoveCursor.x + ", " + this.lastPointermoveCursor.y);
console.log("Change position of text. diffX : " + dx + " diffY : " + dy);

// no need to call it every time.
if (dx !== 0 || dy !== 0) {
for (var propertyKey in this.propertyEditElements) {
this.propertyEditElements[propertyKey].setRelativePosition(dx, dy);
Expand Down Expand Up @@ -248,7 +293,12 @@ export class DefaultDiagramNode implements DiagramNode {
return this.constPropertiesPack;
}

setProperty(key: string, property: Property ): void {
/**
* Sets new property and shows it on the screen.
* @param key property key
* @param property property to set
*/
setProperty(key: string, property: Property): void {
this.changeableProperties[key] = property;
console.log("Set new text property : " + property.name + " : " + property.value);
this.propertyEditElements[key].setProperty(property, this.graph);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import {Property} from "./Property";

/**
* Class that wraps text Joint object. Responsible for showing text on screen.
*/
export class PropertyEditElement {
/**
* Default size of text font.
*/
public static fontSize = 20;

/**
* Text object which contains text information.
*/
private textObject: joint.shapes.basic.Text;
private lastX: number;
private lastY: number;

/**
* Current x, y position of text object.
*/
private currentX: number;
private currentY: number;

/**
* Creates property at specified coordinates with specified name and value.
Expand All @@ -17,8 +30,8 @@ export class PropertyEditElement {
constructor(x : number, y : number, property : Property, graph : joint.dia.Graph) {
console.log("Property edit element constructor");

this.lastX = x;
this.lastY = y;
this.currentX = x;
this.currentY = y;
this.setProperty(property, graph);

this.textObject.on("cell:pointermove", (cellView, event, x, y): void => {
Expand All @@ -38,23 +51,31 @@ export class PropertyEditElement {
return (this.textObject.get("position"))['y'];
}

/**
* Sets the position of text.
* @param x x axis coordinate
* @param y y axis coordinate
*/
public setPosition(x: number, y: number): void {
console.log("Setting text position with x : " + x + " and y : " + y);
this.textObject.position(x, y);
}

/**
* Sets new property. Removes old and replace it with new one property on the same position.
* @param property property to set.
* @param graph graph, where text joint object is situated.
*/
public setProperty(property : Property, graph : joint.dia.Graph): void {
var width: number = 0.5 * (property.name.length + property.value.length) * PropertyEditElement.fontSize;
var height: number = PropertyEditElement.fontSize;

if (this.textObject) {
this.lastX = this.getX();
this.lastY = this.getY();
this.textObject.remove();
}

this.textObject = new joint.shapes.basic.Text({
position: { x: this.lastX, y: this.lastY },
position: { x: this.currentX, y: this.currentY },
size: { width: width, height: height },
attrs: {
text: {
Expand All @@ -66,9 +87,14 @@ export class PropertyEditElement {
graph.addCell(this.textObject);
}

/**
* Sets relative position. In other words: it moves text object by appending coordinates respectively.
* @param deltaX x coordinate change
* @param deltaY y coordinate change
*/
public setRelativePosition(deltaX : number, deltaY : number): void {
this.lastX = this.getX() + deltaX;
this.lastY = this.getY() + deltaY;
this.setPosition(this.lastX, this.lastY);
this.currentX = this.getX() + deltaX;
this.currentY = this.getY() + deltaY;
this.setPosition(this.currentX, this.currentY);
}
}