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


Java Point類代碼示例

本文整理匯總了Java中org.apache.pivot.wtk.Point的典型用法代碼示例。如果您正苦於以下問題:Java Point類的具體用法?Java Point怎麽用?Java Point使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Point類屬於org.apache.pivot.wtk包,在下文中一共展示了Point類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setValueInternal

import org.apache.pivot.wtk.Point; //導入依賴的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 Point) {
        super.setValueInternal(value);
    } else {
        throw illegalValue(value, Point.class);
    }
}
 
開發者ID:aalmiray,項目名稱:griffon2,代碼行數:18,代碼來源:PointPropertyEditor.java

示例2: handleAsString

import org.apache.pivot.wtk.Point; //導入依賴的package包/類
private void handleAsString(String str) {
    if (isBlank(str)) {
        super.setValueInternal(null);
        return;
    }

    String[] parts = str.split(",");
    switch (parts.length) {
        case 1:
            int s = parseValue(parts[0]);
            super.setValueInternal(new Point(s, s));
            break;
        case 2:
            int x = parseValue(parts[0]);
            int y = parseValue(parts[1]);
            super.setValueInternal(new Point(x, y));
            break;
        default:
            throw illegalValue(str, Point.class);
    }
}
 
開發者ID:aalmiray,項目名稱:griffon2,代碼行數:22,代碼來源:PointPropertyEditor.java

示例3: handleAsList

import org.apache.pivot.wtk.Point; //導入依賴的package包/類
private void handleAsList(List<?> list) {
    if(list.isEmpty()) {
        super.setValueInternal(null);
        return;
    }

    switch (list.size()) {
        case 1:
            int s = parseValue(list.get(0));
            super.setValueInternal(new Point(s, s));
            break;
        case 2:
            int x = parseValue(list.get(0));
            int y = parseValue(list.get(1));
            super.setValueInternal(new Point(x, y));
            break;
        default:
            throw illegalValue(list, Point.class);
    }
}
 
開發者ID:aalmiray,項目名稱:griffon2,代碼行數:21,代碼來源:PointPropertyEditor.java

示例4: tooltipTriggered

import org.apache.pivot.wtk.Point; //導入依賴的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());
    }
}
 
開發者ID:groovejames,項目名稱:groovejames,代碼行數:28,代碼來源:TooltipTableMouseListener.java

示例5: handleAsMap

import org.apache.pivot.wtk.Point; //導入依賴的package包/類
private void handleAsMap(Map<?, ?> map) {
    if(map.isEmpty()) {
        super.setValueInternal(null);
        return;
    }

    int x = getMapValue(map, "x", 0);
    int y = getMapValue(map, "y", 0);
    super.setValueInternal(new Point(x, y));
}
 
開發者ID:aalmiray,項目名稱:griffon2,代碼行數:11,代碼來源:PointPropertyEditor.java

示例6: parseValue

import org.apache.pivot.wtk.Point; //導入依賴的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, Point.class);
}
 
開發者ID:aalmiray,項目名稱:griffon2,代碼行數:9,代碼來源:PointPropertyEditor.java

示例7: parse

import org.apache.pivot.wtk.Point; //導入依賴的package包/類
private int parse(String val) {
    try {
        return Integer.parseInt(val.trim());
    } catch (NumberFormatException e) {
        throw illegalValue(val, Point.class, e);
    }
}
 
開發者ID:aalmiray,項目名稱:griffon2,代碼行數:8,代碼來源:PointPropertyEditor.java

示例8: getMapValue

import org.apache.pivot.wtk.Point; //導入依賴的package包/類
private int getMapValue(Map<?, ?> map, String key, int defaultValue) {
    Object val = map.get(key);
    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, Point.class);
}
 
開發者ID:aalmiray,項目名稱:griffon2,代碼行數:12,代碼來源:PointPropertyEditor.java

示例9: getAsText

import org.apache.pivot.wtk.Point; //導入依賴的package包/類
public String getAsText() {
    if (null == getValue()) return null;
    Point p = (Point) getValue();
    return p.x + ", " + p.y;
}
 
開發者ID:aalmiray,項目名稱:griffon2,代碼行數:6,代碼來源:PointPropertyEditor.java

示例10: handleAsNumber

import org.apache.pivot.wtk.Point; //導入依賴的package包/類
private void handleAsNumber(Number value) {
    int s = parse(value);
    super.setValueInternal(new Point(s, s));
}
 
開發者ID:aalmiray,項目名稱:griffon2,代碼行數:5,代碼來源:PointPropertyEditor.java


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