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


Java TextAlignment類代碼示例

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


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

示例1: makeStatsPane

import javafx.scene.text.TextAlignment; //導入依賴的package包/類
private void makeStatsPane(Map<String, String> stats) {
	myStats = new VBox(5);
	for(String statName : stats.keySet()){
		Text nameAndValue = new Text(statName + ": " + stats.get(statName));
	
		//TODO: set text size 
		TextFlow wrapper = new TextFlow(nameAndValue);
		wrapper.setTextAlignment(TextAlignment.LEFT);
		wrapper.getStylesheets().add("resources/socialStyle.css");
		wrapper.getStyleClass().add("textfill");
		myStats.getChildren().add(wrapper);
	}
	myStats.getStylesheets().add("resources/socialStyle.css");
	myStats.getStyleClass().add("statsbox");
	
}
 
開發者ID:LtubSalad,項目名稱:voogasalad-ltub,代碼行數:17,代碼來源:GameStatsView.java

示例2: settingTab

import javafx.scene.text.TextAlignment; //導入依賴的package包/類
public void settingTab(Tab tab, String CategoryName) {
    AnchorPane content = (AnchorPane) tab.getContent();
    ArrayList singleList = getItemListByCategory(CategoryName);
    for (int i = 0; i < singleList.size(); i++) {
        DAOItem temp = (DAOItem) singleList.get(i);
        int indexX = i % 4;
        int indexY = i / 4;
        Button button = new Button();
        button.setPrefWidth(buttonSize);
        button.setPrefHeight(buttonSize);
        button.setLayoutX(startX + indexX * gap + (buttonSize * indexX));
        button.setLayoutY(startY + indexY * gap + (buttonSize * indexY));
        button.setText(temp.getItemName() + "\n" + "(" + temp.getItemPrice() + ")");
        button.setTextAlignment(TextAlignment.CENTER);
        button.setOnAction(this::menuItemAction);
        button.setWrapText(true);
        button.setId(temp.getItemName());
        content.getChildren().add(button);
    }
}
 
開發者ID:Jinsu-L,項目名稱:CNU_TermProject_SoftwareEngineering,代碼行數:21,代碼來源:ShoppingBasketController.java

示例3: createLED

import javafx.scene.text.TextAlignment; //導入依賴的package包/類
private LED createLED(int number)
{
	String labelText = Integer.toString(number);
	Label ledLabel = new Label(labelText);
	ledLabel.setFont(new Font(FONT_NAME, FONT_SIZE));
	ledLabel.setTextAlignment(TextAlignment.CENTER);
	ledLabel.setTextFill(FONT_COLOR);
	
	LED led = new LED();
	led.setMinHeight(DEFAULT_SIZE);
	led.setPrefWidth(DEFAULT_SIZE);
	led.setCenter(ledLabel);
	updateLEDStyle(led);
	
	return led;
}
 
開發者ID:dhawal9035,項目名稱:WebPLP,代碼行數:17,代碼來源:LEDDisplay.java

示例4: createSwitch

import javafx.scene.text.TextAlignment; //導入依賴的package包/類
private Switch createSwitch(int index)
{
	Switch button = new Switch();
	button.setFont(new Font(FONT_NAME, FONT_SIZE));
	button.setTextAlignment(TextAlignment.CENTER);
	button.setTextFill(FONT_COLOR);
	button.setPrefHeight(DEFAULT_SIZE);
	button.setPrefWidth(DEFAULT_SIZE);
	
	String labelText = Integer.toString(index);
	button.setText(labelText);
	updateSwitchStyle(button);
	
	button.setOnAction((event) -> toggle(button));
	
	return button;
}
 
開發者ID:dhawal9035,項目名稱:WebPLP,代碼行數:18,代碼來源:SwitchesDisplay.java

示例5: drawNumbers

import javafx.scene.text.TextAlignment; //導入依賴的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();
}
 
開發者ID:haslam22,項目名稱:gomoku,代碼行數:26,代碼來源:BoardPane.java

示例6: IndexTableCell

import javafx.scene.text.TextAlignment; //導入依賴的package包/類
/**
 * IndexTableCell
 * @param tableView the table the index-cell should be attached to. This value is required for
 *                  displaying the comment icon.
 */
public IndexTableCell(TableView tableView) {
  super();
  this.tableView = tableView;
  ChangeListener<Number> indexChangeListener = (observableValue, oldIndex, newIndexNumber) -> {
    int newIndex = newIndexNumber.intValue();
    if (newIndex < 0) {
      return;
    }
    icon.visibleProperty().bind(getCommentPropertyByIndex(newIndex).isEmpty().not());
    tooltip.textProperty().bind(getCommentPropertyByIndex(newIndex));
  };
  indexChangeListener.changed(null, 0, this.getIndex());
  this.indexProperty().addListener(indexChangeListener);

  this.setGraphic(icon);
  this.setTextAlignment(TextAlignment.RIGHT);
  this.setTooltip(tooltip);
}
 
