当前位置: 首页>>代码示例>>Java>>正文


Java Toolkit类代码示例

本文整理汇总了Java中com.sun.javafx.tk.Toolkit的典型用法代码示例。如果您正苦于以下问题:Java Toolkit类的具体用法?Java Toolkit怎么用?Java Toolkit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Toolkit类属于com.sun.javafx.tk包,在下文中一共展示了Toolkit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: NGCanvas

import com.sun.javafx.tk.Toolkit; //导入依赖的package包/类
public NGCanvas() {
    Toolkit tk = Toolkit.getToolkit();
    ScreenConfigurationAccessor screenAccessor = tk.getScreenConfigurationAccessor();
    float hPS = 1.0f;
    for (Object screen : tk.getScreens()) {
        hPS = Math.max(screenAccessor.getRenderScale(screen), hPS);
    }
    highestPixelScale = hPS;

    cv = new RenderBuf(InitType.PRESERVE_UPPER_LEFT);
    temp = new RenderBuf(InitType.CLEAR);
    clip = new RenderBuf(InitType.FILL_WHITE);

    path = new Path2D();
    ngtext = new NGText();
    textLayout = new PrismTextLayout();
    transform = new Affine2D();
    clipStack = new LinkedList<Path2D>();
    initAttributes();
}
 
开发者ID:bourgesl,项目名称:marlin-fx,代码行数:21,代码来源:NGCanvas.java

示例2: measureText

import com.sun.javafx.tk.Toolkit; //导入依赖的package包/类
/** Measure text
 *  @param gc JFX Graphics context. Font must be set.
 *  @param text Text to measure, may contain '\n' for multi-line text.
 *  @return Rectangle where (x, y) is the offset from the top-left
 *          corner of the text to its baseline as used for gc.drawString(),
 *          and (width, height) are the overall bounding box.
 */
public static Rectangle measureText(final GraphicsContext gc, final String text)
{
    // This is not public API for FontMetrics, see
    // https://bugs.openjdk.java.net/browse/JDK-8098301
    // https://bugs.openjdk.java.net/browse/JDK-8090775
    final com.sun.javafx.tk.FontMetrics metrics =
            Toolkit.getToolkit().getFontLoader().getFontMetrics(gc.getFont());

    // Check for multi-line text
    int lines = 1;
    int nl = 0;
    while ( (nl = text.indexOf('\n', nl)) > 0)
    {
        ++nl;
        ++lines;
    }

    return new Rectangle(0,
                         (int)(metrics.getLeading() + metrics.getAscent()),
                         (int)metrics.computeStringWidth(text),
                         lines * (int)metrics.getLineHeight());
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:30,代码来源:GraphicsUtils.java

示例3: getNode

import com.sun.javafx.tk.Toolkit; //导入依赖的package包/类
@Override
public Node getNode() {
    // actual name for labels at the top, add tick for selected labels
    Label label = new Label((canDisplayFullName ? getFullName() : getShortName()));
    setLabelStyle(label);
    label.setText(label.getText() + (!canDisplayFullName && isSelected ? " ✓" : ""));

    FontLoader fontLoader = Toolkit.getToolkit().getFontLoader();
    double width = fontLoader.computeStringWidth(label.getText(), label.getFont());
    label.setPrefWidth(width + 30);

    if (isInGroup()) {
        Tooltip groupTooltip = new Tooltip(getGroupName());
        label.setTooltip(groupTooltip);
    }

    setupEvents(label);
    return label;
}
 
开发者ID:HubTurbo,项目名称:HubTurbo,代码行数:20,代码来源:PickerLabel.java

示例4: updateListView

import com.sun.javafx.tk.Toolkit; //导入依赖的package包/类
public void updateListView()
{
	if (Toolkit.getToolkit().isFxUserThread())
	{
		if (lfpc_ == null)
		{
			lfpc_ = LegoFilterPaneController.init();
		}
		lfpc_.reloadOptions();
		lfpc_.updateLegoList();
	}
	else
	{
		Platform.runLater(() -> 
		{
			if (lfpc_ == null)
			{
				lfpc_ = LegoFilterPaneController.init();
			}
			lfpc_.reloadOptions();
			lfpc_.updateLegoList();
		});
	}
}
 
开发者ID:Apelon-VA,项目名称:ISAAC,代码行数:25,代码来源:LegoListView.java

示例5: initView

import com.sun.javafx.tk.Toolkit; //导入依赖的package包/类
private void initView(List<String> kingdomCards) {
    FontMetrics fontMetrics = Toolkit.getToolkit().getFontLoader().getFontMetrics(Font.getDefault());
    double minLength = 0;
    for (String card : kingdomCards) {
        double cardNameLength = fontMetrics.computeStringWidth(card);
        if (cardNameLength > minLength) {
            minLength = cardNameLength;
        }
    }
    
    kingdomCard1.setText(kingdomCards.get(0) + ": ");
    kingdomCard2.setText(kingdomCards.get(1).toString() + ": ");
    kingdomCard3.setText(kingdomCards.get(2).toString() + ": ");
    kingdomCard4.setText(kingdomCards.get(3).toString() + ": ");
    kingdomCard5.setText(kingdomCards.get(4).toString() + ": ");
    kingdomCard6.setText(kingdomCards.get(5).toString() + ": ");
    kingdomCard7.setText(kingdomCards.get(6).toString() + ": ");
    kingdomCard8.setText(kingdomCards.get(7).toString() + ": ");
    kingdomCard9.setText(kingdomCards.get(8).toString() + ": ");
    kingdomCard10.setText(kingdomCards.get(9).toString() + ": ");
    
    kingdomCardHolder.setPrefWidth(minLength * 2);
}
 
开发者ID:willisjtc,项目名称:Dominator,代码行数:24,代码来源:KingdomCardsView.java

示例6: AutoSizedTextField

import com.sun.javafx.tk.Toolkit; //导入依赖的package包/类
/**
 * Default constructor.
 */
public AutoSizedTextField() {
  setPadding(new Insets(3));
  prefWidthProperty().bind(
      EasyBind.combine(visibleProperty(), textProperty(), fontProperty(), (visible, text, font) -> {
        double width = Toolkit.getToolkit().getFontLoader().computeStringWidth(text, font);
        return visible ? width + 7 : 1;
      })
  );
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:13,代码来源:AutoSizedTextField.java

示例7: rebuildContextMenu

import com.sun.javafx.tk.Toolkit; //导入依赖的package包/类
private void rebuildContextMenu(Collection<String> values, boolean isPartial) {
    context.getItems().clear();
    values.forEach(value -> {
        MenuItem item = new MenuItem(value);
        context.getItems().add(item);
        item.setOnAction(event -> {
            String text = getText();
            String[] words = text.split(" ");

            if (isPartial) {
                words[words.length - 1] = value;
            } else {
                words = ArrayUtils.add(words, value);
            }
            String newText = StringUtils.join(words, " ");
            if (!newText.endsWith(" ")) {
                newText += " ";
            }
            setText(newText);
            positionCaret(newText.length());
        });
    });

    FontLoader fontLoader = Toolkit.getToolkit().getFontLoader();
    float width = fontLoader.computeStringWidth(getText(), getFont());
    context.show(this, Side.BOTTOM, width, 0);
}
 
开发者ID:Kindrat,项目名称:cassandra-client,代码行数:28,代码来源:FilterTextField.java

示例8: FontDetails

import com.sun.javafx.tk.Toolkit; //导入依赖的package包/类
public FontDetails (String name, int size, Font font)
{
  this.font = font;
  this.name = name;
  this.size = size;

  FontMetrics fontMetrics =
      Toolkit.getToolkit ().getFontLoader ().getFontMetrics (font);
  width = (int) (fontMetrics.computeStringWidth ("W") + 0.9);

  ascent = (int) (fontMetrics.getAscent () + fontMetrics.getLeading () + 0.9);
  descent = (int) (fontMetrics.getDescent () + 0.9);
  height = ascent + descent;
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:15,代码来源:FontDetails.java

示例9: isOnQueue

import com.sun.javafx.tk.Toolkit; //导入依赖的package包/类
/**
 * Checks whether the calling code is already on the queue thread.
 * @return
 */
@Override
public boolean isOnQueue() {
    //return Thread.currentThread().equals(getQueueThread());
    try {
        Toolkit.getToolkit().checkFxUserThread();
    } catch (Throwable th) {
        return false;
    }
    return true;
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:15,代码来源:QueueExecutor.java

示例10: createContext

import com.sun.javafx.tk.Toolkit; //导入依赖的package包/类
private static AdapterContext createContext() {
  if (!Toolkit.getToolkit().getSystemMenu().isSupported()) {
    return null;
  }

  try {
    return new AdapterContext(new TKSystemMenuAdapter(), new MacApplicationAdapter());
  } catch (ReflectiveOperationException e) {
    throw new GlassAdaptionException(e);
  }
}
 
开发者ID:codecentric,项目名称:NSMenuFX,代码行数:12,代码来源:AdapterContext.java

示例11: createNoExistingAssigneeLabel

import com.sun.javafx.tk.Toolkit; //导入依赖的package包/类
private Label createNoExistingAssigneeLabel() {
    Label noExistingAssignee = new Label(MESSAGE_NO_ASSIGNEE);
    noExistingAssignee.setPrefHeight(40);
    FontLoader fontLoader = Toolkit.getToolkit().getFontLoader();
    double width = fontLoader.computeStringWidth(noExistingAssignee.getText(), noExistingAssignee.getFont());
    noExistingAssignee.setPrefWidth(width);
    return noExistingAssignee;
}
 
开发者ID:HubTurbo,项目名称:HubTurbo,代码行数:9,代码来源:AssigneePickerDialog.java

示例12: getAssigneeLabel

import com.sun.javafx.tk.Toolkit; //导入依赖的package包/类
private Label getAssigneeLabel() {
    Label assigneeLoginName = new Label(getLoginName());
    FontLoader fontLoader = Toolkit.getToolkit().getFontLoader();
    double width = fontLoader.computeStringWidth(assigneeLoginName.getText(), assigneeLoginName.getFont());
    assigneeLoginName.setPrefWidth(width + 35);
    assigneeLoginName.setPrefHeight(LABEL_HEIGHT);
    assigneeLoginName.getStyleClass().add("labels");
    return assigneeLoginName;
}
 
开发者ID:HubTurbo,项目名称:HubTurbo,代码行数:10,代码来源:PickerAssignee.java

示例13: getAssigneeLabelWithAvatar

import com.sun.javafx.tk.Toolkit; //导入依赖的package包/类
private Label getAssigneeLabelWithAvatar() {
    Label assignee = new Label(getLoginName());
    assignee.setGraphic(getAvatarImageView());
    FontLoader fontLoader = Toolkit.getToolkit().getFontLoader();
    double width = fontLoader.computeStringWidth(assignee.getText(), assignee.getFont());
    assignee.setPrefWidth(width + 35 + AVATAR_SIZE);
    assignee.setPrefHeight(LABEL_HEIGHT);
    assignee.getStyleClass().add("labels");
    assignee.setStyle("-fx-background-color: lightgreen;");
    return assignee;
}
 
开发者ID:HubTurbo,项目名称:HubTurbo,代码行数:12,代码来源:PickerAssignee.java

示例14: setColSizes

import com.sun.javafx.tk.Toolkit; //导入依赖的package包/类
private void setColSizes(TableView<RefsetInstance> refsetRows)
{
	//Horrible hack to move the stamp column to the end
	//TODO remove this hack after code gets refactored to combine these various init methods
	for (int i = 0; i < refsetRows.getColumns().size(); i++)
	{
		if (refsetRows.getColumns().get(i).getText().equals("STAMP"))
		{
			refsetRows.getColumns().add(refsetRows.getColumns().remove(i));
			break;
		}
	}
	
	//Horrible hack to set a reasonable default size on the columns.
	//Min width to the with of the header column.  Preferred width - divide space out evenly.
	Font f = new Font("System Bold", 13.0);
	float prefColWidthPercentage = 1.0f / (float) refsetRows.getColumns().size();
	for (TableColumn<RefsetInstance, ?> col : refsetRows.getColumns())
	{
		for (TableColumn<RefsetInstance, ?> nestedCol : col.getColumns())
		{
			nestedCol.setMinWidth(Toolkit.getToolkit().getFontLoader().computeStringWidth(nestedCol.getText(), f) + 20);
			nestedCol.prefWidthProperty().bind(refsetRows.widthProperty().subtract(5.0).multiply(prefColWidthPercentage).divide(col.getColumns().size()));
		}
		col.setMinWidth(Toolkit.getToolkit().getFontLoader().computeStringWidth(col.getText(), f) + 20);
		col.prefWidthProperty().bind(refsetRows.widthProperty().subtract(5.0).multiply(prefColWidthPercentage));
	}
}
 
开发者ID:Apelon-VA,项目名称:ISAAC,代码行数:29,代码来源:RefsetTableHandler.java

示例15: checkBackgroundThread

import com.sun.javafx.tk.Toolkit; //导入依赖的package包/类
/**
 * Makes sure thread is NOT the FX application thread.
 */
public static void checkBackgroundThread() {
    // Throw exception if on FX user thread
    if (Toolkit.getToolkit().isFxUserThread()) {
        throw new IllegalStateException("Not on background thread; currentThread = "
                + Thread.currentThread().getName());
    }
}
 
开发者ID:Apelon-VA,项目名称:ISAAC,代码行数:11,代码来源:FxUtils.java


注:本文中的com.sun.javafx.tk.Toolkit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。