Hi,

There's a lot of questions (implicit or explicit) here
and it'd be tough to answer all of them.  I'd suggest
that you pick up a book on Java2D to begin with; that
should help put you on the path for much of this.
In fact, Vincent Hardy's book (hopefully still in print,
but I don't know) actually implements a layers approach
(his "GLF" framework) that you could use to do some
of what you're talking about.

A couple of other things to keep in mind:

- you generally want to override paintComponent() for
Swing components as your rendering mechanism

- Java2D is an "immediate mode" API; we don't remember
drawing objects that you've already rendered, we just draw
what you tell us to and then forget about it.  However, this
does not stop you from implementing your own "retained mode"
approach on top of Java2D.  There are a couple of ways I can
think of off the top of my head that you could do this:
       - create objects that remember how to paint themselves.
       When you need to re-render them, just tell the object
       to paint itself and it will call the 2D commands
       to do the right thing.
       - intermediate images: you can draw complex
       renderings into an image that you cache for later
       re-rendering.  This might be helpful in both remembering
       rendering operations and saving performance for
       complex rendering.

Good luck!

Chet.



[ Fenrir Northern Wolf ] wrote:
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".

===========================================================================
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".

Reply via email to