473,659 Members | 2,632 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, 360 views)
Apr 13 '12 #1
0 1606

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

Similar topics

1
5902
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: Thurs, Mar 17 2005 5:40 am Subject: Read Text file into Oracle Reports Reply | Reply to Author | Forward | Print | Individual Message | Show original | Remove | Report Abuse
2
6311
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
7619
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 DB-provider. Unfortunately I can't affect in what kind of
1
2339
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 three.txt 13/3/2007
1
2673
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 and if anyone has the sources that could help solve my problem, please direct me to the source. Thank you very much -abtet-
1
1731
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 Support On Xp. In My Project Asp.net Is Generating One Text File Having Data 1 Or 0. N I Want That Vb Program Should Read The Content Of This File Contineously And Give Info Or Access To Parallel Port...should It Be Possible???? If Yes So Plz Help...
1
8787
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
2474
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 from user to calculate the score. Here is a problem. I can read a text file. However, it's read whole file at a time. So,
5
11254
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 couple areas that have ASCII text that I need to extract. At the end of the 2580 bytes, I can read the report like a standard text file. It should have CR/LF at the end of each line. What is the best way for me to read this report using C#. It is...
8
12390
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
8428
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8539
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8630
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4176
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4342
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2759
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1739
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.