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

Web: More cleanup.

parent 63a51915
...@@ -264,20 +264,10 @@ class Cli { ...@@ -264,20 +264,10 @@ class Cli {
if (this.cliTable[this.cliTableIndex].qualifier[i] === null) { if (this.cliTable[this.cliTableIndex].qualifier[i] === null) {
break; break;
} }
if (this.cliTable[this.cliTableIndex].qualifier[i] === ("cli_arg1")) { for (let i = 1; i <= 5; i++) {
this.configuredVerbs++; 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 { ...@@ -318,17 +308,10 @@ class Cli {
* @return Returns true if the qualifier is present. * @return Returns true if the qualifier is present.
*/ */
qualifierFound(qual) { qualifierFound(qual) {
if (qual === ("cli_arg1")) { for (let i = 1; i < 6; i++) {
return !(this.verb.length < 2 || this.configuredVerbs < 1); if (qual == ("cli_arg" + String(i))) {
} return !(this.verb.length < (i+1) || this.configuredVerbs < i);
if (qual === ("cli_arg2")) { }
return !(this.verb.length < 3 || this.configuredVerbs < 2);
}
if (qual === ("cli_arg3")) {
return !(this.verb.length < 4 || this.configuredVerbs < 3);
}
if (qual === ("cli_arg4")) {
return !(this.verb.length < 5 || this.configuredVerbs < 4);
} }
for (let i = 0; i < this.qualifier.length; i++) { for (let i = 0; i < this.qualifier.length; i++) {
if (qual === (this.qualifier[i])) { if (qual === (this.qualifier[i])) {
...@@ -344,28 +327,13 @@ class Cli { ...@@ -344,28 +327,13 @@ class Cli {
* @return Returns the value of the qualifier. * @return Returns the value of the qualifier.
*/ */
getQualValue(qual) { getQualValue(qual) {
if (qual === ("cli_arg1")) { for (let i = 1; i < 6; i++) {
if (this.verb.length < 2 || this.configuredVerbs < 1) { if (qual == ("cli_arg" + String(i))) {
return ""; if (this.verb.length < (i+1) || this.configuredVerbs < i) {
} return ""
return this.verb[1]; }
} return this.verb[i];
if (qual === ("cli_arg2")) {
if (this.verb.length < 3 || this.configuredVerbs < 2) {
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[4];
} }
for (let i = 0; i < this.qualifier.length; i++) { for (let i = 0; i < this.qualifier.length; i++) {
if (qual === (this.qualifier[i])) { if (qual === (this.qualifier[i])) {
......
...@@ -71,7 +71,7 @@ class ObjectInfo { ...@@ -71,7 +71,7 @@ class ObjectInfo {
name; name;
description; description;
classname; classname;
full_name; fullname;
param1; param1;
} }
...@@ -813,11 +813,8 @@ class Gdh { ...@@ -813,11 +813,8 @@ class Gdh {
this.ws.send(helper.buf); this.ws.send(helper.buf);
this.next_id++; this.next_id++;
return sub.refid;
} else {
return sub.refid;
} }
return sub.refid;
} }
refObjectInfoReply(id, sts) { refObjectInfoReply(id, sts) {
......
This diff is collapsed.
...@@ -208,18 +208,46 @@ class Point { ...@@ -208,18 +208,46 @@ class Point {
} }
class Rect { class Rect {
x = 0; ll_x = 0;
y = 0; ll_y = 0;
width = 0; ur_x = 0;
height = 0; ur_y = 0;
constructor() { constructor() {
} }
constructor(x: number, y: number, width: number, height: number) { constructor(x: number, y: number, x2: number, y2: number) {
this.x = x; this.ll_x = x;
this.y = y; this.ll_y = y;
this.width = width; this.ur_x = x2;
this.height = height; 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 { ...@@ -22,11 +22,8 @@ class Ev {
constructor() { constructor() {
this.type = this.get_type(); this.type = this.get_type();
switch (this.type) { if (this.type === EvType.EventList) {
case EvType.EventList: document.title = "Event List";
document.title = "Event List";
break;
default:
} }
this.priv = Number(sessionStorage.getItem("pwr_privilege")); this.priv = Number(sessionStorage.getItem("pwr_privilege"));
...@@ -220,11 +217,7 @@ class Ev { ...@@ -220,11 +217,7 @@ class Ev {
login_cb(id, data, sts, result) { login_cb(id, data, sts, result) {
console.log("Login:", sts, result); console.log("Login:", sts, result);
if (sts & 1) { this.priv = (sts & 1) ? result : 0;
this.priv = result;
} else {
this.priv = 0;
}
} }
sync_cb(id, data, sts, result) { sync_cb(id, data, sts, result) {
...@@ -280,9 +273,7 @@ class Ev { ...@@ -280,9 +273,7 @@ class Ev {
} }
break; break;
} }
if (this.mhSyncIdx < result[i].syncIdx) { this.mhSyncIdx = Math.max(this.mhSyncIdx, result[i].syncIdx);
this.mhSyncIdx = result[i].syncIdx;
}
} }
this.ctx.configure(); this.ctx.configure();
this.ctx.reset_nodraw(); this.ctx.reset_nodraw();
...@@ -297,9 +288,7 @@ class Ev { ...@@ -297,9 +288,7 @@ class Ev {
} }
new EvItemAlarm(this, e, null, Dest.BEFORE); new EvItemAlarm(this, e, null, Dest.BEFORE);
if (this.mhSyncIdx < result[i].syncIdx) { this.mhSyncIdx = Math.max(this.mhSyncIdx, result[i].syncIdx);
this.mhSyncIdx = result[i].syncIdx;
}
} }
this.ctx.configure(); this.ctx.configure();
this.ctx.reset_nodraw(); this.ctx.reset_nodraw();
...@@ -491,69 +480,38 @@ class Ev { ...@@ -491,69 +480,38 @@ class Ev {
this.ncAlarmA = new PlowNodeClass(this.ctx); this.ncAlarmA = new PlowNodeClass(this.ctx);
this.ncAlarmA.insert(r1); this.ncAlarmA.insert(r1);
this.ncAlarmA.insert(r2a); 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 // A alarm with yellow square
this.ncAlarmB = new PlowNodeClass(this.ctx); this.ncAlarmB = new PlowNodeClass(this.ctx);
this.ncAlarmB.insert(r1); this.ncAlarmB.insert(r1);
this.ncAlarmB.insert(r2b); 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 // D and C alarm with no square
this.ncAlarm = new PlowNodeClass(this.ctx); this.ncAlarm = new PlowNodeClass(this.ctx);
this.ncAlarm.insert(r1); 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 // Info with white square
this.ncInfo = new PlowNodeClass(this.ctx); this.ncInfo = new PlowNodeClass(this.ctx);
this.ncInfo.insert(r1); this.ncInfo.insert(r1);
this.ncInfo.insert(r2info); 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 // InfoSuccess with green square
this.ncSuccess = new PlowNodeClass(this.ctx); this.ncSuccess = new PlowNodeClass(this.ctx);
this.ncSuccess.insert(r1); this.ncSuccess.insert(r1);
this.ncSuccess.insert(r2success); this.ncSuccess.insert(r2success);
this.ncSuccess.insert(a1);
this.ncSuccess.insert(p1); [a1, p1, p2, p3, p4, a2, a3, a4].forEach(function (a) {
this.ncSuccess.insert(p2); this.ncAlarmA.insert(a);
this.ncSuccess.insert(p3); this.ncAlarmB.insert(a);
this.ncSuccess.insert(p4); this.ncAlarm.insert(a);
this.ncSuccess.insert(a2); this.ncInfo.insert(a);
this.ncSuccess.insert(a3); this.ncSuccess.insert(a);
this.ncSuccess.insert(a4); });
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); this.ctx.insert_nc(this.ncSuccess);
} }
...@@ -598,7 +556,7 @@ class Ev { ...@@ -598,7 +556,7 @@ class Ev {
next.set_select(true); next.set_select(true);
next.set_invert(true); next.set_invert(true);
if (!this.ctx.is_visible(next)) { 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 { ...@@ -615,7 +573,7 @@ class Ev {
o.draw(this.ctx.gdraw.gctx, null, null, 0); o.draw(this.ctx.gdraw.gctx, null, null, 0);
next.draw(this.ctx.gdraw.gctx, null, null, 0); next.draw(this.ctx.gdraw.gctx, null, null, 0);
if (!this.ctx.is_visible(next)) { 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 { ...@@ -644,7 +602,6 @@ class Ev {
// Query 'list' = alarm/event/block. Alarm is default. // Query 'list' = alarm/event/block. Alarm is default.
get_type() { get_type() {
let query = window.location.search.substring(1); let query = window.location.search.substring(1);
let type;
if (query === "") { if (query === "") {
return EvType.AlarmList; return EvType.AlarmList;
...@@ -653,14 +610,12 @@ class Ev { ...@@ -653,14 +610,12 @@ class Ev {
let vars = query.split('&'); let vars = query.split('&');
let typestr = vars[0].substring(5); let typestr = vars[0].substring(5);
if (typestr === "event") { if (typestr === "event") {
type = EvType.EventList; return EvType.EventList;
} else if (typestr === "block") { } else if (typestr === "block") {
type = EvType.BlockList; return EvType.BlockList;
} else { } else {
type = EvType.AlarmList; return EvType.AlarmList;
} }
return type;
} }
} }
...@@ -684,19 +639,12 @@ class EvItemAlarm { ...@@ -684,19 +639,12 @@ class EvItemAlarm {
case Event.Reblock: case Event.Reblock:
case Event.CancelBlock: case Event.CancelBlock:
case Event.Unblock: case Event.Unblock:
switch (this.e.eventPrio) { if (this.e.eventPrio === EventPrio.A) {
case EventPrio.A: nodeclass = ev.ncAlarmA;
nodeclass = ev.ncAlarmA; } else if (this.e.eventPrio === EventPrio.B) {
break; nodeclass = ev.ncAlarmB;
case EventPrio.B: } else {
nodeclass = ev.ncAlarmB; nodeclass = ev.ncAlarm;
break;
case EventPrio.C:
nodeclass = ev.ncAlarm;
break;
case EventPrio.D:
nodeclass = ev.ncAlarm;
break;
} }
break; break;
case Event.Info: case Event.Info:
...@@ -722,20 +670,7 @@ class EvItemAlarm { ...@@ -722,20 +670,7 @@ class EvItemAlarm {
case Event.Reblock: case Event.Reblock:
case Event.CancelBlock: case Event.CancelBlock:
case Event.Unblock: case Event.Unblock:
switch (this.e.eventPrio) { this.node.set_annotation(0, String.fromCharCode(132 - 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;
}
break; break;
} }
switch (this.e.eventType) { switch (this.e.eventType) {
......
This diff is collapsed.
...@@ -13,49 +13,56 @@ ...@@ -13,49 +13,56 @@
<script type="text/babel" src="gdh.js"></script> <script type="text/babel" src="gdh.js"></script>
<script type="text/babel" src="glow.ts"></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_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_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_annot.ts"></script>
<script type="text/babel" src="glow_conclass.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_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_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_rect.ts"></script>
<script type="text/babel" src="glow_text.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_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_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_annot.ts"></script>
<script type="text/babel" src="grow_polyline.ts"></script> <script type="text/babel" src="grow_arc.ts"></script>
<script type="text/babel" src="grow_conpoint.ts"></script> <script type="text/babel" src="grow_axis.ts"></script>
<script type="text/babel" src="grow_image.ts"></script> <script type="text/babel" src="grow_axisarc.ts"></script>
<script type="text/babel" src="grow_conglue.ts"></script>
<script type="text/babel" src="grow_bar.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_bararc.ts"></script>
<script type="text/babel" src="grow_trend.ts"></script> <script type="text/babel" src="grow_barchart.ts"></script>
<script type="text/babel" src="grow_xycurve.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_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_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_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_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_ctx.ts"></script>
<script type="text/babel" src="grow_frame.ts"></script> <script type="text/babel" src="grow_frame.ts"></script>
......
...@@ -88,7 +88,7 @@ class Appl { ...@@ -88,7 +88,7 @@ class Appl {
graphName = cli.getQualValue("cli_arg2").toLowerCase(); graphName = cli.getQualValue("cli_arg2").toLowerCase();
if (graphName.charAt(".pwg") === -1) { if (graphName.charAt(".pwg") === -1) {
graphName = graphName + ".pwg"; graphName += ".pwg";
} }
let href; let href;
...@@ -186,7 +186,7 @@ class Appl { ...@@ -186,7 +186,7 @@ class Appl {
} }
if (source.indexOf('.') === -1) { if (source.indexOf('.') === -1) {
source = source + ".pwg"; source += ".pwg";
} }
this.graph.setSubwindowSource(name, source, object); this.graph.setSubwindowSource(name, source, object);
......
...@@ -325,7 +325,6 @@ class Dyn { ...@@ -325,7 +325,6 @@ class Dyn {
this.elements.push(elem); this.elements.push(elem);
i = elem.open(lines, i + 1); i = elem.open(lines, i + 1);
} }
return i; return i;
default: default:
console.log("Syntax error in Dyn"); console.log("Syntax error in Dyn");
...@@ -2225,7 +2224,6 @@ class DynValue extends DynElem { ...@@ -2225,7 +2224,6 @@ class DynValue extends DynElem {
if (this.format !== null) { if (this.format !== null) {
this.cFormat = new GlowCFormat(this.format); this.cFormat = new GlowCFormat(this.format);
} }
return i; return i;
default: default:
console.log("Syntax error in DynValue"); console.log("Syntax error in DynValue");
...@@ -2789,10 +2787,10 @@ class DynMove extends DynElem { ...@@ -2789,10 +2787,10 @@ class DynMove extends DynElem {
if (!object.transformIsStored()) { if (!object.transformIsStored()) {
object.storeTransform(); object.storeTransform();
let geom = object.measure(); let geom = object.measure();
this.x_orig = geom.x; this.x_orig = geom.ll_x;
this.y_orig = geom.y; this.y_orig = geom.ll_y;
this.width_orig = geom.width; this.width_orig = geom.width();
this.height_orig = geom.height; this.height_orig = geom.height();
} }
return 1; return 1;
...@@ -3362,13 +3360,10 @@ class DynScrollingText extends DynElem { ...@@ -3362,13 +3360,10 @@ class DynScrollingText extends DynElem {
} }
let geom = object.measure(); let geom = object.measure();
switch (this.direction) { if (this.direction == Direction.Left || this.direction == Direction.Right) {
case Direction.Left: this.osize = geom.width();
case Direction.Right: } else {
this.osize = geom.width; this.osize = geom.height();
break;
default:
this.osize = geom.height;
} }
return 1; return 1;
...@@ -6881,25 +6876,25 @@ class DynFillLevel extends DynElem { ...@@ -6881,25 +6876,25 @@ class DynFillLevel extends DynElem {
value = value =
((pvalue - this.min_value) / (this.max_value - this.min_value) * ((pvalue - this.min_value) / (this.max_value - this.min_value) *
(this.limit_max - this.limit_min) + (this.limit_max - this.limit_min) +
(this.limit_min - geom.x)) / geom.width; (this.limit_min - geom.ll_x)) / geom.width();
break; break;
case Direction.Left: case Direction.Left:
value = value =
((pvalue - this.min_value) / (this.max_value - this.min_value) * ((pvalue - this.min_value) / (this.max_value - this.min_value) *
(this.limit_max - this.limit_min) + (this.limit_max - this.limit_min) +
(geom.width - geom.x - this.limit_max)) / geom.width; (geom.ur_x - this.limit_max)) / geom.width();
break; break;
case Direction.Up: case Direction.Up:
value = value =
((pvalue - this.min_value) / (this.max_value - this.min_value) * ((pvalue - this.min_value) / (this.max_value - this.min_value) *
(this.limit_max - this.limit_min) + (this.limit_max - this.limit_min) +
(this.limit_min - geom.y)) / geom.height; (this.limit_min - geom.ll_y)) / geom.height();
break; break;
case Direction.Down: case Direction.Down:
value = value =
((pvalue - this.min_value) / (this.max_value - this.min_value) * ((pvalue - this.min_value) / (this.max_value - this.min_value) *
(this.limit_max - this.limit_min) + (this.limit_max - this.limit_min) +
(geom.height - geom.y - this.limit_max)) / geom.height; (geom.ur_y - this.limit_max)) / geom.height();
break; break;
default: default:
} }
...@@ -8465,7 +8460,7 @@ class DynSlider extends DynElem { ...@@ -8465,7 +8460,7 @@ class DynSlider extends DynElem {
let g = object.measure(); let g = object.measure();
let info = object.get_info(); let info = object.get_info();
let b = this.dyn.graph.getCtx() 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) { if ((b.sts & 1) === 0) {
this.direction = info.direction; this.direction = info.direction;
} else { } else {
...@@ -9052,10 +9047,10 @@ class DynPulldownMenu extends DynElem { ...@@ -9052,10 +9047,10 @@ class DynPulldownMenu extends DynElem {
} }
let g = object.measure(); let g = object.measure();
this.menu_object = new GrowMenu(this.dyn.graph.getCtx()); this.menu_object = new GrowMenu(this.dyn.graph.getCtx(),
this.menu_object.init("__Menu", info, g.x, g.y + g.height, g.width, "__Menu", info, g.x, g.ur_y, g.width(),
DrawType.Line, 0, 1, 1, bg_color, text_size, text_drawtype, DrawType.Line, 0, 1, 1, bg_color, text_size,
text_color, DrawType.MediumGray, text_font); text_drawtype, text_color, DrawType.MediumGray, text_font);
this.menu_object.set_scale(scale, scale, 0, 0, this.menu_object.set_scale(scale, scale, 0, 0,
ScaleType.LowerLeft); ScaleType.LowerLeft);
this.dyn.graph.getCtx().insert(this.menu_object); this.dyn.graph.getCtx().insert(this.menu_object);
...@@ -9605,10 +9600,10 @@ class DynOptionMenu extends DynElem { ...@@ -9605,10 +9600,10 @@ class DynOptionMenu extends DynElem {
} }
let g = object.measure(); let g = object.measure();
this.menu_object = new GrowMenu(this.dyn.graph.getCtx()); this.menu_object = new GrowMenu(this.dyn.graph.getCtx(),
this.menu_object.init("__Menu", info, g.x, g.y + g.height, g.width, "__Menu", info, g.ll_x, g.ur_y, g.width(),
DrawType.Line, 0, 1, 1, bg_color, tsize, text_drawtype, DrawType.Line, 0, 1, 1, bg_color, tsize,
text_color, DrawType.MediumGray, text_font); text_drawtype, text_color, DrawType.MediumGray, text_font);
this.menu_object.set_scale(scale, scale, 0, 0, this.menu_object.set_scale(scale, scale, 0, 0,
ScaleType.LowerLeft); ScaleType.LowerLeft);
this.dyn.graph.getCtx().insert(this.menu_object); this.dyn.graph.getCtx().insert(this.menu_object);
...@@ -10806,9 +10801,9 @@ class DynMethodPulldownMenu extends DynElem { ...@@ -10806,9 +10801,9 @@ class DynMethodPulldownMenu extends DynElem {
} }
let g = this.o.measure(); let g = this.o.measure();
this.menu_object = new GrowMenu(this.dyn.graph.getCtx()); this.menu_object = new GrowMenu(this.dyn.graph.getCtx(),
this.menu_object.init("__Menu", info, g.x, g.y + g.height, g.width, "__Menu", info, g.ll_x, g.ur_y, g.width(), DrawType.Line,
DrawType.Line, 0, 1, 1, bg_color, text_size, text_drawtype, 0, 1, 1, bg_color, text_size, text_drawtype,
text_color, DrawType.MediumGray, text_font); text_color, DrawType.MediumGray, text_font);
this.menu_object.set_scale(scale, scale, 0, 0, ScaleType.LowerLeft); this.menu_object.set_scale(scale, scale, 0, 0, ScaleType.LowerLeft);
this.dyn.graph.getCtx().insert(this.menu_object); this.dyn.graph.getCtx().insert(this.menu_object);
......
...@@ -276,7 +276,7 @@ class Graph { ...@@ -276,7 +276,7 @@ class Graph {
} }
gdh_init_cb() { gdh_init_cb() {
if (this.priv == null) { if (this.priv === null) {
this.gdh.login("", "", this.login_cb, this); this.gdh.login("", "", this.login_cb, this);
} }
...@@ -366,14 +366,13 @@ class Graph { ...@@ -366,14 +366,13 @@ class Graph {
let dyn; let dyn;
let o; let o;
if (e.object_type !== ObjectType.NoObject && e.object !== null) { if (e.object) {
ctx_popped = this.ctxPop(e.object.ctx); ctx_popped = this.ctxPop(e.object.ctx);
} }
switch (e.event) { switch (e.event) {
case Event.MB1Click: case Event.MB1Click:
if (e.object_type === ObjectType.NoObject || if (!(e.object instanceof GrowMenu)) {
!(e.object instanceof GrowMenu)) {
// Close any open menu, if not click in menu // Close any open menu, if not click in menu
let event = new GlowEventMenu(); let event = new GlowEventMenu();
event.event = Event.MenuDelete; event.event = Event.MenuDelete;
...@@ -383,8 +382,7 @@ class Graph { ...@@ -383,8 +382,7 @@ class Graph {
let list = this.ctx.get_object_list(); let list = this.ctx.get_object_list();
for (let i = 0; i < list.size(); i++) { for (let i = 0; i < list.size(); i++) {
o = list.get(i); o = list.get(i);
if ((o instanceof GrowNode || o instanceof GrowGroup) && if ((o instanceof GrowNode || o instanceof GrowGroup) && o !== e.object) {
(e.object_type === ObjectType.NoObject || o !== e.object)) {
dyn = o.getUserData(); dyn = o.getUserData();
if (dyn !== null) { if (dyn !== null) {
dyn.action(o, event); dyn.action(o, event);
...@@ -419,24 +417,20 @@ class Graph { ...@@ -419,24 +417,20 @@ class Graph {
break; break;
case Event.MenuActivated: case Event.MenuActivated:
case Event.MenuCreate: case Event.MenuCreate:
case Event.MenuDelete: { case Event.MenuDelete:
let old_size;
let sts;
let list = this.ctx.get_object_list(); let list = this.ctx.get_object_list();
for (let i = 0; i < list.size(); i++) { for (let i = 0; i < list.size(); i++) {
o = list.get(i); o = list.get(i);
if (o instanceof GrowNode || o instanceof GrowGroup) { if (o instanceof GrowNode || o instanceof GrowGroup) {
dyn = o.getUserData(); dyn = o.getUserData();
if (dyn !== null) { if (dyn !== null) {
sts = dyn.action(o, e); let sts = dyn.action(o, e);
if (sts === GLOW__TERMINATED) { if (sts === GLOW__TERMINATED) {
return; return;
} }
// Check if anything is deleted // Check if anything is deleted
old_size = list.size(); let old_size = list.size();
list = this.ctx.get_object_list(); list = this.ctx.get_object_list();
if (old_size !== list.size()) { if (old_size !== list.size()) {
break; break;
...@@ -445,7 +439,6 @@ class Graph { ...@@ -445,7 +439,6 @@ class Graph {
} }
} }
break; break;
}
default: default:
break; break;
} }
...@@ -653,7 +646,7 @@ class Graph { ...@@ -653,7 +646,7 @@ class Graph {
} }
pname.database = Database.Ccm; pname.database = Database.Ccm;
pname.tname = new String(pname.name); pname.tname = String(pname.name);
return pname; return pname;
} }
...@@ -665,7 +658,7 @@ class Graph { ...@@ -665,7 +658,7 @@ class Graph {
} }
} }
pname.tname = new String(str); pname.tname = String(str);
if ((idx = str.indexOf('[')) === -1) { if ((idx = str.indexOf('[')) === -1) {
if ((eidx = str.lastIndexOf('#')) !== -1 && str.charAt(eidx - 1) !== '#') { if ((eidx = str.lastIndexOf('#')) !== -1 && str.charAt(eidx - 1) !== '#') {
...@@ -732,7 +725,7 @@ class Graph { ...@@ -732,7 +725,7 @@ class Graph {
ctx_popped = this.ctxPop(object.ctx); ctx_popped = this.ctxPop(object.ctx);
} }
if (object.userdata == null) { if (object.userdata === null) {
if (ctx_popped) { if (ctx_popped) {
this.ctxPush(); this.ctxPush();
} }
...@@ -748,7 +741,7 @@ class Graph { ...@@ -748,7 +741,7 @@ class Graph {
(dyn.dyn_type1 & DynType1.HostObject) !== 0) { (dyn.dyn_type1 & DynType1.HostObject) !== 0) {
let nodeclass_dyn = object.getClassUserData(); let nodeclass_dyn = object.getClassUserData();
dyn.setTotal(null); dyn.setTotal(null);
if (nodeclass_dyn != null) { if (nodeclass_dyn !== null) {
let old_dyn = dyn; let old_dyn = dyn;
dyn = new Dyn(this); dyn = new Dyn(this);
dyn.merge(old_dyn); dyn.merge(old_dyn);
...@@ -810,7 +803,7 @@ class Graph { ...@@ -810,7 +803,7 @@ class Graph {
} }
openConfirmDialog(dyn, text, object) { openConfirmDialog(dyn, text, object) {
if (appl != null) { if (appl !== null) {
appl.openConfirmDialog(dyn, text, object); appl.openConfirmDialog(dyn, text, object);
} }
} }
...@@ -831,14 +824,14 @@ class Graph { ...@@ -831,14 +824,14 @@ class Graph {
} }
command(cmd) { command(cmd) {
if (this.appl != null) { if (this.appl !== null) {
return this.appl.command(cmd); return this.appl.command(cmd);
} }
return 0; return 0;
} }
script(script) { script(script) {
if (this.appl != null) { if (this.appl !== null) {
return this.appl.script(script); return this.appl.script(script);
} }
return 0; return 0;
...@@ -853,7 +846,7 @@ class Graph { ...@@ -853,7 +846,7 @@ class Graph {
let idx; let idx;
while ((idx = str.indexOf("$object")) !== -1) { while ((idx = str.indexOf("$object")) !== -1) {
if (appl != null) { if (appl !== null) {
let oname = this.ctx.getOwner(); let oname = this.ctx.getOwner();
str = str.substring(0, idx) + oname + str.substring(idx + 7); str = str.substring(0, idx) + oname + str.substring(idx + 7);
} }
......
...@@ -1699,11 +1699,6 @@ class GlowEventToolbar extends GlowEvent { ...@@ -1699,11 +1699,6 @@ class GlowEventToolbar extends GlowEvent {
idx = 0; idx = 0;
} }
class GlowPointX {
x;
y;
}
class GlowSliderInfo { class GlowSliderInfo {
direction; direction;
max_value; max_value;
...@@ -1719,7 +1714,7 @@ class MenuInfoItem { ...@@ -1719,7 +1714,7 @@ class MenuInfoItem {
} }
class GlowMenuInfo { class GlowMenuInfo {
item = Array(32); item = Array<MenuInfoItem>(32);
constructor() { constructor() {
for (let i = 0; i < 32; i++) { 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 { ...@@ -19,15 +19,10 @@ class GlowArc {
open(lines, row) { open(lines, row) {
let i; let i;
for (i = row; i < lines.length; i++) { for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' '); let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10); let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GlowArc : " + lines[i]);
}
switch (key) { switch (key) {
case GlowSave.Arc: case GlowSave.Arc:
break; break;
...@@ -59,6 +54,7 @@ class GlowArc { ...@@ -59,6 +54,7 @@ class GlowArc {
break; break;
} }
} }
return i; return i;
} }
...@@ -67,14 +63,13 @@ class GlowArc { ...@@ -67,14 +63,13 @@ class GlowArc {
return; return;
} }
let ll_x, ll_y, ur_x, ur_y; let ll_x = Math.floor(this.ll.x * this.ctx.mw.zoom_factor_x + 0.5) -
ll_x = Math.floor(this.ll.x * this.ctx.mw.zoom_factor_x + 0.5) -
this.ctx.mw.offset_x; 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; 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; 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; this.ctx.mw.offset_y;
if (ll_x === ur_x && ll_y === ur_y) { if (ll_x === ur_x && ll_y === ur_y) {
...@@ -94,14 +89,13 @@ class GlowArc { ...@@ -94,14 +89,13 @@ class GlowArc {
return; return;
} }
let ll_x, ll_y, ur_x, ur_y; let ll_x = Math.floor(this.ll.x * this.ctx.mw.zoom_factor_x + 0.5) -
ll_x = Math.floor(this.ll.x * this.ctx.mw.zoom_factor_x + 0.5) -
this.ctx.mw.offset_x; 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; 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; 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; this.ctx.mw.offset_y;
let idx = Math.floor(this.ctx.mw.zoom_factor_y / let idx = Math.floor(this.ctx.mw.zoom_factor_y /
this.ctx.mw.base_zoom_factor * this.line_width - 1); this.ctx.mw.base_zoom_factor * this.line_width - 1);
......
...@@ -11,13 +11,11 @@ class GlowArray { ...@@ -11,13 +11,11 @@ class GlowArray {
} }
remove(elem) { remove(elem) {
for (let i = 0; i < this.a.length; i++) { let idx = this.a.indexOf(elem);
if (this.a[i] === elem) { if (idx != -1) {
this.a.splice(i, 1); this.a.splice(idx, 1);
return 1;
}
} }
return 0; return (idx != -1);
} }
size() { size() {
...@@ -35,10 +33,6 @@ class GlowArray { ...@@ -35,10 +33,6 @@ class GlowArray {
let key = parseInt(tokens[0], 10); let key = parseInt(tokens[0], 10);
let o; let o;
if (this.ctx.debug) {
console.log("GlowArray : " + lines[i]);
}
switch (key) { switch (key) {
case GlowSave.Array: case GlowSave.Array:
break; break;
...@@ -233,10 +227,23 @@ class GlowArray { ...@@ -233,10 +227,23 @@ class GlowArray {
break; break;
} }
} }
return i; return i;
} }
clear() { clear() {
this.a.length = 0; 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 { ...@@ -125,8 +125,9 @@ class GlowCFormat {
pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' '; pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' ';
pad_length = ph.width - (sign + arg).length; pad_length = ph.width - (sign + arg).length;
let pad_rpt = ''; let pad_rpt = '';
for (let i = 0; i < pad_length; i++) for (let i = 0; i < pad_length; i++) {
pad_rpt += pad_character; pad_rpt += pad_character;
}
pad = ph.width ? (pad_length > 0 ? pad_rpt : '') : ''; pad = ph.width ? (pad_length > 0 ? pad_rpt : '') : '';
output += ph.align ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg); output += ph.align ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg);
} }
...@@ -145,21 +146,23 @@ class GlowCFormat { ...@@ -145,21 +146,23 @@ class GlowCFormat {
} else if ((match = CFormatC.placeholder.exec(_fmt)) !== null) { } else if ((match = CFormatC.placeholder.exec(_fmt)) !== null) {
if (match[2]) { if (match[2]) {
arg_names |= 1; arg_names |= 1;
let field_list = [], replacement_field = match[2], field_match = []; let replacement_field = match[2];
if ((field_match = CFormatC.key.exec(replacement_field)) !== null) { let field_match = CFormatC.key.exec(replacement_field);
field_list.push(field_match[1]); if (field_match === null) {
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]);
} else if ((field_match = CFormatC.index_access.exec(replacement_field)) !== null) {
field_list.push(field_match[1]);
} else {
throw new SyntaxError('[sprintf] failed to parse named argument key');
}
}
} else {
throw new SyntaxError('[sprintf] failed to parse named argument key'); 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]);
} else if ((field_match = CFormatC.index_access.exec(replacement_field)) !== null) {
field_list.push(field_match[1]);
} else {
throw new SyntaxError('[sprintf] failed to parse named argument key');
}
}
match[2] = field_list; match[2] = field_list;
} else { } else {
arg_names |= 2; arg_names |= 2;
......
...@@ -84,8 +84,6 @@ class GlowColor { ...@@ -84,8 +84,6 @@ class GlowColor {
} }
static shift_drawtype(dt, shift, node) { static shift_drawtype(dt, shift, node) {
let incr;
let base_drawtype;
let drawtype; let drawtype;
if (node !== null && node.getColorInverse() !== 0) { if (node !== null && node.getColorInverse() !== 0) {
...@@ -93,8 +91,8 @@ class GlowColor { ...@@ -93,8 +91,8 @@ class GlowColor {
} }
if (this.is_shiftable(dt)) { if (this.is_shiftable(dt)) {
base_drawtype = Math.floor(dt / 10) * 10; let base_drawtype = Math.floor(dt / 10) * 10;
incr = shift + dt - base_drawtype; let incr = shift + dt - base_drawtype;
if (incr < 0) { // White if (incr < 0) { // White
drawtype = DrawType.Color4; drawtype = DrawType.Color4;
...@@ -123,15 +121,8 @@ class GlowColor { ...@@ -123,15 +121,8 @@ class GlowColor {
static get_drawtype(local_drawtype, highlight_drawtype, highlight, node, fill, static get_drawtype(local_drawtype, highlight_drawtype, highlight, node, fill,
highlight_disabled) { highlight_disabled) {
let drawtype; let drawtype;
let base_drawtype; let lightness = (node === null) ? 0 : node.getColorLightness();
let incr; let intensity = (node === null) ? 0 : node.getColorIntensity();
let lightness = 0;
let intensity = 0;
if (node !== null) {
lightness = node.getColorLightness();
intensity = node.getColorIntensity();
}
if (highlight !== 0 && highlight_disabled === 0) { if (highlight !== 0 && highlight_disabled === 0) {
drawtype = highlight_drawtype; drawtype = highlight_drawtype;
...@@ -189,8 +180,8 @@ class GlowColor { ...@@ -189,8 +180,8 @@ class GlowColor {
if (node !== null && lightness !== 0) { if (node !== null && lightness !== 0) {
if (local_drawtype >= 30 && drawtype < 300) { if (local_drawtype >= 30 && drawtype < 300) {
base_drawtype = Math.floor(drawtype / 10) * 10; let base_drawtype = Math.floor(drawtype / 10) * 10;
incr = -lightness + drawtype - base_drawtype; let incr = -lightness + drawtype - base_drawtype;
if (incr < 0) { // White if (incr < 0) { // White
drawtype = DrawType.Color4; drawtype = DrawType.Color4;
} else if (incr >= 10) { // DarkGrey } else if (incr >= 10) { // DarkGrey
...@@ -202,8 +193,8 @@ class GlowColor { ...@@ -202,8 +193,8 @@ class GlowColor {
} }
if (node !== null && intensity !== 0) { if (node !== null && intensity !== 0) {
if (drawtype >= 60) { if (drawtype >= 60) {
base_drawtype = Math.floor(drawtype / 30) * 30; let base_drawtype = Math.floor(drawtype / 30) * 30;
incr = drawtype - base_drawtype; let incr = drawtype - base_drawtype;
drawtype = drawtype =
(drawtype + Math.min(2 - Math.floor(incr / 10), intensity) * 10); (drawtype + Math.min(2 - Math.floor(incr / 10), intensity) * 10);
if (drawtype < base_drawtype) { if (drawtype < base_drawtype) {
...@@ -213,7 +204,7 @@ class GlowColor { ...@@ -213,7 +204,7 @@ class GlowColor {
} }
if (node !== null && node.getColorShift() !== 0) { if (node !== null && node.getColorShift() !== 0) {
if (drawtype >= 60 && drawtype < 300) { if (drawtype >= 60 && drawtype < 300) {
incr = let incr =
node.getColorShift() - Math.floor(node.getColorShift() / 8) * 8; node.getColorShift() - Math.floor(node.getColorShift() / 8) * 8;
if (incr < 0) { if (incr < 0) {
incr += 8; incr += 8;
...@@ -270,34 +261,19 @@ class GlowColor { ...@@ -270,34 +261,19 @@ class GlowColor {
} }
static rgb_color(idx, customcolors) { 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) { if (idx === 300) {
idx = 31; idx = 31;
} }
if (idx === 3) { // White if (idx === 3) { // White
r = 1.0; return new Rgb(1, 1, 1);
g = 1.0;
b = 1.0;
} else if (idx === 2) { // Gray } else if (idx === 2) { // Gray
r = 0.75; return new Rgb(0.75, 0.75, 0.75);
g = 0.75;
b = 0.75;
} else if (idx === 1) { // Red } else if (idx === 1) { // Red
r = 1.0; return new Rgb(1, 0, 0);
g = 0;
b = 0;
} else if (idx < 20) { } else if (idx < 20) {
// Sixteen colors of different hue // Sixteen colors of different hue
h1 = 360.0 * (idx - 4) / 16; return this.his_to_rgb(360.0 * (idx - 4) / 16, 1, 1.5);
s1 = 1.5;
i1 = 1;
return this.his_to_rgb(h1, i1, s1);
} else if (idx < 60) { } else if (idx < 60) {
// Four sets of gray // Four sets of gray
let i0 = GlowColor.gray_i0; let i0 = GlowColor.gray_i0;
...@@ -306,25 +282,22 @@ class GlowColor { ...@@ -306,25 +282,22 @@ class GlowColor {
i0 = 0.25; i0 = 0.25;
} }
r = i0 + (GlowColor.gray_i1 - i0) * Math.pow((9 - idx % 10) / 9, 0.9); let r = i0 + (GlowColor.gray_i1 - i0) * Math.pow((9 - idx % 10) / 9, 0.9);
g = r; return new Rgb(r, r, r);
b = r;
} else if (idx < 300) { } else if (idx < 300) {
i = Math.floor((idx - 60) / 30); let i = Math.floor((idx - 60) / 30);
j = Math.floor((idx - 60 - i * 30) / 10); let j = Math.floor((idx - 60 - i * 30) / 10);
k = 9 - (idx - 60 - i * 30 - j * 10); let k = 9 - (idx - 60 - i * 30 - j * 10);
if ((i === 0 && j === 2) || (i === 2 && j === 2 && k > 5)) { if ((i === 0 && j === 2) || (i === 2 && j === 2 && k > 5)) {
// Formula doesn't work for yellow... // Formula doesn't work for yellow...
r = this.rgbtab[i * 10 + k].r; return new Rgb(this.rgbtab[i * 10 + k].r, this.rgbtab[i * 10 + k].g, this.rgbtab[i * 10 + k].b);
g = this.rgbtab[i * 10 + k].g;
b = this.rgbtab[i * 10 + k].b;
} else { } else {
s1 = this.ctab[i].s[j].s; let s1 = this.ctab[i].s[j].s;
i1 = this.ctab[i].s[j].i_min + let i1 = this.ctab[i].s[j].i_min +
(this.ctab[i].s[j].i_max - 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); 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); return this.his_to_rgb(h1, i1, s1);
} }
...@@ -336,7 +309,7 @@ class GlowColor { ...@@ -336,7 +309,7 @@ class GlowColor {
return customcolors.get_color(idx); return customcolors.get_color(idx);
} }
} }
return new Rgb(r, g, b); return new Rgb(0, 0, 0);
} }
static his_to_rgb(h, i, s) { static his_to_rgb(h, i, s) {
...@@ -388,10 +361,6 @@ class GlowCustomColors { ...@@ -388,10 +361,6 @@ class GlowCustomColors {
let tokens = lines[i].split(' '); let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10); let key = parseInt(tokens[0], 10);
if (this.debug) {
console.log("GlowCustomColors : " + lines[i]);
}
switch (key) { switch (key) {
case GlowSave.CustomColors: case GlowSave.CustomColors:
break; break;
...@@ -424,6 +393,7 @@ class GlowCustomColors { ...@@ -424,6 +393,7 @@ class GlowCustomColors {
break; break;
} }
} }
return i; return i;
} }
......
class GlowCon { class GlowCon extends Rect {
static MAX_POINT = 8; static MAX_POINT = 8;
ctx: GrowCtx; ctx: GrowCtx;
line_a: GlowArray; line_a: GlowArray;
...@@ -8,10 +8,6 @@ class GlowCon { ...@@ -8,10 +8,6 @@ class GlowCon {
cc_name; cc_name;
cc; cc;
c_name; c_name;
x_right;
x_left;
y_high;
y_low;
dest_node; dest_node;
source_node; source_node;
dest_conpoint; dest_conpoint;
...@@ -37,6 +33,7 @@ class GlowCon { ...@@ -37,6 +33,7 @@ class GlowCon {
hot = 0; hot = 0;
constructor(ctx) { constructor(ctx) {
super();
this.ctx = ctx; this.ctx = ctx;
this.line_a = new GlowArray(ctx); this.line_a = new GlowArray(ctx);
this.arc_a = new GlowArray(ctx); this.arc_a = new GlowArray(ctx);
...@@ -51,10 +48,6 @@ class GlowCon { ...@@ -51,10 +48,6 @@ class GlowCon {
let tokens = lines[i].split(' '); let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10); let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GlowCon : " + lines[i]);
}
switch (key) { switch (key) {
case GlowSave.Con: case GlowSave.Con:
break; break;
...@@ -72,16 +65,16 @@ class GlowCon { ...@@ -72,16 +65,16 @@ class GlowCon {
} }
break; break;
case GlowSave.Con_x_right: case GlowSave.Con_x_right:
this.x_right = parseFloat(tokens[1]); this.ur_x = parseFloat(tokens[1]);
break; break;
case GlowSave.Con_x_left: case GlowSave.Con_x_left:
this.x_left = parseFloat(tokens[1]); this.ll_x = parseFloat(tokens[1]);
break; break;
case GlowSave.Con_y_high: case GlowSave.Con_y_high:
this.y_high = parseFloat(tokens[1]); this.ur_y = parseFloat(tokens[1]);
break; break;
case GlowSave.Con_y_low: case GlowSave.Con_y_low:
this.y_low = parseFloat(tokens[1]); this.ll_y = parseFloat(tokens[1]);
break; break;
case GlowSave.Con_dest_node: case GlowSave.Con_dest_node:
if (tokens.length > 1) { if (tokens.length > 1) {
...@@ -187,43 +180,29 @@ class GlowCon { ...@@ -187,43 +180,29 @@ class GlowCon {
break; break;
} }
} }
return i;
}
draw() { return i;
this.tdraw(null, this.highlight, this.hot, null, null);
} }
tdraw(t, highlight, hot, node, colornode) { draw(t = null, highlight = this.highlight, hot = this.hot, node = null, colornode = null) {
if (this.ctx.nodraw !== 0) { if (this.ctx.nodraw !== 0) {
return; return;
} }
let tmp;
let i;
if (this.temporary_ref !== 0 || if (this.temporary_ref !== 0 ||
this.cc.con_type === ConType.Reference) { this.cc.con_type === ConType.Reference) {
// ref_a.draw( w, &cc->zero, highlight, hot, NULL); // ref_a.draw( w, &cc->zero, highlight, hot, NULL);
} else { } else {
for (i = 0; i < this.l_num; i++) { let ltmp = this.line_a.slice(0, this.l_num);
this.line_a.get(i).draw(highlight, hot); let atmp = this.arc_a.slice(0, this.a_num);
} ltmp.forEach(e => e.draw(highlight, hot));
for (i = 0; i < this.a_num; i++) { atmp.forEach(e => e.draw(highlight, hot));
this.arc_a.get(i).draw(highlight, hot);
}
// arrow_a.draw( highlight, hot); // arrow_a.draw( highlight, hot);
if ((this.shadow !== 0 || this.border !== 0) && if ((this.shadow !== 0 || this.border !== 0) &&
this.cc.con_type === ConType.Routed && this.cc.con_type === ConType.Routed &&
this.cc.corner === Corner.Rounded) { this.cc.corner === Corner.Rounded) {
for (i = 0; i < this.l_num; i++) { ltmp.forEach(e => e.draw_shadow(this.border, this.shadow, highlight, hot));
this.line_a.get(i) atmp.forEach(e => e.draw_shadow(this.border, this.shadow, highlight, hot));
.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);
}
} }
} }
} }
......
...@@ -20,10 +20,6 @@ class GlowConClass { ...@@ -20,10 +20,6 @@ class GlowConClass {
let tokens = lines[i].split(' '); let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10); let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GlowConClass : " + lines[i]);
}
switch (key) { switch (key) {
case GlowSave.ConClass: case GlowSave.ConClass:
break; break;
...@@ -64,6 +60,7 @@ class GlowConClass { ...@@ -64,6 +60,7 @@ class GlowConClass {
break; break;
} }
} }
return i; return i;
} }
} }
\ No newline at end of file
...@@ -15,15 +15,10 @@ class GlowConPoint { ...@@ -15,15 +15,10 @@ class GlowConPoint {
open(lines, row) { open(lines, row) {
let i; let i;
for (i = row; i < lines.length; i++) { for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' '); let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10); let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GrowPolyline : " + lines[i]);
}
switch (key) { switch (key) {
case GlowSave.ConPoint: case GlowSave.ConPoint:
break; break;
...@@ -54,15 +49,13 @@ class GlowConPoint { ...@@ -54,15 +49,13 @@ class GlowConPoint {
break; break;
} }
} }
return i; return i;
} }
draw() { draw() {
} }
tdraw(t, highlight, hot, node, colornode) {
}
event_handler(event, fx, fy) { event_handler(event, fx, fy) {
return 0; return 0;
} }
......
This diff is collapsed.
...@@ -7,8 +7,8 @@ class GlowLine { ...@@ -7,8 +7,8 @@ class GlowLine {
constructor(ctx) { constructor(ctx) {
this.ctx = ctx; this.ctx = ctx;
this.p1 = new GlowPoint(ctx); this.p1 = new GlowPoint();
this.p2 = new GlowPoint(ctx); this.p2 = new GlowPoint();
} }
open(lines, row) { open(lines, row) {
...@@ -17,10 +17,6 @@ class GlowLine { ...@@ -17,10 +17,6 @@ class GlowLine {
let tokens = lines[i].split(' '); let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10); let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GlowCon : " + lines[i]);
}
switch (key) { switch (key) {
case GlowSave.Line: case GlowSave.Line:
break; break;
...@@ -47,22 +43,18 @@ class GlowLine { ...@@ -47,22 +43,18 @@ class GlowLine {
return i; return i;
} }
tdraw(t, highlight, hot, node, colornode) {
}
draw(highlight, hot) { draw(highlight, hot) {
if (this.ctx.nodraw !== 0) { if (this.ctx.nodraw !== 0) {
return; return;
} }
let p1_x, p1_y, p2_x, p2_y; let p1_x = Math.floor(this.p1.x * this.ctx.mw.zoom_factor_x + 0.5) -
p1_x = Math.floor(this.p1.x * this.ctx.mw.zoom_factor_x + 0.5) -
this.ctx.mw.offset_x; 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; 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; 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; this.ctx.mw.offset_y;
if (p1_x === p2_x && p1_y === p2_y) { if (p1_x === p2_x && p1_y === p2_y) {
...@@ -81,14 +73,13 @@ class GlowLine { ...@@ -81,14 +73,13 @@ class GlowLine {
return; return;
} }
let p1_x, p1_y, p2_x, p2_y; let p1_x = Math.floor(this.p1.x * this.ctx.mw.zoom_factor_x + 0.5) -
p1_x = Math.floor(this.p1.x * this.ctx.mw.zoom_factor_x + 0.5) -
this.ctx.mw.offset_x; 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; 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; 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; this.ctx.mw.offset_y;
if (p1_x === p2_x && p1_y === p2_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 { ...@@ -36,10 +36,6 @@ class GlowNodeClass {
let tokens = lines[i].split(' '); let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10); let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GlowNodeClass : " + lines[i]);
}
switch (key) { switch (key) {
case GlowSave.NodeClass: case GlowSave.NodeClass:
break; break;
...@@ -179,6 +175,7 @@ class GlowNodeClass { ...@@ -179,6 +175,7 @@ class GlowNodeClass {
this.next_nc.prev_nc = this; this.next_nc.prev_nc = this;
} }
} }
return i; return i;
} }
...@@ -192,10 +189,8 @@ class GlowNodeClass { ...@@ -192,10 +189,8 @@ class GlowNodeClass {
return 0; return 0;
} }
tdraw(t, highlight, hot, node, colornode) { draw(t = null, highlight = 0, hot = 0, node = null, colornode = null) {
for (let i = 0; i < this.a.size(); i++) { this.a.forEach(e => e.draw(t, highlight, hot, node, colornode));
this.a.get(i).tdraw(t, highlight, hot, node, colornode);
}
} }
get_borders(t, g) { get_borders(t, g) {
...@@ -208,7 +203,7 @@ class GlowNodeClass { ...@@ -208,7 +203,7 @@ class GlowNodeClass {
Math.abs(base.y0 - base.y1) < Number.MIN_VALUE)) { Math.abs(base.y0 - base.y1) < Number.MIN_VALUE)) {
// Borders are given i x0, y0, x1, y1 // Borders are given i x0, y0, x1, y1
// Will not work in rotated nodes // 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) { if (t === null) {
kx1 = base.x0; kx1 = base.x0;
...@@ -222,27 +217,9 @@ class GlowNodeClass { ...@@ -222,27 +217,9 @@ class GlowNodeClass {
ky2 = t.y(base.x1, base.y1); ky2 = t.y(base.x1, base.y1);
} }
ll_x = Math.min(kx1, kx2); g.set(Rect.union(g, new Rect(Math.min(kx1, kx2), Math.min(ky1, ky2), Math.max(kx1, kx2), Math.max(ky1, ky2))));
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;
}
} else { } else {
for (let i = 0; i < this.a.size(); i++) { this.a.forEach(e => e.get_borders(t, g));
this.a.get(i).get_borders(t, g);
}
} }
} }
...@@ -257,10 +234,10 @@ class GlowNodeClass { ...@@ -257,10 +234,10 @@ class GlowNodeClass {
for (let i = 0; i < this.a.size(); i++) { for (let i = 0; i < this.a.size(); i++) {
if (this.a.get(i) instanceof GrowAnnot && if (this.a.get(i) instanceof GrowAnnot &&
this.a.get(i).getNumber() === num) { this.a.get(i).getNumber() === num) {
let d = this.a.get(i).getTextExtent(t, node); let p = this.a.get(i).getTextExtent(t, node);
d.width /= this.ctx.mw.zoom_factor_x; p.x /= this.ctx.mw.zoom_factor_x;
d.height /= this.ctx.mw.zoom_factor_y; p.y /= this.ctx.mw.zoom_factor_y;
return d; return p;
} }
} }
return null; return null;
......
...@@ -9,10 +9,6 @@ class GlowNodeGroup extends GlowNodeClass { ...@@ -9,10 +9,6 @@ class GlowNodeGroup extends GlowNodeClass {
let tokens = lines[i].split(' '); let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10); let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GlowNodeClass : " + lines[i]);
}
switch (key) { switch (key) {
case GlowSave.NodeGroup: case GlowSave.NodeGroup:
break; break;
...@@ -26,6 +22,7 @@ class GlowNodeGroup extends GlowNodeClass { ...@@ -26,6 +22,7 @@ class GlowNodeGroup extends GlowNodeClass {
break; break;
} }
} }
return i; return i;
} }
} }
\ No newline at end of file
class GlowPoint { class GlowPoint extends Point {
x = 0.0;
y = 0.0;
open(lines, row) { open(lines, row) {
let i; let i;
for (i = row; i < lines.length; i++) { for (i = row; i < lines.length; i++) {
...@@ -24,6 +21,7 @@ class GlowPoint { ...@@ -24,6 +21,7 @@ class GlowPoint {
break; break;
} }
} }
return i; 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 { ...@@ -19,10 +19,6 @@ class GlowRect {
let tokens = lines[i].split(' '); let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10); let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GlowCon : " + lines[i]);
}
switch (key) { switch (key) {
case GlowSave.Rect: case GlowSave.Rect:
break; break;
......
...@@ -9,7 +9,7 @@ class GlowText { ...@@ -9,7 +9,7 @@ class GlowText {
constructor(ctx) { constructor(ctx) {
this.ctx = ctx; this.ctx = ctx;
this.p = new GlowPoint(ctx); this.p = new GlowPoint();
} }
open(lines, row) { open(lines, row) {
...@@ -18,10 +18,6 @@ class GlowText { ...@@ -18,10 +18,6 @@ class GlowText {
let tokens = lines[i].split(' '); let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10); let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GlowCon : " + lines[i]);
}
switch (key) { switch (key) {
case GlowSave.Text: case GlowSave.Text:
break; break;
...@@ -47,6 +43,7 @@ class GlowText { ...@@ -47,6 +43,7 @@ class GlowText {
break; break;
} }
} }
return i; return i;
} }
......
...@@ -6,23 +6,21 @@ class GlowTransform { ...@@ -6,23 +6,21 @@ class GlowTransform {
a22 = 1; a22 = 1;
a23 = 0; a23 = 0;
rotation = 0; rotation = 0;
s_a11 = 1; s: GlowTransform;
s_a12 = 0;
s_a13 = 0;
s_a21 = 0;
s_a22 = 1;
s_a23 = 0;
s_rotation = 0;
stored = false; 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() { store() {
this.s_a11 = this.a11; this.s.set(this);
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.stored = true; this.stored = true;
} }
...@@ -63,75 +61,70 @@ class GlowTransform { ...@@ -63,75 +61,70 @@ class GlowTransform {
break; break;
} }
} }
return i; return i;
} }
rot() { rot() {
if (arguments.length === 0) { if (arguments.length === 1 && arguments[0] !== null) {
return this.rotation;
}
if (arguments.length === 1) {
let t = arguments[0]; let t = arguments[0];
return t.rotation + this.rotation; return t.rotation + this.rotation;
} else {
return this.rotation;
} }
} }
x() { x() {
let t, x1, y1; if (arguments.length === 3 && arguments[0] !== null) {
if (arguments.length === 2) { let t = arguments[0];
x1 = arguments[0]; let x1 = arguments[1];
y1 = arguments[1]; let y1 = arguments[2];
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);
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() { y() {
let t, x1, y1; if (arguments.length === 3 && arguments[0] !== null) {
if (arguments.length === 2) { let t = arguments[0];
x1 = arguments[0]; let x1 = arguments[1];
y1 = arguments[1]; let y1 = arguments[2];
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);
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(); let tmp = new GlowTransform();
tmp.a11 = this.a11 * p.a11 + this.a12 * p.a21; tmp.a11 = a.a11 * b.a11 + a.a12 * b.a21;
tmp.a12 = this.a11 * p.a12 + this.a12 * p.a22; tmp.a12 = a.a11 * b.a12 + a.a12 * b.a22;
tmp.a13 = this.a11 * p.a13 + this.a12 * p.a23 + this.a13; tmp.a13 = a.a11 * b.a13 + a.a12 * b.a23 + a.a13;
tmp.a21 = this.a21 * p.a11 + this.a22 * p.a21; tmp.a21 = a.a21 * b.a11 + a.a22 * b.a21;
tmp.a22 = this.a21 * p.a12 + this.a22 * p.a22; tmp.a22 = a.a21 * b.a12 + a.a22 * b.a22;
tmp.a23 = this.a21 * p.a13 + this.a22 * p.a23 + this.a23; tmp.a23 = a.a21 * b.a13 + a.a22 * b.a23 + a.a23;
tmp.rotation = this.rotation + p.rotation; tmp.rotation = a.rotation + b.rotation;
return tmp; return tmp;
} }
set_from_stored(t) { set_from_stored(t) {
this.a11 = t.a11 * this.s_a11 + t.a12 * this.s_a21; this.set(GlowTransform.multiply(t, this.s));
this.a12 = t.a11 * this.s_a12 + t.a12 * this.s_a22; this.a11 = t.a11 * this.s.a11 + t.a12 * this.s.a21;
this.a13 = t.a11 * this.s_a13 + t.a12 * this.s_a23 + t.a13; this.a12 = t.a11 * this.s.a12 + t.a12 * this.s.a22;
this.a21 = t.a21 * this.s_a11 + t.a22 * this.s_a21; this.a13 = t.a11 * this.s.a13 + t.a12 * this.s.a23 + t.a13;
this.a22 = t.a21 * this.s_a12 + t.a22 * this.s_a22; this.a21 = t.a21 * this.s.a11 + t.a22 * this.s.a21;
this.a23 = t.a21 * this.s_a13 + t.a22 * this.s_a23 + t.a23; this.a22 = t.a21 * this.s.a12 + t.a22 * this.s.a22;
this.rotation = this.s_rotation + t.rotation; 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) { scale(sx, sy, x0, y0) {
...@@ -144,12 +137,12 @@ class GlowTransform { ...@@ -144,12 +137,12 @@ class GlowTransform {
} }
scale_from_stored(sx, sy, x0, y0) { scale_from_stored(sx, sy, x0, y0) {
this.a13 = this.s_a13 * sx + x0 * (1 - sx); this.a13 = this.s.a13 * sx + x0 * (1 - sx);
this.a23 = this.s_a23 * sy + y0 * (1 - sy); this.a23 = this.s.a23 * sy + y0 * (1 - sy);
this.a11 = this.s_a11 * sx; this.a11 = this.s.a11 * sx;
this.a12 = this.s_a12 * sx; this.a12 = this.s.a12 * sx;
this.a21 = this.s_a21 * sy; this.a21 = this.s.a21 * sy;
this.a22 = this.s_a22 * sy; this.a22 = this.s.a22 * sy;
} }
rotate(angle, x0, y0) { rotate(angle, x0, y0) {
...@@ -186,23 +179,23 @@ class GlowTransform { ...@@ -186,23 +179,23 @@ class GlowTransform {
rotate_from_stored(angle, x0, y0) { rotate_from_stored(angle, x0, y0) {
let sin_a; let sin_a;
let cos_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; sin_a = -1.0;
cos_a = 0.0; cos_a = 0.0;
} else { } else {
sin_a = Math.sin((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); cos_a = Math.cos((this.s.rotation + angle) / 180 * 3.14159);
} }
this.a11 = this.s_a11 * cos_a - this.s_a21 * 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.a12 = this.s.a12 * cos_a - this.s.a22 * sin_a;
this.a13 = this.a13 =
this.s_a13 * cos_a - this.s_a23 * sin_a + x0 * (1 - cos_a) + y0 * sin_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.a21 = this.s.a11 * sin_a + this.s.a21 * cos_a;
this.a22 = this.s_a21 * sin_a + this.s_a22 * cos_a; this.a22 = this.s.a21 * sin_a + this.s.a22 * cos_a;
this.a23 = this.a23 =
this.s_a13 * sin_a + this.s_a23 * cos_a + y0 * (1 - cos_a) - x0 * sin_a; this.s.a13 * sin_a + this.s.a23 * cos_a + y0 * (1 - cos_a) - x0 * sin_a;
this.rotation = this.s_rotation + angle; this.rotation = this.s.rotation + angle;
} }
move(x0, y0) { move(x0, y0) {
...@@ -211,8 +204,8 @@ class GlowTransform { ...@@ -211,8 +204,8 @@ class GlowTransform {
} }
move_from_stored(x0, y0) { move_from_stored(x0, y0) {
this.a13 = this.s_a13 + x0; this.a13 = this.s.a13 + x0;
this.a23 = this.s_a23 + y0; this.a23 = this.s.a23 + y0;
} }
posit(x0, y0) { posit(x0, y0) {
...@@ -245,7 +238,7 @@ class GlowTransform { ...@@ -245,7 +238,7 @@ class GlowTransform {
return Math.sqrt(this.a12 * this.a12 + this.a22 * this.a22); 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); return Math.sqrt(tmp.a12 * tmp.a12 + tmp.a22 * tmp.a22);
} }
......
class GrowAnnot { class GrowAnnot extends GlowAnnot {
ctx: GrowCtx;
p: GlowPoint;
trf: GlowTransform; trf: GlowTransform;
adjustment; adjustment;
number;
draw_type;
color_drawtype;
text_size;
display_level;
annot_type;
font;
protect;
constructor(ctx) { constructor(ctx) {
this.ctx = ctx; super(ctx);
this.p = new GlowPoint();
this.trf = new GlowTransform(); this.trf = new GlowTransform();
} }
...@@ -24,15 +13,10 @@ class GrowAnnot { ...@@ -24,15 +13,10 @@ class GrowAnnot {
open(lines, row) { open(lines, row) {
let i; let i;
for (i = row; i < lines.length; i++) { for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' '); let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10); let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GrowArc : " + lines[i]);
}
switch (key) { switch (key) {
case GlowSave.GrowAnnot: case GlowSave.GrowAnnot:
break; break;
...@@ -40,7 +24,7 @@ class GrowAnnot { ...@@ -40,7 +24,7 @@ class GrowAnnot {
this.adjustment = parseInt(tokens[1], 10); this.adjustment = parseInt(tokens[1], 10);
break; break;
case GlowSave.GrowAnnot_annot_part: case GlowSave.GrowAnnot_annot_part:
i = this.glowannot_open(lines, i + 1); i = super.open(lines, i + 1);
break; break;
case GlowSave.GrowAnnot_trf: case GlowSave.GrowAnnot_trf:
i = this.trf.open(lines, i + 1); i = this.trf.open(lines, i + 1);
...@@ -56,64 +40,7 @@ class GrowAnnot { ...@@ -56,64 +40,7 @@ class GrowAnnot {
return i; return i;
} }
glowannot_open(lines, row) { draw(t = null, highlight = 0, hot = 0, node = null, colornode = null) {
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;
if (this.ctx.nodraw !== 0) { if (this.ctx.nodraw !== 0) {
return; return;
} }
...@@ -122,10 +49,6 @@ class GrowAnnot { ...@@ -122,10 +49,6 @@ class GrowAnnot {
return; return;
} }
let color;
let rot;
let offset_x = 0;
let offset_y = 0;
let trf_scale = this.trf.vertical_scale(t); let trf_scale = this.trf.vertical_scale(t);
let idx = Math.floor(trf_scale * this.ctx.mw.zoom_factor_y / let idx = Math.floor(trf_scale * this.ctx.mw.zoom_factor_y /
this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 3); this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 3);
...@@ -136,14 +59,14 @@ class GrowAnnot { ...@@ -136,14 +59,14 @@ class GrowAnnot {
} }
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let lfont; let offset_x = 0;
let ldraw_type; let offset_y = 0;
if (node !== null && node.annot_scrollingtext === this.number) { if (node !== null && node.annot_scrollingtext === this.number) {
offset_x = node.annot_offset_x; offset_x = node.annot_offset_x;
offset_y = node.annot_offset_y; offset_y = node.annot_offset_y;
} }
let lfont, ldraw_type;
if (node !== null && node.text_font !== Font.No) { if (node !== null && node.text_font !== Font.No) {
lfont = node.text_font; lfont = node.text_font;
ldraw_type = node.text_type; ldraw_type = node.text_type;
...@@ -152,19 +75,11 @@ class GrowAnnot { ...@@ -152,19 +75,11 @@ class GrowAnnot {
ldraw_type = this.draw_type; ldraw_type = this.draw_type;
} }
if (t === null) { let x1 = Math.floor((this.trf.x(t, this.p.x, this.p.y) + offset_x) *
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; 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) * 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; this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
rot = Math.floor(this.trf.rot()); let rot = Math.floor(this.trf.rot(t));
} else {
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) *
this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
rot = Math.floor(this.trf.rot(t));
}
rot = rot < 0 ? rot % 360 + 360 : rot % 360; rot = rot < 0 ? rot % 360 + 360 : rot % 360;
switch (this.annot_type) { switch (this.annot_type) {
...@@ -173,7 +88,7 @@ class GrowAnnot { ...@@ -173,7 +88,7 @@ class GrowAnnot {
let height = 0; let height = 0;
let descent = 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); DrawType.LineHighlight, highlight, colornode, 2, 0);
if (((rot < 45 || rot >= 315) && if (((rot < 45 || rot >= 315) &&
...@@ -181,23 +96,16 @@ class GrowAnnot { ...@@ -181,23 +96,16 @@ class GrowAnnot {
0)) || (!(rot < 45 || rot >= 315)) || 0)) || (!(rot < 45 || rot >= 315)) ||
this.adjustment === Adjustment.Right || this.adjustment === Adjustment.Right ||
this.adjustment === Adjustment.Center) { this.adjustment === Adjustment.Center) {
let d = this.getTextExtent(t, node); let p = this.getTextExtent(t, node);
width = d.width; width = p.x;
height = d.height; height = p.y;
descent = height / 4; descent = height / 4;
} }
switch (this.adjustment) { if (this.adjustment == Adjustment.Right) {
case Adjustment.Left: x1 -= width;
break; } else if (this.adjustment == Adjustment.Center) {
case Adjustment.Right: x1 -= width / 2;
x1 -= width;
break;
case Adjustment.Center:
x1 -= width / 2;
break;
default:
break;
} }
if (rot < 45 || rot >= 315) { if (rot < 45 || rot >= 315) {
...@@ -210,21 +118,21 @@ class GrowAnnot { ...@@ -210,21 +118,21 @@ class GrowAnnot {
// Text is rotated, adjust the coordinates // Text is rotated, adjust the coordinates
if (this.adjustment === Adjustment.Center) { if (this.adjustment === Adjustment.Center) {
// Only center adjustment supports text rotation // Only center adjustment supports text rotation
if (45 <= rot && rot < 135) { if (rot >= 45 && rot < 135) {
x1 += width / 2; x1 += width / 2;
y1 += width / 2; y1 += width / 2;
} else if (135 <= rot && rot < 225) { } else if (rot >= 135 && rot < 225) {
y1 += height - descent; y1 += height - descent;
} else if (225 <= rot && rot < 315) { } else if (rot >= 225 && rot < 315) {
x1 += width / 2 - height + descent; x1 += width / 2 - height + descent;
y1 -= width / 2 - height + descent; y1 -= width / 2 - height + descent;
} else { } else {
x1 -= width; x1 -= width;
} }
} else { } else {
if (45 <= rot && rot < 135) { if (rot >= 45 && rot < 135) {
y1 += height - descent; y1 += height - descent;
} else if (135 <= rot && rot < 225) { } else if (rot >= 135 && rot < 225) {
x1 -= width; x1 -= width;
y1 += height - descent; y1 += height - descent;
} else { } else {
...@@ -244,34 +152,23 @@ class GrowAnnot { ...@@ -244,34 +152,23 @@ class GrowAnnot {
} }
} }
getTextExtent(t, node) { getTextExtent(t, node): Point {
let dim = new Rect();
if (node.annotv[this.number] === null || node.annotv[this.number] === "") { if (node.annotv[this.number] === null || node.annotv[this.number] === "") {
dim.width = 0; return new Point();
dim.height = 0;
return dim;
} }
let z_width, z_height, descent;
let trf_scale = this.trf.vertical_scale(t); let trf_scale = this.trf.vertical_scale(t);
let idx = Math.floor(trf_scale * this.ctx.mw.zoom_factor_y / let idx = Math.floor(trf_scale * this.ctx.mw.zoom_factor_y /
this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 4); this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 4);
let tsize = trf_scale * this.ctx.mw.zoom_factor_y / let tsize = trf_scale * this.ctx.mw.zoom_factor_y /
this.ctx.mw.base_zoom_factor * (8 + 2 * this.text_size); this.ctx.mw.base_zoom_factor * (8 + 2 * this.text_size);
if (idx < 0) { if (idx < 0) {
dim.width = 0; return new Point();
dim.height = 0;
return dim;
} }
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); 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); this.font, this.draw_type);
dim.width = d.width;
dim.height = d.height;
return dim;
} }
event_handler(event, fx, fy) { event_handler(event, fx, fy) {
......
This diff is collapsed.
This diff is collapsed.
...@@ -33,15 +33,10 @@ class GrowAxisArc extends GrowArc { ...@@ -33,15 +33,10 @@ class GrowAxisArc extends GrowArc {
open(lines, row) { open(lines, row) {
let i; let i;
for (i = row; i < lines.length; i++) { for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' '); let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10); let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GrowAxisArc : " + lines[i]);
}
switch (key) { switch (key) {
case GlowSave.GrowAxisArc: case GlowSave.GrowAxisArc:
break; break;
...@@ -108,27 +103,22 @@ class GrowAxisArc extends GrowArc { ...@@ -108,27 +103,22 @@ class GrowAxisArc extends GrowArc {
return i; return i;
} }
tdraw(t, highlight, hot, node, colornode) { draw(t = null, highlight = 0, hot = 0, node = null, colornode = null) {
if (this.ctx.nodraw !== 0) { if (this.ctx.nodraw !== 0) {
return; return;
} }
let i;
let draw_text = (Math.abs(this.increment) > Number.MIN_VALUE); let draw_text = (Math.abs(this.increment) > Number.MIN_VALUE);
let idx;
let x, y;
let text;
let line_length; let line_length;
let x_text, y_text; let x_text;
let z_height = 0, z_width, z_descent = 0; let z_height = 0, z_width, z_descent = 0;
let max_z_width = 0; let max_z_width = 0;
let rotation;
let drawtype;
let text_idx = Math.floor(this.ctx.mw.zoom_factor_y / let text_idx = Math.floor(this.ctx.mw.zoom_factor_y /
this.ctx.mw.base_zoom_factor * (this.text_size + 4) - 4); 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 * let tsize = this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor *
(8 + 2 * this.text_size); (8 + 2 * this.text_size);
text_idx = Math.min(text_idx, DRAW_TYPE_SIZE - 1); text_idx = Math.min(text_idx, DRAW_TYPE_SIZE - 1);
let idx;
if (node !== null && node.line_width !== 0) { if (node !== null && node.line_width !== 0) {
idx = idx =
Math.floor(this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor * Math.floor(this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor *
...@@ -142,37 +132,23 @@ class GrowAxisArc extends GrowArc { ...@@ -142,37 +132,23 @@ class GrowAxisArc extends GrowArc {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); 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) { let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
x1 = Math.floor(this.trf.x(this.ll.x, this.ll.y) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; 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; 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; 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; this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
rotation = let 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 =
(this.trf.rot(t) / 360 - Math.floor(this.trf.rot(t) / 360)) * 360; (this.trf.rot(t) / 360 - Math.floor(this.trf.rot(t) / 360)) * 360;
}
ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
ll_y = Math.min(y1, y2); let ll_y = Math.min(y1, y2);
ur_y = Math.max(y1, y2); let ur_y = Math.max(y1, y2);
drawtype = let drawtype =
GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight, GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight,
highlight, colornode, 0, 0); highlight, colornode, 0, 0);
...@@ -185,23 +161,24 @@ class GrowAxisArc extends GrowArc { ...@@ -185,23 +161,24 @@ class GrowAxisArc extends GrowArc {
return; return;
} }
let text;
if (this.increment > 0) { if (this.increment > 0) {
text = this.format_text(this.format, this.min_value + (this.lines - 2) * text = this.format_text(this.format, this.min_value + (this.lines - 2) *
this.increment); this.increment);
} else { } else {
text = this.format_text(this.format, this.min_value + this.increment); 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); Font.Helvetica, this.text_drawtype);
z_width = d.width; z_width = p.x;
z_height = d.height; z_height = p.y;
z_descent = z_height / 4; z_descent = z_height / 4;
if (max_z_width < z_width) { if (max_z_width < z_width) {
max_z_width = z_width; max_z_width = z_width;
} }
let line_angle = this.angle2 / (this.lines - 1); 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 sin1 = Math.sin((this.angle1 + i * line_angle) / 180 * Math.PI);
let cos1 = Math.cos((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); y1 = Math.floor((ur_y - ll_y) / 2 * (-sin1 + 1) + ll_y);
...@@ -217,10 +194,10 @@ class GrowAxisArc extends GrowArc { ...@@ -217,10 +194,10 @@ class GrowAxisArc extends GrowArc {
x2 = Math.floor((ur_x - ll_x) / 2 * x2 = Math.floor((ur_x - ll_x) / 2 *
(cos1 * (1.0 - this.linelength / 2) + 1) + ll_x); (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) + Math.floor((ur_y - ll_y) / 2 * (-sin1 * (1.0 - this.linelength) + 1) +
ll_y + sin1 * (z_height - z_descent) / 2); ll_y + sin1 * (z_height - z_descent) / 2);
xt = let xt =
Math.floor((ur_x - ll_x) / 2 * (cos1 * (1.0 - this.linelength) + 1) + Math.floor((ur_x - ll_x) / 2 * (cos1 * (1.0 - this.linelength) + 1) +
ll_x - cos1 * z_width / 2); ll_x - cos1 * z_width / 2);
...@@ -232,10 +209,10 @@ class GrowAxisArc extends GrowArc { ...@@ -232,10 +209,10 @@ class GrowAxisArc extends GrowArc {
(this.increment < 0 && i === 0)))) { (this.increment < 0 && i === 0)))) {
text = this.format_text(this.format, this.min_value + i * text = this.format_text(this.format, this.min_value + i *
this.increment); 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); Font.Helvetica, this.text_drawtype);
z_width = d.width; z_width = p.x;
z_height = d.height; z_height = p.y;
z_descent = z_height / 4; z_descent = z_height / 4;
if (max_z_width < z_width) { if (max_z_width < z_width) {
max_z_width = z_width; max_z_width = z_width;
...@@ -243,12 +220,12 @@ class GrowAxisArc extends GrowArc { ...@@ -243,12 +220,12 @@ class GrowAxisArc extends GrowArc {
if (i === this.lines - 1 && this.angle1 === 0 && if (i === this.lines - 1 && this.angle1 === 0 &&
this.angle2 === 180) { this.angle2 === 180) {
xt = xt - z_width / 2; xt -= z_width / 2;
} else if (i === 0 && this.angle1 === 0 && this.angle2 !== 360) { } else if (i === 0 && this.angle1 === 0 && this.angle2 !== 360) {
xt = xt - z_width / 2; xt -= z_width / 2;
} else { } else {
yt = yt + (z_height - z_descent) / 2; yt += (z_height - z_descent) / 2;
xt = xt - z_width / 2; xt -= z_width / 2;
} }
this.ctx.gdraw.text(xt, yt, text, this.text_drawtype, this.ctx.gdraw.text(xt, yt, text, this.text_drawtype,
this.text_color_drawtype, text_idx, highlight, 0, this.text_color_drawtype, text_idx, highlight, 0,
...@@ -286,29 +263,18 @@ class GrowAxisArc extends GrowArc { ...@@ -286,29 +263,18 @@ class GrowAxisArc extends GrowArc {
360; 360;
if (keep_settings === 0) { if (keep_settings === 0) {
let len;
let lix;
let di;
let horizontal = (rotation < 45 || (rotation > 135 && rotation < 225) || let horizontal = (rotation < 45 || (rotation > 135 && rotation < 225) ||
rotation > 315) ? 0 : 1; rotation > 315) ? 0 : 1;
if (horizontal === 0) { let len = (horizontal === 0) ? Math.abs(y2 - y1) : Math.abs(x2 - x1);
len = Math.abs(y2 - y1);
} else {
len = Math.abs(x2 - x1);
}
if (len < 150) { let lix = Number(!(len < 150));
lix = 0;
} else {
lix = 1;
}
let d = Math.abs(maxval - minval); let d = Math.abs(maxval - minval);
if (d < 5) { if (d < 5) {
d = 1000 * d; d = 1000 * d;
} }
di = Math.floor(d + 0.5); let di = Math.floor(d + 0.5);
while (di >= 25) { while (di >= 25) {
di /= 10; di /= 10;
} }
...@@ -324,51 +290,24 @@ class GrowAxisArc extends GrowArc { ...@@ -324,51 +290,24 @@ class GrowAxisArc extends GrowArc {
} }
let m = Math.max(Math.abs(maxval), Math.abs(minval)); let m = Math.max(Math.abs(maxval), Math.abs(minval));
switch (lix) { if (m < 0.01) {
case 0: this.format = "%g";
if (m < 0.01) { } else if (m < 0.1) {
this.format = "%g"; this.format = "%5.3f";
} else if (m < 0.1) { } else if (m < 1) {
this.format = "%5.3f"; this.format = "%4.2f";
} else if (m < 1) { } else if ((lix === 0 && m < 3) || (lix === 1 && m <= 4)) {
this.format = "%4.2f"; this.format = "%3.1f";
} else if (m < 3) { } else if (m <= 20) {
this.format = "%3.1f"; this.format = "%2.0f";
} else if (m <= 20) { } else if (m <= 200) {
this.format = "%2.0f"; this.format = "%3.0f";
} else if (m <= 200) { } else if (m < 2000) {
this.format = "%3.0f"; this.format = "%4.0f";
} else if (m < 2000) { } else if (m < 20000) {
this.format = "%4.0f"; this.format = "%5.0f";
} else if (m < 20000) { } else {
this.format = "%5.0f"; this.format = "%g";
} 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) {
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;
default:
break;
} }
} }
this.configure(); this.configure();
......
...@@ -13,15 +13,10 @@ class GrowBar extends GrowRect { ...@@ -13,15 +13,10 @@ class GrowBar extends GrowRect {
open(lines, row) { open(lines, row) {
let i; let i;
for (i = row; i < lines.length; i++) { for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' '); let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10); let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GrowBar : " + lines[i]);
}
switch (key) { switch (key) {
case GlowSave.GrowBar: case GlowSave.GrowBar:
break; break;
...@@ -77,17 +72,15 @@ class GrowBar extends GrowRect { ...@@ -77,17 +72,15 @@ class GrowBar extends GrowRect {
break; break;
} }
} }
return i; return i;
} }
tdraw(t, highlight, hot, node, colornode) { draw(t = null, highlight = 0, hot = 0, node = null, colornode = null) {
if (this.ctx.nodraw !== 0) { if (this.ctx.nodraw !== 0) {
return; return;
} }
let idx;
let drawtype;
let rotation;
let grad = this.gradient; let grad = this.gradient;
if (this.gradient === Gradient.No && if (this.gradient === Gradient.No &&
(node !== null && node.gradient !== Gradient.No) && (node !== null && node.gradient !== Gradient.No) &&
...@@ -100,6 +93,7 @@ class GrowBar extends GrowRect { ...@@ -100,6 +93,7 @@ class GrowBar extends GrowRect {
bar_border_idx = bar_border_idx =
Math.min(DRAW_TYPE_SIZE - 1, Math.max(0, bar_border_idx)); Math.min(DRAW_TYPE_SIZE - 1, Math.max(0, bar_border_idx));
let idx;
if (node !== null && node.line_width !== 0) { if (node !== null && node.line_width !== 0) {
idx = idx =
Math.floor(this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor * Math.floor(this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor *
...@@ -113,34 +107,22 @@ class GrowBar extends GrowRect { ...@@ -113,34 +107,22 @@ class GrowBar extends GrowRect {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1, y1, x2, y2, ll_x, ll_y, ur_x, ur_y;
if (t === null) { let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
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;
} 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; 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; 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; 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; this.ctx.mw.zoom_factor_y) - this.ctx.mw.offset_y;
}
ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
ll_y = Math.min(y1, y2); let ll_y = Math.min(y1, y2);
ur_y = Math.max(y1, y2); let ur_y = Math.max(y1, y2);
if (this.fill !== 0) { if (this.fill !== 0) {
drawtype = let drawtype =
GlowColor.get_drawtype(this.fill_drawtype, DrawType.FillHighlight, GlowColor.get_drawtype(this.fill_drawtype, DrawType.FillHighlight,
highlight, colornode, 1, 0); highlight, colornode, 1, 0);
...@@ -148,13 +130,9 @@ class GrowBar extends GrowRect { ...@@ -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, this.ctx.gdraw.fill_rect(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y,
drawtype); drawtype);
} else { } else {
let fa1, fa2; let rotation = (t) ? this.trf.rot(t) : this.trf.rot();
if (t === null) { let fa1, fa2;
rotation = this.trf.rot();
} else {
rotation = this.trf.rot(t);
}
if (this.gradient_contrast >= 0) { if (this.gradient_contrast >= 0) {
fa2 = GlowColor.shift_drawtype(drawtype, -this.gradient_contrast / 2, fa2 = GlowColor.shift_drawtype(drawtype, -this.gradient_contrast / 2,
null); null);
...@@ -170,64 +148,49 @@ class GrowBar extends GrowRect { ...@@ -170,64 +148,49 @@ class GrowBar extends GrowRect {
drawtype, fa1, fa2, this.ctx.gdraw.gradient_rotate(rotation, grad)); drawtype, fa1, fa2, this.ctx.gdraw.gradient_rotate(rotation, grad));
} }
} }
drawtype = let drawtype =
GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight, GlowColor.get_drawtype(this.draw_type, DrawType.LineHighlight,
highlight, colornode, 0, 0); highlight, colornode, 0, 0);
if (this.max_value !== this.min_value) { if (this.max_value !== this.min_value) {
let x0, y0, width, height, l_x0, l_y0, l_x1, l_y1; let x0, y0, width, height, l_x0, l_y0, l_x1, l_y1;
if (t === null) { let rotation = (t) ? this.trf.rot(t) : this.trf.rot();
rotation = rotation = (rotation / 360 - Math.floor(rotation / 360)) * 360;
(this.trf.rot() / 360 - Math.floor(this.trf.rot() / 360)) * 360; x0 = ll_x;
} else { y0 = ll_y;
rotation = width = ur_x - ll_x;
(this.trf.rot(t) / 360 - Math.floor(this.trf.rot(t) / 360)) * 360; height = ur_y - ll_y;
} l_x0 = ll_x;
if (45 >= rotation || rotation > 315) { 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) / height = Math.floor((this.bar_value - this.min_value) /
(this.max_value - this.min_value) * (ur_y - ll_y)); (this.max_value - this.min_value) * (ur_y - ll_y));
height = Math.max(0, Math.min(height, 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; y0 = ur_y - height;
l_x0 = ll_x;
l_y0 = ur_y - height; l_y0 = ur_y - height;
l_x1 = ur_x;
l_y1 = ur_y - height; 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) / width = Math.floor((this.bar_value - this.min_value) /
(this.max_value - this.min_value) * (ur_x - ll_x)); (this.max_value - this.min_value) * (ur_x - ll_x));
width = Math.max(0, Math.min(width, 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_x0 = ll_x + width;
l_y0 = ll_y;
l_x1 = ll_x + width; l_x1 = ll_x + width;
l_y1 = ur_y; } else if (rotation > 135 && rotation <= 225) {
} else if (135 < rotation && rotation <= 225) {
height = Math.floor((this.bar_value - this.min_value) / height = Math.floor((this.bar_value - this.min_value) /
(this.max_value - this.min_value) * (ur_y - ll_y)); (this.max_value - this.min_value) * (ur_y - ll_y));
height = Math.max(0, Math.min(height, 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_y0 = ll_y + height;
l_x1 = ur_x;
l_y1 = ll_y + height; l_y1 = ll_y + height;
} else { // if ( 225 < rotation && rotation <= 315) } else { // if ( 225 < rotation && rotation <= 315)
width = Math.floor((this.bar_value - this.min_value) / width = Math.floor((this.bar_value - this.min_value) /
(this.max_value - this.min_value) * (ur_x - ll_x)); (this.max_value - this.min_value) * (ur_x - ll_x));
width = Math.max(0, Math.min(width, ur_x - ll_x)); width = Math.max(0, Math.min(width, ur_x - ll_x));
height = ur_y - ll_y;
x0 = ur_x - width; x0 = ur_x - width;
y0 = ll_y;
l_x0 = ur_x - width; l_x0 = ur_x - width;
l_y0 = ll_y;
l_x1 = ur_x - width; l_x1 = ur_x - width;
l_y1 = ur_y;
} }
let dt = drawtype; let dt = drawtype;
...@@ -238,13 +201,9 @@ class GrowBar extends GrowRect { ...@@ -238,13 +201,9 @@ class GrowBar extends GrowRect {
if (grad === Gradient.No) { if (grad === Gradient.No) {
this.ctx.gdraw.fill_rect(x0, y0, width, height, dt); this.ctx.gdraw.fill_rect(x0, y0, width, height, dt);
} else { } else {
let fb1, fb2; rotation = (t) ? this.trf.rot(t) : this.trf.rot();
if (t === null) { let fb1, fb2;
rotation = this.trf.rot();
} else {
rotation = this.trf.rot(t);
}
if (this.gradient_contrast >= 0) { if (this.gradient_contrast >= 0) {
fb2 = GlowColor.shift_drawtype(dt, -this.gradient_contrast / 2, null); fb2 = GlowColor.shift_drawtype(dt, -this.gradient_contrast / 2, null);
fb1 = GlowColor.shift_drawtype(dt, fb1 = GlowColor.shift_drawtype(dt,
......
...@@ -15,15 +15,10 @@ class GrowBarArc extends GrowArc { ...@@ -15,15 +15,10 @@ class GrowBarArc extends GrowArc {
open(lines, row) { open(lines, row) {
let i; let i;
for (i = row; i < lines.length; i++) { for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' '); let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10); let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GrowBarArc : " + lines[i]);
}
switch (key) { switch (key) {
case GlowSave.GrowBarArc: case GlowSave.GrowBarArc:
break; break;
...@@ -69,24 +64,20 @@ class GrowBarArc extends GrowArc { ...@@ -69,24 +64,20 @@ class GrowBarArc extends GrowArc {
break; break;
} }
} }
return i; return i;
} }
tdraw(t, highlight, hot, node, colornode) { draw(t = null, highlight = 0, hot = 0, node = null, colornode = null) {
if (this.ctx.nodraw !== 0) { if (this.ctx.nodraw !== 0) {
return; 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 width = Math.floor(this.bar_width * this.ctx.mw.zoom_factor_x);
let value = Math.max(this.min_value, let value = Math.max(this.min_value,
Math.min(this.bar_value, this.max_value)); Math.min(this.bar_value, this.max_value));
let idx;
if (node !== null && node.line_width !== 0) { if (node !== null && node.line_width !== 0) {
idx = idx =
Math.floor(this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor * Math.floor(this.ctx.mw.zoom_factor_y / this.ctx.mw.base_zoom_factor *
...@@ -100,50 +91,31 @@ class GrowBarArc extends GrowArc { ...@@ -100,50 +91,31 @@ class GrowBarArc extends GrowArc {
idx = Math.max(0, idx); idx = Math.max(0, idx);
idx = Math.min(idx, DRAW_TYPE_SIZE - 1); idx = Math.min(idx, DRAW_TYPE_SIZE - 1);
let x1, y1, x2, y2, ll_x, ll_y, ur_x, ur_y;
if (t === null) { let x1 = Math.floor(this.trf.x(t, this.ll.x, this.ll.y) *
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) *
this.ctx.mw.zoom_factor_x) - this.ctx.mw.offset_x; 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; 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; 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; 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; (this.trf.rot(t) / 360 - Math.floor(this.trf.rot(t) / 360)) * 360;
}
ll_x = Math.min(x1, x2); let ll_x = Math.min(x1, x2);
ur_x = Math.max(x1, x2); let ur_x = Math.max(x1, x2);
ll_y = Math.min(y1, y2); let ll_y = Math.min(y1, y2);
ur_y = Math.max(y1, y2); let ur_y = Math.max(y1, y2);
let yscale = (ur_y - ll_y) / (ur_x - ll_x);
yscale = (ur_y - ll_y) / (ur_x - ll_x);
if (width > ur_x - ll_x) { if (width > ur_x - ll_x) {
width = ur_x - ll_x; width = ur_x - ll_x;
} }
drawtype = let drawtype =
GlowColor.get_drawtype(this.fill_drawtype, DrawType.FillHighlight, GlowColor.get_drawtype(this.fill_drawtype, DrawType.FillHighlight,
highlight, colornode, 1, 0); highlight, colornode, 1, 0);
if (this.background_drawtype === DrawType.No) { let bg_drawtype = (this.background_drawtype === DrawType.No) ? this.ctx.background_color : this.background_drawtype;
bg_drawtype = this.ctx.background_color;
} else {
bg_drawtype = this.background_drawtype;
}
// Draw circle background // Draw circle background
this.ctx.gdraw.fill_arc(ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, 0, 360, 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 { ...@@ -154,11 +126,9 @@ class GrowBarArc extends GrowArc {
Math.floor(rotation), this.angle2, drawtype); Math.floor(rotation), this.angle2, drawtype);
// Draw bar // Draw bar
if (this.bar_direction === 0) { let ang = this.angle1 - rotation;
ang = this.angle1 - rotation; if (this.bar_direction !== 0) {
} else { ang += this.angle2 * (this.max_value - value) / (this.max_value - this.min_value);
ang = this.angle1 + this.angle2 * (this.max_value - value) /
(this.max_value - this.min_value) - rotation;
} }
if (this.gradient === Gradient.No) { if (this.gradient === Gradient.No) {
...@@ -167,7 +137,6 @@ class GrowBarArc extends GrowArc { ...@@ -167,7 +137,6 @@ class GrowBarArc extends GrowArc {
(this.max_value - this.min_value), this.bar_drawtype); (this.max_value - this.min_value), this.bar_drawtype);
} else { } else {
let f1, f2; let f1, f2;
if (this.gradient_contrast >= 0) { if (this.gradient_contrast >= 0) {
f2 = f2 =
GlowColor.shift_drawtype(this.bar_drawtype, -this.gradient_contrast / 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 { ...@@ -5,15 +5,10 @@ class GrowGroup extends GrowNode {
open(lines, row) { open(lines, row) {
let i; let i;
for (i = row; i < lines.length; i++) { for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' '); let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10); let key = parseInt(tokens[0], 10);
if (this.ctx.debug) {
console.log("GrowGroup : " + lines[i]);
}
switch (key) { switch (key) {
case GlowSave.GrowGroup: case GlowSave.GrowGroup:
break; break;
...@@ -36,12 +31,9 @@ class GrowGroup extends GrowNode { ...@@ -36,12 +31,9 @@ class GrowGroup extends GrowNode {
} }
get_object_group(object) { get_object_group(object) {
let sts;
let group;
for (let i = 0; i < this.nc.a.size(); i++) { for (let i = 0; i < this.nc.a.size(); i++) {
if (this.nc.a.get(i) instanceof GrowGroup) { 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) { if (group !== null) {
return group; 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.
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.
...@@ -433,7 +433,8 @@ class JopCrypt { ...@@ -433,7 +433,8 @@ class JopCrypt {
JopCrypt.intToFourBytes(out[1], b, 4); JopCrypt.intToFourBytes(out[1], b, 4);
b[8] = 0; 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++) { for (let j = 0, c = 0; j < 6; j++) {
c <<= 1; 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