draw2d 로 테이블을 그려주려고 했는데 검색이 부족해서인지 하는 방법을 찾을 수가 없었습니다.
또 직접 맹글어야 하는 슬픈 현실이...
민물곰탱이님의 블로그와
OneLineBorder(gmf 에 포함된)를 참고하여
HTMLBorder 를 맹글었습니다.
import org.eclipse.draw2d.AbstractBorder; import org.eclipse.draw2d.Graphics; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.geometry.Insets; import org.eclipse.swt.graphics.Color;
public class HTMLBorder extends AbstractBorder { private Color color;
private int width; private int position;
public HTMLBorder(int width) { this(width, PositionConstants.NSEW); }
public HTMLBorder(int width, int position) { setWidth(width); setPosition(position); }
@Override public Insets getInsets(IFigure ifigure) { Insets insets = new Insets(); if ((position & PositionConstants.NORTH) == PositionConstants.NORTH) { insets.top = getWidth(); } if ((position & PositionConstants.SOUTH) == PositionConstants.SOUTH) { insets.bottom = getWidth(); } if ((position & PositionConstants.WEST) == PositionConstants.WEST) { insets.left = getWidth(); } if ((position & PositionConstants.EAST) == PositionConstants.EAST) { insets.right = getWidth(); } return insets; }
@Override public boolean isOpaque() { return true; }
@Override public void paint(IFigure ifigure, Graphics g, Insets insets) { tempRect.setBounds(getPaintRectangle(ifigure, insets)); if (getWidth() % 2 == 1) { tempRect.width--; tempRect.height--; } tempRect.shrink(getWidth() / 2, getWidth() / 2); g.setLineWidth(getWidth()); if ((position & PositionConstants.NORTH) == PositionConstants.NORTH) { g.drawLine(tempRect.getTopLeft(), tempRect.getTopRight()); } if ((position & PositionConstants.SOUTH) == PositionConstants.SOUTH) { g.drawLine(tempRect.getBottomLeft(), tempRect.getBottomRight()); } if ((position & PositionConstants.WEST) == PositionConstants.WEST) { g.drawLine(tempRect.getTopLeft(), tempRect.getBottomLeft()); } if ((position & PositionConstants.EAST) == PositionConstants.EAST) { g.drawLine(tempRect.getTopRight(), tempRect.getBottomRight()); } }
public Color getColor() { return color; }
public void setColor(Color color) { this.color = color; }
public int getWidth() { return width; }
public void setWidth(int width) { this.width = width; }
public int getPosition() { return position; }
public void setPosition(int position) { this.position = position; } public void appendPosition(int position) { this.position |= position; }
} |
Java2html |
1 Figure shape = new Figure(); 2 HTMLBorder border = new HTMLBorder(1, PositionConstants.NORTH_WEST); 3 if (i == (rows - 1)) { 4 border.appendPosition(PositionConstants.SOUTH); 5 } 6 if (j == (columns - 1)) { 7 border.appendPosition(PositionConstants.EAST); 8 } 9 shape.setBorder(border); |
Java2html |
Java2html 을 처음 사용해보는데 나름 괜찮은듯?? 저기 아래 링크는 귀찮아서 그냥 크윽....
신택스하일라이터는 쩜 느려서... 꾸르릉...