TS 68 JavaFX CodeFormating

(Difference between revisions)
(Created page with ' ==Code Formating== '''Author:''' [mailto:sunflower@netbeans.org Alexandr Scherbatiy] <br> '''Version:''' 1.1 <br> '''Last update:''' 29 September 2009 <br> '''Introduction:''' …')
Line 1: Line 1:
-
 
==Code Formating==
==Code Formating==
'''Author:''' [mailto:sunflower@netbeans.org Alexandr Scherbatiy] <br>
'''Author:''' [mailto:sunflower@netbeans.org Alexandr Scherbatiy] <br>
Line 83: Line 82:
<br>
<br>
 +
Line 88: Line 88:
      
      
# {{testcase|Variable}}
# {{testcase|Variable}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
var a = 10;
var a = 10;
var b = 20.5;
var b = 20.5;
var c = a + b;
var c = a + b;
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <pre>
+
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <code> <pre>
var a = 10;
var a = 10;
var b = 20.5;
var b = 20.5;
var c = a + b;
var c = a + b;
-
</pre>
+
</pre> </code>
# {{testcase|Data Types}}
# {{testcase|Data Types}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
var i = 3;
var i = 3;
var num = 3.0;
var num = 3.0;
Line 131: Line 131:
var seq = ["1","2","3" ];
var seq = ["1","2","3" ];
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <pre>
+
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <code> <pre>
var i = 3;
var i = 3;
var num = 3.0;
var num = 3.0;
Line 164: Line 164:
var seq = ["1","2","3" ];
var seq = ["1","2","3" ];
-
</pre>
+
</pre> </code>
# {{testcase|Trigger}}
# {{testcase|Trigger}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
var a = 3 on replace{
var a = 3 on replace{
     println(a);
     println(a);
}
}
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <pre>
+
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <code> <pre>
var a = 3 on replace{
var a = 3 on replace{
     println(a);
     println(a);
}
}
-
</pre>
+
</pre> </code>
# {{testcase|Binding}}
# {{testcase|Binding}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
var a  =  4;
var a  =  4;
var b  =  bind a with inverse;
var b  =  bind a with inverse;
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <pre>
+
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <code> <pre>
var a  =  4;
var a  =  4;
var b  =  bind a with inverse;
var b  =  bind a with inverse;
-
</pre>
+
</pre> </code>
<br>
<br>
Line 198: Line 198:
# {{testcase|Simple Function Body}}
# {{testcase|Simple Function Body}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
function    sqr(  x : Number) { x*  x }
function    sqr(  x : Number) { x*  x }
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code is formatted  }} <pre>
+
#* {{result|EXPECTED RESULT:  The code is formatted  }} <code> <pre>
function sqr(x:Number) { x * x }
function sqr(x:Number) { x * x }
-
</pre>
+
</pre> </code>
      
      
# {{testcase|Function Body}}
# {{testcase|Function Body}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
function sqr(x:Number) {    x  * x }
function sqr(x:Number) {    x  * x }
Line 224: Line 224:
}
}
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code is formatted  }} <pre>
+
#* {{result|EXPECTED RESULT:  The code is formatted  }} <code> <pre>
function sqr(x:Number) { x * x }
function sqr(x:Number) { x * x }
Line 241: Line 241:
}
}
-
</pre>
+
</pre> </code>
<br>
<br>
Line 255: Line 255:
      
      
# {{testcase|Sequence}}
# {{testcase|Sequence}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
var seq = [[1,2,3,[4,5,6 |  1, 2, 3, [ 4, 5, 6]], [7,8,9] ];
var seq = [[1,2,3,[4,5,6 |  1, 2, 3, [ 4, 5, 6]], [7,8,9] ];
Line 263: Line 263:
         ];
         ];
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <pre>
+
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <code> <pre>
var seq = [[1,2,3,[4,5,6 |  1, 2, 3, [ 4, 5, 6]], [7,8,9] ];
var seq = [[1,2,3,[4,5,6 |  1, 2, 3, [ 4, 5, 6]], [7,8,9] ];
Line 273: Line 273:
     "Mary"
     "Mary"
];
];
-
</pre>
+
</pre> </code>
# {{testcase|Sequence}}
# {{testcase|Sequence}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
var seq = for(i in [1..3]){ i * i }
var seq = for(i in [1..3]){ i * i }
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <pre>
+
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <code> <pre>
var seq = for(i in [1..3]){ i * i }
var seq = for(i in [1..3]){ i * i }
-
</pre>
+
</pre> </code>
# {{testcase|Slice}}
# {{testcase|Slice}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
var seq = [1,3,6,8];
var seq = [1,3,6,8];
var slice = seq[N*N <10];
var slice = seq[N*N <10];
def selected = for (x in seq where (x*x) < 20) x;
def selected = for (x in seq where (x*x) < 20) x;
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <pre>
+
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <code> <pre>
var seq = [1,3,6,8];
var seq = [1,3,6,8];
var slice = seq[N*N <10];
var slice = seq[N*N <10];
def selected = for (x in seq where (x*x) < 20) x;
def selected = for (x in seq where (x*x) < 20) x;
-
</pre>
+
</pre> </code>
# {{testcase|Expressoins}}
# {{testcase|Expressoins}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
var names  =  [Evelyn,Will];
var names  =  [Evelyn,Will];
Line 308: Line 308:
delete names;
delete names;
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <pre>
+
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <code> <pre>
var names  =  [Evelyn,Will];
var names  =  [Evelyn,Will];
Line 323: Line 323:
delete names;
delete names;
-
</pre>
+
</pre> </code>
<br>
<br>
Line 340: Line 340:
      
      
# {{testcase|Attribute}}
# {{testcase|Attribute}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
class A {
class A {
     public var a : String;
     public var a : String;
}
}
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code is formatted  }} <pre>
+
#* {{result|EXPECTED RESULT:  The code is formatted  }} <code> <pre>
class A {
class A {
     public var a : String;
     public var a : String;
}
}
-
</pre>
+
</pre> </code>
# {{testcase|Overridden Attribute}}
# {{testcase|Overridden Attribute}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
class A{
class A{
     public var a:Number;
     public var a:Number;
Line 360: Line 360:
     override var a = 10;
     override var a = 10;
}
}
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code is formatted  }} <pre>
+
#* {{result|EXPECTED RESULT:  The code is formatted  }} <code> <pre>
class A{
class A{
     public var a:Number;
     public var a:Number;
Line 370: Line 370:
     override var a = 10;
     override var a = 10;
}
}
-
</pre>
+
</pre> </code>
# {{testcase|Trigger}}
# {{testcase|Trigger}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
class Foo {
class Foo {
     var x : Integer on replace = newV { println("x: =>{newV}={x}"); };
     var x : Integer on replace = newV { println("x: =>{newV}={x}"); };
Line 379: Line 379:
     var seq: String[[ | ]] on replace oldSlice[A..b] = newSlice{ for(s in seq){ println(s)</tt>;
     var seq: String[[ | ]] on replace oldSlice[A..b] = newSlice{ for(s in seq){ println(s)</tt>;
}
}
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code is formatted  }} <pre>
+
#* {{result|EXPECTED RESULT:  The code is formatted  }} <code> <pre>
class Foo {
class Foo {
     var x : Integer on replace = newV { println("x: =>{newV}={x}"); };
     var x : Integer on replace = newV { println("x: =>{newV}={x}"); };
Line 388: Line 388:
     var seq: String[[ | ]] on replace oldSlice[A..b] = newSlice{ for(s in seq){ println(s)</tt>;
     var seq: String[[ | ]] on replace oldSlice[A..b] = newSlice{ for(s in seq){ println(s)</tt>;
}
}
-
</pre>
+
</pre> </code>
# {{testcase|Function}}
# {{testcase|Function}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
class A {
class A {
          
          
Line 401: Line 401:
}
}
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code should be formatted }} <pre>
+
#* {{result|EXPECTED RESULT:  The code should be formatted }} <code> <pre>
class A {
class A {
          
          
Line 414: Line 414:
}
}
-
</pre>
+
</pre> </code>
# {{testcase|Function Return}}
# {{testcase|Function Return}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
class B{
class B{
     public function create ():B {
     public function create ():B {
Line 422: Line 422:
     }
     }
}
}
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code should be formatted }} <pre>
+
#* {{result|EXPECTED RESULT:  The code should be formatted }} <code> <pre>
class B{
class B{
     public function create ():B {
     public function create ():B {
Line 430: Line 430:
     }
     }
}
}
-
</pre>
+
</pre> </code>
# {{testcase|Init}}
# {{testcase|Init}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
class A{
class A{
Line 444: Line 444:
}
}
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code should be formatted }} <pre>
+
#* {{result|EXPECTED RESULT:  The code should be formatted }} <code> <pre>
class A{
class A{
Line 458: Line 458:
}
}
-
</pre>
+
</pre> </code>
# {{testcase|Inheritance}}
# {{testcase|Inheritance}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
import javafx.scene.*;
import javafx.scene.*;
Line 466: Line 466:
     override function create(){ Group{} }
     override function create(){ Group{} }
}
}
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code should be formatted }} <pre>
+
#* {{result|EXPECTED RESULT:  The code should be formatted }} <code> <pre>
import javafx.scene.*;
import javafx.scene.*;
Line 474: Line 474:
     override function create(){ Group{} }
     override function create(){ Group{} }
}
}
-
</pre>
+
</pre> </code>
<br>
<br>
Line 488: Line 488:
      
      
# {{testcase|Stage}}
# {{testcase|Stage}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
import javafx.stage.*;
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.*;
Line 529: Line 529:
     }
     }
}
}
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
#* {{result|EXPECTED RESULT:  The code should be formatted  }}  
#* {{result|EXPECTED RESULT:  The code should be formatted  }}  
# {{testcase|Sequence}}
# {{testcase|Sequence}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
import javafx.scene.shape.*;
import javafx.scene.shape.*;
import javafx.scene.transform.*;
import javafx.scene.transform.*;
Line 540: Line 540:
     transforms: [Rotate{Angle:90.0},Scale{X:0.3,Y:0.3} ]
     transforms: [Rotate{Angle:90.0},Scale{X:0.3,Y:0.3} ]
}
}
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <pre>
+
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <code> <pre>
import javafx.scene.shape.*;
import javafx.scene.shape.*;
import javafx.scene.transform.*;
import javafx.scene.transform.*;
Line 549: Line 549:
     transforms: [Rotate{Angle:90.0},Scale{X:0.3,Y:0.3} ]
     transforms: [Rotate{Angle:90.0},Scale{X:0.3,Y:0.3} ]
}
}
-
</pre>
+
</pre> </code>
# {{testcase|For Loop}}
# {{testcase|For Loop}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
import javafx.scene.Group;
import javafx.scene.Group;
import javafx.scene.paint.Color;
import javafx.scene.paint.Color;
Line 560: Line 560:
     content: for( r in [1..10Step2]) Circle{ radius: r fill: Color.GREEN }
     content: for( r in [1..10Step2]) Circle{ radius: r fill: Color.GREEN }
}
}
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code should be formatted }} <pre>
+
#* {{result|EXPECTED RESULT:  The code should be formatted }} <code> <pre>
import javafx.scene.Group;
import javafx.scene.Group;
import javafx.scene.paint.Color;
import javafx.scene.paint.Color;
Line 571: Line 571:
     content: for( r in [1..10Step2]) Circle{ radius: r fill: Color.GREEN }
     content: for( r in [1..10Step2]) Circle{ radius: r fill: Color.GREEN }
}
}
-
</pre>
+
</pre> </code>
Line 584: Line 584:
      
      
# {{testcase|Operator If}}
# {{testcase|Operator If}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
ar a  =  10;
ar a  =  10;
var f  =  false;
var f  =  false;
Line 600: Line 600:
var b = if( a +3 < 100  ) 10 else if( -100 < a - 3 ) -10 else 0;
var b = if( a +3 < 100  ) 10 else if( -100 < a - 3 ) -10 else 0;
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <pre>
+
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <code> <pre>
ar a  =  10;
ar a  =  10;
var f  =  false;
var f  =  false;
Line 618: Line 618:
var b = if( a +3 < 100  ) 10 else if( -100 < a - 3 ) -10 else 0;
var b = if( a +3 < 100  ) 10 else if( -100 < a - 3 ) -10 else 0;
-
</pre>
+
</pre> </code>
# {{testcase|Operator For}}
# {{testcase|Operator For}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
for(a in [1..100]){
for(a in [1..100]){
     println(a+10);
     println(a+10);
Line 626: Line 626:
var seq = for(b in [1,5,9]) b + b / 2;
var seq = for(b in [1,5,9]) b + b / 2;
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <pre>
+
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <code> <pre>
for(a in [1..100]){
for(a in [1..100]){
     println(a+10);
     println(a+10);
Line 634: Line 634:
var seq = for(b in [1,5,9]) b + b / 2;
var seq = for(b in [1,5,9]) b + b / 2;
-
</pre>
+
</pre> </code>
# {{testcase|Operator While}}
# {{testcase|Operator While}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
var a = 10;
var a = 10;
Line 644: Line 644:
     println(a);
     println(a);
}
}
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <pre>
+
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <code> <pre>
var a = 10;
var a = 10;
Line 654: Line 654:
     println(a);
     println(a);
}
}
-
</pre>
+
</pre> </code>
# {{testcase|Operator Try-Ctach}}
# {{testcase|Operator Try-Ctach}}
-
##  Copy the code to the editor:<pre>         
+
##  Copy the code to the editor:<code> <pre>         
import java.io.FileReader;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.BufferedReader;
Line 679: Line 679:
     println("The end");
     println("The end");
}
}
-
</pre>   
+
</pre> </code>   
##  Format the code (press &lt;Ctrl+F5&gt;).  
##  Format the code (press &lt;Ctrl+F5&gt;).  
-
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <pre>
+
#* {{result|EXPECTED RESULT:  The code should be formatted  }} <code> <pre>
import java.io.FileReader;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.BufferedReader;
Line 704: Line 704:
     println("The end");
     println("The end");
}
}
-
</pre>
+
</pre> </code>
<br>
<br>

Revision as of 14:27, 9 November 2009

Code Formating

Author: Alexandr Scherbatiy
Version: 1.1
Last update: 29 September 2009
Introduction:
Comments:


Contents



Code Formatting Umbrella issue: 173487

What Issues
Variable
declaration 173240
data types
trigger 173368
binding 173370
Function
body 173365, 173468
Sequence
declaration 173367,172466
select 173400
Class
attribute 172644
trigger
function
init
inheritance 173464
instantiation 173462
Scene Graph
Stage
sequence
Operators
if 173467
for
while
try-catch




Variable

  1. Variable
    1. Copy the code to the editor:
               
      

var a = 10; var b = 20.5; var c = a + b;

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted

var a = 10; var b = 20.5; var c = a + b;

  1. Data Types
    1. Copy the code to the editor:
               
      

var i = 3; var num = 3.0;

var b = true;

var c = "2".charAt(0);


var byte:Byte = 1; var short:Short = 2; var long:Long = 3; var float:Float = 5.0; var double:Double = 10.0;


var date = 3h;

var str = "Hello!";

class A{}

var a = A{};

var void = function():Void{};

var f = function(a:Number, b:String):Boolean { true }; var seqf = function(a:A[[ | ]], b:String[[ | ]]):Boolean[[ | ]] { [] };


var seq = ["1","2","3" ];

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted

var i = 3; var num = 3.0;

var b = true;

var c = "2".charAt(0);


var byte:Byte = 1; var short:Short = 2; var long:Long = 3; var float:Float = 5.0; var double:Double = 10.0;


var date = 3h;

var str = "Hello!";

class A{}

var a = A{};

var void = function():Void{};

var f = function(a:Number, b:String):Boolean { true }; var seqf = function(a:A[[ | ]], b:String[[ | ]]):Boolean[[ | ]] { [] };


var seq = ["1","2","3" ];

  1. Trigger
    1. Copy the code to the editor:
               
      

var a = 3 on replace{

   println(a);

}

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted

var a = 3 on replace{

   println(a);

}

  1. Binding
    1. Copy the code to the editor:
               
      

var a = 4; var b = bind a with inverse;

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted

var a = 4; var b = bind a with inverse;





Function

  1. Simple Function Body
    1. Copy the code to the editor:
               
      

function sqr( x : Number) { x* x }

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code is formatted

function sqr(x:Number) { x * x }

  1. Function Body
    1. Copy the code to the editor:
               
      

function sqr(x:Number) { x * x }

function f(name:String, seq:String[[ | ]]):String[]{

               return [Name,Seq ];

}

function show(a:Number, b:Number){

       var c = a + b;
   var d = a - b;
       println(c);
   println(d);

}

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code is formatted

function sqr(x:Number) { x * x }

function f(name:String, seq:String[[ | ]]):String[]{

   return [Name,Seq ];

}

function show(a:Number, b:Number){

   var c = a + b;
   var d = a - b;
   println(c);
   println(d);

}






Sequence

  1. Sequence
    1. Copy the code to the editor:
               
      

var seq = [[1,2,3,[4,5,6 | 1, 2, 3, [ 4, 5, 6]], [7,8,9] ];

var names = [ "Petr",

   "John",
   "Mary"
       ];
    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted

var seq = [[1,2,3,[4,5,6 | 1, 2, 3, [ 4, 5, 6]], [7,8,9] ];

var names = [

   "Petr",
   "John",
   "Mary"

];

  1. Sequence
    1. Copy the code to the editor:
               
      

var seq = for(i in [1..3]){ i * i }

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted

var seq = for(i in [1..3]){ i * i }

  1. Slice
    1. Copy the code to the editor:
               
      

var seq = [1,3,6,8]; var slice = seq[N*N <10]; def selected = for (x in seq where (x*x) < 20) x;

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted

var seq = [1,3,6,8]; var slice = seq[N*N <10]; def selected = for (x in seq where (x*x) < 20) x;

  1. Expressoins
    1. Copy the code to the editor:
               
      

var names = [Evelyn,Will];

insert 'Marsha' into names; insert [[Ron,Melissa | 'Ron', 'Melissa']] before names[1]; insert 'Daz' after names[3];

delete 'Ron' from names; delete names[SizeofNames1]; delete names[2..4];


delete names;

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted

var names = [Evelyn,Will];

insert 'Marsha' into names; insert [[Ron,Melissa | 'Ron', 'Melissa']] before names[1]; insert 'Daz' after names[3];

delete 'Ron' from names; delete names[SizeofNames1]; delete names[2..4];


delete names;







Class

  1. Attribute
    1. Copy the code to the editor:
               
      

class A {

   public var a : String;

}

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code is formatted

class A {

   public var a : String;

}

  1. Overridden Attribute
    1. Copy the code to the editor:
               
      

class A{

   public var a:Number;

}

class B extends A{

   override var a = 10;

}

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code is formatted

class A{

   public var a:Number;

}

class B extends A{

   override var a = 10;

}

  1. Trigger
    1. Copy the code to the editor:
               
      

class Foo {

   var x : Integer on replace = newV { println("x: =>{newV}={x}"); };
   var y : Integer on replace { println("y: {y}"); };
   var z : String = "Ralph" on replace { println("z: {z}"); };
   var seq: String[[ | ]] on replace oldSlice[A..b] = newSlice{ for(s in seq){ println(s)</tt>;

}

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code is formatted

class Foo {

   var x : Integer on replace = newV { println("x: =>{newV}={x}"); };
   var y : Integer on replace { println("y: {y}"); };
   var z : String = "Ralph" on replace { println("z: {z}"); };
   var seq: String[[ | ]] on replace oldSlice[A..b] = newSlice{ for(s in seq){ println(s)</tt>;

}

  1. Function
    1. Copy the code to the editor:
               
      

class A {

   function f(name:String){
       println("class {this}");
       println("name: {name}");
   }
   override function toString():String{ "A" }

}

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted

class A {

   function f(name:String){
       println("class {this}");
       println("name: {name}");
   }
   override function toString():String{ "A" }

}

  1. Function Return
    1. Copy the code to the editor:
               
      

class B{

   public function create ():B {
       return B{}
   }

}

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted

class B{

   public function create ():B {
       return B{}
   }

}

  1. Init
    1. Copy the code to the editor:
               
      

class A{

   init{
       println("init");
   }
   postinit{
       println("post init");
   }

}

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted

class A{

   init{
       println("init");
   }
   postinit{
       println("post init");
   }

}

  1. Inheritance
    1. Copy the code to the editor:
               
      

import javafx.scene.*;

class MyCustomNode extends CustomNode {

   override function create(){ Group{} }

}

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted

import javafx.scene.*;

class MyCustomNode extends CustomNode {

   override function create(){ Group{} }

}






Scene Graph

  1. Stage
    1. Copy the code to the editor:
               
      

import javafx.stage.*; import javafx.scene.*; import javafx.scene.text.*; import javafx.scene.input.*; import javafx.scene.shape.*; import javafx.scene.paint.*; import javafx.scene.control.*;


Stage {

   title : "MyApp"
   scene: Scene {
   width: 200
   height: 200
       content: [
           Text {
               font: Font { size: 24 }
               x: 10, y: 30
               content: "Hello World!"
           }
           Button {
                   text: "Button"
                   action: function() {
                       println("2 + 3 = {2 + 3}");
                       println("Hello World!")
                   }
           }
           Circle {
                   centerX: 100, centerY: 100
                   radius: 40
                   fill: Color.GREEN
                   onMouseClicked: function( e: MouseEvent ):Void {
                       var x = e.x;
                       var y = e.y;
                       println("x: {x}, y: {y}");
                   }
           }
       ]
   }

}

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted
  1. Sequence
    1. Copy the code to the editor:
               
      

import javafx.scene.shape.*; import javafx.scene.transform.*;

Circle {

   transforms: [Rotate{Angle:90.0},Scale{X:0.3,Y:0.3} ]

}

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted

import javafx.scene.shape.*; import javafx.scene.transform.*;

Circle {

   transforms: [Rotate{Angle:90.0},Scale{X:0.3,Y:0.3} ]

}

  1. For Loop
    1. Copy the code to the editor:
               
      

import javafx.scene.Group; import javafx.scene.paint.Color; import javafx.scene.shape.Circle;


Group {

   content: for( r in [1..10Step2]) Circle{ radius: r fill: Color.GREEN }

}

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted

import javafx.scene.Group; import javafx.scene.paint.Color; import javafx.scene.shape.Circle;


Group {

   content: for( r in [1..10Step2]) Circle{ radius: r fill: Color.GREEN }

}






Operators

  1. Operator If
    1. Copy the code to the editor:
               
      

ar a = 10; var f = false;

if(a < 100 and not f ){

   a++;
   f = not f;

}else if(a != 100 and f ) {

   a--;
   f = a!=2 ;

}else{

   a+=10;
   f = a < 100 ;

}

var b = if( a +3 < 100 ) 10 else if( -100 < a - 3 ) -10 else 0;

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted

ar a = 10; var f = false;

if(a < 100 and not f ){

   a++;
   f = not f;

}else if(a != 100 and f ) {

   a--;
   f = a!=2 ;

}else{

   a+=10;
   f = a < 100 ;

}

var b = if( a +3 < 100 ) 10 else if( -100 < a - 3 ) -10 else 0;

  1. Operator For
    1. Copy the code to the editor:
               
      

for(a in [1..100]){

   println(a+10);

}

var seq = for(b in [1,5,9]) b + b / 2;

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted

for(a in [1..100]){

   println(a+10);

}

var seq = for(b in [1,5,9]) b + b / 2;

  1. Operator While
    1. Copy the code to the editor:
               
      

var a = 10;

while(a < 100){

   a++;
   a * 2;
   println(a);

}

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted

var a = 10;

while(a < 100){

   a++;
   a * 2;
   println(a);

}

  1. Operator Try-Ctach
    1. Copy the code to the editor:
               
      

import java.io.FileReader; import java.io.BufferedReader;

import java.io.IOException; import java.lang.RuntimeException;

try {

   var reader = new BufferedReader(new FileReader("infilename"));
   var str = "";
   while (str != null) {
       println(str);
   }
   reader.close();
   throw new RuntimeException("");
   

} catch (e: IOException) {

   e.printStackTrace();

}catch(e: java.lang.Exception){

   println("Exception: {e.getMessage()}");

}finally{

   println("The end");

}

    1. Format the code (press <Ctrl+F5>).
    • EXPECTED RESULT: The code should be formatted

import java.io.FileReader; import java.io.BufferedReader;

import java.io.IOException; import java.lang.RuntimeException;

try {

   var reader = new BufferedReader(new FileReader("infilename"));
   var str = "";
   while (str != null) {
       println(str);
   }
   reader.close();
   throw new RuntimeException("");
   

} catch (e: IOException) {

   e.printStackTrace();

}catch(e: java.lang.Exception){

   println("Exception: {e.getMessage()}");

}finally{

   println("The end");

}



Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo