Boolean in Math

I was just reading through some old presentations and came across a concept of using boolean results in math. The example was...
NewSales = Sales * @ISUDA("NewMbr");
I would imagine that the value would come back "TRUE" or "FALSE". Does "TRUE" evaluate to a "1" and "FALSE" to a zero?? Has anyone ever used this before??
Thanks,
Kevin

Thanks Glenn. Yes, it was a Roske presentation.
I was unaware that logic was numeric, but I guess it makes sense.
Any idea if a boolean attribute type could also be used in math??
CaffeinatedSales = Sales * @ATTRIBUTEBVAL(Caffeinated);
If this is so, I guess I could extrapolate that "True"/"False" would always evaluate to 1/#Mi.
Thanks

Similar Messages

  • Images disappearing / being painted over

    Hi,
    Not especially familiar with images and am having issues with images being painted over when ever I move or adjust the size of my GUI. I built a majority of the GUI using the Form Designer included with Netbeans.
    Would really appreciate any advice, happy to include more detail if required.
    Cheers,
    Tim
    GUIView
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import java.util.Vector;
    import javax.imageio.ImageIO;
    * GUIView.java
    * Created on 22 April 2007, 21:25
    * The GUIView class is responsible to display a graphical interface.
    * This class interacts with the user and the GUIControl class allowing the user to operate the system.
    * @author  Tim
    public class GUIView extends JFrame implements ActionListener {
    // Declare method variables
        private JTextField prodIDInput0;
        private JLabel prodIDLabel0;
        private JLabel prodIDLabel1;
        private JLabel prodIDLabel2;
        private JLabel prodNameLabel0;
        private JLabel prodNameLabel1;
        private JTextField amtRcvdInput0;
        private JLabel amtRcvdLabel0;
        private JButton cancelButton0;
        private JMenu fileMenu0;
        private JMenuItem exportXMLMenuItem;
        private JMenuItem exitMenuItem;
        private JButton findButton0;
        private JLabel itemPrice0;
        private JScrollPane jScrollPane1;
        private JMenuBar menuBar0;
        private JButton paymentButton0;
        private JLabel prodDescLabel0;
        private JLabel prodDescLabel1;
        private JPanel prodImagePanel0;
        private JPanel prodPanel0;
        private JLabel qtyLabel0;
        private JTextField qtyInput0;
        private JLabel totalPrice0;
        private JLabel totalPrice1;
        private JList transList0;
        private JPanel transPanel0;
        private Vector listData;
        private BufferedImage img;
        private GUIControl guiCtl0;
        /** Creates new form GUIView */
        public GUIView (GUIControl guiCtl0) {
            // reference guiCtl object
            this.guiCtl0 = guiCtl0;
        /** initilise gui object */
        public void initGui () {
            // initialise the GUI
            initComponents ();
            // paint image
            paintImage ("images/transparent.gif");
            // show the GUI
            setVisible (true);
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        private void initComponents () {
            // Instantiate GUI objects
            prodIDLabel0 = new JLabel ();
            prodIDLabel1 = new JLabel ();
            prodNameLabel0 = new JLabel ();
            prodNameLabel1 = new JLabel ();
            prodDescLabel0 = new JLabel ();
            prodDescLabel1 = new JLabel ();
            prodImagePanel0 = new JPanel ();
            itemPrice0 = new JLabel ();
            totalPrice0 = new JLabel ();
            totalPrice1 = new JLabel ();
            prodPanel0 = new JPanel ();
            prodIDLabel2 = new JLabel ();
            prodIDInput0 = new JTextField ();
            qtyInput0 = new JTextField ();
            qtyLabel0 = new JLabel ();
            findButton0 = new JButton ();
            transPanel0 = new JPanel ();
            paymentButton0 = new JButton ();
            cancelButton0 = new JButton ();
            amtRcvdInput0 = new JTextField ();
            amtRcvdLabel0 = new JLabel ();
            jScrollPane1 = new JScrollPane ();
            transList0 = new JList ();
            menuBar0 = new JMenuBar ();
            fileMenu0 = new JMenu ();
            listData = new Vector ();
            // default close operation is to terminate the application
            setDefaultCloseOperation (WindowConstants.EXIT_ON_CLOSE);
            // title of the window
            setTitle ("Supermarket Management System");
            // centre the GUI on the screen
            Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment ().getMaximumWindowBounds ();
            rect.grow (-185,-100);
            setBounds (rect);
            // sets the minimum size the wonw can be shrunk to
            setMinimumSize (new java.awt.Dimension (880, 480));
            // sets the name of the frame
            setName ("mainFrame");
            // setup label to show Product ID:
            prodIDLabel0.setFont (new java.awt.Font ("Tahoma", 1, 14));
            prodIDLabel0.setText ("Product ID:");
            // setup label to show the id of the latest product object
            prodIDLabel1.setFont (new java.awt.Font ("Tahoma", 0, 14));
            prodIDLabel1.setText ("");
            prodIDLabel1.setToolTipText ("Product ID");
            // setup label to show Name:
            prodNameLabel0.setFont (new java.awt.Font ("Tahoma", 1, 14));
            prodNameLabel0.setText ("Name:");
            // setup label to show the name of the latest product object
            prodNameLabel1.setFont (new java.awt.Font ("Tahoma", 0, 14));
            prodNameLabel1.setText ("");
            prodNameLabel1.setToolTipText ("Product Name");
            // setup label to show Description:
            prodDescLabel0.setFont (new java.awt.Font ("Tahoma", 1, 14));
            prodDescLabel0.setText ("Description:");
            // setup label to show the description of the latest product object
            prodDescLabel1.setFont (new java.awt.Font ("Tahoma", 0, 14));
            prodDescLabel1.setText ("");
            prodDescLabel1.setToolTipText ("Product Description");
            // align the prodDescLabel1 to TOP
            prodDescLabel1.setVerticalAlignment (SwingConstants.TOP);
            // setup panel to display image
            prodImagePanel0.setBackground (new java.awt.Color (255, 255, 255));
            prodImagePanel0.setBorder (javax.swing.BorderFactory.createEtchedBorder (javax.swing.border.EtchedBorder.RAISED));
            org.jdesktop.layout.GroupLayout prodImagePanel0Layout = new org.jdesktop.layout.GroupLayout (prodImagePanel0);
            prodImagePanel0.setLayout (prodImagePanel0Layout);
            // specify how much the panel expands on the horizontal axis
            prodImagePanel0Layout.setHorizontalGroup (
                    prodImagePanel0Layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (0, 304, Short.MAX_VALUE)
            // specify how much the panel expands on the vertical axis
            prodImagePanel0Layout.setVerticalGroup (
                    prodImagePanel0Layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (0, 255, Short.MAX_VALUE)
            // setup item price label
            itemPrice0.setFont (new java.awt.Font ("Tahoma", 1, 14));
            itemPrice0.setText ("");
            itemPrice0.setToolTipText ("Transaction Item Price information");
            // setup label to display Total Price:
            totalPrice0.setFont (new java.awt.Font ("Tahoma", 1, 18));
            totalPrice0.setText ("Total Price:");
            // setup label to display current transaction total price
            totalPrice1.setFont (new java.awt.Font ("Tahoma", 0, 18));
            totalPrice1.setText ("$0.00");
            totalPrice1.setToolTipText ("Total cost of transaction");
            // setup JPanel to contain product look up components
            prodPanel0.setBorder (BorderFactory.createTitledBorder ("Enter Product"));
            // setup label to display Product ID:
            prodIDLabel2.setText ("Product ID:");
            // setup label to display Quantity:
            qtyLabel0.setText ("Quantity:");
            // setup button and display FIND as the text
            findButton0.setFont (new java.awt.Font ("Tahoma", 0, 14));
            findButton0.setText ("FIND");
            findButton0.setToolTipText ("Click to find product");
            findButton0.addActionListener (this);
            // create new GroupLayout for prodPanel0
            org.jdesktop.layout.GroupLayout prodPanel0Layout = new org.jdesktop.layout.GroupLayout (prodPanel0);
            prodPanel0.setLayout (prodPanel0Layout);
            // set horizontal group
            prodPanel0Layout.setHorizontalGroup (
                    prodPanel0Layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (prodPanel0Layout.createSequentialGroup ()
                    .add (15, 15, 15)
                    .add (prodIDLabel2)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    // add prodIDInput0 JTextField to form
                    .add (prodIDInput0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 126, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add (22, 22, 22)
                    .add (qtyLabel0)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    // addd qtyInput0 JTextField to form
                    .add (qtyInput0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 39, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add (22, 22, 22)
                    .add (findButton0)
                    .addContainerGap (org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            // set vertical group
            prodPanel0Layout.setVerticalGroup (
                    prodPanel0Layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (prodPanel0Layout.createSequentialGroup ()
                    .addContainerGap ()
                    .add (prodPanel0Layout.createParallelGroup (org.jdesktop.layout.GroupLayout.BASELINE)
                    .add (prodIDLabel2)
                    // add prodIDInput0 JTextField to form
                    .add (prodIDInput0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add (qtyLabel0)
                    // add qtyInput0 JTextField to form
                    .add (qtyInput0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add (findButton0))
                    .addContainerGap (org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            // setup JPanel to contain finialise payment components
            transPanel0.setBorder (BorderFactory.createTitledBorder ("Finalise Transaction"));
            // setup button and display PAYMENT as the text
            paymentButton0.setFont (new java.awt.Font ("Tahoma", 0, 14));
            paymentButton0.setText ("PAYMENT");
            paymentButton0.setToolTipText ("Click to finalise transaction");
            // setup button and display CANCEL as the text
            cancelButton0.setFont (new java.awt.Font ("Tahoma", 0, 14));
            cancelButton0.setText ("CANCEL");
            cancelButton0.setToolTipText ("Cancel the current transaction");
            cancelButton0.addActionListener (this);
            // setup label to display Amount received:
            amtRcvdLabel0.setText ("Amount received:");
            // create new GroupLayout for TransPanel0
            org.jdesktop.layout.GroupLayout transPanel0Layout = new org.jdesktop.layout.GroupLayout (transPanel0);
            transPanel0.setLayout (transPanel0Layout);
            // set horizontal group
            transPanel0Layout.setHorizontalGroup (
                    transPanel0Layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (org.jdesktop.layout.GroupLayout.TRAILING, transPanel0Layout.createSequentialGroup ()
                    .addContainerGap (org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add (amtRcvdLabel0)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    // add amtRcvdInput0 JTextField to form
                    .add (amtRcvdInput0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 58, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add (22, 22, 22)
                    .add (paymentButton0)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (cancelButton0)
                    .addContainerGap ())
            // set vertical group
            transPanel0Layout.setVerticalGroup (
                    transPanel0Layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (transPanel0Layout.createSequentialGroup ()
                    .addContainerGap ()
                    .add (transPanel0Layout.createParallelGroup (org.jdesktop.layout.GroupLayout.BASELINE)
                    .add (cancelButton0)
                    .add (paymentButton0)
                    // add amtRcvdInput0 JTextField to form
                    .add (amtRcvdInput0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add (amtRcvdLabel0))
                    .addContainerGap (org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            // setup JScrollPanel to display transaction items
            transList0.setFont (new java.awt.Font ("Tahoma", 0, 14));
            transList0.setListData (listData);
            transList0.setToolTipText ("Items entered in the current transaction");
            // specify scrollbars
            jScrollPane1.setViewportView (transList0);
            // setup the file menu
            fileMenu0.setText ("File");
            // add Export XML menu item to file menu
            exportXMLMenuItem = new JMenuItem ("Export to XML");
            exportXMLMenuItem.setToolTipText ("Export current product list to product.xml");
            fileMenu0.add (exportXMLMenuItem);
            // add menu seperator
            fileMenu0.addSeparator ();
            // add Exit menu item to file menu
            exitMenuItem = new JMenuItem ("Exit");
            exitMenuItem.setToolTipText ("Exit application");
            fileMenu0.add (exitMenuItem);
            // add the file menu to the menu bar
            menuBar0.add (fileMenu0);
            // set the menu bar to be menuBar0
            setJMenuBar (menuBar0);
            // layout remaining components onto JFrame
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout (getContentPane ());
            getContentPane ().setLayout (layout);
            // set horizontal group
            layout.setHorizontalGroup (
                    layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (layout.createSequentialGroup ()
                    .addContainerGap ()
                    .add (layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (layout.createSequentialGroup ()
                    .add (prodIDLabel0)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (prodIDLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 78, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (prodNameLabel0)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (prodNameLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 164, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add (layout.createSequentialGroup ()
                    .add (prodDescLabel0)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (prodDescLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 725, Short.MAX_VALUE))
                    .add (layout.createSequentialGroup ()
                    .add (prodImagePanel0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 499, Short.MAX_VALUE))
                    .add (layout.createSequentialGroup ()
                    .add (itemPrice0)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED, 441, Short.MAX_VALUE)
                    .add (totalPrice0)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (totalPrice1))
                    .add (layout.createSequentialGroup ()
                    .add (prodPanel0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (transPanel0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addContainerGap ())
            // set vertical group
            layout.setVerticalGroup (
                    layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (layout.createSequentialGroup ()
                    .addContainerGap ()
                    .add (layout.createParallelGroup (org.jdesktop.layout.GroupLayout.BASELINE)
                    .add (prodIDLabel1)
                    .add (prodNameLabel1)
                    .add (prodNameLabel0)
                    .add (prodIDLabel0))
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (layout.createParallelGroup (org.jdesktop.layout.GroupLayout.BASELINE)
                    .add (prodDescLabel0)
                    .add (prodDescLabel1))
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE)
                    .add (prodImagePanel0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (itemPrice0)
                    .add (layout.createParallelGroup (org.jdesktop.layout.GroupLayout.BASELINE)
                    .add (totalPrice1)
                    .add (totalPrice0)))
                    .addPreferredGap (org.jdesktop.layout.LayoutStyle.RELATED)
                    .add (layout.createParallelGroup (org.jdesktop.layout.GroupLayout.LEADING)
                    .add (prodPanel0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add (transPanel0, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap ())
            // resize the frame to the minimum size needed to satisfy the preferred size of each of the components in the layout
            pack ();
        /** actionPerformed()
         *  handles events from components.
        public void actionPerformed (ActionEvent e) {
            if ( e.getSource () == findButton0 )
                guiCtl0.findButtonAction (prodIDInput0.getText (), qtyInput0.getText ());
            if ( e.getSource () == cancelButton0 )
                guiCtl0.cancelButtonAction ();
        /** showWelcomeMsg()
         *  Shows a welcome dialogue message to the user.
        public void showWelcomeMsg (){
            // Create a new dialogue box
            JOptionPane welcomeMsg = new JOptionPane ();
            // Show welcome dialogue box
            welcomeMsg.showMessageDialog (null, "Welcome to the Supermarket Management System.  Click OK to begin.", "Welcome", welcomeMsg.INFORMATION_MESSAGE);
        /** showMsg()
         *  Shows a message to the user.
        public void showErrorMsg (String s){
            // Create a new dialogue box
            JOptionPane errorMsg = new JOptionPane ();
            // Show welcome dialogue box
            errorMsg.showMessageDialog (null, s, "Message", errorMsg.ERROR_MESSAGE);
        /** set prodIDInput0 text field */
        public void setProdIDInput0 (String s){
            prodIDInput0.setText (s);
        /** set qtyInput0 text field */
        public void setQtyInput0 (String s){
            qtyInput0.setText (s);
        /** set ProdDescLabel1 label */
        public void setProdDescLabel1 (String s) {
            prodDescLabel1.setText (s);
        /** set prodIDLabel1 label */
        public void setProdIDLabel1 (String s) {
            prodIDLabel1.setText (s);
        /** set prodNameLabel1 label */
        public void setProdNameLabel1 (String s) {
            prodNameLabel1.setText (s);
        /** set totalPrice1 label */
        public void setTotalPrice1 (String s) {
            totalPrice1.setText (s);
        /** populate transList0 with latest trans info */
        public void setTransList0 (Vector v){
            transList0.setListData (v);
        /** set itemPrice0 label */
        public void setItemPrice0 (String s) {
            itemPrice0.setText (s);
        /** draw prod images onto gui */
        public void paintImage (String imagePath) {
            // get Graphics
            Graphics g = prodImagePanel0.getGraphics ();
            // draw image into prodImagePanel0
            img = null;
            try {
                img = ImageIO.read (new File (imagePath));
            } catch (IOException e) {
                System.err.println ("Caught IOException: "
                        + e.getMessage ());
            // draw the image on screen
            g.drawImage (img, 2, 2, prodImagePanel0);
        /** Change image */
        public void updateImage (String imagePath){
            // draw image into prodImagePanel0
            img = null;
            try {
                img = ImageIO.read (new File (imagePath));
            } catch (IOException e) {
                System.err.println ("Caught IOException: "
                        + e.getMessage ());
    GUIControl
    import javax.swing.*;
    import java.text.*;
    * GUIControl.java
    * The GUIControl class is responsible to perform actions requested from the GUIView class.
    * It also liaises with the TransControl and ProdControl objects to generate output to the
    * gui and handle input from the gui.
    * @author Tim
    public class GUIControl {
        // Declare object variables
        private GUIView gui;
        private ProdControl prodCtl0;
        private TransControl transCtl0;
        /** Creates a new instance of GUIControl */
        public GUIControl (ProdControl prodCtl0, TransControl transCtl0) {
            // make reference to prodCtl0, transCtl0 and gui objects
            this.prodCtl0 = prodCtl0;
            this.transCtl0 = transCtl0;
        /** Set gui view object */
        public void setGui (GUIView gui) {
            this.gui = gui;
        /** show the welcome dialouge */
        public void showWelcome (){
            // Call the showWelcomeMsg() method from gui to dispay welcome dialogue.
            gui.showWelcomeMsg ();
        /** find product */
        public Product findProd (int prodId){
            Product foundProd = prodCtl0.getProdByID (prodId);
            return foundProd;
        /** add product to transaction */
        public String addProdToTrans (int prodId, double transQuantity){
            // declare method variables
            String status = "Product not added";
            Product curProd0;
            // find prodduct by ID
            curProd0 = prodCtl0.getProdByID (prodId);
            //  1. if product exists then add a new transaction item to the transaction list.
            if (curProd0 != null) {
                // 2. check quantity is a whole number for UPC Products
                if (curProd0 instanceof UPCProd) {
                    // check if the result is a whole number
                    boolean isWhole = (Math.rint (transQuantity) == transQuantity);
                    // 3. if isWhole is false change status message.
                    if (isWhole == false) {
                        // return status as Product cannot be found.
                        status = "You must enter the quantity as a whole number for UPC products.";
                        return status;
                    } else {
                        // 4. check there is enough stock in the store
                        if (transQuantity > curProd0.getQuantity ()) {
                            // return status as there is not enough stock.
                            status = "There is currently not enough stock to fulfill this transaction.  Please reduce the quantity." ;
                            return status;
                        } else {
                        }  // end if 4.
                    }  // end if 3.
                } else {
                }  // end if 2.
                // add curProd as new transItem
                transCtl0.addTransItem (curProd0, transQuantity);
                // return status as null to notify that the Product was added.
                status = null;
                return status;
            } else {
                // return status as Product cannot be found.
                status = "Product " + prodId + " cannot be found.";
                return status;
            }  // end if 1.
        }  // end addProdToTrans method
        /** action Find button */
        public void findButtonAction (String prodId0, String quantity0){
            // status msg
            String status;
            // check prodId0 is not null
            if (prodId0.equals ("")) {
                // set status message to error and display error msg
                status = "Please enter a valid Product ID.";
                gui.showErrorMsg (status);
                // check quantity0 is not null
            } else if (quantity0.equals ("")) {
                // set status message to error and display error msg
                status = "Please enter a valid quantity.";
                gui.showErrorMsg (status);
            } else {
                // parse String values into int and double
                int prodId1 = Integer.parseInt (prodId0);
                double quantity1 = Double.parseDouble (quantity0);
                // reset prodIDInput0 and qtyInput0 text fields in the gui
                gui.setProdIDInput0 ("");
                gui.setQtyInput0 ("");
                // add trans item and return result as a string
                status = addProdToTrans (prodId1, quantity1);
                if (status == null) {
                    updateProdTransView ();
                } else {
                    // display msg to the user
                    gui.showErrorMsg (status);
                } // end if
            } // end if
        } // end findButtonAction method
        /** update product and transaction view on gui */
        public void updateProdTransView (){
            // get the last trans item added
            TransItem lastTransItem0 = transCtl0.getLastTransItem ();
            // find the product
            Product p = findProd (lastTransItem0.getId ());
            // update product info displayed in the gui
            gui.setProdIDLabel1 (Integer.toString (p.getId ()));
            gui.setProdNameLabel1 (p.getName ());
            gui.setProdDescLabel1 (p.getDescription ());
            // paint prod image
            gui.paintImage (p.getImage ());
            // update transaction info displayed in the gui
            gui.setTransList0 (transCtl0.getTransItems ());
            gui.setItemPrice0 (transCtl0.transItemPriceInfo (lastTransItem0));
            // update total transaction cost displayed in the gui
            gui.setTotalPrice1 ("$" + transCtl0.transTotal ());
        } // end updateProdTransView method
        /** action Cancel button */
        public void cancelButtonAction (){
            // cleat transaction items from transaction array list
            transCtl0.clearTrans ();
            // reset gui components
            gui.setProdIDLabel1 ("");
            gui.setProdNameLabel1 ("");
            gui.setProdDescLabel1 ("");
            gui.setTransList0 (transCtl0.getTransItems ());
            gui.setItemPrice0 ("");
            gui.setTotalPrice1 ("$0.00");
            gui.paintImage ("images/transparent.gif");
    }

    happy to include more detail if required.You've included too much detail.
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the posted code retains its original formatting.
    And don't post code generated by NetBeans. It uses the GroupLayout which is not a standard layout manager until JDK6 and a lot of people don't use JDK6 yet so we won't be able to execute you code to see whats happening.

  • Going nuts over modulo of two doubles

    consider:
    double x=2.0;
    double y=0.1;
    double z=x%y;
    boolean perfectFit = (Math.round(x/y)==x/y);
    System.out.println("x="+x+",y="+y+",z="+z+",perfectFit="+perfectFit);
    // surprisingly (at least for me),
    // while perfectFit is true (as expected), z is not zero at all:
    x=2.0,y=0.1,z=0.0999999999999999,perfectFit=true
    am I missing something?

    What happens is quite normal and you will understand this if you try:
    public class Modulo {
        public static void main (String [] args) {
            double x = 2.0;
            double y = 0.00001;
            double z=x%y;
            boolean perfectFit = (Math.round(x/y)==x/y);
            System.out.println("rounded: "+Math.round(x/y));
            System.out.println("not rounded: "+x/y);
            System.out.println("modulo: "+z);
            System.out.println(perfectFit);       
    }You see Math.round(double) returns a long and you play with double. That means that you lose a bit of presision here... In the above example this becomes obvious for a big number.
    Hope that helped
    afotoglidis

  • 1152 Error

    So I have a MC thats throwing me for a loop.  As stated its giving me the 1152 error code. 
    Symbol 'Personal Gallery MC', Layer 'Actions', Frame 2, Line 8
    1152: A conflict exists with inherited definition flash.display:DisplayObject.root in namespace public.
    and here is the line it refers to.
    var root:MovieClip = this;
    While I am sure this is exceedingly simple to fix I am stuck.  I know there are know smae named instances and that the stupid little check box is turned off in the AS section. 
    Any thoughts? 

    I dont need this MC to do anything to the main timeline,  It was coded and put together seperate from the main File... maybe thats the problem.  The MC is just a scrolling slide show that I am setting on the mainstage.  At anyrate Ill post up the whole code.. I just need to get this last thing working am im home free.
    // Preloader in AS frame 1
    stop();
    onEnterFrame = function () {
        loading = Math.round(_root.getBytesLoaded().toString()/1024);
        total = Math.round(_root.getBytesTotal().toString()/1024);
        percentage = Math.round((loading/total)*100);
        if (_root.getBytesLoaded().toString() == _root.getBytesTotal().toString()) {
            gotoAndStop(2);
            delete this.onEnterFrame;
    // Main AS in frame 2
    import flash.display.*;
    import flash.geom.*;
    import flash.filters.*;
    //Change these values below to customize the viewer fuctionality
    var root:MovieClip = this;
    var myMO:Object;
    var myKO:Object;
    var loadedAll:Boolean;
    var distance:Number;
    var autoJump:Number = .15;
    var maxSlide:Number = 100;
    var deleteMinDistance:Number = 0;
    var deleteMaxDistance:Number = 900;
    var doubleClickRegister:Number = 500;
    var frontCDWidth:Number = 370;
    var frontCDHeight:Number = 370;
    var shelveCDHeight:Number = 320;
    var shelveCDWidth:Number = 280;
    var shelveCDSpacing:Number = 150;
    var centerDistance:Number = 50;
    var albumEase:Number = 4;
    var angle:Number = 8;
    var fadePoint:Number = Stage.width;
    var fadeDist:Number = 200;
    var current:Number = 1;
    var centerX:Number = Stage.width / 2;
    var centerY:Number = 200;
    var clickDelay:Number = 750;
    var scrollBarStart:Number = 0;
    var scrollerDelay:Number = 150;
    var scrollBarStop:Number = scrollBar.scroller._width + 49;
    var reflectionBackgroundColour:Number = d3dfd1;
    var reflectionBlurX:Number = 0;
    var reflectionBlurY:Number = 0;
    var reflectionQuality:Number = 3;
    var reflectionSpace:Number = 250;
    var reflectionAlpha:Number = 100;
    var reflectionRotation:Number = 90;
    var reflectionFocalPointRatio:Number = 0.3;
    var reflectionFillType:String = "linear";
    var reflectionSpreadMethod:String = "pad";
    var reflectionInterpolationMethod:String = "RGB";
    var unknownArtist:String = "Unknown Artist";
    var unknownAlbum:String = "Unknown Album";
    var infostruc:Array = [];
    var reflectionColors:Array = [0x000000, 0x000000];
    var reflectionAlphas:Array = [100, 10];
    var reflectionRatios:Array = [0, 255];
    var xmlData:XML = new XML();
    MovieClip.prototype.setSides = function(x1:Number, y1:Number, x2:Number, y2:Number, x3:Number, y3:Number, x4:Number, y4:Number):Void  {
        this.px1 = x1;
        this.py1 = y1;
        this.px2 = x2;
        this.py2 = y2;
        this.px3 = x3;
        this.py3 = y3;
        this.px4 = x4;
        this.py4 = y4;
    MovieClip.prototype.DistortImage = function(ptexture, vseg:Number, hseg:Number) {
        if (ptexture instanceof BitmapData) {
            this.texture = ptexture;
        } else if (ptexture instanceof MovieClip) {
            this.texture = new BitmapData(ptexture._width, ptexture._height);
            this.texture.draw(ptexture);
        this._w = this.texture.width;
        this._h = this.texture.height;
        this._aMcs = [];
        this._p = [];
        this._tri = [];
        this.init();
    MovieClip.prototype.setTransform = function(x0:Number, y0:Number, x1:Number, y1:Number, x2:Number, y2:Number, x3:Number, y3:Number):Void  {
        this.dx30 = x3 - x0;
        this.dy30 = y3 - y0;
        this.dx21 = x2 - x1;
        this.dy21 = y2 - y1;
        for (var l in this._p) {
            this.point = this._p[l];
            var gx = (this.point.x - this._xMin) / this._w;
            var gy = (this.point.y - this._yMin) / this._h;
            var bx = x0 + gy * (this.dx30);
            var by = y0 + gy * (this.dy30);
            this.point.sx = bx + gx * ((x1 + gy * (this.dx21)) - bx);
            this.point.sy = by + gx * ((y1 + gy * (this.dy21)) - by);
        this.render();
    MovieClip.prototype.init = function(Void):Void  {
        this._p = [];
        this._tri = [];
        this.w2 = this._w / 2;
        this.h2 = this._h / 2;
        this._xMin = this._yMin = 0;
        this._xMax = this._w;
        this._yMax = this._h;
        this._hsLen = this._w / 2;
        this._vsLen = this._h / 2;
        for (ix = 0; ix < 3; ix++) {
            for (iy = 0; iy < 3; iy++) {
                x = ix * this._hsLen;
                y = iy * this._vsLen;
                this._p.push({x:x, y:y, sx:x, sy:y});
        for (ix = 0; ix < 2; ix++) {
            for (iy = 0; iy < 2; iy++) {
                this.p0 = this._p[iy + ix * 3];
                this.p1 = this._p[iy + ix * 3 + 1];
                this.p2 = this._p[iy + (ix + 1) * 3];
                this.addTriangle(this.p0,this.p1,this.p2);
                this.p0 = this._p[iy + (ix + 1) * 3 + 1];
                this.p1 = this._p[iy + (ix + 1) * 3];
                this.p2 = this._p[iy + ix * 3 + 1];
                this.addTriangle(this.p0,this.p1,this.p2);
        this.render();
    MovieClip.prototype.addTriangle = function(p0:Object, p1:Object, p2:Object):Void  {
        this.tMat = {};
        this.u0 = p0.x;
        this.v0 = p0.y;
        this.u1 = p1.x;
        this.v1 = p1.y;
        this.u2 = p2.x;
        this.v2 = p2.y;
        this.tMat.tx = -this.v0 * (this._w / (this.v1 - this.v0));
        this.tMat.ty = -this.u0 * (this._h / (this.u2 - this.u0));
        this.tMat.a = this.tMat.d = 0;
        this.tMat.b = this._h / (this.u2 - this.u0);
        this.tMat.c = this._w / (this.v1 - this.v0);
        this._tri.push([p0, p1, p2, this.tMat]);
    MovieClip.prototype.render = function(Void):Void  {
        this.clear();
        this.ih = 1 / this._h;
        this.iw = 1 / this._w;
        this.tM = this.sM = {};
        for (var l in this._tri) {
            a = this._tri[l];
            this.p0 = a[0];
            this.p1 = a[1];
            this.p2 = a[2];
            this.tM = a[3];
            this.sM.a = (this.p1.sx - (this.x0 = this.p0.sx)) * this.iw;
            this.sM.b = (this.p1.sy - (this.y0 = this.p0.sy)) * this.iw;
            this.sM.c = (this.p2.sx - this.x0) * this.ih;
            this.sM.d = (this.p2.sy - this.y0) * this.ih;
            this.sM.tx = this.x0;
            this.sM.ty = this.y0;
            this.sM = concat(this.sM, this.tM);
            this.beginBitmapFill(this.texture,this.sM,false,false);
            this.moveTo(this.x0,this.y0);
            this.lineTo(this.p1.sx,this.p1.sy);
            this.lineTo(this.p2.sx,this.p2.sy);
            this.endFill();
    function init(Void):Void {
        myMO = {};
        myKO = {};
        Mouse.addListener(myMO);
        Key.addListener(myKO);
        for (var i in infostruc) {
            loader.clear();
            loader.gradient_mc.removeMovieClip();
            loader.attachMovie("default","art",1);
            loader._width = frontCDWidth;
            loader._height = frontCDHeight;
            this["_bmd" + i] = new BitmapData(loader._width, loader._height);
            this["_ref" + i] = new BitmapData(loader._width, loader._height);
            this["_bmd" + i].draw(loader);
            var mc:MovieClip = loader.createEmptyMovieClip("gradient_mc", loader.getNextHighestDepth());
            matrix = new Matrix();
            matrix.createGradientBox(loader._width,loader._height,reflectionRotation / 180 * Math.PI,0,0);
            mc.beginGradientFill(reflectionFillType,reflectionColors,reflectionAlphas,reflectionRatio s,matrix,reflectionSpreadMethod,reflectionInterpolationMethod,reflectionFocalPointRatio);
            mc.moveTo(0,0);
            mc.lineTo(0,loader._height);
            mc.lineTo(loader._width,loader._height);
            mc.lineTo(loader._width,0);
            mc.lineTo(0,0);
            mc.endFill();
            loader.art._alpha = reflectionAlpha;
            loader.beginFill(reflectionBackgroundColour);
            loader.moveTo(0,0);
            loader.lineTo(0,loader._height);
            loader.lineTo(loader._width,loader._height);
            loader.lineTo(loader._width,0);
            loader.lineTo(0,0);
            loader.endFill();
            this["_ref" + i].draw(loader);
        for (var i:Number = count = 0; count < Stage.width - (centerDistance * 2); count += shelveCDSpacing, i++) {
            var cArt:MovieClip = this.createEmptyMovieClip("art" + this.getNextHighestDepth(), this.getNextHighestDepth());
            var rArt:MovieClip = this.createEmptyMovieClip("reflection" + (this.getNextHighestDepth() - 1), this.getNextHighestDepth());
            rArt.id = cArt.id = rArt.cid = cArt.cid = Number(i) + 1;
            cArt.DistortImage(this["_bmd" + cArt.id]);
            controlTheObject(cArt);
            rArt.DistortImage(this["_ref" + cArt.id]);
            controlTheObject(rArt);
            var tmpFilter:BlurFilter = new BlurFilter(reflectionBlurX, reflectionBlurY, reflectionQuality);
            rArt.filterArray = [];
            rArt.filterArray.push(tmpFilter);
            rArt.filters = rArt.filterArray;
        myMO.onMouseWheel = function(delta:Number):Void  {
            if (delta > 0) {
                next();
            } else if (delta <= 0) {
                previous();
        myKO.onKeyDown = function():Void  {
            if (Selection.getFocus() != "_level0.goto") {
                if (Key.isDown(Key.RIGHT)) {
                    next();
                } else if (Key.isDown(Key.LEFT)) {
                    previous();
        scrollBar.scroller.onPress = function():Void  {
            dist = this._parent._xmouse - this._x;
            this.onMouseMove = function():Void  {
                tmp = 1 + Math.ceil(((this._parent._xmouse - dist) - scrollBarStart) / (scrollBar._width - scrollBarStop) * (infostruc.length - 1));
                if (tmp > infostruc.length) {
                    tmp = infostruc.length;
                if (tmp < 1) {
                    tmp = 1;
                current = tmp;
                updateInfo();
        scrollBar.scroller.onRelease = scrollBar.scroller.onReleaseOutside = function ():Void {
            stopDrag();
            delete this.onMouseMove;
        scrollBar.left.onPress = function():Void  {
            previous();
            shifter = setInterval(previous, scrollerDelay);
        scrollBar.right.onPress = function():Void  {
            next();
            shifter = setInterval(next, scrollerDelay);
        scrollBar.onMouseUp = function():Void  {
            clearInterval(shifter);
        scrollBar.onMouseDown = function():Void  {
            if (this.hitTest(_xmouse, _ymouse, true) && !this.left.hitTest(_xmouse, _ymouse, true) && !this.right.hitTest(_xmouse, _ymouse, true)) {
                if (this._xmouse < this.scroller._x) {
                    previous();
                    shifter = setInterval(previous, clickDelay);
                if (this._xmouse > this.scroller._x + this.scroller._width) {
                    next();
                    shifter = setInterval(next, clickDelay);
        goto.onChanged = function():Void  {
            if (!isNaN(Number(this.text) + 1)) {
                this.text = Math.round(Number(this.text));
                if (this.text > infostruc.length) {
                    this.text = infostruc.length;
                if (this.text < 1) {
                    this.text = 1;
                current = this.text;
            } else {
                this.text = current;
            updateInfo();
        distance = Number(i);
        mask.removeMovieClip();
        loader.removeMovieClip();
        scrollBar.swapDepths(1101);
        loadNext();
        updateInfo();
    function concat(m1, m2):Object {
        var mat:Object = {};
        mat.a = m1.c * m2.b;
        mat.b = m1.d * m2.b;
        mat.c = m1.a * m2.c;
        mat.d = m1.b * m2.c;
        mat.tx = m1.a * m2.tx + m1.c * m2.ty + m1.tx;
        mat.ty = m1.b * m2.tx + m1.d * m2.ty + m1.ty;
        return mat;
    function updateInfo():Void {
        goto.text = current;
        img_info.author = infostruc[current - 1].auth;
        img_info.album = infostruc[current - 1].album;
        //New Addition
        img_info.artistLink.enabled = true;
        if (infostruc[current - 1].authLink == undefined) {
            img_info.authLink.enabled = false;
        } else {
            if (infostruc[current - 1].authLink == "undefined") {
                img_info.authLink.enabled = false;
            } else {
                img_info.artistLink.onPress = function() {
                    getURL(infostruc[current - 1].authLink, "_blank");
        img_info.albumLink.enabled = true;
        if (infostruc[current - 1].albumLink == undefined) {
            img_info.albumLink.enabled = false;
        } else {
            if (infostruc[current - 1].albumLink == "undefined") {
                img_info.albumLink.enabled = false;
            } else {
                img_info.albumLink.onPress = function() {
                    getURL(infostruc[current - 1].albumLink, "_blank");
        scrollBar.scroller._x = scrollBarStart + ((current - 1) / (infostruc.length - 1) * (scrollBar._width - scrollBarStop));
    function validateOk(target:MovieClip):Boolean {
        return Math.abs(Math.min(Math.max((target._x - target.x) / albumEase, -maxSlide), maxSlide)) == maxSlide;
    function controlTheObject(mc):Void {
        if (mc._name.indexOf("reflection") == -1) {
            mc.onPress = function():Void  {
                if (getTimer() - this.pressTime <= doubleClickRegister && this.pressTime) {
                this.pressTime = getTimer();
                current = this.cid + 1;
                updateInfo();
        mc.onEnterFrame = function():Void  {
            if (Math.abs(this._x - this.x) > 1) {
                if (this._name.indexOf("reflection") == -1) {
                    this._y = centerY;
                    if (this._x >= centerX + centerDistance) {
                        this.swapDepths(Stage.width - this._x);
                        this.setSides(-(shelveCDWidth / 2),-(shelveCDHeight / 2) + ((Math.sin(angle * Math.PI / 180) * frontCDWidth)),-(shelveCDWidth / 2) + shelveCDWidth,-(shelveCDHeight / 2),-(shelveCDWidth / 2) + shelveCDWidth,shelveCDHeight / 2,-(shelveCDWidth / 2),(shelveCDHeight / 2) - ((Math.sin(angle * Math.PI / 180) * frontCDWidth)));
                    } else if (this._x <= centerX - centerDistance) {
                        this.swapDepths(this._x);
                        this.setSides(-(shelveCDWidth / 2),-(shelveCDHeight / 2),-(shelveCDWidth / 2) + shelveCDWidth,-(shelveCDHeight / 2) + (Math.sin(angle * Math.PI / 180) * frontCDWidth),-(shelveCDWidth / 2) + shelveCDWidth,(shelveCDHeight / 2) - (Math.sin(angle * Math.PI / 180) * frontCDWidth),-(shelveCDWidth / 2),shelveCDHeight / 2);
                    } else if (this._x > centerX - centerDistance && Math.floor(this._x) < centerX && !validateOk(this) && angle - ((this._x - (centerX - centerDistance)) / centerDistance * angle) > autoJump) {
                        this.swapDepths(1002);
                        var sum:Number = shelveCDWidth + ((this._x - (centerX - centerDistance)) / centerDistance * (frontCDWidth - shelveCDWidth));
                        var sum2:Number = angle - ((this._x - (centerX - centerDistance)) / centerDistance * angle);
                        var sum3:Number = shelveCDHeight + ((this._x - (centerX - centerDistance)) / centerDistance * (frontCDHeight - shelveCDHeight));
                        this.setSides(-(sum / 2),-(sum3 / 2),-(sum / 2) + sum,-(sum3 / 2) + ((Math.sin(sum2 * Math.PI / 180) * frontCDWidth)),-(sum / 2) + sum,(sum3 / 2) - ((Math.sin(sum2 * Math.PI / 180) * frontCDWidth)),-(sum / 2),sum3 / 2);
                    } else if (this._x < centerX + centerDistance && Math.ceil(this._x) > centerX && !validateOk(this) && angle - (((centerX + centerDistance) - this._x) / centerDistance * angle) > autoJump) {
                        this.swapDepths(1003);
                        var sum:Number = shelveCDWidth + (((centerX + centerDistance) - this._x) / centerDistance * (frontCDWidth - shelveCDWidth));
                        var sum2:Number = angle - (((centerX + centerDistance) - this._x) / centerDistance * angle);
                        var sum3:Number = shelveCDHeight + (((centerX + centerDistance) - this._x) / centerDistance * (frontCDHeight - shelveCDHeight));
                        this.setSides(-(sum / 2),-(sum3 / 2) + ((Math.sin(sum2 * Math.PI / 180) * frontCDWidth)),-(sum / 2) + sum,-(sum3 / 2),-(sum / 2) + sum,sum3 / 2,-(sum / 2),(sum3 / 2) - ((Math.sin(sum2 * Math.PI / 180) * frontCDWidth)));
                    } else if (!validateOk(this)) {
                        this.swapDepths(1004);
                        this.setSides(-(frontCDWidth / 2),-(frontCDHeight / 2),-(frontCDWidth / 2) + frontCDWidth,-(frontCDHeight / 2),-(frontCDWidth / 2) + frontCDWidth,frontCDHeight / 2,-(frontCDWidth / 2),frontCDHeight / 2);
                } else {
                    this._yscale = -100;
                    if (this._x >= centerX + centerDistance) {
                        this._y = centerY + shelveCDHeight + reflectionSpace;
                        this.swapDepths((Stage.width - this._x) - 333);
                        this.setSides(-(shelveCDWidth / 2),-(shelveCDHeight / 2) + (Math.sin(angle * Math.PI / 180) * frontCDWidth),-(shelveCDWidth / 2) + shelveCDWidth,-(shelveCDHeight / 2),-(shelveCDWidth / 2) + shelveCDWidth,shelveCDHeight / 2,-(shelveCDWidth / 2),(shelveCDHeight / 2) + ((Math.sin(angle * Math.PI / 180) * frontCDWidth)));
                    } else if (this._x <= centerX - centerDistance) {
                        this._y = centerY + shelveCDHeight + reflectionSpace;
                        this.swapDepths(this._x - 333);
                        this.setSides(-(shelveCDWidth / 2),-(shelveCDHeight / 2),-(shelveCDWidth / 2) + shelveCDWidth,-(shelveCDHeight / 2) + ((Math.sin(angle * Math.PI / 180) * frontCDWidth)),-(shelveCDWidth / 2) + shelveCDWidth,(shelveCDHeight / 2) + (Math.sin(angle * Math.PI / 180) * frontCDWidth),-(shelveCDWidth / 2),shelveCDHeight / 2);
                    } else if (this._x > centerX - centerDistance && this._x < centerX && !validateOk(this)) {
                        this.swapDepths(999);
                        var sum:Number = shelveCDWidth + ((this._x - (centerX - centerDistance)) / centerDistance * (frontCDWidth - shelveCDWidth));
                        var sum2:Number = angle - ((this._x - (centerX - centerDistance)) / centerDistance * angle);
                        var sum3:Number = shelveCDHeight + ((this._x - (centerX - centerDistance)) / centerDistance * (frontCDHeight - shelveCDHeight));
                        this._y = centerY + sum3 + reflectionSpace;
                        this.setSides(-(sum / 2),-(sum3 / 2),-(sum / 2) + sum,-(sum3 / 2) + ((Math.sin(sum2 * Math.PI / 180) * frontCDWidth)),-(sum / 2) + sum,(sum3 / 2) + ((Math.sin(sum2 * Math.PI / 180) * frontCDWidth)),-(sum / 2),sum3 / 2);
                    } else if (this._x < centerX + centerDistance && this._x > centerX && !validateOk(this)) {
                        this.swapDepths(998);
                        var sum:Number = shelveCDWidth + (((centerX + centerDistance) - this._x) / centerDistance * (frontCDWidth - shelveCDWidth));
                        var sum2:Number = angle - (((centerX + centerDistance) - this._x) / centerDistance * angle);
                        var sum3:Number = shelveCDHeight + (((centerX + centerDistance) - this._x) / centerDistance * (frontCDHeight - shelveCDHeight));
                        this.setSides(-(sum / 2),-(sum3 / 2) + ((Math.sin(sum2 * Math.PI / 180) * frontCDWidth)),-(sum / 2) + sum,-(sum3 / 2),-(sum / 2) + sum,sum3 / 2,-(sum / 2),(sum3 / 2) + ((Math.sin(sum2 * Math.PI / 180) * frontCDWidth)));
                        this._y = centerY + sum3 + reflectionSpace;
                    } else if (!validateOk(this)) {
                        this.swapDepths(995);
                        this._y = centerY + frontCDHeight + reflectionSpace;
                        this.setSides(-(frontCDWidth / 2),-(frontCDHeight / 2),-(frontCDWidth / 2) + frontCDWidth,-(frontCDHeight / 2),-(frontCDWidth / 2) + frontCDWidth,frontCDHeight / 2,-(frontCDWidth / 2),frontCDHeight / 2);
            if (infostruc[this.cid].loaded && !this.loadedImage) {
                this.DistortImage(this._name.indexOf("reflection") > -1 ? this._parent["_ref" + this.cid] : this._parent["_bmd" + this.cid]);
                this.loadedImage = true;
            if (this._x < deleteMinDistance && this._parent["_ref" + (this.cid + distance)]) {
                this.cid += distance;
                this._x = deleteMaxDistance;
                controlTheObject(this);
                this.loadedImage = infostruc[this.cid].loaded;
                this.DistortImage(this._name.indexOf("reflection") > -1 ? this._parent["_ref" + this.cid] : this._parent["_bmd" + this.cid]);
            if (this._x > deleteMaxDistance && this._parent["_ref" + (this.cid - distance)]) {
                this.cid -= distance;
                this._x = deleteMinDistance;
                controlTheObject(this);
                this.loadedImage = infostruc[this.cid].loaded;
                this.DistortImage(this._name.indexOf("reflection") > -1 ? this._parent["_ref" + this.cid] : this._parent["_bmd" + this.cid]);
            if (this.cid + 1 > current) {
                this.x = (centerX + ((this.cid + 1 - current) * shelveCDSpacing)) + centerDistance;
            } else if (this.cid + 1 < current) {
                this.x = (centerX + ((this.cid + 1 - current) * shelveCDSpacing)) - centerDistance;
            } else {
                this.x = centerX + ((this.cid + 1 - current) * shelveCDSpacing);
            this._x -= Math.min(Math.max((this._x - this.x) / albumEase, -maxSlide), maxSlide);
            if (this._x < fadeDist) {
                this._alpha = (this._x / fadeDist * 100);
            } else if (this._x > fadePoint - fadeDist) {
                this._alpha = ((fadePoint - this._x) / fadeDist * 100);
            } else {
                this._alpha = 100;
            this.setTransform(this.px1,this.py1,this.px2,this.py2,this.px3,this.py3,this.px4,this.py4 );
    function next():Void {
        if (current < infostruc.length) {
            current += 1;
        updateInfo();
    function previous():Void {
        if (current > 1) {
            current -= 1;
        updateInfo();
    function displayAlternArt(art, width:Number, height:Number):Void {
        artDisplay.attachBitmap(art,1);
        artDisplay._width = width;
        artDisplay._height = height;
    function loadNext():Void {
        if (!loadedAll) {
            var num:Number = current - 1;
            if (infostruc[current - 1].loaded) {
                var num:Number = current - Math.floor(distance / 2) - 1 >= 0 ? current - Math.floor(distance / 2) - 1 : 0;
                while (infostruc[num].loaded && num < infostruc.length) {
                    num++;
                if (num >= infostruc.length) {
                    var num:Number = current - 1;
                    while (infostruc[num].loaded && num > 0) {
                        num--;
                    if (num <= 0) {
                        loadedAll = true;
            var newLoad:MovieClip = this.createEmptyMovieClip("artLoad" + num, this.getNextHighestDepth());
            newLoad.createEmptyMovieClip("art",newLoad.getNextHighestDepth());
            newLoad._alpha = 0;
            var mc:Object = {};
            mc.number = num;
            var artLoader:MovieClipLoader = new MovieClipLoader();
            artLoader.addListener(mc);
            artLoader.loadClip("./" + infostruc[num].art,newLoad.art);
            mc.onLoadError = function() {
                infostruc[this.number].loaded = true;
                loadNext();
            mc.onLoadInit = function(target:MovieClip) {
                target._parent._width = frontCDWidth;
                target._parent._height = frontCDHeight;
                root["_bmd" + this.number] = new BitmapData(target._width, target._height);
                root["_ref" + this.number] = new BitmapData(target._width, target._height);
                root["_bmd" + this.number].draw(target);
                var mc:MovieClip = target._parent.createEmptyMovieClip("gradient_mc", target._parent.getNextHighestDepth());
                matrix = new Matrix();
                matrix.createGradientBox(target._width,target._height,reflectionRotation / 180 * Math.PI,0,0);
                mc.beginGradientFill(reflectionFillType,reflectionColors,reflectionAlphas,reflectionRatio s,matrix,reflectionSpreadMethod,reflectionInterpolationMethod,reflectionFocalPointRatio);
                mc.moveTo(0,0);
                mc.lineTo(0,target._height);
                mc.lineTo(target._width,target._height);
                mc.lineTo(target._width,0);
                mc.lineTo(0,0);
                mc.endFill();
                target._alpha = 50;
                target._parent.beginFill(reflectionBackgroundColour);
                target._parent.moveTo(0,0);
                target._parent.lineTo(0,target._height);
                target._parent.lineTo(target._width,target._height);
                target._parent.lineTo(target._width,0);
                target._parent.lineTo(0,0);
                target._parent.endFill();
                root["_ref" + this.number].draw(target._parent);
                infostruc[this.number].loaded = true;
                target._parent.removeMovieClip();
                updateInfo();
                loadNext();
    xmlData.onLoad = function(success:Boolean):Void  {
        if (success) {
            for (var i:Number = -1; this.childNodes[0].childNodes[++i]; ) {
                var cNode:XMLNode = this.childNodes[0].childNodes[i].childNodes;
                var val2:String = cNode[1].childNodes[0].nodeValue ? unescape(cNode[1].childNodes[0].nodeValue) : unknownArtist;
                var val3:String = cNode[2].childNodes[0].nodeValue ? unescape(cNode[2].childNodes[0].nodeValue) : unknownAlbum;
                var val4:String = cNode[3].childNodes[0].nodeValue ? unescape(cNode[3].childNodes[0].nodeValue) : noLink;
                var val5:String = cNode[4].childNodes[0].nodeValue ? unescape(cNode[4].childNodes[0].nodeValue) : noLink;
                infostruc.push({art:cNode[0].childNodes[0].nodeValue, info:val1, auth:val2, album:val3, authLink:val4, albumLink:val5, loaded:false});
            loadStat = "";
            init();
        } else {
            loadStat = "Unable to load XML Data";
    xmlData.ignoreWhite = true;
    xmlData.load("./albuminfo.xml");
    this.createEmptyMovieClip("loader",this.getNextHighestDepth());
    loader._visible = false;
    mask._alpha = 0;
    scrollBar.scroller._y = 0;
    img_info.swapDepths(2000);
    As I said it works fine on its own, which in case of root Var name makes sense, but I need it work work within a parent file, Hopping not to have to reconstruct this.

  • Help with java (2 simple classes)

    would anyone be able to help me with some questions about two very short java classes?
    i have come up with some answers of my own, but yeah, i'm not sure how correct my answers are....
    the 4 questions are:
    1. The data attributes m, n and grid in the HeatGrid class are declared private, and methods
    such as gridHeight(), gridWidth() and copyGrid() are provided to extract their value. Why
    is the better class design than simply declaring those attributes as public?
    My answer: So other classes accessing them cannot modify those data atributes, i am not sure why this is better class design.
    2. Why must the (global) constants in HeatSim.java be declared static ?
    My Answer: because HeatSim is what you run first and so you don't create a HeatSim object, you just access its methods, thus the need to make them static.
    3. Assuming HeatGrid has been fully implemented, during the execution of the statement
    HeatGrid = new HeatGrid(inGridFile), how many objects of HeatGrid, double [][] and
    Scanner are created?
    My Answer: 1 HeatGrid object, 1 doulbe[][] object and 1 scanner object
    Which of these objects must still exist after the statement completes execution?
    4. For each of the classes HeatSim and HeatGrid, identify the client and supplier classes
    (including library classes).
    My Answer: So far this is what i have done. for the HeatSim class, i said that the supplier classea are:
    double
    int
    boolean
    String
    Math Class
    viewgrid class
    array
    and the clients for the HeatSim class are:
    HeatGrid class
    if anyone can help me i will but up the VERY short code to these two classes. I am really stuck and any help woould be greatly appriciated! :)
    Lots o love
    Sarah

    ok here is the code (i don't have my compelted copy on me but this will do for the moment).....
    import java.lang.Integer;
    import java.lang.Double;
    import java.text.DecimalFormat;
    public class HeatSim {
        final static boolean ENABLE_VIEW = true; // if true, create GUI to view grid
        final static double DEFAULT_THR = 1.0e-02;
        final static int DEFAULT_PAUSE = 100; // pause between each update of window in ms
        final static int DISPLAY_WIDTH = 7;   // width to print each grid value
        final static int MAX_MN_DISPLAY = 10; // maximum grid size to be displayed
        public static void main(String[] args) {
            // initialize program `parameters' according to the command line,
            // entering `default' values if none were given
            String inGridFile = (args.length < 1)? "": args[0];
            int nIter = (args.length < 2)? 1: Integer.parseInt(args[1]);
            double Thr = (args.length < 3)? DEFAULT_THR: Double.parseDouble(args[2]);
            String dumpFile = (args.length < 4)? "": args[3];
         DecimalFormat residFormat = new DecimalFormat("0.00E0");
            ViewGrid view = null;
            System.out.println("HeatFlow simulation program");
            if (inGridFile.equals("")) {
                System.out.println("Error: an empty grid file name was entered");
                return;
            // create HeatGrid object
            HeatGrid heatGrid = new HeatGrid(inGridFile);
            int m = heatGrid.gridHeight();
            int n = heatGrid.gridWidth();
            if (m <= MAX_MN_DISPLAY  && n <= MAX_MN_DISPLAY) {
                System.out.println("\nGrid at time 0:" );
                heatGrid.display(DISPLAY_WIDTH);
            if (ENABLE_VIEW) {
                // create a ViewGrid WINDOW object to view the grid
                view = new ViewGrid(m+2, n+2, DEFAULT_PAUSE);
                view.display(heatGrid.time(), 0.0, heatGrid.copyGrid());
            while (heatGrid.time() != nIter && heatGrid.residual() > Thr) {
                heatGrid.iterate();
                if (m <= MAX_MN_DISPLAY  && n <= MAX_MN_DISPLAY) {
                    System.out.println("Grid at time " + heatGrid.time() +
                                    " has residual " +
                         residFormat.format(heatGrid.residual()));
                    heatGrid.display(DISPLAY_WIDTH);
                if (ENABLE_VIEW) {
                     view.display(heatGrid.time(), heatGrid.residual(),
                                  heatGrid.copyGrid());
            } //while(...)
            if (ENABLE_VIEW) {
                view.finalize();
            if (!dumpFile.equals("")) {
             heatGrid.dumpGrid(dumpFile);
            System.out.println("\nHeat Flow simulation of (" + m + "+2)x(" + n +
                               "+2) grid ends at time " +  heatGrid.time() +
                               " with residual " +
                      residFormat.format(heatGrid.residual()));
        } //mainProgram()
    } //HeatSim
    import java.util.Scanner;
    import java.io.*;
    import java.text.DecimalFormat;
    public class HeatGrid {
        private int m, n;
        private double[][] grid;     // m+2 x n+2 array representing a grid
        private int t;               // the time the grid has been evolved
        private double resid;        // residual left from the last timestep
        // initializes m, n and grid according to the information in the grid file
        // of name gridFileN; sets t to 0, and resid to Double.MAX_VALUE
        public HeatGrid(String gridFileN) {
        } //HeatGrid()
        // returns the value of m
        public int gridHeight() {
            return 0;         // [ replace with an appropriate value ]
        } //gridHeight()
        // returns the value of n
        public int gridWidth() {
            return 0;         // [ replace with an appropriate value ] =
        } //gridWidth()
        // returns the value of t
        public int time() {
            return 0;         // [ replace with an appropriate value ]
        } //time()
        // returns the value of the residual from the previous timestep
        public double residual() {
            return 0;         // [ replace with an appropriate value ]
        } //residual()
        // returns a copy of the grid
        public double[][] copyGrid() {
            return null;         // [ replace with an appropriate value ]
        } //copyGrid
        // precondition: all elements of grid can be printed to 1 decimal place
        // using width characters.
        // prints the m+2 x n+2 grid by rows, rows in descending order.
        // All values are printed to 1 decimal place, and are right-justified
        // in a text field of width characters.
        // Note: this method is for debugging; hence right-justification is useful
        public void display(int width) {
        } //display()
        // advance the simulation a single timestep
        public void iterate() {
         } //iterate()
        // prints the m+2 x n+2 grid by rows, rows in ascending order.
        // All values are printed to 2 decimal places, with at least one space
        // between them.
        // Note: this method is intended for result checking by a computer program;
        // thus justification is not important.
        public void dumpGrid(String outGridFileN) {
        } //dumpGrid

  • Wrong code analysis on "unreachable statement" for nested loops

    Try this with JavaFX 1.2 (NetBeans 6.5.1)
    function foo():Void {
        for (i in [0..<10]) {
            for (j in [0..<10]) { // be marked as unreachable statement
                if (match()) {
                    break;
                return; // I just want to get out
            // break goes here
    }It shows "unreachable statement" at the second 'for'.
    Right now I just change "return;" to "if (true) return;" to get it pass.

    I agree it is a bug at the compiler level. If I do your change and add println of i and j, I get a trace on j, obviously.
    You should file a bug report at [Jira / Kenai|http://javafx-jira.kenai.com/] (or I can do if you don't want to create an account).
    [EDIT] Uh, no, it is a known problem: [Bogus 'Unreachable statement' error|http://javafx-jira.kenai.com/browse/JFXC-3323], I will add this thread as a comment.
    A more complete use case:
    function foo(): Void {
         for (i in [ 0 ..< 5 ]) {
              println("I {i}");
              for (j in [ 0 ..< 5 ]) {
                   println("J {j}");
                   if (match()) {
                        break;
                   println("Some operation in the inner loop");
                   if (true) return;
              // break goes here
    function match(): Boolean { return Math.random() > 0.5; }
    foo();Now, the inner loop isn't really necessary, we never go beyond 0 for j... But technically, there is no unreachable statement, unless it means we never go up to 5 in the inner loop. In this case, Robert Field is right, the error message should be clearer.
    Edited by: PhiLho on 29 juil. 2009 10:17

  • Help with math.random!

    I'm trying to replace all even numbers in a string with odd numbers that are produced from a random generator. I have somewhat of an idea of how to do it as far as creating an array of 5 characters(1,3,5,7,9) and then implement the math.random to take random numbers from that array. i just dont know how to execute that. for example:
    "adam123456789" -->should be "adam153157739"
    whereas, the underlined(5,1,7,3) should be random numbers(i just picked these for an instance). is it possible to do any form of :
    Methods...
    char [ ] ary = {1,3,5,7,9};
    String line = "adam123456789";
    line = line.replaceAll("[0,2,4,6,8]", Math.round(Math.random()*[ary]));
    return line;**i'm a beginner, so i dont really know what im talking about. just seeking help. thanks!

    ok. this is the class with all of my methods in there. just excuse the rest of it..
    import java.util.Random;
    public class NoVowelNoEven {
      private String str = "";
      NoVowelNoEven() {
        str = "hello";
      NoVowelNoEven(String newString) {
        str = newString;
      String getOriginal() {
        return str;
      static String getValid(String newString) {
        char[] arr = newString.toCharArray();
        String str2 = "";
        for (int i = 0; i < arr.length; i++) {
          if (isValid(arr)) {
    str2 += arr[i];
    return str2;
    static int countValidChar(String newString) {
    String validString = getValid(newString);
    return validString.length();
    static String replaceWithYAndOdd(String newString) {
         char [] ary = {1,3,5,7,9};
         String str3 = newString;
    str3 = str3.replaceAll("[a,e,i,o,u]","y");
    str3 = str3.replaceAll("[A,E,I,O,U]","Y");
         //str3 = str3.replaceAll("[0,2,4,6,8]", );
    return str3;
    static boolean isValid(char char2) {
    switch (Character.toLowerCase(char2)) {
    case 'a':
    return false;
    case 'e':
    return false;
    case 'i':
    return false;
    case 'o':
    return false;
    case 'u':
    return false;
    case '0':
    return false;
    case '2':
    return false;
    case '4':
    return false;
    case '6':
    return false;
    case '8':
    return false;
    default:
    return true;

  • Creating a user prompt when a boolean control is first lached but not contiuousl​y showing while it is lached.

    Greetings,
    I need a boolean control that will write measured data to a text file while it is lached and do nothing while it is unlached (which is simple).  However, I also need it to display a dialog box when it is first lached to prompt the user to either append to an existing file or create a new file.  It should not contiously prompt the user to select new or append while it is lached.  It should only reprompt if the boolean has been unlached and relached.
    Any ideas?  I have tried several different approaches but everything that I have done has either not worked at all or contiuously prompts while lached.
    I know it will involve a shift register and at least one boolean comparison but I cannot figure out the arrangement.
    Thanks in advance.
    Solved!
    Go to Solution.

    Hi BB,
    looked at the Pt-by-Pt functions. There you will find a ready-to-use VI to detect edges of a boolean signal!
    Or use that boolean math: RisingEdge = signal[n] AND NOT(signal[n-1]). (Here you need the already mentioned boolean function with a shift register...)
    All you need is opening the dialog for rising edges of the boolean signal...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Is there a way to create a math.random that doesn't overlap movieclips?

    Hi,
    Actually I have two questions. I am creating a memory sequence game and I was wondering:
    1. Is there a way to random position movieclips on the stage without having them overlap each other?
    2. Is there  a way to have flash draw a vector line from one clip to another in sequence and then have the user retrace what flash did? I have 6 movieclips on the stage, each with their own instance (ex. obj1_mc, obj2_mc, etc.). Is there a way to tell flash to always draw a line between movieclips in sequence even though the movieclips are randomly placed on the stage?
    Thanks,
    OJ

    sure.
    1.  the easiest way to position objects without over-lapping, IF you can assume it will always be possible, is to use something like:
    var mcA:Array=[your movieclips]
    var index:uint=0;
    positionF();
    function positionF(){
    // assuming top-left reg points of your movieclips
    mcA[index].x=Math.random()*(stage.stageWidth-mcA[index].width);
    mcA[index].y=Math.random()*(stage.stageHeight-mcA[index].height);
    var hitBool:Boolean=false;
    for(var i:int=0;i<index-1;i++){
    if(mcA[index].hitTestObject(mcA[i])){
    hitBool=true;
    break;
    if(hitBool){
    positionF();
    } else {
    index++;
    if(index<mcA.length){
    positionF();
    } else {
    // positioning complete.  do whatever
    2.  you can use the graphics class to draw dynamic lines.

  • Boolean error with a If else statement

    Hello, i am new to java, and the only other programing language i have used is pascal, and compared to java its ALOT different any ways my problem. I am trying to write a simply little program which random selects a number between 1 and 10, i did that fine got to show that on screen with no probelm . Next i wanted to but in a if else statement, depending which numbers was selected it would show a different message this is where i am getting a probelm, here is the code for the whole thing:
    // randomColour
    import javax.swing.JOptionPane;
    public class randomColour {
      public static void main ( String args [])
        int value;
         value = 1 + ( int ) ( Math.random() * 10 );
            if (value = "1" )
             System.out.println("Green");
               else
                System.out.println("Blue");
              System.exit( 0 );
       } // end mainWhen i try to Compile it comes up with error saying required:boolean why is this? and what can i do to change to fix it?

    A single = is used to indicate assignment. You are testing for equality which requires ==. Also, "1" is a String. Value is an int. Changeif value = "1" to if value == 1Mark

  • Use boolean array to perform set operations

    I am currently taking a computer science class that uses Java as the language of choice. I have no prior experience with Java. We have a homework assignment in which we are supposed to use a boolean array to implement set operations. We have to create a method that inserts an integer into the array, another that deletes an integer element, and several others. I am confused as how to do this with integers, as it is a boolean array. The datr for this class is:
    private boolean base[];The constructor is:
    public largeset(int size){ }We then have to create a method that inserts an integer into the array:
    public void insert(int i){ }And one that deletes the element:
    public void delete(int i) { }I am unsure how to do this using a boolean array. If it were an integer array I would not have any trouble, but I get an error when trying to insert/delete an integer from the boolean array. Can anyone help point me in the right direction? I would prefer advice only, not the actual code, as this is a homework assignment, and I would like to create the code myself so I actually know what I am doing. Thanks.

    This is the assignment exactly as posted on the course website:
    In this homework, we will use a boolean array to implement various set operations. Please create a class called largeset that supports set operations of any number of elements. The data of this class is
    private boolean[] base;The constructor of the class is
    public largeset(int size);  // create a boolean array of size "size" and store it in "base"The methods of the class are:
    public void insert(int i);  // insert number i into the current set, where 0 <= i < base.length
    public void delete(int i);  // delete number i from the current set, where 0 <= i < base.length
    public boolean member(int i); // test if i is in the set
    public largeset union(largeset B); // return the union of two sets
    public largeset interset(largeset B); // return the intersection of two sets
    public largeset subtract(largeset B); // return the subtraction of two sets
    public largeset complement(); // return the complement of the current set
    public boolean subset(largeset B); // test if the current set is a subset of set B
    public int cardinality();  // return the number of elements in the current set
    public String toString();  // return a string which is a printing of the current setThen create another class called testset that uses the largeset class. At first, please create the following two sets:
    X = { 1, 3, 5, 7, ..., 999 };
    Y = { 9, 18, 27, 36, ..., 999 };
    Please perform the following tests:
    1. display the cardinalities of X and Y, respectively.
    2. display the content of substraction of Y by X.
    3. display the square root of the sum of all the elements of X (Math.sqrt(x) will return the square root of x in double type).
    4. For every pair of distinct elements x and y in Y, compute the sum of (Math.max(x, y) - Math.min(x, y)) (or equivalently, Math.abs(x - y)), and report this sum.

  • Implementing Boolean operators during find object for qualification

    Hi Team
    We would like to maintain requirements profiles for PD object (position,job etc.) in terms of qualifications (Q) using complicated boolean operators , for example :
    ((Q=English>4 OR (Q=French=5 and Q=Spanish>2)) OR (Q=German=6 and english<3) and Q=education # 2
    The complicated boolean operators could be also : range,excluded from the range,equal,not equal,not exits.
    We would like to execute the search for qualification ,profile matchup based on this complicated boolean requirments profile.
    Is there any custom development or configuration to make this happen ?
    Best Regards
    Dror

    Is this still true if the Collection generics elements are an interface type? For example, in the
    code I sent earlier, I have:
    /** The authorities granted to this account. */
    private Set<Authority> authorities;
    But Authority is an interface that is implemented by the DefaultAuthority class (maybe others
    eventually). I was under the impression that in this situation, the metadata does have to provide
    the actual type that will be in the collection.
    But even if it works in Kodo, one of the requirements of my project is that the JDO implementation
    be swapable with JPOX. When I started working on it, both Kodo and JPOX were at a much earlier stage
    of implementing JDO 2, and if I recall correctly, JPOX required the implementation class (though I
    don't know if it had to be fully qualified). I'm not sure that requirement has been removed from
    JPOX yet, though I haven't checked in a while.
    Thanks for your help with the default value settings though. Is there any place where I could have
    found that behavior documented (Kodo docs, JDO2 spec, etc.)?
    Mark
    Abe White wrote:
    p.s. You don't need to set the element-type in metadata if you're using
    Java 5 generics; we can get the element type from the field declaration.
    Also, when you do have to declare an element-type in metadata, you
    don't need to fully qualify the class name if the element class is in
    the same package as the field's owner (the current <package>), or in
    java.util, java.math, java.lang.

  • Package corejava.Math not found error !??

    hi, I tried to compile this code but got the
    following error message ----
    what does it mean ????
    ==================================================
    TextSummary.java:17: Package corejava.Math not found in import.
    import corejava.Math.*;
    ^
    TextSummary.java:18: Package corejava not found in import.
    import corejava.*;
    ^
    2 errors
    ==================================================
    /** * @(#)TextSummary.java * * Copyright (c) 2000 by Sundar Dorai-Raj
    * * @author Sundar Dorai-Raj
    * * Email: [email protected]
    * * This program is free software; you can redistribute it and/or
    * * modify it under the terms of the GNU General Public License
    * * as published by the Free Software Foundation; either version 2
    * * of the License, or (at your option) any later version,
    * * provided that any use properly credits the author.
    * * This program is distributed in the hope that it will be useful,
    * * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    * * GNU General Public License for more details at http://www.gnu.org * * */
    package corejava.Graphics;
    import java.awt.*;
    import corejava.Math.*;
    import corejava.*;
    public class TextSummary extends Canvas {
    private Univariate x=null;
    private int width,height;
    private Dimension size;
    private Font font;
    private boolean box;
    private int[] margins;
    private Color textColor;
    private Image offScrImage;
    private Graphics offScrGraphics;
    /* define constants */
    public final static Font DEFAULT_FONT=new Font("Courier",Font.PLAIN,10);
    public final static Color DEFAULT_COLOR=Color.black;
    public final static Format f=new Format("%1.4f");
    public TextSummary() { super(); }
    public void addNotify() {
    super.addNotify();
    offScrImage=createImage(width,height);
    offScrGraphics=offScrImage.getGraphics();
    public void update(Graphics g) {
    paint(offScrGraphics);
    g.drawImage(offScrImage,0,0,this);
    public TextSummary(int width,int height) {
    this.width=width;
    this.height=height;
    size=new Dimension(width,height);
    margins=new int[4];
    margins[0]=10;
    margins[1]=10;
    margins[2]=10;
    margins[3]=10;
    super.setBackground(Color.white);
    box=false;
    font=DEFAULT_FONT;
    textColor=DEFAULT_COLOR;
    public TextSummary(int width,int height,Font font,Color textColor) {
    this.width=width;
    this.height=height;
    size=new Dimension(width,height);
    margins=new int[4];
    margins[0]=10;
    margins[1]=10;
    margins[2]=10;
    margins[3]=10;
    super.setBackground(Color.white);
    box=false;
    this.font=font;
    this.textColor=textColor;
    public TextSummary(int width,int height,boolean box) {
    this.width=width;
    this.height=height;
    size=new Dimension(width,height);
    this.box=box;
    margins=new int[4];
    margins[0]=10;
    margins[1]=10;
    margins[2]=10;
    margins[3]=10;
    super.setBackground(Color.white);
    font=DEFAULT_FONT;
    textColor=DEFAULT_COLOR;
    public TextSummary(int width,int height,Font font,Color textColor,boolean box) {
    this.width=width;
    this.height=height;
    size=new Dimension(width,height);
    this.box=box;
    margins=new int[4];
    margins[0]=10;
    margins[1]=10;
    margins[2]=10;
    margins[3]=10;
    super.setBackground(Color.white);
    this.font=font;
    this.textColor=textColor;
    public void newData(double[] data,boolean plot) {
    x=new Univariate(data);
    if(plot) repaint();
    public void newData(Univariate data,boolean plot) {
    x=data;
    if(plot) repaint();
    public void setMargins(int[] margins) {
    this.margins=(int[])margins.clone();
    public void setGraphicsParams(Font font,Color textColor,boolean box) {
    this.font=font;
    this.textColor=textColor;
    this.box=box;
    public void paint(Graphics g) {
    if(x==null) return;
    g.setColor(Color.white);
    g.fillRect(0,0,width-1,height-1);
    g.setFont(font);
    g.setColor(textColor);
    FontMetrics fm=getFontMetrics(font);
    int yOrigin=height,
    xOrigin=0,
    bottom=-margins[0],
    left=margins[1],
    top=margins[2],
    right=margins[3],
    center=(int)((width-left-right)*.5),
    quarter=(int)((width-left-right)*0.25),
    textWidth,
    textHeight=fm.getHeight();
    textWidth=fm.stringWidth("Summary");
    g.drawString("Summary",left+center-(int)(textWidth*.5),top+textHeight);
    g.drawLine(left,top+textHeight+2,width-right,top+textHeight+2);
    g.drawLine(left,top+textHeight+3,width-right,top+textHeight+3);
    textWidth=fm.stringWidth("N");
    g.drawString("N",quarter-textWidth,top+2*textHeight);
    textWidth=fm.stringWidth(""+x.size());
    g.drawString(""+x.size(),center-textWidth,top+2*textHeight);
    textWidth=fm.stringWidth("Mean");
    g.drawString("Mean",quarter-textWidth,top+3*textHeight);
    textWidth=fm.stringWidth(f.form(x.mean()));
    g.drawString(f.form(x.mean()),center-textWidth,top+3*textHeight);
    textWidth=fm.stringWidth("Var");
    g.drawString("Var",quarter-textWidth,top+4*textHeight);
    textWidth=fm.stringWidth(f.form(x.variance()));
    g.drawString(f.form(x.variance()),center-textWidth,top+4*textHeight);
    textWidth=fm.stringWidth("Stdev");
    g.drawString("Stdev",quarter-textWidth,top+5*textHeight);
    textWidth=fm.stringWidth(f.form(x.stdev()));
    g.drawString(f.form(x.stdev()),center-textWidth,top+5*textHeight);
    textWidth=fm.stringWidth("SE");
    g.drawString("SE",quarter-textWidth,top+6*textHeight);
    textWidth=fm.stringWidth(f.form(x.SE()));
    g.drawString(f.form(x.SE()),center-textWidth,top+6*textHeight);
    textWidth=fm.stringWidth("Min");
    g.drawString("Min",3*quarter-textWidth,top+2*textHeight);
    textWidth=fm.stringWidth(f.form(x.min()));
    g.drawString(f.form(x.min()),width-right-textWidth,top+2*textHeight);
    textWidth=fm.stringWidth("Q1");
    g.drawString("Q1",3*quarter-textWidth,top+3*textHeight);
    textWidth=fm.stringWidth(f.form(x.quant(0.25)));
    g.drawString(f.form(x.quant(0.25)),width-right-textWidth,top+3*textHeight);
    textWidth=fm.stringWidth("Median");
    g.drawString("Median",3*quarter-textWidth,top+4*textHeight);
    textWidth=fm.stringWidth(f.form(x.median()));
    g.drawString(f.form(x.median()),width-right-textWidth,top+4*textHeight);
    textWidth=fm.stringWidth("Q3");
    g.drawString("Q3",3*quarter-textWidth,top+5*textHeight);
    textWidth=fm.stringWidth(f.form(x.quant(0.75)));
    g.drawString(f.form(x.quant(0.75)),width-right-textWidth,top+5*textHeight);
    textWidth=fm.stringWidth("Max");
    g.drawString("Max",3*quarter-textWidth,top+6*textHeight);
    textWidth=fm.stringWidth(f.form(x.max()));
    g.drawString(f.form(x.max()),width-right-textWidth,top+6*textHeight);
    g.drawLine(left,top+6*textHeight+2,width-right,top+6*textHeight+2);
    g.drawLine(left,top+6*textHeight+3,width-right,top+6*textHeight+3);
    /* Canvas Functions */
    public Dimension getPreferredSize() {
    return(size);
    public Dimension getMinimumSize() {
    return(size);

    I'd guess there's a package corejava.Math, which is needed for this code to compile, but you don't have it...

  • AS3 Math issue

    If i have this code:
    var test: Boolean;
    test = false;
    if (2 == 2 == 1)
        test = true;
    trace (test);
    Result: true.
    var test: Boolean;
    test = false;
    if (2 == 2 == 2)
        test = true;
    trace (test);
    Result: false
    var test: Boolean;
    test = false;
    if (2 == 2 == 3)
        test = true;
    trace (test);
    Result: false.
    Why is that?

    This is not a Math issue, it is a matter of how a condfitonal test is carried out.   Conditions are tested as pairs (with a left to right hierarchy unless otherwise arranged using parentheses), meaning for 2 == 2 == whatever, first the test is performed to see if 2 == 2 ?, which is true, meaning the result evaluates as a "true".  Then the next comparison is performed using the result of the first... which would be...  true == whatever ?. which depends on "whatever" is.  A 1 evaluates as true as far as logic goes, but any other number does not, so true == 1 = true, true == 0,2,3,4,5.... = false
    You will find nothing passes the test if you reverse the order of the numbers.
    If you want to do compound conditional tests you are best to do it in pairs and/or use parentheses to define the order in which evaluations are managed.

  • Cannot cast boolean to BigDicemal??

    i am new in reporting
    i am using iReport 3.0...
    i want to show my line in report if a field value is greater than 5000
    my field type is BigDecimal
    i wrote formula as
    (($F{AvgAmount}.intValue() >= 5000 )? true : false )
    when i check expression result is Expression successfully validated.
    when i Run report error accour
    Errors compiling .\BranchWiseAverage.jasper.
    net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: 1. Cannot cast from boolean to BigDecimal                 value = (java.math.BigDecimal)(((((java.math.BigDecimal)field_AvgAmount.getValue()).intValue() >= 5000 )? true : false ));//$JR_EXPR_ID=14$                         <---------------------------------------------------------------------------------------------------------------> 2. Cannot cast from boolean to BigDecimal                 value = (java.math.BigDecimal)(((((java.math.BigDecimal)field_AvgAmount.getOldValue()).intValue() >= 5000 )? true : false ));//$JR_EXPR_ID=14$                         <------------------------------------------------------------------------------------------------------------------> 3. Cannot cast from boolean to BigDecimal                 value = (java.math.BigDecimal)(((((java.math.BigDecimal)field_AvgAmount.getValue()).intValue() >= 5000 )? true : false ));//$JR_EXPR_ID=14$                         <---------------------------------------------------------------------------------------------------------------> 3 errors      at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:193)     at it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:591)     at java.lang.Thread.run(Unknown Source)
    Compilation running time: 328
    how can i remove this error.
    thanks

    Hi Les,
    where there is a will, there is a script:
    Get-ADUser -Filter * -SearchBase "OU=Departments,dc=contoso,dc=com" -Properties * | select Name, @{ n = "Enabled"; e = { [int]$_.Enabled } }, Canon* | export-csv departments.csv
    Cheers,
    Fred
    There's no place like 127.0.0.1

Maybe you are looking for