Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: panels size on gridlayout

Reply
Thread Tools

Re: panels size on gridlayout

 
 
VisionSet
Guest
Posts: n/a
 
      07-10-2003
"memememe" <[rem]casolorz[rem]@hot[rem]mail.com> wrote in message
news:7j_Oa.669$...
> I have a scrollpane with a panel inside of it which has gridlayout. This
> panel gets added other panels. My purpose is to add one panel below the
> other (by below I am a little further down on the screen). The panels get
> added fine but they contain images, images which I hope will take up the
> whole panel so that the images on the panels above and below will touch,

but
> instead the images dont take the whole panel and the images dont touch. I
> have checked the VGap and HGap of the gridlayout and thats not the

problem,
> I have also colored the background of the most inner panels and they do
> touch each other, its just the images that seem to be small than the panel
> size.
> I am using AWT in case it wasnt clear.
>


Rewrite a *tiny* version of it, to track down the problem, if it still does
it, post it here.

--
Mike W



 
Reply With Quote
 
 
 
 
VisionSet
Guest
Posts: n/a
 
      07-10-2003
"Ike" <> wrote in message
news:dIcPa.39465$ rthlink.net...
> Are the image sizes, when displayed, full size? i.e. is it that you want
> them to "stretch," to take up the panel? If so, I have some blitting

classes
> I wrote to take an Image and a JPanel. Please let me know here. -Ike


They are full size, they won't resize by default in the same way the panel
does.
You will have to write code that gets the size of the panel on each window
change and reproduces the image appropriately.

--
Mike W


 
Reply With Quote
 
 
 
 
Ike
Guest
Posts: n/a
 
      07-10-2003
