Commit 6623271c authored by Christoffer Ackelman's avatar Christoffer Ackelman

Web: More cleanup.

parent 63a51915
......@@ -264,20 +264,10 @@ class Cli {
if (this.cliTable[this.cliTableIndex].qualifier[i] === null) {
break;
}
if (this.cliTable[this.cliTableIndex].qualifier[i] === ("cli_arg1")) {
for (let i = 1; i <= 5; i++) {
if (this.cliTable[this.cliTableIndex].qualifier[i] === ("cli_arg" + String(i))) {
this.configuredVerbs++;
}
if (this.cliTable[this.cliTableIndex].qualifier[i] === ("cli_arg2")) {
this.configuredVerbs++;
}
if (this.cliTable[this.cliTableIndex].qualifier[i] === ("cli_arg3")) {
this.configuredVerbs++;
}
if (this.cliTable[this.cliTableIndex].qualifier[i] === ("cli_arg4")) {
this.configuredVerbs++;
}
if (this.cliTable[this.cliTableIndex].qualifier[i] === ("cli_arg5")) {
this.configuredVerbs++;
}
}
......@@ -318,17 +308,10 @@ class Cli {
* @return Returns true if the qualifier is present.
*/
qualifierFound(qual) {
if (qual === ("cli_arg1")) {
return !(this.verb.length < 2 || this.configuredVerbs < 1);
}
if (qual === ("cli_arg2")) {
return !(this.verb.length < 3 || this.configuredVerbs < 2);
}
if (qual === ("cli_arg3")) {
return !(this.verb.length < 4 || this.configuredVerbs < 3);
for (let i = 1; i < 6; i++) {
if (qual == ("cli_arg" + String(i))) {
return !(this.verb.length < (i+1) || this.configuredVerbs < i);
}
if (qual === ("cli_arg4")) {
return !(this.verb.length < 5 || this.configuredVerbs < 4);
}
for (let i = 0; i < this.qualifier.length; i++) {
if (qual === (this.qualifier[i])) {
......@@ -344,28 +327,13 @@ class Cli {
* @return Returns the value of the qualifier.
*/
getQualValue(qual) {
if (qual === ("cli_arg1")) {
if (this.verb.length < 2 || this.configuredVerbs < 1) {
return "";
}
return this.verb[1];
}
if (qual === ("cli_arg2")) {
if (this.verb.length < 3 || this.configuredVerbs < 2) {
return "";
for (let i = 1; i < 6; i++) {
if (qual == ("cli_arg" + String(i))) {
if (this.verb.length < (i+1) || this.configuredVerbs < i) {
return ""
}
return this.verb[2];
}
if (qual === ("cli_arg3")) {
if (this.verb.length < 4 || this.configuredVerbs < 3) {
return this.verb[3];
}
}
if (qual === ("cli_arg4")) {
if (this.verb.length < 5 || this.configuredVerbs < 4) {
return "";
return this.verb[i];
}
return this.verb[4];
}
for (let i = 0; i < this.qualifier.length; i++) {
if (qual === (this.qualifier[i])) {
......
......@@ -71,7 +71,7 @@ class ObjectInfo {
name;
description;
classname;
full_name;
fullname;
param1;
}
......@@ -813,11 +813,8 @@ class Gdh {
this.ws.send(helper.buf);
this.next_id++;
return sub.refid;
} else {
return sub.refid;
}
return sub.refid;
}
refObjectInfoReply(id, sts) {
......
......@@ -136,52 +136,44 @@ class PlowNodeClass {
}
insert(elem) {
this.a.add(elem);
this.a.push(elem);
}
}
class PlowArray {
a: Array = [];
a: Array<PlowNode> = [];
ctx: PlowCtx;
constructor(ctx) {
this.ctx = ctx;
}
add(elem) {
push(elem) {
this.a.push(elem);
}
insertNode(elem, destination, code) {
let idx = this.find(elem);
let idx = this.a.indexOf(elem);
if (idx !== -1) {
return;
}
if (destination === null) {
switch (code) {
case Dest.INTOLAST:
case Dest.AFTER:
this.a.push(elem);
elem.level = 0;
break;
default:
elem.level = 0;
if (code == Dest.INTOLAST || code == Dest.AFTER) {
this.a.push(elem);
} else {
this.a.unshift(elem);
}
} else {
let dest_idx = this.find(destination);
let dest_idx = this.a.indexOf(destination);
if (dest_idx === -1) {
return;
}
switch (code) {
case Dest.INTOFIRST:
if (dest_idx === this.a.length - 1) {
this.a.push(elem);
} else {
this.a.splice(dest_idx + 1, 0, elem);
}
elem.level = destination.level + 1;
break;
case Dest.INTOLAST:
......@@ -195,12 +187,8 @@ class PlowArray {
break;
}
}
if (idx === this.a.length) {
this.a.push(elem);
} else {
this.a.splice(idx, 0, elem);
}
}
elem.level = destination.level + 1;
break;
case Dest.AFTER:
......@@ -229,7 +217,7 @@ class PlowArray {
}
remove(elem) {
let idx = this.find(elem);
let idx = this.a.indexOf(elem);
if (idx === -1) {
return;
}
......@@ -246,15 +234,11 @@ class PlowArray {
}
draw(g, p, node, highlight) {
for (let i = 0; i < this.a.length; i++) {
this.a[i].draw(g, p, node, highlight);
}
this.a.forEach(e => e.draw(g, p, node, highlight));
}
set_borders(node) {
for (let i = 0; i < this.a.length; i++) {
this.a[i].set_borders(node);
}
this.a.forEach(e => e.set_borders(node));
}
configure() {
......@@ -265,7 +249,7 @@ class PlowArray {
}
close_node(node) {
let idx = this.find(node);
let idx = this.a.indexOf(node);
if (idx === -1) {
return;
}
......@@ -291,7 +275,7 @@ class PlowArray {
}
get_parent_object(node) {
let idx = this.find(node);
let idx = this.a.indexOf(node);
if (idx === -1) {
return null;
}
......@@ -305,7 +289,7 @@ class PlowArray {
}
get_first_child(node) {
let idx = this.find(node);
let idx = this.a.indexOf(node);
if (idx === -1) {
return null;
}
......@@ -340,60 +324,35 @@ class PlowArray {
}
get_next_object(node) {
for (let i = 0; i < this.a.length; i++) {
if (this.a[i] === node) {
if (i === this.a.length - 1) {
return null;
}
return this.a[i + 1];
}
}
return null;
let idx = this.a.indexOf(node);
return this.a[idx + 1] || null;
}
get_previous_object(node) {
for (let i = 0; i < this.a.length; i++) {
if (this.a[i] === node) {
if (i === 0) {
return null;
}
return this.a[i - 1];
}
}
return null;
let idx = this.a.indexOf(node);
return this.a[idx - 1] || null;
}
get_first_object() {
if (this.a.length === 0) {
return null;
}
return this.a[0];
return this.a[0] || null;
}
get_last_object() {
if (this.a.length === 0) {
return null;
}
return this.a[this.a.length - 1];
return this.a[this.a.length - 1] || null;
}
find(elem) {
for (let i = 0; i < this.a.length; i++) {
if (this.a[i] === elem) {
return i;
}
indexOf(elem) {
return this.a.indexOf(elem);
}
return -1;
forEach(callback) {
this.a.forEach(callback);
}
}
class PlowNode {
class PlowNode extends Rect {
ctx: PlowCtx;
userdata: object = null;
x_right = 0.0;
x_left = 0.0;
y_high = 0.0;
y_low = 0.0;
nc: PlowNodeClass;
pos = new Point();
n_name = "";
......@@ -415,6 +374,7 @@ class PlowNode {
relative_position = 0;
constructor(ctx, nc, level) {
super();
this.ctx = ctx;
this.nc = nc;
this.level = level;
......@@ -439,14 +399,11 @@ class PlowNode {
}
draw(g, p, node, highlight) {
let x = this.x_left * this.ctx.zoom_factor;
let y = this.y_low * this.ctx.zoom_factor - 1;
let width = (this.x_right - this.x_left) * this.ctx.zoom_factor;
let height = (this.y_high - this.y_low) * this.ctx.zoom_factor + 2;
g.fillStyle = "white";
if (this.select) {
g.fillStyle = "lightblue";
}
let x = this.ll_x * this.ctx.zoom_factor;
let y = this.ll_y * this.ctx.zoom_factor - 1;
let width = this.width() * this.ctx.zoom_factor;
let height = this.height() * this.ctx.zoom_factor + 2;
g.fillStyle = (this.select) ? "lightblue" : "white";
g.fillRect(x, y, width, height);
this.nc.draw(g, this.pos, this, this.highlight);
......@@ -486,18 +443,15 @@ class PlowNode {
}
set_borders(node) {
this.x_left = 1.0e37;
this.x_right = -1.0e37;
this.y_low = 1.0e37;
this.y_high = -1.0e37;
this.set(new Rect(1.0e37, 1.0e37, -1.0e37, -1.0e37));
this.nc.a.set_borders(this);
}
event_handler(event, x, y) {
if ((x - this.ctx.offset_x) / this.ctx.zoom_factor >= this.x_left &&
(x - this.ctx.offset_x) / this.ctx.zoom_factor <= this.x_right &&
(y - this.ctx.offset_y) / this.ctx.zoom_factor >= this.y_low &&
(y - this.ctx.offset_y) / this.ctx.zoom_factor <= this.y_high) {
let p = new Point(
(x - this.ctx.offset_x) / this.ctx.zoom_factor,
(y - this.ctx.offset_y) / this.ctx.zoom_factor);
if (this.hit(p)) {
this.ctx.event_object = this;
return 1;
}
......@@ -533,16 +487,12 @@ class PlowNode {
}
in_icon(x, y) {
return x >= this.x_left * this.ctx.zoom_factor && x <=
(this.x_left + 1.75) * this.ctx.zoom_factor;
return x >= this.ll_x * this.ctx.zoom_factor &&
x <= (this.ll_x + 1.75) * this.ctx.zoom_factor;
}
measure() {
return new Rect(
this.x_left * this.ctx.zoom_factor,
this.y_low * this.ctx.zoom_factor,
(this.x_right - this.x_left) * this.ctx.zoom_factor,
(this.y_high - this.y_low) * this.ctx.zoom_factor);
return this;
};
}
......@@ -572,51 +522,19 @@ class PlowAnnot {
return;
}
let tsize = 0;
let idx = this.ctx.zoom_factor / this.ctx.base_zoom_factor *
(this.text_size + 4) - 4;
if (idx < 0) {
return;
}
switch (idx) {
case 0:
tsize = 8;
break;
case 1:
tsize = 10;
break;
case 2:
tsize = 12;
break;
case 3:
tsize = 14;
break;
case 4:
tsize = 14;
break;
case 5:
tsize = 18;
break;
case 6:
tsize = 18;
break;
case 7:
tsize = 18;
break;
default:
tsize = idx * 3;
}
let tsize = (idx < 0 || idx > 7) ? (idx * 3) : ([8, 10, 12, 14, 14, 18, 18, 18][idx]);
g.font = tsize + "px Arial";
if (node.invert) {
g.fillStyle = "white";
} else {
g.fillStyle = "black";
}
if (highlight) {
g.fillStyle = "red";
} else {
g.fillStyle = (node.invert) ? "white" : "black";
}
g.lineWidth = 0.5;
......@@ -759,36 +677,17 @@ class PlowRect {
g.fillStyle = "lightgreen";
break;
case Color.WHITE:
if (node.invert) {
g.fillStyle = "black";
} else {
g.fillStyle = "white";
}
g.fillStyle = (node.invert) ? "black" : "white";
break;
default:
if (node.invert) {
g.fillStyle = "white";
} else {
g.fillStyle = "black";
}
g.fillStyle = (node.invert) ? "white" : "black";
}
g.fillRect(x, y, width, height);
}
}
set_borders(node) {
if (this.ll.x + node.pos.x < node.x_left) {
node.x_left = this.ll.x + node.pos.x;
}
if (this.ur.x + node.pos.x > node.x_right) {
node.x_right = this.ur.x + node.pos.x;
}
if (this.ll.y + node.pos.y < node.y_low) {
node.y_low = this.ll.y + node.pos.y;
}
if (this.ur.y + node.pos.y > node.y_high) {
node.y_high = this.ur.y + node.pos.y;
}
node.set(Rect.union(node, new Rect(this.ll.x + node.pos.x, this.ll.y + node.pos.y, this.ur.x + node.pos.x, this.ur.y + node.pos.y)));
}
}
......@@ -814,10 +713,7 @@ class PlowCtx {
base_zoom_factor = 20.0;
offset_x = 0;
offset_y = 0;
x_right = 0.0;
x_left = 0.0;
y_high = 0.0;
y_low = 0.0;
rect: Rect;
a: PlowArray;
a_nc: PlowArray;
name = "Claes context";
......@@ -830,6 +726,7 @@ class PlowCtx {
this.a = new PlowArray(this);
this.a_nc = new PlowArray(this);
this.gdraw = new GDraw(this);
this.rect = new Rect();
}
draw() {
......@@ -919,7 +816,7 @@ class PlowCtx {
}
insert(n, dest) {
this.a.add(n);
this.a.push(n);
}
insertNode(n, destination, destCode) {
......@@ -934,7 +831,7 @@ class PlowCtx {
}
insert_nc(nc) {
this.a_nc.add(nc);
this.a_nc.push(nc);
}
configure() {
......@@ -968,9 +865,9 @@ class PlowCtx {
}
is_visible(o) {
return (o.y_high * this.zoom_factor <= window.pageYOffset +
return (o.ur_y * this.zoom_factor <= window.pageYOffset +
window.innerHeight - this.gdraw.offset_top) &&
(o.y_low * this.zoom_factor >= window.pageYOffset -
(o.ll_y * this.zoom_factor >= window.pageYOffset -
this.gdraw.offset_top);
}
......
......@@ -208,18 +208,46 @@ class Point {
}
class Rect {
x = 0;
y = 0;
width = 0;
height = 0;
ll_x = 0;
ll_y = 0;
ur_x = 0;
ur_y = 0;
constructor() {
}
constructor(x: number, y: number, width: number, height: number) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
constructor(x: number, y: number, x2: number, y2: number) {
this.ll_x = x;
this.ll_y = y;
this.ur_x = x2;
this.ur_y = y2;
}
set(r: Rect) {
this.ll_x = r.ll_x;
this.ll_y = r.ll_y;
this.ur_x = r.ur_x;
this.ur_y = r.ur_y;
}
width() {
return this.ur_x - this.ll_x;
}
height() {
return this.ur_y - this.ll_y;
}
hit(p: Point) {
return (p.x >= this.ll_x && p.x <= this.ur_x && p.y >= this.ll_y && p.y <= this.ur_y);
}
static union(r1: Rect, r2: Rect) {
return new Rect(
Math.min(r1.ll_x, r2.ll_x),
Math.min(r1.ll_y, r2.ll_y),
Math.max(r1.ur_x, r2.ur_x),
Math.max(r1.ur_y, r2.ur_y),
);
}
}
\ No newline at end of file
......@@ -22,11 +22,8 @@ class Ev {
constructor() {
this.type = this.get_type();
switch (this.type) {
case EvType.EventList:
if (this.type === EvType.EventList) {
document.title = "Event List";
break;
default:
}
this.priv = Number(sessionStorage.getItem("pwr_privilege"));
......@@ -220,11 +217,7 @@ class Ev {
login_cb(id, data, sts, result) {
console.log("Login:", sts, result);
if (sts & 1) {
this.priv = result;
} else {
this.priv = 0;
}
this.priv = (sts & 1) ? result : 0;
}
sync_cb(id, data, sts, result) {
......@@ -280,9 +273,7 @@ class Ev {
}
break;
}
if (this.mhSyncIdx < result[i].syncIdx) {
this.mhSyncIdx = result[i].syncIdx;
}
this.mhSyncIdx = Math.max(this.mhSyncIdx, result[i].syncIdx);
}
this.ctx.configure();
this.ctx.reset_nodraw();
......@@ -297,9 +288,7 @@ class Ev {
}
new EvItemAlarm(this, e, null, Dest.BEFORE);
if (this.mhSyncIdx < result[i].syncIdx) {
this.mhSyncIdx = result[i].syncIdx;
}
this.mhSyncIdx = Math.max(this.mhSyncIdx, result[i].syncIdx);
}
this.ctx.configure();
this.ctx.reset_nodraw();
......@@ -491,69 +480,38 @@ class Ev {
this.ncAlarmA = new PlowNodeClass(this.ctx);
this.ncAlarmA.insert(r1);
this.ncAlarmA.insert(r2a);
this.ncAlarmA.insert(a1);
this.ncAlarmA.insert(p1);
this.ncAlarmA.insert(p2);
this.ncAlarmA.insert(p3);
this.ncAlarmA.insert(p4);
this.ncAlarmA.insert(a2);
this.ncAlarmA.insert(a3);
this.ncAlarmA.insert(a4);
this.ctx.insert_nc(this.ncAlarmA);
// A alarm with yellow square
this.ncAlarmB = new PlowNodeClass(this.ctx);
this.ncAlarmB.insert(r1);
this.ncAlarmB.insert(r2b);
this.ncAlarmB.insert(a1);
this.ncAlarmB.insert(p1);
this.ncAlarmB.insert(p2);
this.ncAlarmB.insert(p3);
this.ncAlarmB.insert(p4);
this.ncAlarmB.insert(a2);
this.ncAlarmB.insert(a3);
this.ncAlarmB.insert(a4);
this.ctx.insert_nc(this.ncAlarmB);
// D and C alarm with no square
this.ncAlarm = new PlowNodeClass(this.ctx);
this.ncAlarm.insert(r1);
this.ncAlarm.insert(a1);
this.ncAlarm.insert(p1);
this.ncAlarm.insert(p2);
this.ncAlarm.insert(p3);
this.ncAlarm.insert(p4);
this.ncAlarm.insert(a2);
this.ncAlarm.insert(a3);
this.ncAlarm.insert(a4);
this.ctx.insert_nc(this.ncAlarm);
// Info with white square
this.ncInfo = new PlowNodeClass(this.ctx);
this.ncInfo.insert(r1);
this.ncInfo.insert(r2info);
this.ncInfo.insert(a1);
this.ncInfo.insert(p1);
this.ncInfo.insert(p2);
this.ncInfo.insert(p3);
this.ncInfo.insert(p4);
this.ncInfo.insert(a2);
this.ncInfo.insert(a3);
this.ncInfo.insert(a4);
this.ctx.insert_nc(this.ncInfo);
// InfoSuccess with green square
this.ncSuccess = new PlowNodeClass(this.ctx);
this.ncSuccess.insert(r1);
this.ncSuccess.insert(r2success);
this.ncSuccess.insert(a1);
this.ncSuccess.insert(p1);
this.ncSuccess.insert(p2);
this.ncSuccess.insert(p3);
this.ncSuccess.insert(p4);
this.ncSuccess.insert(a2);
this.ncSuccess.insert(a3);
this.ncSuccess.insert(a4);
[a1, p1, p2, p3, p4, a2, a3, a4].forEach(function (a) {
this.ncAlarmA.insert(a);
this.ncAlarmB.insert(a);
this.ncAlarm.insert(a);
this.ncInfo.insert(a);
this.ncSuccess.insert(a);
});
this.ctx.insert_nc(this.ncAlarmA);
this.ctx.insert_nc(this.ncAlarmB);
this.ctx.insert_nc(this.ncAlarm);
this.ctx.insert_nc(this.ncInfo);
this.ctx.insert_nc(this.ncSuccess);
}
......@@ -598,7 +556,7 @@ class Ev {
next.set_select(true);
next.set_invert(true);
if (!this.ctx.is_visible(next)) {
this.ctx.scroll(next.y_low, 0.10);
this.ctx.scroll(next.ll_y, 0.10);
}
}
}
......@@ -615,7 +573,7 @@ class Ev {
o.draw(this.ctx.gdraw.gctx, null, null, 0);
next.draw(this.ctx.gdraw.gctx, null, null, 0);
if (!this.ctx.is_visible(next)) {
this.ctx.scroll(next.y_low, 0.90);
this.ctx.scroll(next.ll_y, 0.90);
}
}
}
......@@ -644,7 +602,6 @@ class Ev {
// Query 'list' = alarm/event/block. Alarm is default.
get_type() {
let query = window.location.search.substring(1);
let type;
if (query === "") {
return EvType.AlarmList;
......@@ -653,14 +610,12 @@ class Ev {
let vars = query.split('&');
let typestr = vars[0].substring(5);
if (typestr === "event") {
type = EvType.EventList;
return EvType.EventList;
} else if (typestr === "block") {
type = EvType.BlockList;
return EvType.BlockList;
} else {
type = EvType.AlarmList;
return EvType.AlarmList;
}
return type;
}
}
......@@ -684,19 +639,12 @@ class EvItemAlarm {
case Event.Reblock:
case Event.CancelBlock:
case Event.Unblock:
switch (this.e.eventPrio) {
case EventPrio.A:
if (this.e.eventPrio === EventPrio.A) {
nodeclass = ev.ncAlarmA;
break;
case EventPrio.B:
} else if (this.e.eventPrio === EventPrio.B) {
nodeclass = ev.ncAlarmB;
break;
case EventPrio.C:
nodeclass = ev.ncAlarm;
break;
case EventPrio.D:
} else {
nodeclass = ev.ncAlarm;
break;
}
break;
case Event.Info:
......@@ -722,20 +670,7 @@ class EvItemAlarm {
case Event.Reblock:
case Event.CancelBlock:
case Event.Unblock:
switch (this.e.eventPrio) {
case EventPrio.A:
this.node.set_annotation(0, "A");
break;
case EventPrio.B:
this.node.set_annotation(0, "B");
break;
case EventPrio.C:
this.node.set_annotation(0, "C");
break;
case EventPrio.D:
this.node.set_annotation(0, "D");
break;
}
this.node.set_annotation(0, String.fromCharCode(132 - this.e.eventPrio));
break;
}
switch (this.e.eventType) {
......
This diff is collapsed.
......@@ -13,49 +13,56 @@
<script type="text/babel" src="gdh.js"></script>
<script type="text/babel" src="glow.ts"></script>
<script type="text/babel" src="glow_point.ts"></script>
<script type="text/babel" src="glow_color.ts"></script>
<script type="text/babel" src="glow_array.ts"></script>
<script type="text/babel" src="glow_point.ts"></script>
<script type="text/babel" src="glow_transform.ts"></script>
<script type="text/babel" src="glow_nodeclass.ts"></script>
<script type="text/babel" src="glow_nodegroup.ts"></script>
<script type="text/babel" src="glow_conclass.ts"></script>
<script type="text/babel" src="glow_annot.ts"></script>
<script type="text/babel" src="glow_arc.ts"></script>
<script type="text/babel" src="glow_array.ts"></script>
<script type="text/babel" src="glow_cformat.ts"></script>
<script type="text/babel" src="glow_con.ts"></script>
<script type="text/babel" src="glow_conclass.ts"></script>
<script type="text/babel" src="glow_conpoint.ts"></script>
<script type="text/babel" src="glow_draw.ts"></script>
<script type="text/babel" src="glow_line.ts"></script>
<script type="text/babel" src="glow_arc.ts"></script>
<script type="text/babel" src="glow_node.ts"></script>
<script type="text/babel" src="glow_nodeclass.ts"></script>
<script type="text/babel" src="glow_nodegroup.ts"></script>
<script type="text/babel" src="glow_polyline.ts"></script>
<script type="text/babel" src="glow_rect.ts"></script>
<script type="text/babel" src="glow_text.ts"></script>
<script type="text/babel" src="glow_conpoint.ts"></script>
<script type="text/babel" src="glow_draw.ts"></script>
<script type="text/babel" src="glow_cformat.ts"></script>
<script type="text/babel" src="grow_node.ts"></script>
<script type="text/babel" src="grow_group.ts"></script>
<script type="text/babel" src="grow_slider.ts"></script>
<script type="text/babel" src="grow_toolbar.ts"></script>
<script type="text/babel" src="grow_rect.ts"></script>
<script type="text/babel" src="grow_rectrounded.ts"></script>
<script type="text/babel" src="grow_line.ts"></script>
<script type="text/babel" src="grow_arc.ts"></script>
<script type="text/babel" src="grow_text.ts"></script>
<script type="text/babel" src="grow_annot.ts"></script>
<script type="text/babel" src="grow_polyline.ts"></script>
<script type="text/babel" src="grow_conpoint.ts"></script>
<script type="text/babel" src="grow_image.ts"></script>
<script type="text/babel" src="grow_conglue.ts"></script>
<script type="text/babel" src="grow_arc.ts"></script>
<script type="text/babel" src="grow_axis.ts"></script>
<script type="text/babel" src="grow_axisarc.ts"></script>
<script type="text/babel" src="grow_bar.ts"></script>
<script type="text/babel" src="grow_bararc.ts"></script>
<script type="text/babel" src="grow_trend.ts"></script>
<script type="text/babel" src="grow_xycurve.ts"></script>
<script type="text/babel" src="grow_barchart.ts"></script>
<script type="text/babel" src="grow_conglue.ts"></script>
<script type="text/babel" src="grow_conpoint.ts"></script>
<script type="text/babel" src="grow_group.ts"></script>
<script type="text/babel" src="grow_image.ts"></script>
<script type="text/babel" src="grow_line.ts"></script>
<script type="text/babel" src="grow_menu.ts"></script>
<script type="text/babel" src="grow_pie.ts"></script>
<script type="text/babel" src="grow_polyline.ts"></script>
<script type="text/babel" src="grow_rectrounded.ts"></script>
<script type="text/babel" src="grow_scrollbar.ts"></script>
<script type="text/babel" src="grow_slider.ts"></script>
<script type="text/babel" src="grow_table.ts"></script>
<script type="text/babel" src="grow_text.ts"></script>
<script type="text/babel" src="grow_toolbar.ts"></script>
<script type="text/babel" src="grow_trend.ts"></script>
<script type="text/babel" src="grow_window.ts"></script>
<script type="text/babel" src="grow_xycurve.ts"></script>
<script type="text/babel" src="grow_folder.ts"></script>
<script type="text/babel" src="grow_axis.ts"></script>
<script type="text/babel" src="grow_axisarc.ts"></script>
<script type="text/babel" src="grow_pie.ts"></script>
<script type="text/babel" src="grow_barchart.ts"></script>
<script type="text/babel" src="grow_table.ts"></script>
<script type="text/babel" src="grow_ctx.ts"></script>
<script type="text/babel" src="grow_frame.ts"></script>
......
......@@ -88,7 +88,7 @@ class Appl {
graphName = cli.getQualValue("cli_arg2").toLowerCase();
if (graphName.charAt(".pwg") === -1) {
graphName = graphName + ".pwg";
graphName += ".pwg";
}
let href;
......@@ -186,7 +186,7 @@ class Appl {
}
if (source.indexOf('.') === -1) {
source = source + ".pwg";
source += ".pwg";
}
this.graph.setSubwindowSource(name, source, object);
......
......@@ -325,7 +325,6 @@ class Dyn {
this.elements.push(elem);
i = elem.open(lines, i + 1);
}
return i;
default:
console.log("Syntax error in Dyn");
......@@ -2225,7 +2224,6 @@ class DynValue extends DynElem {
if (this.format !== null) {
this.cFormat = new GlowCFormat(this.format);
}
return i;
default:
console.log("Syntax error in DynValue");
......@@ -2789,10 +2787,10 @@ class DynMove extends DynElem {
if (!object.transformIsStored()) {
object.storeTransform();
let geom = object.measure();
this.x_orig = geom.x;
this.y_orig = geom.y;
this.width_orig = geom.width;
this.height_orig = geom.height;
this.x_orig = geom.ll_x;
this.y_orig = geom.ll_y;
this.width_orig = geom.width();
this.height_orig = geom.height();
}
return 1;
......@@ -3362,13 +3360,10 @@ class DynScrollingText extends DynElem {
}
let geom = object.measure();
switch (this.direction) {
case Direction.Left:
case Direction.Right:
this.osize = geom.width;
break;
default:
this.osize = geom.height;
if (this.direction == Direction.Left || this.direction == Direction.Right) {
this.osize = geom.width();
} else {
this.osize = geom.height();
}
return 1;
......@@ -6881,25 +6876,25 @@ class DynFillLevel extends DynElem {
value =
((pvalue - this.min_value) / (this.max_value - this.min_value) *
(this.limit_max - this.limit_min) +
(this.limit_min - geom.x)) / geom.width;
(this.limit_min - geom.ll_x)) / geom.width();
break;
case Direction.Left:
value =
((pvalue - this.min_value) / (this.max_value - this.min_value) *
(this.limit_max - this.limit_min) +
(geom.width - geom.x - this.limit_max)) / geom.width;
(geom.ur_x - this.limit_max)) / geom.width();
break;
case Direction.Up:
value =
((pvalue - this.min_value) / (this.max_value - this.min_value) *
(this.limit_max - this.limit_min) +
(this.limit_min - geom.y)) / geom.height;
(this.limit_min - geom.ll_y)) / geom.height();
break;
case Direction.Down:
value =
((pvalue - this.min_value) / (this.max_value - this.min_value) *
(this.limit_max - this.limit_min) +
(geom.height - geom.y - this.limit_max)) / geom.height;
(geom.ur_y - this.limit_max)) / geom.height();
break;
default:
}
......@@ -8465,7 +8460,7 @@ class DynSlider extends DynElem {
let g = object.measure();
let info = object.get_info();
let b = this.dyn.graph.getCtx()
.getBackgroundObjectLimits(DynType1.SliderBackground, g.x + g.width / 2, g.y + g.height / 2);
.getBackgroundObjectLimits(DynType1.SliderBackground, (g.ll_x + g.ur_x) / 2, (g.ll_y + g.ur_y) / 2);
if ((b.sts & 1) === 0) {
this.direction = info.direction;
} else {
......@@ -9052,10 +9047,10 @@ class DynPulldownMenu extends DynElem {
}
let g = object.measure();
this.menu_object = new GrowMenu(this.dyn.graph.getCtx());
this.menu_object.init("__Menu", info, g.x, g.y + g.height, g.width,
DrawType.Line, 0, 1, 1, bg_color, text_size, text_drawtype,
text_color, DrawType.MediumGray, text_font);
this.menu_object = new GrowMenu(this.dyn.graph.getCtx(),
"__Menu", info, g.x, g.ur_y, g.width(),
DrawType.Line, 0, 1, 1, bg_color, text_size,
text_drawtype, text_color, DrawType.MediumGray, text_font);
this.menu_object.set_scale(scale, scale, 0, 0,
ScaleType.LowerLeft);
this.dyn.graph.getCtx().insert(this.menu_object);
......@@ -9605,10 +9600,10 @@ class DynOptionMenu extends DynElem {
}
let g = object.measure();
this.menu_object = new GrowMenu(this.dyn.graph.getCtx());
this.menu_object.init("__Menu", info, g.x, g.y + g.height, g.width,
DrawType.Line, 0, 1, 1, bg_color, tsize, text_drawtype,
text_color, DrawType.MediumGray, text_font);
this.menu_object = new GrowMenu(this.dyn.graph.getCtx(),
"__Menu", info, g.ll_x, g.ur_y, g.width(),
DrawType.Line, 0, 1, 1, bg_color, tsize,
text_drawtype, text_color, DrawType.MediumGray, text_font);
this.menu_object.set_scale(scale, scale, 0, 0,
ScaleType.LowerLeft);
this.dyn.graph.getCtx().insert(this.menu_object);
......@@ -10806,9 +10801,9 @@ class DynMethodPulldownMenu extends DynElem {
}
let g = this.o.measure();
this.menu_object = new GrowMenu(this.dyn.graph.getCtx());
this.menu_object.init("__Menu", info, g.x, g.y + g.height, g.width,
DrawType.Line, 0, 1, 1, bg_color, text_size, text_drawtype,
this.menu_object = new GrowMenu(this.dyn.graph.getCtx(),
"__Menu", info, g.ll_x, g.ur_y, g.width(), DrawType.Line,
0, 1, 1, bg_color, text_size, text_drawtype,
text_color, DrawType.MediumGray, text_font);
this.menu_object.set_scale(scale, scale, 0, 0, ScaleType.LowerLeft);
this.dyn.graph.getCtx().insert(this.menu_object);
......
......@@ -276,7 +276,7 @@ class Graph {
}
gdh_init_cb() {
if (this.priv == null) {
if (this.priv === null) {
this.gdh.login("", "", this.login_cb, this);
}
......@@ -366,14 +366,13 @@ class Graph {
let dyn;
let o;
if (e.object_type !== ObjectType.NoObject && e.object !== null) {
if (e.object) {
ctx_popped = this.ctxPop(e.object.ctx);
}
switch (e.event) {
case Event.MB1Click:
if (e.object_type === ObjectType.NoObject ||
!(e.object instanceof GrowMenu)) {
if (!(e.object instanceof GrowMenu)) {
// Close any open menu, if not click in menu
let event = new GlowEventMenu();
event.event = Event.MenuDelete;
......@@ -383,8 +382,7 @@ class Graph {
let list = this.ctx.get_object_list();
for (let i = 0; i < list.size(); i++) {
o = list.get(i);
if ((o instanceof GrowNode || o instanceof GrowGroup) &&
(e.object_type === ObjectType.NoObject || o !== e.object)) {
if ((o instanceof GrowNode || o instanceof GrowGroup) && o !== e.object) {
dyn = o.getUserData();
if (dyn !== null) {
dyn.action(o, event);
......@@ -419,24 +417,20 @@ class Graph {
break;
case Event.MenuActivated:
case Event.MenuCreate:
case Event.MenuDelete: {
let old_size;
let sts;
case Event.MenuDelete:
let list = this.ctx.get_object_list();
for (let i = 0; i < list.size(); i++) {
o = list.get(i);
if (o instanceof GrowNode || o instanceof GrowGroup) {
dyn = o.getUserData();
if (dyn !== null) {
sts = dyn.action(o, e);
let sts = dyn.action(o, e);
if (sts === GLOW__TERMINATED) {
return;
}
// Check if anything is deleted
old_size = list.size();
let old_size = list.size();
list = this.ctx.get_object_list();
if (old_size !== list.size()) {
break;
......@@ -445,7 +439,6 @@ class Graph {
}
}
break;
}
default:
break;
}
......@@ -653,7 +646,7 @@ class Graph {
}
pname.database = Database.Ccm;
pname.tname = new String(pname.name);
pname.tname = String(pname.name);
return pname;
}
......@@ -665,7 +658,7 @@ class Graph {
}
}
pname.tname = new String(str);
pname.tname = String(str);
if ((idx = str.indexOf('[')) === -1) {
if ((eidx = str.lastIndexOf('#')) !== -1 && str.charAt(eidx - 1) !== '#') {
......@@ -732,7 +725,7 @@ class Graph {
ctx_popped = this.ctxPop(object.ctx);
}
if (object.userdata == null) {
if (object.userdata === null) {
if (ctx_popped) {
this.ctxPush();
}
......@@ -748,7 +741,7 @@ class Graph {
(dyn.dyn_type1 & DynType1.HostObject) !== 0) {
let nodeclass_dyn = object.getClassUserData();
dyn.setTotal(null);
if (nodeclass_dyn != null) {
if (nodeclass_dyn !== null) {
let old_dyn = dyn;
dyn = new Dyn(this);
dyn.merge(old_dyn);
......@@ -810,7 +803,7 @@ class Graph {
}
openConfirmDialog(dyn, text, object) {
if (appl != null) {
if (appl !== null) {
appl.openConfirmDialog(dyn, text, object);
}
}
......@@ -831,14 +824,14 @@ class Graph {
}
command(cmd) {
if (this.appl != null) {
if (this.appl !== null) {
return this.appl.command(cmd);
}
return 0;
}
script(script) {
if (this.appl != null) {
if (this.appl !== null) {
return this.appl.script(script);
}
return 0;
......@@ -853,7 +846,7 @@ class Graph {
let idx;
while ((idx = str.indexOf("$object")) !== -1) {
if (appl != null) {
if (appl !== null) {
let oname = this.ctx.getOwner();
str = str.substring(0, idx) + oname + str.substring(idx + 7);
}
......
......@@ -1699,11 +1699,6 @@ class GlowEventToolbar extends GlowEvent {
idx = 0;
}
class GlowPointX {
x;
y;
}
class GlowSliderInfo {
direction;
max_value;
......@@ -1719,7 +1714,7 @@ class MenuInfoItem {
}
class GlowMenuInfo {
item = Array(32);
item = Array<MenuInfoItem>(32);
constructor() {
for (let i = 0; i < 32; i++) {
......
class GlowAnnot {
ctx: GrowCtx;
number;
p: GlowPoint;
draw_type;
text_size;
annot_type;
display_level;
color_drawtype;
font;
protect;
constructor(ctx) {
this.ctx = ctx;
this.p = new GlowPoint();
}
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
switch (key) {
case GlowSave.Annot:
break;
case GlowSave.Annot_number:
this.number = parseInt(tokens[1], 10);
break;
case GlowSave.Annot_draw_type:
this.draw_type = parseInt(tokens[1], 10);
break;
case GlowSave.Annot_color_drawtype:
this.color_drawtype = parseInt(tokens[1], 10);
break;
case GlowSave.Annot_text_size:
this.text_size = parseInt(tokens[1], 10);
break;
case GlowSave.Annot_display_level:
this.display_level = parseInt(tokens[1], 10);
break;
case GlowSave.Annot_p:
i = this.p.open(lines, i + 1);
break;
case GlowSave.Annot_annot_type:
this.annot_type = parseInt(tokens[1], 10);
break;
case GlowSave.Annot_font:
this.font = parseInt(tokens[1], 10);
break;
case GlowSave.Annot_protect:
this.protect = parseInt(tokens[1], 10);
break;
case GlowSave.End:
return i;
default:
console.log("Syntax error in GlowAnnot");
break;
}
}
return i;
}
}
\ No newline at end of file
......@@ -19,15 +19,10 @@ class GlowArc {
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GlowArc : " + lines[i]);
}
switch (key) {
case GlowSave.Arc:
break;
......@@ -59,6 +54,7 @@ class GlowArc {
break;
}
}
return i;
}
......@@ -67,14 +63,13 @@ class GlowArc {
return;
}
let ll_x, ll_y, ur_x, ur_y;
ll_x = Math.floor(this.ll.x * this.ctx.mw.zoom_factor_x + 0.5) -
let ll_x = Math.floor(this.ll.x * this.ctx.mw.zoom_factor_x + 0.5) -
this.ctx.mw.offset_x;
ll_y = Math.floor(this.ll.y * this.ctx.mw.zoom_factor_y + 0.5) -
let ll_y = Math.floor(this.ll.y * this.ctx.mw.zoom_factor_y + 0.5) -
this.ctx.mw.offset_y;
ur_x = Math.floor(this.ur.x * this.ctx.mw.zoom_factor_x + 0.5) -
let ur_x = Math.floor(this.ur.x * this.ctx.mw.zoom_factor_x + 0.5) -
this.ctx.mw.offset_x;
ur_y = Math.floor(this.ur.y * this.ctx.mw.zoom_factor_y + 0.5) -
let ur_y = Math.floor(this.ur.y * this.ctx.mw.zoom_factor_y + 0.5) -
this.ctx.mw.offset_y;
if (ll_x === ur_x && ll_y === ur_y) {
......@@ -94,14 +89,13 @@ class GlowArc {
return;
}
let ll_x, ll_y, ur_x, ur_y;
ll_x = Math.floor(this.ll.x * this.ctx.mw.zoom_factor_x + 0.5) -
let ll_x = Math.floor(this.ll.x * this.ctx.mw.zoom_factor_x + 0.5) -
this.ctx.mw.offset_x;
ll_y = Math.floor(this.ll.y * this.ctx.mw.zoom_factor_y + 0.5) -
let ll_y = Math.floor(this.ll.y * this.ctx.mw.zoom_factor_y + 0.5) -
this.ctx.mw.offset_y;
ur_x = Math.floor(this.ur.x * this.ctx.mw.zoom_factor_x + 0.5) -
let ur_x = Math.floor(this.ur.x * this.ctx.mw.zoom_factor_x + 0.5) -
this.ctx.mw.offset_x;
ur_y = Math.floor(this.ur.y * this.ctx.mw.zoom_factor_y + 0.5) -
let ur_y = Math.floor(this.ur.y * this.ctx.mw.zoom_factor_y + 0.5) -
this.ctx.mw.offset_y;
let idx = Math.floor(this.ctx.mw.zoom_factor_y /
this.ctx.mw.base_zoom_factor * this.line_width - 1);
......
......@@ -11,13 +11,11 @@ class GlowArray {
}
remove(elem) {
for (let i = 0; i < this.a.length; i++) {
if (this.a[i] === elem) {
this.a.splice(i, 1);
return 1;
let idx = this.a.indexOf(elem);
if (idx != -1) {
this.a.splice(idx, 1);
}
}
return 0;
return (idx != -1);
}
size() {
......@@ -35,10 +33,6 @@ class GlowArray {
let key = parseInt(tokens[0], 10);
let o;
if (this.ctx.debug) {
console.log("GlowArray : " + lines[i]);
}
switch (key) {
case GlowSave.Array:
break;
......@@ -233,10 +227,23 @@ class GlowArray {
break;
}
}
return i;
}
clear() {
this.a.length = 0;
}
forEach(callback) {
this.a.forEach(callback);
}
slice(start, end) {
return this.a.slice(start, end);
}
find(callback) {
return this.a.find(callback);
}
}
\ No newline at end of file
......@@ -125,8 +125,9 @@ class GlowCFormat {
pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' ';
pad_length = ph.width - (sign + arg).length;
let pad_rpt = '';
for (let i = 0; i < pad_length; i++)
for (let i = 0; i < pad_length; i++) {
pad_rpt += pad_character;
}
pad = ph.width ? (pad_length > 0 ? pad_rpt : '') : '';
output += ph.align ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg);
}
......@@ -145,9 +146,13 @@ class GlowCFormat {
} else if ((match = CFormatC.placeholder.exec(_fmt)) !== null) {
if (match[2]) {
arg_names |= 1;
let field_list = [], replacement_field = match[2], field_match = [];
if ((field_match = CFormatC.key.exec(replacement_field)) !== null) {
field_list.push(field_match[1]);
let replacement_field = match[2];
let field_match = CFormatC.key.exec(replacement_field);
if (field_match === null) {
throw new SyntaxError('[sprintf] failed to parse named argument key');
}
let field_list = [field_match[1]];
while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
if ((field_match = CFormatC.key_access.exec(replacement_field)) !== null) {
field_list.push(field_match[1]);
......@@ -157,9 +162,7 @@ class GlowCFormat {
throw new SyntaxError('[sprintf] failed to parse named argument key');
}
}
} else {
throw new SyntaxError('[sprintf] failed to parse named argument key');
}
match[2] = field_list;
} else {
arg_names |= 2;
......
......@@ -84,8 +84,6 @@ class GlowColor {
}
static shift_drawtype(dt, shift, node) {
let incr;
let base_drawtype;
let drawtype;
if (node !== null && node.getColorInverse() !== 0) {
......@@ -93,8 +91,8 @@ class GlowColor {
}
if (this.is_shiftable(dt)) {
base_drawtype = Math.floor(dt / 10) * 10;
incr = shift + dt - base_drawtype;
let base_drawtype = Math.floor(dt / 10) * 10;
let incr = shift + dt - base_drawtype;
if (incr < 0) { // White
drawtype = DrawType.Color4;
......@@ -123,15 +121,8 @@ class GlowColor {
static get_drawtype(local_drawtype, highlight_drawtype, highlight, node, fill,
highlight_disabled) {
let drawtype;
let base_drawtype;
let incr;
let lightness = 0;
let intensity = 0;
if (node !== null) {
lightness = node.getColorLightness();
intensity = node.getColorIntensity();
}
let lightness = (node === null) ? 0 : node.getColorLightness();
let intensity = (node === null) ? 0 : node.getColorIntensity();
if (highlight !== 0 && highlight_disabled === 0) {
drawtype = highlight_drawtype;
......@@ -189,8 +180,8 @@ class GlowColor {
if (node !== null && lightness !== 0) {
if (local_drawtype >= 30 && drawtype < 300) {
base_drawtype = Math.floor(drawtype / 10) * 10;
incr = -lightness + drawtype - base_drawtype;
let base_drawtype = Math.floor(drawtype / 10) * 10;
let incr = -lightness + drawtype - base_drawtype;
if (incr < 0) { // White
drawtype = DrawType.Color4;
} else if (incr >= 10) { // DarkGrey
......@@ -202,8 +193,8 @@ class GlowColor {
}
if (node !== null && intensity !== 0) {
if (drawtype >= 60) {
base_drawtype = Math.floor(drawtype / 30) * 30;
incr = drawtype - base_drawtype;
let base_drawtype = Math.floor(drawtype / 30) * 30;
let incr = drawtype - base_drawtype;
drawtype =
(drawtype + Math.min(2 - Math.floor(incr / 10), intensity) * 10);
if (drawtype < base_drawtype) {
......@@ -213,7 +204,7 @@ class GlowColor {
}
if (node !== null && node.getColorShift() !== 0) {
if (drawtype >= 60 && drawtype < 300) {
incr =
let incr =
node.getColorShift() - Math.floor(node.getColorShift() / 8) * 8;
if (incr < 0) {
incr += 8;
......@@ -270,34 +261,19 @@ class GlowColor {
}
static rgb_color(idx, customcolors) {
let h1, i1, s1;
let i, j, k;
let r = 0;
let g = 0;
let b = 0;
if (idx === 300) {
idx = 31;
}
if (idx === 3) { // White
r = 1.0;
g = 1.0;
b = 1.0;
return new Rgb(1, 1, 1);
} else if (idx === 2) { // Gray
r = 0.75;
g = 0.75;
b = 0.75;
return new Rgb(0.75, 0.75, 0.75);
} else if (idx === 1) { // Red
r = 1.0;
g = 0;
b = 0;
return new Rgb(1, 0, 0);
} else if (idx < 20) {
// Sixteen colors of different hue
h1 = 360.0 * (idx - 4) / 16;
s1 = 1.5;
i1 = 1;
return this.his_to_rgb(h1, i1, s1);
return this.his_to_rgb(360.0 * (idx - 4) / 16, 1, 1.5);
} else if (idx < 60) {
// Four sets of gray
let i0 = GlowColor.gray_i0;
......@@ -306,25 +282,22 @@ class GlowColor {
i0 = 0.25;
}
r = i0 + (GlowColor.gray_i1 - i0) * Math.pow((9 - idx % 10) / 9, 0.9);
g = r;
b = r;
let r = i0 + (GlowColor.gray_i1 - i0) * Math.pow((9 - idx % 10) / 9, 0.9);
return new Rgb(r, r, r);
} else if (idx < 300) {
i = Math.floor((idx - 60) / 30);
j = Math.floor((idx - 60 - i * 30) / 10);
k = 9 - (idx - 60 - i * 30 - j * 10);
let i = Math.floor((idx - 60) / 30);
let j = Math.floor((idx - 60 - i * 30) / 10);
let k = 9 - (idx - 60 - i * 30 - j * 10);
if ((i === 0 && j === 2) || (i === 2 && j === 2 && k > 5)) {
// Formula doesn't work for yellow...
r = this.rgbtab[i * 10 + k].r;
g = this.rgbtab[i * 10 + k].g;
b = this.rgbtab[i * 10 + k].b;
return new Rgb(this.rgbtab[i * 10 + k].r, this.rgbtab[i * 10 + k].g, this.rgbtab[i * 10 + k].b);
} else {
s1 = this.ctab[i].s[j].s;
i1 = this.ctab[i].s[j].i_min +
let s1 = this.ctab[i].s[j].s;
let i1 = this.ctab[i].s[j].i_min +
(this.ctab[i].s[j].i_max - this.ctab[i].s[j].i_min) *
Math.pow(k / 9, this.ctab[i].s[j].a);
h1 = this.ctab[i].h + this.ctab[i].hk * k / 9;
let h1 = this.ctab[i].h + this.ctab[i].hk * k / 9;
return this.his_to_rgb(h1, i1, s1);
}
......@@ -336,7 +309,7 @@ class GlowColor {
return customcolors.get_color(idx);
}
}
return new Rgb(r, g, b);
return new Rgb(0, 0, 0);
}
static his_to_rgb(h, i, s) {
......@@ -388,10 +361,6 @@ class GlowCustomColors {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.debug) {
console.log("GlowCustomColors : " + lines[i]);
}
switch (key) {
case GlowSave.CustomColors:
break;
......@@ -424,6 +393,7 @@ class GlowCustomColors {
break;
}
}
return i;
}
......
class GlowCon {
class GlowCon extends Rect {
static MAX_POINT = 8;
ctx: GrowCtx;
line_a: GlowArray;
......@@ -8,10 +8,6 @@ class GlowCon {
cc_name;
cc;
c_name;
x_right;
x_left;
y_high;
y_low;
dest_node;
source_node;
dest_conpoint;
......@@ -37,6 +33,7 @@ class GlowCon {
hot = 0;
constructor(ctx) {
super();
this.ctx = ctx;
this.line_a = new GlowArray(ctx);
this.arc_a = new GlowArray(ctx);
......@@ -51,10 +48,6 @@ class GlowCon {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GlowCon : " + lines[i]);
}
switch (key) {
case GlowSave.Con:
break;
......@@ -72,16 +65,16 @@ class GlowCon {
}
break;
case GlowSave.Con_x_right:
this.x_right = parseFloat(tokens[1]);
this.ur_x = parseFloat(tokens[1]);
break;
case GlowSave.Con_x_left:
this.x_left = parseFloat(tokens[1]);
this.ll_x = parseFloat(tokens[1]);
break;
case GlowSave.Con_y_high:
this.y_high = parseFloat(tokens[1]);
this.ur_y = parseFloat(tokens[1]);
break;
case GlowSave.Con_y_low:
this.y_low = parseFloat(tokens[1]);
this.ll_y = parseFloat(tokens[1]);
break;
case GlowSave.Con_dest_node:
if (tokens.length > 1) {
......@@ -187,43 +180,29 @@ class GlowCon {
break;
}
}
return i;
}
draw() {
this.tdraw(null, this.highlight, this.hot, null, null);
return i;
}
tdraw(t, highlight, hot, node, colornode) {
draw(t = null, highlight = this.highlight, hot = this.hot, node = null, colornode = null) {
if (this.ctx.nodraw !== 0) {
return;
}
let tmp;
let i;
if (this.temporary_ref !== 0 ||
this.cc.con_type === ConType.Reference) {
// ref_a.draw( w, &cc->zero, highlight, hot, NULL);
} else {
for (i = 0; i < this.l_num; i++) {
this.line_a.get(i).draw(highlight, hot);
}
for (i = 0; i < this.a_num; i++) {
this.arc_a.get(i).draw(highlight, hot);
}
let ltmp = this.line_a.slice(0, this.l_num);
let atmp = this.arc_a.slice(0, this.a_num);
ltmp.forEach(e => e.draw(highlight, hot));
atmp.forEach(e => e.draw(highlight, hot));
// arrow_a.draw( highlight, hot);
if ((this.shadow !== 0 || this.border !== 0) &&
this.cc.con_type === ConType.Routed &&
this.cc.corner === Corner.Rounded) {
for (i = 0; i < this.l_num; i++) {
this.line_a.get(i)
.draw_shadow(this.border, this.shadow, highlight, hot);
}
for (i = 0; i < this.a_num; i++) {
this.arc_a.get(i)
.draw_shadow(this.border, this.shadow, highlight, hot);
}
ltmp.forEach(e => e.draw_shadow(this.border, this.shadow, highlight, hot));
atmp.forEach(e => e.draw_shadow(this.border, this.shadow, highlight, hot));
}
}
}
......
......@@ -20,10 +20,6 @@ class GlowConClass {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GlowConClass : " + lines[i]);
}
switch (key) {
case GlowSave.ConClass:
break;
......@@ -64,6 +60,7 @@ class GlowConClass {
break;
}
}
return i;
}
}
\ No newline at end of file
......@@ -15,15 +15,10 @@ class GlowConPoint {
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GrowPolyline : " + lines[i]);
}
switch (key) {
case GlowSave.ConPoint:
break;
......@@ -54,15 +49,13 @@ class GlowConPoint {
break;
}
}
return i;
}
draw() {
}
tdraw(t, highlight, hot, node, colornode) {
}
event_handler(event, fx, fy) {
return 0;
}
......
This diff is collapsed.
......@@ -7,8 +7,8 @@ class GlowLine {
constructor(ctx) {
this.ctx = ctx;
this.p1 = new GlowPoint(ctx);
this.p2 = new GlowPoint(ctx);
this.p1 = new GlowPoint();
this.p2 = new GlowPoint();
}
open(lines, row) {
......@@ -17,10 +17,6 @@ class GlowLine {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GlowCon : " + lines[i]);
}
switch (key) {
case GlowSave.Line:
break;
......@@ -47,22 +43,18 @@ class GlowLine {
return i;
}
tdraw(t, highlight, hot, node, colornode) {
}
draw(highlight, hot) {
if (this.ctx.nodraw !== 0) {
return;
}
let p1_x, p1_y, p2_x, p2_y;
p1_x = Math.floor(this.p1.x * this.ctx.mw.zoom_factor_x + 0.5) -
let p1_x = Math.floor(this.p1.x * this.ctx.mw.zoom_factor_x + 0.5) -
this.ctx.mw.offset_x;
p1_y = Math.floor(this.p1.y * this.ctx.mw.zoom_factor_y + 0.5) -
let p1_y = Math.floor(this.p1.y * this.ctx.mw.zoom_factor_y + 0.5) -
this.ctx.mw.offset_y;
p2_x = Math.floor(this.p2.x * this.ctx.mw.zoom_factor_x + 0.5) -
let p2_x = Math.floor(this.p2.x * this.ctx.mw.zoom_factor_x + 0.5) -
this.ctx.mw.offset_x;
p2_y = Math.floor(this.p2.y * this.ctx.mw.zoom_factor_y + 0.5) -
let p2_y = Math.floor(this.p2.y * this.ctx.mw.zoom_factor_y + 0.5) -
this.ctx.mw.offset_y;
if (p1_x === p2_x && p1_y === p2_y) {
......@@ -81,14 +73,13 @@ class GlowLine {
return;
}
let p1_x, p1_y, p2_x, p2_y;
p1_x = Math.floor(this.p1.x * this.ctx.mw.zoom_factor_x + 0.5) -
let p1_x = Math.floor(this.p1.x * this.ctx.mw.zoom_factor_x + 0.5) -
this.ctx.mw.offset_x;
p1_y = Math.floor(this.p1.y * this.ctx.mw.zoom_factor_y + 0.5) -
let p1_y = Math.floor(this.p1.y * this.ctx.mw.zoom_factor_y + 0.5) -
this.ctx.mw.offset_y;
p2_x = Math.floor(this.p2.x * this.ctx.mw.zoom_factor_x + 0.5) -
let p2_x = Math.floor(this.p2.x * this.ctx.mw.zoom_factor_x + 0.5) -
this.ctx.mw.offset_x;
p2_y = Math.floor(this.p2.y * this.ctx.mw.zoom_factor_y + 0.5) -
let p2_y = Math.floor(this.p2.y * this.ctx.mw.zoom_factor_y + 0.5) -
this.ctx.mw.offset_y;
if (p1_x === p2_x && p1_y === p2_y) {
......
class GlowNode extends Rect {
static MAX_CONPOINTS = 32;
ctx: GrowCtx;
hot = 0;
nc = null;
nc_root = null;
pos: GlowPoint;
highlight = 0;
annotsize = new Array(10);
annotv = new Array(10);
nc_name = null;
n_name = null;
access = 0;
cycle = 0;
ref_object = null;
constructor(ctx) {
super();
this.ctx = ctx;
this.pos = new GlowPoint();
for (let i = 0; i < 10; i++) {
this.annotv[i] = null;
}
}
open(lines, row) {
let i, j;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
switch (key) {
case GlowSave.Node:
break;
case GlowSave.Node_nc:
this.nc_name = tokens[1];
if (!(this instanceof GrowGroup)) {
this.nc = this.ctx.get_nodeclass_from_name(this.nc_name);
this.nc_root = this.nc;
if (this.nc === null) {
console.log("GlowNode : ", lines[i], ", node class not found: ",
this.nc_name);
}
}
break;
case GlowSave.Node_n_name:
if (tokens.length > 1) {
this.n_name = tokens[1];
}
break;
case GlowSave.Node_refcon_cnt:
i += GlowNode.MAX_CONPOINTS;
break;
case GlowSave.Node_x_right:
this.ur_x = parseFloat(tokens[1]);
break;
case GlowSave.Node_x_left:
this.ll_x = parseFloat(tokens[1]);
break;
case GlowSave.Node_y_high:
this.ur_y = parseFloat(tokens[1]);
break;
case GlowSave.Node_y_low:
this.ll_y = parseFloat(tokens[1]);
break;
case GlowSave.Node_obst_x_right:
case GlowSave.Node_obst_x_left:
case GlowSave.Node_obst_y_high:
case GlowSave.Node_obst_y_low:
break;
case GlowSave.Node_annotsize:
for (j = 0; j < 10; j++) {
i++;
this.annotsize[j] = parseInt(lines[i], 10);
}
break;
case GlowSave.Node_annotv:
for (j = 0; j < 10; j++) {
if (this.annotsize[j] !== 0) {
i++;
this.annotv[j] = lines[i].substring(1, lines[i].length - 1);
}
}
break;
case GlowSave.Node_pos:
i = this.pos.open(lines, i + 1);
break;
case GlowSave.Node_trace_data1:
case GlowSave.Node_trace_data2:
case GlowSave.Node_trace_data3:
case GlowSave.Node_trace_data4:
case GlowSave.Node_trace_data5:
case GlowSave.Node_trace_data6:
case GlowSave.Node_trace_data7:
case GlowSave.Node_trace_data8:
case GlowSave.Node_trace_data9:
case GlowSave.Node_trace_data10:
case GlowSave.Node_trace_attr_type:
case GlowSave.Node_trace_color:
case GlowSave.Node_trace_color2:
break;
case GlowSave.Node_access:
this.access = parseInt(tokens[1], 10); // TODO, Can be unsigned
break;
case GlowSave.Node_cycle:
this.cycle = parseInt(tokens[1], 10);
break;
case GlowSave.Node_ref_object:
if (tokens.length > 1) {
this.ref_object = tokens[1];
}
break;
case GlowSave.End:
return i;
default:
console.log("Syntax error in GlowNode");
break;
}
}
return i;
}
}
\ No newline at end of file
......@@ -36,10 +36,6 @@ class GlowNodeClass {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GlowNodeClass : " + lines[i]);
}
switch (key) {
case GlowSave.NodeClass:
break;
......@@ -179,6 +175,7 @@ class GlowNodeClass {
this.next_nc.prev_nc = this;
}
}
return i;
}
......@@ -192,10 +189,8 @@ class GlowNodeClass {
return 0;
}
tdraw(t, highlight, hot, node, colornode) {
for (let i = 0; i < this.a.size(); i++) {
this.a.get(i).tdraw(t, highlight, hot, node, colornode);
}
draw(t = null, highlight = 0, hot = 0, node = null, colornode = null) {
this.a.forEach(e => e.draw(t, highlight, hot, node, colornode));
}
get_borders(t, g) {
......@@ -208,7 +203,7 @@ class GlowNodeClass {
Math.abs(base.y0 - base.y1) < Number.MIN_VALUE)) {
// Borders are given i x0, y0, x1, y1
// Will not work in rotated nodes
let ll_x, ur_x, ll_y, ur_y, kx1, kx2, ky1, ky2;
let kx1, kx2, ky1, ky2;
if (t === null) {
kx1 = base.x0;
......@@ -222,27 +217,9 @@ class GlowNodeClass {
ky2 = t.y(base.x1, base.y1);
}
ll_x = Math.min(kx1, kx2);
ur_x = Math.max(kx1, kx2);
ll_y = Math.min(ky1, ky2);
ur_y = Math.max(ky1, ky2);
if (ll_x < g.ll_x) {
g.ll_x = ll_x;
}
if (ur_x > g.ur_x) {
g.ur_x = ur_x;
}
if (ll_y < g.ll_y) {
g.ll_y = ll_y;
}
if (ur_y > g.ur_y) {
g.ur_y = ur_y;
}
g.set(Rect.union(g, new Rect(Math.min(kx1, kx2), Math.min(ky1, ky2), Math.max(kx1, kx2), Math.max(ky1, ky2))));
} else {
for (let i = 0; i < this.a.size(); i++) {
this.a.get(i).get_borders(t, g);
}
this.a.forEach(e => e.get_borders(t, g));
}
}
......@@ -257,10 +234,10 @@ class GlowNodeClass {
for (let i = 0; i < this.a.size(); i++) {
if (this.a.get(i) instanceof GrowAnnot &&
this.a.get(i).getNumber() === num) {
let d = this.a.get(i).getTextExtent(t, node);
d.width /= this.ctx.mw.zoom_factor_x;
d.height /= this.ctx.mw.zoom_factor_y;
return d;
let p = this.a.get(i).getTextExtent(t, node);
p.x /= this.ctx.mw.zoom_factor_x;
p.y /= this.ctx.mw.zoom_factor_y;
return p;
}
}
return null;
......
......@@ -9,10 +9,6 @@ class GlowNodeGroup extends GlowNodeClass {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GlowNodeClass : " + lines[i]);
}
switch (key) {
case GlowSave.NodeGroup:
break;
......@@ -26,6 +22,7 @@ class GlowNodeGroup extends GlowNodeClass {
break;
}
}
return i;
}
}
\ No newline at end of file
class GlowPoint {
x = 0.0;
y = 0.0;
class GlowPoint extends Point {
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
......@@ -24,6 +21,7 @@ class GlowPoint {
break;
}
}
return i;
}
......
class GlowPolyline {
ctx: GrowCtx;
a_points: GlowArray;
points = [];
draw_type = 0;
line_width = 0;
fill = 0;
closed_line = 0;
constructor(ctx) {
this.ctx = ctx;
this.a_points = new GlowArray(ctx);
}
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
switch (key) {
case GlowSave.PolyLine:
break;
case GlowSave.PolyLine_draw_type:
this.draw_type = parseInt(tokens[1], 10);
break;
case GlowSave.PolyLine_line_width:
this.line_width = parseInt(tokens[1], 10);
break;
case GlowSave.PolyLine_fill:
this.fill = parseInt(tokens[1], 10);
break;
case GlowSave.PolyLine_closed_line:
this.closed_line = parseInt(tokens[1], 10);
break;
case GlowSave.PolyLine_a_points:
i = this.a_points.open(lines, i + 1);
break;
case GlowSave.End:
return i;
default:
console.log("Syntax error in GlowPolyline");
break;
}
}
return i;
}
}
\ No newline at end of file
......@@ -19,10 +19,6 @@ class GlowRect {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GlowCon : " + lines[i]);
}
switch (key) {
case GlowSave.Rect:
break;
......
......@@ -9,7 +9,7 @@ class GlowText {
constructor(ctx) {
this.ctx = ctx;
this.p = new GlowPoint(ctx);
this.p = new GlowPoint();
}
open(lines, row) {
......@@ -18,10 +18,6 @@ class GlowText {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GlowCon : " + lines[i]);
}
switch (key) {
case GlowSave.Text:
break;
......@@ -47,6 +43,7 @@ class GlowText {
break;
}
}
return i;
}
......
......@@ -6,23 +6,21 @@ class GlowTransform {
a22 = 1;
a23 = 0;
rotation = 0;
s_a11 = 1;
s_a12 = 0;
s_a13 = 0;
s_a21 = 0;
s_a22 = 1;
s_a23 = 0;
s_rotation = 0;
s: GlowTransform;
stored = false;
set(o: GlowTransform) {
this.a11 = o.a11;
this.a12 = o.a12;
this.a13 = o.a13;
this.a21 = o.a21;
this.a22 = o.a22;
this.a23 = o.a23;
this.rotation = o.rotation;
}
store() {
this.s_a11 = this.a11;
this.s_a12 = this.a12;
this.s_a13 = this.a13;
this.s_a21 = this.a21;
this.s_a22 = this.a22;
this.s_a23 = this.a23;
this.s_rotation = this.rotation;
this.s.set(this);
this.stored = true;
}
......@@ -63,75 +61,70 @@ class GlowTransform {
break;
}
}
return i;
}
rot() {
if (arguments.length === 0) {
return this.rotation;
}
if (arguments.length === 1) {
if (arguments.length === 1 && arguments[0] !== null) {
let t = arguments[0];
return t.rotation + this.rotation;
} else {
return this.rotation;
}
}
x() {
let t, x1, y1;
if (arguments.length === 2) {
x1 = arguments[0];
y1 = arguments[1];
return x1 * this.a11 + y1 * this.a12 + this.a13;
}
if (arguments.length === 3) {
t = arguments[0];
x1 = arguments[1];
y1 = arguments[2];
let tmp = t.multiply(this);
if (arguments.length === 3 && arguments[0] !== null) {
let t = arguments[0];
let x1 = arguments[1];
let y1 = arguments[2];
return tmp.x(x1, y1);
let tmp = GlowTransform.multiply(t, this);
return x1 * tmp.a11 + y1 * tmp.a12 + tmp.a13;
} else {
let x1 = arguments[0];
let y1 = arguments[1];
return x1 * this.a11 + y1 * this.a12 + this.a13;
}
}
y() {
let t, x1, y1;
if (arguments.length === 2) {
x1 = arguments[0];
y1 = arguments[1];
return x1 * this.a21 + y1 * this.a22 + this.a23;
}
if (arguments.length === 3) {
t = arguments[0];
x1 = arguments[1];
y1 = arguments[2];
let tmp = t.multiply(this);
if (arguments.length === 3 && arguments[0] !== null) {
let t = arguments[0];
let x1 = arguments[1];
let y1 = arguments[2];
return tmp.y(x1, y1);
let tmp = GlowTransform.multiply(t, this);
return x1 * tmp.a21 + y1 * tmp.a22 + tmp.a23;
} else {
let x1 = arguments[0];
let y1 = arguments[1];
return x1 * this.a21 + y1 * this.a22 + this.a23;
}
}
multiply(p) {
static multiply(a, b) {
let tmp = new GlowTransform();
tmp.a11 = this.a11 * p.a11 + this.a12 * p.a21;
tmp.a12 = this.a11 * p.a12 + this.a12 * p.a22;
tmp.a13 = this.a11 * p.a13 + this.a12 * p.a23 + this.a13;
tmp.a21 = this.a21 * p.a11 + this.a22 * p.a21;
tmp.a22 = this.a21 * p.a12 + this.a22 * p.a22;
tmp.a23 = this.a21 * p.a13 + this.a22 * p.a23 + this.a23;
tmp.rotation = this.rotation + p.rotation;
tmp.a11 = a.a11 * b.a11 + a.a12 * b.a21;
tmp.a12 = a.a11 * b.a12 + a.a12 * b.a22;
tmp.a13 = a.a11 * b.a13 + a.a12 * b.a23 + a.a13;
tmp.a21 = a.a21 * b.a11 + a.a22 * b.a21;
tmp.a22 = a.a21 * b.a12 + a.a22 * b.a22;
tmp.a23 = a.a21 * b.a13 + a.a22 * b.a23 + a.a23;
tmp.rotation = a.rotation + b.rotation;
return tmp;
}
set_from_stored(t) {
this.a11 = t.a11 * this.s_a11 + t.a12 * this.s_a21;
this.a12 = t.a11 * this.s_a12 + t.a12 * this.s_a22;
this.a13 = t.a11 * this.s_a13 + t.a12 * this.s_a23 + t.a13;
this.a21 = t.a21 * this.s_a11 + t.a22 * this.s_a21;
this.a22 = t.a21 * this.s_a12 + t.a22 * this.s_a22;
this.a23 = t.a21 * this.s_a13 + t.a22 * this.s_a23 + t.a23;
this.rotation = this.s_rotation + t.rotation;
this.set(GlowTransform.multiply(t, this.s));
this.a11 = t.a11 * this.s.a11 + t.a12 * this.s.a21;
this.a12 = t.a11 * this.s.a12 + t.a12 * this.s.a22;
this.a13 = t.a11 * this.s.a13 + t.a12 * this.s.a23 + t.a13;
this.a21 = t.a21 * this.s.a11 + t.a22 * this.s.a21;
this.a22 = t.a21 * this.s.a12 + t.a22 * this.s.a22;
this.a23 = t.a21 * this.s.a13 + t.a22 * this.s.a23 + t.a23;
this.rotation = this.s.rotation + t.rotation;
}
scale(sx, sy, x0, y0) {
......@@ -144,12 +137,12 @@ class GlowTransform {
}
scale_from_stored(sx, sy, x0, y0) {
this.a13 = this.s_a13 * sx + x0 * (1 - sx);
this.a23 = this.s_a23 * sy + y0 * (1 - sy);
this.a11 = this.s_a11 * sx;
this.a12 = this.s_a12 * sx;
this.a21 = this.s_a21 * sy;
this.a22 = this.s_a22 * sy;
this.a13 = this.s.a13 * sx + x0 * (1 - sx);
this.a23 = this.s.a23 * sy + y0 * (1 - sy);
this.a11 = this.s.a11 * sx;
this.a12 = this.s.a12 * sx;
this.a21 = this.s.a21 * sy;
this.a22 = this.s.a22 * sy;
}
rotate(angle, x0, y0) {
......@@ -186,23 +179,23 @@ class GlowTransform {
rotate_from_stored(angle, x0, y0) {
let sin_a;
let cos_a;
if (-90.01 < this.s_rotation + angle && this.s_rotation + angle < -89.99) {
if (-90.01 < this.s.rotation + angle && this.s.rotation + angle < -89.99) {
sin_a = -1.0;
cos_a = 0.0;
} else {
sin_a = Math.sin((this.s_rotation + angle) / 180 * 3.14159);
cos_a = Math.cos((this.s_rotation + angle) / 180 * 3.14159);
sin_a = Math.sin((this.s.rotation + angle) / 180 * 3.14159);
cos_a = Math.cos((this.s.rotation + angle) / 180 * 3.14159);
}
this.a11 = this.s_a11 * cos_a - this.s_a21 * sin_a;
this.a12 = this.s_a12 * cos_a - this.s_a22 * sin_a;
this.a11 = this.s.a11 * cos_a - this.s.a21 * sin_a;
this.a12 = this.s.a12 * cos_a - this.s.a22 * sin_a;
this.a13 =
this.s_a13 * cos_a - this.s_a23 * sin_a + x0 * (1 - cos_a) + y0 * sin_a;
this.a21 = this.s_a11 * sin_a + this.s_a21 * cos_a;
this.a22 = this.s_a21 * sin_a + this.s_a22 * cos_a;
this.s.a13 * cos_a - this.s.a23 * sin_a + x0 * (1 - cos_a) + y0 * sin_a;
this.a21 = this.s.a11 * sin_a + this.s.a21 * cos_a;
this.a22 = this.s.a21 * sin_a + this.s.a22 * cos_a;
this.a23 =
this.s_a13 * sin_a + this.s_a23 * cos_a + y0 * (1 - cos_a) - x0 * sin_a;
this.rotation = this.s_rotation + angle;
this.s.a13 * sin_a + this.s.a23 * cos_a + y0 * (1 - cos_a) - x0 * sin_a;
this.rotation = this.s.rotation + angle;
}
move(x0, y0) {
......@@ -211,8 +204,8 @@ class GlowTransform {
}
move_from_stored(x0, y0) {
this.a13 = this.s_a13 + x0;
this.a23 = this.s_a23 + y0;
this.a13 = this.s.a13 + x0;
this.a23 = this.s.a23 + y0;
}
posit(x0, y0) {
......@@ -245,7 +238,7 @@ class GlowTransform {
return Math.sqrt(this.a12 * this.a12 + this.a22 * this.a22);
}
let tmp = t.multiply(this);
let tmp = GlowTransform.multiply(t, this);
return Math.sqrt(tmp.a12 * tmp.a12 + tmp.a22 * tmp.a22);
}
......
class GrowAnnot {
ctx: GrowCtx;
p: GlowPoint;
class GrowAnnot extends GlowAnnot {
trf: GlowTransform;
adjustment;
number;
draw_type;
color_drawtype;
text_size;
display_level;
annot_type;
font;
protect;
constructor(ctx) {
this.ctx = ctx;
this.p = new GlowPoint();
super(ctx);
this.trf = new GlowTransform();
}
......@@ -24,15 +13,10 @@ class GrowAnnot {
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GrowArc : " + lines[i]);
}
switch (key) {
case GlowSave.GrowAnnot:
break;
......@@ -40,7 +24,7 @@ class GrowAnnot {
this.adjustment = parseInt(tokens[1], 10);
break;
case GlowSave.GrowAnnot_annot_part:
i = this.glowannot_open(lines, i + 1);
i = super.open(lines, i + 1);
break;
case GlowSave.GrowAnnot_trf:
i = this.trf.open(lines, i + 1);
......@@ -56,64 +40,7 @@ class GrowAnnot {
return i;
}
glowannot_open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GrowArc : " + lines[i]);
}
switch (key) {
case GlowSave.Annot:
break;
case GlowSave.Annot_number:
this.number = parseInt(tokens[1], 10);
break;
case GlowSave.Annot_draw_type:
this.draw_type = parseInt(tokens[1], 10);
break;
case GlowSave.Annot_color_drawtype:
this.color_drawtype = parseInt(tokens[1], 10);
break;
case GlowSave.Annot_text_size:
this.text_size = parseInt(tokens[1], 10);
break;
case GlowSave.Annot_display_level:
this.display_level = parseInt(tokens[1], 10);
break;
case GlowSave.Annot_p:
i = this.p.open(lines, i + 1);
break;
case GlowSave.Annot_annot_type:
this.annot_type = parseInt(tokens[1], 10);
break;
case GlowSave.Annot_font:
this.font = parseInt(tokens[1], 10);
break;
case GlowSave.Annot_protect:
this.protect = parseInt(tokens[1], 10);
break;
case GlowSave.End:
return i;
default:
console.log("Syntax error in GlowAnnot");
break;
}
}
return i;
}
draw() {
this.tdraw(null, 0, 0, null, null);
}
tdraw(t, highlight, hot, node, colornode) {
let x1, y1;
draw(t = null, highlight = 0, hot = 0, node = null, colornode = null) {
if (this.ctx.nodraw !== 0) {
return;
}
......@@ -122,10 +49,6 @@ class GrowAnnot {
return;
}
let color;
let rot;
let offset_x = 0;
let offset_y = 0;
let trf_scale = this.trf.vertical_scale(t);
let idx = Math.floor(trf_scale * this.ctx.mw.zoom_factor_y /
this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 3);
......@@ -136,14 +59,14 @@ class GrowAnnot {
}
idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let lfont;
let ldraw_type;
let offset_x = 0;
let offset_y = 0;
if (node !== null && node.annot_scrollingtext === this.number) {
offset_x = node.annot_offset_x;
offset_y = node.annot_offset_y;
}
let lfont, ldraw_type;
if (node !== null && node.text_font !== Font.No) {
lfont = node.text_font;
ldraw_type = node.text_type;
......@@ -152,19 +75,11 @@ class GrowAnnot {
ldraw_type = this.draw_type;
}
if (t === null) {
x1 = Math.floor((this.trf.x(this.p.x, this.p.y) + offset_x) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
y1 = Math.floor((this.trf.y(this.p.x, this.p.y) + offset_y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
rot = Math.floor(this.trf.rot());
} else {
x1 = Math.floor((this.trf.x(t, this.p.x, this.p.y) + offset_x) *
let x1 = Math.floor((this.trf.x(t, this.p.x, this.p.y) + offset_x) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
y1 = Math.floor((this.trf.y(t, this.p.x, this.p.y) + offset_y) *
let y1 = Math.floor((this.trf.y(t, this.p.x, this.p.y) + offset_y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
rot = Math.floor(this.trf.rot(t));
}
let rot = Math.floor(this.trf.rot(t));
rot = rot < 0 ? rot % 360 + 360 : rot % 360;
switch (this.annot_type) {
......@@ -173,7 +88,7 @@ class GrowAnnot {
let height = 0;
let descent = 0;
color = GlowColor.get_drawtype(this.color_drawtype,
let color = GlowColor.get_drawtype(this.color_drawtype,
DrawType.LineHighlight, highlight, colornode, 2, 0);
if (((rot < 45 || rot >= 315) &&
......@@ -181,23 +96,16 @@ class GrowAnnot {
0)) || (!(rot < 45 || rot >= 315)) ||
this.adjustment === Adjustment.Right ||
this.adjustment === Adjustment.Center) {
let d = this.getTextExtent(t, node);
width = d.width;
height = d.height;
let p = this.getTextExtent(t, node);
width = p.x;
height = p.y;
descent = height / 4;
}
switch (this.adjustment) {
case Adjustment.Left:
break;
case Adjustment.Right:
if (this.adjustment == Adjustment.Right) {
x1 -= width;
break;
case Adjustment.Center:
} else if (this.adjustment == Adjustment.Center) {
x1 -= width / 2;
break;
default:
break;
}
if (rot < 45 || rot >= 315) {
......@@ -210,21 +118,21 @@ class GrowAnnot {
// Text is rotated, adjust the coordinates
if (this.adjustment === Adjustment.Center) {
// Only center adjustment supports text rotation
if (45 <= rot && rot < 135) {
if (rot >= 45 && rot < 135) {
x1 += width / 2;
y1 += width / 2;
} else if (135 <= rot && rot < 225) {
} else if (rot >= 135 && rot < 225) {
y1 += height - descent;
} else if (225 <= rot && rot < 315) {
} else if (rot >= 225 && rot < 315) {
x1 += width / 2 - height + descent;
y1 -= width / 2 - height + descent;
} else {
x1 -= width;
}
} else {
if (45 <= rot && rot < 135) {
if (rot >= 45 && rot < 135) {
y1 += height - descent;
} else if (135 <= rot && rot < 225) {
} else if (rot >= 135 && rot < 225) {
x1 -= width;
y1 += height - descent;
} else {
......@@ -244,34 +152,23 @@ class GrowAnnot {
}
}
getTextExtent(t, node) {
let dim = new Rect();
getTextExtent(t, node): Point {
if (node.annotv[this.number] === null || node.annotv[this.number] === "") {
dim.width = 0;
dim.height = 0;
return dim;
return new Point();
}
let z_width, z_height, descent;
let trf_scale = this.trf.vertical_scale(t);
let idx = Math.floor(trf_scale * this.ctx.mw.zoom_factor_y /
this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 4);
let tsize = trf_scale * this.ctx.mw.zoom_factor_y /
this.ctx.mw.base_zoom_factor * (8 + 2 * this.text_size);
if (idx < 0) {
dim.width = 0;
dim.height = 0;
return dim;
return new Point();
}
idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let d = this.ctx.gdraw.getTextExtent(node.annotv[this.number], idx,
return this.ctx.gdraw.getTextExtent(node.annotv[this.number], idx,
this.font, this.draw_type);
dim.width = d.width;
dim.height = d.height;
return dim;
}
event_handler(event, fx, fy) {
......
This diff is collapsed.
This diff is collapsed.
......@@ -33,15 +33,10 @@ class GrowAxisArc extends GrowArc {
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GrowAxisArc : " + lines[i]);
}
switch (key) {
case GlowSave.GrowAxisArc:
break;
......@@ -108,27 +103,22 @@ class GrowAxisArc extends GrowArc {
return i;
}
tdraw(t, highlight, hot, node, colornode) {
draw(t = null, highlight = 0, hot = 0, node = null, colornode = null) {
if (this.ctx.nodraw !== 0) {
return;
}
let i;
let draw_text = (Math.abs(this.increment) > Number.MIN_VALUE);
let idx;
let x, y;
let text;
let line_length;
let x_text, y_text;
let x_text;
let z_height = 0, z_width, z_descent = 0;
let max_z_width = 0;
let rotation;
let drawtype;
let text_idx = Math.floor(this.ctx.mw.zoom_factor_y /
this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 4);
let tsize = this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor *
(8 + 2 * this.text_size);
text_idx = Math.min(text_idx, DRAW_TYPE_SIZE - 1);
let idx;
if (node !== null && node.line_width !== 0) {
idx =
Math.floor(this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor *
......@@ -142,37 +132,23 @@ class GrowAxisArc extends GrowArc {
idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1, y1, x2, y2, ll_x, ll_y, ur_x, ur_y, xt, yt;
if (t === null) {
x1 = Math.floor(this.trf.x(this.ll.x, this.ll.y) *
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
y1 = Math.floor(this.trf.y(this.ll.x, this.ll.y) *
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
x2 = Math.floor(this.trf.x(this.ur.x, this.ur.y) *
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
y2 = Math.floor(this.trf.y(this.ur.x, this.ur.y) *
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
rotation =
(this.trf.rot() / 360 - Math.floor(this.trf.rot() / 360)) * 360;
} else {
x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
rotation =
let rotation =
(this.trf.rot(t) / 360 - Math.floor(this.trf.rot(t) / 360)) * 360;
}
ll_x = Math.min(x1, x2);
ur_x = Math.max(x1, x2);
ll_y = Math.min(y1, y2);
ur_y = Math.max(y1, y2);
drawtype =
let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2);
let ll_y = Math.min(y1, y2);
let ur_y = Math.max(y1, y2);
let drawtype =
GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight,
highlight, colornode, 0, 0);
......@@ -185,23 +161,24 @@ class GrowAxisArc extends GrowArc {
return;
}
let text;
if (this.increment > 0) {
text = this.format_text(this.format, this.min_value + (this.lines - 2) *
this.increment);
} else {
text = this.format_text(this.format, this.min_value + this.increment);
}
let d = this.ctx.gdraw.getTextExtent(text, Math.max(0, text_idx),
let p = this.ctx.gdraw.getTextExtent(text, Math.max(0, text_idx),
Font.Helvetica, this.text_drawtype);
z_width = d.width;
z_height = d.height;
z_width = p.x;
z_height = p.y;
z_descent = z_height / 4;
if (max_z_width < z_width) {
max_z_width = z_width;
}
let line_angle = this.angle2 / (this.lines - 1);
for (i = 0; i < this.lines; i++) {
for (let i = 0; i < this.lines; i++) {
let sin1 = Math.sin((this.angle1 + i * line_angle) / 180 * Math.PI);
let cos1 = Math.cos((this.angle1 + i * line_angle) / 180 * Math.PI);
y1 = Math.floor((ur_y - ll_y) / 2 * (-sin1 + 1) + ll_y);
......@@ -217,10 +194,10 @@ class GrowAxisArc extends GrowArc {
x2 = Math.floor((ur_x - ll_x) / 2 *
(cos1 * (1.0 - this.linelength / 2) + 1) + ll_x);
}
yt =
let yt =
Math.floor((ur_y - ll_y) / 2 * (-sin1 * (1.0 - this.linelength) + 1) +
ll_y + sin1 * (z_height - z_descent) / 2);
xt =
let xt =
Math.floor((ur_x - ll_x) / 2 * (cos1 * (1.0 - this.linelength) + 1) +
ll_x - cos1 * z_width / 2);
......@@ -232,10 +209,10 @@ class GrowAxisArc extends GrowArc {
(this.increment < 0 && i === 0)))) {
text = this.format_text(this.format, this.min_value + i *
this.increment);
d = this.ctx.gdraw.getTextExtent(text, Math.max(0, text_idx),
p = this.ctx.gdraw.getTextExtent(text, Math.max(0, text_idx),
Font.Helvetica, this.text_drawtype);
z_width = d.width;
z_height = d.height;
z_width = p.x;
z_height = p.y;
z_descent = z_height / 4;
if (max_z_width < z_width) {
max_z_width = z_width;
......@@ -243,12 +220,12 @@ class GrowAxisArc extends GrowArc {
if (i === this.lines - 1 && this.angle1 === 0 &&
this.angle2 === 180) {
xt = xt - z_width / 2;
xt -= z_width / 2;
} else if (i === 0 && this.angle1 === 0 && this.angle2 !== 360) {
xt = xt - z_width / 2;
xt -= z_width / 2;
} else {
yt = yt + (z_height - z_descent) / 2;
xt = xt - z_width / 2;
yt += (z_height - z_descent) / 2;
xt -= z_width / 2;
}
this.ctx.gdraw.text(xt, yt, text, this.text_drawtype,
this.text_color_drawtype, text_idx, highlight, 0,
......@@ -286,29 +263,18 @@ class GrowAxisArc extends GrowArc {
360;
if (keep_settings === 0) {
let len;
let lix;
let di;
let horizontal = (rotation < 45 || (rotation > 135 && rotation < 225) ||
rotation > 315) ? 0 : 1;
if (horizontal === 0) {
len = Math.abs(y2 - y1);
} else {
len = Math.abs(x2 - x1);
}
let len = (horizontal === 0) ? Math.abs(y2 - y1) : Math.abs(x2 - x1);
if (len < 150) {
lix = 0;
} else {
lix = 1;
}
let lix = Number(!(len < 150));
let d = Math.abs(maxval - minval);
if (d < 5) {
d = 1000 * d;
}
di = Math.floor(d + 0.5);
let di = Math.floor(d + 0.5);
while (di >= 25) {
di /= 10;
}
......@@ -324,36 +290,13 @@ class GrowAxisArc extends GrowArc {
}
let m = Math.max(Math.abs(maxval), Math.abs(minval));
switch (lix) {
case 0:
if (m < 0.01) {
this.format = "%g";
} else if (m < 0.1) {
this.format = "%5.3f";
} else if (m < 1) {
this.format = "%4.2f";
} else if (m < 3) {
this.format = "%3.1f";
} else if (m <= 20) {
this.format = "%2.0f";
} else if (m <= 200) {
this.format = "%3.0f";
} else if (m < 2000) {
this.format = "%4.0f";
} else if (m < 20000) {
this.format = "%5.0f";
} else {
this.format = "%g";
}
break;
case 1:
if (m < 0.01) {
this.format = "%g";
} else if (m < 0.1) {
this.format = "%5.3f";
} else if (m < 1) {
this.format = "%4.2f";
} else if (m <= 4) {
} else if ((lix === 0 && m < 3) || (lix === 1 && m <= 4)) {
this.format = "%3.1f";
} else if (m <= 20) {
this.format = "%2.0f";
......@@ -366,10 +309,6 @@ class GrowAxisArc extends GrowArc {
} else {
this.format = "%g";
}
break;
default:
break;
}
}
this.configure();
this.draw();
......
......@@ -13,15 +13,10 @@ class GrowBar extends GrowRect {
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GrowBar : " + lines[i]);
}
switch (key) {
case GlowSave.GrowBar:
break;
......@@ -77,17 +72,15 @@ class GrowBar extends GrowRect {
break;
}
}
return i;
}
tdraw(t, highlight, hot, node, colornode) {
draw(t = null, highlight = 0, hot = 0, node = null, colornode = null) {
if (this.ctx.nodraw !== 0) {
return;
}
let idx;
let drawtype;
let rotation;
let grad = this.gradient;
if (this.gradient === Gradient.No &&
(node !== null && node.gradient !== Gradient.No) &&
......@@ -100,6 +93,7 @@ class GrowBar extends GrowRect {
bar_border_idx =
Math.min(DRAW_TYPE_SIZE - 1, Math.max(0, bar_border_idx));
let idx;
if (node !== null && node.line_width !== 0) {
idx =
Math.floor(this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor *
......@@ -113,34 +107,22 @@ class GrowBar extends GrowRect {
idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1, y1, x2, y2, ll_x, ll_y, ur_x, ur_y;
if (t === null) {
x1 = Math.floor(this.trf.x(this.ll.x, this.ll.y) *
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
y1 = Math.floor(this.trf.y(this.ll.x, this.ll.y) *
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
x2 = Math.floor(this.trf.x(this.ur.x, this.ur.y) *
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
y2 = Math.floor(this.trf.y(this.ur.x, this.ur.y) *
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
} else {
x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
}
ll_x = Math.min(x1, x2);
ur_x = Math.max(x1, x2);
ll_y = Math.min(y1, y2);
ur_y = Math.max(y1, y2);
let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2);
let ll_y = Math.min(y1, y2);
let ur_y = Math.max(y1, y2);
if (this.fill !== 0) {
drawtype =
let drawtype =
GlowColor.get_drawtype(this.fill_drawtype, DrawType.FillHighlight,
highlight, colornode, 1, 0);
......@@ -148,13 +130,9 @@ class GrowBar extends GrowRect {
this.ctx.gdraw.fill_rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y,
drawtype);
} else {
let fa1, fa2;
let rotation = (t) ? this.trf.rot(t) : this.trf.rot();
if (t === null) {
rotation = this.trf.rot();
} else {
rotation = this.trf.rot(t);
}
let fa1, fa2;
if (this.gradient_contrast >= 0) {
fa2 = GlowColor.shift_drawtype(drawtype, -this.gradient_contrast / 2,
null);
......@@ -170,64 +148,49 @@ class GrowBar extends GrowRect {
drawtype, fa1, fa2, this.ctx.gdraw.gradient_rotate(rotation, grad));
}
}
drawtype =
let drawtype =
GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight,
highlight, colornode, 0, 0);
if (this.max_value !== this.min_value) {
let x0, y0, width, height, l_x0, l_y0, l_x1, l_y1;
if (t === null) {
rotation =
(this.trf.rot() / 360 - Math.floor(this.trf.rot() / 360)) * 360;
} else {
rotation =
(this.trf.rot(t) / 360 - Math.floor(this.trf.rot(t) / 360)) * 360;
}
if (45 >= rotation || rotation > 315) {
let rotation = (t) ? this.trf.rot(t) : this.trf.rot();
rotation = (rotation / 360 - Math.floor(rotation / 360)) * 360;
x0 = ll_x;
y0 = ll_y;
width = ur_x - ll_x;
height = ur_y - ll_y;
l_x0 = ll_x;
l_y0 = ll_y;
l_x1 = ur_x;
l_y1 = ur_y;
if (rotation <= 45 || rotation > 315) {
height = Math.floor((this.bar_value - this.min_value) /
(this.max_value - this.min_value) * (ur_y - ll_y));
height = Math.max(0, Math.min(height, ur_y - ll_y));
width = ur_x - ll_x;
x0 = ll_x;
y0 = ur_y - height;
l_x0 = ll_x;
l_y0 = ur_y - height;
l_x1 = ur_x;
l_y1 = ur_y - height;
} else if (45 < rotation && rotation <= 135) {
} else if (rotation > 45 && rotation <= 135) {
width = Math.floor((this.bar_value - this.min_value) /
(this.max_value - this.min_value) * (ur_x - ll_x));
width = Math.max(0, Math.min(width, ur_x - ll_x));
height = ur_y - ll_y;
x0 = ll_x;
y0 = ll_y;
l_x0 = ll_x + width;
l_y0 = ll_y;
l_x1 = ll_x + width;
l_y1 = ur_y;
} else if (135 < rotation && rotation <= 225) {
} else if (rotation > 135 && rotation <= 225) {
height = Math.floor((this.bar_value - this.min_value) /
(this.max_value - this.min_value) * (ur_y - ll_y));
height = Math.max(0, Math.min(height, ur_y - ll_y));
width = ur_x - ll_x;
x0 = ll_x;
y0 = ll_y;
l_x0 = ll_x;
l_y0 = ll_y + height;
l_x1 = ur_x;
l_y1 = ll_y + height;
} else { // if ( 225 < rotation && rotation <= 315)
width = Math.floor((this.bar_value - this.min_value) /
(this.max_value - this.min_value) * (ur_x - ll_x));
width = Math.max(0, Math.min(width, ur_x - ll_x));
height = ur_y - ll_y;
x0 = ur_x - width;
y0 = ll_y;
l_x0 = ur_x - width;
l_y0 = ll_y;
l_x1 = ur_x - width;
l_y1 = ur_y;
}
let dt = drawtype;
......@@ -238,13 +201,9 @@ class GrowBar extends GrowRect {
if (grad === Gradient.No) {
this.ctx.gdraw.fill_rect(x0, y0, width, height, dt);
} else {
let fb1, fb2;
rotation = (t) ? this.trf.rot(t) : this.trf.rot();
if (t === null) {
rotation = this.trf.rot();
} else {
rotation = this.trf.rot(t);
}
let fb1, fb2;
if (this.gradient_contrast >= 0) {
fb2 = GlowColor.shift_drawtype(dt, -this.gradient_contrast / 2, null);
fb1 = GlowColor.shift_drawtype(dt,
......
......@@ -15,15 +15,10 @@ class GrowBarArc extends GrowArc {
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GrowBarArc : " + lines[i]);
}
switch (key) {
case GlowSave.GrowBarArc:
break;
......@@ -69,24 +64,20 @@ class GrowBarArc extends GrowArc {
break;
}
}
return i;
}
tdraw(t, highlight, hot, node, colornode) {
draw(t = null, highlight = 0, hot = 0, node = null, colornode = null) {
if (this.ctx.nodraw !== 0) {
return;
}
let idx;
let rotation;
let ang;
let drawtype;
let bg_drawtype;
let yscale;
let width = Math.floor(this.bar_width * this.ctx.mw.zoom_factor_x);
let value = Math.max(this.min_value,
Math.min(this.bar_value, this.max_value));
let idx;
if (node !== null && node.line_width !== 0) {
idx =
Math.floor(this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor *
......@@ -100,50 +91,31 @@ class GrowBarArc extends GrowArc {
idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1, y1, x2, y2, ll_x, ll_y, ur_x, ur_y;
if (t === null) {
x1 = Math.floor(this.trf.x(this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
y1 = Math.floor(this.trf.y(this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
x2 = Math.floor(this.trf.x(this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
y2 = Math.floor(this.trf.y(this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
rotation =
(this.trf.rot() / 360 - Math.floor(this.trf.rot() / 360)) * 360;
} else {
x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) *
let y1 = Math.floor(this.trf.y(t, this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) *
let x2 = Math.floor(this.trf.x(t, this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x;
y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) *
let y2 = Math.floor(this.trf.y(t, this.ur.x, this.ur.y) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
rotation =
let rotation =
(this.trf.rot(t) / 360 - Math.floor(this.trf.rot(t) / 360)) * 360;
}
ll_x = Math.min(x1, x2);
ur_x = Math.max(x1, x2);
ll_y = Math.min(y1, y2);
ur_y = Math.max(y1, y2);
yscale = (ur_y - ll_y) / (ur_x - ll_x);
let ll_x = Math.min(x1, x2);
let ur_x = Math.max(x1, x2);
let ll_y = Math.min(y1, y2);
let ur_y = Math.max(y1, y2);
let yscale = (ur_y - ll_y) / (ur_x - ll_x);
if (width > ur_x - ll_x) {
width = ur_x - ll_x;
}
drawtype =
let drawtype =
GlowColor.get_drawtype(this.fill_drawtype, DrawType.FillHighlight,
highlight, colornode, 1, 0);
if (this.background_drawtype === DrawType.No) {
bg_drawtype = this.ctx.background_color;
} else {
bg_drawtype = this.background_drawtype;
}
let bg_drawtype = (this.background_drawtype === DrawType.No) ? this.ctx.background_color : this.background_drawtype;
// Draw circle background
this.ctx.gdraw.fill_arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, 0, 360,
......@@ -154,11 +126,9 @@ class GrowBarArc extends GrowArc {
Math.floor(rotation), this.angle2, drawtype);
// Draw bar
if (this.bar_direction === 0) {
ang = this.angle1 - rotation;
} else {
ang = this.angle1 + this.angle2 * (this.max_value - value) /
(this.max_value - this.min_value) - rotation;
let ang = this.angle1 - rotation;
if (this.bar_direction !== 0) {
ang += this.angle2 * (this.max_value - value) / (this.max_value - this.min_value);
}
if (this.gradient === Gradient.No) {
......@@ -167,7 +137,6 @@ class GrowBarArc extends GrowArc {
(this.max_value - this.min_value), this.bar_drawtype);
} else {
let f1, f2;
if (this.gradient_contrast >= 0) {
f2 =
GlowColor.shift_drawtype(this.bar_drawtype, -this.gradient_contrast /
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -5,15 +5,10 @@ class GrowGroup extends GrowNode {
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GrowGroup : " + lines[i]);
}
switch (key) {
case GlowSave.GrowGroup:
break;
......@@ -36,12 +31,9 @@ class GrowGroup extends GrowNode {
}
get_object_group(object) {
let sts;
let group;
for (let i = 0; i < this.nc.a.size(); i++) {
if (this.nc.a.get(i) instanceof GrowGroup) {
group = this.nc.a.get(i).get_object_group(object);
let group = this.nc.a.get(i).get_object_group(object);
if (group !== null) {
return group;
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -11,15 +11,10 @@ class GrowSlider extends GrowNode {
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GrowGroup : " + lines[i]);
}
switch (key) {
case GlowSave.GrowSlider:
break;
......@@ -54,48 +49,37 @@ class GrowSlider extends GrowNode {
get_origo(direction) {
let t = new GlowTransform();
let g = new Rect();
g.x = 10.0e37;
g.y = 10.0e37;
g.width = 10.0e-37;
g.height = 10.0e-37;
let pos;
let g = new Rect(10.0e37, 10.0e37, -10.0e37, -10.0e37);
// Get borders in the nodeclass coordinates
this.nc.get_borders(t, g);
switch (this.direction) {
case Direction.Down:
case Direction.Up:
if (Math.abs(g.height) < Number.MIN_VALUE) {
pos = this.y_low;
if (Math.abs(g.height()) < Number.MIN_VALUE) {
return this.ll_y;
} else {
pos = (this.nc.y0 - g.y) * (this.y_high - this.y_low) / g.height;
return (this.nc.y0 - g.ll_y) * this.height() / g.height();
}
break;
case Direction.Left:
case Direction.Right:
if (Math.abs(g.height) < Number.MIN_VALUE) {
pos = this.y_low;
if (Math.abs(g.height()) < Number.MIN_VALUE) {
return this.ll_y;
} else {
pos = (this.nc.y0 - g.y) * (this.x_right - this.x_left) / g.height;
return (this.nc.y0 - g.ll_y) * this.width() / g.height();
}
break;
default:
pos = 0;
return 0;
}
return pos;
}
get_info() {
let info = new GlowSliderInfo();
info.direction = this.direction;
info.max_value = this.max_value;
info.min_value = this.min_value;
info.max_position = this.max_pos;
info.min_position = this.min_pos;
return info;
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -433,7 +433,8 @@ class JopCrypt {
JopCrypt.intToFourBytes(out[1], b, 4);
b[8] = 0;
for (let i = 2, y = 0, u = 0x80; i < 13; i++) {
let y = 0;
for (let i = 2, u = 0x80; i < 13; i++) {
for (let j = 0, c = 0; j < 6; j++) {
c <<= 1;
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment