本文整理汇总了Java中org.apache.pivot.wtk.Insets类的典型用法代码示例。如果您正苦于以下问题:Java Insets类的具体用法?Java Insets怎么用?Java Insets使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Insets类属于org.apache.pivot.wtk包,在下文中一共展示了Insets类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setValueInternal
import org.apache.pivot.wtk.Insets; //导入依赖的package包/类
protected void setValueInternal(Object value) {
if (null == value) {
super.setValueInternal(null);
} else if (value instanceof CharSequence) {
handleAsString(String.valueOf(value));
} else if (value instanceof List) {
handleAsList((List) value);
} else if (value instanceof Map) {
handleAsMap((Map) value);
} else if (value instanceof Number) {
handleAsNumber((Number) value);
} else if (value instanceof Insets) {
super.setValueInternal(value);
} else {
throw illegalValue(value, Insets.class);
}
}
示例2: handleAsString
import org.apache.pivot.wtk.Insets; //导入依赖的package包/类
private void handleAsString(String str) {
if (isBlank(str)) {
super.setValueInternal(null);
return;
}
int t = 0;
int l = 0;
int r = 0;
int b = 0;
String[] parts = str.split(",");
switch (parts.length) {
case 4:
b = parseValue(parts[3]);
case 3:
r = parseValue(parts[2]);
case 2:
l = parseValue(parts[1]);
case 1:
t = parseValue(parts[0]);
super.setValueInternal(new Insets(t, l, r, b));
break;
default:
throw illegalValue(str, Insets.class);
}
}
示例3: handleAsList
import org.apache.pivot.wtk.Insets; //导入依赖的package包/类
private void handleAsList(List<?> list) {
if(list.isEmpty()) {
super.setValueInternal(null);
return;
}
int t = 0;
int l = 0;
int r = 0;
int b = 0;
switch (list.size()) {
case 4:
b = parseValue(list.get(3));
case 3:
r = parseValue(list.get(2));
case 2:
l = parseValue(list.get(1));
case 1:
t = parseValue(list.get(0));
super.setValueInternal(new Insets(t, l, r, b));
break;
default:
throw illegalValue(list, Insets.class);
}
}
示例4: tooltipTriggered
import org.apache.pivot.wtk.Insets; //导入依赖的package包/类
@Override
public void tooltipTriggered(Component component, int x, int y) {
String tooltipText = component.getTooltipText();
if (!isNullOrEmpty(tooltipText)) {
Display display = component.getDisplay();
Point location = component.mapPointToAncestor(display, x, y);
int tooltipX = location.x + 16;
int tooltipY = location.y;
TextArea content = new TextArea();
content.getStyles().put("wrapText", Boolean.TRUE);
content.getStyles().put("margin", new Insets(0));
content.setPreferredWidth(Math.min(display.getWidth() - tooltipX, getStringWidth(tooltipText, (Font) content.getStyles().get("font"))));
content.setText(tooltipText);
Tooltip tooltip = new Tooltip(content);
int tooltipWidth = tooltip.getPreferredWidth();
int tooltipHeight = tooltip.getPreferredHeight();
// ensure tooltip is inside display's bounds
if (tooltipX + tooltipWidth > display.getWidth()) {
tooltipX -= tooltipX + tooltipWidth - display.getWidth();
}
if (tooltipY + tooltipHeight > display.getHeight()) {
tooltipY -= tooltipHeight;
}
tooltip.setLocation(tooltipX, tooltipY);
tooltip.open(component.getWindow());
}
}
示例5: handleAsMap
import org.apache.pivot.wtk.Insets; //导入依赖的package包/类
private void handleAsMap(Map<?, ?> map) {
if(map.isEmpty()) {
super.setValueInternal(null);
return;
}
int t = getMapValue(map, "top", 0);
int l = getMapValue(map, "left", 0);
int r = getMapValue(map, "right", 0);
int b = getMapValue(map, "bottom", 0);
super.setValueInternal(new Insets(t, l, r, b));
}
示例6: parseValue
import org.apache.pivot.wtk.Insets; //导入依赖的package包/类
private int parseValue(Object value) {
if (value instanceof CharSequence) {
return parse(String.valueOf(value));
} else if (value instanceof Number) {
return parse((Number) value);
}
throw illegalValue(value, Insets.class);
}
示例7: parse
import org.apache.pivot.wtk.Insets; //导入依赖的package包/类
private int parse(String val) {
try {
return Integer.parseInt(val.trim());
} catch (NumberFormatException e) {
throw illegalValue(val, Insets.class, e);
}
}
示例8: getMapValue
import org.apache.pivot.wtk.Insets; //导入依赖的package包/类
private int getMapValue(Map<?, ?> map, String key, int defaultValue) {
Object val = map.get(key);
if (null == val) val = map.get(String.valueOf(key.charAt(0)));
if (null == val) {
return defaultValue;
} else if (val instanceof CharSequence) {
return parse(String.valueOf(val));
} else if (val instanceof Number) {
return parse((Number) val);
}
throw illegalValue(map, Insets.class);
}
示例9: getMargin
import org.apache.pivot.wtk.Insets; //导入依赖的package包/类
/**
* Returns the amount of space between the edge of the TextArea and its text
*/
public org.apache.pivot.wtk.Insets getMargin() {
return margin;
}
示例10: setMargin
import org.apache.pivot.wtk.Insets; //导入依赖的package包/类
/**
* Sets the amount of space between the edge of the TextArea and its text
*/
public void setMargin(org.apache.pivot.wtk.Insets margin) {
this.margin = checkNotNull(margin);;
invalidateComponent();
}
示例11: getAsText
import org.apache.pivot.wtk.Insets; //导入依赖的package包/类
public String getAsText() {
if (null == getValue()) return null;
Insets i = (Insets) getValue();
return i.top + ", " + i.left + ", " + i.bottom + ", " + i.right;
}
示例12: handleAsNumber
import org.apache.pivot.wtk.Insets; //导入依赖的package包/类
private void handleAsNumber(Number value) {
int c = parse(value);
super.setValueInternal(new Insets(c, c, c, c));
}