1
/***************************************************************************
5
copyright : (C) 2006 The University of Toronto
7
***************************************************************************/
9
/***************************************************************************
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
16
***************************************************************************/
18
#include "bind_axis.h"
19
#include "bind_timeinterpretation.h"
22
#include <kstdatacollection.h>
23
#include <kstplotlabel.h>
26
#include <kjsembed/jsbinding.h>
28
KstBindAxis::KstBindAxis(KJS::ExecState *exec, Kst2DPlotPtr d, bool isX)
29
: QObject(), KstBinding("Axis", false), _d(d.data()), _xAxis(isX) {
35
KstBindAxis::KstBindAxis(int id)
36
: QObject(), KstBinding("Axis Method", id) {
40
KstBindAxis::~KstBindAxis() {
46
KJS::Value (KstBindAxis::*method)(KJS::ExecState*, const KJS::List&);
50
struct AxisProperties {
52
void (KstBindAxis::*set)(KJS::ExecState*, const KJS::Value&);
53
KJS::Value (KstBindAxis::*get)(KJS::ExecState*) const;
57
static AxisBindings axisBindings[] = {
58
{ "scaleAuto", &KstBindAxis::scaleAuto },
59
{ "scaleAutoSpikeInsensitive", &KstBindAxis::scaleAutoSpikeInsensitive },
60
{ "scaleExpression", &KstBindAxis::scaleExpression },
61
{ "scaleRange", &KstBindAxis::scaleRange },
66
static AxisProperties axisProperties[] = {
67
{ "log", &KstBindAxis::setLog, &KstBindAxis::log },
68
{ "suppressed", &KstBindAxis::setSuppressed, &KstBindAxis::suppressed },
69
{ "oppositeSuppressed", &KstBindAxis::setOppositeSuppressed, &KstBindAxis::oppositeSuppressed },
70
{ "offsetMode", &KstBindAxis::setOffsetMode, &KstBindAxis::offsetMode },
71
{ "reversed", &KstBindAxis::setReversed, &KstBindAxis::reversed },
72
{ "majorGridLines", &KstBindAxis::setMajorGridLines, &KstBindAxis::majorGridLines },
73
{ "minorGridLines", &KstBindAxis::setMinorGridLines, &KstBindAxis::minorGridLines },
74
{ "transformation", &KstBindAxis::setTransformation, &KstBindAxis::transformation },
75
{ "innerTicks", &KstBindAxis::setInnerTicks, &KstBindAxis::innerTicks },
76
{ "outerTicks", &KstBindAxis::setOuterTicks, &KstBindAxis::outerTicks },
77
{ "majorGridColor", &KstBindAxis::setMajorGridColor, &KstBindAxis::majorGridColor },
78
{ "minorGridColor", &KstBindAxis::setMinorGridColor, &KstBindAxis::minorGridColor },
79
{ "minorTickCount", &KstBindAxis::setMinorTickCount, &KstBindAxis::minorTickCount },
80
{ "majorTickDensity", &KstBindAxis::setMajorTickDensity, &KstBindAxis::majorTickDensity },
81
{ "scaleMode", 0L, &KstBindAxis::scaleMode },
82
{ "label", &KstBindAxis::setLabel, &KstBindAxis::label },
83
{ "type", 0L, &KstBindAxis::type },
84
{ "interpretation", 0L, &KstBindAxis::interpretation },
89
KJS::ReferenceList KstBindAxis::propList(KJS::ExecState *exec, bool recursive) {
90
KJS::ReferenceList rc = KstBinding::propList(exec, recursive);
92
for (int i = 0; axisProperties[i].name; ++i) {
93
rc.append(KJS::Reference(this, KJS::Identifier(axisProperties[i].name)));
100
bool KstBindAxis::hasProperty(KJS::ExecState *exec, const KJS::Identifier& propertyName) const {
101
QString prop = propertyName.qstring();
102
for (int i = 0; axisProperties[i].name; ++i) {
103
if (prop == axisProperties[i].name) {
108
return KstBinding::hasProperty(exec, propertyName);
112
void KstBindAxis::put(KJS::ExecState *exec, const KJS::Identifier& propertyName, const KJS::Value& value, int attr) {
113
QString prop = propertyName.qstring();
114
for (int i = 0; axisProperties[i].name; ++i) {
115
if (prop == axisProperties[i].name) {
116
if (!axisProperties[i].set) {
119
(this->*axisProperties[i].set)(exec, value);
124
KstBinding::put(exec, propertyName, value, attr);
128
KJS::Value KstBindAxis::get(KJS::ExecState *exec, const KJS::Identifier& propertyName) const {
129
QString prop = propertyName.qstring();
130
for (int i = 0; axisProperties[i].name; ++i) {
131
if (prop == axisProperties[i].name) {
132
if (!axisProperties[i].get) {
135
return (this->*axisProperties[i].get)(exec);
139
return KstBinding::get(exec, propertyName);
143
KJS::Value KstBindAxis::call(KJS::ExecState *exec, KJS::Object& self, const KJS::List& args) {
146
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
147
exec->setException(eobj);
148
return KJS::Undefined();
151
KstBindAxis *imp = dynamic_cast<KstBindAxis*>(self.imp());
153
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
154
exec->setException(eobj);
155
return KJS::Undefined();
158
return (imp->*axisBindings[id - 1].method)(exec, args);
162
void KstBindAxis::addBindings(KJS::ExecState *exec, KJS::Object& obj) {
163
for (int i = 0; axisBindings[i].name != 0L; ++i) {
164
KJS::Object o = KJS::Object(new KstBindAxis(i + 1));
165
obj.put(exec, axisBindings[i].name, o, KJS::Function);
170
KJS::Value KstBindAxis::type(KJS::ExecState *exec) const {
172
return KJS::String(_xAxis ? "X" : "Y");
176
KJS::Value KstBindAxis::label(KJS::ExecState *exec) const {
178
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
179
exec->setException(eobj);
180
return KJS::Undefined();
182
KstReadLocker rl(_d);
184
return KJS::String(_d->xLabel()->text());
186
return KJS::String(_d->yLabel()->text());
191
void KstBindAxis::setLabel(KJS::ExecState *exec, const KJS::Value& value) {
193
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
194
exec->setException(eobj);
197
if (value.type() != KJS::StringType) {
198
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
199
exec->setException(eobj);
202
KstWriteLocker wl(_d);
204
_d->xLabel()->setText(value.toString(exec).qstring());
206
_d->yLabel()->setText(value.toString(exec).qstring());
209
KstApp::inst()->paintAll(KstPainter::P_PAINT);
213
KJS::Value KstBindAxis::transformation(KJS::ExecState *exec) const {
215
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
216
exec->setException(eobj);
217
return KJS::Undefined();
219
KstReadLocker rl(_d);
221
return KJS::String(_d->xTransformedExp());
223
return KJS::String(_d->yTransformedExp());
228
void KstBindAxis::setTransformation(KJS::ExecState *exec, const KJS::Value& value) {
230
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
231
exec->setException(eobj);
234
if (value.type() != KJS::StringType) {
235
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
236
exec->setException(eobj);
239
KstWriteLocker wl(_d);
241
_d->setXTransformedExp(value.toString(exec).qstring());
243
_d->setYTransformedExp(value.toString(exec).qstring());
246
KstApp::inst()->paintAll(KstPainter::P_PAINT);
250
KJS::Value KstBindAxis::log(KJS::ExecState *exec) const {
252
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
253
exec->setException(eobj);
254
return KJS::Undefined();
256
KstReadLocker rl(_d);
258
return KJS::Boolean(_d->isXLog());
260
return KJS::Boolean(_d->isYLog());
265
void KstBindAxis::setLog(KJS::ExecState *exec, const KJS::Value& value) {
267
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
268
exec->setException(eobj);
271
if (value.type() != KJS::BooleanType) {
272
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
273
exec->setException(eobj);
276
KstWriteLocker wl(_d);
278
_d->setLog(value.toBoolean(exec), _d->isYLog());
280
_d->setLog(_d->isXLog(), value.toBoolean(exec));
283
KstApp::inst()->paintAll(KstPainter::P_PAINT);
287
KJS::Value KstBindAxis::majorGridLines(KJS::ExecState *exec) const {
289
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
290
exec->setException(eobj);
291
return KJS::Undefined();
293
KstReadLocker rl(_d);
295
return KJS::Boolean(_d->hasXMajorGrid());
297
return KJS::Boolean(_d->hasYMajorGrid());
302
void KstBindAxis::setMajorGridLines(KJS::ExecState *exec, const KJS::Value& value) {
304
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
305
exec->setException(eobj);
308
if (value.type() != KJS::BooleanType) {
309
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
310
exec->setException(eobj);
313
KstWriteLocker wl(_d);
315
_d->setXGridLines(value.toBoolean(exec), _d->hasXMinorGrid());
317
_d->setYGridLines(value.toBoolean(exec), _d->hasYMinorGrid());
320
KstApp::inst()->paintAll(KstPainter::P_PAINT);
324
KJS::Value KstBindAxis::minorGridLines(KJS::ExecState *exec) const {
326
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
327
exec->setException(eobj);
328
return KJS::Undefined();
330
KstReadLocker rl(_d);
332
return KJS::Boolean(_d->hasXMinorGrid());
334
return KJS::Boolean(_d->hasYMinorGrid());
339
void KstBindAxis::setMinorGridLines(KJS::ExecState *exec, const KJS::Value& value) {
341
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
342
exec->setException(eobj);
345
if (value.type() != KJS::BooleanType) {
346
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
347
exec->setException(eobj);
350
KstWriteLocker wl(_d);
352
_d->setXGridLines(_d->hasXMajorGrid(), value.toBoolean(exec));
354
_d->setYGridLines(_d->hasYMajorGrid(), value.toBoolean(exec));
357
KstApp::inst()->paintAll(KstPainter::P_PAINT);
361
KJS::Value KstBindAxis::reversed(KJS::ExecState *exec) const {
363
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
364
exec->setException(eobj);
365
return KJS::Undefined();
367
KstReadLocker rl(_d);
369
return KJS::Boolean(_d->xReversed());
371
return KJS::Boolean(_d->yReversed());
376
void KstBindAxis::setReversed(KJS::ExecState *exec, const KJS::Value& value) {
378
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
379
exec->setException(eobj);
382
if (value.type() != KJS::BooleanType) {
383
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
384
exec->setException(eobj);
387
KstWriteLocker wl(_d);
389
_d->setXReversed(value.toBoolean(exec));
391
_d->setYReversed(value.toBoolean(exec));
394
KstApp::inst()->paintAll(KstPainter::P_PAINT);
398
KJS::Value KstBindAxis::offsetMode(KJS::ExecState *exec) const {
400
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
401
exec->setException(eobj);
402
return KJS::Undefined();
404
KstReadLocker rl(_d);
406
return KJS::Boolean(_d->xOffsetMode());
408
return KJS::Boolean(_d->yOffsetMode());
413
void KstBindAxis::setOffsetMode(KJS::ExecState *exec, const KJS::Value& value) {
415
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
416
exec->setException(eobj);
419
if (value.type() != KJS::BooleanType) {
420
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
421
exec->setException(eobj);
424
KstWriteLocker wl(_d);
426
_d->setXOffsetMode(value.toBoolean(exec));
428
_d->setYOffsetMode(value.toBoolean(exec));
431
KstApp::inst()->paintAll(KstPainter::P_PAINT);
435
KJS::Value KstBindAxis::suppressed(KJS::ExecState *exec) const {
437
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
438
exec->setException(eobj);
439
return KJS::Undefined();
441
KstReadLocker rl(_d);
443
return KJS::Boolean(_d->suppressBottom());
445
return KJS::Boolean(_d->suppressLeft());
450
void KstBindAxis::setSuppressed(KJS::ExecState *exec, const KJS::Value& value) {
452
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
453
exec->setException(eobj);
456
if (value.type() != KJS::BooleanType) {
457
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
458
exec->setException(eobj);
461
KstWriteLocker wl(_d);
463
_d->setSuppressBottom(value.toBoolean(exec));
465
_d->setSuppressLeft(value.toBoolean(exec));
468
KstApp::inst()->paintAll(KstPainter::P_PAINT);
472
KJS::Value KstBindAxis::oppositeSuppressed(KJS::ExecState *exec) const {
474
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
475
exec->setException(eobj);
476
return KJS::Undefined();
478
KstReadLocker rl(_d);
480
return KJS::Boolean(_d->suppressTop());
482
return KJS::Boolean(_d->suppressRight());
487
void KstBindAxis::setOppositeSuppressed(KJS::ExecState *exec, const KJS::Value& value) {
489
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
490
exec->setException(eobj);
493
if (value.type() != KJS::BooleanType) {
494
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
495
exec->setException(eobj);
498
KstWriteLocker wl(_d);
500
_d->setSuppressTop(value.toBoolean(exec));
502
_d->setSuppressRight(value.toBoolean(exec));
505
KstApp::inst()->paintAll(KstPainter::P_PAINT);
509
KJS::Value KstBindAxis::innerTicks(KJS::ExecState *exec) const {
511
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
512
exec->setException(eobj);
513
return KJS::Undefined();
515
KstReadLocker rl(_d);
517
return KJS::Boolean(_d->xTicksInPlot());
519
return KJS::Boolean(_d->yTicksInPlot());
524
void KstBindAxis::setInnerTicks(KJS::ExecState *exec, const KJS::Value& value) {
526
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
527
exec->setException(eobj);
530
if (value.type() != KJS::BooleanType) {
531
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
532
exec->setException(eobj);
535
KstWriteLocker wl(_d);
537
_d->setXTicksInPlot(value.toBoolean(exec));
539
_d->setYTicksInPlot(value.toBoolean(exec));
542
KstApp::inst()->paintAll(KstPainter::P_PAINT);
546
KJS::Value KstBindAxis::outerTicks(KJS::ExecState *exec) const {
548
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
549
exec->setException(eobj);
550
return KJS::Undefined();
552
KstReadLocker rl(_d);
554
return KJS::Boolean(_d->xTicksOutPlot());
556
return KJS::Boolean(_d->yTicksOutPlot());
561
void KstBindAxis::setOuterTicks(KJS::ExecState *exec, const KJS::Value& value) {
563
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
564
exec->setException(eobj);
567
if (value.type() != KJS::BooleanType) {
568
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
569
exec->setException(eobj);
572
KstWriteLocker wl(_d);
574
_d->setXTicksOutPlot(value.toBoolean(exec));
576
_d->setYTicksOutPlot(value.toBoolean(exec));
579
KstApp::inst()->paintAll(KstPainter::P_PAINT);
583
KJS::Value KstBindAxis::majorGridColor(KJS::ExecState *exec) const {
585
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
586
exec->setException(eobj);
587
return KJS::Undefined();
589
KstReadLocker rl(_d);
590
return KJSEmbed::convertToValue(exec, _d->majorGridColor());
594
void KstBindAxis::setMajorGridColor(KJS::ExecState *exec, const KJS::Value& value) {
596
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
597
exec->setException(eobj);
600
QVariant cv = KJSEmbed::convertToVariant(exec, value);
601
if (!cv.canCast(QVariant::Color)) {
602
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
603
exec->setException(eobj);
606
KstWriteLocker rl(_d);
607
_d->setGridLinesColor(cv.toColor(), _d->minorGridColor(), false, _d->defaultMinorGridColor());
609
KstApp::inst()->paintAll(KstPainter::P_PAINT);
613
KJS::Value KstBindAxis::minorGridColor(KJS::ExecState *exec) const {
615
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
616
exec->setException(eobj);
617
return KJS::Undefined();
619
KstReadLocker rl(_d);
620
return KJSEmbed::convertToValue(exec, _d->minorGridColor());
624
void KstBindAxis::setMinorGridColor(KJS::ExecState *exec, const KJS::Value& value) {
626
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
627
exec->setException(eobj);
630
QVariant cv = KJSEmbed::convertToVariant(exec, value);
631
if (!cv.canCast(QVariant::Color)) {
632
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
633
exec->setException(eobj);
636
KstWriteLocker rl(_d);
637
_d->setGridLinesColor(_d->majorGridColor(), cv.toColor(), _d->defaultMajorGridColor(), false);
639
KstApp::inst()->paintAll(KstPainter::P_PAINT);
643
KJS::Value KstBindAxis::interpretation(KJS::ExecState *exec) const {
644
return KJS::Object(new KstBindTimeInterpretation(exec, const_cast<KstBindAxis*>(this))); // yuck
648
KJS::Value KstBindAxis::minorTickCount(KJS::ExecState *exec) const {
650
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
651
exec->setException(eobj);
652
return KJS::Undefined();
654
KstReadLocker rl(_d);
656
return KJS::Number(_d->xMinorTicks());
658
return KJS::Number(_d->yMinorTicks());
663
void KstBindAxis::setMinorTickCount(KJS::ExecState *exec, const KJS::Value& value) {
665
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
666
exec->setException(eobj);
669
if (value.type() != KJS::NumberType) {
670
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
671
exec->setException(eobj);
675
KstWriteLocker rl(_d);
677
_d->setXMinorTicks(value.toInt32(exec));
679
_d->setYMinorTicks(value.toInt32(exec));
682
KstApp::inst()->paintAll(KstPainter::P_PAINT);
686
KJS::Value KstBindAxis::majorTickDensity(KJS::ExecState *exec) const {
688
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
689
exec->setException(eobj);
690
return KJS::Undefined();
692
KstReadLocker rl(_d);
695
i = _d->xMajorTicks();
697
i = _d->yMajorTicks();
715
return KJS::Number(i);
719
void KstBindAxis::setMajorTickDensity(KJS::ExecState *exec, const KJS::Value& value) {
721
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
722
exec->setException(eobj);
725
if (value.type() != KJS::NumberType) {
726
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
727
exec->setException(eobj);
731
int i = value.toInt32(exec);
746
KJS::Object eobj = KJS::Error::create(exec, KJS::RangeError);
747
exec->setException(eobj);
751
KstWriteLocker rl(_d);
753
_d->setXMajorTicks(value.toInt32(exec));
755
_d->setYMajorTicks(value.toInt32(exec));
758
KstApp::inst()->paintAll(KstPainter::P_PAINT);
762
KJS::Value KstBindAxis::scaleMode(KJS::ExecState *exec) const {
764
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
765
exec->setException(eobj);
766
return KJS::Undefined();
768
KstReadLocker rl(_d);
771
i = _d->xScaleMode();
773
i = _d->yScaleMode();
776
KstApp::inst()->paintAll(KstPainter::P_PAINT);
777
return KJS::Number(i);
781
KJS::Value KstBindAxis::scaleAuto(KJS::ExecState *exec, const KJS::List& args) {
783
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
784
exec->setException(eobj);
785
return KJS::Undefined();
788
if (args.size() != 0) {
789
KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires exactly zero arguments.");
790
exec->setException(eobj);
791
return KJS::Undefined();
794
KstWriteLocker rl(_d);
796
_d->setXScaleMode(AUTO);
798
_d->setYScaleMode(AUTO);
801
KstApp::inst()->paintAll(KstPainter::P_PAINT);
802
return KJS::Undefined();
806
KJS::Value KstBindAxis::scaleAutoSpikeInsensitive(KJS::ExecState *exec, const KJS::List& args) {
808
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
809
exec->setException(eobj);
810
return KJS::Undefined();
813
if (args.size() != 0) {
814
KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires exactly zero arguments.");
815
exec->setException(eobj);
816
return KJS::Undefined();
819
KstWriteLocker rl(_d);
821
_d->setXScaleMode(NOSPIKE);
823
_d->setYScaleMode(NOSPIKE);
826
KstApp::inst()->paintAll(KstPainter::P_PAINT);
827
return KJS::Undefined();
831
KJS::Value KstBindAxis::scaleExpression(KJS::ExecState *exec, const KJS::List& args) {
833
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
834
exec->setException(eobj);
835
return KJS::Undefined();
838
if (args.size() != 2) {
839
KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires exactly two arguments.");
840
exec->setException(eobj);
841
return KJS::Undefined();
844
if (args[0].type() != KJS::StringType || args[1].type() != KJS::StringType) {
845
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
846
exec->setException(eobj);
847
return KJS::Undefined();
850
KstWriteLocker rl(_d);
852
_d->setXScaleMode(EXPRESSION);
853
_d->setXExpressions(args[0].toString(exec).qstring(), args[1].toString(exec).qstring());
855
_d->setYScaleMode(EXPRESSION);
856
_d->setYExpressions(args[0].toString(exec).qstring(), args[1].toString(exec).qstring());
859
KstApp::inst()->paintAll(KstPainter::P_PAINT);
860
return KJS::Undefined();
864
KJS::Value KstBindAxis::scaleRange(KJS::ExecState *exec, const KJS::List& args) {
866
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
867
exec->setException(eobj);
868
return KJS::Undefined();
871
if (args.size() != 2) {
872
KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires exactly two arguments.");
873
exec->setException(eobj);
874
return KJS::Undefined();
877
if (args[0].type() != KJS::NumberType || args[1].type() != KJS::NumberType) {
878
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
879
exec->setException(eobj);
880
return KJS::Undefined();
883
KstWriteLocker rl(_d);
885
_d->setXScaleMode(FIXED);
886
_d->setXScale(args[0].toNumber(exec), args[1].toNumber(exec));
888
_d->setYScaleMode(FIXED);
889
_d->setYScale(args[0].toNumber(exec), args[1].toNumber(exec));
892
KstApp::inst()->paintAll(KstPainter::P_PAINT);
893
return KJS::Undefined();