當前位置: 首頁>>代碼示例>>Java>>正文


Java LabelState類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:mike10004,項目名稱:appengine-imaging,代碼行數:40,代碼來源:DefaultLabel.java

示例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);
    }
 
開發者ID:mike10004,項目名稱:appengine-imaging,代碼行數:12,代碼來源:DefaultLabel.java

示例3: drawLabel

import org.apache.harmony.awt.state.LabelState; //導入依賴的package包/類
public void drawLabel(Graphics g, LabelState s) {
    drawLabelBackground(g, s);
    drawLabelText(g, s);
}
 
開發者ID:mike10004,項目名稱:appengine-imaging,代碼行數:5,代碼來源:Theme.java

示例4: calculateLabel

import org.apache.harmony.awt.state.LabelState; //導入依賴的package包/類
public void calculateLabel(LabelState s) {
    DefaultLabel.calculate(s);
}
 
開發者ID:mike10004,項目名稱:appengine-imaging,代碼行數:4,代碼來源:Theme.java

示例5: drawLabelBackground

import org.apache.harmony.awt.state.LabelState; //導入依賴的package包/類
protected void drawLabelBackground(Graphics g, LabelState s) {
    DefaultLabel.drawBackground(g, s);
}
 
開發者ID:mike10004,項目名稱:appengine-imaging,代碼行數:4,代碼來源:Theme.java

示例6: drawLabelText

import org.apache.harmony.awt.state.LabelState; //導入依賴的package包/類
protected void drawLabelText(Graphics g, LabelState s) {
    DefaultLabel.drawText(g, s);
}
 
開發者ID:mike10004,項目名稱:appengine-imaging,代碼行數:4,代碼來源:Theme.java

示例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);
    }
 
開發者ID:mike10004,項目名稱:appengine-imaging,代碼行數:7,代碼來源:DefaultLabel.java


注:本文中的org.apache.harmony.awt.state.LabelState類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。