グラフィックス スクリプトの追加と削除比較的複雑なアニメーション シーケンス中に、いくつかのグラフィックス スクリプトがグラフ ビルダーに追加およびグラフ ビルダーから削除される JSL ルーチンを作成しました。 追加および削除する必要があるスクリプトは、分析するデータセットによって異なるため、次のような多くのスクリプトを作成する必要があります (gb は GraphBuilder オブジェクト、myScript1 と myScript2 は両方とも定義した式です)他の場所):
If( k == 5, Report( gb ) << dispatch( {}, "Graph Builder", FrameBox, {Add Graphics Script( 1, Description( "Script" ), myScript1 )} ));
If( k == 10, Report( gb ) << dispatch( {}, "Graph Builder", FrameBox, {Remove Graphics Script( 2 )} ));
If( k == 15, Report( gb ) << dispatch( {}, "Graph Builder", FrameBox, {Add Graphics Script( 1, Description( "Script" ), myScript2 )} ));
私の問題は、どのスクリプトを削除する必要があるのか分からなくなることです。スクリプトを番号で参照しているためです。グラフ ビルダーによってスクリプトに割り当てられる番号は、スクリプトが削除されるたびに変わります。
私は私を知っていますすべきすべてのグラフィックス スクリプトを 1 つの大きなスクリプトに結合して、if-then-else 節によってさまざまなセクション間で制御を切り替えることができる可能性がありますが、それらのスクリプトが数十ある可能性があり、全体が非常に複雑になる可能性があります。
グラフィックス スクリプトを名前で参照することはできますか? 基本的に、次のようなことができるようにしたいです。
report(gb) << dispatch( {}, "Graph Builder", FrameBox, {Remove Graphics Script( myScript2 )} );
上記は機能しません(当然、そうでなければ問題はありません)が、私が見逃している同様のものがないかどうか疑問に思っています。
ご提案をいただきありがとうございました。
Re: グラフィックス スクリプトの追加と削除クレイジ
詳細な例をありがとうございます。 編集スクリプトの例は多くの人にとって役立つはずです。
しかし、私は説明タグがあればどんなに素晴らしいだろうかと考えており、スクリプトへのハンドルを取得するのは次のように簡単になるでしょう。
thisOne = rbiv_fb << Xpath( "//TopSeg[@description='bluepoly'] " );
たぶんJMP15でしょうか?
Re: グラフィックス スクリプトの追加と削除私も好き@gzmorgan0 2番目のアプローチ。 ここでは、リストを保持するのではなく、スクリプトを検索する別のアイデアを紹介します。 JSL スクリプトでは 0 のような式。または「フレッド」。何もしません。それは評価されて捨てられます。 したがって、次のようなグラフィックススクリプト
"red"; fill color(...); circle(...);
先頭に識別子を付けることができます。この識別子は、arg( script, 1 ) 関数を使用して「red」を取得することで後で調べることができます。
dt = Open( "$sample_data/big class.jmp" );
gb = dt << Graph Builder(
Size( 525, 452 ),
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ) ),
Elements( Points( X, Y, Legend( 6 ) ) )
);
colors = {"red", "green", "blue", "yellow", "cyan", "magenta", "orange", "purple", "gray"};
For( i = 1, i <= N Items( colors ), i++,
Eval( // the "i" variable needs to be cast-in-stone so it will not be needed if the graph
Eval Expr( // is saved in a journal. EvalExpr will pre-eval the expr() below...
(Report( gb )[framebox( 1 )]) << addGraphicsScript(
1,
Expr( colors[i] ); // this will be the identifier for the script
Fill Color( Expr( colors[i] ) ); // pre-eval the color name, not just the subscript
Circle( {80 + 5 * Expr( i ), 50 + 2 * Expr( i )}, 1, "FILL" );
)
)
)
);
findSegById = Function( {frame, id}, // locate a graphics script by an id string
{child = frame << childSeg, script}, // the frame has a list of graphics scripts
While( !Is Empty( child ),
If( child << className == "TopSeg", // TopSeg is the className of a graphics script
script = child << getscript; // check the script to see if the first
If( Arg( script, 1 ) == id, // statement is the id name
Return( child )
);
);
child = child << sib;
);
Return( child ); // empty, not found
);
Wait( 1 );
thisOne = findSegById( Report( gb )[framebox( 1 )], colors[5] ); // the cyan script
thisOne << delete;
Wait( 1 );
thisOne = findSegById( Report( gb )[framebox( 1 )], "green" );
thisOne << delete;
Wait( 1 );
thisOne = findSegById( Report( gb )[framebox( 1 )], colors[9] ); // the gray script
thisOne << delete;
Wait( 1 );
// if needed, you can retrieve, edit, and replace the script
thisOne = findSegById( Report( gb )[framebox( 1 )], "blue" );
oldScript = thisOne << getscript;
newScript = Substitute( Name Expr( oldScript ), "FILL", Empty() ); // hollow black outline remains
Eval( Eval Expr( thisOne << setscript( Expr( Name Expr( newscript ) ) ) ) );
// gb << inval;
Print( If( Is Empty( findSegById( Report( gb )[framebox( 1 )], "argyle" ) ), "Good", "Bad" ) );
Three filled circles removed and one hollowed outThree filled circles removed and one hollowed out3 つの塗りつぶされた円が削除され、1 つはくり抜かれています
Use the customize popup menu item to see the scripts; this is the edited scriptUse the customize popup menu item to see the scripts; this is the edited scriptスクリプトを表示するには、カスタマイズ ポップアップ メニュー項目を使用します。これは編集されたスクリプトです
Re: グラフィックス スクリプトの追加と削除こんにちは - それは確かに非常に役に立ちます - 特にあなたが説明した 2 番目の方法は独創的です。 私が使用したいコンテキストで eval(substitute(expr(...))) 構造がどのように機能するかを示す例は、入手するのがかなり難しいため、(少なくとも私にとっては) より読みやすいものを書くことになる傾向があります。しかし、スクリプトはそれほどスマートではありません。 ただし、この例では、明らかにあなたの例にかなり近いものが必要になるので、それを適応させます。
多くの場合、このような状況で最も重要なことは、問題に本格的に取り組む前に、単純なトリックを見逃していないことを最初に確認することです:)
どうもありがとう
Re: グラフィックス スクリプトの追加と削除おめでとうございます、またはスクリプトを作成しました。 構文からすると、JSL についてはかなり初心者だと思います。
役に立つかもしれない 2 つのサンプル スクリプトがあります。最初の例では、スクリプト式のreference(name)を使用します。 スクリプトを追加した後、フレームボックスを右クリックして「カスタマイズ」を選択します。グラフィックス スクリプトの JSL は表示されず、expr 参照のみが表示されます。 これは機能します。 ただし、あなたまたはユーザーがグラフをジャーナルに記録した場合は、後でジャーナルを閉じます。新しいセッションでジャーナルを開いた場合、これらの式は定義されず、グラフィックスは描画されません。 この方法は、グラフィックス スクリプトに変数の衝突がなく、グラフが現在のセッションにのみ関連する場合に機能します。 Xpath は、フレームボックス TopSeq、ユーザーが追加したグラフィックス、この場合はスクリプト参照のみを検索するために使用されます。
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
orangepoly = Expr( Transparency( 0.5 );
Fill Color( {1.0, 0.5, 0.0} );
Polygon( [60, 72, 57], [75, 120, 120] );
);
bluepoly = Expr(
Transparency( 0.5 );
Fill Color( {0.0, 0.5, 1.0} );
Polygon( [60, 72, 57], [150, 120, 120] );
);
biv = Bivariate( Y( :weight ), X( :height ), FitLine );
rbiv = biv << report;
rbiv_fb = rbiv[frame box( 1 )];
rbiv_fb << Add Graphics Script(orangepoly);
rbiv_fb << Add Graphics Script(bluepoly);
//right click on the framebox and select Customize
/*just the expr reference is visible
If this graph is journaled, the journal is closed and reopened the graphics from the script
will not appear. look up Freeze All for the journal. */
glist = (rbiv_fb << XPath("//TopSeg")) << get script;
idx = contains(glist, expr(bluepoly));
Wait( 3 );
rbiv_fb << Remove Graphics Script( idx );この 2 番目の方法では、スクリプトをフレームボックスに埋め込みます。 スクリプトを追加した後、フレームボックス内で右クリックしてカスタマイズを選択し、スクリプトをクリックして 2 つの方法の違いを確認します。 スクリプトインセットをリストに追加した後のスクリプト名。 スクリプトを削除する場合は、リストから削除します。 このリストは、どのスクリプトがアクティブであるかを動的に記録するもので、その位置を特定するために関数が使用されます。
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
glist={};
orangepoly = Expr(
Transparency( 0.5 );
Fill Color( {1.0, 0.5, 0.0} );
Polygon( [60, 72, 57], [75, 120, 120] );
);
bluepoly = Expr(
Transparency( 0.5 );
Fill Color( {0.0, 0.5, 1.0} );
Polygon( [60, 72, 57], [150, 120, 120] );
);
addgraph = Function({gnme}, {gexpr}, //"orangepoly")
Eval(Parse("gexpr = NameExpr("||gnme||")" ) );
Eval(Substitute(Expr(rbiv_fb << Add Graphics Script(_xxx)), Expr(_xxx), NameExpr(gexpr) ) );
insert into(glist, gnme );
); //end addgraph
rmvgraph = Function({gnme}, {idx},
idx = contains(glist, gnme);
if(idx>0,
rbiv_fb << Remove Graphics Script(idx);
removefrom(glist, idx)
);
); //end rmvgrph
biv = Bivariate( Y( :weight ), X( :height ), FitLine );
rbiv = biv << report;
rbiv_fb = rbiv[frame box( 1 )];
addgraph("orangepoly");
addgraph("bluepoly");
//right click on the framebox and select Customize
//the actual script is embedded
Wait( 3 );
rmvgraph("bluepoly");ウィッシュ リストの項目に同意します。これらのスクリプト (トップセグ) フレームボックスに説明/名前タグを追加します。<<グラフィック スクリプトの追加(名前、スクリプト) は、あれば間違いなく便利です。