Hi there to everyone. I'm starting to learn and work with java about one month ago and I have some questions that I wonder if someone could help me, making a sugestions or guide me a lil'.
Someone already implemented some kind of layer thing like Photoshop? I need something like layers that you can create news, or delete the ones that you have and what you draw in each layer work independently from the other layers. I'm doing an application to web that works now like a simple paintbrush, I did it using BufferedImage and a JPanel to draw in. I would thank a lot if someone could help me with this, I'm pretty much lost and don't imagine how to do this layer thing (well, I imagine that using JLayeredPane maybe O_o).
Other thing, the most important. I did this lil "paintbrush" like application, but my problem is that I can not set for each shape that I draw a "style" like a different stroke or color, because I use to draw every shape a single Graphics2D, and I dont know how to recover the shapes that I already draw if I would like to move them to another place for example.
I'm a newbie and apologize to disturb everyone with my questions, but I would that a lot if someone could help me.
(sorry, I don't write very well in english, but I understand everything that you write.)
here I'm placing the part of my code that I draw the shapes :
public void update(Graphics g){
Graphics2D g2 = (Graphics2D)g;
Dimension dim = getSize();
int w = dim.width;
int h = dim.height;
if(firstTime){
bi =
(BufferedImage)createImage(w, h);
big = bi.createGraphics();
big.setColor(Color.black);
big.setStroke
(new BasicStroke(1.0f,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
big.setRenderingHint(RenderingHints.KEY_ANTIALIASING
, RenderingHints.VALUE_ANTIALIAS_ON);
area = new Rectangle(dim);
firstTime = false;
}
// Clear the JPanel.
big.setColor(Color.white);
big.clearRect(0, 0, area.width, area.height);
big.setPaint(Color.black);
for (int i=0; i <
vetorDeFiguras.size(); i++){
/** vetorDeFiguras is a Vector that contains all the Shapes that I draw in the JPanel and
Figura is a class that have all the java.awt.geom Shapes and by a flag that is sended to
it manipulate the cordnates sended and "draw" the shape according to its type */
big.draw
(((Figura) vetorDeFiguras.get(i)).getShape());
}
// desenha BufferedImage na tela
g2.
drawImage(bi, 0, 0, this);
}
--
What said Odin to the Gods and to the Champions who surrounded him? "We will give our lives and let our world be destroyed, but we will battle so that these evil powers will not live after us." Out of Hel's ship sprang Fenrir the Wolf. His mouth gaped; his lower jaw hung against the earth, and his upper jaw scraped the sky. Against the Wolf Odin All-Father fought...
...By Fenrir the Wolf Odin was slain.
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
- [JAVA2D] Layers like Photoshop. [ Fenrir Northern Wolf ]
- Re: [JAVA2D] Layers like Photoshop. Chet Haase
- [JAVA2D] "Retained Mode" Graph... David Eisner
- Re: [JAVA2D] "Retained Mode&quo... Emmanuel Pietriga
- Re: [JAVA2D] Layers like Photoshop. Mars
