- 前ページ
- 次ページ
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
import java.util.*;
public class FlickrPhotoPanel extends JPanel {
ArrayList photoImgList;
FlickrPhotoPanel(){
photoImgList = new ArrayList();
}
public void setPhotoList(ArrayListflickrObjList){
for(FlickrPhoto photo : flickrObjList){
photoImgList.add(photo.getImg75());//追加。
}
} //↑setPhotoListおわり
//↓丸い円が二重に表示されるように改造する
public void paint(Graphics g){
int width = this.getWidth();
int height = this.getHeight();
int radius = width < height ? width/4-50 : height/4-50;
int radius2 = width < height ? width/2-50 : height/2-50;
g.setColor(getBackground());
g.fillRect(0, 0, width, height);
int photoNum = photoImgList.size();
if(0 < photoNum){
double angle = 2.0*Math.PI/photoNum;
for(int i=0; i int x = (int)(width/2 + radius*Math.cos(angle*i));
int y = (int)(height/2 + radius*Math.sin(angle*i));
g.drawImage(photoImgList.get(i), x-74/2, y-74/2,
null);
}
if(0 < photoNum){
for(int i=0; i int x = (int)(width/2 + radius2*Math.cos(angle*i));
int y = (int)(height/2 + radius2*Math.sin(angle*i));
g.drawImage(photoImgList.get(i), x-74/2, y-74/2,
null);
}
}
}
}
}
import java.awt.image.*;
import javax.swing.*;
import java.util.*;
public class FlickrPhotoPanel extends JPanel {
ArrayList
FlickrPhotoPanel(){
photoImgList = new ArrayList
}
public void setPhotoList(ArrayList
for(FlickrPhoto photo : flickrObjList){
photoImgList.add(photo.getImg75());//追加。
}
} //↑setPhotoListおわり
//↓丸い円が二重に表示されるように改造する
public void paint(Graphics g){
int width = this.getWidth();
int height = this.getHeight();
int radius = width < height ? width/4-50 : height/4-50;
int radius2 = width < height ? width/2-50 : height/2-50;
g.setColor(getBackground());
g.fillRect(0, 0, width, height);
int photoNum = photoImgList.size();
if(0 < photoNum){
double angle = 2.0*Math.PI/photoNum;
for(int i=0; i
int y = (int)(height/2 + radius*Math.sin(angle*i));
g.drawImage(photoImgList.get(i), x-74/2, y-74/2,
null);
}
if(0 < photoNum){
for(int i=0; i
int y = (int)(height/2 + radius2*Math.sin(angle*i));
g.drawImage(photoImgList.get(i), x-74/2, y-74/2,
null);
}
}
}
}
}






