javafx.scene.control.Label#setAlignment ( )源码实例Demo

下面列出了javafx.scene.control.Label#setAlignment ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: mars-sim   文件: MainScene.java
/**
 * Creates the pause box to be displayed on the root pane.
 * 
 * @return VBox
 */
private VBox createPausePaneContent() {
	VBox vbox = new VBox();
	vbox.setPrefSize(150, 150);

	Label label = new Label("||");
	label.setAlignment(Pos.CENTER);
	label.setPadding(new Insets(10));
	label.setStyle("-fx-font-size: 48px; -fx-text-fill: cyan;");
	// label.setMaxWidth(250);
	label.setWrapText(true);

	Label label1 = new Label("ESC to resume");
	label1.setAlignment(Pos.CENTER);
	label1.setPadding(new Insets(2));
	label1.setStyle(" -fx-font: bold 11pt 'Corbel'; -fx-text-fill: cyan;");
	vbox.getChildren().addAll(label, label1);
	vbox.setAlignment(Pos.CENTER);

	return vbox;
}
 
源代码2 项目: Quelea   文件: StatusPanel.java
/**
 * Create a new status panel.
 * <p/>
 * @param group the group this panel is part of.
 * @param labelText the text to put on the label on this panel.
 * @param index the index of this panel on the group.
 */
StatusPanel(StatusPanelGroup group, String labelText, int index) {
    setAlignment(Pos.CENTER);
    setSpacing(5);
    this.group = group;
    this.index = index;
    label = new Label(labelText);
    label.setAlignment(Pos.CENTER);
    label.setMaxHeight(Double.MAX_VALUE);
    HBox.setMargin(label, new Insets(5));
    progressBar = new ProgressBar();
    progressBar.setMaxWidth(Double.MAX_VALUE); //Allow progress bar to fill space.
    HBox.setHgrow(progressBar, Priority.ALWAYS);
    cancelButton = new Button("", new ImageView(new Image("file:icons/cross.png", 13, 13, false, true)));
    Utils.setToolbarButtonStyle(cancelButton);
    cancelButton.setAlignment(Pos.CENTER);
    getChildren().add(label);
    getChildren().add(progressBar);
    getChildren().add(cancelButton);
}
 
源代码3 项目: tilesfx   文件: DateTileSkin.java
@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);
}
 
源代码4 项目: gluon-samples   文件: ListTile.java
private void updateText() {
    textBox.getChildren().clear();
    for (int i = 0; i <= 2; i++) {
        Label label = new Label(textProperty.get(i));
        label.setWrapText(true);
        label.setMaxHeight(Double.MAX_VALUE);
        label.setAlignment(Pos.TOP_LEFT);
        if (i == 0) {
            label.getStyleClass().add("primary");
        }
        textBox.getChildren().add(label);
        VBox.setVgrow(label, Priority.ALWAYS);
    }
}
 
源代码5 项目: mars-sim   文件: MainScene.java
public Label createLabelLeft(String name, String tip) {
	Label l = new Label(name);
	// upTimeLabel0.setEffect(blend);
	l.setAlignment(Pos.CENTER_RIGHT);
	l.setTextAlignment(TextAlignment.RIGHT);
	l.setStyle(LABEL_CSS_STYLE);
	l.setPadding(new Insets(1, 1, 1, 2));
	setQuickToolTip(l, tip);
	return l;
}
 
源代码6 项目: helloiot   文件: SliderSimple.java
@Override
public Node constructContent() {
    
    VBox vboxroot = new VBox();
    vboxroot.setSpacing(10.0);
    
    boxview = new HBox();
    boxview.setSpacing(6.0);
    
    level = new Label();
    level.setAlignment(Pos.CENTER_RIGHT);
    level.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    level.getStyleClass().add("unitmaintext");
    HBox.setHgrow(level, Priority.SOMETIMES);
    
    boxview.getChildren().add(level);
    
    slider = new Slider();
    slider.setFocusTraversable(false);
    StackPane.setAlignment(slider, Pos.BOTTOM_CENTER);        
    
    StackPane stack = new StackPane(slider);
    VBox.setVgrow(stack, Priority.SOMETIMES);
    vboxroot.getChildren().addAll(boxview, stack);
    
    initialize();
    
    return vboxroot;
}
 
