Open mcnLeandro opened 3 years ago
I wrote code
let class1 = ClassesController.create()
class1.bounds = new Rectangle(100,100,100,100)
And here is the result
Can expand group, but expand all children in the group too. So, have to separate expand targets. To specify them, need to add frags to them and create a original method to expand UMLObject.
I wrote program with expand method but didn't work, so create issue in paper.js repository https://github.com/paperjs/paper.js/issues/1942
I wrote a program
let class1 = ClassesController.create()
class1.statusGroup.children[0].bounds = new Rectangle(100,100,300,300)
And here is the result
I wanted to expand width, so...
let class1 = ClassesController.create()
class1.statusGroup.children[0].bounds.width = 300
Here is the result. It worked !!
with Columns
let class1 = ClassesController.create()
let column1 = ColumnsController.createInto(class1)
let column2 = ColumnsController.createInto(class1)
let expandWidthOfColumn = (column, width) => {
let pp = column.parent.parent; // i know the names are bad
let bounds = pp.bounds;
let l = bounds.left;
let r = bounds.right;
column.outerRect.bounds.width = width
column.innerRect.bounds = new Rectangle(
new Point(l + column.space, column.outerRect.bounds.top + column.space),
new Point(r - column.space, column.outerRect.bounds.bottom - column.space)
);
}
let expandWidthOfClass = (_class,width) => {
_class.statusGroup.children[0].bounds.width = width
_class.contentsGroup.children.forEach(child => {
expandWidthOfColumn(child, width)//this case there's only column model
})
}
expandWidthOfClass(class1, 400)
Also with Divider
let class1 = ClassesController.create()
let column1 = ColumnsController.createInto(class1)
let divider1 = DividersController.createInto(class1)
let column2 = ColumnsController.createInto(class1)
let expandWidthOfColumn = (column, width) => {
let pp = column.parent.parent; // i know the names are bad
let bounds = pp.bounds;
let l = bounds.left;
let r = bounds.right;
column.outerRect.bounds.width = width
column.innerRect.bounds = new Rectangle(
new Point(l + column.space, column.outerRect.bounds.top + column.space),
new Point(r - column.space, column.outerRect.bounds.bottom - column.space)
);
}
let expandWidthOfDivider = (divider, width) => {
let pp = divider.parent.parent;
let bounds = pp.bounds;
let l = bounds.left;
let r = bounds.right;
divider.outerRect.bounds.width = width;
divider.bar.removeSegments()
divider.bar.addSegments([
new Point(l , divider.outerRect.bounds.center.y),
new Point(r, divider.outerRect.bounds.center.y)
]);
}
let expandWidthOfClass = (_class,width) => {
_class.statusGroup.children[0].bounds.width = width
_class.contentsGroup.children.forEach(child => {
switch(child.constructor.name){
case "Column" : expandWidthOfColumn(child, width);break;
case "Divider": expandWidthOfDivider(child,width);break;
default : break;
}
})
}
expandWidthOfClass(class1, 400)
Replace Class's Text to center
let class1 = ClassesController.create()
let expandWidthOfClass = (_class,width) => {
_class.statusGroup.children[0].bounds.width = width
_class.nameText.bounds.center = new Point(_class.rect.bounds.center.x, _class.rect.bounds.center.y + 10);
// _class.contentsGroup.children.forEach(child => {
// switch(child.constructor.name){
// case "Column" : expandWidthOfColumn(child, width);break;
// case "Divider": expandWidthOfDivider(child,width);break;
// default : break;
// }
// })
}
expandWidthOfClass(class1, 400)
expand with clicking button
let class1 = ClassesController.create()
let column1 = ColumnsController.createInto(class1)
let divider1 = DividersController.createInto(class1)
let column2 = ColumnsController.createInto(class1)
let expandWidthOfColumn = (column, width) => {
let pp = column.parent.parent; // i know the names are bad
let bounds = pp.bounds;
let l = bounds.left;
let r = bounds.right;
column.outerRect.bounds.width = width
column.innerRect.bounds = new Rectangle(
new Point(l + column.space, column.outerRect.bounds.top + column.space),
new Point(r - column.space, column.outerRect.bounds.bottom - column.space)
);
}
let expandWidthOfDivider = (divider, width) => {
let pp = divider.parent.parent;
let bounds = pp.bounds;
let l = bounds.left;
let r = bounds.right;
divider.outerRect.bounds.width = width;
divider.bar.removeSegments()
divider.bar.addSegments([
new Point(l , divider.outerRect.bounds.center.y),
new Point(r, divider.outerRect.bounds.center.y)
]);
}
let expandWidthOfClass = (_class,width) => {
_class.statusGroup.children[0].bounds.width = width
_class.nameText.bounds.center = new Point(_class.rect.bounds.center.x, _class.rect.bounds.center.y + 10);
_class.contentsGroup.children.forEach(child => {
switch(child.constructor.name){
case "Column" : expandWidthOfColumn(child, width);break;
case "Divider": expandWidthOfDivider(child,width);break;
default : break;
}
})
}
config.expandBtn.addEventListener("click", ()=>{
expandWidthOfClass(class1, class1.bounds.width + 10)
FociController.focus()
})
Will be able to set Listeners of each handles
foci_listener
export class FociHandleListener {
//Focus.rightMiddle.isDown = false
static set(){
FociHandleListener.setRightHandleListener()
}
static setRightHandleListener(){
document.querySelector('.rightMiddle').addEventListener('mousedown',()=>{
Focus.handle.rightMiddle.isMouseDown = true
})
document.querySelector('.rightMiddle').addEventListener('mousemove',()=>{
if(Focus.handle.rightMiddle.isMouseDown){
//do some thing
}
})
document.querySelector('.rightMiddle').addEventListener('mouseup',()=>{
Focus.handle.rightMiddle.isMouseDown = false
})
}
}
foci_controller
static focus(){
// if(!Focus.umlObj.isFocused){
import('js/utils/index.js').then(module => {
const MVCL = module.getMVCLFromUMLObject(Focus.umlObj)
Focus.umlObj.isFocused = true;
MVCL.CONSTROLLER.focus()
FociHandleListener.set()
});
// }
}
Considerations
https://user-images.githubusercontent.com/72016706/127174887-9da52a68-1cfa-4921-a12d-453d6621f5f3.mov
https://github.com/mcnLeandro/UML_App/issues/9#issuecomment-894030444
setShape
method in ControllersetShape
from View