本文整理汇总了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);
}