336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

import java.awt.Color;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;

import javax.media.jai.widget.ScrollingImagePanel;

public class ImageTestCanvas {

 private BufferedImage bimg = null;
 private Graphics2D g2d = null;
 private int width = 256;
 private int height = 256;
 private Color BLACK = new Color(0,0,0);
 private Color WHITE = new Color(255,255,255);
 
 public ImageTestCanvas(int width, int height)
 {
  this.width = width;
  this.height = height;
  bimg = new BufferedImage(width,height, BufferedImage.TYPE_USHORT_565_RGB);
  g2d = (Graphics2D)bimg.getGraphics();
 
 }
 
 public void fonttest()
 {
  String[] fontlist ={"굴림","바탕","돋움체"
  };
 
  int x = 0;
  int y = 0;
  g2d.setColor(BLACK);
  g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
 
  for (int i = 0; i< fontlist.length; ++i)
  {
   x = i*250 + 5;
   y = 0;
   for (int j = 8; j< 30; ++j)
   {
    y += j + 10;
   
    Font font = new Font(fontlist[i], Font.PLAIN, j);
   
   
    g2d.setFont(font);
    g2d.drawString("("+j +")" + fontlist[i] + " Test", x, y);
   }
  }
 }
 
 public void draw()
 {
  clean();
  fonttest();
 }
 
 private void clean()
 {
  g2d.setColor(WHITE);
  g2d.fillRect(0,0,width,height);
 
 }
 
 public void show()
 {
  ScrollingImagePanel panel = new ScrollingImagePanel(bimg, width, height);

  /* Create a frame to contain the panel. */
  Frame window = new Frame("Test Program");
  window.add(panel);
  window.addWindowListener(new WindowAdapter(){
   public void windowClosing(WindowEvent we){
    System.exit(0);}
   });
  window.pack();
  window.show();
 }
 
 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub

  ImageTestCanvas test = new ImageTestCanvas(1024,800);
  test.draw();
  test.show();
 
 }

}

-------------------------
헉 50라인을 훨씬 초과해버렸다.. 쩝

사용자 삽입 이미지

+ Recent posts