Polygon2D.Float

I created this Polygon class. I've already tested it and it works just like java.awt.Polygon. This class
supports floating point coordinates. It does not extend Polygon in java.awt. Enjoy
import java.awt.*;
import java.awt.geom.*;
* This is a polygon that supports floating point values.  It does <b> not </b> extend java.awt.Polygon.  A polygon is comprised
* of an array of x values and an array of it's corrisponding y values.  There is also an integer value - npoints - that determine
* the number of points you want to be valid.  The polygon starts at xpoints[0] and ypoints[0] (if it exists) and connects a line
* to xpoints[1] and ypoints[1] and then to xpoints[2] and ypoints[2] and so on until the index equals npoints.  The path is then
* closed back to xpoints[0] and ypoints[0].  Lets see an example:
* <p>
* Polygon2D.Float p = new Polygon2D.Float( new float[] {20,20,40,40}, new float[] {20,40,40,20}, npoints);  //constructs a new new rectangle that is a polygon <br>
* graphics.fill(p);  // fills a rectangle <br>
* p.npoints = 3;  // the polygon now ignores the fourth coordinate <br>
* graphics.fill(p);  // fills a triangle <br>
* p.npoints = 2; // the polygon now ignores the last two coordinates <br>
* graphic.fill(p); // does nothing - cannot fill a line (does update the polygon) <br>
* graphic.draw(p); // draws a line; <br>
* p.npoints = 5; //not allowed, but no error yet. <br>
* try{graphic.draw(p)}catch(Exception e) {}// error - IndexOutOfBoundsException <br>
* p.npoints = 4; <br>
* p.xpoints[0] = 10; p.ypoints[0] = 10;  // makes it a weard looking rectangle; <br>
* Rectangle bounds = p.getBounds(); //the bounds is <b> incorrect </b>.  It is the bounds of when p.npoints was set to 2. <br>
* boolean contains = p.contains(30, 30); //will return false.  Should return true.  The shape is still set to when the p.npoins = 2 <br>
* p.invalidate(); //updates the the polygon <br>
* Rectangle bounds = p.getBounds(); //returns the correct bounds <br>
* boolean contains = p.contains(30, 30); //returns true <br>
* <p>
* If the polygon dosen't draw right make sure that your coordinates and npoints are right.  The polygon does not update itself
* by virtue of changing its coordinates directly or using the translate(float deltaX, float deltaY) method.  The polygon <b> is </b>
* updated just before every draw (when the getPathIterator(AffineTransform at) method is called).  This has several implications.
* All the contains, intersects, and getBounds methods go off the state the polygon was after its <b> last </b> update.  So if any of
* these methods are called after you have manipulated the polygon and before you have redrawn it, then these specific methods return innacurate
* results, becuase the polygon has not been updated yet.  If such a case occurs, call the invalidate() method to update the polygon forcibly.
* The documentation for the methods of Polygon2D are coppied straight out of java.awt.Shape.
* @author Christopher Colon
* @version 1.0
public abstract class Polygon2D implements Shape
    protected GeneralPath path;
    public Polygon2D()
       path = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
    /**Call this method after you are done with direct manipulation of the x and y points (including translate) and if you plan
     * to use any of the contains, intersects, or get bounds methods right after the
     * manipulation.  In effect this method 'updates' the polygon to its position and shape.  The polygon is always updated
     * just before drawing, so if you use any of the contains, intersects, or get bounds method
     * right after drawing and before manipulation, then these methods return accurate results.
     * Its in the period between manipulation and drawing that this method should be called if you
     * plan to use the other methods (excluding translate) before drawing.  */
    public abstract void invalidate();
    /**Tests if the specified coordinates are inside the boundary of the Shape.
     * @param x - the specified x coordinate
     * @param y - the specified y coordinate
     * @return true if the specified coordinates are inside the Shape boundary; false otherwise.*/
    public boolean contains(double x, double y)
        {return path.contains(x, y);}
    /**Tests if the interior of the Shape entirely contains the specified rectangular area. All coordinates that lie inside the rectangular area must lie within the Shape for the entire rectanglar area to be considered contained within the Shape.
     * This method might conservatively return false when: <br>
     * <p>
     * the intersect method returns true and <br>
     * the calculations to determine whether or not the Shape entirely contains the rectangular area are prohibitively expensive. <br>
     * <p>
     * This means that this method might return false even though the Shape contains the rectangular area.
     * The Area class can be used to perform more accurate computations of geometric intersection for any Shape
     * object if a more precise answer is required.
     * @param x - the x coordinate of the specified rectangular area
     * @param y - the y coordinate of the specified rectangular area
     * @param w - the width of the specified rectangular area
     * @param h - the height of the specified rectangular area
     * @return true if the interior of the Shape entirely contains the specified rectangular area; false otherwise or, if the Shape
     *          contains the rectangular area and the intersects method returns true and the containment calculations would be too
     *          expensive to perform.*/
    public boolean contains(double x, double y, double w, double h)
        {return path.contains(x,y,w,h);}
    /**Tests if a specified Point2D is inside the boundary of the Shape.
     * @param p - a specified Point2D
     * @return true if the specified Point2D is inside the boundary of the Shape; false otherwise.*/   
    public boolean contains(Point2D p)
        {return path.contains(p);}
    /**Tests if the interior of the Shape entirely contains the specified rectangular area. All coordinates that lie inside the rectangular area must lie within the Shape for the entire rectanglar area to be considered contained within the Shape.
     * This method might conservatively return false when: <br>
     * <p>
     * the intersect method returns true and <br>
     * the calculations to determine whether or not the Shape entirely contains the rectangular area are prohibitively expensive. <br>
     * <p>
     * This means that this method might return false even though the Shape contains the rectangular area.
     * The Area class can be used to perform more accurate computations of geometric intersection for any Shape
     * object if a more precise answer is required.
     * @param r - The specified Rectangle2D
     * @return true if the interior of the Shape entirely contains the specified rectangular area; false otherwise or, if the Shape
     *          contains the rectangular area and the intersects method returns true and the containment calculations would be too
     *          expensive to perform.*/
    public boolean contains(Rectangle2D r)
        {return path.contains(r);}
    /**Returns an integer Rectangle that completely encloses the Shape. Note that there is no guarantee that the returned Rectangle is
     * the smallest bounding box that encloses the Shape, only that the Shape lies entirely within the indicated Rectangle.
     * The returned Rectangle might also fail to completely enclose the Shape if the Shape overflows the limited range of the integer
     * data type. The getBounds2D method generally returns a tighter bounding box due to its greater flexibility in representation.
     * @return an integer Rectangle that completely encloses the Shape.*/
    public Rectangle getBounds()
        {return path.getBounds();}
    /**Returns a high precision and more accurate bounding box of the Shape than the getBounds method. Note that there is no
     * guarantee that the returned Rectangle2D is the smallest bounding box that encloses the Shape, only that the Shape lies
     * entirely within the indicated Rectangle2D. The bounding box returned by this method is usually tighter than that returned by
     * the getBounds method and never fails due to overflow problems since the return value can be an instance of the Rectangle2D that
     * uses double precision values to store the dimensions.
     * @return an instance of Rectangle2D that is a high-precision bounding box of the Shape.*/
    public Rectangle2D getBounds2D()
        {return path.getBounds2D();}
    /**Returns an iterator object that iterates along the Shape boundary and provides access to the geometry of the Shape outline.
     * If an optional AffineTransform is specified, the coordinates returned in the iteration are transformed accordingly.
     * Each call to this method returns a fresh PathIterator object that traverses the geometry of the Shape object independently
     * from any other PathIterator objects in use at the same time.
     * It is recommended, but not guaranteed, that objects implementing the Shape interface
     * isolate iterations that are in process from any changes that might occur to the original object's geometry during such iterations.
     * Before using a particular implementation of the Shape interface in more than one thread simultaneously, refer
     * to its documentation to verify that it guarantees that iterations are isolated from modifications.
     * @param at - an optional AffineTransform to be applied to the coordinates as they are returned in the iteration,
     *              or null if untransformed coordinates are desired
     * @return a new PathIterator object, which independently traverses the geometry of the Shape.*/  
    public abstract PathIterator getPathIterator(AffineTransform at);
     /**Returns an iterator object that iterates along the Shape boundary and provides access to a flattened view of the Shape
      * outline geometry. Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE point types are returned by the iterator.
      * If an optional AffineTransform is specified, the coordinates returned in the iteration are transformed accordingly.
      * The amount of subdivision of the curved segments is controlled by the flatness parameter, which specifies the maximum
      * distance that any point on the unflattened transformed curve can deviate from the returned flattened path segments.
      * Note that a limit on the accuracy of the flattened path might be silently imposed, causing very small flattening parameters
      * to be treated as larger values. This limit, if there is one, is defined by the particular implementation that is used.
      * Each call to this method returns a fresh PathIterator object that traverses the Shape object geometry independently
      * from any other PathIterator objects in use at the same time. It is recommended, but not guaranteed, that objects implementing
      * the Shape interface isolate iterations that are in process from any changes that might occur to the original object's geometry
      * during such iterations. Before using a particular implementation of this interface in more than one thread simultaneously,
      * refer to its documentation to verify that it guarantees that iterations are isolated from modifications.
      * @param at - an optional AffineTransform to be applied to the coordinates as they are returned in the iteration, or
      *              null if untransformed coordinates are desired
      * @param flatness - the maximum distance that the line segments used to approximate the curved segments are
      *                      allowed to deviate from any point on the original curve
      * @return a new PathIterator that independently traverses the Shape geometry.*/
    public abstract PathIterator getPathIterator(AffineTransform at, double flatness);
    /** Tests if the interior of the Shape intersects the interior of a specified rectangular area. The rectangular area is
     * considered to intersect the Shape if any point is contained in both the interior of the Shape and the specified rectangular area.
     * This method might conservatively return true when: <br>
     * there is a high probability that the rectangular area and the Shape intersect, but  <br>
     * the calculations to accurately determine this intersection are prohibitively expensive. <br>
     * This means that this method might return true even though the rectangular area does not intersect the Shape. <br>
     * The Area class can be used to perform more accurate computations of geometric intersection for any Shape object if a more
     * precise answer is required.
     * @param x - the x coordinate of the specified rectangular area
     * @param y - the y coordinate of the specified rectangular area
     * @param w - the width of the specified rectangular area
     * @param h - the height of the specified rectangular area
     * @return true if the interior of the Shape and the interior of the rectangular area intersect, or are
     *         both highly likely to intersect and intersection calculations would be too expensive to perform; false otherwise.*/
    public boolean intersects(double x, double y, double w, double h)
        {return path.intersects(x, y, w, h);}
    /**Tests if the interior of the Shape intersects the interior of a specified Rectangle2D.
     * This method might conservatively return true when: <br>
     * there is a high probability that the Rectangle2D and the Shape intersect, but <br>
     * the calculations to accurately determine this intersection are prohibitively expensive. <br>
     * This means that this method might return true even though the Rectangle2D does not intersect the Shape.
     * @param r - the specified Rectangle2D
     * @return true if the interior of the Shape and the interior of the specified Rectangle2D intersect, or are both
     *         highly likely to intersect and intersection calculations would be too expensive to perform; false otherwise.*/
    public boolean intersects(Rectangle2D r)
        {return path.intersects(r);}
    public static class Float extends Polygon2D implements Cloneable
        public float xpoints[];
        public float ypoints[];
        public int npoints;
        /**Creates a new empty polygon. The array of xpoints and ypoints is set to a size of 4.  So long as npoints remain 0
         * then everthing is fine.  The addPoint(float x, float y) appends the coordinates to xpoints[npoints+1] and ypoints[npoints+1]
         * and then increments npoints.*/
        public Float()
            xpoints = new float[4];
            ypoints = new float[4];
            npoints = 0;
        /**Creates a new empty polygon. The array of xpoints and ypoints is set to a size of the expectedCapacity.  So long as npoints remain 0
         * then everthing is fine.  The addPoint(float x, float y) appends the coordinates to xpoints[npoints+1] and ypoints[npoints+1]
         * and then increments npoints.
         * @throws NegativeArraySizeException If expectedCapacity < 0*/
        public Float(int expectedCapacity)
            if(expectedCapacity < 0) throw new NegativeArraySizeException("negative array size");
            xpoints = new float[expectedCapacity];
            ypoints = new float[expectedCapacity];
            npoints = 0;
        /**Creates a new polygon that represent the given specifications.*/
        public Float(float[] x, float[] y, int npoints)
            if(npoints < 0) throw new NegativeArraySizeException("negative amount of sides (npoints < 0)");
            if(npoints > x.length || npoints > y.length) throw new IndexOutOfBoundsException("more sides than points");
            if(x == null || y == null) throw new NullPointerException("null array of points");
            this.xpoints = x;
            this.ypoints = y;
            this.npoints = npoints;
            constructPath();
        /**Creates a new polygon that represent the given specifications.  The integers are coppied over as float values.*/
        public Float(int[] x, int[] y, int npoints)
            if(npoints < 0) throw new NegativeArraySizeException("negative amount of sides (npoints < 0)");
            if(npoints > x.length || npoints > y.length) throw new IndexOutOfBoundsException("more sides than points");
            if(x == null || y == null) throw new NullPointerException("null array of points");
            xpoints = new float[x.length];
            for(int index = 0; index < x.length; index++) xpoints[index] = x[index];
            ypoints = new float[y.length];
            for(int index = 0; index < y.length; index++) ypoints[index] = y[index];
            this.npoints = npoints;
            constructPath();           
       /*Updates the polygon.*/    
       private synchronized void constructPath()
            if(npoints < 0) throw new NegativeArraySizeException("negative amound of sides (nPoints < 0)");
            path.reset();
            if(xpoints.length == 0 || ypoints.length == 0) return;
            path.moveTo(xpoints[0], ypoints[0]);
            for(int index = 0; index < npoints; index++)
                path.lineTo(xpoints[index],ypoints[index]);
            path.closePath();
        /**The addPoint(float x, float y) appends the coordinates to xpoints[npoints+1] and ypoints[npoints+1]
         * and then increments npoints.*/
        public synchronized void addPoint(float x, float y)
            if(xpoints.length == npoints)
                float[] temp = new float[xpoints.length+1];
                for(int index = 0; index < xpoints.length; index++) temp[index] = xpoints[index];
                xpoints = temp;
            if(ypoints.length == npoints)
                float[] temp = new float[ypoints.length+1];
                for(int index = 0; index < ypoints.length; index++) temp[index] = ypoints[index];
                ypoints = temp;
            xpoints[npoints+1] = x;
            ypoints[npoints+1] = y;
            npoints++;
        /**Rotate the polygon by the specified amount of degrees around the specified pivot point. It is entirly possible
         * that the polygon could shrink a little or grow a little, after repeated calls to this method.  This is due to
         * rounding errors (double to float).  If the polygon shrinks a little, it will expand a little the next time and vise versa. 
         * The net result is that the polygon is always within 5 (just an estimate) pixels of the intended polygon rotation. So
         * the polygon will never expand too much or shrink too much.  In general the greatest shrinkage or expansion occurs
         * when the polygon is rotated about its center.*/
        public void rotate(double deltaTheta, double pivotX, double pivotY)
            while(deltaTheta >= 360) deltaTheta -= 360;
            while(deltaTheta < 0) deltaTheta += 360;
            for(int index = 0; index < npoints; index++)
                if(xpoints[index] == pivotX && ypoints[index] == pivotY) continue;
                double distance = Point.distance(xpoints[index], ypoints[index], pivotX, pivotY);
                double angle = Math.atan( -(ypoints[index] - pivotY) / (xpoints[index] - pivotX) );
                if((xpoints[index] - pivotX) < 0) angle += Math.PI;
                angle += Math.toRadians(deltaTheta);
                xpoints[index] = (float) (Math.cos(angle) * distance + pivotX);
                ypoints[index] = (float) (-Math.sin(angle) * distance + pivotY);
        /**Rotate the polygon about its center by the specified amount of degrees.  This is the equivalent of calling
         * rotate(deltaTheta, (float) getXMid(), (float) getYMid()).*/
        public void rotate(double deltaTheta)
            rotate(deltaTheta, getXMid(), getYMid());
        /**Resize the polygon by the specified factor.  A factor of 1 will not change the polygon.
         * A factor greater than 1 will make the polygon grow.  A factor between 0 and 1 will make the polygon shrink.
         * The polygon shrinks towards its center or grows away from its center.
         * @throws IllegalArgumentException if the factor is less than 0.*/
        public void resize(double factor)
            if(factor < 0) throw new IllegalArgumentException("illegal factor");
            if(factor == 1) return;
            double xMid = getXMid();
            double yMid = getYMid();
            for(int index = 0; index < npoints; index++)
                xpoints[index] = (float) (((xpoints[index] - xMid) * factor) + xMid);
                ypoints[index] = (float) (((ypoints[index] - yMid) * factor) + yMid);
        /**Returns the x coordinate of the mid point (center) of this polygon.*/
        public double getXMid()
            double sum = 0;
            for(int index = 0; index < npoints; index++) sum += xpoints[index];
            return sum / npoints;
        /**Returns the y coordinate of the mid point (center) of this polygon.*/
        public double getYMid()
            double sum = 0;
            for(int index = 0; index < npoints; index++) sum += ypoints[index];
            return sum / npoints;
        /**Resets this polygon to an empty polygon.*/
        public synchronized void reset()
            xpoints = new float[xpoints.length];
            ypoints = new float[ypoints.length];
            npoints = 0;
         /**Translates the polygon by the specified x and y amounts.  The polygon is not updated
          * after the transformation.*/
        public void translate(float deltaX, float deltaY)
            for(int index = 0; index < xpoints.length; index++) xpoints[index] += deltaX;
            for(int index = 0; index < ypoints.length; index++) ypoints[index] += deltaY;
        public void invalidate()
             {constructPath();}
        public PathIterator getPathIterator(AffineTransform at)
        {   constructPath();
            return path.getPathIterator(at);}
        public PathIterator getPathIterator(AffineTransform at, double flatness)
        {   constructPath();
            return path.getPathIterator(at, flatness);}
        /**Returns a polygon with the same shape and points.*/
        public Object clone()
            return new Polygon2D.Float(xpoints, ypoints, npoints);
}

