本文整理匯總了Java中org.compiere.util.Env.getGraphics方法的典型用法代碼示例。如果您正苦於以下問題:Java Env.getGraphics方法的具體用法?Java Env.getGraphics怎麽用?Java Env.getGraphics使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.compiere.util.Env
的用法示例。
在下文中一共展示了Env.getGraphics方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setTimeSlots
import org.compiere.util.Env; //導入方法依賴的package包/類
/**
* Set Time Slots and calculate width
* @param timeSlots time slots
*/
public void setTimeSlots (MAssignmentSlot[] timeSlots)
{
log.debug( "VScheduleTimePanel.setTimeSlots");
m_timeSlots = timeSlots;
m_lines = new String[m_timeSlots.length];
//
FontMetrics fm = null;
Graphics g = getGraphics();
if (g == null)
g = Env.getGraphics(this);
if (g != null)
fm = g.getFontMetrics(m_font); // the "correct" way
else
{
log.error("No Graphics");
// fm = getToolkit().getFontMetrics(m_font);
}
m_width = 0;
for (int i = 0; i < m_lines.length; i++)
{
m_lines[i] = m_timeSlots[i].getInfoTimeFrom();
int width = 0;
if (fm != null)
width = fm.stringWidth(m_lines[i]);
if (width > m_width)
m_width = width;
}
setSize();
// repaint();
}
示例2: setSize
import org.compiere.util.Env; //導入方法依賴的package包/類
/**
* Set Size
*/
public void setSize ()
{
// width
FontMetrics fm = null;
Graphics g = getGraphics();
if (g == null)
g = Env.getGraphics(this);
if (g != null)
fm = g.getFontMetrics(g.getFont()); // the "correct" way
m_dayWidth = 0;
for (int i = 0; i < m_noDays; i++)
{
if (fm != null)
{
String string = getHeading(i);
int width = fm.stringWidth(string);
if (width > m_dayWidth)
m_dayWidth = width;
}
}
m_dayWidth += 20;
if (m_dayWidth < 180) // minimum width
m_dayWidth = 180;
int w = m_noDays * m_dayWidth;
//
Dimension size = new Dimension(w, m_height);
setPreferredSize(size);
setMinimumSize(size);
setMaximumSize(size);
}