Could somebody help me regarding Jbottons,please

i wanna add two bottons in my programe so that if i press botton 'save' it should execute the following method (given below)and if i press botton 'Cancel' the programe should remove all the Text(from Jfield).right now i have to press"enter"in order to execute this method.i have already set the Jbottons on my GridBagWindow but i don't know how to make them work.
somebody please help me.
private class TextFieldHandler implements ActionListener {
public void actionPerformed( ActionEvent e )
String s = Email.getText();
if ( e.getSource() == Email){
if(s.endsWith("."))
s="Email address cannot end with a dot";//+e.getActionCommand();
else if(s.startsWith("@"))
s="The Email address cannot start with @";//+e.getActionCommand();
else if(s.indexOf('.')-s.indexOf('@')==1)
s="Dot and @ cannot be consecitive charecter";//+e.getActionCommand();
else if(s.indexOf('@')-s.indexOf('.')==1)
s="Dot and @ cannot be consecitive charecter";//+e.getActionCommand();
else if(s.indexOf(' ')>0)
s="There has to be no space between any of two Email charecter";//+e.getActionCommand();
else
s="your Email address has been saved";//+e.getActionCommand();
JOptionPane.showMessageDialog( null, s );
}

You just posted the same question less than 20 minutes ago.

Similar Messages

  • Please could somebody help me I have an iMac which came with Tiger 10.4.10 installed I have lost my disks and I need to re-install after a hard drive failure. Where can I find this? I will upgrade to Snow Leopard after but I cannot go straight to SL

    Please could somebody help me I have an iMac which came with Tiger 10.4.10 installed I have lost my disks and I need to re-install after a hard drive failure. Where can I find this? I will upgrade to Snow Leopard after but I cannot go straight to SL

    You can go strait to SL, all you need is a retail SL DVD available from Apple for $20. The US online store has them at:
    http://store.apple.com/us/product/MC573Z/A/mac-os-x-106-snow-leopard

  • Hi could somebody help

