mirror of
https://github.com/icedman/yaml2mindmap.git
synced 2024-12-21 22:12:33 +03:00
layout update
This commit is contained in:
parent
c2b62d6ecc
commit
24d6cf97a8
13
layout.pde
13
layout.pde
@ -89,6 +89,13 @@ class Layout {
|
||||
|
||||
void _position(Node n) {
|
||||
|
||||
boolean centeredVertically = false;
|
||||
|
||||
if (n.parent != null) {
|
||||
if (n.parent.parent == null)
|
||||
centeredVertically = true;
|
||||
}
|
||||
|
||||
Style style = n.style;
|
||||
Rect exT = style.calculateTextExtents(n.text, style.textSize);
|
||||
Rect exS = style.calculateTextExtents(" ", style.textSize);
|
||||
@ -123,6 +130,10 @@ class Layout {
|
||||
|
||||
_position(nc);
|
||||
}
|
||||
|
||||
if (centeredVertically && ! n.childrenDirection.equals("down") && children.size() > 1) {
|
||||
n.layout.y = n.layout.y + (n.layout.bounds.height / 2);
|
||||
}
|
||||
}
|
||||
|
||||
void _calculatePorts(Node n) {
|
||||
@ -222,7 +233,7 @@ class Layout {
|
||||
_reset(n);
|
||||
_calculateSize(n);
|
||||
|
||||
int d = _getDepth();
|
||||
int d = 1; // _getDepth();
|
||||
for (int i=0; i<d; i++) {
|
||||
_calculateBounds(n);
|
||||
_position(n);
|
||||
|
6
rect.pde
6
rect.pde
@ -66,4 +66,10 @@ class Rect {
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
|
||||
boolean pointInRect(int px, int py) {
|
||||
if (px < x || px > x + width || py < y || py > y +height)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
15
render.pde
15
render.pde
@ -97,10 +97,17 @@ class Renderer {
|
||||
float tx = (eh.height / 2) + (r.width / 2) - (ew.width / 2);
|
||||
float ty = (eh.height / 1.6) + (r.height / 2) - (ew.height / 2);
|
||||
|
||||
g.textFont(gs.font, style.textSize);
|
||||
g.textAlign(style.textAlign);
|
||||
g.fill(style.textColor);
|
||||
g.text(n.text, r.x + tx, r.y + ty);
|
||||
if (previewOnly) {
|
||||
int border = 8;
|
||||
g.fill(style.textColor);
|
||||
g.noStroke();
|
||||
g.rect(r.x + (border*2), r.y + (border*2), r.width - (border*4), r.height - (border*4));
|
||||
} else {
|
||||
g.textFont(gs.font, style.textSize);
|
||||
g.textAlign(style.textAlign);
|
||||
g.fill(style.textColor);
|
||||
g.text(n.text, r.x + tx, r.y + ty);
|
||||
}
|
||||
|
||||
for (Object c : n.children) {
|
||||
Node nc = (Node)c;
|
||||
|
@ -1,4 +1,6 @@
|
||||
String project = "civpro";
|
||||
String project = "crim2b";
|
||||
|
||||
boolean previewOnly = false;
|
||||
|
||||
Node root;
|
||||
|
||||
@ -23,6 +25,9 @@ void doRedraw() {
|
||||
|
||||
void settings()
|
||||
{
|
||||
if (previewOnly) {
|
||||
scale = 0.25;
|
||||
}
|
||||
size((int)(1280*windowScale), (int)(720*windowScale));
|
||||
}
|
||||
|
||||
@ -117,8 +122,11 @@ void keyReleased() {
|
||||
|
||||
{
|
||||
if (key == 'i') {
|
||||
boolean tmp = previewOnly;
|
||||
previewOnly = false;
|
||||
println("saving image");
|
||||
globalRenderer.saveImage(root, fileScale);
|
||||
previewOnly = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user