473,507 Members | 2,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I read from a text file and translate that info to graphics?

10 New Member
My program is supposed to render graphics from the attached file. I can get my program to read the file without issue. My problem lies in getting the file to convert into graphics. I'm not even sure where to begin on this one. To say I'm frustrated would be a major understatement at this point. Here is my code so far:

Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. import java.util.*;
  3. import java.io.*;
  4.  
  5. public class Project8 {
  6.     static Graphics g;
  7.     // Program to render the objects described in the model file
  8.     public static void main(String[] args) throws FileNotFoundException {
  9.         Scanner input= new Scanner(new File("sun.txt"));
  10.         DrawingPanel panel = new DrawingPanel(500, 500);
  11.         g = panel.getGraphics();
  12.         while (input.hasNextLine()) {
  13.             String text = input.nextLine();
  14.             renderCommand(text);
  15.         }        
  16.     }
  17.  
  18.     // takes a String rendering command and renders the specified
  19.     // line, oval, or rectangle to the drawing panel
  20.     public static void renderCommand(String text) {
  21.         Scanner commandLine = new Scanner(text);
  22.         String command = commandLine.nextLine();
  23.         if (command.equals(text)) {
  24.             System.out.println(text);
  25.  
  26.         }
  27.  
  28.         // 
  29.  
  30.     }
  31.  
  32.  
  33. }
  34.  
Any help would be most appreciated. I have been all over google and my textbook trying to figure this out to no avail. The answer is probably staring me right in the face, but I'm at my wits end on this.
Attached Files
File Type: txt sun.txt (18.8 KB, 357 views)
Apr 13 '12 #1
0 1599

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5882
by: rishka | last post by:
Rishka Mar 17, 5:40 am show options Newsgroups: comp.databases.oracle.tools From: "Rishka" <ris...@webmail.co.za> - Find messages by this author Date: 17 Mar 2005 05:40:45 -0800 Local:...
2
6298
by: Lam | last post by:
Hi the default readline method in StreamReader read the text from the top to bottom how can I read a text file from the bottom to the top? Thanks
5
7613
by: Mika M | last post by:
Hi! I'm trying to read text file like... "Field1";"Field2";"Field3";"Field4" "ABCD";"EFGH";"1234";"20051020" "AABB";"CCDD";"2468";"20051021" "CCDD";"XXYY";"4321";"20051022" ....using OLE...
1
2315
by: sallu2000 | last post by:
hi to all, I am new to php,can u give any idea to read text file from folder based on datewise .for eg. in that folder there are three text file. one.txt 10/3/2007 two.txt 13/3/2007...
1
2666
by: abtet | last post by:
Hello people, I am new to php and have question on how to read text file and convert it to XML with php. . Can it be done if the text file contains text, image and also tables? please help...
1
1727
by: shahid706 | last post by:
Hi... I M Working On Project "web-based Wireless Home Automation" My Hardware Part Is Completed ..n Now I Want To Access This Hardware Using Parallel Port...so I Choose Vb..bcoz C Program Doesnt...
1
8779
by: neveen | last post by:
i want to open and read text file using j2me that can run on mobile 6630 then i want to make button called read that when pressed the data inside text display
6
2464
by: portCo | last post by:
Hello there, I am creating a vb application which is some like like a questionare. Application read a text file which contains many questions and display one question and the input is needed...
5
11217
by: dm3281 | last post by:
Hello, I have a text report from a mainframe that I need to parse. The report has about a 2580 byte header that contains binary information (garbage for the most part); although there are a...
8
12377
by: karimkhan | last post by:
I am trying to read text file , here is the code , I cant use activex control so plz give me some way.... <html> <head> <script type="text/javascript"> function r() {
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7114
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7488
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5045
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.