    Its me again with that loading problem.
    Thanks for all the respond.Even after all the help I got from some of you, I couldn't figure-out what the problem is. I am still stuck with the below given issue, because of this I am unable to step further. Please help.
    <u>Issue</u>:
    I am trying to Load a Masterdata(flatfile) in a infoobject.
    This is what i did:
    I created a infoobject name 'EMPNAM' with some attributes, like [soc_sec, 0city,0country].
    I created and activated communication struct , and Transfer struct.
    Created my own flatfile(.csv) with some fake datas.
    created infopackage and loaded the flatfile, system generated as loading successful. I checked the datas in PSA and i was able to see all the fields ['EMPNAM, soc_sec, 0city,0country] been loaded.
    When i try to see the loaded data in the datatarget i.e the infoobject, i could only see the 'EMPNAM' been loaded, not the attributes[soc_sec,0city,0country].
    Why is that, could anyone help me with this please.

    Hello Ranjani naga,
    How r u ?
    Just check the data in Transaction - SE11
    In the Option "Table" enter "/BIC/PEMPNAM" and "Display"
    Press CTRLSHIFTF10 or Contents icon
    Then Execute.
    Could u see the data there ?
    Best Regards....
    Sankar Kumar
    +91 98403 47141

  • I am trying to buy mitril for hobbit kom but it always gives me error i have already added my card information to store but i cant buy it.Could u help me about it ,please?

    I am trying to buy mitril for hobbit kom but it always gives me error i have already added my card information to store but i cant buy it.Could u help me about it ,please?

    Wish I could help. My wife is having the same problem.  Same computer for 2 years and all of a suddent it thinks this is her first purchase.

  • I BOUGHT LIGHTROOM 5 IN LAREDO TX AND I TRIED TO GET IN MONTERREY MEXICO THE SERIAL NUMBER WITH THE REDEMPTION CODE BUT APPEARS AN ERROR. MY PC IS WINDOWS 8. COULD SOMEBODY HELP ME?

    I BOUGHT LIGHTROOM 5 IN BEST BUY LAREDO TX AND I TRIED TO GET IN MONTERREY MEXICO THE SERIAL NUMER WITH THE REDEMPTION CODE FROM THE BOX, BUT APPEARS AN ERROR. MY PC IS WINDOWS 8, COULD SOMEBODY HELP ME??

    I don't know that you can purchase Adobe software in the US for installing and using outside of the US.
    Redemption Code Help
    http://helpx.adobe.com/x-productkb/global/redemption-code-help.html
    Serial number and activation chat support (non-CC)
    http://helpx.adobe.com/x-productkb/global/service1.html ( http://adobe.ly/1aYjbSC )

  • HT4463 I bought the OS Moutain Lion three weeks ago, but I can't download it. The site does not responde. Could somebody help me?

    I bought the OS Moutain Lion three weeks ago, but I can't download it. The site does not responde. Could somebody help me?

    Turn off the Firewall in System Preferences > Security & Privacy > Firewall
    Disable anti virus software.
    Make sure your Mac meets Mountain Lion requirements > Apple - Upgrade your Mac to OS X Mountain Lion.

  • Can somebody help me regarding my iphone battery its not charging..please help me..thank you

    Can somebody help?what do i need to do if my iphone is not charging using the USB and other adaptor..please help me...

    if it's not charging both using usb and ac then likely it have a broken connector or defect battery
    if it works on the ac charger then you need to get itunes working on the computer as that seem to be required for a computer to charge an ios device

  • Could somebody help please, my albums are all split in to individual tracks in my library how can i merge in to one album. many thanks

    could sombody help please, my albums in my library are split in to individual tracks how can i merge them in to one album. many thanks

    This web page can help you figure it out: http://samsoft.org.uk/iTunes/grouping.asp

  • Can somebody help me regarding BAM(business activity monitoring tool)

    hi,
    can somebody tell me regarding BAM.
    thanks

    Hello Subhasis,
    Please use the following link to know about BAM
    http://www.sap.com/platform/netweaver/pdf/BWP_Business_Activity_Monitoring.pdf
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/800e2826-718c-2a10-f680-d6b29f0dce18
    Hope the above links are helpful
    Regards,
    Satish.

  • I cannot get Firefox to my page today, could you help. Regards J

    Hello,
    When I tried to use Firefox today, I cannot get acess to it, I have a
    lot of information there including Favorites etc,.
    Could you please help.
    Regards,
    James.

    Rename or delete formhistory.sqlite (plus formhistory.sqlite-journal and formhistory.sqlite.corrupt and formhistory.dat, if they exist) in the [http://kb.mozillazine.org/Profile_folder_-_Firefox Profile Folder] in case there is a problem with the file that stores the "Saved Form" data.
    This will remove all saved form data, so you may want to rename formhistory.sqlite to formhistory.sqlite.sav or move the file to another folder in case you need to recover some saved data.

  •   Could somebody help in "how to Connect to database" 

    I'm trying to connect to database and there's a messege appearing tells " ORA-12154: TNS: could not resolve service name", so please if does anybody know how to solve this problem to send me a solution on my email address ( [email protected])........... Thanks

    What client you are using to connect to the database??
    If you are using the database's own client that the above solution works.
    If you are using forms then you must set the tnsnames.ora of the forms that you are using, and not the database's.
    Forms6: %ORACLE_HOME%/Net80/ADMIN/tnsnames.ora
    Forms9 and above: %ORACLE_HOME%/NETWORK/ADMIN/tnsnames.ora
    Or for both cases you can use the net Configuration Assistance provided by Oracle which is a GUI interface of defining TNS Names.
    Regards,
    Tony Garabedian

  • Could somebody help me improve my program

    Hi i have created a program that calculates specific properties of a scanned image and uses them to create a better image cropped and angled appropriatley.
    But i am having a few problems and would like to improve it. Sometimes the code will crop the image and cut out text or not angle the image properly.
    Most of the time it works but i want to improve it so that it will work with any image.
    Could somebody possibly look at my code and see if they can see any improvements that can be made. I would really appreciate it.
    My program consists of 4 java files and 2 .bat files. I cannot use attachments on here so if u are interested in looking at the code leave a reply and i could send u the files.
    Thank you
    Mark

    Here is the PageProcess.java file. There are two versions in this piece of code one has been commented out. I haven't taken out all my comments in my code so if u do not like the comments just say and i'll take them out
    import java.awt.* ;
    import java.awt.image.* ;
    import java.awt.image.renderable.* ;
    import java.io.* ;
    import java.text.* ;
    import java.util.* ;
    import javax.media.jai.* ;
    import com.sun.media.jai.codec.* ;
    import rgg.util.* ;
    public class PageProcess
        private static String pageName ;
        private static boolean printPartial ;
        private static PrintWriter lout ;
        private static RenderedOp image1 ;
        private static BufferedImage image1a ;
        private static int imageWidth, imageHeight ;
        private static int leftEdge, cropWidth, topEdge, cropHeight, textEdge ;
        private static float scaleFactor ;
        private static PrintWriter pout1 ;
        private static String outDirectory, outDirectory1 ;
        private static int noOfRows ;
        private static IntegerQuad[] rows = new IntegerQuad[100] ;
        private static int noOfGlossRows ;
        private static IntegerQuad[] glossRows = new IntegerQuad[100] ;
        public static void main(String[] args) throws Exception
         // read in command line parameters
         String pages = "" ;
         outDirectory = "" ;
         outDirectory1 = "" ;
         String logFile = "" ;
         printPartial = false ;
         String imageDirectory = "" ;
         for (int i = 0 ; i < args.length ; i++)
             if (args.equals("-p"))
              i++ ;
              pages = args[i] ;
         else if (args[i].equals("-o"))
              i++ ;
              outDirectory = args[i].replace('=', ' ') ;
         else if (args[i].equals("-o1"))
              i++ ;
              outDirectory1 = args[i].replace('=', ' ') ;
         else if (args[i].equals("-l"))
              i++ ;
              logFile = args[i] ;
         else if (args[i].equals("-partial"))
              printPartial = true ;
         else if (args[i].equals("-f"))
              i++ ;
              imageDirectory = args[i].replace('=', ' ') ;
         else
              System.err.println("invalid command line parameter " + args[i]) ;
              System.exit(1) ;
    if (outDirectory.length() == 0)
         System.err.println("no output directory specified") ;
         System.exit(1) ;
    if (outDirectory1.length() == 0)
         System.err.println("no supplementary output directory specified") ;
         System.exit(1) ;
         lout = null ;
         if (logFile.length() != 0)
         String name = outDirectory1 + File.separator + logFile + ".txt" ;
         File file = new File(name) ;
         if (file.exists())
              System.err.println("log file '" + name + "' exists") ;
              System.exit(1) ;
         lout = new PrintWriter(new FileWriter(name)) ;
         String firstPage, lastPage ;
         if (pages.length() != 0)
         firstPage = pages ;
         lastPage = pages ;
         int offset = pages.indexOf('-') ;
         if (offset != -1)
         firstPage = pages.substring(0,offset) ;
         lastPage = pages.substring(offset + 1) ;
         if (lastPage.length() < firstPage.length())
              String prefix = firstPage.substring(0,
                             firstPage.length() - lastPage.length()) ;
              lastPage = prefix + lastPage ;
         else
         BufferedReader iin = new BufferedReader(new InputStreamReader(System.in)) ;
         System.err.print("first page? ") ;
         firstPage = iin.readLine().trim() ;
         System.err.print("last page? ") ;
         lastPage = iin.readLine().trim() ;
         if (lastPage.length() == 0)
              lastPage = firstPage ;
         message("first page = " + firstPage + "; last page = " + lastPage) ;
         pageName = "" ;
         String nextPageName = firstPage ;
         while (true)
         if (pageName.equals(lastPage))
              break ;
         pageName = nextPageName ;
         nextPageName = getNextPage(pageName) ;
         message("") ;
         message("Page: " + pageName) ;
         int ii = 0 ;
         while (Character.isDigit(pageName.charAt(ii)))
         ii++ ;
         int pageNumber = Integer.parseInt(pageName.substring(ii + 1)) ;
         boolean leftPage = (pageNumber % 2 == 0) ;
         // process the image
         IntegerPair temp = getPageImage(imageDirectory, pageName) ;
         int mx = temp.int1 ;
         int my = temp.int2 ;
         setCroppingWidth(mx) ;
         setCroppingHeight(my) ;
         pout1 = new PrintWriter(new FileWriter(outDirectory1 + File.separator +
                        pageName + "coordinates.txt")) ;
         pout1.println("Image = " + pageName) ;
         pout1.println() ;
         pout1.println("(" + leftEdge + ", " + topEdge + ", " + cropWidth +
              ", " + cropHeight + ")") ;
         pout1.println() ;
         double angleRadians = getTextAngle(my) ;
         if (Math.abs(angleRadians) > 0.001)
              rotateImage(angleRadians) ;
              String newImageName = outDirectory + File.separator + pageName + "a.tif" ;
              JAI.create("filestore", image1, newImageName, "tiff", null) ;
              message("created file " + newImageName) ;
         textEdge = setTextEdge(leftPage) ;
         splitTextArea(leftPage) ;
         splitGlossArea(leftPage) ;
         cropScaleOutputImage() ;
         image1 = null ;
         image1a = null ;
         System.gc() ;
         } // end of main method
    private static int getColour(int x, int y)
         int c = image1a.getRGB(x, y) ;
         int blue = c & 0377 ;
         int green = (c & 0177400) >> 8 ;
         int red = (c & 077600000) >> 16 ;
         int temp = (red + green + blue) / 3 ;
         if (temp > 200)
         return 255 ;
         else
         return 0 ;
         // return (red + green + blue) / 3 ;
         } // end of method getColour
    private static int getUpColour(int x, int y)
         if ((getColour(x, y) == 255) || (getColour(x, y - 1) == 255))
         return 255 ;
         else
         return 0 ;
         } // end of method getUpColour
    private static int getDownColour(int x, int y)
         if ((getColour(x, y) == 255) || (getColour(x, y + 1) == 255))
         return 255 ;
         else
         return 0 ;
         } // end of method getDownColour
    private static int getColumnColour(int top, int bottom, int x)
         int sum = 0 ;
         for (int y = top ; y < bottom ; y++)
         sum += getColour(x, y) ;
         return sum / (bottom - top) ;
         } // end of method getColumnColour
    private static int getRowColour(int left, int right, int y)
         int sum = 0 ;
         for (int x = left ; x < right ; x++)
         sum += getColour(x, y) ;
         return sum / (right - left) ;
         } // end of method getRowColour
    public static void message(String m)
         System.err.println(m) ;
         if (lout != null)
         lout.println(m) ;
         } // end of method message
    private static String getNextPage(String f)
         int ii = f.length() - 1 ;
         while ((ii >= 0) && (Character.isDigit(f.charAt(ii))))
         ii-- ;
         String restOfName = f.substring(0, ii + 1) ;
         int num1 = Integer.parseInt(f.substring(ii + 1)) ;
         int length = f.length() - ii - 1 ;
         String num2 = Integer.toString(num1 + 1) ;
         while (num2.length() < length)
         num2 = "0" + num2 ;
         return restOfName + num2 ;
         } // end of method getNextPage
    private static IntegerPair getPageImage(String directory, String pageName)
                             throws IOException
    String fileName = directory + File.separator + pageName + ".tif" ;
         FileSeekableStream stream = null ;
         try {
         stream = new FileSeekableStream(fileName) ;
         catch (IOException ex)
         message(fileName + " not found") ;
         System.exit(-1) ;
         message("reading image " + pageName) ;
         image1 = JAI.create("stream", stream) ;
    imageWidth = image1.getWidth() ;
    imageHeight = image1.getHeight() ;
         message("width = " + imageWidth + " height = " + imageHeight) ;
         image1a = image1.getAsBufferedImage() ;
         // work out the colour scheme, and a start point in the background
         int cx = imageWidth / 2 ;
         int cy = imageHeight / 2 ;
         int foreColour = 300 ;
    int backColour = -1 ;
         int mx = -1,
         my = -1 ;
         int search_length = 100 ;
         for (int i = 0 ; i < search_length ; i++)
         int colour = getColour(cx, cy) ;
         if (colour > backColour)
              backColour = colour ;
              mx = cx ;
              my = cy ;
         if (colour < foreColour)
              foreColour = colour ;
         cx++ ;
         cy++ ;
         if (printPartial)
         message("background colour is " + backColour +
                   "; foreground colour is " + foreColour) ;
         message("new white centre point is (" + mx + ", " + my + ")") ;
         // display the central pixels
         if (printPartial)
         int display_size = 70 ;
         for (int i = 0 ; i < display_size ; i++)
         for (int j = 0 ; j < display_size ; j++)
              // int c = getColour(mx - display_size + j, my - display_size + i) ;
              int c = getColour(170 - display_size + j, my - display_size + i) ;
              if (c > 200)
              c = 0 ;
              else
              c = 1 ;
              System.err.print(c) ;
         System.err.println() ;
         return new IntegerPair(mx, my) ;
         } // end of method getPageImage
    private static void setCroppingWidth(int mx)
         int[] firstMode = new int[imageWidth + 1] ;
         int[] secondMode = new int[imageWidth + 1] ;
         for (int i = 0 ; i <= imageWidth ; i++)
         firstMode[i] = 0 ;
         secondMode[i] = 0 ;
         int minimum_width = (int) (0.67 * imageWidth) ;
         for (int i = 0 ; i < imageHeight ; i++)
         int mx1 = mx ;
         while ((mx1 > 0) && (getColour(mx1, i) > 200))
              mx1-- ;
         int mx2 = mx ;
         while ((mx2 < imageWidth) && (getColour(mx2, i) > 200))
         mx2++ ;
         if ((mx2 - mx1) > minimum_width)
              firstMode[mx1]++ ;
              secondMode[mx2]++ ;
         int maxMode = -1,
         posMode = -1 ;
         for (int i = 3 ; i < imageWidth - 3 ; i++)     // omit max width
         int s = firstMode[i-3] + firstMode[i-2] + firstMode[i-1] +
              firstMode[i] + firstMode[i+1] + firstMode[i+2] +
              firstMode[i+3] ;
         if (maxMode < s)
              maxMode = s ;
              posMode = i ;
         int maxMode1 = -1,
         posMode1 = -1 ;
         for (int i = 3 ; i < imageWidth - 3 ; i++)     // omit max width
         int s = secondMode[i-3] + secondMode[i-2] + secondMode[i-1] +
              secondMode[i] + secondMode[i+1] + secondMode[i+2] +
              secondMode[i+3] ;
         if (maxMode1 < s)
              maxMode1 = s ;
              posMode1 = i ;
         message("proposed left/right edges at (" + posMode +
                                  ", " + posMode1 + ")") ;
         int crop_horiz_clearance = 10 ;
         leftEdge = posMode + crop_horiz_clearance ;
         cropWidth = posMode1 - leftEdge - 2 * crop_horiz_clearance ;
    private static void setCroppingHeight(int my) throws IOException
         // PrintWriter pout2 = new PrintWriter(new FileWriter(outDirectory1 +
         //               File.separator + "xxx.txt")) ;
         int[] firstMode = new int[imageHeight + 1] ;
         int[] secondMode = new int[imageHeight + 1] ;
         for (int i = 0 ; i <= imageHeight ; i++)
         firstMode[i] = 0 ;
         secondMode[i] = 0 ;
         int minimum_height = (int) (0.67 * imageHeight) ;
         int band_width = 300 ;
         for (int i = 0 ; i < band_width ; i++)
         int my1 = my ;
         while ((my1 > 0) && (getUpColour(i, my1) > 200))
              my1-- ;
         int my2 = my ;
         while ((my2 < imageHeight) && (getDownColour(i, my2) > 200))
         my2++ ;
         // pout2.println(i + " " + my1 + " " + my2) ;
         /* if ((my2 - my1) > minimum_height)
              firstMode[my1]++ ;
              secondMode[my2]++ ;
         // pout2.println(i + " " + my1 + " " + my2) ;
         if (my1 < 300)
              firstMode[my1]++ ;
         if (my2 > 1200)
              secondMode[my2]++ ;
         int ii1 = imageWidth - band_width + i ;
         my1 = my ;
         while ((my1 > 0) && (getUpColour(ii1, my1) > 200))
              my1-- ;
         my2 = my ;
         while ((my2 < imageHeight) && (getDownColour(ii1, my2) > 200))
              my2++ ;
         // pout2.println(ii1 + " " + my1 + " " + my2) ;
         /* if ((my2 - my1) > minimum_height)
              firstMode[my1]++ ;
              secondMode[my2]++ ;
         // pout2.println(ii1 + " " + my1 + " " + my2) ;
         if (my1 < 300)
              firstMode[my1]++ ;
         if (my2 > 1200)
              secondMode[my2]++ ;
         int maxMode = -1,
         posMode = -1 ;
         for (int i = 3 ; i < imageHeight - 3 ; i++)     // omit max height
         int s = firstMode[i-3] + firstMode[i-2] + firstMode[i-1] +
              firstMode[i] + firstMode[i+1] + firstMode[i+2] +
              firstMode[i+3] ;
         if (maxMode < s)
              maxMode = s ;
              posMode = i ;
         int maxMode1 = -1,
         posMode1 = -1 ;
         for (int i = 3 ; i < imageHeight - 3 ; i++)     // omit max height
         int s = secondMode[i-3] + secondMode[i-2] + secondMode[i-1] +
              secondMode[i] + secondMode[i+1] + secondMode[i+2] +
              secondMode[i+3] ;
         if (maxMode1 < s)
              maxMode1 = s ;
              posMode1 = i ;
         message("proposed top/bottom edges at (" + posMode +
                        ", " + posMode1 + ")") ;
         int crop_vert_clearance = 10 ;
         topEdge = posMode + crop_vert_clearance ;
         cropHeight = posMode1 - topEdge - 2 * crop_vert_clearance ;
         // pout2.close() ;
         } // end of method getCroppingHeight
    private static double getTextAngle(int my) throws IOException
         // PrintWriter pout2 = new PrintWriter(new FileWriter(outDirectory1 +
         //               File.separator + "xxx.txt")) ;
    // VERSION I
         /* int profileSearchLength = 200 ;
         int[] section1 = new int[cropWidth] ;
         for (int i = 0 ; i < cropWidth ; i++)
         int j = 0 ;
         while ((j < profileSearchLength) &&
              ((getColour(leftEdge + i, my - j) > 230)) ||
              (getColour(leftEdge + i + 1, my - j) > 230)))
              j++ ;
         section1[i] = j ;
         // pout2.println(i + " " + j) ;
         int[] section2 = new int[profileSearchLength + 1] ;
         for (int i = 0 ; i <= profileSearchLength ; i++)
         section2[i] = 0 ;
         for (int i = 0 ; i < cropWidth ; i++)
         section2[section1[i]]++ ;
         int maxLine = -1,
         posLine = -1 ;
         for (int i = 0 ; i < profileSearchLength ; i++) // note - omit largest offset
         if (maxLine < section2[i])
              maxLine = section2[i] ;
              posLine = i ;
         message("maximum is " + section2[posLine] + " at " + posLine) ;
         int xSum = 0, ySum = 0, count = 0 ;
         int text_clearance = 10 ;
         for (int i = 0 ; i < cropWidth ; i++)
         if ((section1[i] > posLine - text_clearance) &&
         (section1[i] < posLine + text_clearance))
    //     if (section1[i] < (profileSearchLength / 3))
              xSum += i ;
              ySum += section1[i] ;
              count++ ;
         double xBar = ((double) xSum) / count,
         yBar = ((double) ySum) / count ;
         message("xBar = " + xBar + " yBar = " + yBar) ;
         double numerator = 0.0,
         denominator = 0.0 ;
         for (int i = 0 ; i < cropWidth ; i++)
         if ((section1[i] > posLine - text_clearance) &&
         (section1[i] < posLine + text_clearance))
    //     if (section1[i] < (profileSearchLength / 3))
              numerator += (i - xBar) * (section1[i] - yBar) ;
              denominator += (i - xBar) * (i - xBar) ;
         double slope = numerator / denominator ;
         message("slope is " + slope) ;
         double angleRadians = Math.atan(slope) ;
    // double x = 10.0 ;
    // angleRadians = x / 180.0 * Math.PI ;
    // this proves that positive angles cause rotation clockwise 4/July/00
         double angleDegrees = angleRadians / Math.PI * 180 ;
         message("angle is " + angleDegrees + " degrees") ;
         // pout2.close() ;
         return angleRadians ; */
    // COALFACE
    // VERSION II
    // get profile of left-hand side of text
         int[] section1 = new int[cropHeight] ;
         for (int i = 0 ; i < cropHeight ; i++)
         int mx1 = 40 ;
         while ((mx1 <= cropWidth) &&
              ((getColour(leftEdge + mx1, topEdge + i) > 200) ||
              (getColour(leftEdge + mx1 + 1, topEdge + i) > 200)))
              mx1++ ;
         section1[i] = mx1 ;
         // pout2.println(i + " " + mx1) ;
    // find most frequent text offset
         int[] section2 = new int[imageWidth + 1] ;
         for (int i = 0 ; i <= imageWidth ; i++)
         section2[i] = 0 ;
         for (int i = 0 ; i < cropHeight ; i++)
         if (section1[i] < (cropWidth / 2))
         section2[section1[i]]++ ;
         int maxLine = -1,
         posLine = -1 ;
         for (int i = 1 ; i < imageWidth ; i++)
         if (maxLine < section2[i])
              maxLine = section2[i] ;
              posLine = i ;
         // pout2.println("maximum is " + section2[posLine] + " at " + posLine) ;
    // fit line ot profile (cf "Teach Yourself Statistics" pp102-4)
         int xSum = 0, ySum = 0, count = 0 ;
         int text_clearance = 20 ;
         for (int i = 0 ; i < cropHeight ; i++)
         if ((section1[i] > posLine - text_clearance) &&
         (section1[i] < posLine + text_clearance))
              xSum += i ;
              ySum += section1[i] ;
              count++ ;
         double xBar = ((double) xSum) / count,
         yBar = ((double) ySum) / count ;
         // pout2.println("xBar = " + xBar + " yBar = " + yBar) ;
         double numerator = 0.0,
         denominator = 0.0 ;
         for (int i = 0 ; i < cropHeight ; i++)
         if ((section1[i] > posLine - text_clearance) &&
         (section1[i] < posLine + text_clearance))
              numerator += (i - xBar) * (section1[i] - yBar) ;
              denominator += (i - xBar) * (i - xBar) ;
         double slope = numerator / denominator ;
         // pout2.println("slope is " + slope) ;
         double angleRadians = Math.atan(slope) ;
         message("angle is " + (angleRadians / Math.PI * 180) + " degrees") ;
    int x1 = (int) Math.round(yBar + leftEdge) ;
    int x2 = (int) Math.round(xBar + topEdge) ;
    double xxx = yBar - (slope * xBar) + leftEdge ;
    int x3 = (int) Math.round(xxx) ;
    int x4 = (int) Math.round(xxx + (slope * cropHeight)) ;
         pout1.println("(" + x1 + ", " + x2 + ", " + x3 + ", " + x4 + ")") ;
         pout1.println() ;
         // pout2.close() ;
         return angleRadians ;
         } // end of method getTextAngle
    private static void rotateImage(double angleRadians)
         float cx1 = ((float) imageWidth) / 2 ;
         float cy1 = ((float) imageHeight) / 2 ;
         float angle = (float) angleRadians ;
         ParameterBlock pb = new ParameterBlock() ;
    pb.addSource(image1);
         pb.add(cx1) ;
         pb.add(cy1) ;
         pb.add(angle) ;
         pb.add(new InterpolationBilinear()) ;
         RenderedOp image2 = JAI.create("Rotate", pb, null) ;
         message("angle rotated is " + angle) ;
         image1 = null ;
         image1a = null ;
         System.gc() ;
         image1 = image2 ;
    image1a = image1.getAsBufferedImage() ;
         } // end of method rotateImage
    private static int setTextEdge(boolean leftPage)
         int[] firstMode = new int[imageWidth + 1] ;
         for (int i = 0 ; i <= imageWidth ; i++)
         firstMode[i] = 0 ;
         for (int i = 0 ; i < cropHeight ; i++)
         int mx1 = 0 ;
         if (leftPage)
         while ((mx1 <cropWidth) &&
              (getColour(leftEdge + mx1, topEdge + i) > 200))
              mx1++ ;
         else
         while ((mx1 <cropWidth) &&
              (getColour(leftEdge + cropWidth - mx1, topEdge + i) > 200))
              mx1++ ;
         if (mx1 < (cropWidth / 2))
              firstMode[mx1]++ ;
         int maxMode = -1,
         posMode = -1 ;
         for (int i = 0 ; i < imageWidth ; i++)
         if (maxMode < firstMode[i])
              maxMode = firstMode[i] ;
              posMode = i ;
         posMode -= 2 ;
         if (leftPage)
         message("left edge of text is at " + (leftEdge + posMode)) ;
         return leftEdge + posMode ;
         else
         message("right edge of text is at " + (leftEdge + cropWidth - posMode)) ;
         return leftEdge + cropWidth - posMode ;
         } // end of method setTextEdge
    private static void splitTextArea(boolean leftPage) throws IOException
         int left = 0,
         right = 0 ;
         if (leftPage)
         left = textEdge ;
         right = leftEdge + cropWidth ;
         else
         left = leftEdge ;
         right = textEdge ;
         int rowWidth = right - left ;
         // int backcolour1 = 253 ;
         int backcolour1 = 245,
         max_light_lines = 4,
         max_dark_lines = 8,
         lightLineCounter = 0,
         darkLineCounter = 0 ;
         boolean inLightZone = true,
              inTextZone = false ;
         int lastY = topEdge,
         descender_space = 3 ;
         // PrintWriter pout2 = new PrintWriter(new FileWriter(outDirectory1 +
         //                    File.separator + "xxx.txt")) ;
         noOfRows = 0 ;
         int clearance = 40 ;
         for (int i = topEdge + clearance ; i < topEdge + cropHeight - clearance ; i++)
         int colour = getRowColour(left, right, i) ;
         // pout2.println(i + ", " + colour) ;
    if (colour >= backcolour1)
              lightLineCounter++ ;
              darkLineCounter-- ;
         else
              darkLineCounter++ ;
              lightLineCounter-- ;
         if (lightLineCounter > max_light_lines)
         lightLineCounter = max_light_lines ;
         if (lightLineCounter < 0)
         lightLineCounter = 0 ;
         if (darkLineCounter > max_dark_lines)
         darkLineCounter = max_dark_lines ;
         if (darkLineCounter < 0)
         darkLineCounter = 0 ;
         if ((lightLineCounter == max_light_lines) && (inTextZone))
              inLightZone = true ;
              inTextZone = false ;
              int line = noOfRows + 1 ;
              int rowHeight = i + descender_space - lastY ;
              // message("(" + left + ", " + lastY + ", " + rowWidth + ", " +
              //               rowHeight + ")") ;
              pout1.println("(" + left + ", " + lastY + ", " + rowWidth +
                             ", " + rowHeight + ")") ;
              rows[noOfRows] = new IntegerQuad(left, lastY, rowWidth, rowHeight) ;
              noOfRows++ ;
              lastY = i + descender_space ;
         else if ((darkLineCounter == max_dark_lines) && (inLightZone))
              inLightZone = false ;
              inTextZone = true ;
         // pout2.close() ;
         message("no of lines = " + noOfRows) ;
         pout1.println("No of Lines = " + noOfRows) ;
         pout1.println() ;
         } // end of method splitTextArea
    private static void splitGlossArea(boolean leftPage)
         int left = 0,
         right = 0 ;
         if (leftPage)
         left = leftEdge ;
         right = textEdge ;
         else
         left = textEdge ;
         right = leftEdge + cropWidth ;
         int rowWidth = right - left ;
         if (rowWidth == 0)
         message("WARNING: no gloss area found") ;
         noOfGlossRows = 0 ;
         return ;
         // int backcolour1 = 253,
         int backcolour1 = 245,
         max_light_lines = 20,
         max_dark_lines = 10,
         lightLineCounter = 0,
         darkLineCounter = 0 ;
         boolean inLightZone = true,
              inTextZone = false ;
         int lastY = topEdge,
         descender_space = 17,
         ascender_space = 20 ;
         noOfGlossRows = 0 ;
         int clearance = 40 ;
         for (int i = topEdge + clearance ; i < topEdge + cropHeight - clearance ; i++)
         int colour = getRowColour(left, right, i) ;
         if (colour >= backcolour1)
         lightLineCounter++ ;
         darkLineCounter-- ;
         else
              darkLineCounter++ ;
              lightLineCounter-- ;
         if (lightLineCounter > max_light_lines)
         lightLineCounter = max_light_lines ;
         if (lightLineCounter < 0)
         lightLineCounter = 0 ;
         if (darkLineCounter > max_dark_lines)
         darkLineCounter = max_dark_lines ;
         if (darkLineCounter < 0)
         darkLineCounter = 0 ;
         if ((lightLineCounter == max_light_lines) && (inTextZone))
         inLightZone = true ;
              inTextZone = false ;
              int line = noOfGlossRows + 1 ;
              int rowHeight = i + descender_space - lastY ;
              // message("(" + left + ", " + lastY + ", " + rowWidth + ", " +
              //          rowHeight + ")") ;
              pout1.println("(" + left + ", " + lastY + ", " + rowWidth +
                        ", " + rowHeight + ")") ;
              glossRows[noOfGlossRows] = new IntegerQuad(left, lastY, rowWidth,
                        rowHeight) ;
              noOfGlossRows++ ;
         lastY = i + descender_space ;
         else if ((darkLineCounter == max_dark_lines) && (inLightZone))
              inLightZone = false ;
              inTextZone = true ;
              // this overrides other values of lastY,
              //      to eliminate gloss whitespace
              lastY = i - max_dark_lines - ascender_space ;
         message("no of glosses = " + noOfGlossRows) ;
         pout1.println("No of Glosses = " + noOfGlossRows) ;
    pout1.close() ;
    } // end of method splitGlossArea
    private static void cropScaleOutputImage() throws IOException
         /* image1a = null ;
         System.gc() ; */
         // crop the image
         float fx = leftEdge, fy = topEdge, fw = cropWidth, fh = cropHeight ;
         ParameterBlock pb = new ParameterBlock();
    pb.addSource(image1);
    pb.add(fx);
    pb.add(fy);
    pb.add(fw);
    pb.add(fh);
         RenderedOp image2 = JAI.create("Crop", pb, null);
         // scale the image
         int newPageWidth = 600 ;
         scaleFactor = ((float) newPageWidth) / cropWidth ;
    pb = new ParameterBlock();
    pb.addSource(image2);
    pb.add(scaleFactor);
    pb.add(scaleFactor);
    pb.add(0.0f);
    pb.add(0.0f);
         // pb.add(new InterpolationNearest()) ;
         pb.add(new InterpolationBilinear()) ;
         RenderedOp image3 = JAI.create("Scale", pb, null) ;
         if (printPartial)
         message("scale factor is " + scaleFactor) ;
         image2 = null ;
         // output the image
         String newImageName = outDirectory + File.separator + pageName + "s.jpg" ;
         JAI.create("filestore", image3, newImageName, "jpeg", null) ;
         message("created file " + newImageName) ;
         image3 = null ;
         // revise coordinates, etc
         /* pout1 = new PrintWriter(new FileWriter(outDirectory1 + File.separator +
                             pageName + "scoordinates.txt")) ;
         pout1.println("Image = " + pageName) ;
         pout1.println() ;
         pout1.println("(0, 0, " + cropWidth + ", " + cropHeight + ")") ;
         pout1.println() ;
         for (int i = 0 ; i < noOfRows ; i++)
         IntegerQuad temp = rows[i] ;
         int x = (int) (scaleFactor * (temp.int1 - leftEdge)) ;
         int y = (int) (scaleFactor * (temp.int2 - topEdge)) ;
         int w = (int) (scaleFactor * temp.int3) ;
         int h = (int) (scaleFactor * temp.int4) ;
         pout1.println("(" + x + ", " + y + ", " + w + ", " + h + ")") ;
         rows[i] = new IntegerQuad(x, y, w, h) ;
         pout1.println("No of Lines = " + noOfRows) ;
         pout1.println() ;
         for (int i = 0 ; i < noOfGlossRows ; i++)
         IntegerQuad temp = glossRows[i] ;
         int x = (int) (scaleFactor * (temp.int1 - leftEdge)) ;
         int y = (int) (scaleFactor * (temp.int2 - topEdge)) ;
         int w = (int) (scaleFactor * temp.int3) ;
         int h = (int) (scaleFactor * temp.int4) ;
         pout1.println("(" + x + ", " + y + ", " + w + ", " + h + ")") ;
         glossRows[i] = new IntegerQuad(x, y, w, h) ;
         pout1.println("No of Glosses = " + noOfGlossRows) ;
    pout1.close() ; */
         } // end of method cropAndScaleImage
    } // end of class PageProcess
    Here is the ViewPage.java file
    import java.awt.* ;
    import java.awt.event.* ;
    import java.awt.image.* ;
    import java.awt.image.renderable.* ;
    import java.io.* ;
    import java.util.* ;
    import javax.media.jai.* ;
    import com.sun.media.jai.codec.* ;
    public class ViewPage extends Frame implements WindowListener, ActionListener
        // picture elements
        private Label label ;
        private ScrollPane scroll ;
        private ViewPageCanvas canvas ;
        private Button quit ;
        Image image ;
        int imageWidth, imageHeight ;
        boolean scaledImage, displayLines ;
        int cropX ;
        int cropY  ;
        int cropWidth ;
        int cropHeight ;
        int noOfLines ;
        int[] lineX = new int[100] ;
        int[] lineY = new int[100] ;
        int[] lineWidth = new int[100] ;
        int[] lineHeight = new int[100] ;
        int noOfGlosses ;
        int[] glossX = new int[100] ;
        int[] glossY = new int[100] ;
        int[] glossWidth = new int[100] ;
        int[] glossHeight = new int[100] ;
    //COALFACE
        int x1, x2, x3, x4 ;
         * main                                        *
        public static void main(String[] args) throws IOException
         boolean scaleDown = false ;
         String imageName = "" ;
         String coordsName = "" ;
         for (int i = 0 ; i < args.length ; i++)
             if (args.equalsIgnoreCase("-scale"))
              scaleDown = true ;
         else if (imageName.length() == 0)
              imageName = args[i] ;
         else if (coordsName.length() == 0)
              coordsName = args[i] ;
         else
              System.err.println("java ViewPage imageName coordsName -scale") ;
              System.exit(1) ;
         if (imageName.length() == 0)
         System.err.println("java ViewPage imageName coordsName -scale") ;
         System.exit(1) ;
    ViewPage f = new ViewPage(imageName, coordsName, scaleDown) ;
    f.setVisible(true) ;
    } // end of method main
    * ViewPage                                        *
    private ViewPage(String imageName, String coords, boolean scaleDown) throws IOException
         scaledImage = scaleDown ;
         displayLines = (coords.length() != 0) ;
         FileSeekableStream stream = null ;
         try {
         stream = new FileSeekableStream(imageName) ;
         catch (IOException ex)
         System.err.println("ERROR: cannot open image file " + imageName) ;
         System.err.println("reading image " + imageName) ;
         RenderedOp image0 = JAI.create("stream", stream) ;
    imageWidth = image0.getWidth() ;
    imageHeight = image0.getHeight() ;
         System.err.println("width = " + imageWidth + " height = " + imageHeight) ;
         image = image0.getAsBufferedImage() ;
         int new_page_width = 600 ;
         double scaleFactor = 1.0 ;
         if (scaleDown)
         image = image.getScaledInstance(new_page_width, -1, Image.SCALE_DEFAULT) ;
         scaleFactor = ((double) new_page_width) / imageWidth ;
         imageWidth = new_page_width ;
         imageHeight = (int) (scaleFactor * imageHeight) ;
         System.err.println("image scaled: scale factor = " + scaleFactor) ;
         if (displayLines)
         BufferedReader fin1 = new BufferedReader(new FileReader(coords)) ;
         String line = fin1.readLine() ;
         line = fin1.readLine() ;
         line = fin1.readLine() ;
         StringTokenizer st = new StringTokenizer(line, "(, )") ;
         cropX = Integer.parseInt(st.nextToken()) ;
         cropY = Integer.parseInt(st.nextToken()) ;
         cropWidth = Integer.parseInt(st.nextToken()) ;
         cropHeight = Integer.parseInt(st.nextToken()) ;
         line = fin1.readLine() ;
         line = fin1.readLine() ;
    //COALFACE
         st = new StringTokenizer(line, "(, )") ;
         x1 = Integer.parseInt(st.nextToken()) ;
         x2 = Integer.parseInt(st.nextToken()) ;
         x3 = Integer.parseInt(st.nextToken()) ;
         x4 = Integer.parseInt(st.nextToken()) ;
    System.err.println(x1 + " " + x2 + " " + x3 + " " + x4) ;
         line = fin1.readLine() ;
         int j = 0 ;
         while (true)
              line = fin1.readLine() ;
              if (line.startsWith("No of Lines"))
              break ;
              st = new StringTokenizer(line

  • Hi, my name is Chenet i have a Macbook 0sx lion 10.7.5 i don't remember my password for the system preferences i can't even go online, can somebody help me with that please

    Hi, my name is Chenet i have a Macbook 0sx lion 10.7.5 i don't remember my password for the system preferences i can't even go online, can somebody help me with that please

    Hi 'baltwo'
    Thank you for your link, I already had been on this particular website this afternoon. they only discuss problems in the application and nothing about how the MS Office application installation does disturb Mac OS.
    Or have I missed a special comment there?
    In any case many thanks, trioloGo

  • Could you help me regarding the planning layout in excel please ???

    Dear All,
    Could you kindly help me to solve my case please .. ? :).
    I tried to change the template of excel planning layout using this program: UPP_MASTER_CHECKIN.
    I tried to modify the template by inserting some logo picture there.
    I put the picture in the left-top corner,
    but after i run the program, the logo picture position cover/above the planning data.
    My questions is:
    1. Could we setup in what row we're going to start the planning data ?? So it the planning data will not be covered by Logo ..
    e.g.
    Before:
    Planning data is written in row 1 and column 1.
    Could i modify the planning data to be written in row 6 and column 1.
    Regards,
    Niel..

    Hi Neil,
    you must insert row between logo and data region. Furthermore you must set image properties to not change its dimension.
    Best Regards

  • Please could somebody help? Aperture will not open - has a coloured spinning disc prior to opening the program correctly. I have the latest Snow Leopard  update on a Mini Mac. I have "successfully installed" the latest Aperture 3.1.2 update.

    I am running the latest OS version and uploaded the latest version of Aperture 3.1.2 all successfully installed. I have all my photos (say 12000 files) stored on a RAID WD (MyBook) external hard-drive and I assume that that has the latest software update Wd 2.25. I have previously had problems with Aperture's external referencing - which drops out frustratingly, I was in the middle of a major import of photos when the spinning rainbow ball appeared. I am now unable to open Aperture.
    I have tried rebooting to no change.
    Help please?

    Colin-
    Thanks for the detailed info. One additional question, how full is each hard drive? The internal and external drives' % full.
    Step one is to change the import workflow. Even though lots of manuals inappropriately lead folks in that direction, one should never import directly into Aperture or any other images management app. Instead, in this exact order:
    • Restart the Mini (to clear possible memory leaks of the limiting 2-GB of RAM).
    • Create a folder ("abc") for the incoming images. Since you are on a Mini you will want to be referencing Masters with the Library on the Mini's hard drive and the Masters on your external RAID array. The abc folder should be created on the RAID.
    • Connect a card reader with the camera card in it. The camera card should show on the desktop. If it does not show, restart the Mini with the reader and card still plugged in. You can of course use the camera directly in this step, but I do not recommend it. Obviously cameras like the iPad do require direct camera-to-computer uploading.
    • Drag the contents of the card's image folder(s) to the abc folder that you previously created on the hard drive.
    • Review the abc folder contents to be sure they all copied properly.
    • Software-eject the camera card.
    • Physically disconnect the camera card reader from the Mini. This step is important to help avoid all-too-common human error.
    • Again review the abc folder contents to be sure they are indeed all there (because stuff happens sometimes...).
    • Back up the abc folder contents on to another drive.
    • Review the files on the backup to be sure they all copied properly.
    • At any time after but not before the previous step you can reformat the camera card in-camera. Do not delete images on the card using the computer.
    • Start Aperture and only have Aperture running (due to your limited 2 GB RAM).
    • Import the images from folder abc into Aperture, selecting "Store Files: In their current location" on the right-hand side of the import window.
    Some generic advice I posted in another thread:
    Aperture is a heavy pro graphics app that is very demanding of hardware. Your Mac's CPU, GPU, i/o and RAM are all limiting to Aperture so we need to do what we can to optimize. Some steps:
    • Set Previews to only be built manually, and only tell Aperture to build Previews when you are not otherwise editing in Aperture. I suggest setting the size of Previews to be the pixel dimensions of your display.
    • Keep the internal drive underfilled for speed, which sooner or later usually requires using a Referenced-Masters-Library with Masters on external drives. Back up originals before importing into Aperture or any other images app.
    • The Aperture Library should be on an internal drive.
    • Turn off Share Previews with iLife and iWork.
    • Remember that HDs slow as they fill and keep the internal drive underfilled. Approx. 70% full _maximum_ is a good guideline.
    • If page outs increase significantly during operation, max out RAM and/or try to run Aperture by itself. On my C2D MBP with its max of 3 GB RAM I always did a restart prior to a heavy Aperture session to clear any memory leaks and make sure no other apps were open. Browsers in particular will often suck RAM Aperture would otherwise be using.
    IMO all Aperture users who can should routinely bump RAM to at least 8 GB.
    • Some users have observed that it can take a new Aperture installation time (weeks) to stabilize on slow computers. So do not panic; and allow Aperture to continue background work by not fully shutting down the computer.
    HTH
    -Allen Wicks

Maybe you are looking for

  • External Hard Drive Trouble

    I use macs all the time and I have a lacie external drive that has done me proud, but I just enrolled in an editing course that teached Avid editing on a....PC... I can't reformat my existing drive so I need a new one. I'm looking for something small

  • Concatenate multiple tables into one table

    Dear all, I am doing migration between two database structures, that's why I need also to know if we want to concatenate the data in tables A,B and C into one table in the destination schema, what is the strategy to do this knowing that I have a lot

  • Does anyone know where to find printer profiles for Epson paper with MG6200 printer using Lightroom?

    Does anyone know where to find printer profiles for Epson paper with MG6200 printer for use in LightRoom5?

  • From Where Can I download

    Hi All,     i want to work RFC-XI real-time scenario but i don't know the exact path in sdn.sap.com. can you tell me exact path please. Regards, Selva.

  • IPhoto '11: Eventnames in originals

    All of our photo's are in iPhoto but I like to make a back-up just to be shure. When opening the library from the finder I always used to see the names of the events in the originals file. We switched to iPhoto '11 a couple of months ago and the name