X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fswingjs%2Fj2s%2Fswingjs%2Ftest%2Fconverter%2FConverter.js;fp=site%2Fswingjs%2Fj2s%2Fswingjs%2Ftest%2Fconverter%2FConverter.js;h=ed68f8a4e6822bb703ea6a46d0fcc08c001d56ca;hp=4c713646a585a2f75d8474be7f33034330b291e6;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/swingjs/j2s/swingjs/test/converter/Converter.js b/site/swingjs/j2s/swingjs/test/converter/Converter.js index 4c71364..ed68f8a 100644 --- a/site/swingjs/j2s/swingjs/test/converter/Converter.js +++ b/site/swingjs/j2s/swingjs/test/converter/Converter.js @@ -1,111 +1,111 @@ -Clazz.declarePackage ("swingjs.test.converter"); -Clazz.load (["javax.swing.JApplet", "swingjs.test.converter.ConverterRangeModel"], "swingjs.test.converter.Converter", ["java.awt.Color", "$.Dimension", "javax.swing.BorderFactory", "$.Box", "$.BoxLayout", "$.JPanel", "$.UIManager", "swingjs.test.converter.ConversionPanel", "$.FollowerRangeModel", "$.Unit"], function () { -c$ = Clazz.decorateAsClass (function () { -this.metricPanel = null; -this.usaPanel = null; -this.metricDistances = null; -this.usaDistances = null; -this.dataModel = null; -this.mainPane = null; -Clazz.instantialize (this, arguments); -}, swingjs.test.converter, "Converter", javax.swing.JApplet); -Clazz.prepareFields (c$, function () { -this.metricDistances = new Array (3); -this.usaDistances = new Array (4); -this.dataModel = new swingjs.test.converter.ConverterRangeModel (); -}); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, swingjs.test.converter.Converter, []); -this.metricDistances[0] = new swingjs.test.converter.Unit ("Centimeters", 0.01); -this.metricDistances[1] = new swingjs.test.converter.Unit ("Meters", 1.0); -this.metricDistances[2] = new swingjs.test.converter.Unit ("Kilometers", 1000.0); -this.metricPanel = new swingjs.test.converter.ConversionPanel (this, "Metric System", this.metricDistances, this.dataModel); -this.usaDistances[0] = new swingjs.test.converter.Unit ("Inches", 0.0254); -this.usaDistances[1] = new swingjs.test.converter.Unit ("Feet", 0.305); -this.usaDistances[2] = new swingjs.test.converter.Unit ("Yards", 0.914); -this.usaDistances[3] = new swingjs.test.converter.Unit ("Miles", 1613.0); -this.usaPanel = new swingjs.test.converter.ConversionPanel (this, "U.S. System", this.usaDistances, new swingjs.test.converter.FollowerRangeModel (this.dataModel)); -this.mainPane = new javax.swing.JPanel (); -this.mainPane.setLayout ( new javax.swing.BoxLayout (this.mainPane, 3)); -if (false) { -this.mainPane.setOpaque (true); -this.mainPane.setBackground ( new java.awt.Color (255, 0, 0)); -}this.mainPane.setBorder (javax.swing.BorderFactory.createEmptyBorder (5, 5, 5, 5)); -this.mainPane.add (javax.swing.Box.createRigidArea ( new java.awt.Dimension (0, 5))); -this.mainPane.add (this.metricPanel); -this.mainPane.add (javax.swing.Box.createRigidArea ( new java.awt.Dimension (0, 5))); -this.mainPane.add (this.usaPanel); -this.mainPane.add (javax.swing.Box.createGlue ()); -this.resetMaxValues (true); -}); -Clazz.defineMethod (c$, "resetMaxValues", -function (resetCurrentValues) { -var metricMultiplier = this.metricPanel.getMultiplier (); -var usaMultiplier = this.usaPanel.getMultiplier (); -var maximum = 10000; -if (metricMultiplier > usaMultiplier) { -maximum = Clazz.doubleToInt (10000 * (usaMultiplier / metricMultiplier)); -}this.dataModel.setMaximum (maximum); -if (resetCurrentValues) { -this.dataModel.setDoubleValue (maximum); -}}, "~B"); -c$.initLookAndFeel = Clazz.defineMethod (c$, "initLookAndFeel", - function () { -var lookAndFeel = null; -if (swingjs.test.converter.Converter.LOOKANDFEEL != null) { -if (swingjs.test.converter.Converter.LOOKANDFEEL.equals ("Metal")) { -lookAndFeel = javax.swing.UIManager.getCrossPlatformLookAndFeelClassName (); -} else if (swingjs.test.converter.Converter.LOOKANDFEEL.equals ("System")) { -lookAndFeel = javax.swing.UIManager.getSystemLookAndFeelClassName (); -} else if (swingjs.test.converter.Converter.LOOKANDFEEL.equals ("Motif")) { -lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel"; -} else if (swingjs.test.converter.Converter.LOOKANDFEEL.equals ("GTK+")) { -lookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; -} else { -System.err.println ("Unexpected value of LOOKANDFEEL specified: " + swingjs.test.converter.Converter.LOOKANDFEEL); -lookAndFeel = javax.swing.UIManager.getCrossPlatformLookAndFeelClassName (); -}try { -javax.swing.UIManager.setLookAndFeel (lookAndFeel); -} catch (e$$) { -if (Clazz.exceptionOf (e$$, ClassNotFoundException)) { -var e = e$$; -{ -System.err.println ("Couldn't find class for specified look and feel:" + lookAndFeel); -System.err.println ("Did you include the L&F library in the class path?"); -System.err.println ("Using the default look and feel."); -} -} else if (Clazz.exceptionOf (e$$, javax.swing.UnsupportedLookAndFeelException)) { -var e = e$$; -{ -System.err.println ("Can't use the specified look and feel (" + lookAndFeel + ") on this platform."); -System.err.println ("Using the default look and feel."); -} -} else if (Clazz.exceptionOf (e$$, Exception)) { -var e = e$$; -{ -System.err.println ("Couldn't get specified look and feel (" + lookAndFeel + "), for some reason."); -System.err.println ("Using the default look and feel."); -e.printStackTrace (); -} -} else { -throw e$$; -} -} -}}); -Clazz.overrideMethod (c$, "init", -function () { -this.resize (300, 170); -this.createAndShowGUI (); -}); -Clazz.defineMethod (c$, "createAndShowGUI", - function () { -swingjs.test.converter.Converter.initLookAndFeel (); -var converter = new swingjs.test.converter.Converter (); -converter.mainPane.setOpaque (true); -this.add (converter.mainPane); -}); -Clazz.defineStatics (c$, -"MULTICOLORED", false, -"LOOKANDFEEL", null); -}); +Clazz.declarePackage ("swingjs.test.converter"); +Clazz.load (["javax.swing.JApplet", "swingjs.test.converter.ConverterRangeModel"], "swingjs.test.converter.Converter", ["java.awt.Color", "$.Dimension", "javax.swing.BorderFactory", "$.Box", "$.BoxLayout", "$.JPanel", "$.UIManager", "swingjs.test.converter.ConversionPanel", "$.FollowerRangeModel", "$.Unit"], function () { +c$ = Clazz.decorateAsClass (function () { +this.metricPanel = null; +this.usaPanel = null; +this.metricDistances = null; +this.usaDistances = null; +this.dataModel = null; +this.mainPane = null; +Clazz.instantialize (this, arguments); +}, swingjs.test.converter, "Converter", javax.swing.JApplet); +Clazz.prepareFields (c$, function () { +this.metricDistances = new Array (3); +this.usaDistances = new Array (4); +this.dataModel = new swingjs.test.converter.ConverterRangeModel (); +}); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, swingjs.test.converter.Converter, []); +this.metricDistances[0] = new swingjs.test.converter.Unit ("Centimeters", 0.01); +this.metricDistances[1] = new swingjs.test.converter.Unit ("Meters", 1.0); +this.metricDistances[2] = new swingjs.test.converter.Unit ("Kilometers", 1000.0); +this.metricPanel = new swingjs.test.converter.ConversionPanel (this, "Metric System", this.metricDistances, this.dataModel); +this.usaDistances[0] = new swingjs.test.converter.Unit ("Inches", 0.0254); +this.usaDistances[1] = new swingjs.test.converter.Unit ("Feet", 0.305); +this.usaDistances[2] = new swingjs.test.converter.Unit ("Yards", 0.914); +this.usaDistances[3] = new swingjs.test.converter.Unit ("Miles", 1613.0); +this.usaPanel = new swingjs.test.converter.ConversionPanel (this, "U.S. System", this.usaDistances, new swingjs.test.converter.FollowerRangeModel (this.dataModel)); +this.mainPane = new javax.swing.JPanel (); +this.mainPane.setLayout ( new javax.swing.BoxLayout (this.mainPane, 3)); +if (false) { +this.mainPane.setOpaque (true); +this.mainPane.setBackground ( new java.awt.Color (255, 0, 0)); +}this.mainPane.setBorder (javax.swing.BorderFactory.createEmptyBorder (5, 5, 5, 5)); +this.mainPane.add (javax.swing.Box.createRigidArea ( new java.awt.Dimension (0, 5))); +this.mainPane.add (this.metricPanel); +this.mainPane.add (javax.swing.Box.createRigidArea ( new java.awt.Dimension (0, 5))); +this.mainPane.add (this.usaPanel); +this.mainPane.add (javax.swing.Box.createGlue ()); +this.resetMaxValues (true); +}); +Clazz.defineMethod (c$, "resetMaxValues", +function (resetCurrentValues) { +var metricMultiplier = this.metricPanel.getMultiplier (); +var usaMultiplier = this.usaPanel.getMultiplier (); +var maximum = 10000; +if (metricMultiplier > usaMultiplier) { +maximum = Clazz.doubleToInt (10000 * (usaMultiplier / metricMultiplier)); +}this.dataModel.setMaximum (maximum); +if (resetCurrentValues) { +this.dataModel.setDoubleValue (maximum); +}}, "~B"); +c$.initLookAndFeel = Clazz.defineMethod (c$, "initLookAndFeel", + function () { +var lookAndFeel = null; +if (swingjs.test.converter.Converter.LOOKANDFEEL != null) { +if (swingjs.test.converter.Converter.LOOKANDFEEL.equals ("Metal")) { +lookAndFeel = javax.swing.UIManager.getCrossPlatformLookAndFeelClassName (); +} else if (swingjs.test.converter.Converter.LOOKANDFEEL.equals ("System")) { +lookAndFeel = javax.swing.UIManager.getSystemLookAndFeelClassName (); +} else if (swingjs.test.converter.Converter.LOOKANDFEEL.equals ("Motif")) { +lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel"; +} else if (swingjs.test.converter.Converter.LOOKANDFEEL.equals ("GTK+")) { +lookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; +} else { +System.err.println ("Unexpected value of LOOKANDFEEL specified: " + swingjs.test.converter.Converter.LOOKANDFEEL); +lookAndFeel = javax.swing.UIManager.getCrossPlatformLookAndFeelClassName (); +}try { +javax.swing.UIManager.setLookAndFeel (lookAndFeel); +} catch (e$$) { +if (Clazz.exceptionOf (e$$, ClassNotFoundException)) { +var e = e$$; +{ +System.err.println ("Couldn't find class for specified look and feel:" + lookAndFeel); +System.err.println ("Did you include the L&F library in the class path?"); +System.err.println ("Using the default look and feel."); +} +} else if (Clazz.exceptionOf (e$$, javax.swing.UnsupportedLookAndFeelException)) { +var e = e$$; +{ +System.err.println ("Can't use the specified look and feel (" + lookAndFeel + ") on this platform."); +System.err.println ("Using the default look and feel."); +} +} else if (Clazz.exceptionOf (e$$, Exception)) { +var e = e$$; +{ +System.err.println ("Couldn't get specified look and feel (" + lookAndFeel + "), for some reason."); +System.err.println ("Using the default look and feel."); +e.printStackTrace (); +} +} else { +throw e$$; +} +} +}}); +Clazz.overrideMethod (c$, "init", +function () { +this.resize (300, 170); +this.createAndShowGUI (); +}); +Clazz.defineMethod (c$, "createAndShowGUI", + function () { +swingjs.test.converter.Converter.initLookAndFeel (); +var converter = new swingjs.test.converter.Converter (); +converter.mainPane.setOpaque (true); +this.add (converter.mainPane); +}); +Clazz.defineStatics (c$, +"MULTICOLORED", false, +"LOOKANDFEEL", null); +});