源代码7 项目: helloiot   文件: UnitsContainerEmpty.java
public UnitsContainerEmpty(String label) {
    message = new Label(label);
    message.setAlignment(Pos.TOP_CENTER);
    message.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    message.getStyleClass().add("unitsempty");
    VBox.setVgrow(message, Priority.SOMETIMES);                    
}
 
源代码8 项目: helloiot   文件: ViewSimple.java
@Override
protected Node constructContent() {
    content = new Label(null);
    content.setContentDisplay(ContentDisplay.TOP);
    content.setAlignment(Pos.CENTER);
    content.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    VBox.setVgrow(content, Priority.SOMETIMES);
    return content;
}
 
源代码9 项目: ShootOFF   文件: HeadlessController.java
@Override
public void autocalibrationTimedOut() {
	calibrated = false;

	final Label calibrationLabel = new Label("Calibration Failed!");
	calibrationLabel.setFont(Font.font(48));
	calibrationLabel.setTextFill(Color.web("#f5a807"));
	calibrationLabel.setLayoutX(6);
	calibrationLabel.setLayoutY(6);
	calibrationLabel.setPrefSize(628, 90);
	calibrationLabel.setAlignment(Pos.CENTER);

	arenaPane.getCanvasManager().getCanvasGroup().getChildren().add(calibrationLabel);
}
 
源代码10 项目: helloiot   文件: ViewText.java
@Override
protected Node constructContent() {
    VBox vboxroot = new VBox();
    vboxroot.setSpacing(10.0);        
    
    level = new Label();
    level.setAlignment(Pos.CENTER_RIGHT);
    level.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    level.getStyleClass().add("unitmaintext");
    
    vboxroot.getChildren().add(level);
    
    initialize();
    return vboxroot;
}
 
源代码11 项目: paintera   文件: MetaPanel.java
private static void formatLabels(final Label... labels)
{
	for (Label label : labels) {
		label.setAlignment(Pos.BASELINE_CENTER);
		label.setPrefWidth(TEXTFIELD_WIDTH);
	}
}
 
源代码12 项目: mars-sim   文件: MarsNode.java
public Label createEach(Settlement settlement) {
	Label l = new Label(settlement.getName());

	l.setPadding(new Insets(20));
	l.setAlignment(Pos.CENTER);
	l.setMaxWidth(Double.MAX_VALUE);

	l.setId("settlement-node");
	l.getStylesheets().add("/fxui/css/settlementnode.css");

	l.setOnMouseClicked(new EventHandler<MouseEvent>() {
     	PopOver popOver = null;
         @Override
         public void handle(MouseEvent evt) {
       	if (popOver == null ) {
                popOver = createPopOver(l, settlement);
         	}
       	else if (evt.getClickCount() >= 1) {
               popOver.hide(Duration.seconds(.5));
        	}
       	else if (popOver.isShowing()) {
         		popOver.hide(Duration.seconds(.5));
         	}
       	else if (!popOver.isShowing()) {
         		popOver = createPopOver(l, settlement);
         	}
         }
     });
	return l;
}
 
源代码13 项目: marathonv5   文件: AboutStage.java
private HBox createBlurbTitle() {
    Label bulrbTitleLabel = createLabel(versionInfo.getBlurbTitle());
    bulrbTitleLabel.setId("blurbTitle");
    bulrbTitleLabel.setAlignment(Pos.TOP_CENTER);

    HBox titleBox = new HBox();
    titleBox.setId("titleBar");
    titleBox.setAlignment(Pos.TOP_CENTER);
    titleBox.getChildren().addAll(bulrbTitleLabel);
    return titleBox;
}
 
public CategoryNode() {
	setAlignment(Pos.TOP_CENTER);

	taComment.setEditable(false);

	Label lblComment = new Label(bundle.getString("Popups.ChooseCustomControl.Category.All.comment"));
	lblComment.setAlignment(Pos.TOP_CENTER);

	VBox vbox = new VBox(5, lblComment, stackPaneComment);
	VBox.setVgrow(stackPaneComment, Priority.ALWAYS);
	stackPaneComment.setAlignment(Pos.TOP_CENTER);
	vbox.setAlignment(Pos.TOP_CENTER);
	vbox.setFillWidth(true);
	getChildren().add(vbox);
}
 
源代码15 项目: Medusa   文件: AmpSkin.java
private void initGraphics() {
    // Set initial size
    if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) {
        if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) {
            gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight());
        } else {
            gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    ticksAndSectionsCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ticksAndSections       = ticksAndSectionsCanvas.getGraphicsContext2D();

    ledCanvas = new Canvas();
    led       = ledCanvas.getGraphicsContext2D();

    thresholdTooltip = new Tooltip("Threshold\n(" + String.format(locale, formatString, gauge.getThreshold()) + ")");
    thresholdTooltip.setTextAlignment(TextAlignment.CENTER);

    threshold = new Path();
    Helper.enableNode(threshold, gauge.isThresholdVisible());
    Tooltip.install(threshold, thresholdTooltip);

    average = new Path();
    Helper.enableNode(average, gauge.isAverageVisible());

    markerPane = new Pane();

    needleRotate = new Rotate(180 - START_ANGLE);
    needleRotate.setAngle(needleRotate.getAngle() + (gauge.getValue() - oldValue - gauge.getMinValue()) * angleStep);

    needleMoveTo1       = new MoveTo();
    needleCubicCurveTo2 = new CubicCurveTo();
    needleCubicCurveTo3 = new CubicCurveTo();
    needleCubicCurveTo4 = new CubicCurveTo();
    needleLineTo5       = new LineTo();
    needleCubicCurveTo6 = new CubicCurveTo();
    needleClosePath7    = new ClosePath();
    needle              = new Path(needleMoveTo1, needleCubicCurveTo2, needleCubicCurveTo3, needleCubicCurveTo4, needleLineTo5, needleCubicCurveTo6, needleClosePath7);
    needle.setFillRule(FillRule.EVEN_ODD);
    needle.getTransforms().setAll(needleRotate);

    dropShadow = new DropShadow();
    dropShadow.setColor(Color.rgb(0, 0, 0, 0.25));
    dropShadow.setBlurType(BlurType.TWO_PASS_BOX);
    dropShadow.setRadius(0.015 * PREFERRED_WIDTH);
    dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH);

    shadowGroup = new Group(needle);
    shadowGroup.setEffect(gauge.isShadowsEnabled() ? dropShadow : null);

    titleText = new Text(gauge.getTitle());
    titleText.setTextOrigin(VPos.CENTER);
    titleText.setFill(gauge.getTitleColor());
    Helper.enableNode(titleText, !gauge.getTitle().isEmpty());

    unitText = new Text(gauge.getUnit());
    unitText.setMouseTransparent(true);
    unitText.setTextOrigin(VPos.CENTER);

    lcd = new Rectangle(0.3 * PREFERRED_WIDTH, 0.1 * PREFERRED_HEIGHT);
    lcd.setArcWidth(0.0125 * PREFERRED_HEIGHT);
    lcd.setArcHeight(0.0125 * PREFERRED_HEIGHT);
    lcd.relocate((PREFERRED_WIDTH - lcd.getWidth()) * 0.5, 0.44 * PREFERRED_HEIGHT);
    Helper.enableNode(lcd, gauge.isLcdVisible() && gauge.isValueVisible());

    lcdText = new Label(String.format(locale, "%." + gauge.getDecimals() + "f", gauge.getValue()));
    lcdText.setAlignment(Pos.CENTER_RIGHT);
    lcdText.setVisible(gauge.isValueVisible());

    // Set initial value
    angleStep          = ANGLE_RANGE / gauge.getRange();
    double targetAngle = 180 - START_ANGLE + (gauge.getValue() - gauge.getMinValue()) * angleStep;
    targetAngle        = clamp(180 - START_ANGLE, 180 - START_ANGLE + ANGLE_RANGE, targetAngle);
    needleRotate.setAngle(targetAngle);

    lightEffect = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.65), 2, 0.0, 0.0, 2.0);

    foreground = new SVGPath();
    foreground.setContent("M 26 26.5 C 26 20.2432 26.2432 20 32.5 20 L 277.5 20 C 283.7568 20 284 20.2432 284 26.5 L 284 143.5 C 284 149.7568 283.7568 150 277.5 150 L 32.5 150 C 26.2432 150 26 149.7568 26 143.5 L 26 26.5 ZM 0 6.7241 L 0 253.2758 C 0 260 0 260 6.75 260 L 303.25 260 C 310 260 310 260 310 253.2758 L 310 6.7241 C 310 0 310 0 303.25 0 L 6.75 0 C 0 0 0 0 0 6.7241 Z");
    foreground.setEffect(lightEffect);

    // Add all nodes
    pane = new Pane();
    pane.getChildren().setAll(ticksAndSectionsCanvas,
                              markerPane,
                              ledCanvas,
                              unitText,
                              lcd,
                              lcdText,
                              shadowGroup,
                              foreground,
                              titleText);

    getChildren().setAll(pane);
}
 
源代码16 项目: redtorch   文件: CombinationLayout.java
private void createLayout() {
	hBox.getChildren().clear();

	VBox leftVbox = new VBox();

	Label allTodayProfitLabel = new Label("今日盈亏(率):");
	allTodayProfitLabel.setMinWidth(labelWidth);
	allTodayProfitLabel.setAlignment(Pos.CENTER_RIGHT);
	allTodayProfitLabel.getStyleClass().add("trade-label");

	HBox allTodayProfitHBox = new HBox();
	allTodayProfitHBox.getChildren().add(allTodayProfitLabel);
	allTodayProfitHBox.getChildren().add(allTodayProfitText);
	leftVbox.getChildren().add(allTodayProfitHBox);

	Label allBalanceLabel = new Label("资金:");
	allBalanceLabel.setMinWidth(labelWidth);
	allBalanceLabel.setAlignment(Pos.CENTER_RIGHT);
	allBalanceLabel.getStyleClass().add("trade-label");
	HBox allBalanceHBox = new HBox();
	allBalanceHBox.getChildren().add(allBalanceLabel);
	allBalanceHBox.getChildren().add(allBalanceText);
	leftVbox.getChildren().add(allBalanceHBox);

	Label allOpenPositionProfitLabel = new Label("持仓盈亏:");
	allOpenPositionProfitLabel.setMinWidth(labelWidth);
	allOpenPositionProfitLabel.setAlignment(Pos.CENTER_RIGHT);
	allOpenPositionProfitLabel.getStyleClass().add("trade-label");
	HBox allOpenPositionProfitHBox = new HBox();
	allOpenPositionProfitHBox.getChildren().add(allOpenPositionProfitLabel);
	allOpenPositionProfitHBox.getChildren().add(allOpenPositionProfitText);
	leftVbox.getChildren().add(allOpenPositionProfitHBox);

	hBox.getChildren().add(leftVbox);
	HBox.setHgrow(leftVbox, Priority.ALWAYS);

	VBox centerVbox = new VBox();

	Label allPositionProfitLabel = new Label("盯市持仓盈亏:");
	allPositionProfitLabel.setMinWidth(labelWidth);
	allPositionProfitLabel.setAlignment(Pos.CENTER_RIGHT);
	allPositionProfitLabel.getStyleClass().add("trade-label");
	HBox allPositionProfitHBox = new HBox();
	allPositionProfitHBox.getChildren().add(allPositionProfitLabel);
	allPositionProfitHBox.getChildren().add(allPositionProfitText);
	centerVbox.getChildren().add(allPositionProfitHBox);

	Label allMarginLabel = new Label("保证金(率):");
	allMarginLabel.setMinWidth(labelWidth);
	allMarginLabel.setAlignment(Pos.CENTER_RIGHT);
	allMarginLabel.getStyleClass().add("trade-label");
	HBox allMarginHBox = new HBox();
	allMarginHBox.getChildren().add(allMarginLabel);
	allMarginHBox.getChildren().add(allMarginText);
	centerVbox.getChildren().add(allMarginHBox);

	Label allCommissionLabel = new Label("佣金:");
	allCommissionLabel.setMinWidth(labelWidth);
	allCommissionLabel.setAlignment(Pos.CENTER_RIGHT);
	allCommissionLabel.getStyleClass().add("trade-label");
	HBox allCommissionHBox = new HBox();
	allCommissionHBox.getChildren().add(allCommissionLabel);
	allCommissionHBox.getChildren().add(allCommissionText);
	centerVbox.getChildren().add(allCommissionHBox);

	hBox.getChildren().add(centerVbox);
	HBox.setHgrow(centerVbox, Priority.ALWAYS);

	VBox rightVbox = new VBox();

	Label allCloseProfitLabel = new Label("盯市平仓盈亏:");
	allCloseProfitLabel.setMinWidth(labelWidth);
	allCloseProfitLabel.setAlignment(Pos.CENTER_RIGHT);
	allCloseProfitLabel.getStyleClass().add("trade-label");
	HBox allCloseProfitHBox = new HBox();
	allCloseProfitHBox.getChildren().add(allCloseProfitLabel);
	allCloseProfitHBox.getChildren().add(allCloseProfitText);
	rightVbox.getChildren().add(allCloseProfitHBox);

	Label allContractValueLabel = new Label("合约价值:");
	allContractValueLabel.setMinWidth(labelWidth);
	allContractValueLabel.setAlignment(Pos.CENTER_RIGHT);
	allContractValueLabel.getStyleClass().add("trade-label");
	HBox allContractValueHBox = new HBox();
	allContractValueHBox.getChildren().add(allContractValueLabel);
	allContractValueHBox.getChildren().add(allContractValueText);
	rightVbox.getChildren().add(allContractValueHBox);

	Label allDepositAndWithdrawLabel = new Label("出入金:");
	allDepositAndWithdrawLabel.setMinWidth(labelWidth);
	allDepositAndWithdrawLabel.setAlignment(Pos.CENTER_RIGHT);
	allDepositAndWithdrawLabel.getStyleClass().add("trade-label");
	HBox allDepositAndWithdrawHBox = new HBox();
	allDepositAndWithdrawHBox.getChildren().add(allDepositAndWithdrawLabel);
	allDepositAndWithdrawHBox.getChildren().add(allDepositAndWithdrawText);
	rightVbox.getChildren().add(allDepositAndWithdrawHBox);

	hBox.getChildren().add(rightVbox);
	HBox.setHgrow(rightVbox, Priority.ALWAYS);

}
 