I assume the reason you posted your code is because you want feedback. The GeneralPath class does not allow the points to be changed (or even looked at) once an operation has been performed. If that is the problem you were facing, then I probably would recommend using the GeneralPath class as a guideline to implement your new class on. I don't see the need to wrap the "Float" class inside the Polygon2D class. The fact that Polygon2D.Float is a container of points is not very clear by the name. Lastly, it looks like everytime you add a point, you will have to call invalidate() to update the internal storage. That is somewhat inefficient, and probably more confusing than anything. For your clone method, I would recommend doing a deep copy.

Similar Messages

  • Float overlow Exception!

    Hi all,
    To quote JLS in verbatim ..."Java floating-point
    operators produce no exceptions (�11). An operation
    that overflows produces a signed infinity, an
    operation that underflows produces a signed zero, and
    an operation that has no mathematically definite
    result produces NaN."
    But I am facing a problem here. The highest value
    that can be held by a Double variable is
    1.79769313486231570e+308. Any operation resulting in
    an overflow of this variable should produce 'infinity'
    accodring to the JLS but I am getting a
    "EXCEPTION_FLT_OVERFLOW". Does this have something to
    do with the OS or the processor?
    Here's a simple test program:
    public class FloatingPointInexactRulesTest {
    public static void main(String[] args) {
    // An example of overflow:
    double d = 1.79769313486231570e+308;
    System.out.print("overflow produces infinity: ");
    System.out.println(d + "*1.1==" + d*1.1);
    The program's output should have been:
    overflow produces infinity: 1.0e+308*1.1==Infinity
    but I get a EXCEPTION_FLT_OVERFLOW! Since the JVM cant
    violate the semantics of the JLS I think the problem
    lies somewhere else(either the OS or the processor). I
    am using WIndows2000 as the OS and Intel PIV as the
    processor.
    Please help me...
    --------------EXCEPTION!---------------------
    Unexpected Signal : EXCEPTION_FLT_OVERFLOW
    (0xc0000091) occurred at PC=0xEFA6C3
    Function=[Unknown.]
    Library=(N/A)
    NOTE: We are unable to locate the function name symbol
    for the error
    just occurred. Please refer to release
    documentation for possible
    reason and solutions.
    Current Java thread:
    Dynamic libraries:
    0x00400000 - 0x00407000
    C:\j2sdk1.4.2_04\bin\java.exe
    0x77F80000 - 0x77FFD000
    C:\WINNT\system32\ntdll.dll
    0x7C2D0000 - 0x7C332000
    C:\WINNT\system32\ADVAPI32.dll
    0x7C570000 - 0x7C628000
    C:\WINNT\system32\KERNEL32.DLL
    0x77D30000 - 0x77D9E000
    C:\WINNT\system32\RPCRT4.DLL
    0x78000000 - 0x78045000
    C:\WINNT\system32\MSVCRT.dll
    0x00250000 - 0x002C3000
    C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\uga1.tmp
    0x71710000 - 0x71794000
    C:\WINNT\system32\COMCTL32.DLL
    0x77F40000 - 0x77F7E000
    C:\WINNT\system32\GDI32.dll
    0x77E10000 - 0x77E75000
    C:\WINNT\system32\USER32.DLL
    0x76620000 - 0x76630000
    C:\WINNT\system32\MPR.DLL
    0x77A50000 - 0x77B3C000
    C:\WINNT\system32\OLE32.DLL
    0x779B0000 - 0x77A4B000
    C:\WINNT\system32\OLEAUT32.DLL
    0x75050000 - 0x75058000
    C:\WINNT\system32\WSOCK32.DLL
    0x75030000 - 0x75044000
    C:\WINNT\system32\WS2_32.DLL
    0x75020000 - 0x75028000
    C:\WINNT\system32\WS2HELP.DLL
    0x08000000 - 0x08138000
    C:\j2sdk1.4.2_04\jre\bin\client\jvm.dll
    0x77570000 - 0x775A0000
    C:\WINNT\system32\WINMM.dll
    0x10000000 - 0x10007000
    C:\j2sdk1.4.2_04\jre\bin\hpi.dll
    0x00CE0000 - 0x00CEE000
    C:\j2sdk1.4.2_04\jre\bin\verify.dll
    0x00CF0000 - 0x00D09000
    C:\j2sdk1.4.2_04\jre\bin\java.dll
    0x00D10000 - 0x00D1D000
    C:\j2sdk1.4.2_04\jre\bin\zip.dll
    0x77920000 - 0x77943000
    C:\WINNT\system32\imagehlp.dll
    0x72A00000 - 0x72A2D000
    C:\WINNT\system32\DBGHELP.dll
    0x690A0000 - 0x690AB000
    C:\WINNT\system32\PSAPI.DLL
    Heap at VM Abort:
    Heap
    def new generation total 576K, used 197K
    [0x10010000, 0x100b0000, 0x104f0000)
    eden
    Another exception has been detected while we were
    handling last error.
    Dumping information about last error:
    ERROR REPORT FILE = (N/A)
    PC = 0x00efa6c3
    SIGNAL = -1073741679
    FUNCTION NAME = (N/A)
    OFFSET = 0xFFFFFFFF
    LIBRARY NAME = (N/A)
    Please check ERROR REPORT FILE for further
    information, if there is any.
    Good bye.
    --------------EXCEPTION!---------------------
    Thanks a lot.

    Yeah switching to Linux is a good idea. The firsttime I tried that,
    GRUB crashed and I screwed everything else tryingto copy the
    bootloader. Before this I had problems accessingthe file system on
    Windows via LAN, Samba server is not really theeasiest to use.
    Before that I had display problems with wierdmessages like sync out
    of range, Init respawning too fast so disabling.......I guess this is just
    the tip of an iceberg when it comes to problemswith Linux. It is
    sometimes really frustrating.Really? The only problems I recognise are the
    automatic chip set
    detection for the graphics card. I always let it boot
    in 'mode 3', figure
    out the exact chip set present in the computer and
    only then switch
    to 'mode 5' ...Yeah I had all these problems with RH Linux within a span of 2 months.
    I solved most of them though(Google is my best friend ;). The problem with the display was coz of horizontal and vertical sync values.
    btw, Samba has a nice webbrowser interface; I simply
    follow the docs
    step by step (I know next to nothing about Samba) and
    I'm in business
    after typing in all the required stuff ...I had problems with Samba bcoz of the firewall settings and the firewall interface was not comin on properly on the display.
    And now there are viruses for Linux too!Never do anything online when logged in as root and
    keep your FS
    permissions sensible.Yeah. I dont log in to root untill it is really really needed.
    An offtopic question (hope no one minds) Is there any book for Linux which is on the same lines of "The Design of the Unix Operating System" by Maurice.J.Bach?. If yes, then pls pls lemme know. I am a big Fan of "The Design of the Unix Operating System".
    kind regards,
    JosThanks and regards.

  • Convert Char to float

    Hi all,
    Am wanting to convert a char value (the infoobject is defined as NUMC) into float in order to perform a calculation in the FOX formula. It would not allow the char value to be stored into a float variable...comes back wz an error message - Types of operands F and <infoobject_numc> do not agree.
    Any ways of doing this? I thought about using a function to perform the conversion from char to float format but dont knw if such a function exists on the BI system?
    Thanks!

    Hi,
    I sometimes use a local variable of type STRING to pass on values to other data types:
    DATA local type STRING.
    local = A.
    B = local.
    But I'm not sure it will work for you. If not, you can do it with an exit function.
    D

  • Floating fields and fragment subforms in Outlook 2007 do not display correctly

    I'm using LCES Forms 8.0 Update 1 to render a non-interactive HTML forms using dynamic content (customer info). The email appears ok in clients except in Outlook 2007.
    The Floating text and Text Fields appear multiple times on the form (scattered around their placement point on the form) and the subform fragments are appearing with borders surrounding them.
    I have heard that there are issues with Outlook 2007 not displaying HTML correctly. Is there a way to setup the Text Fields/Subforms in Designer so they display correctly in Outlook 2007?
    Thanks!

    Create a new profile as a test to check if your current profile is causing the problems.
    See "Basic Troubleshooting: Make a new profile":
    *https://support.mozilla.org/kb/Basic+Troubleshooting#w_8-make-a-new-profile
    There may be extensions and plugins installed by default in a new profile, so check that in "Tools > Add-ons > Extensions & Plugins" in case there are still problems.
    If the new profile works then you can transfer some files from the old profile to that new profile, but be careful not to copy corrupted files.
    See:
    *http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox

  • Please Help!  I don't want images to "stick" to the outside of CS3!  I want them to float!

    I have CS3 and I like having my images float without "sticking" to anything over the whole screen.  As it is now, they like to grab onto the edge of the application when I move them outside its boundaries.  I did this all the time in CS2 and I like it a lot.  This new thing is very annoying and I want desperately to TURN IT OFF.  Please!  I am asking could someone please tell me how to turn the image stickiness to the edge of the app OFF?  Thanks so much in advance!
    Nothing I've tried thus far has worked and I've lost three days trying to figure it out.  Why is this not a clickable option to turn off in preferences???

    You can't.
    The Mail.app displays all image/photo and single page PDF attachments inline or viewed in place within the body of the message by default - sending and receiving.
    You can control-click on a viewed in place attachment and select View as Icon but the icon for the attached file will remain in the body of the message. Regardless, depending on the recipient's email client and available preference settings, such attachments may appear inline or viewed in place when the message is opened by the recipient (as with the Mail.app when receiving such attachments) or as attached files only which must be opened separately to be viewed for which the sender has no control over.
    This was a minor adjustment for me at first but I now prefer such attachments being displayed inline since I have confirmation that I selected the correct file or file names as attachments before the message is sent.

  • XLS upload via HSODBC. Unable to upload numeric (float) fields

    hi,
    I wrote a program unit with Oracle Forms Builder 10g to upload and read an Excel sheet.
    I created a HSODBC Data link to my DB, and used Excel 2003 to edit the XLS file to upload, and WEBUTIL_FILE_TRANSFER.CLIENT_TO_AS(client_dir_file,'\\server\dir\myfile.xls') to upload.
    My DBLink works and Im able to upload the file. But it seems oracle is unable to upload some fields containing numeric (float) values.
    running DESCRIBE [email protected]; I got this table structure
    UPLOAD_DATE          DATE
    NUMBER VARCHAR2(32512 CHAR)
    CODE VARCHAR2(32512 CHAR)
    DESCR          VARCHAR2(32512 CHAR)
    SIMILARS FLOAT(49)
    WIDTH VARCHAR2(32512 CHAR)
    HEIGHT VARCHAR2(32512 CHAR)
    HIGH      VARCHAR2(32512 CHAR)
    ITEMS      FLOAT(49)
    fields SIMILARS, WIDTH, HEIGHT, HIGH, ITEMS contain numeric values in float format (ex: 1,00000). When I run
    SELECT * FROM [email protected]
    I get that WIDTH, HEIGHT, HIGH columns are EMPTY (contain NULL values), while SIMILARS and ITEMS contains not null values.
    I am sure that the \\server\dir\myfile.xls contains not null values for WIDTH, HEIGHT, HIGH fields! I tried to change cells format before upload, setting them to FLOAT, but I got no results!
    Please help me, how can I do to change cell format in order to obtain a correct upload?

    E.C.
    there is a mistake in the subject. As I said in my thread, the upload works and the uploaded file contains all values. My problem is that I am "unable to READ" the numeric values stored in VARCHAR2 fields.

  • Union two tables with diffrent count of fields with null and float value

    Hello,
    i want to union two tables, first one with 3 fields and second one with 4 fields (diffrent count of fields).
    I can add null value at end of first select but it does not work with float values in second table. Value form second table is convert to integer.
    For example:
    select null v1 from sessions
    union
    select 0.05 v1 from sessions
    result is set of null and 0 value.
    As workaround i can type:
    select null+0.0 v1 from sessions
    union
    select 0.05 v1 from sessions
    or simple change select's order.
    Is any better/proper way to do this? Can I somehow set float field type in first select?
    Best regards,
    Lukasz.
    WIN XP, MAXDB 7.6.03

    Hi Lukasz,
    in a UNION statement the first statement defines the structure (number, names and types of fields) of the resultset.
    Therefore you have to define a FLOAT field in the first SELECT statement in order to avoid conversion to VARCHAR.
    Be aware that NULL and 0.0 are not the same thus NULL+0.0 does not equal NULL.
    In fact NULL cannot equal to any number or character value at all.
    BTW: you may want to use UNION ALL to avoid the search and removal of duplicates - looks like your datasets won't contain duplicates anyhow...
    Regards,
    Lars

  • Drop down boxes do not show up. My tabs are not visible. I could barely see the box to type in this question. Something is off. I deleted and reinstalled program it is still just floating words. I work on a Mac with ox 10.6.8

    The browser boxes, tabs, and links do not show up with the needed outlines, colors, and shapes. This box I am typing in was barely visible. Above this box is a set of two verticle parallel bars. When I moused over it, I saw it was for inserting a link, but if I had not been curious I would not have known what those lines were for. When I look at this page on PC I have a colored blue backdrop. It is not visible on the Mac. The search box does not have the image of the magnifying class and the arrow does not show up where it should be. The words Post Question just appear below the statement we have made some educated guesses about your browser. I thought maybe it had been a theme that was applied, but I do not see how it could have come on when I trashed the old version of the firefox.

    A;though the CSS is very well documented, there are those that ignore those signs. Look at the following
    /* Menu item containers, position children relative to this container and are a fixed width */
    ul.MenuBarHorizontal li
        margin: 0;
        padding: 0;
        list-style-type: none;
        font-size: 100%;
        position: relative;
        text-align: left;
        cursor: pointer;
        width: auto;
        float: left;
    The rest have been given a width of 15em, so this value may be a good start.
    DESIGN INFORMATION: describes color scheme, borders, fonts
    /* Submenu containers have borders on all sides */
    ul.MenuBarHorizontal ul
        border: 1px solid #CCC;
       width: auto;
        background-attachment: fixed;
    Just keep the border property and remove the other two.
    BROWSER HACKS: the hacks below should not be changed unless you are an expert
    /* HACK FOR IE: to make sure the sub menus show above form controls, we underlay each submenu with an iframe */
    ul.MenuBarHorizontal iframe
        position: absolute;
        z-index: 1010;
    /* HACK FOR IE: to stabilize appearance of menu items; the slash in float is to keep IE 5.0 from parsing */
    @media screen, projection
    ul.MenuBarHorizontal li.MenuBarItemIE
              display: inline;
              f\loat: left;
              background: #FFF;
    The following is the original for the above
    BROWSER HACKS: the hacks below should not be changed unless you are an expert
    /* HACK FOR IE: to make sure the sub menus show above form controls, we underlay each submenu with an iframe */
    ul.MenuBarHorizontal iframe
        position: absolute;
        z-index: 1010;
        filter:alpha(opacity:0.1);
    /* HACK FOR IE: to stabilize appearance of menu items; the slash in float is to keep IE 5.0 from parsing */
    @media screen, projection
        ul.MenuBarHorizontal li.MenuBarItemIE
            display: inline;
            f\loat: left;
            background: #FFF;
    Cheers,
    Gramps

  • Photos/graphics insert over text, will not float or move

    I'm trying to compose a document in Pages '09. If I use the Insert>Choose command to add either a graphic or a photo, the item is inserted over existing text. Under WRAP, all options are greyed out (Inline, Floating, Background) and Object Causes Wrap moves the graphic out of sight.  Is there a fix? Must the photo or graphic be a .tiff or .jpeg only?  It seems to me that Pages did not used to be so strict and fixed - although sometimes I have had to go to Keynote to prepare something. I thought Pages was a page layout program!

    Yes, I select the image. Cannot even drag an image from the image iPhoto selector to the page. The page is set up for 2 columns,

  • I am trying to find an image that was on the Photoshop 3 samples from the mid '90s.  It was islands reflected in a still lake with stars making the islands look like they were floating.

    How do I go about finding this image?  I have the original PS 3 disk but it is to old to load the program now.  It was an image of a lake with islands that appeared to be floating in the night sky as the stars were reflected in the still water. 

    Not at all familiar with Photoshop 3. Have you tried a Google search?
    Benjamin

  • How do I keep a floating window on top of a tabbed document so that it can be used as a reference while drawing/painting?

    Just started using Photoshop CC on my iMac and I have noticed this issue which I did not have using windows based computers. Any floating window just seems to hide in the background as soon as I click on the tabbed document I want to work on. This is an issue for me since I like to have a couple of references open while painting plus I always have another with nothing but my color palette in it. I've already gone over the preferences but can't seem to find the way to avoid this and the options from Widow>Arrange weren't any help also resizing all windows so that they don't overlap each other ends up wasting a lot of screen real estate.

    c.pfaffenbichler meruhelp this is what I'm used to in Windows windowsWORKSPACE | Flickr - Photo Sharing! and yes the active document does not need to be the top most window. This enables me to have my references as floating windows and keep them where I need them as I paint.
    This is what I have to do while working on my Mac macWORKSPACE | Flickr - Photo Sharing! keeping references to either side using floating windows or options from Window>Arrange. If I drag them closer to the area I want to work on, the window will either disappear behind the active document window or it will overlap as you can see in the two images in the top left corner. Aside from the extra work from rearranging windows this way I feel that I'm loosing a good chunk of screen (see yellow striped area).

  • Floating VI front panel

    I have question regarding keeping a specific VI front panel always "On Top" of any other front panels(Sort of like toolbar pallete floats over the "main" window in LabVIEW). I can set the front panel properties to be a dialog (ModaL) but then I don't have access to menu or any other controls on the other front panels. I can set the front panel properties to normal, but when the operators click on main front panel the other front panel goes to the back. We have very very very novice computers and they get confused and they can't "find" the "other front panel".
    Any help would be greatly appreciated.
    Thanks

    If you have LabVIEW 7.0 or 7.1, there is another selection in Window Apperance setup called 'Floating' that does exactly what you want.
    If you have an earlier version, this Dev Zone thread may help.
    Ed
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.

  • Issue with setting float point in Textfield

    hi
    i have an issue with float input in a textfield.
    what i want to do is.
    when the user start typing numerics it should accept from right hand side and keep appending value from right hand side.
    for ex
    if i want to enter 123.45
    user starts entering
    1 then it should display as 0.01
    2 then it should display as 0.12
    3 then it should display as 1.23
    4 then it should display as 12.34
    5 then it should display as 123.45
    to achive this i have written the code as below
    public class Test{
         public static void main(String[] a){
         try {
    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception evt) {}
    DecimalFormat format = new DecimalFormat();
    format.setGroupingUsed(true);
    format.setGroupingSize(3);
    format.setParseIntegerOnly(false);
    JFrame f = new JFrame("Numeric Text Field Example");
    final DecimalFormateGen tf = new DecimalFormateGen(10, format);
    // tf.setValue((double) 123456.789);
    tf.setHorizontalAlignment(SwingConstants.RIGHT);
    JLabel lbl = new JLabel("Type a number: ");
    f.getContentPane().add(tf, "East");
    f.getContentPane().add(lbl, "West");
    tf.addKeyListener(new KeyAdapter(){
         public void keyReleased(KeyEvent ke){
              char ch = ke.getKeyChar();
              char key;
              int finalres =0;
              String str,str1 = null,str2 =null,str3 = null,str4= null;
              if(ke.getKeyChar() == KeyEvent.VK_0 || ke.getKeyChar() == KeyEvent.VK_0 ||
                        ke.getKeyChar() == KeyEvent.VK_0 || ke.getKeyChar() == KeyEvent.VK_1 || ke.getKeyChar() == KeyEvent.VK_2 ||
                             ke.getKeyChar() == KeyEvent.VK_3 || ke.getKeyChar() == KeyEvent.VK_4 || ke.getKeyChar() == KeyEvent.VK_5 ||
                             ke.getKeyChar() == KeyEvent.VK_6 || ke.getKeyChar() == KeyEvent.VK_7 || ke.getKeyChar() == KeyEvent.VK_8 ||
                             ke.getKeyChar() == KeyEvent.VK_9 ){
                   double value1 = Double.parseDouble(tf.getText());
                   int position = tf.getCaretPosition();
                   if(tf.getText().length() == 1){
                        if(tf.getText() != null || tf.getText() != ""){
                        value1 = value1 / 100;
                        tf.setText(String.valueOf(value1));
                   /*else if(tf.getText().length() == 3){
                        str = tf.getText();
                        for(int i=0;i<str.length();i++){
                             if(str.charAt(i) == '.'){
                                  str1 = str.substring(0,i);
                                  str2 = str.substring(i+1,str.length()-1);
                                  break;
                        key = ke.getKeyChar();
                        finalres = calculate.calculate1(str2,key);
                        str3 = merge.merge1(str1,finalres);
                        tf.setText(str3);
                        System.out.println(key);
                        System.out.println(str1);
                        System.out.println(str2);
                   else{
                        value1 = Float.parseFloat(tf.getText());
                        value1 = value1*10;
                        tf.setText(String.valueOf(value1));
    tf.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
    try {
    tf.normalize();
    Long l = tf.getLongValue();
    System.out.println("Value is (Long)" + l);
    } catch (ParseException e1) {
    try {
    Double d = tf.getDoubleValue();
    System.out.println("Value is (Double)" + d);
    } catch (ParseException e2) {
    System.out.println(e2);
    f.pack();
    f.setVisible(true);
    import javax.swing.JTextField;
    * Created on May 25, 2005
    * TODO To change the template for this generated file go to
    * Window - Preferences - Java - Code Style - Code Templates
    * @author jagjeevanreddyg
    * TODO To change the template for this generated type comment go to
    * Window - Preferences - Java - Code Style - Code Templates
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.text.DecimalFormat;
    import java.text.ParseException;
    import java.text.ParsePosition;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
    import javax.swing.UIManager;
    import javax.swing.text.AbstractDocument;
    import javax.swing.text.AttributeSet;
    import javax.swing.text.BadLocationException;
    import javax.swing.text.Document;
    import javax.swing.text.PlainDocument;
    import javax.swing.text.AbstractDocument.Content;
    public class DecimalFormateGen extends JTextField implements
    NumericPlainDocument.InsertErrorListener {
         public DecimalFormateGen() {
         this(null, 0, null);
         public DecimalFormateGen(String text, int columns, DecimalFormat format) {
         super(null, text, columns);
         NumericPlainDocument numericDoc = (NumericPlainDocument) getDocument();
         if (format != null) {
         numericDoc.setFormat(format);
         numericDoc.addInsertErrorListener(this);
         public DecimalFormateGen(int columns, DecimalFormat format) {
         this(null, columns, format);
         public DecimalFormateGen(String text) {
         this(text, 0, null);
         public DecimalFormateGen(String text, int columns) {
         this(text, columns, null);
         public void setFormat(DecimalFormat format) {
         ((NumericPlainDocument) getDocument()).setFormat(format);
         public DecimalFormat getFormat() {
         return ((NumericPlainDocument) getDocument()).getFormat();
         public void formatChanged() {
         // Notify change of format attributes.
         setFormat(getFormat());
         // Methods to get the field value
         public Long getLongValue() throws ParseException {
         return ((NumericPlainDocument) getDocument()).getLongValue();
         public Double getDoubleValue() throws ParseException {
         return ((NumericPlainDocument) getDocument()).getDoubleValue();
         public Number getNumberValue() throws ParseException {
         return ((NumericPlainDocument) getDocument()).getNumberValue();
         // Methods to install numeric values
         public void setValue(Number number) {
         setText(getFormat().format(number));
         public void setValue(long l) {
         setText(getFormat().format(l));
         public void setValue(double d) {
         setText(getFormat().format(d));
         public void normalize() throws ParseException {
         // format the value according to the format string
         setText(getFormat().format(getNumberValue()));
         // Override to handle insertion error
         public void insertFailed(NumericPlainDocument doc, int offset, String str,
         AttributeSet a) {
         // By default, just beep
         Toolkit.getDefaultToolkit().beep();
         // Method to create default model
         protected Document createDefaultModel() {
         return new NumericPlainDocument();
         // Test code
         public static void main(String[] args) {
         try {
         UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
         } catch (Exception evt) {}
         DecimalFormat format = new DecimalFormat("#,###.###");
         format.setGroupingUsed(true);
         format.setGroupingSize(3);
         format.setParseIntegerOnly(false);
         JFrame f = new JFrame("Numeric Text Field Example");
         final DecimalFormateGen tf = new DecimalFormateGen(10, format);
         tf.setValue((double) 123456.789);
         JLabel lbl = new JLabel("Type a number: ");
         f.getContentPane().add(tf, "East");
         f.getContentPane().add(lbl, "West");
         tf.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
         try {
         tf.normalize();
         Long l = tf.getLongValue();
         System.out.println("Value is (Long)" + l);
         } catch (ParseException e1) {
         try {
         Double d = tf.getDoubleValue();
         System.out.println("Value is (Double)" + d);
         } catch (ParseException e2) {
         System.out.println(e2);
         f.pack();
         f.setVisible(true);
         class NumericPlainDocument extends PlainDocument {
         public NumericPlainDocument() {
         setFormat(null);
         public NumericPlainDocument(DecimalFormat format) {
         setFormat(format);
         public NumericPlainDocument(AbstractDocument.Content content,
         DecimalFormat format) {
         super(content);
         setFormat(format);
         try {
         format
         .parseObject(content.getString(0, content.length()), parsePos);
         } catch (Exception e) {
         throw new IllegalArgumentException(
         "Initial content not a valid number");
         if (parsePos.getIndex() != content.length() - 1) {
         throw new IllegalArgumentException(
         "Initial content not a valid number");
         public void setFormat(DecimalFormat fmt) {
         this.format = fmt != null ? fmt : (DecimalFormat) defaultFormat.clone();
         decimalSeparator = format.getDecimalFormatSymbols()
         .getDecimalSeparator();
         groupingSeparator = format.getDecimalFormatSymbols()
         .getGroupingSeparator();
         positivePrefix = format.getPositivePrefix();
         positivePrefixLen = positivePrefix.length();
         negativePrefix = format.getNegativePrefix();
         negativePrefixLen = negativePrefix.length();
         positiveSuffix = format.getPositiveSuffix();
         positiveSuffixLen = positiveSuffix.length();
         negativeSuffix = format.getNegativeSuffix();
         negativeSuffixLen = negativeSuffix.length();
         public DecimalFormat getFormat() {
         return format;
         public Number getNumberValue() throws ParseException {
         try {
         String content = getText(0, getLength());
         parsePos.setIndex(0);
         Number result = format.parse(content, parsePos);
         if (parsePos.getIndex() != getLength()) {
         throw new ParseException("Not a valid number: " + content, 0);
         return result;
         } catch (BadLocationException e) {
         throw new ParseException("Not a valid number", 0);
         public Long getLongValue() throws ParseException {
         Number result = getNumberValue();
         if ((result instanceof Long) == false) {
         throw new ParseException("Not a valid long", 0);
         return (Long) result;
         public Double getDoubleValue() throws ParseException {
         Number result = getNumberValue();
         if ((result instanceof Long) == false
         && (result instanceof Double) == false) {
         throw new ParseException("Not a valid double", 0);
         if (result instanceof Long) {
         result = new Double(result.doubleValue());
         return (Double) result;
         public void insertString(int offset, String str, AttributeSet a)
         throws BadLocationException {
         if (str == null || str.length() == 0) {
         return;
         Content content = getContent();
         int length = content.length();
         int originalLength = length;
         parsePos.setIndex(0);
         // Create the result of inserting the new data,
         // but ignore the trailing newline
         String targetString = content.getString(0, offset) + str
         + content.getString(offset, length - offset - 1);
         // Parse the input string and check for errors
         do {
         boolean gotPositive = targetString.startsWith(positivePrefix);
         boolean gotNegative = targetString.startsWith(negativePrefix);
         length = targetString.length();
         // If we have a valid prefix, the parse fails if the
         // suffix is not present and the error is reported
         // at index 0. So, we need to add the appropriate
         // suffix if it is not present at this point.
         if (gotPositive == true || gotNegative == true) {
         String suffix;
         int suffixLength;
         int prefixLength;
         if (gotPositive == true && gotNegative == true) {
         // This happens if one is the leading part of
         // the other - e.g. if one is "(" and the other "(("
         if (positivePrefixLen > negativePrefixLen) {
         gotNegative = false;
         } else {
         gotPositive = false;
         if (gotPositive == true) {
         suffix = positiveSuffix;
         suffixLength = positiveSuffixLen;
         prefixLength = positivePrefixLen;
         } else {
         // Must have the negative prefix
         suffix = negativeSuffix;
         suffixLength = negativeSuffixLen;
         prefixLength = negativePrefixLen;
         // If the string consists of the prefix alone,
         // do nothing, or the result won't parse.
         if (length == prefixLength) {
         break;
         // We can't just add the suffix, because part of it
         // may already be there. For example, suppose the
         // negative prefix is "(" and the negative suffix is
         // "$)". If the user has typed "(345$", then it is not
         // correct to add "$)". Instead, only the missing part
         // should be added, in this case ")".
         if (targetString.endsWith(suffix) == false) {
         int i;
         for (i = suffixLength - 1; i > 0; i--) {
         if (targetString
         .regionMatches(length - i, suffix, 0, i)) {
         targetString += suffix.substring(i);
         break;
         if (i == 0) {
         // None of the suffix was present
         targetString += suffix;
         length = targetString.length();
         format.parse(targetString, parsePos);
         int endIndex = parsePos.getIndex();
         if (endIndex == length) {
         break; // Number is acceptable
         // Parse ended early
         // Since incomplete numbers don't always parse, try
         // to work out what went wrong.
         // First check for an incomplete positive prefix
         if (positivePrefixLen > 0 && endIndex < positivePrefixLen
         && length <= positivePrefixLen
         && targetString.regionMatches(0, positivePrefix, 0, length)) {
         break; // Accept for now
         // Next check for an incomplete negative prefix
         if (negativePrefixLen > 0 && endIndex < negativePrefixLen
         && length <= negativePrefixLen
         && targetString.regionMatches(0, negativePrefix, 0, length)) {
         break; // Accept for now
         // Allow a number that ends with the group
         // or decimal separator, if these are in use
         char lastChar = targetString.charAt(originalLength - 1);
         int decimalIndex = targetString.indexOf(decimalSeparator);
         if (format.isGroupingUsed() && lastChar == groupingSeparator
         && decimalIndex == -1) {
         // Allow a "," but only in integer part
         break;
         if (format.isParseIntegerOnly() == false
         && lastChar == decimalSeparator
         && decimalIndex == originalLength - 1) {
         // Allow a ".", but only one
         break;
         // No more corrections to make: must be an error
         if (errorListener != null) {
         errorListener.insertFailed(this, offset, str, a);
         return;
         } while (true == false);
         // Finally, add to the model
         super.insertString(offset, str, a);
         public void addInsertErrorListener(InsertErrorListener l) {
         if (errorListener == null) {
         errorListener = l;
         return;
         throw new IllegalArgumentException(
         "InsertErrorListener already registered");
         public void removeInsertErrorListener(InsertErrorListener l) {
         if (errorListener == l) {
         errorListener = null;
         public interface InsertErrorListener {
         public abstract void insertFailed(NumericPlainDocument doc, int offset,
         String str, AttributeSet a);
         protected InsertErrorListener errorListener;
         protected DecimalFormat format;
         protected char decimalSeparator;
         protected char groupingSeparator;
         protected String positivePrefix;
         protected String negativePrefix;
         protected int positivePrefixLen;
         protected int negativePrefixLen;
         protected String positiveSuffix;
         protected String negativeSuffix;
         protected int positiveSuffixLen;
         protected int negativeSuffixLen;
         protected ParsePosition parsePos = new ParsePosition(0);
         protected static DecimalFormat defaultFormat = new DecimalFormat();
    this is not working as desired pls help me.
    can we use this code and get the desired result or is there any other way to do this.
    it is very urgent for me pls help immediately
    thanks in advance

    Hi camickr
    i learned how to format the code now, and u also responded for my testarea problem , iam very much thankful to u, and now i repeat the same problem what i have with a text field.
    actually i have window with a textfield on it and while end user starts entering data in it , it should be have as follows
    when the user start typing numerics it should accept from right hand side and keep appending value from right hand side.
    first the default value should be as 0.00 and as the user starts entering
    then it is as follows
    for ex
    if i want to enter 123.45
    user starts entering
    1 then it should display as 0.01
    2 then it should display as 0.12
    3 then it should display as 1.23
    4 then it should display as 12.34
    5 then it should display as 123.45
    i hope u will give me quick reply because this is very hard time for me.

  • Float data types

    I don't really know SSAS but have been a .NET programmer and worked with SQL Server and T-SQL for years.  I am working on a project where there is a database storing sales transactions and a cube that is created nightly so we can get MTD Sales, YTD
    Sales, Profit $, etc.
    I just ran into an issue where I got an error retrieving the Profit $ measure (using an MDX query inside of a SQL stored procedure using OPENQUERY) and found that the profit $ should be 0.07 but is coming back as 6.9999999999993179E-2. After talking
    to our DBA, he said all of the calculations in the cube are double precision floating point and I need to round all results to 2 decimal places (programs like Excel handle the rounding and I should too.)
    Our DBA also claims the measures can't be calculated and returned as currency. He claims that the potential for error is very small and no one has ever complained about a $ value being off.
    I am struggling with this answer because I have always been told never to use floating point for monetary values.  I am having a hard time believing there is no way to have a measure be a currency field that is accurate.  I looked for articles
    online but can't seem to find anything to answer my questions.
    Could someone please point me in the right direction? Thanks so much!

    Your DBA is not completely correct in his claims. All calculations are not floating point below is a link to all of the data types supported by SSAS (Multi-Dimensional)
    https://technet.microsoft.com/en-us/library/gg471558%28v=sql.110%29.aspx?f=255&MSPPError=-2147217396
    SSAS supports a currency data type. It's 4 decimal places not 2, but it is the recommended data type for currency values as it does not suffer from the imprecision of the double data type.
    The other thing measures in a cube have is the concept of a format string, so you can ask the cube to return a pre-formatted value to you. But default an OPENQUERY will just return the raw value, but if you add the following:
    CELL PROPERTIES FORMATTED_VALUE
    to the end of your MDX query that should tell it to return the formatted value (which could be something like "$#,##0.00")
    See here https://msdn.microsoft.com/en-us/library/ms146084.aspx for a list of all the different format masks that can be applied
    http://darren.gosbell.com - please mark correct answers

  • Help! Exception when trying to use Float

    Hi. I'm about to lose my mind trying to fix this exception:
    SubsampleAverage - Parameter value's class (java.lang.Float) is not an instance of the parameter class (java.lang.Double) for parameter "scaleX".It's being thrown by this code,
    public BufferedImage resizeImage(InputStream inputStream)
        BufferedImage resizedImage = null;
        try {
          SeekableStream stream = SeekableStream.wrapInputStream(inputStream, true);
          RenderedOp newImage = JAI.create("stream",stream);
          ((OpImage)newImage.getRendering()).setTileCache(null);
          float scale = targetWidth / newImage.getWidth();
          ParameterBlock pb = new ParameterBlock();
          pb.addSource(newImage);
          pb.add(scale);
          pb.add(scale);
          RenderingHints qualityHints =
            new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
          resizedImage = (JAI.create("SubsampleAverage",pb,qualityHints)).getAsBufferedImage();
        catch (Exception e)
          this.error = e.getMessage();
        return resizedImage;
      }

    I suspect scale should be a double then.

Maybe you are looking for

  • Please answer these questions?

    hello sir. 1.Types of Joins in sap-abap? 2.What is the typical structure of an ABAP program? 3.Can you create a table with fields not referring to data elements? 4.What is an interactive report? What is the obvious diff of such report compared with c

  • Trouble Whitelisting E-mail Server IP

    In the hopes of attracting Verizon problem-solvers, I'm posting here as a Verizon customer and owner of a small business.  I own my own business domain, but my e-mail server is owned by a parent company and all outgoing e-mail goes through that compa

  • Internal And External Documents

    what are the internal and external documents of SAP MM

  • How to browse the directories on deployed war-files?

    Ciao! When I deploy a war-file on tomcat I can browse the directories e.g. I would like to see all the files in the jsp folder. Is it possible to get this under weblogic? Thanks and Nice greetings! Ciao

  • How do I register my ProCare?

    I am a newbie and purchased my new Macbook Pro in the middle of Decemeber. I live a couple hours away from the store. I also purchased the procare. I want to make an appointment but it keeps asking for my email or phone number. I don't remember every