H
Heph
Hey people,
I have a small problem with some paint and replaceing.
What I try to do:
I draw 1 line at the most right of a panel
next I have to make a image out of this line, move it 1 pixel to the
left.
then I draw a new line, the previous line should still be visible to
the left of the new line.
I then have to make a image out of these 2 lines, move it 1 pixel to
the left
etc.
Why I want to do it this way:
repaint of 100's of lines takes too much instead of just an image + new
line.
What I have tried so far:
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
bimage = (BufferedImage)this.createImage(seqNr,getHeight()); //where
seqNr is the amount of lines currently painted so far
g2d = (Graphics2D)bimage.getGraphics();
g2d.copyArea(x1, 0, 1, 0, -1, 0);
g2d.drawImage(bimage, 0, 0, null);
g2d.paintstuff //this actually paints the lines in the correct color,
size etc
}
the g2d.paintstuff is creating the lines out of a bunch of seperately
colored pixels.
I have tried replacing the image making etc to other parts but that
didnt work either.
My questions:
How can i make an image out of the selection of lines currently on
screen?
How do i move that 1 pixel and NOT lose it on repaint();?
Did i overlook a much simpler solution to what I am trying to do?
So it should look like this:
You have a increasing number of lines spawning from the rightside of
the panel and pusing older lines to the left.
most left = oldest.
greetings, D
I have a small problem with some paint and replaceing.
What I try to do:
I draw 1 line at the most right of a panel
next I have to make a image out of this line, move it 1 pixel to the
left.
then I draw a new line, the previous line should still be visible to
the left of the new line.
I then have to make a image out of these 2 lines, move it 1 pixel to
the left
etc.
Why I want to do it this way:
repaint of 100's of lines takes too much instead of just an image + new
line.
What I have tried so far:
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
bimage = (BufferedImage)this.createImage(seqNr,getHeight()); //where
seqNr is the amount of lines currently painted so far
g2d = (Graphics2D)bimage.getGraphics();
g2d.copyArea(x1, 0, 1, 0, -1, 0);
g2d.drawImage(bimage, 0, 0, null);
g2d.paintstuff //this actually paints the lines in the correct color,
size etc
}
the g2d.paintstuff is creating the lines out of a bunch of seperately
colored pixels.
I have tried replacing the image making etc to other parts but that
didnt work either.
My questions:
How can i make an image out of the selection of lines currently on
screen?
How do i move that 1 pixel and NOT lose it on repaint();?
Did i overlook a much simpler solution to what I am trying to do?
So it should look like this:
You have a increasing number of lines spawning from the rightside of
the panel and pusing older lines to the left.
most left = oldest.
greetings, D