Rotate text using java 1.1

Hi...i need to rotate text using only java 1.1...no Affine Transformations.
Does anyone ever had to do this?
Please give some ideas.
Thanks.

Hrm. You could always create an extension of Label's paint that provides the super method with a Graphics object and then, in your implementation, paint the rotation yourself...

Similar Messages

  • Difficulty Rotating Text w/ Java 1.4

    I've used the following code to rotate a line of text successfully
    using Java 1.3. However, when I run the same code under 1.4, the
    text is not rotated. Anyone have any idea why, and some suggestions
    for a successful workaround?
    Thanks in advance!
    Jeff
    import javax.swing.JFrame;
    import java.awt.Container;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.geom.AffineTransform;
    import java.awt.font.FontRenderContext;
    import java.awt.font.TextLayout;
    import java.awt.Font;
    import javax.swing.JPanel;
    public class AffineTransformTest extends JPanel
    public void paintComponent(Graphics g)
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D)g;
    AffineTransform af = new AffineTransform();
    af.setToRotation(Math.PI/2);
    FontRenderContext renderContext = new FontRenderContext(af, false, false);
    TextLayout layout = new TextLayout("This text should be rotated 90 degrees from horizontal." , g2d.getFont(), renderContext);
    layout.draw(g2d, 100, 50);
    public static void main(String [] args)
    AffineTransformTest app = new AffineTransformTest();
    JFrame frame = new JFrame("Affine Transform Test");
    frame.getContentPane().add(app);
    frame.setSize(300,400);
    frame.setVisible(true);
    }

    Apply both a translation and rotation transform to g2d, leaving the RenderContext transform null and the drawing coordinates 0,0.    public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2d = (Graphics2D) g;
            AffineTransform af = new AffineTransform();
            af.translate(100.,50.);
            af.rotate(Math.PI / 2);
            FontRenderContext renderContext = new FontRenderContext(null, false, false);
            g2d.transform(af);
            TextLayout layout =
                new TextLayout(
                    "This text should be rotated 90 degrees from horizontal.",
                    g2d.getFont(),
                    renderContext);
            layout.draw(g2d, 0, 0);
        }Note that you can create the FontRenderContext outside of paintComponent since it never changes.

  • Replacing Element with text using Java iwth XPath

    Hi
    I have to relpace elements which are with name <Link>,with
    string <?abc id='10' city='xxx' ?>
    <root>
    <title>Dummy title</title>
    <content type='html'>
    <Link id='100,101'/> Dummy <a href='www.google.com'>content</a> that the <a href='www.yahoo.com'>cross</a> linking tool will manipulate
    </content>
    <content type='html'>
    <Link id='200,201'/> Dummy <a href='www.google.com'>content</a> that the <a href='www.yahoo.com'>cross</a> linking tool will manipulate
    </content>
    <content type='html'>
    <Link id='300,301'/> Dummy <a href='www.google.com'>content</a> that the <a href='www.yahoo.com'>cross</a> linking tool will manipulate
    </content>
    <removed>500</removed_ids>
    </root>expected out put is file is
    code]<root>
    <title>Dummy title</title>
    <content type='html'>
    <?abc id='100,101' city='xxx' ?>Dummy content that the cross linking tool will manipulate
    </content>
    <content type='html'>
    <?abc id='200,201' city='xxx' ?>Dummy content that the cross linking tool will manipulate
    </content>
    <content type='html'>
    <?abc id='300,310' city='xxx' ?> Dummy content that the cross linking tool will manipulate
    </content>
    <removed>500</removed_ids>
    </root>
    java code is
    DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document document = builder.parse(new File("C:\\LinkProcess.xml"));
        XPath xpath = XPathFactory.newInstance().newXPath();
        String expression = "//Link";
        NodeList  nodelist = (NodeList) xpath.evaluate(expression, document, XPathConstants.NODESET);
        for(int i=0;i<nodelist.getLength();i++){
        Element element = (Element)nodelist.item(i);
        String id = element.getAttribute("id");
        System.out.println("id = "+id);
        Text text = document.createTextNode("<?dctm id ='100'?>");
        document.insertBefore(text,element);
        System.out.println("remove is success");
        }document.insertBefore(text,element); statement throwing exception as
    org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.
    and i would like to remove element named <removed>
    can you help in this
    Thanks & Regards
    vittal

    1. This element makes your XML document malformed:<removed>500</removed_ids>The name of the start tag and the closing tag must always be identical.
    http://www.w3.org/TR/REC-xml/#sec-starttags
    2. The type of the nodes with which you would like to replace your <Link> elements is called "ProcessingInstruction". Processing instructions are to be handled somewhat differently from elements.
    3. The string "><?dctm id ='100'?>" is misspelled. Additionally, it is meant to be a processing instruction so it should not be created as a text node.
    4. You use a node list to replace elements by means of a loop. A loop is only useful when there is a system to the data to be processed, which is not the case with your processing instructions:<?abc id='100,101' city='xxx'?>
    <?abc id='200,201' city='xxx'?>
    <?abc id='300,310' city='xxx'?>From the fact that you use a loop, I presume that the third node is meant to be <?abc id='300,301' city='xxx' ?>. If so, you can use this code:DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    Document document = builder.parse(new File("C:\\LinkProcess.xml"));
    XPath xpath = XPathFactory.newInstance().newXPath();
    String expression = "//Link";
    NodeList  nodelist = (NodeList) xpath.evaluate(expression, document, XPathConstants.NODESET);
    float n;
    String piData;
    ProcessingInstruction pi;
    for(int i=0;i<nodelist.getLength();i++){
      Element element = (Element)nodelist.item(i);
      n = (i+1)*100+((i+1)*100+1)/1000F;
      piData = "id='" + n + "' city='xxx'";
      pi = document.createProcessingInstruction("abc", piData);
      element.getParentNode().replaceChild(pi, element);
      System.out.println("Element <Link...> has been replaced with <?abc " + piData + "?>");
    }This code is not ideal, but I hope is easy to understand and you will be able to change it to suit your needs.
    5. To remove an element use the removeChild() method of the Node interface. If your XML document contains "ignorable" white spaces, it's best to use an XPath expression again ("root/removed") to set reference to the node to be removed rather than locate it by position (e.g. using the getLastChild() method).

  • How to convert a HTML files into a text file using Java

    Hi guys...!
    I was wondering if there is a way to convert a HTML file into a text file using java programing language. Likewise I would also like to know if there is a way to convert any type of file (excel, power point, and word) into text using java.
    By the way, I really appreciated the help that you guys gave me on my previous topic on how to extract tests from a pdf file.
    Thank you....

    HTML files are already text files. What do you mean you want to convert them?
    I think if you search the web, you can find things for converting those MS Office files to text (or extracting text from them, as I assume you mean).

  • How to print "Text" in JAVA(TM)....

    Does anyone know how to print "text" using Java?
    - Here's an example output...
    NOTE: # == 'empty spaces'
    --------------------------- <- Paper
    |###################|
    |####Welcome#########|
    |###################|
    |########to##########|
    |###########JAVA(TM)##|
    |###################|
    |#######Programming####|
    |###################|
    Please post a complete << SAMPLE CODE >> for printing the "text" (Welcome to JAVA(TM) Programming. Including the indentions. So it will not be like this...
    -------------------- <- Paper
    |Welcome |
    |to |
    |JAVA(TM) |
    |Programming |
    | |
    | |
    | |
    | |
    Thanks.

    Please read How To Ask Questions The Smart Way

  • Need help in how to print new line character in unix using java

    Hi All,
    I use the printstream class to print some line in a text using java.
    here is the code:
       FileOutputStream out; // declare a file output object
            PrintStream p; // declare a print stream object
                    p.print("\t");
                    p.print(date);
                    p.print("\t\t");
                    p.print(RecCount);
                    p.println("\n");when i use this and output of this character in windows is
    date RecCount
    22-07-2007 23456
    when i use the same code in unix it shows the following output:
    date RecCount[]22-07-2007
    it wont accept the new line character could any one give me an idea to solve this problem.

    PrintStream has a println() method. Use that. Or System.getProperty("line.separator").
    Because a newline char doesn't necessarily specify a line break. It's system-dependent.

  • Print different format files using java API

    Hi All,
    I need to print documents ( MS-DOC, PDF, Plain Text ) using Java API. I do not need window for configuring number of pages to be print etc etc.. Whatever the file specified should be printed.
    I checked with printerJob.print(); from java API and able to print simple text. I need to approach same for files of different formats.
    Any other API's ? How do i approach?
    Any help will be appreciated.
    Thanks,
    Praveen

    Which of the LiveCycle products are you looking at? (there is no Java API to Acrobat)

  • Java 3d rotating text snapshot problem

    Hi guys !
    I have searched for a method which captured a 3d rotating text and print it on the screen ,but i didn`t found it.
    I have to this exercise :
    Write a Java 3D program showing two panels and a button. The first panel displays a scene of a rotating 3D text string. When the button is clicked, the image of the 3D scene is captured and the still image is displayed in the second panel.
    Can anybody help me or write me the source code???
    thank you

    Only a fool will do your homework for you.
    But I can't help noticing that the assignment specifically mentions Java3d, and you're asking on an applet forum. It seems unlikely that you're supposed to implement your assignment as an applet.
    Most likely, the assignment tells you how to obtain Java3d. Either that or an earlier hand-out in your class says how to.
    You should re-read your assignment and other class notes, get the Java3D library, and then read the Java3D documentation. Write a simple "hello world" type program using Java3d. At that point, this assignment will probably be pretty simple for you.

  • How to print a text file using Java

    How can I print a text file using Java without converting the output to an image format. Is there anyway I can send the characters in the text file as it is for a print job? I did get a listing doing this ... but that converted the text to an image format before printing....
    THanks,.

    Hi I had to write a print api from scratch, and I did not convert the output to image. Go and read up on the following code. I know there is a Tutorial on Sun about the differant sections of the snippet.
    private void printReport()
         Frame tempFrame = new Frame(getName());
         PrintJob printerJob = Toolkit.getDefaultToolkit().getPrintJob(tempFrame, "Liesltext", null);
         Graphics g = printerJob.getGraphics();
                    //I wrote the method below for calculations
         printBasics(g);
         g.dispose();
         printerJob.end();
    }This alone wont print it you have to do all the calculations in the printBasics method. And as I said I wrote this from scratch and all I did was research first the tutorial and the white papers
    Ciao

  • PDF created using Java iText package - Text not editable and not displaying font properties on Acrobat

    Hi,
    I have an issue in editing the text and viewing the font properties of a text region on a PDF created using Java iText package.
    I use Adobe Acrobat 9 Pro Extended and the option Tools -> Advanced Editing -> TouchUp Text Tool.
    The strange behaviour is that, I have 2 PDFs created out of the same base PDF and text added via Java iText package with the same Text, Font and other properties.
    One of the PDF has the text region editable on Acrobat but the other one has the text region which is not editable.
    But both the PDFs are editable via Adobe Illustrator.
    I have attached both the PDFs for your reference
    PDF_Editable.pdf - Editable on Acrobat
    PDF_Not Editable.pdf - Not Editable on Acrobat
    Any help or insight to find out the difference/issue with the PDF which is not editable via Acrobat would be appreciated.
    Thanks in advance.
    Regards,
    Madhusoodhan Henryraman

    You don't have direct control of the leading of a multiline text field. A common approach is to control the background color of the field with JavaScript since the lines are not really needed when the field is used in Reader/Acrobat. They may be useful when using the form by hand. For more information, see the posts by Max in this topic: http://acrobatusers.com/forum/forms-acrobat/how-do-i-use-multi-lined-text-fields-over-prin ted-line-area-existing-form

  • Trying to write data to a text file using java.io.File

    I am trying to create a text file and write data to it by using java.io.File and . I am using JDeveloper 10.1.3.2.0. When I try run the program I get a java.lang.NullPointerException error. Here is the snippet of code that I believe is calling the class that's causing the problem:
    String fpath = "/test.html";
    FileOutputStream out = new FileOutputStream(fpath);
    PrintStream pout = new PrintStream(out);
    Do I need to add additional locations for source files or am I doing something wrong? Any suggestions would be appreciated.
    Thank you.

    Hi dhartle,
    May be that can help:
    * Class assuming handling logs and connections to the Oracle database
    * @author Fabre tristan
    * @version 1.0 03/12/07
    public class Log {
        private String fileName;
         * Constructor for the log
        public Log(String name) {
            fileName = name;
         * Write a new line into a log from the line passed as parameter and the system date
         * @param   line    The line to write into the log
        public void lineWriter(String line) {
            try {
                FileWriter f = new FileWriter(fileName, true);
                BufferedWriter bf = new BufferedWriter(f);
                Calendar c = Calendar.getInstance();
                Date now = c.getTime();
                String dateLog =
                    DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM,
                                                   Locale.FRANCE).format(now);
                bf.write("[" + dateLog + "] :" + line);
                bf.newLine();
                bf.close();
            } catch (IOException e) {
                System.out.println(e.getMessage());
         * Write a new line into a log from the line passed as parameter,
         * an header and the system date
         * @param   header  The header to write into the log
         * @param   info    The line to write into the log
        public void lineWriter(String header, String info) {
            lineWriter(header + " > " + info);
         * Write a new long number as line into a log from the line 
         * passed as parameter, an header and the system date
         * @param   header  The header to write into the log
         * @param   info    The line to write into the log
        public void lineWriter(String header, Long info) {
            lineWriter(header + " > " + info);
         * Enable to create folders needed to correspond with the path proposed
         * @param   location    The path into which writing the log
         * @param   name        The name for the new log
         * @return  Log         Return a new log corresponding to the proposed location
        public static Log myLogCreation(String location, String name) {
            boolean exists = (new File(location)).exists();
            if (!exists) {
                (new File(location)).mkdirs();
            Log myLog = new Log(location + name);
            return myLog;
         * Enable to create the connection to the DB
         * @return  Connection  Return a new connection to the Oracle database
        public static Connection oracleConnectionCreation() throws Exception {
            // Register the Oracle JDBC driver
            DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
            //connecting to the DB
            Connection conn =
                DriverManager.getConnection("jdbc:oracle:thin:@myComputerIP:1521:myDB","user", "password");
            return conn;
         * This main is used for testing purposes
        public static void main(String[] args) {
            Log myLog =
                Log.myLogCreation("c:/Migration Logs/", "Test_LinksToMethod.log");
            String directory = "E:\\Blob\\Enalapril_LC-MS%MS_MS%MS_Solid Phase Extraction_Plasma_Enalaprilat_ERROR_BLOB_test";
            myLog.lineWriter(directory);
            System.out.println(directory);
    [pre]
    This class contained some other functions i've deleted, but i think it still works.
    That enables to create a log (.txt file) that you can fill line by line.
    Each line start by the current system date. This class was used in swing application, but could work in a web app.
    Regards,
    Tif                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to read a text file using Java

    Guys,
    Good day!
    Please help me how to read a text file using Java and create/convert that text file into XML.
    Thanks and God Bless.
    Regards,
    I-Talk

         public void fileRead(){
                 File aFile =new File("myFile.txt");
             BufferedReader input = null;
             try {
               input = new BufferedReader( new FileReader(aFile) );
               String line = null;
               while (( line = input.readLine()) != null){
             catch (FileNotFoundException ex) {
               ex.printStackTrace();
             catch (IOException ex){
               ex.printStackTrace();
         }This code is to read a text file. But there is no such thing that will convert your text file to xml file. You have to have a defined XML format. Then you can read your data from text files and insert them inside your xml text. Or you may like to read xml tags from text files and insert your own data. The file format of .txt and .xml is far too different.
    cheers
    Mohammed Jubaer Arif.

  • How to insert text in the middle of an existing textfile using java

    Hi,
    How to insert text in the middle of an existing textfile using java i/o streams??

    Mickie wrote:
    I shudn't delete the file...Then you will have the old file and the new file - do you want that?
    and I have to insert text not only at a single place ....got to do at many places in the text file!!then extrapolate on the procedure outlined in reply #1 .

  • Using java to call a text file

    I am new to java and was wondering if there is a way of using java to call a text file on my server and use it to create a webpage using a template. Namely to click a link to a poem, and have the java automatically create a page from a text file of the poetry. I need to know if this is even possible, what I would need to look into, (IE: which software or applet to look for), and if there are any sites that anyone knows about that I could learn how to do this. currently I am having to create a page for every poem posted on my site, which takes a great deal of time, and I would like to speed the process up a bit if it is possible. Any suggestions would be greatly appreciated.

    Why a text file? I don't think it is a best practice of doing that. Just use a database, keep your poem collections there, and set up a jsp page that seek the database, and then display it on another jsp page. I guess you can find similar application in the sample projects provided by JSC.

  • Processing line by line text in a file using java io

    hi,
    i am able to do the basic file handling such reading files, creating a new text file, appending data etc..etc... using java.
    But now i am having a text file containing many lines of sql update statements. i need to go through each line, execute the line in database and if it is successfull then the corresponding line will be deleted. In process of going through these many lines if the connection with database ends abruptly in between then i must be left with all the lines that were not updated in the database.
    Thus if there is no failure in the connection during the process then all lines will be executed and the file will be emptied. on the other hand if connection ends in between then all the lines which were not executed will be left in the file.
    i think the above process could be summarized[b] as to go through the each line in a text file..do some processing and delete the correspondng line and then proceed to the next line and reapeat the above process until file end has been reached.
    i didnt find any good methods to do such updations of file. so please help me...
    thanx

    If you really want to delete a line from a text file, you have to move everything after the line upwards. This is equivalent to deleting an item in an array - you have to shift everything after the item to keep it contiguous. However, I don't think that solution is what you want because it is very inefficient. It would be more efficient for you to read a line, perform the update, then move to the next line. If you get an error, or you come to the end of the file, you're finished. Once you're finished, start reading from the current position and write to the beginning of the file. At this point you would need to keep track of both positions. The easiest way is with a RandomAccessFile. Once you've moved all the remaining lines up in the file, just set the length of the file to the current position.

Maybe you are looking for

  • SBS Server 2003 and Exchange Server - need to access but only have HDD

    Hi, I have been redirected here from a Microsoft Community Forum. I am reasonably conversant with windows systems but am not a computer professional, just trying to see if I can solve a problem without spending a great deal of cash at this stage as o

  • Blue Ray player not working after upgrading to windows 7

    I upgraded my HP Pavilion  m9517c-b desktop PC bundle (part number FQ575AA) which includes: m9517c Desktop PC, part number FQ574AA# ABA   to windows 7 from Vista  home 64. This upgrade now prevents the HP mediasmart program to play blue ray DVD's  gi

  • Why can't I click on a URL in a calendar?

    Hi, When I open a calendar item created from an invite from elsewhere, the text of that invite is loaded but URLs miss the url information. Hence it is not possible to click on them. An example of this might be where an invite contains a link to a we

  • Enhancement Request for Period End Closing

    Hi All, When using Segmented Chart of Accounts, the Period End Closing procedure does not allow you to select different GLs from various companies. The Trial Balance for example, does allow you to select the different GL sets by pressing Find in the

  • Question Lightroom mobile

    Unable to sign in to Lightroom Mobile on my desktop version. Does not recognise my Adobe ID, even after several attempts