List of usage examples for java.awt Graphics fill3DRect
public void fill3DRect(int x, int y, int width, int height, boolean raised)
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFBoolColumnCellRenderer.java
public void paint(Graphics g) { if (g == null) { return;/* www . ja v a 2 s . com*/ } Rectangle bounds = getBounds(); g.setColor(getBackground()); g.fill3DRect(0, 0, bounds.width, bounds.height, true); g.setColor(getForeground()); int xoffbox = (bounds.width - 16) / 2; int yoffbox = (bounds.height - 16) / 2; g.drawRect(xoffbox, yoffbox, 16, 16); Boolean useval; if (value instanceof Boolean) { useval = (Boolean) value; } else if (value instanceof String) { String s = (String) value; if (s.equals("true")) { useval = new Boolean(true); } else if (s.equals("false")) { useval = new Boolean(false); } else { useval = null; } } else { useval = null; } String str; if (useval == null) { str = "?"; } else if (useval.booleanValue()) { str = "X"; } else { str = null; } if (str != null) { FontMetrics fm = g.getFontMetrics(); Rectangle sb = fm.getStringBounds(str, g).getBounds(); int ascent = fm.getAscent(); int leading = fm.getLeading(); int sxoff = xoffbox + ((16 - sb.width) / 2); int syoff = yoffbox + ((16 - (leading + ascent)) / 2) + leading + ascent; g.drawString(str, sxoff, syoff); } }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFDateColumnCellRenderer.java
public void paint(Graphics g) { if (g == null) { return;//ww w.j a va 2 s. co m } Rectangle bounds = getBounds(); g.setColor(getBackground()); g.fill3DRect(0, 0, bounds.width, bounds.height, true); g.setColor(getForeground()); String str; if (value instanceof Calendar) { Calendar cal = (Calendar) value; Format fmt = getDefaultFormat(); str = fmt.format(cal.getTime()); } else if (value instanceof String) { str = (String) value; } else { str = null; } if (str != null) { int firstNewline = str.indexOf('\n'); if (firstNewline < 0) { firstNewline = str.indexOf('\r'); if (firstNewline < 0) { firstNewline = str.indexOf('\f'); if (firstNewline < 0) { firstNewline = str.length(); } } } String firstLine = str.substring(0, firstNewline); FontMetrics fm = g.getFontMetrics(); int ascent = fm.getAscent(); int leading = fm.getLeading(); g.drawString(firstLine, 4, leading + ascent + 4); } }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFDoubleColumnCellRenderer.java
public void paint(Graphics g) { if (g == null) { return;//from w w w . ja v a 2 s . com } Rectangle bounds = getBounds(); g.setColor(getBackground()); g.fill3DRect(0, 0, bounds.width, bounds.height, true); g.setColor(getForeground()); String str; if (value instanceof Double) { Double val = (Double) value; Format fmt = getDefaultFormat(); str = fmt.format(val); } else if (value instanceof String) { str = (String) value; } else { str = null; } if (str != null) { int firstNewline = str.indexOf('\n'); if (firstNewline < 0) { firstNewline = str.indexOf('\r'); if (firstNewline < 0) { firstNewline = str.indexOf('\f'); if (firstNewline < 0) { firstNewline = str.length(); } } } String firstLine = str.substring(0, firstNewline); FontMetrics fm = g.getFontMetrics(); int ascent = fm.getAscent(); int leading = fm.getLeading(); int width = fm.stringWidth(firstLine); int x = (bounds.width - 8) - width; g.drawString(firstLine, x, leading + ascent + 4); } }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFFloatColumnCellRenderer.java
public void paint(Graphics g) { if (g == null) { return;//from ww w .java 2 s. c o m } Rectangle bounds = getBounds(); g.setColor(getBackground()); g.fill3DRect(0, 0, bounds.width, bounds.height, true); g.setColor(getForeground()); String str; if (value instanceof Float) { Float val = (Float) value; Format fmt = getDefaultFormat(); str = fmt.format(val); } else if (value instanceof String) { str = (String) value; } else { str = null; } if (str != null) { int firstNewline = str.indexOf('\n'); if (firstNewline < 0) { firstNewline = str.indexOf('\r'); if (firstNewline < 0) { firstNewline = str.indexOf('\f'); if (firstNewline < 0) { firstNewline = str.length(); } } } String firstLine = str.substring(0, firstNewline); FontMetrics fm = g.getFontMetrics(); int ascent = fm.getAscent(); int leading = fm.getLeading(); int width = fm.stringWidth(firstLine); int x = (bounds.width - 8) - width; g.drawString(firstLine, x, leading + ascent + 4); } }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFHeaderColumnCellRenderer.java
public void paint(Graphics g) { if (g == null) { return;//from w w w.j a v a 2s. c om } Rectangle bounds = getBounds(); g.setColor(getBackground()); g.fill3DRect(0, 0, bounds.width, bounds.height, true); g.setColor(getForeground()); String str; if (value instanceof String) { str = (String) value; } else { str = null; } if (str != null) { int firstNewline = str.indexOf('\n'); if (firstNewline < 0) { firstNewline = str.indexOf('\r'); if (firstNewline < 0) { firstNewline = str.indexOf('\f'); if (firstNewline < 0) { firstNewline = str.length(); } } } String firstLine = str.substring(0, firstNewline); FontMetrics fm = g.getFontMetrics(); int width = fm.stringWidth(firstLine); int x = (bounds.width - width) / 2; int ascent = fm.getAscent(); int leading = fm.getLeading(); g.drawString(firstLine, x, leading + ascent + 4); } }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFInt16ColumnCellRenderer.java
public void paint(Graphics g) { if (g == null) { return;//from www . j a v a 2 s . c om } Rectangle bounds = getBounds(); g.setColor(getBackground()); g.fill3DRect(0, 0, bounds.width, bounds.height, true); g.setColor(getForeground()); String str; if (value instanceof Short) { Short val = (Short) value; Format fmt = getDefaultFormat(); str = fmt.format(val); } else if (value instanceof String) { str = (String) value; } else { str = null; } if (str != null) { int firstNewline = str.indexOf('\n'); if (firstNewline < 0) { firstNewline = str.indexOf('\r'); if (firstNewline < 0) { firstNewline = str.indexOf('\f'); if (firstNewline < 0) { firstNewline = str.length(); } } } String firstLine = str.substring(0, firstNewline); FontMetrics fm = g.getFontMetrics(); int ascent = fm.getAscent(); int leading = fm.getLeading(); int width = fm.stringWidth(firstLine); int x = (bounds.width - 8) - width; g.drawString(firstLine, x, leading + ascent + 4); } }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFInt32ColumnCellRenderer.java
public void paint(Graphics g) { if (g == null) { return;/*from ww w .ja va2 s . co m*/ } Rectangle bounds = getBounds(); g.setColor(getBackground()); g.fill3DRect(0, 0, bounds.width, bounds.height, true); g.setColor(getForeground()); String str; if (value instanceof Integer) { Integer val = (Integer) value; Format fmt = getDefaultFormat(); str = fmt.format(val); } else if (value instanceof String) { str = (String) value; } else { str = null; } if (str != null) { int firstNewline = str.indexOf('\n'); if (firstNewline < 0) { firstNewline = str.indexOf('\r'); if (firstNewline < 0) { firstNewline = str.indexOf('\f'); if (firstNewline < 0) { firstNewline = str.length(); } } } String firstLine = str.substring(0, firstNewline); FontMetrics fm = g.getFontMetrics(); int ascent = fm.getAscent(); int leading = fm.getLeading(); int width = fm.stringWidth(firstLine); int x = (bounds.width - 8) - width; g.drawString(firstLine, x, leading + ascent + 4); } }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFInt64ColumnCellRenderer.java
public void paint(Graphics g) { if (g == null) { return;/* w w w. ja va2 s. com*/ } Rectangle bounds = getBounds(); g.setColor(getBackground()); g.fill3DRect(0, 0, bounds.width, bounds.height, true); g.setColor(getForeground()); String str; if (value instanceof Long) { Long val = (Long) value; Format fmt = getDefaultFormat(); str = fmt.format(val); } else if (value instanceof String) { str = (String) value; } else { str = null; } if (str != null) { int firstNewline = str.indexOf('\n'); if (firstNewline < 0) { firstNewline = str.indexOf('\r'); if (firstNewline < 0) { firstNewline = str.indexOf('\f'); if (firstNewline < 0) { firstNewline = str.length(); } } } String firstLine = str.substring(0, firstNewline); FontMetrics fm = g.getFontMetrics(); int ascent = fm.getAscent(); int leading = fm.getLeading(); int width = fm.stringWidth(firstLine); int x = (bounds.width - 8) - width; g.drawString(firstLine, x, leading + ascent + 4); } }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFNmTokenColumnCellRenderer.java
public void paint(Graphics g) { if (g == null) { return;//from ww w. ja v a 2 s.c om } Rectangle bounds = getBounds(); g.setColor(getBackground()); g.fill3DRect(0, 0, bounds.width, bounds.height, true); g.setColor(getForeground()); String str; if (value instanceof String) { str = (String) value; } else { str = null; } if (str != null) { int firstNewline = str.indexOf('\n'); if (firstNewline < 0) { firstNewline = str.indexOf('\r'); if (firstNewline < 0) { firstNewline = str.indexOf('\f'); if (firstNewline < 0) { firstNewline = str.length(); } } } String firstLine = str.substring(0, firstNewline); FontMetrics fm = g.getFontMetrics(); int ascent = fm.getAscent(); int leading = fm.getLeading(); g.drawString(firstLine, 4, leading + ascent + 4); } }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFNumberColumnCellRenderer.java
public void paint(Graphics g) { if (g == null) { return;//from w ww . j a v a 2s. c om } Rectangle bounds = getBounds(); g.setColor(getBackground()); g.fill3DRect(0, 0, bounds.width, bounds.height, true); g.setColor(getForeground()); String str; if (value instanceof BigDecimal) { BigDecimal val = (BigDecimal) value; Format fmt = getNumberFormat(digits, precis); str = fmt.format(val); } else if (value instanceof String) { str = (String) value; } else { str = null; } if (str != null) { int firstNewline = str.indexOf('\n'); if (firstNewline < 0) { firstNewline = str.indexOf('\r'); if (firstNewline < 0) { firstNewline = str.indexOf('\f'); if (firstNewline < 0) { firstNewline = str.length(); } } } String firstLine = str.substring(0, firstNewline); FontMetrics fm = g.getFontMetrics(); int ascent = fm.getAscent(); int leading = fm.getLeading(); int width = fm.stringWidth(firstLine); int x = (bounds.width - 8) - width; g.drawString(firstLine, x, leading + ascent + 4); } }