開發者ID:VerifAPS,項目名稱:stvs,代碼行數:24,代碼來源:IndexTableCell.java

示例7: initGraphics

import javafx.scene.text.TextAlignment; //導入依賴的package包/類
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 ||
        Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    getStyleClass().add("coxcomb-chart");

    popup = new InfoPopup();

    canvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctx    = canvas.getGraphicsContext2D();

    ctx.setLineCap(StrokeLineCap.BUTT);
    ctx.setTextBaseline(VPos.CENTER);
    ctx.setTextAlign(TextAlignment.CENTER);

    pane = new Pane(canvas);

    getChildren().setAll(pane);
}
 
開發者ID:HanSolo,項目名稱:charts,代碼行數:26,代碼來源:CoxcombChart.java

示例8: initGraphics

import javafx.scene.text.TextAlignment; //導入依賴的package包/類
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 ||
        Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    canvas = new Canvas(PREFERRED_HEIGHT, PREFERRED_HEIGHT);
    ctx    = canvas.getGraphicsContext2D();
    ctx.setTextAlign(TextAlignment.LEFT);
    ctx.setTextBaseline(VPos.CENTER);

    pane   = new Pane(canvas);

    getChildren().setAll(pane);
}
 
開發者ID:HanSolo,項目名稱:charts,代碼行數:20,代碼來源:LegendItem.java

示例9: drawDataPoints

import javafx.scene.text.TextAlignment; //導入依賴的package包/類
private void drawDataPoints() {
    ctx.setTextAlign(TextAlignment.CENTER);
    ctx.setTextBaseline(VPos.CENTER);
    ctx.setFont(Font.font(size * 0.0175));

    for (int i = 0 ; i < points.size() ; i++) {
        DataPoint point = points.get(i);

        ctx.setFill(Color.rgb(255, 255, 255, 0.5));
        ctx.fillOval(point.getX() - 8, point.getY() - 8, 16, 16);

        //ctx.setStroke(getUseColorMapping() ? getColorForValue(point.getValue(), 1) : getColorForValue(point.getValue(), isDiscreteColors()));
        ctx.setStroke(Color.BLACK);
        ctx.strokeOval(point.getX() - 8, point.getY() - 8, 16, 16);

        ctx.setFill(Color.BLACK);
        ctx.fillText(Long.toString(Math.round(point.getValue())), point.getX(), point.getY(), 16);
    }
}
 
開發者ID:HanSolo,項目名稱:charts,代碼行數:20,代碼來源:AreaHeatMap.java

示例10: redraw

import javafx.scene.text.TextAlignment; //導入依賴的package包/類
private void redraw() {
    ctx.clearRect(0, 0, width, height);
    paths.forEach((path, plotItem) -> path.draw(ctx, true, true));
    Color             textColor      = getTextColor();
    int               noOfCategories = chartItems.size();
    DateTimeFormatter formatter      = getCategory().formatter();

    for (int category = 0 ; category < noOfCategories ; category++) {
        List<ChartItemData> itemDataInCategory = itemsPerCategory.get(category);

        // Go through all item data of the current category
        for (ChartItemData itemData : itemDataInCategory) {
            ChartItem item      = itemData.getChartItem();
            CtxBounds bounds    = itemData.getBounds();
            Color     itemColor = item.getFill();

            // Draw item boxes with their labels
            ctx.setFill(itemColor);
            ctx.fillRect(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight());
            ctx.setLineWidth(0);
            ctx.setStroke(itemColor);
            ctx.strokeRect(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight());

            if (item.getValue() > 1) {
                ctx.setFill(textColor);
                ctx.setTextAlign(category == noOfCategories ? TextAlignment.RIGHT : TextAlignment.LEFT);
                ctx.fillText(item.getName(), itemData.getTextPoint().getX(), itemData.getTextPoint().getY(), bounds.getWidth());
            }
        }
        // Draw category text
        ChartItemData firstItem = itemDataInCategory.get(0);
        ctx.fillText(formatter.format(firstItem.getLocalDate()), firstItem.getTextPoint().getX(), reducedHeight + size * 0.02, firstItem.bounds.getWidth());
    }
}
 
開發者ID:HanSolo,項目名稱:charts,代碼行數:35,代碼來源:StreamChart.java

示例11: getGraphic

import javafx.scene.text.TextAlignment; //導入依賴的package包/類
@Override
public Node getGraphic() {

    Text t = new Text();
    t.setFill(Color.WHITE);
    t.setFont(Font.font(ExternalFonts.ROBOTOBOLD, FontWeight.BOLD, 10.0));
    TextFlow tf = new TextFlow(t);
    tf.setPrefWidth(55);
    tf.setTextAlignment(TextAlignment.CENTER);
    tf.setPadding(new Insets(2, 5, 2, 5));

    if ("Subscription".equals(getType())) {
        t.setText("SUB");
        tf.setStyle("-fx-background-color: #001A80; -fx-background-radius: 12px;");
    } else if ("Publication".equals(getType())) {
        t.setText("PUB");
        tf.setStyle("-fx-background-color: #4D001A; -fx-background-radius: 12px;");
    } else { // "Publication/Subscription"
        t.setText("P/SUB");
        tf.setStyle("-fx-background-color: #003300; -fx-background-radius: 12px;");
    }
    return tf;
}
 
開發者ID:adrianromero,項目名稱:helloiot,代碼行數:24,代碼來源:TopicInfoEdit.java

示例12: render

import javafx.scene.text.TextAlignment; //導入依賴的package包/類
public void render(long ms, boolean renderBackGround) {
	gc.clearRect(0, 0, canvas.getWidth(), canvas.getHeight());
	//Match debug
	//Styling
	int rightEdge = viewport.getResWidth();
	int fontSize = 20; //bigger than debug cause we better fam; plus we all know size matters
	Color fontCol = Color.WHITE;
	Color shadowCol = Color.BLACK;

	gc.setFont(new Font(fontSize));
	canvas.setStyle("-fx-stroke: black;-fx-stroke-width: 2px;");

	gc.setTextAlign(TextAlignment.RIGHT);
	String text = Toaster.getToast(new Date());

	gc.setFill(shadowCol);
	gc.fillText(text, rightEdge - 20 + 1, canvas.getHeight() / 2 + 1);
	gc.setFill(fontCol);
	gc.fillText(text, rightEdge - 20, canvas.getHeight() / 2);


}
 
開發者ID:UQdeco2800,項目名稱:coaster,代碼行數:23,代碼來源:ToasterScreen.java

示例13: initGraphics

import javafx.scene.text.TextAlignment; //導入依賴的package包/類
@Override protected void initGraphics() {
    super.initGraphics();

    final ZonedDateTime TIME = tile.getTime();

    titleText = new Text(DAY_FORMATTER.format(TIME));
    titleText.setFill(tile.getTitleColor());

    description = new Label(Integer.toString(TIME.getDayOfMonth()));
    description.setAlignment(Pos.CENTER);
    description.setTextAlignment(TextAlignment.CENTER);
    description.setWrapText(true);
    description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS);
    description.setTextFill(tile.getTextColor());
    description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.72);
    description.setFont(Fonts.latoLight(PREFERRED_HEIGHT * 0.65));

    text = new Text(MONTH_YEAR_FORMATTER.format(TIME));
    text.setFill(tile.getTextColor());

    getPane().getChildren().addAll(titleText, text, description);
}
 
開發者ID:HanSolo,項目名稱:tilesfx,代碼行數:23,代碼來源:DateTileSkin.java

示例14: initGraphics

import javafx.scene.text.TextAlignment; //導入依賴的package包/類
@Override protected void initGraphics() {
    super.initGraphics();

    titleText = new Text();
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    description = new Label(tile.getDescription());
    description.setAlignment(tile.getDescriptionAlignment());
    description.setTextAlignment(TextAlignment.RIGHT);
    description.setWrapText(true);
    description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS);
    description.setTextFill(tile.getTextColor());
    description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795);
    Helper.enableNode(description, tile.isTextVisible());

    text = new Text(tile.getText());
    text.setFill(tile.getUnitColor());
    Helper.enableNode(text, tile.isTextVisible());

    getPane().getChildren().addAll(titleText, text, description);
}
 
開發者ID:HanSolo,項目名稱:tilesfx,代碼行數:23,代碼來源:TextTileSkin.java

示例15: render

import javafx.scene.text.TextAlignment; //導入依賴的package包/類
@Override
public void render() {
    super.render();
    
    // clear screen
    GraphicsContext gc = gcs.get("alert");
    gc.clearRect(0, 0, gcs.get("alert").getCanvas().getWidth(), gcs.get("alert").getCanvas().getHeight());
    
    // dont render if the alert should not be viewed
    if (remainingTicks <= 0) {
        return;
    }
    
    // font settings to be set
    gc.setFont(Global.BIG_FONT);
    gc.setTextAlign(TextAlignment.CENTER);
    gc.setTextBaseline(VPos.CENTER);
    gc.setLineWidth(1);
    
    // render text with alpha opcity
    gc.setFill(Color.RED.deriveColor(0, 1.2, 1, alpha));
    gc.fillText(alert, gcs.get("alert").getCanvas().getWidth() / 2, 50);
}
 
開發者ID:GlassWispInteractive,項目名稱:fictional-spoon,代碼行數:24,代碼來源:AlertDecorator.java


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