Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Using ScriptHelper with the DiagramApplet (Read 3250 times)
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
Using ScriptHelper with the DiagramApplet
Dec 4th, 2013 at 1:16pm
Print Post  
Hello,

Firstly, I am working with the version 3.4.

We want to code 2 things with the ScriptHelper class in javascript :
1°) A Customized DashStyle for a pen like this :
Code (Java)
Select All
	private Pen formeLien (VgLien lie) {
		Pen stylo = new Pen();
		DashStyle d = null;

		if (lie.getReel().equals("1")) {
			d = new DashStyle (new float []{3,3}, 0);
			stylo.setDashStyle(d);
		} else if (lie.getReel().equals("2")) {
			d = new DashStyle (new float []{2,2}, 0);
			stylo.setDashStyle(d);
		} else if (lie.getReel().equals("3")) {
			d = new DashStyle (new float []{4,2,4}, 0);
			stylo.setDashStyle(d);
		}
		if (lie.getCritique() == 2) {
			stylo.setWidth(3);
		} else if (grapheImage) {
			stylo.setWidth(1);
		} else {
			stylo.setWidth(0);
		}
		stylo.setColor(invertColor (lie.getCouleur()));
		return stylo;
	}
 


2°) An AnchorPattern with specifics AnchorPoints like this :

Code (Java)
Select All
AnchorPattern apat = new AnchorPattern(new AnchorPoint[] {new AnchorPoint(5, 0),new AnchorPoint(20, 0),
				new AnchorPoint(45, 0),new AnchorPoint(50, 0),new AnchorPoint(55, 0),
				new AnchorPoint(80, 0),new AnchorPoint(95, 0),
				new AnchorPoint(30, 100),new AnchorPoint(45, 100),new AnchorPoint(50, 100),
				new AnchorPoint(55, 100),new AnchorPoint(70, 100)}, "Process");
 



Is it possible with the ScriptHelper class, have we to use another class or is it impossible ?

Regards

Juan
  
Back to top
 
IP Logged
 
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
Re: Using ScriptHelper with the DiagramApplet
Reply #1 - Dec 4th, 2013 at 4:15pm
Print Post  
Hello,

We have found the solution for the AnchorPoint problem.
We have to do an AnchorPattern.getPoints().add(.. ) like the code below

Code (Javascript)
Select All
var scrhlp = DiagramApplet.getScriptHelper();
var anchors = scrhlp.anchorPatternFromId ("Process");
anchors.getPoints().add(scrhlp.createAnchorPoint (5,0));
anchors.getPoints().add(scrhlp.createAnchorPoint (20,0));
anchors.getPoints().add(scrhlp.createAnchorPoint (40,0));
anchors.getPoints().add(scrhlp.createAnchorPoint (50,0));
anchors.getPoints().add(scrhlp.createAnchorPoint (55,0));
anchors.getPoints().add(scrhlp.createAnchorPoint (80,0));
anchors.getPoints().add(scrhlp.createAnchorPoint (95,0));
anchors.getPoints().add(scrhlp.createAnchorPoint (30,100));
anchors.getPoints().add(scrhlp.createAnchorPoint (45,100));
anchors.getPoints().add(scrhlp.createAnchorPoint (50,100));
anchors.getPoints().add(scrhlp.createAnchorPoint (55,100));
anchors.getPoints().add(scrhlp.createAnchorPoint (70,100));
 



We are still looking for the DashStyle problem.

Regards

Juan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Using ScriptHelper with the DiagramApplet
Reply #2 - Dec 4th, 2013 at 5:33pm
Print Post  
Hi,

It might be possible using the solution shown here:
http://stackoverflow.com/questions/1295882/is-it-possible-to-create-arbitrary-ja...

and Java reflection classes such as:
http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Array.html

If that does not work, you could override DiagramApplet and add your helper methods to the custom applet, then use it on the page instead of the standard one.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
JR
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 86
Joined: Jun 12th, 2007
Re: Using ScriptHelper with the DiagramApplet
Reply #3 - Dec 5th, 2013 at 10:44am
Print Post  
Hello,

We have override the DiagramApplet and it works Smiley.

Thanks

Juan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint