本文整理匯總了Java中com.google.gwt.canvas.dom.client.Context2d.setTextBaseline方法的典型用法代碼示例。如果您正苦於以下問題:Java Context2d.setTextBaseline方法的具體用法?Java Context2d.setTextBaseline怎麽用?Java Context2d.setTextBaseline使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.canvas.dom.client.Context2d
的用法示例。
在下文中一共展示了Context2d.setTextBaseline方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: draw
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void draw(Context2d context, DisplayArea area, OnDrawnCallback cb) {
double zoom = area.zoom();
context.save();
context.translate(-area.viewportLeft(), -area.viewportTop());
context.scale(zoom, zoom);
// outline
int[][] coords = el.coordinates();
context.beginPath();
context.moveTo(coords[0][0], coords[0][1]);
for (int i = 1; i < coords.length; i++) {
context.lineTo(coords[i][0], coords[i][1]);
}
context.setLineWidth(6);
context.stroke();
context.setGlobalAlpha(0.3);
context.setFillStyle("white");
context.fill();
context.setGlobalAlpha(1.0);
context.closePath();
// text
context.setFillStyle("black");
context.setFont("bold 60px sans-serif");
context.setTextBaseline("top");
context.fillText(el.text(), el.baseLeft(), el.baseTop(), el.baseWidth());
context.restore();
cb.onDrawn();
}
示例2: renderText
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private void renderText(Context2d g) {
if (null != text) {
g.setTextAlign(TextAlign.LEFT);
g.setTextBaseline(TextBaseline.MIDDLE);
g.setFont("bold 18px sans-serif");
g.setFillStyle("#000");
g.fillText(text, 10, height / 2);
}
}
示例3: render
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void render(Context2d g, double timestamp) {
g.save();
{
if (textClip == TextClip.HIDDEN) {
g.beginPath();
g.rect(0, 0, width, height);
g.clip();
}
setTextAlign(g, textAlign, width);
setTextBaseline(g, textBaseline, height);
g.setFont(font);
g.setTextAlign(textAlign);
g.setTextBaseline(textBaseline);
g.setFillStyle(color);
String text = this.text;
if (textClip == TextClip.ELLIPSE) {
text = fitEllipse(g, text, width);
}
if (textClip == TextClip.FIT) {
g.fillText(text, 0, 0, width);
} else {
g.fillText(text, 0, 0);
}
}
g.restore();
}
示例4: configContext
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
static void configContext(Context2d ctx, TextFormat format) {
Font font = getFont(format);
ctx.setFont(HtmlFont.toCSS(font));
ctx.setTextBaseline(Context2d.TextBaseline.TOP);
}
示例5: drawString
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private void drawString(Context2d ctx,String theString, double x, double y)
{
ctx.setTextAlign(Context2d.TextAlign.CENTER);
ctx.setTextBaseline(Context2d.TextBaseline.MIDDLE);
ctx.fillText(theString, x, y);
}
示例6: draw
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void draw(Context2d context, DisplayArea area, OnDrawnCallback cb) {
double zoom = area.zoom();
context.save();
context.translate(-area.viewportLeft(), -area.viewportTop());
context.scale(zoom, zoom);
// Draw outline
int[][] coords = el.coordinates();
context.beginPath();
context.moveTo(coords[0][0], coords[0][1]);
for (int i = 1; i < coords.length; i++) {
context.lineTo(coords[i][0], coords[i][1]);
}
context.setLineWidth(6);
context.stroke();
context.setGlobalAlpha(0.3);
context.setFillStyle("white");
context.fill();
context.setGlobalAlpha(1.0);
context.closePath();
// Write text
context.setFillStyle("black");
context.setFont("bold 60px sans-serif");
context.setTextBaseline("top");
if (el.text().contains("<") && el.text().contains(">")) {
context.fillText(el.label() + "...", el.baseLeft(), el.baseTop(), el.baseWidth());
el.neverShowPopup(false);
} else {
String[] words = el.text().split(" ");
String line = "";
int y = el.baseTop();
for (int i = 0; i < words.length; i++) {
String test_line = line + words[i] + " ";
if (context.measureText(test_line).getWidth() > el.baseWidth() && i > 0
|| words[i].contains("\n")) {
context.fillText(line, el.baseLeft(), y);
y += step;
line = words[i] + " ";
if (y + step > el.baseTop() + el.baseHeight()) {
context.restore();
el.neverShowPopup(false);
cb.onDrawn();
return;
}
} else {
line = test_line;
}
}
context.fillText(line, el.baseLeft(), y);
el.neverShowPopup(true);
}
context.restore();
cb.onDrawn();
}