Rotation of String using JDK1.2

I need to rotate a string in an applet. I am able to do that using AffineTransform Class found in(java.awt.geom.AffineTransform) but the problem is that its not visible in Browser.
Can u give me the other alternative for this.
Its Urgent.

Use a browser that supports java correctly ;-)
Installing the Java Plugin wil fix it. Using Opera with Java might help.
But i guess you want to place the applet on a website and cannot order users to use specific sofware. Take a look at the Java API documentation to see since when the functions you use are in the API. You are using an up to date api but that doesn't go for browsers.
But i wouldn't be able to tell you what each browser supports and what not.
But I do have some vague memmories of java.awt.geom.AffineTransform wich does 2D transformations and is standard api and an AffineTransform in the Java3D api, wich is an extension and unlikly to be supported by browsers.
So find out what you are using an what browsers support...

Similar Messages

  • Can anyone help me to add method to rotate the image using mouse?

    Hi everyone, i am currently creating a game which require the user to be able to drag and rotate the image
    on the screen..but sadly...i'm only able to do the dragging part..
    Can anyone be able to help me add the method to rotate the image using the mouse?
    Thanks :-)
    the code
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.awt.geom.*;
    class Game extends JFrame {
         DisplayCanvas canvas;
         public Game() {
              super("My Game");
              Container container = getContentPane();
              canvas = new DisplayCanvas();
              TitledBorder border = new TitledBorder("Game Window");
              border.setTitlePosition(TitledBorder.BOTTOM);
              canvas.setBorder(border);
              container.add(canvas);
              addWindowListener(new WindowEventHandler());
              setSize(450,400);
              show();
              class WindowEventHandler extends WindowAdapter {
                   public void windowClosing(WindowEvent e) {
                        System.exit(0);
              public static void main(String arg[]) {
                   new Example();
         class DisplayCanvas extends JPanel {
              int x, y;
              BufferedImage bi;
              DisplayCanvas() {
                   setBackground(Color.white);
                   setSize(450,400);
                   addMouseMotionListener(new MouseMotionHandler());
                   Image image = getToolkit().getImage("duke.gif");
                   MediaTracker mt = new MediaTracker(this);
                   mt.addImage(image, 1);
                   try {
                        mt.waitForAll();
                   catch (Exception e) {
                        System.out.println("Exception while loading image.");
                   if (image.getWidth(this) == -1) {
                        System.out.println("***Make sure you have the image "
                        + "(duke.gif) file in the same directory.*****");
                        System.exit(0);
                   bi = new BufferedImage(image.getWidth(this),
                   image.getHeight(this),
                   BufferedImage.TYPE_INT_ARGB);
                   Graphics2D big =bi.createGraphics();
                   big.drawImage(image, 0, 0, this);
              public void paintComponent(Graphics g) {
                   super.paintComponent(g);
                   Graphics2D g2D = (Graphics2D) g;
                   g2D.drawImage(bi, x, y, this);
              class MouseMotionHandler extends MouseMotionAdapter {
                   public void mouseDragged(MouseEvent e) {
                        x = e.getX(); y = e.getY();
                        repaint();

    research a bit on AffineTransforms. you can set the rotated instance of the Graphics2D class and it will do the rotations for you :-D

  • Rotating with Mouse using 2D

    Hello,
    I have a shape created using GeneralPath and have hot-points once the user selects the Shape.I would like to add a feature which allows user to rotate the shape using/clicking&dragging the MOUSE.Can anyone please tell me how can I derive the angle between the shape center and mouse dragged position?Any sample code doing this.???
    thanks

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class Rotation {
      public static void main(String[] args) {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(new RotationPanel(200,100,100));
        f.setSize(400,300);
        f.setLocation(300,400);
        f.setVisible(true);
    class RotationPanel extends JPanel {
      int cx, cy, size;
      double radians;
      Shape polygon;
      Area area, tabArea;
      int deltaX, deltaY;
      int shapeIndex = -1;
      boolean
        okToRotate = false,
        showTab = false;
      public RotationPanel(int cx, int cy, int size) {
        this.cx = cx;
        this.cy = cy;
        this.size = size;
        radians = 0;
        setBackground(Color.white);
        addMouseListener(new SelectionListener());
        addMouseMotionListener(new RotateListener());
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
        int R = (int)(size / (4 * Math.cos(Math.PI/5) * Math.sin(Math.PI/5)));
        int[] x = new int[5];
        int[] y = new int[5];
        for(int i = 0; i < 5; i++) {
          x[i] = cx + (int)(R * Math.sin(radians*Math.PI/5));
          y[i] = cy - (int)(R * Math.cos(radians*Math.PI/5));
          radians += 2;
        polygon = new Polygon(x, y, 5);
        area = new Area((Shape)polygon);
        g2.setPaint(Color.blue);
        g2.draw(polygon);
        if(showTab) {
          int xR = cx + (int)(1.4 * R * Math.sin(radians*Math.PI/5));
          int yR = cy - (int)(1.4 * R * Math.cos(radians*Math.PI/5));
          //g2.draw(new Line2D.Double(cx, cy, xR, yR));
          int r = (int)(R * Math.cos(Math.PI/5));
          int xr = cx + (int)(1.4 * r * Math.sin((radians + 1)*Math.PI/5));
          int yr = cy - (int)(1.4 * r * Math.cos((radians + 1)*Math.PI/5));
          //g2.draw(new Line2D.Double(cx, cy, xr, yr));
          int[] xTab = new int[4];
          int[] yTab = new int[4];
          xTab[0] = x[0];
          xTab[1] = xR;
          xTab[2] = xr;
          xTab[3] = cx + (int)(r * Math.sin((radians + 1)*Math.PI/5));
          yTab[0] = y[0];
          yTab[1] = yR;
          yTab[2] = yr;
          yTab[3] = cy - (int)(r * Math.cos((radians + 1)*Math.PI/5));
          Polygon tabPolygon = new Polygon(xTab, yTab, 4);
          tabArea = new Area(tabPolygon);
          g2.setPaint(Color.red);
          g2.fill(tabPolygon);
      class SelectionListener extends MouseAdapter {
        public void mousePressed(MouseEvent e) {
          int x = e.getX();
          int y = e.getY();
          if(area.contains(x,y)) {
            deltaX = (cx - x);
            deltaY = (cy - y);
            shapeIndex = 1;
          if(showTab && tabArea.contains(x,y))
            okToRotate = true;
          else
            okToRotate = false;
        public void mouseReleased(MouseEvent e) {
          shapeIndex = -1;
          okToRotate = false;
        public void mouseClicked(MouseEvent e) {
          if(area.contains(e.getX(), e.getY()))
            showTab = true;
          else
            showTab = false;
          repaint();
      class RotateListener extends MouseMotionAdapter {
        public void mouseDragged(MouseEvent e) {
          int x = e.getX();
          int y = e.getY();
          if(shapeIndex > 0) {
            cx = x + deltaX;
            cy = y + deltaY;
          if(okToRotate) {
            int px = cx - x;
            int py = cy - y;
            int phi = (int)(Math.acos(py/Math.sqrt(px*px + py*py))*180);
            if(x < cx)
              phi *= -1;
            radians = phi * Math.PI/180;     
          repaint();
    }

  • Need Help in Splitting a String Using SQL QUERY

    Hi,
    I need help in splitting a string using a SQL Query:
    String IS:
    AFTER PAINT.ACOUSTICAL.1..9'' MEMBRAIN'I would like to seperate this string into multiple lines using the delimeter .(dot)
    Sample Output should look like:
    SNO       STRING
    1            AFTER PAINT
    2            ACOUSTICAL
    3            1
    4            
    5            9" MEMBRAIN
    {code}
    FYI i am using Oracle 9.2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    There's this as well:
    with x as ( --generating sample data:
               select 'AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN' str from dual union all
               select 'BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN' str from dual)
    select str,
           row_number() over (partition by str order by rownum) s_no,
           cast(dbms_xmlgen.convert(t.column_value.extract('//text()').getstringval(),1) as varchar2(100)) res
    from x,
         table(xmlsequence(xmltype('<x><x>' || replace(str,'.','</x><x>') || '</x></x>').extract('//x/*'))) t;
    STR                                                S_NO RES                                                                                                
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 1 AFTER PAINT                                                                                        
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 2 ACOUSTICAL                                                                                         
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 3 1                                                                                                  
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 4                                                                                                    
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 5 9" MEMBRAIN                                                                                        
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          1 BEFORE PAINT                                                                                       
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          2 ELECTRIC                                                                                           
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          3 2                                                                                                  
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          4                                                                                                    
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          5 45 caliber MEMBRAIN      
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Multi-language support for user-specified text strings used in the forms

    multi-language support for user-specified text strings used in the forms
    Instead of creating multiple forms, 1 in each different language, for the same service, is there any workaround?

    Hoan - is your question what are the considerations when creating multiligual catalogs? If so, I can tell you that at other clients I have seen them use a single catalog for one or two languages. For the two langugages, such as Spanish/English, you can create a single catalog with both of them. Once you get to more than two languages, the catalog would get unweildy and is therefore not suggested.

  • How to measure the rotational speed by using rotary encoder and 1 counter?

    I want to measure the rotational speed of a shaft, and I have below hardware:
    1, a rotary encoder, with A,B,Z signals output;
    2, PCI-E6363 card.
    I do konw how to use such a  encoder to measure the rotational angle by using the function "DAQmxCreateCIAngEncoderChan", but this time I need to measure the speed(rpm), as well as the dirction of the speed, which means a negative speed represent a CCW rotate direction.
    More detail informations:
    for the encoder, the A,B signal is 600ppr, and Z signal is 1ppr
    the rotatinal speed is in range: -300 ~ 5000 rpm.
    some one suggested me that I can use the "DAQmxCreateCIAngEncoderChan" task to measure the angle firstly and then do the differential analysis with the angle. but I have to enable the Z index function, and it's hard to calculate when the shaft speed is fast then 2500rpm.
    Anyone can help me on this issue?
    Thanks in advance!

    RobertoBozzolo:
    Thansk for your reply. You are right that measure frequency to get the speed is the best way, but it's hard to get the dirction at the same time. You suggest me that "perform two angle measurements to get the sense of rotation", but I'm not sure I catched what you mean about this. I try to understand your opinion like this: distribute the signals to 2 counters, and start 2 tasks, one for frequency, the other for angle which used for deciding the dirction?
    And by the way, in my application, the counter is limited:
    I'm using PCI-E6363, which have 4 counters totally, and I have to measure 4 different speed sensors at the same time, so that means only 1 counter for me to measure the speed and the dirction.
    RobertoBozzolo 已写:
    To measure the speed from the encoder you can simply follow some of the frequency measurement examples that ship with DAQmx, considering that speed (rpm) is given by frequency (Hz) on one encoder output / 600 (ppr) * 60 (s->min)  = frequency / 10.
    Difficult is to add a sign to this measurement: frequency measurement gives you no information about sense of rotation, so I suppose you could perform two angle measurements to get the sense of rotation and then get the speed as above.

  • Is there any way to use JDK1.4PreferenceAPI in JWS + Applet clients

    Dear Friends,
    Actually, we are in process of reusing the J2sdk1.4 new utilities like (Preferences API ) in all the applications means Application client, Java WebStart
    Client , Applet client. As for as Application client is concern , we do not have any problem at all, Its because of, J2sdk1.4 Preferences API provides an
    option to Plugin our Implementation for reading and writing User Preference Information.
    But Incase of JWS client or Applet client , we can not Plug in our own Preference Factory Implementation , because of some security concern. We came
    to know that it is possible via setting system property -D option and signing the Jar which uses this Preference API class. But it will create more problem
    for our client while using our application . So we need to use JDK1.4 Preference with out using above two methodology.
    Is there any possible solution which can help me to use the JDK1.4 Preference API in all the clients????.
    Please do help me as early as possible. This is very very important for us.
    Thanks in advance
    with regards,
    Pitchaimani

    Dear Sir,
    Thanks for your immediate reply, I had solved the problem by putting both the classes in a single signed jar. Now i am get into the new Problem. The problem is, even if i set the SystemProperty for Preference Factory, it doesn't take effect at all.
    Actually what happened was, while starting the
    Browser(Netscape or IE), browser will try to load all the Java classes (which includes InputMethodManager class also). This InputMethodManager class create an Object for Preference Node and use the same for getting the Preference values. In this case if i invoke My Application(Applet) from the browser, and set the System Property (For Preference Factory), it won't take effect at all. Suppose if i use Preference.userRoot() in my application, it will try to look the Java Preference Object and return the same which is not a desired one. So i would like to know, is there any mechanism to set/reset the Preference Factory (for my Application alone)???
    Please help me to get out of this problem. It is very very important for me.
    Your help is highly appreciated
    Thanks & Regards,
    Pitchaimani

  • How can i encrypt an ddecrypt a string using java

    hai,
    can anybody know how to encrypt and decrypt a string using java..
    please if anybody help me with a small example and with code
    thanks
    ravi chandra

    hi,
    of course there are better ways to crypt your code, but the following 2 functions do their job....
    as far as i know java has an own api for crypting stuff.
    private String GetEncryptedString(String aCryptedString)
    String result = "";
    String str = aCryptedString;
    int[] asciiArray = new int[str.length()];
    for(int i = 0; i < asciiArray.length; i++)
    asciiArray[i] = (int)str.charAt(i);
    char tempChar = (char)(asciiArray[i]+3);
    result = result+tempChar;
    return result;
    private String GetDecryptedString(String aString)
    String result = "";
    String str = aString;
    int[] asciiArray = new int[str.length()];
    for(int i = 0; i < asciiArray.length; i++)
    asciiArray[i] = (int)str.charAt(i);
    char tempChar = (char)(asciiArray[i]-3);
    result = result+tempChar;
    return result;
    andi

  • Problem in display Of Chinese in UI using jdk1.4

    I have resource bundles files present in escape sequence format(\u6ce2), and I am able to see Chinese charecters appearing in UI when I am using jdk 1.6.
    But my client is using jdk1.4, so for that I have replaced font.properties file in jre/lib with the contents of font.properties.zh but still I am not able to see Chinese charecters in UI.
    Please guide me.
    Regards,
    kalyani...

    You might want to post this question to the l18n forum:
    http://forum.java.sun.com/forum.jspa?forumID=16

  • Invalid column name in query string - using Format function

    In my post just before this one the problem was solved for writing a query string using a date range. The rest of the query string includes the same date field (Call_Date) but formatted as 'MMM-YY'. I get an invalid column name error when I add this field to the query string. Here is the rest of the query string:
    strSql = "SELECT Format(CALL_DATE,'mmm-yy'), " _
    & "HOME_REGION FROM CCC2.CASE_EPRP " _
    & "WHERE (HOME_REGION = 'NCR') AND " _
    "(CALL_DATE >= to_date( '1/1/2002', 'MM/DD/YYYY' )" _
    & "AND CALL_DATE <= to_date( '2/28/2003', 'MM/DD/YYYY' ))"
    In the Access Query tool I can include this field
    Format(CALL_DATE,'mmm-yy')
    and the query runs fine (I just need to make it dynamic using ADO). But in my ADO query string above, I get the invalid column name error. Is there a way I can include
    Format(CALL_DATE,'mmm-yy')
    in my ADO query string? I appologize for not being more familiar with Oracle Sql. Any help greatly appreciated.
    Thanks again,
    Rich

    Thank you very much for your reply. I think I'm getting closer to the solution. Just I got an error message
    "date format not recognized"
    when I add "to_char( call_date, 'mmm-yy' )" to the query string. I tried using all uppercase, but that did not make a difference. Do I need to use to_date inside the to_char maybe?
    to_char(to_date(call_date, 'mmm/yy'), 'mmm-yy')
    Thanks again for your help.
    Rich

  • How To Color a Text string using Regex (java.util.regex)

    Hello,
    How can I color a text string using regex class in 1.4?

    Yes, did you notice it said something about incredibly vague functionality?
    Let me break it down for you
    > How can I color a text string
    Strings do not have color... You can color a component (a label, a button), but you can't color a string
    > using regex class in 1.4?
    Using a regular expression? How would a regular exression color anything? Do you have embedded color codes? Are you searhing a string for some secret word?
    What are you talking about?

  • Problem in parsing a xml string using dom parser

    i want to parse a Xml String using a Dom parser......the parse function in dom parser takes only input stream as argument.......so i made the code as
    InputStream inputstream = new StringBufferInputStream(XmlData) ;
    InputSource inputSource = new InputSource(inputstream );
    but saxexception is coming and also warning called
    "java.io.StringBufferInputStream in java.io has been deprecated"
    please help me.........

    i want to parse a Xml String using a Dom
    parser......the parse function in dom parser takes
    only input stream as argument.......This is not true of the DOM parser in Java 1.4. So you might want to get rid of your old parser and replace it by something more current. Or perhaps you are using 1.4 and you just didn't read all of the API docs.

  • How to split a string using IndexOf?

    How would you split a string using indexOf and not using the .split method?
    Any help is appreciated :D
    Message was edited by:
    billiejoe

    would it be better to use the first or the second?
    int      indexOf(int ch)
    Returns the index within this string of the first occurrence of the specified character.
    int      indexOf(int ch, int fromIndex)
    Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
    I think the second would be helpful. so how do i read it?

  • How to search for upper/lower case using string using JAVA!!!?

    -I am trying to write a program that will examine each letter in the string and count how many time the upper-case letter 'E' appears, and how many times the lower-case letter 'e' appears.
    -I also have to use a JOptionPane.showMessageDialog() to tell the user how many upper and lower case e's were in the string.
    -This will be repeated until the user types the word "Stop". 
    please help if you can
    what i have so far:
    [code]
    public class Project0 {
    public static void main(String[] args) {
      String[] uppercase = {'E'};
      String[] lowercase = {'e'};
      String isOrIsNot, inputWord;
      while (true) {
       // This line asks the user for input by popping out a single window
       // with text input
       inputWord = JOptionPane.showInputDialog(null, "Please enter a sentence");
       if ( inputWord.equals("stop") )
        System.exit(0);
       // if the inputWord is contained within uppercase or
       // lowercase return true
       if (wordIsThere(inputWord, lowercase))
        isOrIsNot = "Number of lower case e's: ";
       if (wordIsThere(inputword, uppercase))
         isOrIsNot = "number of upper case e's: ";
       // Output to a JOptionPane window whether the word is on the list or not
       JOptionPane.showMessageDialog(null, "The word " + inputWord + " " + isOrIsNot + " on the list.");
    } //main
    public static boolean wordIsThere(String findMe, String[] theList) {
      for (int i=0; i<theList.length; ++i) {
       if (findMe.equals(theList[i])) return true;
      return false;
    } // wordIsThere
    } // class Lab4Program1
    [/code]

    So what is your question? Do you get any errors? If so, post them. What doesn't work?
    And crossposted: how to search for upper/lower case using string using JAVA!!!?

  • Application developed using JDK1.2.2 not working with JRE1.3

    I am supporting and application developed using JDK1.2.2, it uses JDBC drivers from oracle(classes12.zip) to connect to an Oracle 8i database. This application is not working with JRE1.3. Can someone suggest any possible methods to make it work with JRE1.3?
    Thanks in advance,
    Anoop.

    well, Now the problem is partly solved. I was having problems in displaying a frame(derived from JInternalFrame), later I discovered that for JRE1.3, I have to explicitly set the setVisible option to true.
    I have a few more frames to correct. I hope after that it wil be alright..
    Thanks for the quick response.
    Anoop.

Maybe you are looking for