Jump to content

  • Log In with Google      Sign In   
  • Create Account

[java] Pixel Plotting Under Java


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Kosh   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 March 2000 - 06:26 PM

hi everyone, I would like to know, can someone please download my java code, which is at this URL http://mx1.xoom.com/KoshHome/JavaApplication.zip and tell me why it doesnt do anything, I am trying to just plot some pixels around, but for some reason, it''s not working, I was wondering if it''s just something simple that I am getting wrong, if you can fix it, either just upload it to a site, then link it here, or just put a couple of lines that tell me what to change and where I went wrong. Thanks everyone, I have been sitting up for the last 10 hours on this, without success. kosh

Sponsor:

#2 javanerd   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 March 2000 - 06:46 PM

Here is the problem class rewritten. The AppFrame was not doing what it was supposed to, first you didn''t call the super() constructor (as you should have), but created another Frame in the constructor that then got lost (you didn''t preserve the reference to it. Also in paint() you don''t have to say getGraphics() as you allready have it...


public class AppFrame extends Frame
{
PixelImage piximage = null;

public AppFrame( int framesize_x, int framesize_y ) {
super("2DG Demo");
piximage = new PixelImage(new Dimension
(framesize_x,framesize_y));
setSize(framesize_x, framesize_y);
setVisible(true);
}

public void paint(Graphics g)
{
Graphics2D g2d = (Graphics2D) g;
g2d.drawImage(piximage.getImage(),0,0,null);
}
}


If you use this code, it''ll work. I also suggest adding a bit of code to your forever for-loop in the Application class. Something like:

try
{
Thread.currentThread().sleep(20);
}
catch( InterruptedException ie )
{
}


That''ll make it a bit more loose loop (that gives other threads some time to do something).

If you like to NOT use the normal repaint-update-paint cycle I suggest you change the repaint method to:

public void paintNow()
{
Graphics2D g2d = (Graphics2D) this.getGraphics();
g2d.drawImage(piximage.getImage(),0,0,null);
}


and in the Application class instead of saying app.repaint() say app.paintNow().

#3 Kosh   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 March 2000 - 09:39 PM

hello all,
JAVANERD !!!! YOUR A FUCKING GENIUS !!!!

yes, it works muhahahahhahah I can plot pixels !!!!

ok, would anyone like a quick and dirty tutorial for you to point people at ? tired of answering the "how do I plot a pixel" question, time and time again ? well, if you want, I''ll do one, now that I can do it, I dont mind helping other people.

What does everyone say ?

kosh

#4 Jim_Ross   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 March 2000 - 02:47 AM

I would like to know how to do pixel plotting. I''m not too good with low level graphics stuff.

#5 Captain Goatse   Banned   -  Reputation: 100

Like
Likes
Like

Posted 20 March 2000 - 04:06 AM

quote:
Original post by Jim_Ross

I would like to know how to do pixel plotting. I''m not too good with low level graphics stuff.


Yeah, me too do you know any good books from low level graphics?



Time comes, time goes and I only am.

#6 javanerd   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 March 2000 - 07:31 AM

Yeah! Spread the knowledge...




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS