Java 类javafx.scene.control.Labeled 实例源码

项目:FxEditor    文件:VFlow.java   
/** estimates the last visible line number and computes preferred width based on that */ 
protected double estimateLineNumberColumnWidth(Labeled c)
{           
    double h = Math.max(1.0, c.prefHeight(-1));
    int lineCount = (int)(getHeight() / h);
    int ix = Math.max(999, topLine + lineCount);

    setLineNumber(c, ix);

    c.setManaged(true);
    getChildren().add(c);
    c.applyCss();

    double w = c.prefWidth(-1);

    getChildren().remove(c);

    return w;
}
项目:Gargoyle    文件:IExcelScreenHandler.java   
/**
 * 헤더로  표현하기 위한 커스터마이즈한 값을 리턴해주는 코드작성.
 * 정의하지않는경우 TableColumn Header텍스트로 표현.
 * 
 * 1. 우선 헤더텍스트값을 먼저 살펴봄
 * 2. JAVAFX의 경우 헤더텍스트가 커스텀으로 구현되어 Graphics가 적용된 경우도 있으므로 
 *   텍스트가 빈값으로 인지된경우 Graphics객체를 리턴받은후 라벨을 리턴받아 적용
 *   
 * @작성자 : KYJ
 * @작성일 : 2016. 9. 6.
 * @param table
 * @param tableColumn
 * @return
 */
public default <T> String columnHeaderMapper(TableView<?> table, TableColumn<?, ?> tableColumn) {

    String headerText = tableColumn.getText();

    /* 2016-09-19 만약 headerText값이 null이라면 graphics에서 리턴받아 처리 시도. */
    if (ValueUtil.isEmpty(headerText)) {
        Node graphic = tableColumn.getGraphic();
        if (graphic != null && graphic instanceof Labeled) {
            Labeled lbl = (Labeled) graphic;
            headerText = lbl.getText();
        }
    }

    return headerText;
}
项目:openjfx-8u-dev-tests    文件:ToggleButtonsApp.java   
@Override
protected List<Labeled> getConstructorPage() {
    List<Labeled> list = new ArrayList<Labeled>();

    ToggleButton default_button = new ToggleButton(DEFAULT_BUTTON);
    defaultLayout.apply(default_button);
    if (!default_button.getText().equals(DEFAULT_BUTTON)) {
        reportGetterFailure("new ToggleButton(DEFAULT_LABEL)");
    } else {
        list.add(default_button);
    }

    Rectangle rectangle = new Rectangle(10, 10, Color.rgb(200, 100, 100));
    ToggleButton graphic_button = new ToggleButton(GRAPHICS_BUTTON, rectangle);
    defaultLayout.apply(graphic_button);
    if (!graphic_button.getText().equals(GRAPHICS_BUTTON) || graphic_button.getGraphic() != rectangle) {
        reportGetterFailure("new ToggleButton(GRAPHICS_LABEL, rectangle)");
    } else {
        list.add(graphic_button);
    }

    return list;
}
项目:openjfx-8u-dev-tests    文件:ToggleButtonsApp.java   
@Override
protected TestNode setup() {
    TestNode root = new TestNode();
    defFill(root);
    ArrayList<Change<Labeled>> list = new ArrayList<Change<Labeled>>();
    list.add(new Change<Labeled>(Pages.setSelected.name()) {
        public void apply(Labeled labeled) {
            ToggleButton button = (ToggleButton) labeled;
            button.setSelected(true);
            if (button.isSelected() != true) {
                reportGetterFailure(getMarker());
            }
        }
    });
    root.add(new Page(list), Pages.setSelected.name());
    return root;
}
项目:openjfx-8u-dev-tests    文件:MenuButtonsApp.java   
@Override
protected List<Labeled> getConstructorPage() {
    List<Labeled> list = new ArrayList<Labeled>();

    MenuButton default_button = new MenuButton(DEFAULT_BUTTON);
    defaultLayout.apply(default_button);
    if (!default_button.getText().equals(DEFAULT_BUTTON)) {
        reportGetterFailure("new MenuButton(DEFAULT_LABEL)");
    } else {
        list.add(default_button);
    }

    Rectangle rectangle = new Rectangle(10, 10, Color.rgb(200, 100, 100));
    MenuButton graphic_button = new MenuButton(GRAPHICS_BUTTON, rectangle);
    defaultLayout.apply(graphic_button);
    if (!graphic_button.getText().equals(GRAPHICS_BUTTON) || graphic_button.getGraphic() != rectangle) {
        reportGetterFailure("new MenuButton(GRAPHICS_LABEL, rectangle)");
    } else {
        list.add(graphic_button);
    }
    return list;
}
项目:openjfx-8u-dev-tests    文件:LabelsApp.java   
@Override
protected List<Labeled> getConstructorPage() {
    List<Labeled> list = new ArrayList<Labeled>();

    Label default_label = new Label(DEFAULT_LABEL);
    defaultLayout.apply(default_label);
    if (!default_label.getText().equals(DEFAULT_LABEL)) {
        reportGetterFailure("new Label(DEFAULT_LABEL)");
    } else {
        list.add(default_label);
    }

    Rectangle rectangle = new Rectangle(10, 10, Color.rgb(200, 100, 100));
    Label graphic_label = new Label(GRAPHICS_LABEL, rectangle);
    defaultLayout.apply(graphic_label);
    if (!graphic_label.getText().equals(GRAPHICS_LABEL) || graphic_label.getGraphic() != rectangle) {
        reportGetterFailure("new Label(GRAPHICS_LABEL, rectangle)");
    } else {
        list.add(graphic_label);
    }
    return list;
}
项目:openjfx-8u-dev-tests    文件:LabelsApp.java   
@Override
protected TestNode setup() {
    TestNode root = new TestNode();
    defFill(root);
    List<Change<Labeled>> list = new LinkedList<Change<Labeled>>();

    list.add(new Change<Labeled>(Pages.setTextFill.name()) {
        public void apply(Labeled labeled) {
            labeled.setText("filled");
            Paint paint = Color.rgb(128, 200, 200);
            labeled.setTextFill(paint);
            if (labeled.getTextFill() != paint) {
                reportGetterFailure(getMarker());
            }
        }
    });
    root.add(new LabeledsAbstactApp.Page(list), Pages.setTextFill.name());


    return root;
}
项目:openjfx-8u-dev-tests    文件:ButtonsApp.java   
@Override
protected List<Labeled> getConstructorPage() {
    List<Labeled> list = new ArrayList<Labeled>();

    Button default_button = new Button(DEFAULT_BUTTON);
    defaultLayout.apply(default_button);
    if (!default_button.getText().equals(DEFAULT_BUTTON)) {
        reportGetterFailure("new Button(DEFAULT_LABEL)");
    } else {
        list.add(default_button);
    }

    Rectangle rectangle = new Rectangle(10, 10, Color.rgb(200, 100, 100));
    Button graphic_button = new Button(GRAPHICS_BUTTON, rectangle);
    defaultLayout.apply(graphic_button);
    if (!graphic_button.getText().equals(GRAPHICS_BUTTON) || graphic_button.getGraphic() != rectangle) {
        reportGetterFailure("new Button(GRAPHICS_LABEL, rectangle)");
    } else {
        list.add(graphic_button);
    }
    return list;
}
项目:openjfx-8u-dev-tests    文件:SplitMenuButtonsApp.java   
@Override
protected List<Labeled> getConstructorPage() {
    List<Labeled> list = new ArrayList<Labeled>();

    SplitMenuButton defaultButton = new SplitMenuButton();
    defaultLayout.apply(defaultButton);
    if (!defaultButton.getText().equals("")) {
        reportGetterFailure("new SplitMenuButton()");
    } else {
        list.add(defaultButton);
    }

    SplitMenuButton itemsButton = new SplitMenuButton(new MenuItem("Item 1"), new MenuItem("Item 2"), new MenuItem("Item 3"));
    defaultLayout.apply(itemsButton);
    if (!itemsButton.getItems().get(0).getText().equals("Item 1")
            || !itemsButton.getItems().get(1).getText().equals("Item 2")
            || !itemsButton.getItems().get(2).getText().equals("Item 3")
            || !itemsButton.getText().equals("")
            || itemsButton.getGraphic() != null) {
        reportGetterFailure("new SplitMenuButton(MenuItem...)");
    } else {
        list.add(itemsButton);
    }

    return list;
}
项目:openjfx-8u-dev-tests    文件:LabeledsAbstactApp.java   
protected void addAlignment(List<Change<Labeled>> list, final boolean wrapped, final String text, String mark) {
    for (final TextAlignment alignment : TextAlignment.values()) {
        list.add(new Change<Labeled>(alignment.toString() + (wrapped ? "_wrapped" : "") + mark) {
            public void apply(Labeled labeled) {
                labeled.setText("TextAlignment = " + alignment.toString() + text);
                labeled.setWrapText(wrapped);
                Utils.LayoutSize layout = new Utils.LayoutSize(250, 40, 250, 40, 250, 40);
                layout.apply(labeled);
                labeled.setTextAlignment(alignment);
                if (labeled.getTextAlignment() != alignment) {
                    reportGetterFailure(getMarker());
                }
            }
        });
    }
}
项目:openjfx-8u-dev-tests    文件:LabeledsAbstactApp.java   
private void init(List<Change<Labeled>> changes) {
    for (Change<Labeled> change : changes) {
        VBox box = new VBox();
        if (change.getName() != null) {
            box.getChildren().add(new Label("[" + change.getName() + "]"));
        }
        Labeled control = getTestingControl();
        change.apply(control);
        if (enableBorder) {
            control.setStyle("-fx-border-color: darkgray");
        }
        box.getChildren().add(control);
        addNode(box);
    }
    changes.clear();
}
项目:openjfx-8u-dev-tests    文件:LabeledsBase.java   
private void testEllipsisSize() {
    org.jemmy.interfaces.Parent p = getScene().as(org.jemmy.interfaces.Parent.class, Node.class);

    final Wrap<? extends Labeled> node = p.lookup(new ByID<Labeled>(LabeledsPages.setEllipsisString.name() + LabeledsAbstactApp.CONTROL)).wrap();
    final Wrap<? extends Labeled> goldennode = p.lookup(new ByID<Labeled>(LabeledsPages.setEllipsisString.name() + LabeledsAbstactApp.GOLDEN)).wrap();

    new Waiter(Wrap.WAIT_STATE_TIMEOUT).waitState(new State() {
        @Override
        public Object reached() {
            return (node.getControl().getChildrenUnmodifiable().size() > 0) ? true : null;
        }
    });

    LabeledText targetText = searchLabeledText(node.getControl());
    Bounds targetTextBounds = targetText.getBoundsInParent();
    Bounds controlBounds = node.getControl().getBoundsInLocal();
    Bounds goldenControlBounds = goldennode.getControl().getBoundsInLocal();
    Assert.assertTrue(controlBounds.contains(targetTextBounds));
    Assert.assertEquals(goldenControlBounds.getWidth(), controlBounds.getWidth());
    Assert.assertEquals(goldenControlBounds.getHeight(), controlBounds.getHeight());
}
项目:openjfx-8u-dev-tests    文件:PaginationEventsTest.java   
/**
 * Finds right arrow button inside pagination and click it to produce an
 * action event.
 */
@Override
@Test(timeout = 60000)
public void onAction()
{
    test(ControlEventsApp.EventTypes.ACTION, new Command() {

        public void invoke() {
            LabeledDock rightButtonDock = new LabeledDock(
                    getPrimeNodeDock().asParent(), new LookupCriteria<Labeled>() {

                public boolean check(Labeled cntrl) {
                    if(cntrl.getStyleClass().containsAll(Arrays.asList(
                        "button", "right-arrow-button")))
                        return true;
                    return false;
                }
            });
            rightButtonDock.mouse().click();
        }
    });
}
项目:openjfx-8u-dev-tests    文件:DockWrapObjectSample.java   
/**
 * <code>*Dock</code> classes are the true API classes. Docks should be used
 * whenever possible. All straightforward operations should be available
 * through docks. If it is not so, please file a feature request.<br/>
 * Dock classes source is generated. They have many different methods which
 * are all convenience methods. Such methods as lookup constructors,
 * <code>as*()</code> methods to perform operations and <code>get*()</code>
 * method to get properties. Please consult other samples to see how to use
 * docks.
 */
@Test
public void dock() {
    //Docks have ...
    //lookup constructors
    LabeledDock button = new LabeledDock(new SceneDock().asParent(), Button.class);
    //as* methods
    Parent<Node> parent = button.asParent();
    //get* methods
    //please make sure to use these rather than direct calls to Java FX node
    //method, becuase this calls the appropriate method on the event queue
    double opacity = button.getOpacity();
    //you can get a wrap out of it
    //see next test method on how to deal with wraps
    Wrap<? extends Labeled> wrap = button.wrap();
    //or a control itself
    Labeled theButtonItself = button.control();
}
项目:JVx.javafx    文件:JavaFXAbstractComponentBase.java   
/**
 * {@inheritDoc}
 */
@Override
public void setFont(IFont pFont)
{
    font = pFont;

    if (resource instanceof Labeled)
    {
        // If the resource is an instance of Labeled, we'll set the font
        // by using the setFont(Font) method. Otherwise the font might
        // be inherited by children, which f.e. looks odd in the case
        // of a TitledPane.
        if (font != null)
        {
            ((Labeled)resource).setFont((Font)font.getResource());
        }
        else
        {
            ((Labeled)resource).setFont(null);
        }
    }
    else
    {
        styleContainer.setFont(font);
    }
}
项目:StreamSis    文件:HorizontalShadowAnimation.java   
public HorizontalShadowAnimation(Labeled label) {
    if (label == null) {
        throw new NullPointerException();
    }
    labeled = label;
    originalEffect = label.getEffect();

    dropShadow.setBlurType(BlurType.ONE_PASS_BOX);

    setInitialShadow(label);

    EventHandler<ActionEvent> onFinished = new EventHandler<ActionEvent>() {
        public void handle(ActionEvent t) {
            label.effectProperty().unbind();
            labeled.setEffect(originalEffect);
        }
    };
    KeyValue endValue = new KeyValue(dropShadow.widthProperty(), 0, Interpolator.EASE_BOTH);
    KeyFrame endFrame = new KeyFrame(Duration.millis(150), onFinished, endValue);

    animation.getKeyFrames().addAll(endFrame);
    animation.setCycleCount(1);
    animation.setAutoReverse(false);

}
项目:StreamSis    文件:MultiSourceFileListerController.java   
/**
 * Replaces &lt;filetype&gt tags in this {@link MultiSourceFileListerController}'s view to a
 * specified text. Should be invoked before
 * {@link #bindToMultiSourceFileLister(MultiSourceFilePicker, MultiSourceFilePicker)} method.
 *
 * @param fileTypeName
 *            The text to use instead of &lt;filetype&gt tags in texts of {@link Label}s. Should
 *            describe in one or two words the type of files this
 *            MultiSourceFilePickerController accepts (not extension).
 * @throws RuntimeException
 *             if it was already invoked and replaced the text in Labels.
 */
public void replaceFileTypeNameTagInLabeledControls(String fileTypeName) {
    if (this.fileTypeName == null) {
        this.fileTypeName = fileTypeName;
        for (Node node : ((GridPane) getView()).getChildren()) {
            if (node instanceof Labeled) {
                Labeled labeled = (Labeled) node;
                labeled.setText(labeled.getText().replace("<filetype>", fileTypeName));
            }
        }
        manualPaneDotsAnima.setAdditionalText(
                manualPaneDotsAnima.getAdditionalText().replace("<filetype>", fileTypeName));
    } else {
        throw new RuntimeException("File type name tag is already replaced.");
    }
}
项目:ISAAC    文件:WrappedLabeled.java   
/**
 * Useful when taking a node already placed by a fxml file, for example, so it wraps properly.
 * WARNING - the mechanism of moving the properties isn't currently very smart - it should only target
 * GridPane properties, but it takes everything.
 */
public static HBox wrapInstalledLabel(Labeled placedNode, GridPane gp)
{
    int index = gp.getChildren().indexOf(placedNode);
    if (index < 0)
    {
        throw new RuntimeException("Placed Node is not in the grid pane");
    }

    gp.getChildren().remove(index);
    HBox replacementNode = wrap(placedNode);
    gp.getChildren().add(index, replacementNode);

    //this transfers the node specific constraints
    replacementNode.getProperties().putAll(placedNode.getProperties());
    return replacementNode;
}
项目:Calculator-JavaFX    文件:FXMLDocumentController.java   
@FXML
private void handleButtonAction(ActionEvent event) {
    String str = ((Labeled)event.getSource()).getText();
    tf.setText(tf.getText()+str);
    tf2.setText(prevStr+str);
    prevStr = tf2.getText();
}
项目:dragdropfx    文件:DragDropFX.java   
@Override
public Void call(Object p) {
    if(isIgnored(p)){return null;}
    Labeled c = (Labeled) p;
    DnDPrepare.labeled(c);
    return null;
}
项目:FxEditor    文件:LineBox.java   
public Labeled getLineNumberComponent()
{
    if(lineNumberComponent == null)
    {
        lineNumberComponent = createLineNumberComponent();
    }
    return lineNumberComponent;
}
项目:openjfx-8u-dev-tests    文件:ToggleButtonsApp.java   
@Override
protected Labeled getListenable() {
    ToggleButton button = new FireListenableButton();
    button.setText(DEFAULT);
    defaultLayout.apply(button);
    return button;
}
项目:openjfx-8u-dev-tests    文件:ToggleButtonsApp.java   
@Override
protected Labeled getButton() {
    ToggleButton button = new ToggleButton();
    button.setText(DEFAULT);
    defaultLayout.apply(button);
    return button;
}
项目:openjfx-8u-dev-tests    文件:LabelsApp.java   
@Override
protected Labeled getTestingControl() {
    Label label = new Label(DEFAULT);
    label.setGraphic(new Rectangle(10, 10));
    defaultLayout.apply(label);
    return label;
}
项目:openjfx-8u-dev-tests    文件:MenuButtonApp.java   
@Override
protected Scene getScene() {
    return new LabeledsApp.LabeledScene() {

        @Override
        protected Labeled getTestedLabeled() {
            return new MenuButton();
        }
    };
}
项目:openjfx-8u-dev-tests    文件:LabelApp.java   
@Override
protected Scene getScene() {
    Utils.setTitleToStage(stage, "LabelApp");
    return new LabeledsApp.LabeledScene() {

        @Override
        protected Labeled getTestedLabeled() {
            return new Label();
        }
    };
}
项目:openjfx-8u-dev-tests    文件:RadioButtonApp.java   
@Override
protected Scene getScene() {
    return new LabeledsApp.LabeledScene() {

        @Override
        protected Labeled getTestedLabeled() {
            return new RadioButton();
        }
    };
}
项目:openjfx-8u-dev-tests    文件:ButtonApp.java   
@Override
protected Scene getScene() {
    return new LabeledsApp.LabeledScene() {

        @Override
        protected Labeled getTestedLabeled() {
            return new Button();
        }
    };
}
项目:openjfx-8u-dev-tests    文件:ToggleApp.java   
@Override
protected Scene getScene() {
    return new LabeledsApp.LabeledScene() {

        @Override
        protected Labeled getTestedLabeled() {
            return new ToggleButton();
        }
    };
}
项目:openjfx-8u-dev-tests    文件:CheckBoxApp.java   
@Override
protected Scene getScene() {
    return new LabeledsApp.LabeledScene() {

        @Override
        protected Labeled getTestedLabeled() {
            return new CheckBox();
        }
    };
}
项目:openjfx-8u-dev-tests    文件:HyperlinkApp.java   
@Override
protected Scene getScene() {
    return new LabeledsApp.LabeledScene() {

        @Override
        protected Labeled getTestedLabeled() {
            return new Hyperlink();
        }
    };
}
项目:openjfx-8u-dev-tests    文件:SplitMenuButtonApp.java   
@Override
protected Scene getScene() {
    return new LabeledsApp.LabeledScene() {

        @Override
        protected Labeled getTestedLabeled() {
            return new SplitMenuButton();
        }
    };
}
项目:openjfx-8u-dev-tests    文件:ButtonBaseApp.java   
protected final Labeled getTestingControl() {
    if (listenableButtons) {
        return getListenable();
    } else {
        return getButton();
    }
}
项目:openjfx-8u-dev-tests    文件:CheckBoxApp.java   
@Override
protected List<Labeled> getConstructorPage() {
    List<Labeled> list = new ArrayList<Labeled>();

    CheckBox default_button = new CheckBox(DEFAULT_BUTTON);
    defaultLayout.apply(default_button);
    if (!default_button.getText().equals(DEFAULT_BUTTON)) {
        reportGetterFailure("new CheckBox(DEFAULT_LABEL)");
    } else {
        list.add(default_button);
    }
    return list;
}
项目:openjfx-8u-dev-tests    文件:CheckBoxApp.java   
@Override
protected TestNode setup() {
    TestNode root = new TestNode();
    defFill(root);
    ArrayList<Change<Labeled>> list = new ArrayList<Change<Labeled>>();
    final boolean bools[] = {false, true};
    for (final boolean i : bools) {
        for (final boolean j : bools) {
            for (final boolean k : bools) {

                list.add(new Change<Labeled>(i + "," + j + "," + k) {
                    public void apply(Labeled labeled) {
                        CheckBox button = (CheckBox) labeled;
                        button.setAllowIndeterminate(i);
                        if (button.isAllowIndeterminate() != i) {
                            reportGetterFailure(getMarker());
                        }
                        button.setSelected(j);
                        if (button.isSelected() != j) {
                            reportGetterFailure(getMarker());
                        }
                        button.setIndeterminate(k);
                        if (button.isIndeterminate() != k) {
                            reportGetterFailure(getMarker());
                        }
                    }
                });
            }
        }
    }
    root.add(new Page(list), Pages.CheckBoxes.name());
    return root;
}
项目:openjfx-8u-dev-tests    文件:EllipsisApp.java   
private Labeled createCase1(Labeled labeled) {
    labeled.setText(TEXT);
    labeled.setTextOverrun(def);

    labeled.setEllipsisString(ELLIPSIS1);
    return labeled;
}
项目:openjfx-8u-dev-tests    文件:SplitMenuButtonsApp.java   
@Override
protected Labeled getListenable() {
    SplitMenuButton button = new FireListenableButton();
    button.setText(DEFAULT);
    defaultLayout.apply(button);
    return button;
}
项目:openjfx-8u-dev-tests    文件:SplitMenuButtonsApp.java   
@Override
protected Labeled getButton() {
    SplitMenuButton button = new SplitMenuButton();
    button.setText(DEFAULT);
    defaultLayout.apply(button);
    return button;
}
项目:openjfx-8u-dev-tests    文件:HyperlinkApp.java   
@Override
protected List<Labeled> getConstructorPage() {
    List<Labeled> list = new ArrayList<Labeled>();

    Hyperlink hyperlink = new Hyperlink();
    defaultLayout.apply(hyperlink);
    if (hyperlink.getText() != null) {
        if (!hyperlink.getText().isEmpty()) {
            reportGetterFailure("hyperlink.getText()");
        }
    }
    if (hyperlink.isVisited() != false) {
        reportGetterFailure("hyperlink.isVisited");
    }
    list.add(hyperlink);

    Hyperlink text_hyperlink = new Hyperlink("Hyperlink");
    defaultLayout.apply(text_hyperlink);
    if (text_hyperlink.getText() == null || !text_hyperlink.getText().contentEquals("Hyperlink")) {
        reportGetterFailure("hyperlink.getText()");
    }
    list.add(text_hyperlink);

    Rectangle rectangle = new Rectangle(10, 10);
    Hyperlink node_hyperlink = new Hyperlink("Hyperlink with Node", rectangle);
    defaultLayout.apply(node_hyperlink);
    if (text_hyperlink.getText() == null || !node_hyperlink.getText().contentEquals("Hyperlink with Node")) {
        reportGetterFailure("hyperlink.getText()");
    }
    if (node_hyperlink.getGraphic() != rectangle) {
        reportGetterFailure("hyperlink.getGraphic()");
    }
    list.add(node_hyperlink);
    return list;
}
项目:openjfx-8u-dev-tests    文件:RadioButtonsApp.java   
@Override
protected List<Labeled> getConstructorPage() {
    List<Labeled> list = new ArrayList<Labeled>();

    RadioButton default_button = new RadioButton(DEFAULT_BUTTON);
    defaultLayout.apply(default_button);
    if (!default_button.getText().equals(DEFAULT_BUTTON)) {
        reportGetterFailure("new ToggleButton(DEFAULT_LABEL)");
    } else {
        list.add(default_button);
    }

    return list;
}