1 2 17 18 package org.apache.poi.hssf.contrib.view; 19 20 import java.util.*; 21 import java.awt.*; 22 import javax.swing.border.*; 23 24 import org.apache.poi.hssf.usermodel.*; 25 import org.apache.poi.hssf.util.*; 26 27 33 public class SVTableUtils { 34 private final static Hashtable colors = HSSFColor.getIndexHash(); 35 36 public final static Color black = getAWTColor(new HSSFColor.BLACK()); 37 38 public final static Color white = getAWTColor(new HSSFColor.WHITE()); 39 40 public static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1); 41 42 43 46 public static Font makeFont(HSSFFont font) { 47 boolean isbold = font.getBoldweight() > HSSFFont.BOLDWEIGHT_NORMAL; 48 boolean isitalics = font.getItalic(); 49 int fontstyle = Font.PLAIN; 50 if (isbold) { 51 fontstyle = Font.BOLD; 52 } 53 if (isitalics) { 54 fontstyle = fontstyle | Font.ITALIC; 55 } 56 57 int fontheight = font.getFontHeightInPoints(); 58 if (fontheight == 9) { 59 fontheight = 10; 61 } 62 63 return new Font(font.getFontName(), fontstyle, fontheight); 64 } 65 66 67 74 public final static Color getAWTColor(int index, Color deflt) { 75 HSSFColor clr = (HSSFColor) colors.get(new Integer (index)); 76 if (clr == null) { 77 return deflt; 78 } 79 return getAWTColor(clr); 80 } 81 82 83 89 public final static Color getAWTColor(HSSFColor clr) { 90 short[] rgb = clr.getTriplet(); 91 return new Color(rgb[0], rgb[1], rgb[2]); 92 } 93 94 } 95 | Popular Tags |