Math.round doesn't work

Hi everyone!
I have a problem with the Math.round function. When I code:
Math.round(undefined);
in my flash-movie, it returns the number 0!! But when I test
the same code in a new flash document it returns NaN.
So my question will sound: Why does it return 0??
/Tobias

Thanx for the answers!!
Actually, it is a variable instead of "undefined". I wrote
"undefined" because it should be easier to see the problem then.
The variable can namely be undefined sometimes. But I will do as
Jeckyl said, check before rounding!!
Thank you very much!!
/Tobias

Similar Messages

  • Finally got round to buying an iPhone 4, really excellent to start with. The sharing of music from my Mac Mini was excellent. ios6 update has ruined all that! The artist view miss's out most of my music and the sharing sometimes doesn't work at all!

    Finally got round to buying an iPhone 4, really excellent to start with. The sharing of music from my Mac Mini was excellent. ios6 update has ruined all that! The artist view miss's out most of my music and the sharing sometimes doesn't work at all!
    How do I get this feature working again? I am reluctant to move to iTunes 10.7 because I don't trust Apple at the moment.

    My suggestion:
    1) Always using MAC AIR with the power plug in.
    2)Don' let the power level of battory fall under 30% percentage.
    3)If the MAC can't be recharged now, just let it be with power plugged, WAIT...

  • Round Robin doesn't work in Bea Weblogic Cluster

    hello!
              we are using a weblogic (V5.1 SP8) cluster in the following configuration:
              2 Weblogic App-Servers as Servlet Containers.
              4 Weblogic App-Servers as EJB Containers.
              if a client connects to the first servlet - server, round robin between the
              4 EJB-servers behind doesn't work. It seems that the servlet-server is
              pinned to one EJB-server all the time.
              If we kill the second servlet-server as from now on round robin works in the
              EJB-server cluster like we expected.
              As we changed this configuration and also use an IPlanet webserver (one
              instance) with the weblogic proxy-plugin which connects to the
              servlet-cluster (2 instances)... round robin is working properly in the
              EJB-server cluster when the client connects to the IPlanet-server....
              what is the problem, why doesn't round robin work in the first
              configuration? any suggestions?
              Torsten Jenkner
              

    Okay, is it that the round-robining is not perfect (i.e., it doesn't send the
              first request to server1 and the second request to server2 and so on) or is it
              sending every request to one server?
              Torsten Jenkner wrote:
              > yes exactly Robert that's it!
              >
              > Torsten
              >
              > "Robert Patrick" <[email protected]> schrieb im Newsbeitrag
              > news:[email protected]...
              > > I don't understand this. Are you saying that with servlet node 1 or
              > servlet
              > > node 2 running by themselves that RR works fine but once you start both
              > > together, it does not?
              > >
              > > This sounds like a case for support...
              > > Robert
              > >
              > > Torsten Jenkner wrote:
              > >
              > > > > > it is always the same stub in our case. Also the round robin in the
              > EJB
              > > > > > cluster does with the same java classes but does not if the servlet
              > > > cluster
              > > > > > consits of two nodes. So it seems to be a configuration problem, but
              > > > which
              > > > > > one?
              > > > >
              > > > > Hmm.... I don't quite understand this last statement about the EJB
              > and
              > > > servlet
              > > > > cluster, could you explain a little more?
              > > > >
              > > > > Thanks,
              > > > > Robert
              > > > >
              > > >
              > > > if you use 2 servlet cluster nodes round robin between the
              > servlet-cluster
              > > > and the ejb-cluster doesn't work. if i kill the second servlet-node it
              > works
              > > > fine. so my thought was it has to be a configuration problem, because RR
              > > > does with one servlet-node. ok?
              > > >
              > > > Torsten Jenkner
              > >
              

  • Round back button doesn't work

    The round button on the edge doesn't work. Have to power off to get back to home page.

    Calibrate Home Button
    1. Open a stock application like Calendar, Weather or Youtube
    2. Hold down the power button until the "slide to power off" control appears
    3. As soon as you see it, press the Home button and keep it pressed until the red slider disappears and the app is forced quit to the Home menu

  • Atan in jdk1.1.8 doesn't work. help

    I am creating a program which simulate the effect of gravity on a object (for a game). For this I am working with jdk1.1.8. (not by choice). But for some reason the movement of the object just turns around. I believed that de method Math.atan2 was wrong so i have rewritten it and it worked better. But the method atan most likely doesn't work either because it is not perfect yet. Does anyone know or have an implementation of de atan method in java that works so i can use it? Because I don't know how the method works.
    maybe i am wrong here but it is basicly the only solution to my problem. if give the code of the bullet class with it. maybe anyone sees the problem there:
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class Bullet extends Thread
         public static boolean running = false;
         private double x, y;
         private double width=10, height=10;
         private double weight=10;
         private double travelAngle = toRadians(45);
         private double speed=5;
         private Attraction hello;
         private Planet[] planets;
         private int planetCount=0;
         Bullet(Attraction hello, int x, int y, int angle, Planet[] planets)
              this.hello = hello;
              this.x = x;
              this.y = y;
              this.travelAngle = toRadians(angle);
              this.planets = planets;
              this.planetCount = planets.length;
              running = true;
         public void run()
              double px=0, py=0, g=0;//comes from the planet
              //variable for the calculation
              Planet p = null;
              double dx=0, dy=0, dx2=0, dy2=0, fdx=0, fdy=0, totalfdx=0, totalfdy=0;
              double forceAngle=0;
              double d=0, gd=0, force=0;
              double oldx = 0;
              double oldy = 0;
              int drawSteps = 0; //for smooth drawing
              double dxSteps=0, dySteps=0;
              double oldspeed = speed;
              while(running)
                   oldspeed = speed;
                   totalfdx=0;
                   totalfdy=0;
                   oldx = x;
                   oldy = y;
                   dx = Math.cos(travelAngle)*speed;//the normal translation for x without the gravity effect
                   dy = Math.sin(travelAngle)*speed;//the normal translation for y without the gravity effect
                   x+=dx;//new x from the normal translation
                   y+=dy;//new y from the normal translation
                   for(int i = 0; i<planetCount; i++)
                        p = planets;
                        px = p.getX();//x coordinate of the planet
                        py = p.getY();//y coordinate of the planet
                        g = p.getGravity();//gravity of the planet
                        dx2 = px - x; //the x-difference between the bullet and the planet
                        dy2 = py - y; //the y-difference between the bullet and the planet
                        //System.out.println(dx2 + " "+ dy2);
                        d = Math.sqrt(dx2*dx2+dy2*dy2); //the direct distance between the bullet and the planet
                        //System.out.println("distance " + d);
                        gd = g/d; //the effect of the gravity at the distance of the bullet
                        //System.out.println("gravitydistance" + gd);
                        force = gd*weight; //the forcepull on the object from the planet
                        forceAngle = atan2(dy2,dx2);//the angle of the force with the y-axis
                        //System.out.println("force " + force + " distance " + d);
                        fdx = force * Math.sin(forceAngle);//the force pull distance for x
                        fdy = force * Math.cos(forceAngle);//the force pull distance for y
                        //System.out.println(fdx + " " + fdy);
                        totalfdx += fdx;
                        totalfdy += fdy;
                   x = x+totalfdx;//new x
                   y = y+totalfdy;//new y
                   //System.out.println("Angle" + toDegrees(travelAngle));
                   travelAngle = atan2( (x-oldx), (y-oldy) );
                   speed = Math.sqrt((x-oldx)*(x-oldx) + (y-oldy)*(y-oldy));
                   if(oldx>x)
                        System.out.println("Turning point");
                   System.out.println(oldspeed + " " + speed);
                   //System.out.println("x=> " + x + " y=> " + y);
                   drawSteps = (int)(speed+1);
                   dxSteps = (x-oldx)/drawSteps;
                   dySteps = (y-oldy)/drawSteps;
                   x = oldx + dxSteps;
                   y = oldy + dySteps;
                   hello.repaint((int)x,(int)y, (int)width, (int)height);
                   for(int i = 0; i<drawSteps; i++)
                        x+=dxSteps;
                        y+=dySteps;
                        hello.repaint((int)(x-dxSteps), (int)(y-dySteps), (int)(width+width), (int)(height+height));
                        try
                             sleep(30);
                        catch(Exception e){}
                   hello.repaint((int)x,(int)y, (int)width, (int)height);
                   //hello.repaint();
                   try
                        sleep(100);
                   catch(Exception e){}
                   System.out.flush();
                   for(int i = 0; i<planetCount; i++)
                        p = planets[i];
                        if(p.contains(x,y))
                             System.out.println("Boom");
                             running = false;
              System.out.println("Bullet Stopped");
         public void draw(Graphics g)
         g.setColor(Color.cyan);
              g.fillRect((int)Math.round(x-width/2), (int)Math.round(y-height/2), (int)width, (int)height);
         public void move(boolean left, boolean right)
              if(left)
                   x--;
                   hello.repaint(x, y-2, width+5, height+5);
              if(right)
                   x++;
                   hello.repaint(x+1, y-2, width+5, height+5);
         public double toRadians(double angle)
              return (angle/180*Math.PI);
         private double toDegrees(double angle)
              return (angle/Math.PI*180);
         private double atan2(double a, double b)
              if(a>0)
                   if(b<0)
                        return (Math.atan(b/a)+(2*Math.PI));
                   return Math.atan(b/a);
              else if(a<0)
                   return (Math.atan(b/a)+Math.PI);
              else if(a==0 && b>0)
                   return ((Math.PI)/2);
              else if(a==0 && b<0)
                   return ((3*Math.PI)/2);
              else
                   return 0;

    I have allready tested my code to the max en I have redone the calculations about 4 times, because I couldn't believe the fault was in the method atan or atan2 from sun. But since my calculations should work in theorie (worked it out with a math teacher) it's the only options I could think of.
    [qoute]
    I haven't looked up in the API docs how atan2 is supposed to work, but I noticed these two lines in your code:
    forceAngle = atan2(dy2,dx2);//the angle of the force with the y-axis
    travelAngle = atan2( (x-oldx), (y-oldy) );
    In one place you use Y and X as the parameters and in the other case you use X and Y. They can't both be right.
    [qoute]
    In this case it is. because the forceangle is opposite the x-axis and thus the two must be reversed. (travelangle is opposite the y-axis).
    I have also tried to reverse them (for both) but the effect got worse :)
    Thanks anyway.

  • Merge 2 code and script doesn't work anymore

    I have 2 AS2 codes (I think). One is a carousel gallery script that lets pictures flying in a circle. And the second code is the one that let words fly, downloaden from http://www.levitated.net/daily/levTextSpace.html.
    The scripts work seperatly, but once i merge the codes together the levTextSpace doesn't work anymore. And I can't find where the problem is. Fla file is included.
    Carousel gallery:
    picData = new XML();
    picData.ignoreWhite = true;
    picData.onLoad = loadXML;
    picData.load("md_photos.xml");
    function loadXML() {
         _root.createEmptyMovieClip("thumbnails", 1);
         images = new Array();
         for (i=0; picData.firstChild.childNodes[i].firstChild.nodeValue != undefined; i++) {
              images.push(picData.firstChild.childNodes[i].firstChild.nodeValue);
         thumbnails._x = 750;
         thumbnails._y = 75;
         imageLoading = true;
         numObjects = images.length;
         objectsInScene = new Array();
         focalLength = 750;
         spin = 0;
         _root.thumbnailSize = 350/((numObjects)/9);
         displayPane = function () {
              var angle = this.angle+spin;
              var x = Math.cos(angle)*this.radius;
              var z = Math.sin(angle)*this.radius;
              var y = this.y;
              var scaleRatio = focalLength/(focalLength+z);
              this._x = x*scaleRatio;
              this._y = y*scaleRatio;
              this._xscale = -(this._yscale=100*scaleRatio);
              this._xscale *= Math.sin(angle);
              this.swapDepths(Math.round(-z));
         angleStep = 2*Math.PI/numObjects;
         for (i=0; i<numObjects; i++) {
              thumbnail = thumbnails.createEmptyMovieClip("thumbnail_"+i, i);
              myPic = thumbnail.createEmptyMovieClip("picHolder", 1);
              myPic.loadMovie(images[i]);
              thumbnail.angle = angleStep*i;
              thumbnail.radius = 650;
              thumbnail.x = Math.cos(thumbnail.angle)*thumbnail.radius;
              thumbnail.z = Math.sin(thumbnail.angle)*thumbnail.radius;
              thumbnail.y = 0;
              thumbnail.display = displayPane;
              thumbnail.drawBox(_root.thumbnailSize);
              thumbnail.buttonize(i);
              thumbnail.notLoaded = true;
              objectsInScene.push(thumbnail);
         panCamera = function () {
              spin -= 0.001;
              for (var i = 0; i<objectsInScene.length; i++) {
                   objectsInScene[i].display();
         thumbnails.onEnterFrame = panCamera;
         _root.onEnterFrame = function() {
              for (i=0; i<images.length; i++) {
                   if ((_root.thumbnails["thumbnail_"+i].picHolder.getBytesLoaded()/_root.thumbnails["thumbnail_"+i].picHolder.getBytesTotal() == 1) && _root.thumbnails["thumbnail_"+i].notLoaded) {
                        if (_root.thumbnails["thumbnail_"+i].picHolder._width>=_root.thumbnails["thumbnail_"+i].picHolder._height) {
                             _root.thumbnails["thumbnail_"+i].picHolder._yscale = _root.thumbnails["thumbnail_"+i].picHolder._xscale=(100*(1-(_root.thumbnails["thumbnail_"+i].picHolder._width-_root.thumbnailSize)/(_root.thumbnails["thumbnail_"+i].picHolder._width)));
                             _root.thumbnails["thumbnail_"+i].picHolder._y = (_root.thumbnailSize-_root.thumbnails["thumbnail_"+i].picHolder._height)/2;
                        if (_root.thumbnails["thumbnail_"+i].picHolder._width<=_root.thumbnails["thumbnail_"+i].picHolder._height) {
                             _root.thumbnails["thumbnail_"+i].picHolder._yscale = _root.thumbnails["thumbnail_"+i].picHolder._xscale=(100*(1-(_root.thumbnails["thumbnail_"+i].picHolder._height-_root.thumbnailSize)/(_root.thumbnails["thumbnail_"+i].picHolder._height)));
                             _root.thumbnails["thumbnail_"+i].picHolder._x = (_root.thumbnailSize-_root.thumbnails["thumbnail_"+i].picHolder._width)/2;
                        if (_root.thumbnails["thumbnail_"+i].picHolder._width == _root.thumbnails["thumbnail_"+i].picHolder._height) {
                             _root.thumbnails["thumbnail_"+i].picHolder._yscale = _root.thumbnails["thumbnail_"+i].picHolder._xscale=(100*(1-(_root.thumbnails["thumbnail_"+i].picHolder._width-_root.thumbnailSize)/(_root.thumbnails["thumbnail_"+i].picHolder._width)));
                             _root.thumbnails["thumbnail_"+i].picHolder._x = _root.thumbnails["thumbnail_"+i].picHolder._y=0;
                        _root.thumbnails["thumbnail_"+i].picHolder._alpha = 80;
                        _root.thumbnails["thumbnail_"+i].notLoaded = false;
                   if ((_root.thumbnails["thumbnail_"+i].picHolder.getBytesLoaded()/_root.thumbnails["thumbnail_"+i].picHolder.getBytesTotal()<1)) {
    levTextSpace:
    // register root as environment
    Object.environment = _root;
    // create camera object
    this.cam = {x:0, y:0, z:500, dx:0, dy:0, dz:-500};
    // set environmental constants
    this.fl = 1000;
    // create 'space' to which all words will be attached
    this.createEmptyMovieClip("space", 2);
    // center 'space' on the stage
    space._x = 800;
    space._y = 900;
    // a string of words related to the wind
    this.keywords = "no-nonsense  full-service partner  co-creation  innovation  keep it simple  technical expertise  integral design method  successful products  teamwork  designers engineers  design for (dis)assembly  sustainability  ecological  smart  ideation  feasability study  ergonomic analysis  imagineering  trade off matrix  prototyping  consultancy  technology  problemsolvers  open-minded  multi-disciplinary  imagination  creative minds  passionated  user centered  strategy  added value";
    // convert the string of words into an array of words
    this.wordList = new Array();
    this.wordList = this.keywords.split("  ");
    // create one instance for each word in the list
    for (n=0; n<this.wordList.length; n++) {
        // pick a word from the list
        var word = Object.environment.wordList[n];
        var x = random(600)-(300);
        var y = random(400)-(200);
        var z = random(Object.environment.fl*2)-Object.environment.fl;
        // create an instance of the keyWord object
        nombre = "word"+String(depth++);
        initialization = {txtword: word, x: x, y: y, z: z};
        space.attachMovie("keyWord", nombre, depth, initialization);
        trace(nombre);
    this.onEnterFrame = function() {
        this.cam.dz += 5;
        // move the camera to its destination
        this.cam.x += (this.cam.dx-this.cam.x)/10;
        this.cam.y += (this.cam.dy-this.cam.y)/10;
        this.cam.z += (this.cam.dz-this.cam.z)/30;

    change the highlighted text
    picData = new XML();
    picData.ignoreWhite = true;
    picData.onLoad = loadXML;
    picData.load("md_photos.xml");
    function loadXML() {
         _root.createEmptyMovieClip("thumbnails", 1);
         images = new Array();
         for (i=0; picData.firstChild.childNodes[i].firstChild.nodeValue != undefined; i++) {
              images.push(picData .firstChild.childNodes[i].firstChild.nodeValue);
         thumbnails._x = 750;
         thumbnails._y = 75;
         imageLoading = true;
         numObjects = images.length;
         objectsInScene = new Array();
         focalLength = 750;
         spin = 0;
         _root.thumbnailSize = 350/((numObjects)/9);
         displayPane = function () {
              var angle = this.angle+spin;
              var x = Math.cos(angle)*this.radius;
              var z = Math.sin(angle)*this.radius;
              var y = this.y;
              var scaleRatio = focalLength/(focalLength+z);
              this._x = x*scaleRatio;
              this._y = y*scaleRatio;
              this._xscale = -(this._yscale=100*scaleRatio);
              this._xscale *= Math.sin(angle);
              this.swapDepths(Mat h.round(-z));
         angleStep = 2*Math.PI/numObjects;
         for (i=0; i<numObjects; i++) {
              thumbnail = thumbnails.createEmptyMovieClip("thumbnail_"+i, i);
              myPic = thumbnail.createEmptyMovieClip("picHolder", 1);
              myPic.loadMovie(ima ges[i]);
              thumbnail.angle = angleStep*i;
              thumbnail.radius = 650;
              thumbnail.x = Math.cos(thumbnail.angle)*thumbnail.radius;
              thumbnail.z = Math.sin(thumbnail.angle)*thumbnail.radius;
              thumbnail.y = 0;
              thumbnail.display = displayPane;
              thumbnail.drawBox(_ root.thumbnailSize);
              thumbnail.buttonize (i);
              thumbnail.notLoaded = true;
              objectsInScene.push (thumbnail);
         panCamera = function () {
              spin -= 0.001;
              for (var i = 0; i<objectsInScene.length; i++) {
                 & nbsp; objectsInScene[i].display();
         thumbnails.onEnterFrame = panCamera;
         _root.onEnterFrame = function() {
              for (i=0; i<images.length; i++) {
                 & nbsp; if ((_root.thumbnails["thumbnail_"+i].picHolder.getBytesLoaded()/_root.thumbnails["thumbnail_"+i].picHolder.getBytesTotal() == 1) && _root.thumbnails["thumbnail_"+i].notLoaded) {
                 & nbsp;      if (_root.thumbnails["thumbnail_"+i].picHolder._width>=_root.thumbnails["thumbnail_"+i].picHolder._height) {
                 & nbsp;           _root.thu mbnails["thumbnail_"+i].picHolder._yscale = _root.thumbnails["thumbnail_"+i].picHolder._xscale=(100*(1-(_root.thumbnails["thumbnail_"+i].picHolder._width-_root.thumbnailSize)/(_root.thumbnails["thumbnail_"+i].picHolder._width)));
                 & nbsp;           _root.thu mbnails["thumbnail_"+i].picHolder._y = (_root.thumbnailSize-_root.thumbnails["thumbnail_"+i].picHolder._height)/2;
                 & nbsp;      }
                 & nbsp;      if (_root.thumbnails["thumbnail_"+i].picHolder._width<=_root.thumbnails["thumbnail_"+i].picHolder._height) {
                 & nbsp;           _root.thu mbnails["thumbnail_"+i].picHolder._yscale = _root.thumbnails["thumbnail_"+i].picHolder._xscale=(100*(1-(_root.thumbnails["thumbnail_"+i].picHolder._height-_root.thumbnailSize)/(_root.thumbnails["thumbnail_"+i].picHolder._height)));
                 & nbsp;           _root.thu mbnails["thumbnail_"+i].picHolder._x = (_root.thumbnailSize-_root.thumbnails["thumbnail_"+i].picHolder._width)/2;
                 & nbsp;      }
                 & nbsp;      if (_root.thumbnails["thumbnail_"+i].picHolder._width == _root.thumbnails["thumbnail_"+i].picHolder._height) {
                 & nbsp;           _root.thu mbnails["thumbnail_"+i].picHolder._yscale = _root.thumbnails["thumbnail_"+i].picHolder._xscale=(100*(1-(_root.thumbnails["thumbnail_"+i].picHolder._width-_root.thumbnailSize)/(_root.thumbnails["thumbnail_"+i].picHolder._width)));
                 & nbsp;           _root.thu mbnails["thumbnail_"+i].picHolder._x = _root.thumbnails["thumbnail_"+i].picHolder._y=0;
                 & nbsp;      }
                 & nbsp;      _root.thumbnails["thumbnail_"+i].picHolder._alpha = 80;
                 & nbsp;      _root.thumbnails["thumbnail_"+i].notLoaded = false;
                 & nbsp; }
                 & nbsp; if ((_root.thumbnails["thumbnail_"+i].picHolder.getBytesLoaded()/_root.thumbnails["thumbnail_"+i].picHolder.getBytesTotal()<1)) {
                 & nbsp; }
    levTextSpace:
    // register root as environment
    Object.environment = _root;
    // create camera object
    this.cam = {x:0, y:0, z:500, dx:0, dy:0, dz:-500};
    // set environmental constants
    this.fl = 1000;
    // create 'space' to which all words will be attached
    this.createEmptyMovieClip("space", 2);
    // center 'space' on the stage
    space._x = 800;
    space._y = 900;
    // a string of words related to the wind
    this.keywords = "no-nonsense  full-service partner  co-creation  innovation  keep it simple  technical expertise  integral design method  successful products  teamwork  designers engineers  design for (dis)assembly  sustainability  ecological  smart  ideation  feasability study  ergonomic analysis  imagineering  trade off matrix  prototyping  consultancy  technology  problemsolvers  open-minded  multi-disciplinary  imagination  creative minds  passionated  user centered  strategy  added value";
    // convert the string of words into an array of words
    this.wordList = new Array();
    this.wordList = this.keywords.split("  ");
    // create one instance for each word in the list
    for (n=0; n<this.wordList.length; n++) {
        // pick a word from the list
        var word = Object.environment.wordList[n];
    // changing the next 3 lines probably will change where the words appear
        var x = random(600)-(300);
        var y = random(400)-(200);
        var z = random(Object.environment.fl*2)-Object.environment.fl;
        // create an instance of the keyWord object
        nombre = "word"+String(depth++);
        initialization = {txtword: word, x: x, y: y, z: z};
        space.attachMovie("keyWord", nombre, depth, initialization);
        trace(nombre);
    this.createEmptyMovieClip("loopMC",this.getNextHighestDepth);
    loopMC.onEnterFrame = function() {
        this.cam.dz += 5;
        // move the camera to its destination
        this.cam.x += (this.cam.dx-this.cam.x)/10;
        this.cam.y += (this.cam.dy-this.cam.y)/10;
        this.cam.z += (this.cam.dz-this.cam.z)/30;

  • My applet doesn't work on Linux

    I've heard from some people working on Linux platform that my applet http://astro.ia.uz.zgora.pl/~nirgal/psren.htm doesn't work even if they have proper JRE plugin installed. The same people can run other applets on other web sites. The applet works good on Windows platform browsers.
    Dear Linux users, do you have any ideas about this issue?

    Ok, I hope the code of the main applet class will help to solve the problem. Surely there is some bug (because other applets work). But I'm curious why it runs well on Windows at the same time?
    package main;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import pulsarek.*;
    * Created on 28-Mar-2005
    * @author Nirgal
    public class PSRSim extends JApplet {
         private static Napisy napisy = new NapisyEng();
         private Maszyna mach = new Maszyna2();
         private PanelSredni averageP = new PanelSredni(napisy);
         private PanelSingli singleP = new PanelSingli(napisy);
         private Profil prof = new Profil(mach,averageP,singleP,null);
         private JTabbedPane tp = new JTabbedPane();
         private JButton spb = new JButton(napisy.getStartpauza());
         private JButton sb = new JButton("STOP");
         private JSlider speed = new JSlider(JSlider.HORIZONTAL,0,5,Maszyna.POS);
         private JProgressBar prog = mach.getBar();
         private EtchedBorder eb = new EtchedBorder();
         private Capanel polarCap = new Capanel(mach,napisy);
         //private static Logger loger = Logger.getLogger("PSRSim");
         public PSRSim() throws Exception{
              //loger.addHandler(new ConsoleHandler());
              //loger.setLevel(Level.OFF);
         public void init(){
              spb.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent e){
                        if(mach.getStan()==0){     //stopped
                             mach.setStart();
                        }else     
                        if(mach.getStan()==2)     //paused
                             mach.setStart();
                        else
                             if(mach.getStan()==1)     //running
                                  mach.setPause();
              sb.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent e){
                        mach.setStop();
              speed.addChangeListener(new ChangeListener(){
                   public void stateChanged(ChangeEvent e){
                        int pulsy = (int)Math.pow(2,((JSlider)e.getSource()).getValue());
                        mach.setDelay((int)Math.round(1000/pulsy));
                        //loger.info("Sleep time: "+(1000/((JSlider)e.getSource()).getValue()));
              Container cp = getContentPane();
              cp.setLayout(null);          
              tp.add(napisy.getParamogolne(),new MainParams(mach,napisy));
              tp.add(napisy.getCzapa(),new CapParams(mach,napisy));
              tp.add(napisy.getObliczenia(),new Obliczenia(mach,napisy));
                   tp.reshape(5,0,300,250);
                   prog.reshape(190,255,120,40);
                   speed.reshape(190,315,120,50);
                   speed.setSnapToTicks(true);
                   speed.setMinorTickSpacing(1);
                   speed.setPaintTicks(true);
                   spb.reshape(190,375,120,25);
                   sb.reshape(190,410,120,25);
                   averageP.reshape(315,1,310,150);
                   singleP.reshape(315,150,310,295);
                   polarCap.reshape(5,255,181,191);
                   TitledBorder polarCapB = BorderFactory.createTitledBorder(eb,napisy.getCzapapolarna());
                   polarCap.setBorder(polarCapB);
                   speed.setBorder(new TitledBorder(napisy.getPredkoscsymulacji()));
                   prog.setBorder(new TitledBorder(napisy.getPostep()));
              cp.add(prog);     
              cp.add(speed);     
              cp.add(tp);
              cp.add(spb);
              cp.add(sb);
              cp.add(averageP);
              cp.add(singleP);
              cp.add(polarCap);
              class MojListener implements ComponentListener{
                   public void componentMoved(ComponentEvent e){
                        e.getComponent().repaint();
                        singleP.repaint();
                        e.getComponent().hide();
                   public void componentShown(ComponentEvent e){
                   public void componentHidden(ComponentEvent e){
                   public void componentResized(ComponentEvent e){
              addComponentListener(new MojListener());
         public static void main(String[] args) throws Exception{
              JApplet applet = new PSRSim();
              JFrame frame = new JFrame("PSR Simulator");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.getContentPane().add(applet);
              frame.setSize(640,480);
              applet.init();
              applet.start();
              frame.setVisible(true);
    }

  • Math.round with checkbox for tax

    I have a form that needs to calculate sales tax. If it ships to California, then tax is applied.
    I have been attempting to cobble together a Boolean JavaScript in Acrobat v8 (on a Mac) using Math.round(). No luck, it always defaults to else. I have searched this forum, planetpdf, bought Padlova's Acrobat Forms book, and just have been stonewalled on this issue.
    I have a series of items that SubTotal - ItemTotal.1, ItemTotal.2, ItemTotal.3 using the simplified Value is menu.
    California tax is calculated with (Tax * SubTotal) * 0.0725, where Tax is a checkbox with a Mouseup value of 1. When the checkbox is active, the tax is added, otherwise the tax value is zero.
    As near as I can tell looking at the State Board of Equalizations tax tables, Acrobats default rounding is displaying the correct amount of tax.
    Is there any reason I shouldnt leave this as it stands, as opposed to more research into the correct syntax for Math.round() with a checkbox variable?

    Interesting - but exactly the sort of thing a programmer hates. It
    gives a huge table, but it doesn't give the exact rules needed to
    actually write legal code.
    There isn't a generic standard to use. In fact, in some states, the
    rule changed. For example, in 2005, Ohio changed to "The computation
    shall be carried out to three decimal places. If the result is a
    fractional amount of a cent, the calculated tax shall be rounded to a
    whole cent using a method that rounds up to the next cent whenever the
    third decimal place is greater than four. A vendor may elect to
    compute the tax due on a transaction on an item or an invoice basis."
    Instead of "always rounding up in any case where the tax calculation
    yielded any fractional amount over a whole cent".
    But you say "rounds up". Let's test that with the table. $100 is a
    good starting point. 7.75% of $100 is exactly $7.75, so no rounding is
    needed. This matches the table, which says that amounts over $99.93
    pay $7.75 tax. So, what about $99.93? Calculated exactly, 7.75% is
    $7.744575. If this were simply rounded up, the tax would be $7.75.
    This suggests it is actually rounded to the closest, and might be the
    same as the new Ohio rule. Or some variation on it.
    Interestingly, there is a California sales tax calculator on
    http://www.csgnetwork.com/salestaxcalc.html, and it seems to match the
    table. They do offer a JavaScript calculator for license, and given
    that it runs to something like 60 lines of code, this may be worth
    considering, as reimplementing it (without copying) sounds hard work.
    Aandi Inston

  • Can't lower voice memo volume. My decrease button doesn't work anymore. Any other way i can lower it without disabling speaker

    Own an iphone 5. Can't control voice memo volume from anywhere that deals with volume on my phone. My decrease button doesn't work. I have to listen to my voice memos on full blown volume. Can't lower it from settings or from music. Help please!

    Hi,
    thanks for your answer. 
    The Size of all disks is: 6 x 4 TB.
    In the Pool are 5 x 4 TB plus 1 x Hot Spare. 
    It comes up to about 14,6 TB of Data formatable.
    But tried it also with just 3 x 4 TB to see if it works. 
    I just made a Raid5EE on the controller and then used Storage Spaces with simple, all worked fine. 
    Here the results of my tests: 
    1) your command had to be modified (typoe in usemaximumsize, and had to add -ResiliencySettingName Parity. 
    new-virtualdisk -friendlyname testpsh -storagepoolfriendlyname test -ResiliencySettingName Parity -usemaximumsize
    But anyway, my problem is not creating the virtual disk, but formatting the partition if it's parity only. 
    I added a screenshot: 
    Here you see my storage pool, and I added 3 virtual disk. 
    1 simple, 1 mirror, 1 parity. Only the parity cannot be formatted. The others can. No mather which size I do. 
    About a testserver, I added 4 x 4 TB to a VM (VHDX-files) and could do parity without problems. So it seems it is this server specific.
    As it worked with another controller, I really wonder if the controller could break parity of Storage Pools?
    The other weird part is, it sais "Raid" as BUS, but it's set to pass through, in details I see the serial of the attached HDD. 
    This is what properties shows on this volume. Always RAW. 
    I also tried Software Raid5 within the server. 
    This also worked fine. So really only parity. 
    Thanks
    Patrick

  • What to do when your program doesn't work.

    A huge number of posts here seem to relate to code that has been written (one presumes by the poster), but which doesn't work.
    I get the impression that people don't know what to do next.
    It's really not that difficult. When you're writing your program you constantly have in mind what you expect will happen as a result of each bit of code that you put.
    If at the end of the day, the program as a whole doesn't behave as you expected, then somewhere in there there must be a point at which the program starts doing something that doesn't correspond to what you anticipated. So, you add some System.err.println statements to test your beliefs.
    Consider this program that tests whether a number is prime.
    public class Test
        public static void main(String args[])
            // Get the number to test.
            int number = Integer.parseInt(args[0]);
            // Try each possible factor.
            int factor;
            for(factor = 2; factor < number; factor++)
                // See whether it is really a factor.
                if(number / factor == 0)
                    break;
            if(factor == number)
                System.out.println("Number is not prime.");
            else
                System.out.println("Number is prime.");
    }Straight forward enough, but it doesn't actually work :( It seems to say that every number is not prime. (Actually, not quite true, but I didn't test it that carefully, since it didn't work).
    Now, I could scrutinise it for errors, and then, having failed to find the problem, I could post it here. But let's suppose I'm too proud for that.
    What might be going wrong. Well, how sure am I that I'm even managing to capture the number of interest, number. Let's put in a System.err.println() to test that.
    Is the program in fact trying the factors I expect? Put in System.err.println() for that.
    Is the program correctly determining whether a number is a factor? Need another System.err.prinln (or two) for that.
    public class Test
        public static void main(String args[])
            // Get the number to test.
            int number = Integer.parseInt(args[0]);
            System.err.println("Number to check is " + number);
            // Try each possible factor.
            int factor;
            for(factor = 2; factor < number; factor++)
                System.err.println("Trying factor " + factor);
                // See whether it is really a factor.
                if(number / factor == 0)
                    System.err.println(factor + " is a factor.");
                    break;
                System.err.println(factor + " is not a factor.");
            if(factor == number)
                System.out.println("Number is not prime.");
            else
                System.out.println("Number is prime.");
    }Let's try with on the number 6.
    The output is:
    Number to check is 6
    Trying factor 2
    2 is not a factor.
    Trying factor 3
    3 is not a factor.
    Trying factor 4
    4 is not a factor.
    Trying factor 5
    5 is not a factor.
    Number is not prime.
    Whoah! That's not right. Clearly, the problem is that it's not correctly deciding whether a number is a factor. Well, we know exactly where that test is done. It's this statement:
                if(number / factor == 0)Hmm.... let's try 6 / 3, 'cos 3 is a factor.
    6 / 3 = 2.
    But that's not zero. What the.... Oh - I see, it should have been number % factor.
    Ok - let's fix that, and run it again.
    Now the output is:
    Number to check is 6
    Trying factor 2
    2 is a factor.
    Number is prime.
    Not the right answer, but at least it's now figured out that 2 is a factor of 6. Let's try a different number.
    Number to check is 9
    Trying factor 2
    2 is not a factor.
    Trying factor 3
    3 is a factor.
    Number is prime.
    Again, got the right factor, but still the wrong answer. Let's try a prime:
    Number to check is 7
    Trying factor 2
    2 is not a factor.
    Trying factor 3
    3 is not a factor.
    Trying factor 4
    4 is not a factor.
    Trying factor 5
    5 is not a factor.
    Trying factor 6
    6 is not a factor.
    Number is not prime.
    Aagh! Obvious - the final test is the wrong way round. Just fix that, remove that System.err.println()s and we're done.
    Sylvia.

    Consider this program that tests whether a number is
    prime.
    [attempt to divide by each integer from 2 to n-1]At risk of lowering the signal to noise ratio, I
    should point out that the algorithm given is just
    about the worst possible.
    I know that the point was to illustrate debugging
    and not good prime test algorithms, and I disagree
    with the correspondent who thought the post was
    condescending.
    Anyway, the java libraries have good prime testing
    methods based on advanced number theory research that the
    non-specialist is unlikely to know. Looking at the java
    libraries first is always a good idea.
    Even with the naive approach, dramatic improvements
    are possible.
    First, only try putative divisors up to the square root
    of the number. For 999997 this is about 1000 times faster.
    Next only try dividing by prime numbers. This is about
    7 times faster again. The snag, of course, is to find the
    prime numbers up to 1000, so there might not be much
    advantage unless you already have such a list. The sieve
    of Erastosthenes could be used. This involves 31 passes
    through an array of 1000 booleans and might allow an
    improvement in speed at the expense of space.
    Sorry if I've added too much noise :-)

  • KA780G second network card doesn't work

    Hi everybody,
    Today, I put an second network card on the KA780G board (it's for a round robin network), on a free PCI slot, and this card isn't recognised by Linux and Windows  (in Windows XP, when the network card is connected, my graphical card works bad as well).
    I tested this network card in another computer and it's working well, I try with another type of network card and it's not working.
    I upgraded the BIOS with the latest release and reset the bios parameters but it doesn't work. 
    Do I need to put some specifics parameters in the BIOS ?
    Someone as an idea ? 
    Thanks
    Matt

    As you want... but I know the truth 
    Transfert a file takes me twice the time when the second network card was unpluged (the test was made with two differents files with the same size, this is for keeping disk caching speeding the transfert).
    I think, your're not understanding, so let me explain the achitecture of my network : two computers pluged to my "super magic switch" (each with one network card) and my NAS with two round robin's network card.
    I transfert one file from the NAS to the first computer and at the same time another file from the NAS to the second computer. The network speed was (on the NAS) about 24MB/s (see with the system monitor).
    If you're right explain me why many people using port trunking with their switches ?
    Matt.

  • Compensation handler and compensate activity doesn't work

    Hi!
    i'm trying to build process with compensation handlers and it doesn't work .. to test it i made the following example:
    in scope_1 there is simple assign_1 and in compensation handler there is assign_2. after scope_1 i throw error and in catchAll branch i have compensate activity - calling compensation of scope_1. But that compensation activity is never invoked! can please someone tell me why? what am i doing wrong?
    I have bpel 10.1.2 ...
    Thanks, Tomas
    This is the source of my process:
    <process name="pokusy" targetNamespace="http://xmlns.oracle.com/pokusy"
    xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
    xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
    xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
    xmlns:ns4="http://xmlns.oracle.com/pcbpel/adapter/db/all_keycodes/"
    xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns5="aa"
    xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
    xmlns:client="http://xmlns.oracle.com/pokusy"
    xmlns:ora="http://schemas.oracle.com/xpath/extension"
    xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc">
    <partnerLinks>
    <partnerLink name="client" partnerLinkType="client:pokusy"
    myRole="pokusyProvider" partnerRole="pokusyRequester"/>
    </partnerLinks>
    <variables>
    <variable name="inputVariable" messageType="client:pokusyRequestMessage"/>
    <variable name="outputVariable" messageType="client:pokusyResponseMessage"/>
    </variables>
    <faultHandlers>
    <catchAll>
    <sequence name="Sequence_2">
    <compensate name="Compensate_2" scope="Scope_1"/>
    <assign name="Assign_3">
    <copy>
    <from expression="concat(bpws:getVariableData('outputVariable','payload','/client:pokusyProcessResponse/client:result'),'after compensate..')"/>
    <to variable="outputVariable" part="payload"
    query="/client:pokusyProcessResponse/client:result"/>
    </copy>
    </assign>
    <invoke name="Invoke_1" partnerLink="client"
    portType="client:pokusyCallback" operation="onResult"
    inputVariable="outputVariable"/>
    </sequence>
    </catchAll>
    </faultHandlers>
    <sequence name="main">
    <receive name="receiveInput" partnerLink="client" portType="client:pokusy"
    operation="initiate" variable="inputVariable" createInstance="yes"/>
    <scope name="Scope_1">
    <compensationHandler>
    <assign name="Assign_2">
    <copy>
    <from expression="concat( bpws:getVariableData('outputVariable','payload','/client:pokusyProcessResponse/client:result'),'...COMPENSATE!!!')"/>
    <to variable="outputVariable" part="payload"
    query="/client:pokusyProcessResponse/client:result"/>
    </copy>
    </assign>
    </compensationHandler>
    <sequence name="Sequence_1">
    <assign name="Assign_1">
    <copy>
    <from expression="concat(bpws:getVariableData('inputVariable','payload','/client:pokusyProcessRequest/client:keyCode'),'...first assign...')"/>
    <to variable="outputVariable" part="payload"
    query="/client:pokusyProcessResponse/client:result"/>
    </copy>
    </assign>
    </sequence>
    </scope>
    <throw name="Throw_1" faultName="ns5:aa"/>
    <invoke name="callbackClient" partnerLink="client"
    portType="client:pokusyCallback" operation="onResult"
    inputVariable="outputVariable"/>
    </sequence>
    </process>

    this might be caused by a bug I found too causing eventhandlers not to work, the work round in your case would be:
    blar blar blar
    </variables>
    <!-- start work round --><scope><!-- end work round -->
    <faultHandlers>
    blar blar blar
    blar blar blar
    </sequence>
    <!-- start work round --></scope><!-- end work round -->
    </process>
    i.e. what I'm saying is that top level handler don't work since they are ignored by the engine because they are not in a scope. Try it and see....

  • Button doesn't work

    The round button at the bottom of the pad screen is not working properly.  It has stopped closing my screen or putting it in sleep mode.  Is the a factory problem and how do I get it working?

    It's called the 'home button', and it may be fixed by some basic troubleshooting.
    First, try rebooting the iPad by pressing and holding both the home and sleep/wake buttons at the same time until the apple logo appears on the screen, and then let go.
    If that doesn't work then...
    Settings/general/reset/reset all settings
    If that doesn't work then...
    Restore as new
    If none of the above steps work the you may need to set up a repair.

  • My sleep buttom doesn't work how can i fix it?

    i have a ipod touch and the sleep buttom doesn't work how can i fix it? thank you

    Hi,
    some people round here had success using a 'Standard DVD-cleaner disc' like the ones for Home Theater Systems.
    Regards
    Stefan

  • Unix Command doesn't work in Tiger

    Hi,
    I've got labs of eMacs that I'm finally upgrading to Tiger. My image seems to work fine, but I'm running into a weird quirk with my "Send Unix" commands via ARD. We're doing NWEA testing and LOVE the unix commands because we can login to machines, turn on TestTaker, login to TestTaker, and select the correct test (math or reading) and the right version of the test.
    The script below works fine on a panther eMac.
    osascript
    tell application "System Events"
    keystroke "1" using command down
    delay 3.0
    keystroke ASCII character 31
    delay 2.0
    keystroke return
    keystroke "n" using command down
    end tell
    On my Tiger machines, the command stops on the:
    "Keystroke ASCII character 31" line (this should arrow down to next test version).
    A report window comes up in ARD with this error message:
    86:104: execution error: System Events got an error: 31 doesn't understand the ASCII character message. (-1708)
    This used to work perfectly, but now I can't get ASCII 31 (or arrow down to work). The real killer is that other techs in my school district have eMacs running tiger with same commands that work (some have to arrow down 16 times to get to correct test version). The other commands (like command 1 and returns, command n) all work fine! Hate to have to touch 80 machines each day to select proper test version when we log in.
    Any Suggestions????

    Try this form of the line:
    keystroke (ASCII character of 31)
    That's worked for some people. Hope it works for you. If it doesn't work as given, try without the parentheses.
    Regards.

Maybe you are looking for

  • How can I use windows software on the IMac

    How can I use windows software on my iMac? I know I can partition the hard drive but do I need to buy Windows OS?

  • System wide PDF presets location is not working in CC

    On both Mac and PC, the system wide location for PDF settings (.joboptions) does not work anymore. /Library/Application Support/Adobe/Adobe PDF/Settings (on a Mac) It is illogical to remove this feature. Even if that folder does not store the main de

  • ODBC Error in OBIEE

    Hello there, Thanks for your help and sharing ideas. I installed OBIEE new version on my windows vista home premium, I created repository in OBI Administrator, I created ODBC data source withh Oracle driver and named as 'Test'. When Itried to import

  • What is /net used for in OS X?

    I ask because canon (Digital Photo Professional) DPP hangs for a while while it lstat's /net. I don't particularly want to implement the workaround discussed in this link: http://luminous-landscape.com/forum/index.php?s=0f16e1b119e7e3b03bd84969919a4e

  • Auto Cropping with video images problem (CS6)

    I'm working with 6 video clips to create a compilation.  All are mp4s.  When 2of them are dropped (or dragged) form the source panel into the timeline, for some reason the video on them is zoomed in, or cropped, to like 30% of the original.  When I v