源代码17 项目: chart-fx   文件: ZoomerSample.java
@Override
public void start(final Stage primaryStage) {
    final FlowPane root = new FlowPane();
    root.setAlignment(Pos.CENTER);

    DataSet testDataSet = generateData();

    Label label = new Label("left-click-hold-drag for zooming. middle-button for panning.\n"
                            + "Tip: drag horizontally/vertically/diagonally for testing; try to select the outlier");
    label.setFont(Font.font(20));
    label.setAlignment(Pos.CENTER);
    label.setContentDisplay(ContentDisplay.CENTER);
    label.setPrefWidth(2.0 * PREF_WIDTH);

    // chart with default zoom
    final Chart chart1 = getTestChart("default zoom", testDataSet);
    Zoomer zoomer1 = new Zoomer();
    registerZoomerChangeListener(zoomer1, chart1.getTitle());
    chart1.getPlugins().add(zoomer1);

    // chart with auto xy zoom
    final Chart chart2 = getTestChart("auto xy zoom", testDataSet);
    final Zoomer zoomer2 = new Zoomer();
    zoomer2.setAutoZoomEnabled(true);
    registerZoomerChangeListener(zoomer2, chart2.getTitle());
    chart2.getPlugins().add(zoomer2);

    // chart with x-only zoom
    final Chart chart3 = getTestChart("x-only zoom", testDataSet);
    Zoomer zoomer3 = new Zoomer(AxisMode.X);
    registerZoomerChangeListener(zoomer3, chart3.getTitle());
    chart3.getPlugins().add(zoomer3);

    // chart with x-only zoom
    final Chart chart4 = getTestChart("y-only zoom", testDataSet);
    Zoomer zoomer4 = new Zoomer(AxisMode.Y);
    registerZoomerChangeListener(zoomer4, chart4.getTitle());
    chart4.getPlugins().add(zoomer4);

    root.getChildren().addAll(chart1, chart2, chart3, chart4, label);

    primaryStage.setTitle(this.getClass().getSimpleName());
    primaryStage.setScene(new Scene(root));
    primaryStage.setOnCloseRequest(evt -> Platform.exit());
    primaryStage.show();
}
 
