'2009/02'에 해당되는 글 3건

  1. 2009/02/24 PositionLayout
  2. 2009/02/20 '서'와 '써'의 차이
  3. 2009/02/05 Java Decompiler JAD와 JadClipse 설치 및 활용
2009/02/24 13:33

PositionLayout

Postion Layout은 사용자 정의 레이아웃입니다.
사용법은 null 레이아웃으로 설정하여 setBounds를 이용하는 방법과 동일합니다.
하지만 Postion Layout은 위치를 퍼센트로 계산하기 때문에 크기 조정시 레이아웃에 포함된 컴포넌트의 크기가 조정됩니다.

import java.awt.*;
import java.util.*;

public class PositionLayout implements LayoutManager {
    Vector  positions = new Vector(10);
    Vector  components = new Vector(10);
    private  boolean   leftRatio;
    private  boolean   topRatio;
    private  boolean   rightRatio;
    private  boolean   bottomRatio;

    public void addLayoutComponent(String p, Component c) {
        positions.addElement(p);
        components.addElement(c);
    }


    public void removeLayoutComponent(Component c) {

        int i = components.indexOf(c);
        if(i != -1) {
            positions.removeElementAt(i);
            components.removeElementAt(i);
        }
    }


    public Dimension preferredLayoutSize(Container parent) {
        Dimension dim = new Dimension(0,0);
        int ncomponents = parent.getComponentCount();
        Insets  insets = parent.getInsets();
        dim.width += insets.left + insets.right;
        dim.height += insets.top + insets.bottom;

        int maxW = dim.width;
        int maxH = dim.height;
        for(int i = 0; i < ncomponents; i++) {
            Component  com = parent.getComponent(i);
            if(com.isVisible() == false)
                continue;
            int  w = com.getPreferredSize().width + dim.width;
            int  h = com.getPreferredSize().height + dim.height;
            if( w > maxW )
                maxW = w;
            if( h > maxH )
                maxH = h;
        }
        //System.out.println("prefer Size: width="+maxW+"\t\theight="+maxH);
        return  new Dimension(maxW, maxH);
    }


    public Dimension minimumLayoutSize(Container target) {
        return  target.getSize();
    }


    public void layoutContainer(Container target) {
        Insets insets = target.getInsets();
        int    ncomponents = target.getComponentCount();
        Dimension d = target.getSize();
        d.width  -= insets.left + insets.right;
        d.height  -= insets.top + insets.bottom;
        int  startX =0, startY =0, endX =0, endY =0;
        int  left = 0, top =0, right = 0, bottom =0;
        for(int i=0; i< ncomponents; i++) {
            Component comp = target.getComponent(i);
         StringTokenizer token = new StringTokenizer((String)positions.elementAt(i), ", \t");
            String  leftSt = token.nextToken();
            if(leftSt.endsWith("%")) {
                leftRatio = true;
                left  = Integer.parseInt(leftSt.substring(0, leftSt.length()-1));
            } else {
                left  = Integer.parseInt(leftSt);
            }

            String  topSt = token.nextToken();
            if(topSt.endsWith("%")) {
                topRatio = true;
                top  = Integer.parseInt(topSt.substring(0, topSt.length()-1));
            } else {
                top  = Integer.parseInt(topSt);
            }

            String  rightSt = token.nextToken();
            if(rightSt.endsWith("%")) {
                rightRatio = true;
                right  = Integer.parseInt(rightSt.substring(0, rightSt.length()-1));
            } else {
                right  = Integer.parseInt(rightSt);
            }

            String  bottomSt = token.nextToken();
            if(bottomSt.endsWith("%")) {
                bottomRatio = true;
                bottom  = Integer.parseInt(bottomSt.substring(0, bottomSt.length()-1));
            } else {
                bottom  = Integer.parseInt(bottomSt);
            }

            if(leftRatio)
                startX = (d.width * left)/100;
            else
                startX = left;

            if(topRatio)
                startY = (d.height * top)/100;
            else
                startY = top;

            if(rightRatio)
                endX = (d.width * right)/100;
            else
                endX = right;

            if(bottomRatio)
                endY = (d.height * bottom)/100;
            else
                endY = bottom;

            if(startX > endX) {
                int temp = startX;
                startX = endX;
                endX = temp;
            }
            if(startY > endY) {
                int temp = startY;
                startY = endY;
                endY = temp;
            }
            int  w = endX - startX;
            int  h = endY - startY;
            comp.setBounds(startX+insets.left, startY+insets.top, w, h);
            topRatio = false;
            leftRatio = false;
            rightRatio = false;
            bottomRatio = false;
        }
    }

