本文整理汇总了Java中com.codename1.ui.Label.getStyle方法的典型用法代码示例。如果您正苦于以下问题:Java Label.getStyle方法的具体用法?Java Label.getStyle怎么用?Java Label.getStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.codename1.ui.Label
的用法示例。
在下文中一共展示了Label.getStyle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawLabelString
import com.codename1.ui.Label; //导入方法依赖的package包/类
/**
* Implements the drawString for the text component and adjust the valign
* assuming the icon is in one of the sides
*/
private int drawLabelString(Graphics g, Label l, String text, int x, int y, int textSpaceW) {
Style style = l.getStyle();
int cx = g.getClipX();
int cy = g.getClipY();
int cw = g.getClipWidth();
int ch = g.getClipHeight();
//g.pushClip();
g.clipRect(x, cy, textSpaceW, ch);
if (l.isTickerRunning()) {
Font font = style.getFont();
if (l.getShiftText() > 0) {
if (l.getShiftText() > textSpaceW) {
l.setShiftText(x - l.getX() - l.getStringWidth(font));
}
} else if (l.getShiftText() + l.getStringWidth(font) < 0) {
l.setShiftText(textSpaceW);
}
}
int drawnW = drawLabelText(g, l, text, x, y, textSpaceW);
g.setClip(cx, cy, cw, ch);
//g.popClip();
return drawnW;
}
示例2: drawLabelString
import com.codename1.ui.Label; //导入方法依赖的package包/类
/**
* Implements the drawString for the text component and adjust the valign
* assuming the icon is in one of the sides
*/
private int drawLabelString(Graphics g, Label l, String text, int x, int y, int textSpaceW) {
Style style = l.getStyle();
int cx = g.getClipX();
int cy = g.getClipY();
int cw = g.getClipWidth();
int ch = g.getClipHeight();
//g.pushClip();
g.clipRect(x, cy, textSpaceW, ch);
if (l.isTickerRunning()) {
if (l.getShiftText() > 0) {
if (l.getShiftText() > textSpaceW) {
l.setShiftText(x - l.getX() - style.getFont().stringWidth(text));
}
} else if (l.getShiftText() + style.getFont().stringWidth(text) < 0) {
l.setShiftText(textSpaceW);
}
}
int drawnW = drawLabelText(g, l, text, x, y, textSpaceW);
g.setClip(cx, cy, cw, ch);
//g.popClip();
return drawnW;
}
示例3: getPreferredSize
import com.codename1.ui.Label; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
private Dimension getPreferredSize(Label l, Image[] icons, Image stateImage) {
int prefW = 0;
int prefH = 0;
Style style = l.getStyle();
int gap = l.getGap();
int ilen = icons.length;
for (int i = 0; i < ilen; i++) {
Image icon = icons[i];
if (icon != null) {
prefW = Math.max(prefW, icon.getWidth());
prefH = Math.max(prefH, icon.getHeight());
}
}
String text = l.getText();
Font font = style.getFont();
if (font == null) {
System.out.println("Missing font for " + l);
font = Font.getDefaultFont();
}
if (text != null && text.length() > 0) {
//add the text size
switch (l.getTextPosition()) {
case Label.LEFT:
case Label.RIGHT:
prefW += font.stringWidth(text);
prefH = Math.max(prefH, font.getHeight());
break;
case Label.BOTTOM:
case Label.TOP:
prefW = Math.max(prefW, font.stringWidth(text));
prefH += font.getHeight();
break;
}
}
//add the state image(relevant for CheckBox\RadioButton)
if (stateImage != null) {
prefW += (stateImage.getWidth() + gap);
prefH = Math.max(prefH, stateImage.getHeight());
}
if (icons[0] != null && text != null && text.length() > 0) {
switch (l.getTextPosition()) {
case Label.LEFT:
case Label.RIGHT:
prefW += gap;
break;
case Label.BOTTOM:
case Label.TOP:
prefH += gap;
break;
}
}
if(l.isShowEvenIfBlank()) {
prefH += style.getVerticalPadding();
prefW += style.getHorizontalPadding();
} else {
if (prefH != 0) {
prefH += style.getVerticalPadding();
}
if (prefW != 0) {
prefW += style.getHorizontalPadding();
}
}
if(style.getBorder() != null) {
prefW = Math.max(style.getBorder().getMinimumWidth(), prefW);
prefH = Math.max(style.getBorder().getMinimumHeight(), prefH);
}
if(isBackgroundImageDetermineSize() && style.getBgImage() != null) {
prefW = Math.max(style.getBgImage().getWidth(), prefW);
prefH = Math.max(style.getBgImage().getHeight(), prefH);
}
return new Dimension(prefW, prefH);
}
示例4: getPreferredSize
import com.codename1.ui.Label; //导入方法依赖的package包/类
/**
* @inheritDoc
*/
private Dimension getPreferredSize(Label l, Image[] icons, Image stateImage) {
int prefW = 0;
int prefH = 0;
Style style = l.getStyle();
int gap = l.getGap();
for (int i = 0; i < icons.length; i++) {
Image icon = icons[i];
if (icon != null) {
prefW = Math.max(prefW, icon.getWidth());
prefH = Math.max(prefH, icon.getHeight());
}
}
String text = l.getText();
Font font = style.getFont();
if (font == null) {
System.out.println("Missing font for " + l);
font = Font.getDefaultFont();
}
if (text != null && text.length() > 0) {
//add the text size
switch (l.getTextPosition()) {
case Label.LEFT:
case Label.RIGHT:
prefW += font.stringWidth(text);
prefH = Math.max(prefH, font.getHeight());
break;
case Label.BOTTOM:
case Label.TOP:
prefW = Math.max(prefW, font.stringWidth(text));
prefH += font.getHeight();
break;
}
}
//add the state image(relevant for CheckBox\RadioButton)
if (stateImage != null) {
prefW += (stateImage.getWidth() + gap);
prefH = Math.max(prefH, stateImage.getHeight());
}
if (icons[0] != null && text != null && text.length() > 0) {
switch (l.getTextPosition()) {
case Label.LEFT:
case Label.RIGHT:
prefW += gap;
break;
case Label.BOTTOM:
case Label.TOP:
prefH += gap;
break;
}
}
if (prefH != 0) {
prefH += (style.getPadding(false, Component.TOP) + style.getPadding(false, Component.BOTTOM));
}
if (prefW != 0) {
prefW += (style.getPadding(l.isRTL(), Component.RIGHT) + style.getPadding(l.isRTL(), Component.LEFT));
}
if(style.getBorder() != null) {
prefW = Math.max(style.getBorder().getMinimumWidth(), prefW);
prefH = Math.max(style.getBorder().getMinimumHeight(), prefH);
}
if(isBackgroundImageDetermineSize() && style.getBgImage() != null) {
prefW = Math.max(style.getBgImage().getWidth(), prefW);
prefH = Math.max(style.getBgImage().getHeight(), prefH);
}
return new Dimension(prefW, prefH);
}