本文整理汇总了Java中javafx.scene.canvas.GraphicsContext.fillText方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsContext.fillText方法的具体用法?Java GraphicsContext.fillText怎么用?Java GraphicsContext.fillText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.canvas.GraphicsContext
的用法示例。
在下文中一共展示了GraphicsContext.fillText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawYValueBox
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void drawYValueBox() {
if (showMouseHoverIndicator.getValue()){
double y = mouseY.getValue();
y = y - 10;
double x = 0;
double wd = 150;
double ht = 18;
if (mouseY == null) {
return;
}
int yIntPos = (int)Math.round(mouseY.getValue());
Float yValue = this.getValueByYPos(yIntPos);
if ( yValue != null && yValue != 0){
String strVolume = String.format("%.2f", yValue);
GraphicsContext gc = getGraphicsContext2D();
gc.setFill(Color.web("#010a23"));
gc.fillRect(x, y, wd, ht);
gc.setFill(Color.web("#4bf221"));
gc.fillText(strVolume, x + 13, y+13);
}
}
}
示例2: drawTimeBox
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
* Draw little time box to indicate exactly the date time when
* showMouseHoverIndicator is on
*/
public void drawTimeBox() {
if (showMouseHoverIndicator.getValue()){
double x = mouseX.getValue();
double w = 45;
x = x - w;
double wd = 2 * w;
double hi = 20;
Calendar curDate = getDayByXPos(mouseX.getValue());
if (curDate != null) {
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
String strDateLabel = sf.format(curDate.getTime());
GraphicsContext gc = getGraphicsContext2D();
gc.setFill(Color.web("#010a23"));
gc.fillRect(x, 0, wd, hi);
gc.setFill(Color.web("#4bf221"));
gc.fillText(strDateLabel, x+14, 14);
}
}
}
示例3: drawYValueBox
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void drawYValueBox() {
if (showMouseHoverIndicator.getValue()){
double y = mouseY.getValue();
y = y - 10;
double x = 0;
double wd = 150;
double ht = 18;
if (mouseY == null) {
return;
}
int yIntPos = (int)Math.round(mouseY.getValue());
Float yValue = this.getValueByYPos(yIntPos);
if ( yValue != null && yValue != 0){
String strVolume = String.format("%.4f", yValue);
GraphicsContext gc = getGraphicsContext2D();
gc.setFill(Color.web("#010a23"));
gc.fillRect(x, y, wd, ht);
gc.setFill(Color.web("#4bf221"));
gc.fillText(strVolume, x + 13, y+13);
}
}
}
示例4: drawYValueBox
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
* Draw little time box to indicate exactly the date time when
* showMouseHoverIndicator is on
*/
@Override
public void drawYValueBox() {
if (showMouseHoverIndicator.getValue()){
double y = mouseY.getValue();
y = y - 10;
double x = 0;
double wd = 150;
double ht = 18;
if (mouseY == null) {
return;
}
int yIntPos = (int)Math.round(mouseY.getValue());
Float yValue = this.getValueByYPos(yIntPos);
if ( yValue != null && yValue != 0){
String strDateLabel = Float.toString(yValue);
GraphicsContext gc = getGraphicsContext2D();
gc.setFill(Color.web("#010a23"));
gc.fillRect(x, y, wd, ht);
//gc.setFill(Color.web("#77e2f9"));
gc.setFill(Color.web("#4bf221"));
gc.fillText(strDateLabel, x + 13, y+13);
}
}
}
示例5: drawNumbers
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
* Draw numbers along the X axis for a previously drawn grid. Each number
* aligns with the corresponding intersection on the grid.
* @param gc Graphics context
* @param startX Start point on x axis
* @param startY Start point on y axis
* @param rows Number of rows
* @param columns Number of columns
* @param cellSize Size of each cell in the grid
* @param distance Draw distance away from the left of the grid
*/
private void drawNumbers(GraphicsContext gc, double startX, double
startY, int rows, int columns, double cellSize, double distance) {
gc.save();
gc.setFont(BOARD_FONT);
gc.setFill(Color.rgb(0,0,0, 0.75));
for(int i = 0; i < size; i++) {
double offset = i*cellSize;
gc.setTextAlign(TextAlignment.CENTER);
gc.setTextBaseline(VPos.CENTER);
gc.fillText(Integer.toString(rows + 1 - i), startX - distance,
startY + offset);
}
gc.restore();
}
示例6: showPlayerInfo
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void showPlayerInfo(GraphicsContext gc) {
for (Tank tank : framework.getTanks()) {
int width = tank.getId().name().length() * 7 + 10;
gc.setFill(Color.LIGHTGRAY);
gc.fillRoundRect(tank.getX() - width / 2, tank.getY() - 65, width, 25, 4, 4);
gc.setFill(Color.WHITESMOKE);
gc.fillText(tank.getId().name(), tank.getX() - width / 2 + 5, tank.getY() - 50);
}
}
示例7: drawLetters
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
* Draw letters along the Y axis for a previously drawn grid. Each letter
* aligns with the corresponding intersection on the grid.
* @param gc Graphics context
* @param startX Start point on x axis
* @param startY Start point on y axis
* @param rows Number of rows
* @param columns Number of columns
* @param cellSize Size of each cell in the grid
* @param distance Draw distance away from the bottom of the grid
*/
private void drawLetters(GraphicsContext gc, double startX, double
startY, int rows, int columns, double cellSize, double distance) {
gc.save();
gc.setFont(BOARD_FONT);
gc.setFill(Color.rgb(0,0,0, 0.75));
for(int i = 0; i < size; i++) {
double offset = i*cellSize;
gc.setTextAlign(TextAlignment.CENTER);
gc.setTextBaseline(VPos.CENTER);
gc.fillText(Character.toString((char)('A' + i)), startX + offset,
startY + cellSize*(rows) + distance);
}
gc.restore();
}
示例8: drawTextWithBackground
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public static final void drawTextWithBackground(final GraphicsContext CTX, final String TEXT, final Font FONT, final Color TEXT_BACKGROUND, final Color TEXT_FILL, final double X, final double Y) {
CtxDimension dim = getTextDimension(TEXT, FONT);
double textWidth = dim.getWidth() * 1.2;
double textHeight = dim.getHeight();
CTX.save();
CTX.setFont(FONT);
CTX.setTextBaseline(VPos.CENTER);
CTX.setTextAlign(TextAlignment.CENTER);
CTX.setFill(TEXT_BACKGROUND);
CTX.fillRect(X - textWidth * 0.5, Y - textHeight * 0.5, textWidth, textHeight);
CTX.setFill(TEXT_FILL);
CTX.fillText(TEXT, X, Y);
CTX.restore();
}
示例9: drawTextTick
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void drawTextTick(double x, double y, double value) {
GraphicsContext gc = getGraphicsContext2D();
double bigTickLength = 10; //Big Tick
//Draw ticks and draw texts
gc.setLineWidth(0.1);
gc.setStroke(ChartTickColorProperty.getValue());
gc.strokeLine(x, y, x + bigTickLength, y);
String strValue = "";
if (value >= 0 && value <= 0.01) {
strValue = String.format("%.4f", value);
}
else if (value > 0.01 && value <= 0.1) {
strValue = String.format("%.3f", value);
}
else if (value > 0.1 && value <= 1.0) {
strValue = String.format("%.3f", value);
}
else if (value > 1.0 && value <= 10.0) {
strValue = String.format("%.2f", value);
}
else {
strValue = String.format("%.2f", value);
}
gc.setFill(ChartTickColorProperty.getValue());
gc.fillText(strValue, x + bigTickLength + 3, y + 5);
}
示例10: drawTextTick
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void drawTextTick(double x, double y, double value) {
GraphicsContext gc = getGraphicsContext2D();
double bigTickLength = 10; //Big Tick
//Draw ticks and draw texts
gc.setLineWidth(0.1);
gc.setStroke(ChartTickColorProperty.getValue());
gc.strokeLine(x, y, x + bigTickLength, y);
String strValue = "";
if (value >= 0 && value <= 0.01) {
strValue = String.format("%.4f m", value);
}
else if (value > 0.01 && value <= 0.1) {
strValue = String.format("%.3f m", value);
}
else if (value > 0.1 && value <= 1.0) {
strValue = String.format("%.3f m", value);
}
else if (value > 1.0 && value <= 10.0) {
strValue = String.format("%.2f m", value);
}
else {
strValue = String.format("%.2f m", value);
}
gc.setFill(ChartTickColorProperty.getValue());
gc.fillText(strValue, x + bigTickLength + 3, y + 5);
}
示例11: drawTextTick
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
* Draw text tick
* @param x POS
* @param y POS
* @param value - the text to be drawn
*/
@Override
public void drawTextTick(double x, double y, double value) {
GraphicsContext gc = getGraphicsContext2D();
double bigTickLength = 10; //Big Tick
//Draw ticks and draw texts
gc.setLineWidth(0.1);
gc.setStroke(ChartTickColorProperty.getValue());
gc.strokeLine(x, y, x + bigTickLength, y);
String strValue = "";
if (value >= 0 && value <= 0.01) {
strValue = String.format("%.4f", value);
}
else if (value > 0.01 && value <= 0.1) {
strValue = String.format("%.3f", value);
}
else if (value > 0.1 && value <= 1.0) {
strValue = String.format("%.3f", value);
}
else if (value > 1.0 && value <= 10.0) {
strValue = String.format("%.2f", value);
}
else {
strValue = String.format("%.2f", value);
}
gc.setFill(ChartTickColorProperty.getValue());
gc.fillText(strValue, x + bigTickLength + 3, y + 5);
}
示例12: paint
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
*
* @param g2d
*/
@Override
public void paint(GraphicsContext g2d) {
super.paint(g2d);
g2d.setStroke(Paint.valueOf("BLACK"));
g2d.setLineWidth(0.5);
g2d.setFill(Paint.valueOf("Red"));
// g2d.fillText(massKey, 10, 15);
int index = 0;
for (double[] myOnPeakData : allMeasuredTrimMasses) {
double[] myOnPeakNormalizedAquireTimes = allMeasuredTrimMassesTimes.get(index);
g2d.beginPath();
g2d.moveTo(mapX(myOnPeakNormalizedAquireTimes[0]), mapY(myOnPeakData[0]));
for (int i = 0; i < myOnPeakData.length; i++) {
// line tracing through points
g2d.lineTo(mapX(myOnPeakNormalizedAquireTimes[i]), mapY(myOnPeakData[i]));
// // every 6 scans
// if ((i + 1) % 6 == 0) {
// g2d.setStroke(Paint.valueOf("Red"));
// g2d.setLineWidth(0.5);
//
// if (i < (myOnPeakData.length - 1)) {
// double runX = mapX((myOnPeakNormalizedAquireTimes[i] + myOnPeakNormalizedAquireTimes[i + 1]) / 2.0);
// g2d.strokeLine(runX, 0, runX, height);
// }
//
// g2d.setFont(Font.font("Lucida Sans", 8));
// g2d.fillText(String.valueOf((int) ((i + 1) / 6)), mapX(myOnPeakNormalizedAquireTimes[i - 4]), height - 2);
// g2d.setStroke(Paint.valueOf("BLACK"));
// g2d.setLineWidth(0.5);
// }
g2d.strokeOval(mapX(myOnPeakNormalizedAquireTimes[i]) - 1, mapY(myOnPeakData[i]) - 1, 2, 2);
}
g2d.stroke();
}
// tics
if (tics != null) {
for (int i = 0; i < tics.length; i++) {
try {
g2d.strokeLine( //
mapX(minX), mapY(tics[i].doubleValue()), mapX(maxX), mapY(tics[i].doubleValue()));
g2d.fillText(tics[i].toPlainString(),//
(float) mapX(minX) - 35f,
(float) mapY(tics[i].doubleValue()) + 2.9f);
} catch (Exception e) {
}
}
}
}
示例13: render
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void render(GraphicsContext gc)
{
gc.setFill(Color.RED);
gc.fillText(text, 50, 50);
}
示例14: onRender
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
protected void onRender(GraphicsContext g)
{
g.setFill(Color.BLACK);
g.fillText(this.text, this.textX, this.textY);
}
示例15: renderHotkey
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void renderHotkey(GraphicsContext g)
{
g.setFill(Color.BLACK);
g.fillText(this.hotkey.getName(), this.x + this.width - 5, this.y + this.height + 5);
}