本文整理匯總了Java中processing.core.PGraphics.textWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java PGraphics.textWidth方法的具體用法?Java PGraphics.textWidth怎麽用?Java PGraphics.textWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類processing.core.PGraphics
的用法示例。
在下文中一共展示了PGraphics.textWidth方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawAttribution
import processing.core.PGraphics; //導入方法依賴的package包/類
private void drawAttribution(PGraphics pGraphics) {
String name = "(C) OpenStreetMap contributors - www.openstreetmap.org/copyright";
float x = 580;
float y = 680;
float spaceWidth = pGraphics.textWidth(" ");
float textHeight = pGraphics.textAscent() + pGraphics.textDescent();
float toolTipWidth = pGraphics.textWidth(" " + name + " ");
float toolTipHeight = textHeight;
pGraphics.pushStyle();
pGraphics.noStroke();
pGraphics.fill(255, 255, 255, 30);
pGraphics.rect(x, y, toolTipWidth, toolTipHeight);
pGraphics.fill(0, 0, 0);
pGraphics.text(name, x + spaceWidth, y + pGraphics.textAscent());
pGraphics.popStyle();
}
示例2: drawToolTip
import processing.core.PGraphics; //導入方法依賴的package包/類
private void drawToolTip(PGraphics pGraphics, float x, float y) {
x = 20;
y = 20;
float spaceWidth = pGraphics.textWidth(" ");
float textHeight = pGraphics.textAscent() + pGraphics.textDescent();
float toolTipWidth = pGraphics.textWidth(name) * 11 / 10;
int toolTipLines = name.length() - name.replace("\n", "").length() + 1;
float toolTipHeight = textHeight * toolTipLines;
pGraphics.pushStyle();
pGraphics.noStroke();
pGraphics.fill(255, 255, 255);
pGraphics.rect(x, y, toolTipWidth, toolTipHeight);
pGraphics.fill(0, 0, 0);
pGraphics.text(name, x + spaceWidth, y + textHeight);
pGraphics.popStyle();
}
示例3: apply
import processing.core.PGraphics; //導入方法依賴的package包/類
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
List<Object> params = ProcessingUtil.parseParams(stack, 1);
PGraphics pg = (PGraphics) params.get(0);
double width = pg.textWidth(params.get(1).toString());
stack.push(pg);
stack.push(width);
return stack;
}