[2153] | 1 | # ---------------------------------------------------------------------- |
---|
| 2 | # LANGUAGE: Java API |
---|
| 3 | # ====================================================================== |
---|
| 4 | # AUTHOR: Michael McLennan, Purdue University |
---|
[3177] | 5 | # Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
[2153] | 6 | # |
---|
| 7 | # See the file "license.terms" for information on usage and |
---|
| 8 | # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
| 9 | # ====================================================================== |
---|
| 10 | language "Java" { |
---|
| 11 | extension ".java" |
---|
| 12 | command {java RpApp @driver} |
---|
| 13 | |
---|
| 14 | main {// --------------------------------------------------------------------- |
---|
| 15 | // MAIN PROGRAM - generated by the Rappture Builder |
---|
| 16 | // --------------------------------------------------------------------- |
---|
| 17 | |
---|
| 18 | class RpApp { |
---|
| 19 | |
---|
| 20 | public static void main(String args[]) { |
---|
| 21 | String str; |
---|
| 22 | |
---|
| 23 | // open the XML file containing the run parameters |
---|
| 24 | rappture.Library io = new rappture.Library(args[0]); |
---|
| 25 | |
---|
| 26 | ///////////////////////////////////////////////////////// |
---|
| 27 | // Get input values from Rappture |
---|
| 28 | ///////////////////////////////////////////////////////// |
---|
| 29 | @@INPUTS@@ |
---|
| 30 | |
---|
| 31 | ///////////////////////////////////////////////////////// |
---|
| 32 | // Add your code here for the main body of your program |
---|
| 33 | ///////////////////////////////////////////////////////// |
---|
| 34 | |
---|
| 35 | // spit out progress messages as you go along... |
---|
| 36 | rappture.Utils.progress(0, "Starting..."); |
---|
| 37 | rappture.Utils.progress(5, "Loading data..."); |
---|
| 38 | rappture.Utils.progress(50, "Half-way there"); |
---|
| 39 | rappture.Utils.progress(100, "Done"); |
---|
| 40 | |
---|
| 41 | ///////////////////////////////////////////////////////// |
---|
| 42 | // Save output values back to Rappture |
---|
| 43 | ///////////////////////////////////////////////////////// |
---|
| 44 | @@OUTPUTS@@ |
---|
| 45 | |
---|
| 46 | io.result(); |
---|
| 47 | } |
---|
| 48 | }} |
---|
| 49 | |
---|
| 50 | input boolean { |
---|
| 51 | code "\n// get input value for $path" |
---|
| 52 | code "str = io.get(\"$path.current\");" |
---|
| 53 | code "boolean $id = str.equals(\"yes\");" |
---|
| 54 | } |
---|
| 55 | input image { |
---|
| 56 | code "\n// get input value for $path" |
---|
| 57 | code "// returns base64-encoded image data" |
---|
| 58 | code "$id = io.get(\"$path.current\");" |
---|
| 59 | } |
---|
| 60 | input integer { |
---|
| 61 | code "\n// get input value for $path" |
---|
| 62 | code "int $id = io.getInt(\"$path.current\");" |
---|
| 63 | } |
---|
| 64 | input number { |
---|
| 65 | set units [attr get units] |
---|
| 66 | if {$units ne ""} { |
---|
| 67 | code "\n// get input value for $path and convert to $units" |
---|
| 68 | code "str = io.get(\"$path.current\");" |
---|
| 69 | code "double $id = Double.valueOf(rappture.Units.convertString(str, \"$units\", false));" |
---|
| 70 | } else { |
---|
| 71 | code "\n// get input value for $path" |
---|
| 72 | code "double $id = io.getDouble(\"$path.current\");" |
---|
| 73 | } |
---|
| 74 | } |
---|
| 75 | input * { |
---|
| 76 | code "\n// get input value for $path" |
---|
| 77 | code "String $id = io.get(\"$path.current\");" |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | output boolean { |
---|
| 81 | code "\n// save output value for $path" |
---|
| 82 | code "io.put(\"$path.component.xy\", ($id) ? \"yes\" : \"no\");" |
---|
| 83 | } |
---|
| 84 | output curve { |
---|
| 85 | code "\n// save output value for $path" |
---|
| 86 | code "// this shows just one (x,y) point -- modify as needed" |
---|
| 87 | code "str = String.format(\"%g %g\\n\", x, y);" |
---|
| 88 | code "io.put(\"$path.component.xy\", line, true);" |
---|
| 89 | } |
---|
| 90 | output histogram { |
---|
| 91 | code "\n// save output value for $path" |
---|
| 92 | code "// this shows just one point -- modify as needed" |
---|
| 93 | code "// (x,h,w) = x-coord, height of bar, and width of bar (optional)" |
---|
| 94 | code "str = String.format(\"%g %g %g\\n\", x, h, w);" |
---|
| 95 | code "io.put(\"$path.component.xhw\", line, true);" |
---|
| 96 | } |
---|
| 97 | output image { |
---|
| 98 | code "\n// save output value for $path" |
---|
| 99 | code "// data should be base64-encoded image data" |
---|
| 100 | code "io.put(\"$path.current\",$id);" |
---|
| 101 | } |
---|
| 102 | output integer { |
---|
| 103 | code "\n// save output value for $path" |
---|
| 104 | code "io.put(\"$path.current\", Integer.toString($id));" |
---|
| 105 | } |
---|
| 106 | output number { |
---|
| 107 | code "\n// save output value for $path" |
---|
| 108 | code "io.put(\"$path.current\", Double.toString($id));" |
---|
| 109 | } |
---|
| 110 | output * { |
---|
| 111 | code "\n// save output value for $path" |
---|
| 112 | code "io.put(\"$path.current\",$id);" |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | makefile {# simple makefile for a Rappture-based program |
---|
| 116 | |
---|
| 117 | JAVAC = javac |
---|
| 118 | |
---|
| 119 | RAPPTURE_DIR = @@RAPPTUREDIR@@ |
---|
| 120 | CLASSPATH = -classpath $(RAPPTURE_DIR)/lib/java |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | all: @@FILEROOT@@.class |
---|
| 124 | |
---|
| 125 | @@FILEROOT@@.class: @@FILENAME@@ |
---|
| 126 | $(JAVAC) $(CLASSPATH) $< |
---|
| 127 | |
---|
[6307] | 128 | install: |
---|
| 129 | |
---|
[2153] | 130 | clean: |
---|
| 131 | $(RM) @@FILEROOT@@.class run*.xml |
---|
| 132 | } |
---|
| 133 | } |
---|