源代码18 项目: ShootOFF   文件: ProjectorArenaPane.java
public ProjectorArenaPane(Stage arenaStage, Stage shootOffStage, Pane trainingExerciseContainer, Resetter resetter,
		ObservableList<ShotEntry> shotTimerModel) {
	config = Configuration.getConfig();

	arenaCanvasGroup = new Group();
	calibrationLabel = new Label("Needs Calibration");
	calibrationLabel.setFont(Font.font(48));
	calibrationLabel.setTextFill(Color.web("#f5a807"));
	calibrationLabel.setLayoutX(6);
	calibrationLabel.setLayoutY(6);
	calibrationLabel.setPrefSize(628, 90);
	calibrationLabel.setAlignment(Pos.CENTER);

	getChildren().addAll(arenaCanvasGroup, calibrationLabel);

	this.shootOffStage = shootOffStage;
	this.arenaStage = arenaStage;
	this.trainingExerciseContainer = trainingExerciseContainer;

	if (config.isHeadless()) {
		canvasManager = new CanvasManager(arenaCanvasGroup, resetter, "arena", shotTimerModel);
	} else {
		canvasManager = new MirroredCanvasManager(arenaCanvasGroup, resetter, "arena", shotTimerModel, this);
	}

	setPrefSize(640, 480);

	setOnKeyPressed((event) -> canvasKeyPressed(event));

	setOnMouseEntered((event) -> requestFocus());

	setOnMouseClicked((event) -> {
		canvasManager.toggleTargetSelection(Optional.empty());
	});

	arenaStage.widthProperty().addListener((e) -> {
		canvasManager.setBackgroundFit(arenaStage.getWidth(), arenaStage.getHeight());
	});

	arenaStage.heightProperty().addListener((e) -> {
		canvasManager.setBackgroundFit(arenaStage.getWidth(), arenaStage.getHeight());
	});

	setStyle("-fx-background-color: #333333;");
}
 
源代码19 项目: marathonv5   文件: HeatTabController.java
private void createStateLabels() {
    Group overlay = map.getOverlayGroup();
    for(String state: Region.ALL_STATES) {
        Node stateNode = map.lookup("#"+state);
        if (stateNode != null) {
            Label label = new Label("+10");
            label.getStyleClass().add("heatmap-label");
            label.setTextAlignment(TextAlignment.CENTER);
            label.setAlignment(Pos.CENTER);
            label.setManaged(false);
            label.setOpacity(0);
            label.setVisible(false);
            Bounds stateBounds = stateNode.getBoundsInParent();
            if ("DE".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()-25, stateBounds.getMinY(), 
                        stateBounds.getWidth()+50, stateBounds.getHeight());
            } else if ("VT".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()-25, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("NH".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()+30, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("MA".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()-20, stateBounds.getMinY()-18, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("RI".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY(), 
                        stateBounds.getWidth()+40, stateBounds.getHeight());
            } else if ("ID".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()+60, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("MI".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()+60, stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("FL".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()+95, stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("LA".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()-50, stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            }
            stateLabelMap.put(state, label);
            overlay.getChildren().add(label);
        }
    }
}
 
源代码20 项目: marathonv5   文件: HeatTabController.java
private void createStateLabels() {
    Group overlay = map.getOverlayGroup();
    for(String state: Region.ALL_STATES) {
        Node stateNode = map.lookup("#"+state);
        if (stateNode != null) {
            Label label = new Label("+10");
            label.getStyleClass().add("heatmap-label");
            label.setTextAlignment(TextAlignment.CENTER);
            label.setAlignment(Pos.CENTER);
            label.setManaged(false);
            label.setOpacity(0);
            label.setVisible(false);
            Bounds stateBounds = stateNode.getBoundsInParent();
            if ("DE".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()-25, stateBounds.getMinY(), 
                        stateBounds.getWidth()+50, stateBounds.getHeight());
            } else if ("VT".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()-25, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("NH".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()+30, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("MA".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()-20, stateBounds.getMinY()-18, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("RI".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY(), 
                        stateBounds.getWidth()+40, stateBounds.getHeight());
            } else if ("ID".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()+60, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("MI".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()+60, stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("FL".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()+95, stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("LA".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()-50, stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            }
            stateLabelMap.put(state, label);
            overlay.getChildren().add(label);
        }
    }
}