Maybe this might help....it lets you do a lot in the way of how you want it
layed out on the panel, including alpha....hth, Ike
/**
* This version uses a default alpha blend of 0% of the previous image,
100% of current image
* @param g the Graphics2D context
* @param blitmode 1=raw at its natural size in upper left of picture at
UpperLeftX,UpperLeftY
* 2=draw at its natural size in center(UpperLeftX,UpperLeftY not used
in blitMode==2)
* 3=draw at its natural size tiled throughout
* 4=scale it all into the view window, aspect ratio be damned
* 5=scale it all into view, but maintain aspect ratio
* 6=like 4&5 but do not scale it, use actual size
* Note - methods 4,5 and 6 tile based on where you are in the window,
1,2 and 3 do not
* @param img the image to blit
*@param UpperLeftX the left corner to put the image in
*@param UpperLeftY the upper corner to put the image in
*@param targWidth the width of the image after blitting
*@param targHeight the heigh of the image after blitting
*@param observer the ImageObserver itself
*/
final static public void blit(Graphics2D g,int blitMode,Image img,int
UpperLeftX, int UpperLeftY,int targWidth,int targHeight, ImageObserver
observer){
blit(g,blitMode,img,UpperLeftX, UpperLeftY,targWidth,targHeight,
1.0F,1.0F,observer);
}
/**
*
* @param g the Graphics2D context
* @param blitmode 1=raw at its natural size in upper left of picture at
UpperLeftX,UpperLeftY
* 2=draw at its natural size in center(UpperLeftX,UpperLeftY not used
in blitMode==2)
* 3=draw at its natural size tiled throughout
* 4=scale it all into the view window, aspect ratio be damned
* 5=scale it all into view, but maintain aspect ratio
* 6=like 4&5 but do not scale it, use actual size
* Note - methods 4,5 and 6 tile based on where you are in the window,
1,2 and 3 do not
* @param img the image to blit
*@param UpperLeftX the left corner to put the image in
*@param UpperLeftY the upper corner to put the image in
*@param targWidth the width of the image after blitting
*@param targHeight the heigh of the image after blitting
*@param alpha the percentage (0.0f - 1.0f, inclusive) of the current
image (img) to use
*@param observer the ImageObserver itself
*/
final static public void blit(Graphics2D g,int blitMode,Image img,int
UpperLeftX, int UpperLeftY,int targWidth,int targHeight, float alpha,
ImageObserver observer){
blit(g,blitMode,img,UpperLeftX, UpperLeftY,targWidth,targHeight,
alpha,1.0F, observer);
}
/**
*
* @param g the Graphics2D context
* @param blitmode 1=raw at its natural size in upper left of picture at
UpperLeftX,UpperLeftY
* 2=draw at its natural size in center(UpperLeftX,UpperLeftY not used
in blitMode==2)
* 3=draw at its natural size tiled throughout
* 4=scale it all into the view window, aspect ratio be damned
* 5=scale it all into view, but maintain aspect ratio
* 6=like 4&5 but do not scale it, use actual size
* Note - methods 4,5 and 6 tile based on where you are in the window,
1,2 and 3 do not
* @param img the image to blit
*@param UpperLeftX the left corner to put the image in
*@param UpperLeftY the upper corner to put the image in
*@param targWidth the width of the image after blitting
*@param targHeight the heigh of the image after blitting
*@param alpha the percentage (0.0f - 1.0f, inclusive) of the current
image (img) to use
*@param alphaOver the percentage (0.0f - 1.0f, inclusive) of the images
to be painted over this bitmap to use
*@param observer the ImageObserver itself
*/
final static public void blit(Graphics2D g,int blitMode,Image img,int
UpperLeftX, int UpperLeftY,int targWidth,int targHeight, float alpha, float
alphaOver, ImageObserver observer){

g.setComposite(AlphaComposite.getInstance(AlphaCom posite.SRC_OVER,alpha));
if (blitMode==1){
//draw at its natural size in upper left of picture at
UpperLeftX,UpperLeftY
g.drawImage(img,UpperLeftX,UpperLeftY,observer);
}else if (blitMode==2){
//draw at its natural size in center
//UpperLeftX,UpperLeftY not used in blitMode==2
float x = (float)(img.getWidth(observer));
float y = (float)(img.getHeight(observer));
float tWidth=(float) targWidth;
float tHeight=(float) targHeight;
tWidth=tWidth/2-x/2;
tHeight=tHeight/2-y/2;
if(x>0.0 && y>0.0)

g.drawImage(img,UpperLeftX+(int)tWidth,UpperLeftY+ (int)tHeight,observer);
}else if (blitMode==3){
//draw at its natural size tiled throughout
int x = img.getWidth(observer);
int y = img.getHeight(observer);
int xcount,ycount;
xcount=ycount=1;
if(x>0 && y>0){
while (x*xcount<targWidth+x){
while (y*ycount<targHeight+y){
g.drawImage(img,x*(xcount-1),y*(ycount-1),observer);
ycount++;
}
ycount=1;
xcount++;
}
}
}else if (blitMode==4){
//scale it all into the view window, aspect ratio be damned

g.drawImage(img,UpperLeftX,UpperLeftY,UpperLeftX+t argWidth,UpperLeftY+targHe
ight, observer);
}else if(blitMode>4){
//scale it all into the view - tries to get most of it in the
view without changing the aspect ratio
float xratio, yratio;
float x = (float)(img.getWidth(observer));
float y = (float)(img.getHeight(observer));
float tWidth=(float) targWidth;
float tHeight=(float) targHeight;

if(x>0.0 && y >0.0){
if(blitMode==5){
xratio = x/tWidth;
yratio = y/tHeight;
}else{
xratio=yratio=1.0f;
}
// x&y are width & height of picture file rect
// tWidth & tHeight are width & height of target rect

if(xratio <= yratio){
g.drawImage(img,UpperLeftX,UpperLeftY,
/*ulx+*/(int)(x/xratio),/* uly+*/(int)(y/xratio) , observer);
}else{
g.drawImage(img,UpperLeftX,UpperLeftY,
/*ulx+*/(int)(x/yratio), /*uly+*/(int)(y/yratio), observer);
}
}else{

g.drawImage(img,UpperLeftX,UpperLeftY,/*ulx+*/targWidth,/*uly+*/targHeight,
observer);
}
}
//set alpha back so controls can draw

g.setComposite(AlphaComposite.getInstance(AlphaCom posite.SRC_OVER,alphaOver)
);
}


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: panels size on gridlayout Ike Java 2 07-10-2003 03:49 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57