    public String toString() {
        return getClass().getName();
    }
}
크리에이티브 커먼즈 라이선스
Creative Commons License
Trackback 0 Comment 0
2009/02/20 22:17

'서'와 '써'의 차이

* '-든가' : 선택

 [예] 가든가(지) 말든가(지) 마음대로 해라.

 

* '-던가'

   1) 과거(회상)의 일을 물을 때 쓰는 종결 어미

     [예] 그가 밥을 먹든가?

             그 물건이 좋던가, 나쁘던가?

   2) 지난 일에 대해 일반적으로 의심할 때 쓰는 연결 어미

     [예]얼마나 많던가 모르겠소.

 

* 었다,  였다.

  1) 었다: 음성(중성) 모음 아래 쓰는 과거 종결 어미(양성 아래; 았)

     [예] 일이었다.   밤이었다,   되었다.

  2) 였다: '이었다'의 준말,   였; '하다'의 '하(어간)'  아래 쓰는 과거시제 선어말 어미

     [예] 보이었다 > 보였다.

             먹이었다 > 먹였다.

             잡히었다 > 잡혔다.

             가득하 + 었> 였 + 다.> 가득하였다.

             행복하 + 었> 였 + 다 > 행복하였다.

 

* 서, 써

 1) '-(으로)서' : 신분, 자격 등,    '-서': 에서의 뜻

   [예] 사람으로서,  자식으로서,   남자로서,  서울서 부산까지

 2) '-(으로)써' : 원인, 수단, 방법( -를 '가지고서'의 뜻) 등

    [예] 열심히 함으로써,  용기로써 대처하라.

크리에이티브 커먼즈 라이선스
Creative Commons License
Trackback 0 Comment 0
2009/02/05 17:55

Java Decompiler JAD와 JadClipse 설치 및 활용

Jad는 바이트코드인 Java class파일을 디컴파일해주는 프로그램이다.
JadClipse는 자바디컴파일을 이클립스에서 편리하게 사용할 수 있도록 해주는 이클립스 플러그인이다.

1. Jad및 JadClipse 다운로드
  * Jad : http://www.kpdus.com/jad.html
     윈도우 사용자는 Jad 1.5.8g for Windows 9x/NT/2000 on Intel platform 를 다운로드

  * JadClipse : http://sourceforge.net/projects/jadclipse
    자신의 이클립스 버전에 맞는 jadclipse3.x 를 다운로드

2. Jad와 Jadclipse를 적절한 위치로 복사하기
   jad의 압축을 풀어 jad.exe 를 C:\Jad 폴더를 만들어 복사한다.
   jadclipse는 net.sf.jadclipse_3.x.0 폴더를 eclipse의 plugins 폴더로 복사한다.

3. jadclipse 사용을 위한 이클립스 환경설정
Window - Preferences - Java - JadClipse에서
 - Path to decompiler > c:\jad\jad.exe  
 - [v] Reuse code buffer 체크

한글이 깨지는 것을 방지하기 위해, JadClipse - Misc 에서 
  - [v] Convert Unicode strings into ANSI strings 를 체크


디컴파일을 위한 모든 준비가 끝났다.

4. 디컴파일 사용하기
디컴파일하고자 하는 class파일을 더블클릭하면, decompile된 소스가 보여지게 된다.


기존에 디컴파일러 존재와 사용은 하고 있었지만 이클립스와 연동을 하지 못해 콘솔에서 썼다.
하지만 김기사님의 포스팅 덕분에 이클립스와의 연동에 성공하여 현재 잘 사용하고 있다. 김기사님 감솨~

원문 및 출처: http://it.kimgisa.net/search/jad
크리에이티브 커먼즈 라이선스
Creative Commons License
Trackback 0 Comment 0