本文整理匯總了Java中org.apache.harmony.awt.state.LabelState類的典型用法代碼示例。如果您正苦於以下問題:Java LabelState類的具體用法?Java LabelState怎麽用?Java LabelState使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LabelState類屬於org.apache.harmony.awt.state包,在下文中一共展示了LabelState類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawText
import org.apache.harmony.awt.state.LabelState; //導入依賴的package包/類
public static void drawText(Graphics g, LabelState s) {
String text = s.getText();
if (text == null) {
return;
}
int alignment = s.getAlignment();
g.setColor(s.getTextColor());
g.setFont(s.getFont());
Dimension textSize = s.getTextSize();
Dimension size = s.getSize();
int textCenterX = textSize.width / 2;
int lblCenterX = size.width / 2;
int lblCenterY = size.height / 2;
int baseX = 0;
int margin = (int) (REL_MARGIN * textSize.height / 3);
switch (alignment) {
case Label.LEFT:
baseX = margin;
break;
case Label.CENTER:
baseX = lblCenterX - textCenterX;
break;
case Label.RIGHT:
baseX = size.width - textSize.width - margin;
break;
}
int textCenterY = textSize.height / 2;
int baseY = lblCenterY + textCenterY;
if (s.isEnabled()) {
g.drawString(text, baseX, baseY);
} else {
drawDisabledString(g, text, baseX, baseY);
}
}
示例2: calculate
import org.apache.harmony.awt.state.LabelState; //導入依賴的package包/類
public static void calculate(LabelState s) {
Dimension textSize = getTextSize(s);
Dimension labelSize = new Dimension();
labelSize.width = textSize.width + (int) (2 * REL_MARGIN * textSize.height) + 2 * ABS_MARGIN;
labelSize.height = (int) ((2 * REL_MARGIN + 1) * textSize.height) + 2 * ABS_MARGIN;
s.setDefaultMinimumSize(labelSize);
s.setTextSize(textSize);
}
示例3: drawLabel
import org.apache.harmony.awt.state.LabelState; //導入依賴的package包/類
public void drawLabel(Graphics g, LabelState s) {
drawLabelBackground(g, s);
drawLabelText(g, s);
}
示例4: calculateLabel
import org.apache.harmony.awt.state.LabelState; //導入依賴的package包/類
public void calculateLabel(LabelState s) {
DefaultLabel.calculate(s);
}
示例5: drawLabelBackground
import org.apache.harmony.awt.state.LabelState; //導入依賴的package包/類
protected void drawLabelBackground(Graphics g, LabelState s) {
DefaultLabel.drawBackground(g, s);
}
示例6: drawLabelText
import org.apache.harmony.awt.state.LabelState; //導入依賴的package包/類
protected void drawLabelText(Graphics g, LabelState s) {
DefaultLabel.drawText(g, s);
}
示例7: drawBackground
import org.apache.harmony.awt.state.LabelState; //導入依賴的package包/類
public static void drawBackground(Graphics g, LabelState s) {
Dimension size = s.getSize();
g.setColor(s.getBackground());
g.fillRect(0, 0, size.width, size.height);
}